@opencx/widget-react 5.16.0 → 5.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Chart.impl-DIgeRBbD.js → Chart.impl-BV-FDx2F.js} +2 -2
- package/dist/{Chart.impl-DIgeRBbD.js.map → Chart.impl-BV-FDx2F.js.map} +1 -1
- package/dist/{Chart.impl-DJvHoxYS.cjs → Chart.impl-D9ZC6NM1.cjs} +2 -2
- package/dist/{Chart.impl-DJvHoxYS.cjs.map → Chart.impl-D9ZC6NM1.cjs.map} +1 -1
- package/dist/{index-CdukcwHL.cjs → index-B5DF6TVa.cjs} +38 -38
- package/dist/index-B5DF6TVa.cjs.map +1 -0
- package/dist/{index-fXZfP77e.js → index-ZDE0vbgt.js} +865 -864
- package/dist/index-ZDE0vbgt.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/load-voice-sdk.cjs +2 -0
- package/dist/load-voice-sdk.cjs.map +1 -0
- package/dist/load-voice-sdk.d.ts +2 -0
- package/dist/load-voice-sdk.js +7 -0
- package/dist/load-voice-sdk.js.map +1 -0
- package/dist/package.json.d.ts +1 -1
- package/dist/src/voice/VoiceCallProvider.d.ts.map +1 -1
- package/dist/src/voice/load-voice-sdk.d.ts +10 -0
- package/dist/src/voice/load-voice-sdk.d.ts.map +1 -0
- package/package.json +5 -5
- package/dist/index-CdukcwHL.cjs.map +0 -1
- package/dist/index-fXZfP77e.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`),o={...t};for(const s of n){const a=hr(s);a&&fa(o,a)}return o}var Qc="spec",el=`data-${Qc}`;function Wo(e,t,n){const o=tn(t);if(o.length===0)return e;const s={...e};let a=s;for(let c=0;c<o.length-1;c++){const d=o[c],l=a[d];if(Array.isArray(l))a[d]=[...l];else if(l!==null&&typeof l=="object")a[d]={...l};else{const m=o[c+1];a[d]=m!==void 0&&/^\d+$/.test(m)?[]:{}}a=a[d]}const i=o[o.length-1];return Array.isArray(a)?i==="-"?a.push(n):a[parseInt(i,10)]=n:a[i]=n,s}function tl(e={}){let t={...e};const n=new Set;function o(){for(const s of n)s()}return{get(s){return ce(t,s)},set(s,a){ce(t,s)!==a&&(t=Wo(t,s,a),o())},update(s){let a=!1,i=t;for(const[c,d]of Object.entries(s))ce(i,c)!==d&&(i=Wo(i,c,d),a=!0);a&&(t=i,o())},getSnapshot(){return t},getServerSnapshot(){return t},subscribe(s){return n.add(s),()=>{n.delete(s)}}}}var Kn=20;function Yr(e,t="",n=0,o,s){const a=o??new Set,i=s??{current:!1},c={};for(const[d,l]of Object.entries(e)){const m=`${t}/${d}`;n<Kn&&l!==null&&typeof l=="object"&&!Array.isArray(l)&&Object.getPrototypeOf(l)===Object.prototype&&!a.has(l)?(a.add(l),Object.assign(c,Yr(l,m,n+1,a,i))):(process.env.NODE_ENV!=="production"&&!i.current&&n>=Kn&&l!==null&&typeof l=="object"&&!Array.isArray(l)&&Object.getPrototypeOf(l)===Object.prototype&&!a.has(l)&&(i.current=!0,console.warn(`flattenToPointers: depth limit (${Kn}) reached. Nested state beyond this depth will be treated as a leaf value.`)),c[m]=l)}return c}var gn=S.z.union([S.z.number(),S.z.object({$state:S.z.string()})]),Xr={eq:S.z.unknown().optional(),neq:S.z.unknown().optional(),gt:gn.optional(),gte:gn.optional(),lt:gn.optional(),lte:gn.optional(),not:S.z.literal(!0).optional()},nl=S.z.object({$state:S.z.string(),...Xr}),rl=S.z.object({$item:S.z.string(),...Xr}),ol=S.z.object({$index:S.z.literal(!0),...Xr}),Bo=S.z.union([nl,rl,ol]),fr=S.z.lazy(()=>S.z.union([S.z.boolean(),Bo,S.z.array(Bo),S.z.object({$and:S.z.array(fr)}),S.z.object({$or:S.z.array(fr)})]));function Ct(e,t){return typeof e=="object"&&e!==null&&"$state"in e&&typeof e.$state=="string"?ce(t.stateModel,e.$state):e}function sl(e){return"$item"in e}function al(e){return"$index"in e}function il(e,t){return al(e)?t.repeatIndex:sl(e)?t.repeatItem===void 0?void 0:e.$item===""?t.repeatItem:ce(t.repeatItem,e.$item):ce(t.stateModel,e.$state)}function Uo(e,t){const n=il(e,t);let o;if(e.eq!==void 0){const s=Ct(e.eq,t);o=n===s}else if(e.neq!==void 0){const s=Ct(e.neq,t);o=n!==s}else if(e.gt!==void 0){const s=Ct(e.gt,t);o=typeof n=="number"&&typeof s=="number"?n>s:!1}else if(e.gte!==void 0){const s=Ct(e.gte,t);o=typeof n=="number"&&typeof s=="number"?n>=s:!1}else if(e.lt!==void 0){const s=Ct(e.lt,t);o=typeof n=="number"&&typeof s=="number"?n<s:!1}else if(e.lte!==void 0){const s=Ct(e.lte,t);o=typeof n=="number"&&typeof s=="number"?n<=s:!1}else o=!!n;return e.not===!0?!o:o}function cl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"$and"in e}function ll(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"$or"in e}function At(e,t){return e===void 0?!0:typeof e=="boolean"?e:Array.isArray(e)?e.every(n=>Uo(n,t)):cl(e)?e.$and.every(n=>At(n,t)):ll(e)?e.$or.some(n=>At(n,t)):Uo(e,t)}function dl(e){const t=new Map;for(const n of e)t.set(n.name,n);return t}function ul(e,t){if(!t||t.size===0)return;let n;for(const[o,s]of t)if(o in e){if(n)throw new Error(`Ambiguous directive: object has multiple directive keys ("${n.name}" and "${o}")`);n=s}return n}function pl(e){return typeof e=="object"&&e!==null&&"$state"in e&&typeof e.$state=="string"}function ga(e){return typeof e=="object"&&e!==null&&"$item"in e&&typeof e.$item=="string"}function xa(e){return typeof e=="object"&&e!==null&&"$index"in e&&e.$index===!0}function ba(e){return typeof e=="object"&&e!==null&&"$bindState"in e&&typeof e.$bindState=="string"}function wa(e){return typeof e=="object"&&e!==null&&"$bindItem"in e&&typeof e.$bindItem=="string"}function ml(e){return typeof e=="object"&&e!==null&&"$cond"in e&&"$then"in e&&"$else"in e}function hl(e){return typeof e=="object"&&e!==null&&"$computed"in e&&typeof e.$computed=="string"}function fl(e){return typeof e=="object"&&e!==null&&"$template"in e&&typeof e.$template=="string"}var gl=100,Zn=new Set;function Gr(e,t){if(t.repeatBasePath==null){console.warn(`$bindItem used outside repeat scope: "${e}"`);return}return e===""?t.repeatBasePath:t.repeatBasePath+"/"+e}function ut(e,t){var n;if(e==null)return e;if(pl(e))return ce(t.stateModel,e.$state);if(ga(e))return t.repeatItem===void 0?void 0:e.$item===""?t.repeatItem:ce(t.repeatItem,e.$item);if(xa(e))return t.repeatIndex;if(ba(e))return ce(t.stateModel,e.$bindState);if(wa(e)){const o=Gr(e.$bindItem,t);return o===void 0?void 0:ce(t.stateModel,o)}if(ml(e)){const o=At(e.$cond,t);return ut(o?e.$then:e.$else,t)}if(hl(e)){const o=(n=t.functions)==null?void 0:n[e.$computed];if(!o){Zn.has(e.$computed)||(Zn.size<gl&&Zn.add(e.$computed),console.warn(`Unknown $computed function: "${e.$computed}"`));return}const s={};if(e.args)for(const[a,i]of Object.entries(e.args))s[a]=ut(i,t);return o(s)}if(fl(e))return e.$template.replace(/\$\{([^}]+)\}/g,(o,s)=>{if(s.startsWith("/")){const i=ce(t.stateModel,s);return i!=null?String(i):""}if(t.repeatItem!==void 0){const i=ce(t.repeatItem,s);if(i!=null)return String(i)}const a=ce(t.stateModel,"/"+s);return a!=null?String(a):""});if(Array.isArray(e))return e.map(o=>ut(o,t));if(typeof e=="object"){const o=ul(e,t.directives);if(o)return o.resolve(e,t);const s={};for(const[a,i]of Object.entries(e))s[a]=ut(i,t);return s}return e}function xl(e,t){const n={};for(const[o,s]of Object.entries(e))n[o]=ut(s,t);return n}function bl(e,t){let n;for(const[o,s]of Object.entries(e))if(ba(s))n||(n={}),n[o]=s.$bindState;else if(wa(s)){const a=Gr(s.$bindItem,t);a!==void 0&&(n||(n={}),n[o]=a)}return n}function qo(e,t){return ga(e)?Gr(e.$item,t):xa(e)?t.repeatIndex:ut(e,t)}var va=new Set;function wl(e){for(const t of va){const n=t.onDispatch;if(n)try{n(e)}catch(o){process.env.NODE_ENV!=="production"&&console.error("[json-render] action observer threw in onDispatch:",o)}}}function vl(e){for(const t of va){const n=t.onSettle;if(n)try{n(e)}catch(o){process.env.NODE_ENV!=="production"&&console.error("[json-render] action observer threw in onSettle:",o)}}}var Vo=0;function yl(){return Vo+=1,`${Date.now()}-${Vo}`}var kl=0,Yo=new Set;function jl(){return kl>0}function Cl(e){return Yo.add(e),()=>{Yo.delete(e)}}var Sl=S.z.object({title:S.z.string(),message:S.z.string(),confirmLabel:S.z.string().optional(),cancelLabel:S.z.string().optional(),variant:S.z.enum(["default","danger"]).optional()}),Nl=S.z.union([S.z.object({navigate:S.z.string()}),S.z.object({set:S.z.record(S.z.string(),S.z.unknown())}),S.z.object({action:S.z.string()})]),_l=S.z.union([S.z.object({set:S.z.record(S.z.string(),S.z.unknown())}),S.z.object({action:S.z.string()})]);S.z.object({action:S.z.string(),params:S.z.record(S.z.string(),pa).optional(),confirm:Sl.optional(),onSuccess:Nl.optional(),onError:_l.optional(),preventDefault:S.z.boolean().optional()});function El(e,t){const n={};if(e.params)for(const[s,a]of Object.entries(e.params))n[s]=ma(a,t);let o=e.confirm;return o&&(o={...o,message:Xo(o.message,t),title:Xo(o.title,t)}),{action:e.action,params:n,confirm:o,onSuccess:e.onSuccess,onError:e.onError}}function Xo(e,t){return e.replace(/\$\{([^}]+)\}/g,(n,o)=>{const s=ma({$state:o},t);return String(s??"")})}async function Go(e){const{action:t,handler:n,setState:o,navigate:s,executeAction:a}=e;try{if(await n(t.params),t.onSuccess)if("navigate"in t.onSuccess&&s)s(t.onSuccess.navigate);else if("set"in t.onSuccess)for(const[i,c]of Object.entries(t.onSuccess.set))o(i,c);else"action"in t.onSuccess&&a&&await a(t.onSuccess.action)}catch(i){if(t.onError)if("set"in t.onError)for(const[c,d]of Object.entries(t.onError.set)){const l=typeof d=="string"&&d==="$error.message"?i.message:d;o(c,l)}else"action"in t.onError&&a&&await a(t.onError.action);else throw i}}var Al=S.z.object({type:S.z.string(),args:S.z.record(S.z.string(),pa).optional(),message:S.z.string()});S.z.object({checks:S.z.array(Al).optional(),validateOn:S.z.enum(["change","blur","submit"]).optional(),enabled:fr.optional()});var Ko=(e,t)=>{const n=t==null?void 0:t.other;return e===n},Tl={required:e=>e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0,email:e=>typeof e!="string"?!1:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),minLength:(e,t)=>{if(typeof e!="string")return!1;const n=t==null?void 0:t.min;return typeof n!="number"?!1:e.length>=n},maxLength:(e,t)=>{if(typeof e!="string")return!1;const n=t==null?void 0:t.max;return typeof n!="number"?!1:e.length<=n},pattern:(e,t)=>{if(typeof e!="string")return!1;const n=t==null?void 0:t.pattern;if(typeof n!="string")return!1;try{return new RegExp(n).test(e)}catch{return!1}},min:(e,t)=>{if(typeof e!="number")return!1;const n=t==null?void 0:t.min;return typeof n!="number"?!1:e>=n},max:(e,t)=>{if(typeof e!="number")return!1;const n=t==null?void 0:t.max;return typeof n!="number"?!1:e<=n},numeric:e=>typeof e=="number"?!isNaN(e):typeof e=="string"?!isNaN(parseFloat(e)):!1,url:e=>{if(typeof e!="string")return!1;try{return new URL(e),!0}catch{return!1}},matches:Ko,equalTo:Ko,lessThan:(e,t)=>{const n=t==null?void 0:t.other;if(e==null||n==null||e===""||n==="")return!1;if(typeof e=="number"&&typeof n=="number"||typeof e=="string"&&typeof n=="string")return e<n;const o=Number(e),s=Number(n);return!isNaN(o)&&!isNaN(s)?o<s:!1},greaterThan:(e,t)=>{const n=t==null?void 0:t.other;if(e==null||n==null||e===""||n==="")return!1;if(typeof e=="number"&&typeof n=="number"||typeof e=="string"&&typeof n=="string")return e>n;const o=Number(e),s=Number(n);return!isNaN(o)&&!isNaN(s)?o>s:!1},requiredIf:(e,t)=>(t==null?void 0:t.field)?e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0:!0};function Il(e,t){const{value:n,stateModel:o,customFunctions:s}=t,a={};if(e.args)for(const[d,l]of Object.entries(e.args))a[d]=ut(l,{stateModel:o});const i=Tl[e.type]??(s==null?void 0:s[e.type]);if(!i)return console.warn(`Unknown validation function: ${e.type}`),{type:e.type,valid:!0,message:e.message};const c=i(n,a);return{type:e.type,valid:c,message:e.message}}function zl(e,t){const n=[],o=[];if(e.enabled&&!At(e.enabled,{stateModel:t.stateModel}))return{valid:!0,errors:[],checks:[]};if(e.checks)for(const s of e.checks){const a=Il(s,t);n.push(a),a.valid||o.push(a.message)}return{valid:o.length===0,errors:o,checks:n}}var Ml=["patch"];function Rl(e){var t;return(t=e==null?void 0:e.modes)!=null&&t.length?e.modes:Ml}function Pl(){return["PATCH MODE (RFC 6902 JSON Patch):","Output one JSON object per line. Each line is a patch operation.",'- Add: {"op":"add","path":"/elements/new-key","value":{...}}','- Replace: {"op":"replace","path":"/elements/existing-key","value":{...}}','- Remove: {"op":"remove","path":"/elements/old-key"}',"Only output patches for what needs to change."].join(`
|
|
3
|
-
`)}function
|
|
4
|
-
`)}function
|
|
5
|
-
`)}function
|
|
6
|
-
`)}function
|
|
7
|
-
`)}function
|
|
1
|
+
"use strict";var Ac=Object.defineProperty;var Tc=(e,t,n)=>t in e?Ac(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var $o=(e,t,n)=>Tc(e,typeof t!="symbol"?t+"":t,n);const r=require("react/jsx-runtime"),Ic=require("@radix-ui/react-popover"),F=require("framer-motion"),u=require("react"),C=require("@opencx/widget-react-headless"),S=require("zod"),K=require("@opencx/widget-core"),M=require("lucide-react"),zc=require("clsx"),Mc=require("tailwind-merge"),Rc=require("@radix-ui/react-slot"),ia=require("class-variance-authority"),ca=require("remark-gfm"),Pc=require("react-markdown"),ur=require("rehype-raw"),ye=require("rehype-sanitize"),Oc=require("@radix-ui/react-avatar"),la=require("@uiw/react-iframe"),Do=require("tinycolor2"),Lc=require("@radix-ui/react-tooltip"),Qt=require("react-dom"),$c=require("@radix-ui/react-menu"),Dc=require("html-to-image"),Fc=require("./load-voice-sdk.cjs"),Hc=require("react-dropzone"),da=require("@shardsui/notation"),Rn=require("react-use");function en(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const et=en(Ic),ot=en(u),Rt=en(Oc),Ie=en(Lc),Ae=en($c);var ua=S.z.union([S.z.string(),S.z.number(),S.z.boolean(),S.z.null(),S.z.object({$state:S.z.string()})]);S.z.union([S.z.string(),S.z.object({$state:S.z.string()})]);S.z.union([S.z.number(),S.z.object({$state:S.z.string()})]);S.z.union([S.z.boolean(),S.z.object({$state:S.z.string()})]);function pa(e,t){if(e!=null)return typeof e=="object"&&"$state"in e?ce(t,e.$state):e}function Wc(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function tn(e){return(e.startsWith("/")?e.slice(1).split("/"):e.split("/")).map(Wc)}function ce(e,t){if(!t||t==="/")return e;const n=tn(t);let o=e;for(const s of n){if(o==null)return;if(Array.isArray(o)){const a=parseInt(s,10);o=o[a]}else if(typeof o=="object")o=o[s];else return}return o}function ma(e){return/^\d+$/.test(e)}function Bc(e,t,n){const o=tn(t);if(o.length===0)return;let s=e;for(let i=0;i<o.length-1;i++){const c=o[i],d=o[i+1],l=d!==void 0&&(ma(d)||d==="-");if(Array.isArray(s)){const m=parseInt(c,10);(s[m]===void 0||typeof s[m]!="object")&&(s[m]=l?[]:{}),s=s[m]}else(!(c in s)||typeof s[c]!="object")&&(s[c]=l?[]:{}),s=s[c]}const a=o[o.length-1];if(Array.isArray(s))if(a==="-")s.push(n);else{const i=parseInt(a,10);s[i]=n}else s[a]=n}function Xn(e,t,n){const o=tn(t);if(o.length===0)return;let s=e;for(let i=0;i<o.length-1;i++){const c=o[i],d=o[i+1],l=d!==void 0&&(ma(d)||d==="-");if(Array.isArray(s)){const m=parseInt(c,10);(s[m]===void 0||typeof s[m]!="object")&&(s[m]=l?[]:{}),s=s[m]}else(!(c in s)||typeof s[c]!="object")&&(s[c]=l?[]:{}),s=s[c]}const a=o[o.length-1];if(Array.isArray(s))if(a==="-")s.push(n);else{const i=parseInt(a,10);s.splice(i,0,n)}else s[a]=n}function Fo(e,t){const n=tn(t);if(n.length===0)return;let o=e;for(let a=0;a<n.length-1;a++){const i=n[a];if(Array.isArray(o)){const c=parseInt(i,10);if(o[c]===void 0||typeof o[c]!="object")return;o=o[c]}else{if(!(i in o)||typeof o[i]!="object")return;o=o[i]}}const s=n[n.length-1];if(Array.isArray(o)){const a=parseInt(s,10);a>=0&&a<o.length&&o.splice(a,1)}else delete o[s]}function pr(e,t){if(e===t)return!0;if(e===null||t===null||typeof e!=typeof t||typeof e!="object")return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((i,c)=>pr(i,t[c]));const n=e,o=t,s=Object.keys(n),a=Object.keys(o);return s.length!==a.length?!1:s.every(i=>pr(n[i],o[i]))}function mr(e){const t=e.trim();if(!t||!t.startsWith("{"))return null;try{const n=JSON.parse(t);return n.op&&n.path!==void 0?n:null}catch{return null}}function ha(e,t){switch(t.op){case"add":Xn(e,t.path,t.value);break;case"replace":Bc(e,t.path,t.value);break;case"remove":Fo(e,t.path);break;case"move":{if(!t.from)break;const n=ce(e,t.from);Fo(e,t.from),Xn(e,t.path,n);break}case"copy":{if(!t.from)break;const n=ce(e,t.from);Xn(e,t.path,n);break}case"test":{const n=ce(e,t.path);if(!pr(n,t.value))throw new Error(`Test operation failed: value at "${t.path}" does not match`);break}}return e}function Uc(e,t){return ha(e,t),e}function qc(e){const t={};let n=0;function o(i){const c=`el-${n++}`,{type:d,props:l,children:m,...p}=i,h=[];if(Array.isArray(m))for(const x of m)x&&typeof x=="object"&&"type"in x&&h.push(o(x));const f={type:d??"unknown",props:l??{},children:h};for(const[x,g]of Object.entries(p))x!=="state"&&g!==void 0&&(f[x]=g);return t[c]=f,c}const a={root:o(e),elements:t};return e.state&&typeof e.state=="object"&&!Array.isArray(e.state)&&(a.state=e.state),a}function Vc(e,t={}){const n=e.split(`
|
|
2
|
+
`),o={...t};for(const s of n){const a=mr(s);a&&ha(o,a)}return o}var Yc="spec",Xc=`data-${Yc}`;function Ho(e,t,n){const o=tn(t);if(o.length===0)return e;const s={...e};let a=s;for(let c=0;c<o.length-1;c++){const d=o[c],l=a[d];if(Array.isArray(l))a[d]=[...l];else if(l!==null&&typeof l=="object")a[d]={...l};else{const m=o[c+1];a[d]=m!==void 0&&/^\d+$/.test(m)?[]:{}}a=a[d]}const i=o[o.length-1];return Array.isArray(a)?i==="-"?a.push(n):a[parseInt(i,10)]=n:a[i]=n,s}function Gc(e={}){let t={...e};const n=new Set;function o(){for(const s of n)s()}return{get(s){return ce(t,s)},set(s,a){ce(t,s)!==a&&(t=Ho(t,s,a),o())},update(s){let a=!1,i=t;for(const[c,d]of Object.entries(s))ce(i,c)!==d&&(i=Ho(i,c,d),a=!0);a&&(t=i,o())},getSnapshot(){return t},getServerSnapshot(){return t},subscribe(s){return n.add(s),()=>{n.delete(s)}}}}var Gn=20;function Vr(e,t="",n=0,o,s){const a=o??new Set,i=s??{current:!1},c={};for(const[d,l]of Object.entries(e)){const m=`${t}/${d}`;n<Gn&&l!==null&&typeof l=="object"&&!Array.isArray(l)&&Object.getPrototypeOf(l)===Object.prototype&&!a.has(l)?(a.add(l),Object.assign(c,Vr(l,m,n+1,a,i))):(process.env.NODE_ENV!=="production"&&!i.current&&n>=Gn&&l!==null&&typeof l=="object"&&!Array.isArray(l)&&Object.getPrototypeOf(l)===Object.prototype&&!a.has(l)&&(i.current=!0,console.warn(`flattenToPointers: depth limit (${Gn}) reached. Nested state beyond this depth will be treated as a leaf value.`)),c[m]=l)}return c}var gn=S.z.union([S.z.number(),S.z.object({$state:S.z.string()})]),Yr={eq:S.z.unknown().optional(),neq:S.z.unknown().optional(),gt:gn.optional(),gte:gn.optional(),lt:gn.optional(),lte:gn.optional(),not:S.z.literal(!0).optional()},Kc=S.z.object({$state:S.z.string(),...Yr}),Zc=S.z.object({$item:S.z.string(),...Yr}),Jc=S.z.object({$index:S.z.literal(!0),...Yr}),Wo=S.z.union([Kc,Zc,Jc]),hr=S.z.lazy(()=>S.z.union([S.z.boolean(),Wo,S.z.array(Wo),S.z.object({$and:S.z.array(hr)}),S.z.object({$or:S.z.array(hr)})]));function Ct(e,t){return typeof e=="object"&&e!==null&&"$state"in e&&typeof e.$state=="string"?ce(t.stateModel,e.$state):e}function Qc(e){return"$item"in e}function el(e){return"$index"in e}function tl(e,t){return el(e)?t.repeatIndex:Qc(e)?t.repeatItem===void 0?void 0:e.$item===""?t.repeatItem:ce(t.repeatItem,e.$item):ce(t.stateModel,e.$state)}function Bo(e,t){const n=tl(e,t);let o;if(e.eq!==void 0){const s=Ct(e.eq,t);o=n===s}else if(e.neq!==void 0){const s=Ct(e.neq,t);o=n!==s}else if(e.gt!==void 0){const s=Ct(e.gt,t);o=typeof n=="number"&&typeof s=="number"?n>s:!1}else if(e.gte!==void 0){const s=Ct(e.gte,t);o=typeof n=="number"&&typeof s=="number"?n>=s:!1}else if(e.lt!==void 0){const s=Ct(e.lt,t);o=typeof n=="number"&&typeof s=="number"?n<s:!1}else if(e.lte!==void 0){const s=Ct(e.lte,t);o=typeof n=="number"&&typeof s=="number"?n<=s:!1}else o=!!n;return e.not===!0?!o:o}function nl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"$and"in e}function rl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"$or"in e}function At(e,t){return e===void 0?!0:typeof e=="boolean"?e:Array.isArray(e)?e.every(n=>Bo(n,t)):nl(e)?e.$and.every(n=>At(n,t)):rl(e)?e.$or.some(n=>At(n,t)):Bo(e,t)}function ol(e){const t=new Map;for(const n of e)t.set(n.name,n);return t}function sl(e,t){if(!t||t.size===0)return;let n;for(const[o,s]of t)if(o in e){if(n)throw new Error(`Ambiguous directive: object has multiple directive keys ("${n.name}" and "${o}")`);n=s}return n}function al(e){return typeof e=="object"&&e!==null&&"$state"in e&&typeof e.$state=="string"}function fa(e){return typeof e=="object"&&e!==null&&"$item"in e&&typeof e.$item=="string"}function ga(e){return typeof e=="object"&&e!==null&&"$index"in e&&e.$index===!0}function xa(e){return typeof e=="object"&&e!==null&&"$bindState"in e&&typeof e.$bindState=="string"}function ba(e){return typeof e=="object"&&e!==null&&"$bindItem"in e&&typeof e.$bindItem=="string"}function il(e){return typeof e=="object"&&e!==null&&"$cond"in e&&"$then"in e&&"$else"in e}function cl(e){return typeof e=="object"&&e!==null&&"$computed"in e&&typeof e.$computed=="string"}function ll(e){return typeof e=="object"&&e!==null&&"$template"in e&&typeof e.$template=="string"}var dl=100,Kn=new Set;function Xr(e,t){if(t.repeatBasePath==null){console.warn(`$bindItem used outside repeat scope: "${e}"`);return}return e===""?t.repeatBasePath:t.repeatBasePath+"/"+e}function ut(e,t){var n;if(e==null)return e;if(al(e))return ce(t.stateModel,e.$state);if(fa(e))return t.repeatItem===void 0?void 0:e.$item===""?t.repeatItem:ce(t.repeatItem,e.$item);if(ga(e))return t.repeatIndex;if(xa(e))return ce(t.stateModel,e.$bindState);if(ba(e)){const o=Xr(e.$bindItem,t);return o===void 0?void 0:ce(t.stateModel,o)}if(il(e)){const o=At(e.$cond,t);return ut(o?e.$then:e.$else,t)}if(cl(e)){const o=(n=t.functions)==null?void 0:n[e.$computed];if(!o){Kn.has(e.$computed)||(Kn.size<dl&&Kn.add(e.$computed),console.warn(`Unknown $computed function: "${e.$computed}"`));return}const s={};if(e.args)for(const[a,i]of Object.entries(e.args))s[a]=ut(i,t);return o(s)}if(ll(e))return e.$template.replace(/\$\{([^}]+)\}/g,(o,s)=>{if(s.startsWith("/")){const i=ce(t.stateModel,s);return i!=null?String(i):""}if(t.repeatItem!==void 0){const i=ce(t.repeatItem,s);if(i!=null)return String(i)}const a=ce(t.stateModel,"/"+s);return a!=null?String(a):""});if(Array.isArray(e))return e.map(o=>ut(o,t));if(typeof e=="object"){const o=sl(e,t.directives);if(o)return o.resolve(e,t);const s={};for(const[a,i]of Object.entries(e))s[a]=ut(i,t);return s}return e}function ul(e,t){const n={};for(const[o,s]of Object.entries(e))n[o]=ut(s,t);return n}function pl(e,t){let n;for(const[o,s]of Object.entries(e))if(xa(s))n||(n={}),n[o]=s.$bindState;else if(ba(s)){const a=Xr(s.$bindItem,t);a!==void 0&&(n||(n={}),n[o]=a)}return n}function Uo(e,t){return fa(e)?Xr(e.$item,t):ga(e)?t.repeatIndex:ut(e,t)}var wa=new Set;function ml(e){for(const t of wa){const n=t.onDispatch;if(n)try{n(e)}catch(o){process.env.NODE_ENV!=="production"&&console.error("[json-render] action observer threw in onDispatch:",o)}}}function hl(e){for(const t of wa){const n=t.onSettle;if(n)try{n(e)}catch(o){process.env.NODE_ENV!=="production"&&console.error("[json-render] action observer threw in onSettle:",o)}}}var qo=0;function fl(){return qo+=1,`${Date.now()}-${qo}`}var gl=0,Vo=new Set;function xl(){return gl>0}function bl(e){return Vo.add(e),()=>{Vo.delete(e)}}var wl=S.z.object({title:S.z.string(),message:S.z.string(),confirmLabel:S.z.string().optional(),cancelLabel:S.z.string().optional(),variant:S.z.enum(["default","danger"]).optional()}),vl=S.z.union([S.z.object({navigate:S.z.string()}),S.z.object({set:S.z.record(S.z.string(),S.z.unknown())}),S.z.object({action:S.z.string()})]),yl=S.z.union([S.z.object({set:S.z.record(S.z.string(),S.z.unknown())}),S.z.object({action:S.z.string()})]);S.z.object({action:S.z.string(),params:S.z.record(S.z.string(),ua).optional(),confirm:wl.optional(),onSuccess:vl.optional(),onError:yl.optional(),preventDefault:S.z.boolean().optional()});function kl(e,t){const n={};if(e.params)for(const[s,a]of Object.entries(e.params))n[s]=pa(a,t);let o=e.confirm;return o&&(o={...o,message:Yo(o.message,t),title:Yo(o.title,t)}),{action:e.action,params:n,confirm:o,onSuccess:e.onSuccess,onError:e.onError}}function Yo(e,t){return e.replace(/\$\{([^}]+)\}/g,(n,o)=>{const s=pa({$state:o},t);return String(s??"")})}async function Xo(e){const{action:t,handler:n,setState:o,navigate:s,executeAction:a}=e;try{if(await n(t.params),t.onSuccess)if("navigate"in t.onSuccess&&s)s(t.onSuccess.navigate);else if("set"in t.onSuccess)for(const[i,c]of Object.entries(t.onSuccess.set))o(i,c);else"action"in t.onSuccess&&a&&await a(t.onSuccess.action)}catch(i){if(t.onError)if("set"in t.onError)for(const[c,d]of Object.entries(t.onError.set)){const l=typeof d=="string"&&d==="$error.message"?i.message:d;o(c,l)}else"action"in t.onError&&a&&await a(t.onError.action);else throw i}}var jl=S.z.object({type:S.z.string(),args:S.z.record(S.z.string(),ua).optional(),message:S.z.string()});S.z.object({checks:S.z.array(jl).optional(),validateOn:S.z.enum(["change","blur","submit"]).optional(),enabled:hr.optional()});var Go=(e,t)=>{const n=t==null?void 0:t.other;return e===n},Cl={required:e=>e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0,email:e=>typeof e!="string"?!1:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),minLength:(e,t)=>{if(typeof e!="string")return!1;const n=t==null?void 0:t.min;return typeof n!="number"?!1:e.length>=n},maxLength:(e,t)=>{if(typeof e!="string")return!1;const n=t==null?void 0:t.max;return typeof n!="number"?!1:e.length<=n},pattern:(e,t)=>{if(typeof e!="string")return!1;const n=t==null?void 0:t.pattern;if(typeof n!="string")return!1;try{return new RegExp(n).test(e)}catch{return!1}},min:(e,t)=>{if(typeof e!="number")return!1;const n=t==null?void 0:t.min;return typeof n!="number"?!1:e>=n},max:(e,t)=>{if(typeof e!="number")return!1;const n=t==null?void 0:t.max;return typeof n!="number"?!1:e<=n},numeric:e=>typeof e=="number"?!isNaN(e):typeof e=="string"?!isNaN(parseFloat(e)):!1,url:e=>{if(typeof e!="string")return!1;try{return new URL(e),!0}catch{return!1}},matches:Go,equalTo:Go,lessThan:(e,t)=>{const n=t==null?void 0:t.other;if(e==null||n==null||e===""||n==="")return!1;if(typeof e=="number"&&typeof n=="number"||typeof e=="string"&&typeof n=="string")return e<n;const o=Number(e),s=Number(n);return!isNaN(o)&&!isNaN(s)?o<s:!1},greaterThan:(e,t)=>{const n=t==null?void 0:t.other;if(e==null||n==null||e===""||n==="")return!1;if(typeof e=="number"&&typeof n=="number"||typeof e=="string"&&typeof n=="string")return e>n;const o=Number(e),s=Number(n);return!isNaN(o)&&!isNaN(s)?o>s:!1},requiredIf:(e,t)=>(t==null?void 0:t.field)?e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0:!0};function Sl(e,t){const{value:n,stateModel:o,customFunctions:s}=t,a={};if(e.args)for(const[d,l]of Object.entries(e.args))a[d]=ut(l,{stateModel:o});const i=Cl[e.type]??(s==null?void 0:s[e.type]);if(!i)return console.warn(`Unknown validation function: ${e.type}`),{type:e.type,valid:!0,message:e.message};const c=i(n,a);return{type:e.type,valid:c,message:e.message}}function Nl(e,t){const n=[],o=[];if(e.enabled&&!At(e.enabled,{stateModel:t.stateModel}))return{valid:!0,errors:[],checks:[]};if(e.checks)for(const s of e.checks){const a=Sl(s,t);n.push(a),a.valid||o.push(a.message)}return{valid:o.length===0,errors:o,checks:n}}var _l=["patch"];function El(e){var t;return(t=e==null?void 0:e.modes)!=null&&t.length?e.modes:_l}function Al(){return["PATCH MODE (RFC 6902 JSON Patch):","Output one JSON object per line. Each line is a patch operation.",'- Add: {"op":"add","path":"/elements/new-key","value":{...}}','- Replace: {"op":"replace","path":"/elements/existing-key","value":{...}}','- Remove: {"op":"remove","path":"/elements/old-key"}',"Only output patches for what needs to change."].join(`
|
|
3
|
+
`)}function Tl(){return["MERGE MODE (RFC 7396 JSON Merge Patch):","Output a single JSON object on one line with __json_edit set to true.","Include only the keys that changed. Unmentioned keys are preserved.","Set a key to null to delete it.","","Example (update a title and add an element):",'{"__json_edit":true,"elements":{"main":{"props":{"title":"New Title"}},"new-el":{"type":"Card","props":{},"children":[]}}}',"","Example (delete an element):",'{"__json_edit":true,"elements":{"old-widget":null}}'].join(`
|
|
4
|
+
`)}function Il(){return["DIFF MODE (unified diff):","Output a unified diff inside a ```diff code fence.","The diff applies against the JSON-serialized current spec.","","Example:","```diff","--- a/spec.json","+++ b/spec.json","@@ -3,1 +3,1 @@",'- "title": "Login"','+ "title": "Welcome Back"',"```"].join(`
|
|
5
|
+
`)}function zl(e){if(e.length===1)return"";const t=["Choose the best edit strategy for the requested change:"];return e.includes("patch")&&t.push("- PATCH: best for precise, targeted single-field updates"),e.includes("merge")&&t.push("- MERGE: best for structural changes (add/remove elements, reparent children, update multiple props at once)"),e.includes("diff")&&t.push("- DIFF: best for small text-level changes when you can see the exact lines to change"),t.join(`
|
|
6
|
+
`)}function Ml(e,t){const n=El(e),o=[];o.push("EDITING EXISTING SPECS:"),o.push("");const s=zl(n);s&&(o.push(s),o.push(""));for(const a of n){switch(a){case"patch":o.push(Al());break;case"merge":o.push(Tl());break;case"diff":o.push(Il());break}o.push("")}return o.join(`
|
|
7
|
+
`)}function va(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.root=="string"&&typeof t.elements=="object"&&t.elements!==null&&Object.keys(t.elements).length>0}function Rl(){return{string:()=>({kind:"string"}),number:()=>({kind:"number"}),boolean:()=>({kind:"boolean"}),array:e=>({kind:"array",inner:e}),object:e=>({kind:"object",inner:e}),record:e=>({kind:"record",inner:e}),any:()=>({kind:"any"}),zod:()=>({kind:"zod"}),ref:e=>({kind:"ref",inner:e}),propsOf:e=>({kind:"propsOf",inner:e}),map:e=>({kind:"map",inner:e}),optional:()=>({optional:!0})}}function Pl(e,t){const n=Rl();return{definition:e(n),promptTemplate:t==null?void 0:t.promptTemplate,defaultRules:t==null?void 0:t.defaultRules,builtInActions:t==null?void 0:t.builtInActions,createCatalog(s){return Ol(this,s)}}}function Ol(e,t){const n=t.components,o=t.actions,s=n?Object.keys(n):[],a=o?Object.keys(o):[],i=Ll(e.definition,t);return{schema:e,data:t,componentNames:s,actionNames:a,prompt(c={}){return Fl(this,c)},jsonSchema(c={}){return Je(i,c.strict??!1)},validate(c){const d=i.safeParse(c);return d.success?{success:!0,data:d.data}:{success:!1,error:d.error}},zodSchema(){return i},get _specType(){throw new Error("_specType is only for type inference")}}}function Ll(e,t){return jn(e.spec,t)}function jn(e,t){switch(e.kind){case"string":return S.z.string();case"number":return S.z.number();case"boolean":return S.z.boolean();case"any":return S.z.any();case"array":{const n=jn(e.inner,t);return S.z.array(n)}case"object":{const n=e.inner,o={};for(const[s,a]of Object.entries(n)){let i=jn(a,t);a.optional&&(i=i.optional()),o[s]=i}return S.z.object(o)}case"record":{const n=jn(e.inner,t);return S.z.record(S.z.string(),n)}case"ref":{const n=e.inner,o=$l(n,t);return o.length===0?S.z.string():o.length===1?S.z.literal(o[0]):S.z.enum(o)}case"propsOf":{const n=e.inner,o=Dl(n,t);return o.length===0?S.z.record(S.z.string(),S.z.unknown()):o.length===1?o[0]:S.z.record(S.z.string(),S.z.unknown())}default:return S.z.unknown()}}function $l(e,t){const n=e.split(".");let o={catalog:t};for(const s of n)if(o&&typeof o=="object")o=o[s];else return[];return o&&typeof o=="object"?Object.keys(o):[]}function Dl(e,t){const n=e.split(".");let o={catalog:t};for(const s of n)if(o&&typeof o=="object")o=o[s];else return[];return o&&typeof o=="object"?Object.values(o).map(s=>s.props).filter(s=>s!==void 0):[]}function Fl(e,t){if(e.schema.promptTemplate){const E={catalog:e.data,componentNames:e.componentNames,actionNames:e.actionNames,options:t,formatZodType:Te};return e.schema.promptTemplate(E)}const{system:n="You are a UI generator that outputs JSON.",customRules:o=[],mode:s="standalone"}=t,a=s==="chat"?(console.warn('[json-render] mode "chat" is deprecated, use "inline" instead'),"inline"):s==="generate"?(console.warn('[json-render] mode "generate" is deprecated, use "standalone" instead'),"standalone"):s,i=[];i.push(n),i.push(""),a==="inline"?(i.push("OUTPUT FORMAT (text + JSONL, RFC 6902 JSON Patch):"),i.push("You respond conversationally. When generating UI, first write a brief explanation (1-3 sentences), then output JSONL patch lines wrapped in a ```spec code fence."),i.push("The JSONL lines use RFC 6902 JSON Patch operations to build a UI tree. Always wrap them in a ```spec fence block:"),i.push(" ```spec"),i.push(' {"op":"add","path":"/root","value":"main"}'),i.push(' {"op":"add","path":"/elements/main","value":{"type":"Card","props":{"title":"Hello"},"children":[]}}'),i.push(" ```"),i.push("If the user's message does not require a UI (e.g. a greeting or clarifying question), respond with text only — no JSONL.")):(i.push("OUTPUT FORMAT (JSONL, RFC 6902 JSON Patch):"),i.push("Output JSONL (one JSON object per line) using RFC 6902 JSON Patch operations to build a UI tree.")),i.push("Each line is a JSON patch operation (add, remove, replace). Start with /root, then stream /elements and /state patches interleaved so the UI fills in progressively as it streams."),i.push(""),i.push("Example output (each line is a separate JSON object):"),i.push("");const c=e.data.components,d=e.componentNames,l=d[0]||"Component",m=d.length>1?d[1]:l,p=c==null?void 0:c[l],h=c==null?void 0:c[m],f=p?Ko(p):{},x=h?Ko(h):{},g=h!=null&&h.props?Hl(h.props):null,y=g?{...x,[g]:{$item:"title"}}:x,w=[JSON.stringify({op:"add",path:"/root",value:"main"}),JSON.stringify({op:"add",path:"/elements/main",value:{type:l,props:f,children:["child-1","list"]}}),JSON.stringify({op:"add",path:"/elements/child-1",value:{type:m,props:x,children:[]}}),JSON.stringify({op:"add",path:"/elements/list",value:{type:l,props:f,repeat:{statePath:"/items",key:"id"},children:["item"]}}),JSON.stringify({op:"add",path:"/elements/item",value:{type:m,props:y,children:[]}}),JSON.stringify({op:"add",path:"/state/items",value:[]}),JSON.stringify({op:"add",path:"/state/items/0",value:{id:"1",title:"First Item"}}),JSON.stringify({op:"add",path:"/state/items/1",value:{id:"2",title:"Second Item"}})].join(`
|
|
8
8
|
`);i.push(`${w}
|
|
9
9
|
|
|
10
|
-
Note: state patches appear right after the elements that use them, so the UI fills in as it streams. ONLY use component types from the AVAILABLE COMPONENTS list below.`),i.push(""),i.push("INITIAL STATE:"),i.push("Specs include a /state field to seed the state model. Components with { $bindState } or { $bindItem } read from and write to this state, and $state expressions read from it."),i.push("CRITICAL: You MUST include state patches whenever your UI displays data via $state, $bindState, $bindItem, $item, or $index expressions, or uses repeat to iterate over arrays. Without state, these references resolve to nothing and repeat lists render zero items."),i.push("Output state patches right after the elements that reference them, so the UI fills in progressively as it streams."),i.push("Stream state progressively - output one patch per array item instead of one giant blob:"),i.push(' For arrays: {"op":"add","path":"/state/posts/0","value":{"id":"1","title":"First Post",...}} then /state/posts/1, /state/posts/2, etc.'),i.push(' For scalars: {"op":"add","path":"/state/newTodoText","value":""}'),i.push(' Initialize the array first if needed: {"op":"add","path":"/state/posts","value":[]}'),i.push('When content comes from the state model, use { "$state": "/some/path" } dynamic props to display it instead of hardcoding the same value in both state and props. The state model is the single source of truth.'),i.push("Include realistic sample data in state. For blogs: 3-4 posts with titles, excerpts, authors, dates. For product lists: 3-5 items with names, prices, descriptions. Never leave arrays empty."),i.push(""),i.push("DYNAMIC LISTS (repeat field):"),i.push('Any element can have a top-level "repeat" field to render its children once per item in a state array: { "repeat": { "statePath": "/arrayPath", "key": "id" } }.'),i.push('The element itself renders once (as the container), and its children are expanded once per array item. "statePath" is the state array path. "key" is an optional field name on each item for stable React keys.'),i.push(`Example: ${JSON.stringify({type:l,props:f,repeat:{statePath:"/todos",key:"id"},children:["todo-item"]})}`),i.push('Inside children of a repeated element, use { "$item": "field" } to read a field from the current item, and { "$index": true } to get the current array index. For two-way binding to an item field use { "$bindItem": "completed" } on the appropriate prop.'),i.push("ALWAYS use the repeat field for lists backed by state arrays. NEVER hardcode individual elements for each array item."),i.push('IMPORTANT: "repeat" is a top-level field on the element (sibling of type/props/children), NOT inside props.'),i.push(""),i.push("ARRAY STATE ACTIONS:"),i.push('Use action "pushState" to append items to arrays. Params: { statePath: "/arrayPath", value: { ...item }, clearStatePath: "/inputPath" }.'),i.push('Values inside pushState can contain { "$state": "/statePath" } references to read current state (e.g. the text from an input field).'),i.push('Use "$id" inside a pushState value to auto-generate a unique ID.'),i.push('Example: on: { "press": { "action": "pushState", "params": { "statePath": "/todos", "value": { "id": "$id", "title": { "$state": "/newTodoText" }, "completed": false }, "clearStatePath": "/newTodoText" } } }'),i.push(`Use action "removeState" to remove items from arrays by index. Params: { statePath: "/arrayPath", index: N }. Inside a repeated element's children, use { "$index": true } for the current item index. Action params support the same expressions as props: { "$item": "field" } resolves to the absolute state path, { "$index": true } resolves to the index number, and { "$state": "/path" } reads a value from state.`),i.push("For lists where users can add/remove items (todos, carts, etc.), use pushState and removeState instead of hardcoding with setState."),i.push(""),i.push('IMPORTANT: State paths use RFC 6901 JSON Pointer syntax (e.g. "/todos/0/title"). Do NOT use JavaScript-style dot notation (e.g. "/todos.length" is WRONG). To generate unique IDs for new items, use "$id" instead of trying to read array length.'),i.push("");const j=c;if(j){i.push(`AVAILABLE COMPONENTS (${e.componentNames.length}):`),i.push("");for(const[E,I]of Object.entries(j)){const W=I.props?Te(I.props):"{}",U=I.slots&&I.slots.length>0?" [accepts children]":"",Y=I.events&&I.events.length>0?` [events: ${I.events.join(", ")}]`:"",q=I.description?` - ${I.description}`:"";i.push(`- ${E}: ${W}${q}${U}${Y}`)}i.push("")}const b=e.data.actions,_=e.schema.builtInActions??[],v=b&&e.actionNames.length>0,k=_.length>0;if(v||k){i.push("AVAILABLE ACTIONS:"),i.push("");for(const E of _)i.push(`- ${E.name}: ${E.description} [built-in]`);if(v)for(const[E,I]of Object.entries(b))i.push(`- ${E}${I.description?`: ${I.description}`:""}`);i.push("")}i.push("EVENTS (the `on` field):"),i.push("Elements can have an optional `on` field to bind events to actions. The `on` field is a top-level field on the element (sibling of type/props/children), NOT inside props."),i.push('Each key in `on` is an event name (from the component\'s supported events), and the value is an action binding: `{ "action": "<actionName>", "params": { ... } }`.'),i.push(""),i.push("Example:"),i.push(` ${JSON.stringify({type:l,props:f,on:{press:{action:"setState",params:{statePath:"/saved",value:!0}}},children:[]})}`),i.push(""),i.push('Action params can use dynamic references to read from state: { "$state": "/statePath" }.'),i.push("IMPORTANT: Do NOT put action/actionParams inside props. Always use the `on` field for event bindings."),i.push(""),i.push("VISIBILITY CONDITIONS:"),i.push("Elements can have an optional `visible` field to conditionally show/hide based on state. IMPORTANT: `visible` is a top-level field on the element object (sibling of type/props/children), NOT inside props."),i.push(`Correct: ${JSON.stringify({type:l,props:f,visible:{$state:"/activeTab",eq:"home"},children:["..."]})}`),i.push('- `{ "$state": "/path" }` - visible when state at path is truthy'),i.push('- `{ "$state": "/path", "not": true }` - visible when state at path is falsy'),i.push('- `{ "$state": "/path", "eq": "value" }` - visible when state equals value'),i.push('- `{ "$state": "/path", "neq": "value" }` - visible when state does not equal value'),i.push('- `{ "$state": "/path", "gt": N }` / `gte` / `lt` / `lte` - numeric comparisons'),i.push("- Use ONE operator per condition (eq, neq, gt, gte, lt, lte). Do not combine multiple operators."),i.push('- Any condition can add `"not": true` to invert its result'),i.push("- `[condition, condition]` - all conditions must be true (implicit AND)"),i.push('- `{ "$and": [condition, condition] }` - explicit AND (use when nesting inside $or)'),i.push('- `{ "$or": [condition, condition] }` - at least one must be true (OR)'),i.push("- `true` / `false` - always visible/hidden"),i.push(""),i.push("Use a component with on.press bound to setState to update state and drive visibility."),i.push(`Example: A ${l} with on: { "press": { "action": "setState", "params": { "statePath": "/activeTab", "value": "home" } } } sets state, then a container with visible: { "$state": "/activeTab", "eq": "home" } shows only when that tab is active.`),i.push(""),i.push('For tab patterns where the first/default tab should be visible when no tab is selected yet, use $or to handle both cases: visible: { "$or": [{ "$state": "/activeTab", "eq": "home" }, { "$state": "/activeTab", "not": true }] }. This ensures the first tab is visible both when explicitly selected AND when /activeTab is not yet set.'),i.push(""),i.push("DYNAMIC PROPS:"),i.push("Any prop value can be a dynamic expression that resolves based on state. Three forms are supported:"),i.push(""),i.push('1. Read-only state: `{ "$state": "/statePath" }` - resolves to the value at that state path (one-way read).'),i.push(' Example: `"color": { "$state": "/theme/primary" }` reads the color from state.'),i.push(""),i.push('2. Two-way binding: `{ "$bindState": "/statePath" }` - resolves to the value at the state path AND enables write-back. Use on form input props (value, checked, pressed, etc.).'),i.push(' Example: `"value": { "$bindState": "/form/email" }` binds the input value to /form/email.'),i.push(' Inside repeat scopes: `"checked": { "$bindItem": "completed" }` binds to the current item\'s completed field.'),i.push(""),i.push('3. Conditional: `{ "$cond": <condition>, "$then": <value>, "$else": <value> }` - evaluates the condition (same syntax as visibility conditions) and picks the matching value.'),i.push(' Example: `"color": { "$cond": { "$state": "/activeTab", "eq": "home" }, "$then": "#007AFF", "$else": "#8E8E93" }`'),i.push(""),i.push("Use $bindState for form inputs (text fields, checkboxes, selects, sliders, etc.) and $state for read-only data display. Inside repeat scopes, use $bindItem for form inputs bound to the current item. Use dynamic props instead of duplicating elements with opposing visible conditions when only prop values differ."),i.push(""),i.push('4. Template: `{ "$template": "Hello, ${/name}!" }` - interpolates references in the string. Absolute paths like `${/path}` resolve against the state model. Bare names like `${field}` resolve against the current repeat item first, then fall back to the state model at `/<field>`.'),i.push(' Example: `"label": { "$template": "Items: ${/cart/count} | Total: ${/cart/total}" }` renders "Items: 3 | Total: 42.00" when /cart/count is 3 and /cart/total is 42.00. Inside a repeat, `{ "$template": "${name} - ${email}" }` reads name and email from each item.'),i.push("");const N=e.data.functions;if(N&&Object.keys(N).length>0){i.push('5. Computed: `{ "$computed": "<functionName>", "args": { "key": <expression> } }` - calls a registered function with resolved args and returns the result.'),i.push(' Example: `"value": { "$computed": "fullName", "args": { "first": { "$state": "/form/firstName" }, "last": { "$state": "/form/lastName" } } }`'),i.push(" Available functions:");for(const E of Object.keys(N))i.push(` - ${E}`);i.push("")}const R=t.directives;if(R&&R.length>0){i.push("CUSTOM DYNAMIC VALUES:"),i.push("");for(const E of R){const I=E.description?` (${E.description})`:"";i.push(`- ${E.name}${I}: ${Te(E.schema)}`)}i.push(""),i.push("Directives compose: any value field can contain another directive or a $state expression, resolved inside-out."),i.push("")}(c?Object.entries(c).some(([,E])=>E.props?Te(E.props).includes("checks"):!1):!1)&&(i.push("VALIDATION:"),i.push("Form components that accept a `checks` prop support client-side validation."),i.push('Each check is an object: { "type": "<name>", "message": "...", "args": { ... } }'),i.push(""),i.push("Built-in validation types:"),i.push(" - required — value must be non-empty"),i.push(" - email — valid email format"),i.push(' - minLength — minimum string length (args: { "min": N })'),i.push(' - maxLength — maximum string length (args: { "max": N })'),i.push(' - pattern — match a regex (args: { "pattern": "regex" })'),i.push(' - min — minimum numeric value (args: { "min": N })'),i.push(' - max — maximum numeric value (args: { "max": N })'),i.push(" - numeric — value must be a number"),i.push(" - url — valid URL format"),i.push(' - matches — must equal another field (args: { "other": { "$state": "/path" } })'),i.push(' - equalTo — alias for matches (args: { "other": { "$state": "/path" } })'),i.push(' - lessThan — value must be less than another field (args: { "other": { "$state": "/path" } })'),i.push(' - greaterThan — value must be greater than another field (args: { "other": { "$state": "/path" } })'),i.push(' - requiredIf — required only when another field is truthy (args: { "field": { "$state": "/path" } })'),i.push(""),i.push("Example:"),i.push(' "checks": [{ "type": "required", "message": "Email is required" }, { "type": "email", "message": "Invalid email" }]'),i.push(""),i.push("IMPORTANT: When using checks, the component must also have a { $bindState } or { $bindItem } on its value/checked prop for two-way binding."),i.push("Always include validation checks on form inputs for a good user experience (e.g. required, email, minLength)."),i.push("")),(v||k)&&(i.push("STATE WATCHERS:"),i.push("Elements can have an optional `watch` field to react to state changes and trigger actions. The `watch` field is a top-level field on the element (sibling of type/props/children), NOT inside props."),i.push("Maps state paths (JSON Pointers) to action bindings. When the value at a watched path changes, the bound actions fire automatically."),i.push(""),i.push("Example (cascading select — country changes trigger city loading):"),i.push(` ${JSON.stringify({type:"Select",props:{value:{$bindState:"/form/country"},options:["US","Canada","UK"]},watch:{"/form/country":{action:"loadCities",params:{country:{$state:"/form/country"}}}},children:[]})}`),i.push(""),i.push("Use `watch` for cascading dependencies where changing one field should trigger side effects (loading data, resetting dependent fields, computing derived values)."),i.push("IMPORTANT: `watch` is a top-level field on the element (sibling of type/props/children), NOT inside props. Watchers only fire when the value changes, not on initial render."),i.push(""));const A=t.editModes;A&&A.length>0&&i.push(Dl({modes:A})),i.push("RULES:");const O=a==="inline"?["When generating UI, wrap all JSONL patches in a ```spec code fence - one JSON object per line inside the fence","Write a brief conversational response before any JSONL output",'First set root: {"op":"add","path":"/root","value":"<root-key>"}','Then add each element: {"op":"add","path":"/elements/<key>","value":{...}}',"Output /state patches right after the elements that use them, one per array item for progressive loading. REQUIRED whenever using $state, $bindState, $bindItem, $item, $index, or repeat.","ONLY use components listed above","Each element value needs: type, props, children (array of child keys)","Use unique keys for the element map entries (e.g., 'header', 'metric-1', 'chart-revenue')"]:["Output ONLY JSONL patches - one JSON object per line, no markdown, no code fences",'First set root: {"op":"add","path":"/root","value":"<root-key>"}','Then add each element: {"op":"add","path":"/elements/<key>","value":{...}}',"Output /state patches right after the elements that use them, one per array item for progressive loading. REQUIRED whenever using $state, $bindState, $bindItem, $item, $index, or repeat.","ONLY use components listed above","Each element value needs: type, props, children (array of child keys)","Use unique keys for the element map entries (e.g., 'header', 'metric-1', 'chart-revenue')"],P=e.schema.defaultRules??[];return[...O,...P,...o].forEach((E,I)=>{i.push(`${I+1}. ${E}`)}),i.join(`
|
|
11
|
-
`)}function Zo(e){return e.example&&Object.keys(e.example).length>0?e.example:e.props?ka(e.props):{}}function ka(e){if(!e||!e._def)return{};const t=e._def,n=ft(e);if(n!=="ZodObject"&&n!=="object")return{};const o=typeof t.shape=="function"?t.shape():t.shape;if(!o)return{};const s={};for(const[a,i]of Object.entries(o)){const c=ft(i);c==="ZodOptional"||c==="optional"||c==="ZodNullable"||c==="nullable"||(s[a]=gr(i))}return s}function gr(e){if(!e||!e._def)return"...";const t=e._def;switch(ft(e)){case"ZodString":case"string":return"example";case"ZodNumber":case"number":return 0;case"ZodBoolean":case"boolean":return!0;case"ZodLiteral":case"literal":return t.value;case"ZodEnum":case"enum":{if(Array.isArray(t.values)&&t.values.length>0)return t.values[0];if(t.entries&&typeof t.entries=="object"){const o=Object.values(t.entries);return o.length>0?o[0]:"example"}return"example"}case"ZodOptional":case"optional":case"ZodNullable":case"nullable":case"ZodDefault":case"default":{const o=t.innerType??t.wrapped;return o?gr(o):null}case"ZodArray":case"array":return[];case"ZodObject":case"object":return ka(e);case"ZodUnion":case"union":{const o=t.options;return o&&o.length>0?gr(o[0]):"..."}default:return"..."}}function Yl(e){if(!e||!e._def)return null;const t=e._def,n=ft(e);if(n!=="ZodObject"&&n!=="object")return null;const o=typeof t.shape=="function"?t.shape():t.shape;if(!o)return null;for(const[s,a]of Object.entries(o)){const i=ft(a);if(!(i==="ZodOptional"||i==="optional"||i==="ZodNullable"||i==="nullable")&&(i==="ZodString"||i==="string"))return s}return null}function ft(e){if(!e||!e._def)return"";const t=e._def;return t.typeName??t.type??""}function Te(e){if(!e||!e._def)return"unknown";const t=e._def;switch(ft(e)){case"ZodString":case"string":return"string";case"ZodNumber":case"number":return"number";case"ZodBoolean":case"boolean":return"boolean";case"ZodLiteral":case"literal":{const o=t.values,s=(o==null?void 0:o[0])??t.value;return JSON.stringify(s)}case"ZodEnum":case"enum":{let o;if(Array.isArray(t.values))o=t.values;else if(t.entries&&typeof t.entries=="object")o=Object.values(t.entries);else return"enum";return o.map(s=>`"${s}"`).join(" | ")}case"ZodArray":case"array":{const o=typeof t.element=="object"?t.element:typeof t.type=="object"?t.type:void 0;return o?`Array<${Te(o)}>`:"Array<unknown>"}case"ZodObject":case"object":{const o=typeof t.shape=="function"?t.shape():t.shape;return o?`{ ${Object.entries(o).map(([a,i])=>{const c=ft(i);return`${a}${c==="ZodOptional"||c==="ZodNullable"||c==="optional"||c==="nullable"?"?":""}: ${Te(i)}`}).join(", ")} }`:"object"}case"ZodOptional":case"optional":case"ZodNullable":case"nullable":{const o=t.innerType??t.wrapped;return o?Te(o):"unknown"}case"ZodUnion":case"union":{const o=t.options;return o?o.map(s=>Te(s)).join(" | "):"unknown"}case"ZodRecord":case"record":{const o=t.keyType??void 0,s=t.valueType??t.element??void 0,a=o?Te(o):"string",i=s?Te(s):"unknown";return`Record<${a}, ${i}>`}case"ZodDefault":case"default":{const o=t.innerType??t.wrapped;return o?Te(o):"unknown"}default:return"unknown"}}function Jo(e){return typeof e.type=="string"?e.type:typeof e.typeName=="string"?e.typeName:""}function Qo(e){return e.startsWith("Zod")?e.slice(3).toLowerCase():e.toLowerCase()}function Je(e,t=!1){const n=e._def;switch(Qo(Jo(n))){case"string":return{type:"string"};case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"literal":{const s=n.values;return{const:s?s[0]:n.value}}case"enum":{const s=n.entries;return{enum:(s?Object.values(s):n.values)??[]}}case"array":{const s=n.element??n.type;return{type:"array",items:s?Je(s,t):{}}}case"object":{const s=n.shape,a=typeof s=="function"?s():s;if(!a)return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{type:"object"};const i={},c=[];for(const[d,l]of Object.entries(a)){const m=l._def,p=Qo(Jo(m)),h=p==="optional"||p==="nullable";if(t)if(c.push(d),h){const f=Je(l,t);i[d]={anyOf:[f,{type:"null"}]}}else i[d]=Je(l,t);else i[d]=Je(l),h||c.push(d)}return{type:"object",properties:i,required:c.length>0?c:void 0,additionalProperties:!1}}case"record":{const s=n.valueType;return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{type:"object",additionalProperties:s?Je(s):!0}}case"optional":case"nullable":{const s=n.innerType;return s?Je(s,t):{}}case"union":{const s=n.options;return s?{anyOf:s.map(a=>Je(a,t))}:{}}case"any":case"unknown":return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{};default:return{}}}function Xl(e,t){return e.createCatalog(t)}var Gl=Hl(e=>({spec:e.object({root:e.string(),elements:e.record(e.object({type:e.ref("catalog.components"),props:e.propsOf("catalog.components"),children:e.array(e.string()),visible:e.any()}))}),catalog:e.object({components:e.map({props:e.zod(),slots:e.array(e.string()),description:e.string(),example:e.any()}),actions:e.map({params:e.zod(),description:e.string()})})}),{builtInActions:[{name:"setState",description:"Update a value in the state model at the given statePath. Params: { statePath: string, value: any }"},{name:"pushState",description:'Append an item to an array in state. Params: { statePath: string, value: any, clearStatePath?: string }. Value can contain {"$state":"/path"} refs and "$id" for auto IDs.'},{name:"removeState",description:"Remove an item from an array in state by index. Params: { statePath: string, index: number }"},{name:"validateForm",description:"Validate all registered form fields and write the result to state. Params: { statePath?: string }. Defaults to /formValidation. Result: { valid: boolean, errors: Record<string, string[]> }."}],defaultRules:["CRITICAL INTEGRITY CHECK: Before outputting ANY element that references children, you MUST have already output (or will output) each child as its own element. If an element has children: ['a', 'b'], then elements 'a' and 'b' MUST exist. A missing child element causes that entire branch of the UI to be invisible.","SELF-CHECK: After generating all elements, mentally walk the tree from root. Every key in every children array must resolve to a defined element. If you find a gap, output the missing element immediately.",'CRITICAL: The "visible" field goes on the ELEMENT object, NOT inside "props". Correct: {"type":"<ComponentName>","props":{},"visible":{"$state":"/tab","eq":"home"},"children":[...]}.','CRITICAL: The "on" field goes on the ELEMENT object, NOT inside "props". Use on.press, on.change, on.submit etc. NEVER put action/actionParams inside props.',"When the user asks for a UI that displays data (e.g. blog posts, products, users), ALWAYS include a state field with realistic sample data. The state field is a top-level field on the spec (sibling of root/elements).",'When building repeating content backed by a state array (e.g. posts, products, items), use the "repeat" field on a container element. Example: { "type": "<ContainerComponent>", "props": {}, "repeat": { "statePath": "/posts", "key": "id" }, "children": ["post-card"] }. Replace <ContainerComponent> with an appropriate component from the AVAILABLE COMPONENTS list. Inside repeated children, use { "$item": "field" } to read a field from the current item, and { "$index": true } for the current array index. For two-way binding to an item field use { "$bindItem": "completed" }. Do NOT hardcode individual elements for each array item.',"Design with visual hierarchy: use container components to group content, heading components for section titles, proper spacing, and status indicators. ONLY use components from the AVAILABLE COMPONENTS list.","For data-rich UIs, use multi-column layout components if available. For forms and single-column content, use vertical layout components. ONLY use components from the AVAILABLE COMPONENTS list.","Always include realistic, professional-looking sample data. For blogs include 3-4 posts with varied titles, authors, dates, categories. For products include names, prices, images. Never leave data empty."]}),ja=u.createContext(null);function Kl(e,t){return e?null:Object.keys(t).length===0?{}:Yr(t)}function Zl({store:e,initialState:t={},onStateChange:n,children:o}){const s=u.useRef(void 0);!e&&!s.current&&(s.current=tl(t));const a=e??s.current,i=u.useRef(a);i.current=a;const c=u.useRef(!!e);c.current=!!e;const d=u.useRef(e?"controlled":"uncontrolled"),l=u.useRef(!1);if(process.env.NODE_ENV!=="production"){const b=e?"controlled":"uncontrolled";b!==d.current&&!l.current&&(l.current=!0,console.warn(`StateProvider: switching from ${d.current} to ${b} mode is not supported.`))}const m=u.useRef(t),p=u.useRef(Kl(!!e,t));u.useEffect(()=>{if(e||t===m.current)return;m.current=t;const b=t&&Object.keys(t).length>0?Yr(t):{},_=p.current??{},v=new Set([...Object.keys(_),...Object.keys(b)]),k={};for(const N of v)_[N]!==b[N]&&(k[N]=N in b?b[N]:void 0);p.current=b,Object.keys(k).length>0&&a.update(k)},[e,t,a]);const h=u.useSyncExternalStore(a.subscribe,a.getSnapshot,a.getServerSnapshot??a.getSnapshot),f=u.useRef(n);f.current=n;const x=u.useCallback((b,_)=>{var N;const v=i.current,k=v.getSnapshot();v.set(b,_),!c.current&&v.getSnapshot()!==k&&((N=f.current)==null||N.call(f,[{path:b,value:_}]))},[]),g=u.useCallback(b=>{var k;const _=i.current,v=_.getSnapshot();if(_.update(b),!c.current&&_.getSnapshot()!==v){const N=[];for(const[R,T]of Object.entries(b))ce(v,R)!==T&&N.push({path:R,value:T});N.length>0&&((k=f.current)==null||k.call(f,N))}},[]),y=u.useCallback(b=>i.current.get(b),[]),w=u.useCallback(()=>i.current.getSnapshot(),[]),j=u.useMemo(()=>({state:h,get:y,set:x,update:g,getSnapshot:w}),[h,y,x,g,w]);return r.jsx(ja.Provider,{value:j,children:o})}function nn(){const e=u.useContext(ja);if(!e)throw new Error("useStateStore must be used within a StateProvider");return e}var Ca=u.createContext(null);function Jl({children:e}){const{state:t}=nn(),n=u.useMemo(()=>({stateModel:t}),[t]),o=u.useMemo(()=>a=>At(a,n),[n]),s=u.useMemo(()=>({isVisible:o,ctx:n}),[o,n]);return r.jsx(Ca.Provider,{value:s,children:e})}function Ql(){const e=u.useContext(Ca);if(!e)throw new Error("useVisibility must be used within a VisibilityProvider");return e}var Sa=u.createContext(null);function ed(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const s of n){const a=e[s],i=t[s];if(a!==i){if(typeof a=="object"&&a!==null&&typeof i=="object"&&i!==null){const c=a.$state,d=i.$state;if(typeof c=="string"&&c===d)continue}return!1}}return!0}function td(e,t){if(e===t)return!0;if(e.validateOn!==t.validateOn)return!1;const n=e.checks??[],o=t.checks??[];if(n.length!==o.length)return!1;for(let s=0;s<n.length;s++){const a=n[s],i=o[s];if(a.type!==i.type||a.message!==i.message||!ed(a.args,i.args))return!1}return!0}function nd({customFunctions:e={},children:t}){const{state:n,getSnapshot:o}=nn(),[s,a]=u.useState({}),i=u.useRef({}),[c,d]=u.useState({}),l=u.useCallback((g,y)=>{d(w=>{const j=w[g];return j&&td(j,y)?w:{...w,[g]:y}})},[]),m=u.useCallback((g,y)=>{var k;const w=o(),j=g.split("/").filter(Boolean);let b=w;for(const N of j)if(b!=null&&typeof b=="object")b=b[N];else{b=void 0;break}const _=zl(y,{value:b,stateModel:w,customFunctions:e}),v={touched:((k=i.current[g])==null?void 0:k.touched)??!0,validated:!0,result:_};return i.current={...i.current,[g]:v},a(i.current),_},[e,o]),p=u.useCallback(g=>{var y,w;i.current={...i.current,[g]:{...i.current[g],touched:!0,validated:((y=i.current[g])==null?void 0:y.validated)??!1,result:((w=i.current[g])==null?void 0:w.result)??null}},a(i.current)},[]),h=u.useCallback(g=>{const{[g]:y,...w}=i.current;i.current=w,a(w)},[]),f=u.useCallback(()=>{let g=!0;for(const[y,w]of Object.entries(c))m(y,w).valid||(g=!1);return g},[c,m]),x=u.useMemo(()=>({customFunctions:e,get fieldStates(){return i.current},validate:m,touch:p,clear:h,validateAll:f,registerField:l}),[e,s,m,p,h,f,l]);return r.jsx(Sa.Provider,{value:x,children:t})}function rd(){return u.useContext(Sa)}var es=0;function ts(){return es+=1,`${Date.now()}-${es}`}function xr(e,t){if(e==null)return e;if(e==="$id")return ts();if(typeof e=="object"&&!Array.isArray(e)){const n=e,o=Object.keys(n);if(o.length===1&&typeof n.$state=="string")return t(n.$state);if(o.length===1&&"$id"in n)return ts()}if(Array.isArray(e))return e.map(n=>xr(n,t));if(typeof e=="object"){const n={};for(const[o,s]of Object.entries(e))n[o]=xr(s,t);return n}return e}var Na=u.createContext(null);function od({handlers:e={},navigate:t,children:n}){const{get:o,set:s,getSnapshot:a}=nn(),i=rd(),[c,d]=u.useState(e),[l,m]=u.useState(new Set),[p,h]=u.useState(null),f=u.useCallback((j,b)=>{d(_=>({..._,[j]:b}))},[]),x=u.useCallback(async j=>{var R;const b=El(j,a()),_=yl(),v=Date.now();wl({id:_,name:b.action,params:b.params,at:v});let k=!0,N;try{if(b.action==="setState"&&b.params){const A=b.params.statePath,O=b.params.value;A&&s(A,O);return}if(b.action==="pushState"&&b.params){const A=b.params.statePath,O=b.params.value;if(A){const P=xr(O,o),B=o(A)??[];s(A,[...B,P]);const E=b.params.clearStatePath;E&&s(E,"")}return}if(b.action==="removeState"&&b.params){const A=b.params.statePath,O=b.params.index;if(A!==void 0&&O!==void 0){const P=o(A)??[];s(A,P.filter((B,E)=>E!==O))}return}if(b.action==="push"&&b.params){const A=b.params.screen;if(A){const O=o("/currentScreen"),P=o("/navStack")??[];O?s("/navStack",[...P,O]):s("/navStack",[...P,""]),s("/currentScreen",A)}return}if(b.action==="pop"){const A=o("/navStack")??[];if(A.length>0){const O=A[A.length-1];s("/navStack",A.slice(0,-1)),O?s("/currentScreen",O):s("/currentScreen",void 0)}return}if(b.action==="validateForm"){const A=i==null?void 0:i.validateAll;if(!A){console.warn("validateForm action was dispatched but no ValidationProvider is connected. Ensure ValidationProvider is rendered inside the provider tree.");return}const O=A(),P={};for(const[E,I]of Object.entries(i.fieldStates))I.result&&!I.result.valid&&(P[E]=I.result.errors);const B=((R=b.params)==null?void 0:R.statePath)||"/formValidation";s(B,{valid:O,errors:P});return}const T=c[b.action];if(!T){console.warn(`No handler registered for action: ${b.action}`);return}if(b.confirm)return new Promise((A,O)=>{h({action:b,handler:T,resolve:()=>{h(null),A()},reject:()=>{h(null),O(new Error("Action cancelled"))}})}).then(async()=>{m(A=>new Set(A).add(b.action));try{await Go({action:b,handler:T,setState:s,navigate:t,executeAction:async A=>{await x({action:A})}})}finally{m(A=>{const O=new Set(A);return O.delete(b.action),O})}});m(A=>new Set(A).add(b.action));try{await Go({action:b,handler:T,setState:s,navigate:t,executeAction:async A=>{await x({action:A})}})}finally{m(A=>{const O=new Set(A);return O.delete(b.action),O})}}catch(T){throw k=!1,N=T,T}finally{const T=Date.now();vl({id:_,name:b.action,ok:k,at:T,durationMs:T-v,error:N})}},[c,o,s,a,t,i]),g=u.useCallback(()=>{p==null||p.resolve()},[p]),y=u.useCallback(()=>{p==null||p.reject()},[p]),w=u.useMemo(()=>({handlers:c,loadingActions:l,pendingConfirmation:p,execute:x,confirm:g,cancel:y,registerHandler:f}),[c,l,p,x,g,y,f]);return r.jsx(Na.Provider,{value:w,children:n})}function _a(){const e=u.useContext(Na);if(!e)throw new Error("useActions must be used within an ActionProvider");return e}function sd({confirm:e,onConfirm:t,onCancel:n}){const o=e.variant==="danger";return r.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:50},onClick:n,children:r.jsxs("div",{style:{backgroundColor:"white",borderRadius:"8px",padding:"24px",maxWidth:"400px",width:"100%",boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.1)"},onClick:s=>s.stopPropagation(),children:[r.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"18px",fontWeight:600},children:e.title}),r.jsx("p",{style:{margin:"0 0 24px 0",color:"#6b7280"},children:e.message}),r.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"},children:[r.jsx("button",{onClick:n,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #d1d5db",backgroundColor:"white",cursor:"pointer"},children:e.cancelLabel??"Cancel"}),r.jsx("button",{onClick:t,style:{padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:o?"#dc2626":"#3b82f6",color:"white",cursor:"pointer"},children:e.confirmLabel??"Confirm"})]})]})})}var Ea=u.createContext(null);function ad({item:e,index:t,basePath:n,children:o}){return r.jsx(Ea.Provider,{value:{item:e,index:t,basePath:n},children:o})}function id(){return u.useContext(Ea)}var cd=class extends u.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.error(`[json-render] Rendering error in <${this.props.elementType}>:`,e,t.componentStack)}render(){return this.state.hasError?null:this.props.children}},Aa={},Ta=u.createContext(Aa);function ld(){return u.useContext(Ta)}var Ia=u.createContext(void 0);function dd(){return u.useContext(Ia)}function ud(){return u.useSyncExternalStore(Cl,jl,()=>!1)}var za=u.memo(function e({element:t,elementKey:n,spec:o,registry:s,loading:a,fallback:i}){var W;const c=ud(),d=id(),{ctx:l}=Ql(),{execute:m}=_a(),{getSnapshot:p,state:h}=nn(),f=ld(),x=dd(),g=u.useMemo(()=>{const $=d?{...l,repeatItem:d.item,repeatIndex:d.index,repeatBasePath:d.basePath}:{...l};return $.functions=f,$.directives=x,$},[l,d,f,x]),y=t.visible===void 0?!0:At(t.visible,g),w=t.on,j=u.useCallback(async $=>{const U=w==null?void 0:w[$];if(!U)return;const Y=Array.isArray(U)?U:[U];for(const q of Y){if(!q.params){await m(q);continue}const se={...g,stateModel:p()},D={};for(const[V,Z]of Object.entries(q.params))D[V]=qo(Z,se);await m({...q,params:D})}},[w,m,g,p]),b=u.useCallback($=>{const U=w==null?void 0:w[$];if(!U)return{emit:()=>{},shouldPreventDefault:!1,bound:!1};const q=(Array.isArray(U)?U:[U]).some(se=>se.preventDefault);return{emit:()=>j($),shouldPreventDefault:q,bound:!0}},[w,j]),_=t.watch,v=u.useRef(null),k=u.useRef(void 0),N=u.useMemo(()=>{if(!_)return;const $={};for(const Y of Object.keys(_))$[Y]=ce(h,Y);const U=k.current;if(U){const Y=Object.keys($);if(Y.length===Object.keys(U).length&&Y.every(q=>$[q]===U[q]))return U}return k.current=$,$},[_,h]);if(u.useEffect(()=>{if(!_||!N)return;const $=Object.keys(_);if($.length===0)return;const U=v.current;if(v.current=N,U===null)return;let Y=!1;return(async()=>{for(const q of $){if(Y)break;if(N[q]!==U[q]){const se=_[q];if(!se)continue;const D=Array.isArray(se)?se:[se];for(const V of D){if(Y)break;if(!V.params){if(await m(V),Y)break;continue}const Z={...g,stateModel:p()},te={};for(const[ae,xe]of Object.entries(V.params))te[ae]=qo(xe,Z);if(await m({...V,params:te}),Y)break}}}})().catch(console.error),()=>{Y=!0}},[_,N,m,g,p]),!y)return null;const R=t.props,T=bl(R,g),A=xl(R,g),O=A!==t.props?{...t,props:A}:t,P=s[O.type]??i;if(!P)return console.warn(`No renderer for component type: ${O.type}`),null;const B=O.repeat?r.jsx(pd,{element:O,spec:o,registry:s,loading:a,fallback:i}):(W=O.children)==null?void 0:W.map($=>{const U=o.elements[$];return U?r.jsx(e,{element:U,elementKey:$,spec:o,registry:s,loading:a,fallback:i},$):(a||console.warn(`[json-render] Missing element "${$}" referenced as child of "${O.type}". This element will not render.`),null)}),E=r.jsx(P,{element:O,emit:j,on:b,bindings:T,loading:a,children:B}),I=c&&n?r.jsx("span",{"data-jr-key":n,style:{display:"contents"},children:E}):E;return r.jsx(cd,{elementType:O.type,children:I})});function pd({element:e,spec:t,registry:n,loading:o,fallback:s}){const{state:a}=nn(),i=e.repeat,c=i.statePath,d=ce(a,c)??[];return r.jsx(r.Fragment,{children:d.map((l,m)=>{var h;const p=i.key&&typeof l=="object"&&l!==null?String(l[i.key]??m):String(m);return r.jsx(ad,{item:l,index:m,basePath:`${c}/${m}`,children:(h=e.children)==null?void 0:h.map(f=>{const x=t.elements[f];return x?r.jsx(za,{element:x,elementKey:f,spec:t,registry:n,loading:o,fallback:s},f):(o||console.warn(`[json-render] Missing element "${f}" referenced as child of "${e.type}" (repeat). This element will not render.`),null)})},p)})})}function md({spec:e,registry:t,loading:n,fallback:o}){if(!e||!e.root)return null;const s=e.elements[e.root];return s?r.jsx(za,{element:s,elementKey:e.root,spec:e,registry:t,loading:n,fallback:o}):null}function hd({registry:e,store:t,initialState:n,handlers:o,navigate:s,validationFunctions:a,functions:i,directives:c,onStateChange:d,children:l}){const m=u.useMemo(()=>c?dl(c):void 0,[c]);return r.jsx(Zl,{store:t,initialState:n,onStateChange:d,children:r.jsx(Jl,{children:r.jsx(nd,{customFunctions:a,children:r.jsx(od,{handlers:o,navigate:s,children:r.jsx(Ta.Provider,{value:i??Aa,children:r.jsxs(Ia.Provider,{value:m,children:[l,r.jsx(fd,{})]})})})})})})}function fd(){const{pendingConfirmation:e,confirm:t,cancel:n}=_a();return e!=null&&e.action.confirm?r.jsx(sd,{confirm:e.action.confirm,onConfirm:t,onCancel:n}):null}function gd(e,t){const n={};if(t.components)for(const[i,c]of Object.entries(t.components))n[i]=({element:d,children:l,emit:m,on:p,bindings:h,loading:f})=>c({props:d.props,children:l,emit:m,on:p,bindings:h,loading:f});const o=t.actions?Object.entries(t.actions):[];return{registry:n,handlers:(i,c)=>{const d={};for(const[l,m]of o)d[l]=async p=>{const h=i(),f=c();h&&await m(p,h,f)};return d},executeAction:async(i,c,d,l={})=>{const m=o.find(([p])=>p===i);m?await m[1](c,d,l):console.warn(`Unknown action: ${i}`)}}}function xd(e){if(typeof e!="object"||e===null)return!1;const t=e;switch(t.type){case"patch":return typeof t.patch=="object"&&t.patch!==null;case"flat":case"nested":return typeof t.spec=="object"&&t.spec!==null;default:return!1}}function bd(e){const t={root:"",elements:{}};let n=!1;for(const o of e)if(o.type===el){if(!xd(o.data))continue;const s=o.data;if(s.type==="patch")n=!0,Kc(t,s.patch);else if(s.type==="flat")n=!0,Object.assign(t,s.spec);else if(s.type==="nested"){n=!0;const a=Zc(s.spec);Object.assign(t,a)}}return n?t:null}function G(){const{dir:e}=C.useDocumentDir(),t=C.useConfig();return u.useMemo(()=>{const n=K.resolveLanguage(t.language);return{t:(s,a)=>K.getTranslation(s,n,t.translationOverrides,a),language:n,dir:K.isRtlLanguage(n)?"rtl":"ltr",hostDocumentDir:e}},[t.language,t.translationOverrides,e])}function Ma(e){const t=K.resolveLanguage(e);return(n,o)=>K.getTranslation(n,t,void 0,o)}const wd={t:Ma("en"),anchorTarget:"_blank"},Ra=u.createContext(wd);function vd({host:e,children:t}){return r.jsx(Ra.Provider,{value:e,children:t})}function rn(){return u.useContext(Ra)}function yd({language:e,onUiAction:t,anchorTarget:n="_blank"}){return u.useMemo(()=>({t:Ma(e),anchorTarget:n,onUiAction:t}),[e,n,t])}class kd extends u.Component{constructor(){super(...arguments);Do(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n){K.log.error("json-render: spec failed to render",{_e:n instanceof Error?n.message:String(n)})}componentDidUpdate(n){this.state.hasError&&n.resetKey!==this.props.resetKey&&this.setState({hasError:!1})}render(){return this.state.hasError?null:this.props.children}}function jd(e){if(!e.elements)return e;let t=!1;const n={};for(const[o,s]of Object.entries(e.elements)){const a=Cd(s,e);a!==s&&(t=!0),n[o]=a}return t?{...e,elements:n}:e}function Cd(e,t){if(e.type!=="List")return e;const n=e.repeat;if(!n||typeof n.statePath!="string")return e;const o=K.isRecord(e.props)?e.props:{},s=o.items;if(Array.isArray(s)&&s.length>0)return e;const i=ce(t.state??{},n.statePath);if(!Array.isArray(i)||i.length===0)return e;const{repeat:c,...d}=e;return{...d,props:{...o,items:i}}}function z(...e){return Fc.twMerge(Dc.clsx(e))}const Sd=u.lazy(()=>Promise.resolve().then(()=>require("./Chart.impl-DJvHoxYS.cjs")));function Nd(e){const t=e.height??220;return r.jsx(u.Suspense,{fallback:r.jsx(_d,{height:t}),children:r.jsx(Sd,{...e})})}function _d({height:e}){return r.jsx("div",{className:"w-full animate-pulse rounded-lg bg-muted-foreground/10",style:{height:e},"aria-hidden":!0})}const Pa=S.z.object({title:S.z.string().nullish(),description:S.z.string().nullish()}),Oa=S.z.object({direction:S.z.enum(["row","column"]).nullish(),gap:S.z.enum(["sm","md","lg"]).nullish(),align:S.z.enum(["start","center","end","stretch"]).nullish(),justify:S.z.enum(["start","center","end","between"]).nullish()}),La=S.z.object({columns:S.z.union([S.z.literal(1),S.z.literal(2),S.z.literal(3)]).nullish(),gap:S.z.enum(["sm","md","lg"]).nullish()}),$a=S.z.object({text:S.z.string(),level:S.z.union([S.z.literal(1),S.z.literal(2),S.z.literal(3),S.z.literal(4)]).nullish()}),Da=S.z.object({text:S.z.string(),variant:S.z.enum(["body","caption","muted","code"]).nullish()}),Fa=S.z.object({text:S.z.string(),variant:S.z.enum(["default","secondary","success","warning","destructive"]).nullish()}),Ed=new Set(["http:","https:","mailto:"]),Ad=S.z.string().nullish().transform(e=>{if(!e)return null;try{return Ed.has(new URL(e).protocol)?e:null}catch{return null}}),Ha=S.z.object({id:S.z.string().nullish(),label:S.z.string(),secondary:S.z.string().nullish(),badge:S.z.string().nullish(),status:S.z.enum(["success","warning","error","info","neutral"]).nullish(),href:Ad}),Wa=S.z.object({items:S.z.array(Ha),maxVisible:S.z.number().int().positive().nullish()}),Td=S.z.object({items:S.z.array(Ha.extend({href:S.z.string().nullish()})),maxVisible:Wa.shape.maxVisible}),Ba=S.z.object({columns:S.z.array(S.z.string()),rows:S.z.array(S.z.array(S.z.string())),caption:S.z.string().nullish()}),Id=S.z.object({value:S.z.string(),direction:S.z.enum(["up","down","flat"]),label:S.z.string().nullish()}),Ua=S.z.object({label:S.z.string(),value:S.z.string(),description:S.z.string().nullish(),trend:S.z.enum(["up","down","neutral"]).nullish(),delta:Id.nullish()}),qa=S.z.object({type:S.z.enum(["info","tip","warning","important"]).nullish(),title:S.z.string().nullish(),content:S.z.string()}),zd=S.z.object({label:S.z.string(),value:S.z.number()}),Va=S.z.object({type:S.z.enum(["bar","line","pie"]),data:S.z.array(zd),title:S.z.string().nullish(),height:S.z.number().int().positive().nullish(),centerLabel:S.z.string().nullish()}),Ya=S.z.object({agentId:S.z.string(),agentName:S.z.string(),model:S.z.string().nullish()});function Se(e,t,n){const o=e.safeParse(t);return o.success?o.data:n}const Md=Xl(Gl,{components:{Card:{props:Pa,slots:["default"],description:"Container card with an optional title/description. Group related content.",example:{title:"Order summary",description:"Placed 2 days ago"}},Stack:{props:Oa,slots:["default"],description:'Flex layout. Use direction="row" for side-by-side, "column" (default) to stack.'},Grid:{props:La,slots:["default"],description:"Column grid that wraps on narrow screens. columns=2 for side-by-side metrics or cards; columns=3 only for three short metrics — the chat panel is about 400px wide, so three wide cells wrap."},Heading:{props:$a,description:"Section heading. level 1 (largest) to 4.",example:{text:"Your orders",level:3}},Text:{props:Da,description:'A paragraph of text. variant "muted"/"caption" for secondary text, "code" for monospace.'},Badge:{props:Fa,description:"Small status pill. Use variant to convey state (success/warning/destructive).",example:{text:"Delivered",variant:"success"}},List:{props:Td,description:"A vertical list of items, each with a label and optional secondary text, badge, and status dot. Pass the full array in `items` — do NOT use repeat/state for the rows.",example:{items:[{label:"Order #1024",secondary:"Shipped",status:"success"},{label:"Order #1025",secondary:"Processing",status:"warning"}]}},Table:{props:Ba,description:"A data table. `columns` are header strings; `rows` is a 2D array of cell strings (each row same length as columns).",example:{columns:["Item","Qty","Price"],rows:[["Widget","2","$20"],["Gadget","1","$15"]]}},Metric:{props:Ua,description:"A single key figure (KPI / insight card) with a label, big value, optional description, trend arrow, and an optional period-over-period delta ({ value, direction, label }).",example:{label:"Total spent",value:"$1,240",description:"Last 30 days",trend:"up",delta:{value:"+8%",direction:"up",label:"vs previous 30d"}}},Callout:{props:qa,description:"A highlighted info / tip / warning box for a single important note. Use for one call-out, not for long prose.",example:{type:"tip",title:"Heads up",content:"Free shipping over $50."}},PhoneAgentCard:{props:Ya,description:'A phone agent card with a "Test via web" action. NEVER author this yourself: it only comes back, already fenced, from the phone-agent tools — carry that fence verbatim.',example:{agentId:"00000000-0000-4000-8000-000000000000",agentName:"Support line",model:"oppie-vox-livekit"}},Chart:{props:Va,description:"A bar, line, or pie (donut) chart. `data` is an array of { label, value } points. Choose by the question: line = trend over time, bar = comparison across categories, pie = share of a total (optional `centerLabel` shows a big number in the donut hole). Use for trends or distributions, not for a handful of numbers (use Metric for those). Colours, axes, legend, and tooltips are handled for you.",example:{type:"bar",title:"Orders per month",data:[{label:"Jan",value:12},{label:"Feb",value:18}]}}},actions:{}});function br({height:e=64}){return r.jsx("div",{className:"w-full animate-pulse rounded-lg bg-muted-foreground/10",style:{height:e},"aria-hidden":!0})}const ns={sm:"gap-1.5",md:"gap-3",lg:"gap-4"},Rd="10rem";function Pd(e){return e===1?"minmax(0, 1fr)":`repeat(auto-fit, minmax(max(${Rd}, calc(100% / ${e} - 1rem)), 1fr))`}const{registry:rs}=gd(Md,{components:{Card:({props:e,children:t,loading:n})=>{const o=Se(Pa,e,{});return r.jsxs("div",{className:"flex flex-col gap-2 rounded-xl border border-muted-foreground/15 p-3",children:[(o.title||o.description)&&r.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.title&&r.jsx("div",{className:"text-sm font-semibold text-foreground",children:o.title}),o.description&&r.jsx("div",{className:"text-xs text-muted-foreground",children:o.description})]}),Jn(t,n)]})},Stack:({props:e,children:t,loading:n})=>{const o=Se(Oa,e,{}),s={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"}[o.align??"stretch"],a={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between"}[o.justify??"start"];return r.jsx("div",{className:z("flex",o.direction==="row"?"flex-row":"flex-col",ns[o.gap??"md"],s,a),children:Jn(t,n)})},Grid:({props:e,children:t,loading:n})=>{const o=Se(La,e,{});return r.jsx("div",{className:z("grid",ns[o.gap??"md"]),style:{gridTemplateColumns:Pd(o.columns??1)},children:Jn(t,n)})},Heading:({props:e})=>{const t=Se($a,e,{text:""}),n=t.level??3,o={1:"text-xl font-bold",2:"text-lg font-bold",3:"text-base font-semibold",4:"text-sm font-semibold"}[n]??"text-base font-semibold";return u.createElement(`h${n}`,{className:z("text-foreground",o)},t.text)},Text:({props:e})=>{const t=Se(Da,e,{text:""});if(t.variant==="code")return r.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:t.text});const n=t.variant==="muted"||t.variant==="caption";return r.jsx("p",{className:z("whitespace-pre-wrap",n?"text-xs text-muted-foreground":"text-sm text-foreground"),children:t.text})},Badge:({props:e})=>{const t=Se(Fa,e,{text:""}),n={default:"bg-primary text-primary-foreground",secondary:"bg-secondary text-secondary-foreground",success:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",warning:"bg-amber-500/15 text-amber-600 dark:text-amber-400",destructive:"bg-destructive/15 text-destructive"}[t.variant??"secondary"];return r.jsx("span",{className:z("inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium",n),children:t.text})},List:({props:e,loading:t})=>{const n=Se(Wa,e,{items:[]});return n.items.length===0?t?r.jsx(br,{}):r.jsx(os,{translationKey:"json_no_items"}):r.jsx(Yd,{items:n.items,maxVisible:n.maxVisible})},Table:({props:e,loading:t})=>{const n=Se(Ba,e,{columns:[],rows:[]});return t&&n.rows.length===0?r.jsx(br,{}):n.columns.length===0?r.jsx(os,{translationKey:"json_no_data"}):r.jsx("div",{className:"overflow-x-auto rounded-lg border border-muted-foreground/15",children:r.jsxs("table",{className:"w-full text-sm",children:[n.caption&&r.jsx("caption",{className:"px-3 py-2 text-start text-xs text-muted-foreground",children:n.caption}),r.jsx("thead",{children:r.jsx("tr",{className:"border-b border-muted-foreground/15 bg-muted/40",children:n.columns.map((o,s)=>r.jsx("th",{className:"px-3 py-2 text-start font-medium text-foreground",children:o},s))})}),r.jsx("tbody",{children:n.rows.map((o,s)=>r.jsx("tr",{className:"border-b border-muted-foreground/10 last:border-0",children:o.map((a,i)=>r.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:a},i))},s))})]})})},Metric:({props:e})=>{const t=Se(Ua,e,{label:"",value:""});return r.jsx(Ud,{label:t.label,value:t.value,description:t.description,trend:t.trend,delta:t.delta})},Callout:({props:e})=>{const t=Se(qa,e,{content:""}),n=Ld[t.type??"info"],o=n.Icon;return r.jsxs("div",{className:z("flex gap-2 rounded-lg border-l-2 p-3",n.cls),children:[r.jsx(o,{className:"mt-0.5 size-4 shrink-0"}),r.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.title&&r.jsx("span",{className:"text-sm font-semibold",children:t.title}),r.jsx("span",{className:"text-sm",children:t.content})]})]})},PhoneAgentCard:({props:e})=>{const t=Se(Ya,e,{agentId:"",agentName:""});return r.jsx(Dd,{...t})},Chart:({props:e})=>{const t=Se(Va,e,{type:"bar",data:[]});return r.jsxs("div",{className:"flex flex-col gap-1",children:[t.title&&r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:t.title}),r.jsx(Nd,{...t})]})}}}),Od=({element:e})=>{const{t}=rn();return r.jsx("div",{className:"rounded-lg border border-dashed border-muted-foreground/30 px-2 py-1.5 text-xs text-muted-foreground",children:t("json_unsupported",{type:e.type})})},Ld={info:{Icon:M.Info,cls:"border-l-blue-500 bg-blue-500/5 text-foreground"},tip:{Icon:M.Lightbulb,cls:"border-l-emerald-500 bg-emerald-500/5 text-foreground"},warning:{Icon:M.AlertTriangle,cls:"border-l-amber-500 bg-amber-500/5 text-foreground"},important:{Icon:M.AlertCircle,cls:"border-l-red-500 bg-red-500/5 text-foreground"}};function Jn(e,t){return u.Children.toArray(e).length>0?e:t?r.jsx(br,{}):null}function os({translationKey:e}){const{t}=rn();return r.jsx("div",{className:"rounded-lg border border-muted-foreground/15 px-3 py-2 text-xs text-muted-foreground",children:t(e)})}const $d="oppie-vox-livekit";function Dd({agentId:e,agentName:t,model:n}){const{t:o,onUiAction:s}=rn(),a=!!s&&!!e&&n===$d;return r.jsxs("div",{className:"flex w-full flex-col gap-3 rounded-xl border border-muted-foreground/15 p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:r.jsx(M.Phone,{className:"size-4","aria-hidden":!0})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:t}),r.jsx("div",{className:"text-xs text-muted-foreground",children:o("json_phone_agent")})]})]}),a&&r.jsxs("button",{type:"button",className:"flex w-full items-center justify-center gap-2 rounded-lg bg-secondary px-3 py-2 text-sm font-medium text-secondary-foreground hover:bg-secondary/80",onClick:()=>s==null?void 0:s({type:"test-phone-agent",payload:{agentId:e,model:n??null}}),children:[r.jsx(M.Play,{className:"size-4","aria-hidden":!0}),o("json_phone_agent_test")]})]})}const Fd={up:"↑",down:"↓",neutral:"→"},Hd={up:"text-emerald-600 dark:text-emerald-400",down:"text-red-600 dark:text-red-400",neutral:"text-muted-foreground"},Wd={up:"↑",down:"↓",flat:"→"},Bd={up:"text-emerald-600 dark:text-emerald-400",down:"text-red-600 dark:text-red-400",flat:"text-muted-foreground"};function Ud({label:e,value:t,description:n,trend:o,delta:s}){return r.jsxs("div",{className:"min-w-[140px] space-y-1 rounded-xl border border-muted-foreground/15 p-3",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:e}),r.jsxs("div",{className:"flex items-baseline gap-2",children:[r.jsx("span",{className:"text-2xl font-medium tracking-tight text-foreground",children:t}),o?r.jsx("span",{className:z("text-sm font-medium",Hd[o]),children:Fd[o]}):null]}),s?r.jsxs("div",{className:"flex items-baseline gap-1 text-xs",children:[r.jsxs("span",{className:z("font-medium",Bd[s.direction]),children:[Wd[s.direction]," ",s.value]}),s.label?r.jsx("span",{className:"text-muted-foreground",children:s.label}):null]}):null,n?r.jsx("span",{className:"block text-xs text-muted-foreground",children:n}):null]})}const qd={success:"bg-emerald-500",warning:"bg-amber-500",error:"bg-red-500",info:"bg-blue-500",neutral:"bg-muted-foreground/40"};function Vd({item:e,showBadge:t,showSecondary:n,showStatus:o}){return r.jsxs(r.Fragment,{children:[t&&(e.badge?r.jsx("span",{className:"block min-w-0 truncate text-xs font-medium",title:e.badge,children:e.badge}):r.jsx("span",{})),r.jsx("span",{className:"block min-w-0 truncate",title:e.label,children:e.label}),n&&(e.secondary?r.jsx("span",{className:"block min-w-0 truncate text-xs text-muted-foreground",title:e.secondary,children:e.secondary}):r.jsx("span",{})),o&&(e.status?r.jsx("span",{className:z("size-2 rounded-full",qd[e.status]),"aria-hidden":!0}):r.jsx("span",{}))]})}function Yd({items:e,maxVisible:t}){const n=t??10,{anchorTarget:o,t:s}=rn(),[a,i]=u.useState(!1),c=e.length>n,d=a?e:e.slice(0,n),l=d.some(x=>!!x.badge),m=d.some(x=>!!x.secondary),p=d.some(x=>!!x.status),h=[l&&"auto","minmax(0,1fr)",m&&"minmax(0,2fr)",p&&"auto"].filter(Boolean).join(" "),f="grid min-w-0 grid-cols-[subgrid] col-span-full items-center gap-x-2.5 px-3 py-2 text-sm text-foreground";return r.jsxs("div",{className:"grid overflow-hidden rounded-lg border border-muted-foreground/15",style:{gridTemplateColumns:h},children:[d.map((x,g)=>{const y=x.id??`row-${g}`,w=r.jsx(Vd,{item:x,showBadge:l,showSecondary:m,showStatus:p});return x.href?r.jsx("a",{href:x.href,target:o||"_top",rel:"noopener noreferrer",className:z(f,"transition-colors hover:bg-muted/50",g>0&&"border-t border-muted-foreground/10"),children:w},y):r.jsx("div",{className:z(f,g>0&&"border-t border-muted-foreground/10"),children:w},y)}),c&&r.jsx("button",{type:"button",className:"col-span-full flex w-full items-center justify-center gap-1 border-t border-muted-foreground/10 py-2 text-xs text-muted-foreground transition-colors hover:bg-muted/50",onClick:()=>i(x=>!x),children:a?r.jsxs(r.Fragment,{children:[r.jsx(M.ChevronUp,{className:"size-3"}),s("json_see_less")]}):r.jsxs(r.Fragment,{children:[r.jsx(M.ChevronDown,{className:"size-3"}),s("json_see_more",{count:e.length-n})]})})]})}function Xa({spec:e,active:t=!1}){const{anchorTarget:n,onUiAction:o}=C.useConfig(),{t:s}=G(),a=u.useMemo(()=>({t:s,anchorTarget:n??"_blank",onUiAction:o}),[s,n,o]);return r.jsx(Ga,{spec:e,host:a,active:t})}function Xd({spec:e,language:t,onUiAction:n,anchorTarget:o}){const s=yd({language:t,onUiAction:n,anchorTarget:o});return r.jsx(Ga,{spec:e,host:s})}function Ga({spec:e,host:t,active:n=!1}){return r.jsx(vd,{host:t,children:r.jsx(kd,{resetKey:e,children:r.jsx(Gd,{spec:e,active:n})})})}function Gd({spec:e,active:t}){const n=u.useMemo(()=>e?jd(e):null,[e]);return!n||!ya(n)?null:r.jsx(hd,{registry:rs,initialState:n.state,children:r.jsx(md,{spec:n,registry:rs,loading:t,fallback:Od})})}function Ka(e){if(!e)return[];const t=e.split(`
|
|
10
|
+
Note: state patches appear right after the elements that use them, so the UI fills in as it streams. ONLY use component types from the AVAILABLE COMPONENTS list below.`),i.push(""),i.push("INITIAL STATE:"),i.push("Specs include a /state field to seed the state model. Components with { $bindState } or { $bindItem } read from and write to this state, and $state expressions read from it."),i.push("CRITICAL: You MUST include state patches whenever your UI displays data via $state, $bindState, $bindItem, $item, or $index expressions, or uses repeat to iterate over arrays. Without state, these references resolve to nothing and repeat lists render zero items."),i.push("Output state patches right after the elements that reference them, so the UI fills in progressively as it streams."),i.push("Stream state progressively - output one patch per array item instead of one giant blob:"),i.push(' For arrays: {"op":"add","path":"/state/posts/0","value":{"id":"1","title":"First Post",...}} then /state/posts/1, /state/posts/2, etc.'),i.push(' For scalars: {"op":"add","path":"/state/newTodoText","value":""}'),i.push(' Initialize the array first if needed: {"op":"add","path":"/state/posts","value":[]}'),i.push('When content comes from the state model, use { "$state": "/some/path" } dynamic props to display it instead of hardcoding the same value in both state and props. The state model is the single source of truth.'),i.push("Include realistic sample data in state. For blogs: 3-4 posts with titles, excerpts, authors, dates. For product lists: 3-5 items with names, prices, descriptions. Never leave arrays empty."),i.push(""),i.push("DYNAMIC LISTS (repeat field):"),i.push('Any element can have a top-level "repeat" field to render its children once per item in a state array: { "repeat": { "statePath": "/arrayPath", "key": "id" } }.'),i.push('The element itself renders once (as the container), and its children are expanded once per array item. "statePath" is the state array path. "key" is an optional field name on each item for stable React keys.'),i.push(`Example: ${JSON.stringify({type:l,props:f,repeat:{statePath:"/todos",key:"id"},children:["todo-item"]})}`),i.push('Inside children of a repeated element, use { "$item": "field" } to read a field from the current item, and { "$index": true } to get the current array index. For two-way binding to an item field use { "$bindItem": "completed" } on the appropriate prop.'),i.push("ALWAYS use the repeat field for lists backed by state arrays. NEVER hardcode individual elements for each array item."),i.push('IMPORTANT: "repeat" is a top-level field on the element (sibling of type/props/children), NOT inside props.'),i.push(""),i.push("ARRAY STATE ACTIONS:"),i.push('Use action "pushState" to append items to arrays. Params: { statePath: "/arrayPath", value: { ...item }, clearStatePath: "/inputPath" }.'),i.push('Values inside pushState can contain { "$state": "/statePath" } references to read current state (e.g. the text from an input field).'),i.push('Use "$id" inside a pushState value to auto-generate a unique ID.'),i.push('Example: on: { "press": { "action": "pushState", "params": { "statePath": "/todos", "value": { "id": "$id", "title": { "$state": "/newTodoText" }, "completed": false }, "clearStatePath": "/newTodoText" } } }'),i.push(`Use action "removeState" to remove items from arrays by index. Params: { statePath: "/arrayPath", index: N }. Inside a repeated element's children, use { "$index": true } for the current item index. Action params support the same expressions as props: { "$item": "field" } resolves to the absolute state path, { "$index": true } resolves to the index number, and { "$state": "/path" } reads a value from state.`),i.push("For lists where users can add/remove items (todos, carts, etc.), use pushState and removeState instead of hardcoding with setState."),i.push(""),i.push('IMPORTANT: State paths use RFC 6901 JSON Pointer syntax (e.g. "/todos/0/title"). Do NOT use JavaScript-style dot notation (e.g. "/todos.length" is WRONG). To generate unique IDs for new items, use "$id" instead of trying to read array length.'),i.push("");const j=c;if(j){i.push(`AVAILABLE COMPONENTS (${e.componentNames.length}):`),i.push("");for(const[E,I]of Object.entries(j)){const W=I.props?Te(I.props):"{}",U=I.slots&&I.slots.length>0?" [accepts children]":"",Y=I.events&&I.events.length>0?` [events: ${I.events.join(", ")}]`:"",q=I.description?` - ${I.description}`:"";i.push(`- ${E}: ${W}${q}${U}${Y}`)}i.push("")}const b=e.data.actions,_=e.schema.builtInActions??[],v=b&&e.actionNames.length>0,k=_.length>0;if(v||k){i.push("AVAILABLE ACTIONS:"),i.push("");for(const E of _)i.push(`- ${E.name}: ${E.description} [built-in]`);if(v)for(const[E,I]of Object.entries(b))i.push(`- ${E}${I.description?`: ${I.description}`:""}`);i.push("")}i.push("EVENTS (the `on` field):"),i.push("Elements can have an optional `on` field to bind events to actions. The `on` field is a top-level field on the element (sibling of type/props/children), NOT inside props."),i.push('Each key in `on` is an event name (from the component\'s supported events), and the value is an action binding: `{ "action": "<actionName>", "params": { ... } }`.'),i.push(""),i.push("Example:"),i.push(` ${JSON.stringify({type:l,props:f,on:{press:{action:"setState",params:{statePath:"/saved",value:!0}}},children:[]})}`),i.push(""),i.push('Action params can use dynamic references to read from state: { "$state": "/statePath" }.'),i.push("IMPORTANT: Do NOT put action/actionParams inside props. Always use the `on` field for event bindings."),i.push(""),i.push("VISIBILITY CONDITIONS:"),i.push("Elements can have an optional `visible` field to conditionally show/hide based on state. IMPORTANT: `visible` is a top-level field on the element object (sibling of type/props/children), NOT inside props."),i.push(`Correct: ${JSON.stringify({type:l,props:f,visible:{$state:"/activeTab",eq:"home"},children:["..."]})}`),i.push('- `{ "$state": "/path" }` - visible when state at path is truthy'),i.push('- `{ "$state": "/path", "not": true }` - visible when state at path is falsy'),i.push('- `{ "$state": "/path", "eq": "value" }` - visible when state equals value'),i.push('- `{ "$state": "/path", "neq": "value" }` - visible when state does not equal value'),i.push('- `{ "$state": "/path", "gt": N }` / `gte` / `lt` / `lte` - numeric comparisons'),i.push("- Use ONE operator per condition (eq, neq, gt, gte, lt, lte). Do not combine multiple operators."),i.push('- Any condition can add `"not": true` to invert its result'),i.push("- `[condition, condition]` - all conditions must be true (implicit AND)"),i.push('- `{ "$and": [condition, condition] }` - explicit AND (use when nesting inside $or)'),i.push('- `{ "$or": [condition, condition] }` - at least one must be true (OR)'),i.push("- `true` / `false` - always visible/hidden"),i.push(""),i.push("Use a component with on.press bound to setState to update state and drive visibility."),i.push(`Example: A ${l} with on: { "press": { "action": "setState", "params": { "statePath": "/activeTab", "value": "home" } } } sets state, then a container with visible: { "$state": "/activeTab", "eq": "home" } shows only when that tab is active.`),i.push(""),i.push('For tab patterns where the first/default tab should be visible when no tab is selected yet, use $or to handle both cases: visible: { "$or": [{ "$state": "/activeTab", "eq": "home" }, { "$state": "/activeTab", "not": true }] }. This ensures the first tab is visible both when explicitly selected AND when /activeTab is not yet set.'),i.push(""),i.push("DYNAMIC PROPS:"),i.push("Any prop value can be a dynamic expression that resolves based on state. Three forms are supported:"),i.push(""),i.push('1. Read-only state: `{ "$state": "/statePath" }` - resolves to the value at that state path (one-way read).'),i.push(' Example: `"color": { "$state": "/theme/primary" }` reads the color from state.'),i.push(""),i.push('2. Two-way binding: `{ "$bindState": "/statePath" }` - resolves to the value at the state path AND enables write-back. Use on form input props (value, checked, pressed, etc.).'),i.push(' Example: `"value": { "$bindState": "/form/email" }` binds the input value to /form/email.'),i.push(' Inside repeat scopes: `"checked": { "$bindItem": "completed" }` binds to the current item\'s completed field.'),i.push(""),i.push('3. Conditional: `{ "$cond": <condition>, "$then": <value>, "$else": <value> }` - evaluates the condition (same syntax as visibility conditions) and picks the matching value.'),i.push(' Example: `"color": { "$cond": { "$state": "/activeTab", "eq": "home" }, "$then": "#007AFF", "$else": "#8E8E93" }`'),i.push(""),i.push("Use $bindState for form inputs (text fields, checkboxes, selects, sliders, etc.) and $state for read-only data display. Inside repeat scopes, use $bindItem for form inputs bound to the current item. Use dynamic props instead of duplicating elements with opposing visible conditions when only prop values differ."),i.push(""),i.push('4. Template: `{ "$template": "Hello, ${/name}!" }` - interpolates references in the string. Absolute paths like `${/path}` resolve against the state model. Bare names like `${field}` resolve against the current repeat item first, then fall back to the state model at `/<field>`.'),i.push(' Example: `"label": { "$template": "Items: ${/cart/count} | Total: ${/cart/total}" }` renders "Items: 3 | Total: 42.00" when /cart/count is 3 and /cart/total is 42.00. Inside a repeat, `{ "$template": "${name} - ${email}" }` reads name and email from each item.'),i.push("");const N=e.data.functions;if(N&&Object.keys(N).length>0){i.push('5. Computed: `{ "$computed": "<functionName>", "args": { "key": <expression> } }` - calls a registered function with resolved args and returns the result.'),i.push(' Example: `"value": { "$computed": "fullName", "args": { "first": { "$state": "/form/firstName" }, "last": { "$state": "/form/lastName" } } }`'),i.push(" Available functions:");for(const E of Object.keys(N))i.push(` - ${E}`);i.push("")}const R=t.directives;if(R&&R.length>0){i.push("CUSTOM DYNAMIC VALUES:"),i.push("");for(const E of R){const I=E.description?` (${E.description})`:"";i.push(`- ${E.name}${I}: ${Te(E.schema)}`)}i.push(""),i.push("Directives compose: any value field can contain another directive or a $state expression, resolved inside-out."),i.push("")}(c?Object.entries(c).some(([,E])=>E.props?Te(E.props).includes("checks"):!1):!1)&&(i.push("VALIDATION:"),i.push("Form components that accept a `checks` prop support client-side validation."),i.push('Each check is an object: { "type": "<name>", "message": "...", "args": { ... } }'),i.push(""),i.push("Built-in validation types:"),i.push(" - required — value must be non-empty"),i.push(" - email — valid email format"),i.push(' - minLength — minimum string length (args: { "min": N })'),i.push(' - maxLength — maximum string length (args: { "max": N })'),i.push(' - pattern — match a regex (args: { "pattern": "regex" })'),i.push(' - min — minimum numeric value (args: { "min": N })'),i.push(' - max — maximum numeric value (args: { "max": N })'),i.push(" - numeric — value must be a number"),i.push(" - url — valid URL format"),i.push(' - matches — must equal another field (args: { "other": { "$state": "/path" } })'),i.push(' - equalTo — alias for matches (args: { "other": { "$state": "/path" } })'),i.push(' - lessThan — value must be less than another field (args: { "other": { "$state": "/path" } })'),i.push(' - greaterThan — value must be greater than another field (args: { "other": { "$state": "/path" } })'),i.push(' - requiredIf — required only when another field is truthy (args: { "field": { "$state": "/path" } })'),i.push(""),i.push("Example:"),i.push(' "checks": [{ "type": "required", "message": "Email is required" }, { "type": "email", "message": "Invalid email" }]'),i.push(""),i.push("IMPORTANT: When using checks, the component must also have a { $bindState } or { $bindItem } on its value/checked prop for two-way binding."),i.push("Always include validation checks on form inputs for a good user experience (e.g. required, email, minLength)."),i.push("")),(v||k)&&(i.push("STATE WATCHERS:"),i.push("Elements can have an optional `watch` field to react to state changes and trigger actions. The `watch` field is a top-level field on the element (sibling of type/props/children), NOT inside props."),i.push("Maps state paths (JSON Pointers) to action bindings. When the value at a watched path changes, the bound actions fire automatically."),i.push(""),i.push("Example (cascading select — country changes trigger city loading):"),i.push(` ${JSON.stringify({type:"Select",props:{value:{$bindState:"/form/country"},options:["US","Canada","UK"]},watch:{"/form/country":{action:"loadCities",params:{country:{$state:"/form/country"}}}},children:[]})}`),i.push(""),i.push("Use `watch` for cascading dependencies where changing one field should trigger side effects (loading data, resetting dependent fields, computing derived values)."),i.push("IMPORTANT: `watch` is a top-level field on the element (sibling of type/props/children), NOT inside props. Watchers only fire when the value changes, not on initial render."),i.push(""));const A=t.editModes;A&&A.length>0&&i.push(Ml({modes:A})),i.push("RULES:");const O=a==="inline"?["When generating UI, wrap all JSONL patches in a ```spec code fence - one JSON object per line inside the fence","Write a brief conversational response before any JSONL output",'First set root: {"op":"add","path":"/root","value":"<root-key>"}','Then add each element: {"op":"add","path":"/elements/<key>","value":{...}}',"Output /state patches right after the elements that use them, one per array item for progressive loading. REQUIRED whenever using $state, $bindState, $bindItem, $item, $index, or repeat.","ONLY use components listed above","Each element value needs: type, props, children (array of child keys)","Use unique keys for the element map entries (e.g., 'header', 'metric-1', 'chart-revenue')"]:["Output ONLY JSONL patches - one JSON object per line, no markdown, no code fences",'First set root: {"op":"add","path":"/root","value":"<root-key>"}','Then add each element: {"op":"add","path":"/elements/<key>","value":{...}}',"Output /state patches right after the elements that use them, one per array item for progressive loading. REQUIRED whenever using $state, $bindState, $bindItem, $item, $index, or repeat.","ONLY use components listed above","Each element value needs: type, props, children (array of child keys)","Use unique keys for the element map entries (e.g., 'header', 'metric-1', 'chart-revenue')"],P=e.schema.defaultRules??[];return[...O,...P,...o].forEach((E,I)=>{i.push(`${I+1}. ${E}`)}),i.join(`
|
|
11
|
+
`)}function Ko(e){return e.example&&Object.keys(e.example).length>0?e.example:e.props?ya(e.props):{}}function ya(e){if(!e||!e._def)return{};const t=e._def,n=ft(e);if(n!=="ZodObject"&&n!=="object")return{};const o=typeof t.shape=="function"?t.shape():t.shape;if(!o)return{};const s={};for(const[a,i]of Object.entries(o)){const c=ft(i);c==="ZodOptional"||c==="optional"||c==="ZodNullable"||c==="nullable"||(s[a]=fr(i))}return s}function fr(e){if(!e||!e._def)return"...";const t=e._def;switch(ft(e)){case"ZodString":case"string":return"example";case"ZodNumber":case"number":return 0;case"ZodBoolean":case"boolean":return!0;case"ZodLiteral":case"literal":return t.value;case"ZodEnum":case"enum":{if(Array.isArray(t.values)&&t.values.length>0)return t.values[0];if(t.entries&&typeof t.entries=="object"){const o=Object.values(t.entries);return o.length>0?o[0]:"example"}return"example"}case"ZodOptional":case"optional":case"ZodNullable":case"nullable":case"ZodDefault":case"default":{const o=t.innerType??t.wrapped;return o?fr(o):null}case"ZodArray":case"array":return[];case"ZodObject":case"object":return ya(e);case"ZodUnion":case"union":{const o=t.options;return o&&o.length>0?fr(o[0]):"..."}default:return"..."}}function Hl(e){if(!e||!e._def)return null;const t=e._def,n=ft(e);if(n!=="ZodObject"&&n!=="object")return null;const o=typeof t.shape=="function"?t.shape():t.shape;if(!o)return null;for(const[s,a]of Object.entries(o)){const i=ft(a);if(!(i==="ZodOptional"||i==="optional"||i==="ZodNullable"||i==="nullable")&&(i==="ZodString"||i==="string"))return s}return null}function ft(e){if(!e||!e._def)return"";const t=e._def;return t.typeName??t.type??""}function Te(e){if(!e||!e._def)return"unknown";const t=e._def;switch(ft(e)){case"ZodString":case"string":return"string";case"ZodNumber":case"number":return"number";case"ZodBoolean":case"boolean":return"boolean";case"ZodLiteral":case"literal":{const o=t.values,s=(o==null?void 0:o[0])??t.value;return JSON.stringify(s)}case"ZodEnum":case"enum":{let o;if(Array.isArray(t.values))o=t.values;else if(t.entries&&typeof t.entries=="object")o=Object.values(t.entries);else return"enum";return o.map(s=>`"${s}"`).join(" | ")}case"ZodArray":case"array":{const o=typeof t.element=="object"?t.element:typeof t.type=="object"?t.type:void 0;return o?`Array<${Te(o)}>`:"Array<unknown>"}case"ZodObject":case"object":{const o=typeof t.shape=="function"?t.shape():t.shape;return o?`{ ${Object.entries(o).map(([a,i])=>{const c=ft(i);return`${a}${c==="ZodOptional"||c==="ZodNullable"||c==="optional"||c==="nullable"?"?":""}: ${Te(i)}`}).join(", ")} }`:"object"}case"ZodOptional":case"optional":case"ZodNullable":case"nullable":{const o=t.innerType??t.wrapped;return o?Te(o):"unknown"}case"ZodUnion":case"union":{const o=t.options;return o?o.map(s=>Te(s)).join(" | "):"unknown"}case"ZodRecord":case"record":{const o=t.keyType??void 0,s=t.valueType??t.element??void 0,a=o?Te(o):"string",i=s?Te(s):"unknown";return`Record<${a}, ${i}>`}case"ZodDefault":case"default":{const o=t.innerType??t.wrapped;return o?Te(o):"unknown"}default:return"unknown"}}function Zo(e){return typeof e.type=="string"?e.type:typeof e.typeName=="string"?e.typeName:""}function Jo(e){return e.startsWith("Zod")?e.slice(3).toLowerCase():e.toLowerCase()}function Je(e,t=!1){const n=e._def;switch(Jo(Zo(n))){case"string":return{type:"string"};case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"literal":{const s=n.values;return{const:s?s[0]:n.value}}case"enum":{const s=n.entries;return{enum:(s?Object.values(s):n.values)??[]}}case"array":{const s=n.element??n.type;return{type:"array",items:s?Je(s,t):{}}}case"object":{const s=n.shape,a=typeof s=="function"?s():s;if(!a)return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{type:"object"};const i={},c=[];for(const[d,l]of Object.entries(a)){const m=l._def,p=Jo(Zo(m)),h=p==="optional"||p==="nullable";if(t)if(c.push(d),h){const f=Je(l,t);i[d]={anyOf:[f,{type:"null"}]}}else i[d]=Je(l,t);else i[d]=Je(l),h||c.push(d)}return{type:"object",properties:i,required:c.length>0?c:void 0,additionalProperties:!1}}case"record":{const s=n.valueType;return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{type:"object",additionalProperties:s?Je(s):!0}}case"optional":case"nullable":{const s=n.innerType;return s?Je(s,t):{}}case"union":{const s=n.options;return s?{anyOf:s.map(a=>Je(a,t))}:{}}case"any":case"unknown":return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{};default:return{}}}function Wl(e,t){return e.createCatalog(t)}var Bl=Pl(e=>({spec:e.object({root:e.string(),elements:e.record(e.object({type:e.ref("catalog.components"),props:e.propsOf("catalog.components"),children:e.array(e.string()),visible:e.any()}))}),catalog:e.object({components:e.map({props:e.zod(),slots:e.array(e.string()),description:e.string(),example:e.any()}),actions:e.map({params:e.zod(),description:e.string()})})}),{builtInActions:[{name:"setState",description:"Update a value in the state model at the given statePath. Params: { statePath: string, value: any }"},{name:"pushState",description:'Append an item to an array in state. Params: { statePath: string, value: any, clearStatePath?: string }. Value can contain {"$state":"/path"} refs and "$id" for auto IDs.'},{name:"removeState",description:"Remove an item from an array in state by index. Params: { statePath: string, index: number }"},{name:"validateForm",description:"Validate all registered form fields and write the result to state. Params: { statePath?: string }. Defaults to /formValidation. Result: { valid: boolean, errors: Record<string, string[]> }."}],defaultRules:["CRITICAL INTEGRITY CHECK: Before outputting ANY element that references children, you MUST have already output (or will output) each child as its own element. If an element has children: ['a', 'b'], then elements 'a' and 'b' MUST exist. A missing child element causes that entire branch of the UI to be invisible.","SELF-CHECK: After generating all elements, mentally walk the tree from root. Every key in every children array must resolve to a defined element. If you find a gap, output the missing element immediately.",'CRITICAL: The "visible" field goes on the ELEMENT object, NOT inside "props". Correct: {"type":"<ComponentName>","props":{},"visible":{"$state":"/tab","eq":"home"},"children":[...]}.','CRITICAL: The "on" field goes on the ELEMENT object, NOT inside "props". Use on.press, on.change, on.submit etc. NEVER put action/actionParams inside props.',"When the user asks for a UI that displays data (e.g. blog posts, products, users), ALWAYS include a state field with realistic sample data. The state field is a top-level field on the spec (sibling of root/elements).",'When building repeating content backed by a state array (e.g. posts, products, items), use the "repeat" field on a container element. Example: { "type": "<ContainerComponent>", "props": {}, "repeat": { "statePath": "/posts", "key": "id" }, "children": ["post-card"] }. Replace <ContainerComponent> with an appropriate component from the AVAILABLE COMPONENTS list. Inside repeated children, use { "$item": "field" } to read a field from the current item, and { "$index": true } for the current array index. For two-way binding to an item field use { "$bindItem": "completed" }. Do NOT hardcode individual elements for each array item.',"Design with visual hierarchy: use container components to group content, heading components for section titles, proper spacing, and status indicators. ONLY use components from the AVAILABLE COMPONENTS list.","For data-rich UIs, use multi-column layout components if available. For forms and single-column content, use vertical layout components. ONLY use components from the AVAILABLE COMPONENTS list.","Always include realistic, professional-looking sample data. For blogs include 3-4 posts with varied titles, authors, dates, categories. For products include names, prices, images. Never leave data empty."]}),ka=u.createContext(null);function Ul(e,t){return e?null:Object.keys(t).length===0?{}:Vr(t)}function ql({store:e,initialState:t={},onStateChange:n,children:o}){const s=u.useRef(void 0);!e&&!s.current&&(s.current=Gc(t));const a=e??s.current,i=u.useRef(a);i.current=a;const c=u.useRef(!!e);c.current=!!e;const d=u.useRef(e?"controlled":"uncontrolled"),l=u.useRef(!1);if(process.env.NODE_ENV!=="production"){const b=e?"controlled":"uncontrolled";b!==d.current&&!l.current&&(l.current=!0,console.warn(`StateProvider: switching from ${d.current} to ${b} mode is not supported.`))}const m=u.useRef(t),p=u.useRef(Ul(!!e,t));u.useEffect(()=>{if(e||t===m.current)return;m.current=t;const b=t&&Object.keys(t).length>0?Vr(t):{},_=p.current??{},v=new Set([...Object.keys(_),...Object.keys(b)]),k={};for(const N of v)_[N]!==b[N]&&(k[N]=N in b?b[N]:void 0);p.current=b,Object.keys(k).length>0&&a.update(k)},[e,t,a]);const h=u.useSyncExternalStore(a.subscribe,a.getSnapshot,a.getServerSnapshot??a.getSnapshot),f=u.useRef(n);f.current=n;const x=u.useCallback((b,_)=>{var N;const v=i.current,k=v.getSnapshot();v.set(b,_),!c.current&&v.getSnapshot()!==k&&((N=f.current)==null||N.call(f,[{path:b,value:_}]))},[]),g=u.useCallback(b=>{var k;const _=i.current,v=_.getSnapshot();if(_.update(b),!c.current&&_.getSnapshot()!==v){const N=[];for(const[R,T]of Object.entries(b))ce(v,R)!==T&&N.push({path:R,value:T});N.length>0&&((k=f.current)==null||k.call(f,N))}},[]),y=u.useCallback(b=>i.current.get(b),[]),w=u.useCallback(()=>i.current.getSnapshot(),[]),j=u.useMemo(()=>({state:h,get:y,set:x,update:g,getSnapshot:w}),[h,y,x,g,w]);return r.jsx(ka.Provider,{value:j,children:o})}function nn(){const e=u.useContext(ka);if(!e)throw new Error("useStateStore must be used within a StateProvider");return e}var ja=u.createContext(null);function Vl({children:e}){const{state:t}=nn(),n=u.useMemo(()=>({stateModel:t}),[t]),o=u.useMemo(()=>a=>At(a,n),[n]),s=u.useMemo(()=>({isVisible:o,ctx:n}),[o,n]);return r.jsx(ja.Provider,{value:s,children:e})}function Yl(){const e=u.useContext(ja);if(!e)throw new Error("useVisibility must be used within a VisibilityProvider");return e}var Ca=u.createContext(null);function Xl(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const s of n){const a=e[s],i=t[s];if(a!==i){if(typeof a=="object"&&a!==null&&typeof i=="object"&&i!==null){const c=a.$state,d=i.$state;if(typeof c=="string"&&c===d)continue}return!1}}return!0}function Gl(e,t){if(e===t)return!0;if(e.validateOn!==t.validateOn)return!1;const n=e.checks??[],o=t.checks??[];if(n.length!==o.length)return!1;for(let s=0;s<n.length;s++){const a=n[s],i=o[s];if(a.type!==i.type||a.message!==i.message||!Xl(a.args,i.args))return!1}return!0}function Kl({customFunctions:e={},children:t}){const{state:n,getSnapshot:o}=nn(),[s,a]=u.useState({}),i=u.useRef({}),[c,d]=u.useState({}),l=u.useCallback((g,y)=>{d(w=>{const j=w[g];return j&&Gl(j,y)?w:{...w,[g]:y}})},[]),m=u.useCallback((g,y)=>{var k;const w=o(),j=g.split("/").filter(Boolean);let b=w;for(const N of j)if(b!=null&&typeof b=="object")b=b[N];else{b=void 0;break}const _=Nl(y,{value:b,stateModel:w,customFunctions:e}),v={touched:((k=i.current[g])==null?void 0:k.touched)??!0,validated:!0,result:_};return i.current={...i.current,[g]:v},a(i.current),_},[e,o]),p=u.useCallback(g=>{var y,w;i.current={...i.current,[g]:{...i.current[g],touched:!0,validated:((y=i.current[g])==null?void 0:y.validated)??!1,result:((w=i.current[g])==null?void 0:w.result)??null}},a(i.current)},[]),h=u.useCallback(g=>{const{[g]:y,...w}=i.current;i.current=w,a(w)},[]),f=u.useCallback(()=>{let g=!0;for(const[y,w]of Object.entries(c))m(y,w).valid||(g=!1);return g},[c,m]),x=u.useMemo(()=>({customFunctions:e,get fieldStates(){return i.current},validate:m,touch:p,clear:h,validateAll:f,registerField:l}),[e,s,m,p,h,f,l]);return r.jsx(Ca.Provider,{value:x,children:t})}function Zl(){return u.useContext(Ca)}var Qo=0;function es(){return Qo+=1,`${Date.now()}-${Qo}`}function gr(e,t){if(e==null)return e;if(e==="$id")return es();if(typeof e=="object"&&!Array.isArray(e)){const n=e,o=Object.keys(n);if(o.length===1&&typeof n.$state=="string")return t(n.$state);if(o.length===1&&"$id"in n)return es()}if(Array.isArray(e))return e.map(n=>gr(n,t));if(typeof e=="object"){const n={};for(const[o,s]of Object.entries(e))n[o]=gr(s,t);return n}return e}var Sa=u.createContext(null);function Jl({handlers:e={},navigate:t,children:n}){const{get:o,set:s,getSnapshot:a}=nn(),i=Zl(),[c,d]=u.useState(e),[l,m]=u.useState(new Set),[p,h]=u.useState(null),f=u.useCallback((j,b)=>{d(_=>({..._,[j]:b}))},[]),x=u.useCallback(async j=>{var R;const b=kl(j,a()),_=fl(),v=Date.now();ml({id:_,name:b.action,params:b.params,at:v});let k=!0,N;try{if(b.action==="setState"&&b.params){const A=b.params.statePath,O=b.params.value;A&&s(A,O);return}if(b.action==="pushState"&&b.params){const A=b.params.statePath,O=b.params.value;if(A){const P=gr(O,o),B=o(A)??[];s(A,[...B,P]);const E=b.params.clearStatePath;E&&s(E,"")}return}if(b.action==="removeState"&&b.params){const A=b.params.statePath,O=b.params.index;if(A!==void 0&&O!==void 0){const P=o(A)??[];s(A,P.filter((B,E)=>E!==O))}return}if(b.action==="push"&&b.params){const A=b.params.screen;if(A){const O=o("/currentScreen"),P=o("/navStack")??[];O?s("/navStack",[...P,O]):s("/navStack",[...P,""]),s("/currentScreen",A)}return}if(b.action==="pop"){const A=o("/navStack")??[];if(A.length>0){const O=A[A.length-1];s("/navStack",A.slice(0,-1)),O?s("/currentScreen",O):s("/currentScreen",void 0)}return}if(b.action==="validateForm"){const A=i==null?void 0:i.validateAll;if(!A){console.warn("validateForm action was dispatched but no ValidationProvider is connected. Ensure ValidationProvider is rendered inside the provider tree.");return}const O=A(),P={};for(const[E,I]of Object.entries(i.fieldStates))I.result&&!I.result.valid&&(P[E]=I.result.errors);const B=((R=b.params)==null?void 0:R.statePath)||"/formValidation";s(B,{valid:O,errors:P});return}const T=c[b.action];if(!T){console.warn(`No handler registered for action: ${b.action}`);return}if(b.confirm)return new Promise((A,O)=>{h({action:b,handler:T,resolve:()=>{h(null),A()},reject:()=>{h(null),O(new Error("Action cancelled"))}})}).then(async()=>{m(A=>new Set(A).add(b.action));try{await Xo({action:b,handler:T,setState:s,navigate:t,executeAction:async A=>{await x({action:A})}})}finally{m(A=>{const O=new Set(A);return O.delete(b.action),O})}});m(A=>new Set(A).add(b.action));try{await Xo({action:b,handler:T,setState:s,navigate:t,executeAction:async A=>{await x({action:A})}})}finally{m(A=>{const O=new Set(A);return O.delete(b.action),O})}}catch(T){throw k=!1,N=T,T}finally{const T=Date.now();hl({id:_,name:b.action,ok:k,at:T,durationMs:T-v,error:N})}},[c,o,s,a,t,i]),g=u.useCallback(()=>{p==null||p.resolve()},[p]),y=u.useCallback(()=>{p==null||p.reject()},[p]),w=u.useMemo(()=>({handlers:c,loadingActions:l,pendingConfirmation:p,execute:x,confirm:g,cancel:y,registerHandler:f}),[c,l,p,x,g,y,f]);return r.jsx(Sa.Provider,{value:w,children:n})}function Na(){const e=u.useContext(Sa);if(!e)throw new Error("useActions must be used within an ActionProvider");return e}function Ql({confirm:e,onConfirm:t,onCancel:n}){const o=e.variant==="danger";return r.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:50},onClick:n,children:r.jsxs("div",{style:{backgroundColor:"white",borderRadius:"8px",padding:"24px",maxWidth:"400px",width:"100%",boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.1)"},onClick:s=>s.stopPropagation(),children:[r.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"18px",fontWeight:600},children:e.title}),r.jsx("p",{style:{margin:"0 0 24px 0",color:"#6b7280"},children:e.message}),r.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"},children:[r.jsx("button",{onClick:n,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #d1d5db",backgroundColor:"white",cursor:"pointer"},children:e.cancelLabel??"Cancel"}),r.jsx("button",{onClick:t,style:{padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:o?"#dc2626":"#3b82f6",color:"white",cursor:"pointer"},children:e.confirmLabel??"Confirm"})]})]})})}var _a=u.createContext(null);function ed({item:e,index:t,basePath:n,children:o}){return r.jsx(_a.Provider,{value:{item:e,index:t,basePath:n},children:o})}function td(){return u.useContext(_a)}var nd=class extends u.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.error(`[json-render] Rendering error in <${this.props.elementType}>:`,e,t.componentStack)}render(){return this.state.hasError?null:this.props.children}},Ea={},Aa=u.createContext(Ea);function rd(){return u.useContext(Aa)}var Ta=u.createContext(void 0);function od(){return u.useContext(Ta)}function sd(){return u.useSyncExternalStore(bl,xl,()=>!1)}var Ia=u.memo(function e({element:t,elementKey:n,spec:o,registry:s,loading:a,fallback:i}){var W;const c=sd(),d=td(),{ctx:l}=Yl(),{execute:m}=Na(),{getSnapshot:p,state:h}=nn(),f=rd(),x=od(),g=u.useMemo(()=>{const $=d?{...l,repeatItem:d.item,repeatIndex:d.index,repeatBasePath:d.basePath}:{...l};return $.functions=f,$.directives=x,$},[l,d,f,x]),y=t.visible===void 0?!0:At(t.visible,g),w=t.on,j=u.useCallback(async $=>{const U=w==null?void 0:w[$];if(!U)return;const Y=Array.isArray(U)?U:[U];for(const q of Y){if(!q.params){await m(q);continue}const se={...g,stateModel:p()},D={};for(const[V,Z]of Object.entries(q.params))D[V]=Uo(Z,se);await m({...q,params:D})}},[w,m,g,p]),b=u.useCallback($=>{const U=w==null?void 0:w[$];if(!U)return{emit:()=>{},shouldPreventDefault:!1,bound:!1};const q=(Array.isArray(U)?U:[U]).some(se=>se.preventDefault);return{emit:()=>j($),shouldPreventDefault:q,bound:!0}},[w,j]),_=t.watch,v=u.useRef(null),k=u.useRef(void 0),N=u.useMemo(()=>{if(!_)return;const $={};for(const Y of Object.keys(_))$[Y]=ce(h,Y);const U=k.current;if(U){const Y=Object.keys($);if(Y.length===Object.keys(U).length&&Y.every(q=>$[q]===U[q]))return U}return k.current=$,$},[_,h]);if(u.useEffect(()=>{if(!_||!N)return;const $=Object.keys(_);if($.length===0)return;const U=v.current;if(v.current=N,U===null)return;let Y=!1;return(async()=>{for(const q of $){if(Y)break;if(N[q]!==U[q]){const se=_[q];if(!se)continue;const D=Array.isArray(se)?se:[se];for(const V of D){if(Y)break;if(!V.params){if(await m(V),Y)break;continue}const Z={...g,stateModel:p()},te={};for(const[ae,xe]of Object.entries(V.params))te[ae]=Uo(xe,Z);if(await m({...V,params:te}),Y)break}}}})().catch(console.error),()=>{Y=!0}},[_,N,m,g,p]),!y)return null;const R=t.props,T=pl(R,g),A=ul(R,g),O=A!==t.props?{...t,props:A}:t,P=s[O.type]??i;if(!P)return console.warn(`No renderer for component type: ${O.type}`),null;const B=O.repeat?r.jsx(ad,{element:O,spec:o,registry:s,loading:a,fallback:i}):(W=O.children)==null?void 0:W.map($=>{const U=o.elements[$];return U?r.jsx(e,{element:U,elementKey:$,spec:o,registry:s,loading:a,fallback:i},$):(a||console.warn(`[json-render] Missing element "${$}" referenced as child of "${O.type}". This element will not render.`),null)}),E=r.jsx(P,{element:O,emit:j,on:b,bindings:T,loading:a,children:B}),I=c&&n?r.jsx("span",{"data-jr-key":n,style:{display:"contents"},children:E}):E;return r.jsx(nd,{elementType:O.type,children:I})});function ad({element:e,spec:t,registry:n,loading:o,fallback:s}){const{state:a}=nn(),i=e.repeat,c=i.statePath,d=ce(a,c)??[];return r.jsx(r.Fragment,{children:d.map((l,m)=>{var h;const p=i.key&&typeof l=="object"&&l!==null?String(l[i.key]??m):String(m);return r.jsx(ed,{item:l,index:m,basePath:`${c}/${m}`,children:(h=e.children)==null?void 0:h.map(f=>{const x=t.elements[f];return x?r.jsx(Ia,{element:x,elementKey:f,spec:t,registry:n,loading:o,fallback:s},f):(o||console.warn(`[json-render] Missing element "${f}" referenced as child of "${e.type}" (repeat). This element will not render.`),null)})},p)})})}function id({spec:e,registry:t,loading:n,fallback:o}){if(!e||!e.root)return null;const s=e.elements[e.root];return s?r.jsx(Ia,{element:s,elementKey:e.root,spec:e,registry:t,loading:n,fallback:o}):null}function cd({registry:e,store:t,initialState:n,handlers:o,navigate:s,validationFunctions:a,functions:i,directives:c,onStateChange:d,children:l}){const m=u.useMemo(()=>c?ol(c):void 0,[c]);return r.jsx(ql,{store:t,initialState:n,onStateChange:d,children:r.jsx(Vl,{children:r.jsx(Kl,{customFunctions:a,children:r.jsx(Jl,{handlers:o,navigate:s,children:r.jsx(Aa.Provider,{value:i??Ea,children:r.jsxs(Ta.Provider,{value:m,children:[l,r.jsx(ld,{})]})})})})})})}function ld(){const{pendingConfirmation:e,confirm:t,cancel:n}=Na();return e!=null&&e.action.confirm?r.jsx(Ql,{confirm:e.action.confirm,onConfirm:t,onCancel:n}):null}function dd(e,t){const n={};if(t.components)for(const[i,c]of Object.entries(t.components))n[i]=({element:d,children:l,emit:m,on:p,bindings:h,loading:f})=>c({props:d.props,children:l,emit:m,on:p,bindings:h,loading:f});const o=t.actions?Object.entries(t.actions):[];return{registry:n,handlers:(i,c)=>{const d={};for(const[l,m]of o)d[l]=async p=>{const h=i(),f=c();h&&await m(p,h,f)};return d},executeAction:async(i,c,d,l={})=>{const m=o.find(([p])=>p===i);m?await m[1](c,d,l):console.warn(`Unknown action: ${i}`)}}}function ud(e){if(typeof e!="object"||e===null)return!1;const t=e;switch(t.type){case"patch":return typeof t.patch=="object"&&t.patch!==null;case"flat":case"nested":return typeof t.spec=="object"&&t.spec!==null;default:return!1}}function pd(e){const t={root:"",elements:{}};let n=!1;for(const o of e)if(o.type===Xc){if(!ud(o.data))continue;const s=o.data;if(s.type==="patch")n=!0,Uc(t,s.patch);else if(s.type==="flat")n=!0,Object.assign(t,s.spec);else if(s.type==="nested"){n=!0;const a=qc(s.spec);Object.assign(t,a)}}return n?t:null}function G(){const{dir:e}=C.useDocumentDir(),t=C.useConfig();return u.useMemo(()=>{const n=K.resolveLanguage(t.language);return{t:(s,a)=>K.getTranslation(s,n,t.translationOverrides,a),language:n,dir:K.isRtlLanguage(n)?"rtl":"ltr",hostDocumentDir:e}},[t.language,t.translationOverrides,e])}function za(e){const t=K.resolveLanguage(e);return(n,o)=>K.getTranslation(n,t,void 0,o)}const md={t:za("en"),anchorTarget:"_blank"},Ma=u.createContext(md);function hd({host:e,children:t}){return r.jsx(Ma.Provider,{value:e,children:t})}function rn(){return u.useContext(Ma)}function fd({language:e,onUiAction:t,anchorTarget:n="_blank"}){return u.useMemo(()=>({t:za(e),anchorTarget:n,onUiAction:t}),[e,n,t])}class gd extends u.Component{constructor(){super(...arguments);$o(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n){K.log.error("json-render: spec failed to render",{_e:n instanceof Error?n.message:String(n)})}componentDidUpdate(n){this.state.hasError&&n.resetKey!==this.props.resetKey&&this.setState({hasError:!1})}render(){return this.state.hasError?null:this.props.children}}function xd(e){if(!e.elements)return e;let t=!1;const n={};for(const[o,s]of Object.entries(e.elements)){const a=bd(s,e);a!==s&&(t=!0),n[o]=a}return t?{...e,elements:n}:e}function bd(e,t){if(e.type!=="List")return e;const n=e.repeat;if(!n||typeof n.statePath!="string")return e;const o=K.isRecord(e.props)?e.props:{},s=o.items;if(Array.isArray(s)&&s.length>0)return e;const i=ce(t.state??{},n.statePath);if(!Array.isArray(i)||i.length===0)return e;const{repeat:c,...d}=e;return{...d,props:{...o,items:i}}}function z(...e){return Mc.twMerge(zc.clsx(e))}const wd=u.lazy(()=>Promise.resolve().then(()=>require("./Chart.impl-D9ZC6NM1.cjs")));function vd(e){const t=e.height??220;return r.jsx(u.Suspense,{fallback:r.jsx(yd,{height:t}),children:r.jsx(wd,{...e})})}function yd({height:e}){return r.jsx("div",{className:"w-full animate-pulse rounded-lg bg-muted-foreground/10",style:{height:e},"aria-hidden":!0})}const Ra=S.z.object({title:S.z.string().nullish(),description:S.z.string().nullish()}),Pa=S.z.object({direction:S.z.enum(["row","column"]).nullish(),gap:S.z.enum(["sm","md","lg"]).nullish(),align:S.z.enum(["start","center","end","stretch"]).nullish(),justify:S.z.enum(["start","center","end","between"]).nullish()}),Oa=S.z.object({columns:S.z.union([S.z.literal(1),S.z.literal(2),S.z.literal(3)]).nullish(),gap:S.z.enum(["sm","md","lg"]).nullish()}),La=S.z.object({text:S.z.string(),level:S.z.union([S.z.literal(1),S.z.literal(2),S.z.literal(3),S.z.literal(4)]).nullish()}),$a=S.z.object({text:S.z.string(),variant:S.z.enum(["body","caption","muted","code"]).nullish()}),Da=S.z.object({text:S.z.string(),variant:S.z.enum(["default","secondary","success","warning","destructive"]).nullish()}),kd=new Set(["http:","https:","mailto:"]),jd=S.z.string().nullish().transform(e=>{if(!e)return null;try{return kd.has(new URL(e).protocol)?e:null}catch{return null}}),Fa=S.z.object({id:S.z.string().nullish(),label:S.z.string(),secondary:S.z.string().nullish(),badge:S.z.string().nullish(),status:S.z.enum(["success","warning","error","info","neutral"]).nullish(),href:jd}),Ha=S.z.object({items:S.z.array(Fa),maxVisible:S.z.number().int().positive().nullish()}),Cd=S.z.object({items:S.z.array(Fa.extend({href:S.z.string().nullish()})),maxVisible:Ha.shape.maxVisible}),Wa=S.z.object({columns:S.z.array(S.z.string()),rows:S.z.array(S.z.array(S.z.string())),caption:S.z.string().nullish()}),Sd=S.z.object({value:S.z.string(),direction:S.z.enum(["up","down","flat"]),label:S.z.string().nullish()}),Ba=S.z.object({label:S.z.string(),value:S.z.string(),description:S.z.string().nullish(),trend:S.z.enum(["up","down","neutral"]).nullish(),delta:Sd.nullish()}),Ua=S.z.object({type:S.z.enum(["info","tip","warning","important"]).nullish(),title:S.z.string().nullish(),content:S.z.string()}),Nd=S.z.object({label:S.z.string(),value:S.z.number()}),qa=S.z.object({type:S.z.enum(["bar","line","pie"]),data:S.z.array(Nd),title:S.z.string().nullish(),height:S.z.number().int().positive().nullish(),centerLabel:S.z.string().nullish()}),Va=S.z.object({agentId:S.z.string(),agentName:S.z.string(),model:S.z.string().nullish()});function Se(e,t,n){const o=e.safeParse(t);return o.success?o.data:n}const _d=Wl(Bl,{components:{Card:{props:Ra,slots:["default"],description:"Container card with an optional title/description. Group related content.",example:{title:"Order summary",description:"Placed 2 days ago"}},Stack:{props:Pa,slots:["default"],description:'Flex layout. Use direction="row" for side-by-side, "column" (default) to stack.'},Grid:{props:Oa,slots:["default"],description:"Column grid that wraps on narrow screens. columns=2 for side-by-side metrics or cards; columns=3 only for three short metrics — the chat panel is about 400px wide, so three wide cells wrap."},Heading:{props:La,description:"Section heading. level 1 (largest) to 4.",example:{text:"Your orders",level:3}},Text:{props:$a,description:'A paragraph of text. variant "muted"/"caption" for secondary text, "code" for monospace.'},Badge:{props:Da,description:"Small status pill. Use variant to convey state (success/warning/destructive).",example:{text:"Delivered",variant:"success"}},List:{props:Cd,description:"A vertical list of items, each with a label and optional secondary text, badge, and status dot. Pass the full array in `items` — do NOT use repeat/state for the rows.",example:{items:[{label:"Order #1024",secondary:"Shipped",status:"success"},{label:"Order #1025",secondary:"Processing",status:"warning"}]}},Table:{props:Wa,description:"A data table. `columns` are header strings; `rows` is a 2D array of cell strings (each row same length as columns).",example:{columns:["Item","Qty","Price"],rows:[["Widget","2","$20"],["Gadget","1","$15"]]}},Metric:{props:Ba,description:"A single key figure (KPI / insight card) with a label, big value, optional description, trend arrow, and an optional period-over-period delta ({ value, direction, label }).",example:{label:"Total spent",value:"$1,240",description:"Last 30 days",trend:"up",delta:{value:"+8%",direction:"up",label:"vs previous 30d"}}},Callout:{props:Ua,description:"A highlighted info / tip / warning box for a single important note. Use for one call-out, not for long prose.",example:{type:"tip",title:"Heads up",content:"Free shipping over $50."}},PhoneAgentCard:{props:Va,description:'A phone agent card with a "Test via web" action. NEVER author this yourself: it only comes back, already fenced, from the phone-agent tools — carry that fence verbatim.',example:{agentId:"00000000-0000-4000-8000-000000000000",agentName:"Support line",model:"oppie-vox-livekit"}},Chart:{props:qa,description:"A bar, line, or pie (donut) chart. `data` is an array of { label, value } points. Choose by the question: line = trend over time, bar = comparison across categories, pie = share of a total (optional `centerLabel` shows a big number in the donut hole). Use for trends or distributions, not for a handful of numbers (use Metric for those). Colours, axes, legend, and tooltips are handled for you.",example:{type:"bar",title:"Orders per month",data:[{label:"Jan",value:12},{label:"Feb",value:18}]}}},actions:{}});function xr({height:e=64}){return r.jsx("div",{className:"w-full animate-pulse rounded-lg bg-muted-foreground/10",style:{height:e},"aria-hidden":!0})}const ts={sm:"gap-1.5",md:"gap-3",lg:"gap-4"},Ed="10rem";function Ad(e){return e===1?"minmax(0, 1fr)":`repeat(auto-fit, minmax(max(${Ed}, calc(100% / ${e} - 1rem)), 1fr))`}const{registry:ns}=dd(_d,{components:{Card:({props:e,children:t,loading:n})=>{const o=Se(Ra,e,{});return r.jsxs("div",{className:"flex flex-col gap-2 rounded-xl border border-muted-foreground/15 p-3",children:[(o.title||o.description)&&r.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.title&&r.jsx("div",{className:"text-sm font-semibold text-foreground",children:o.title}),o.description&&r.jsx("div",{className:"text-xs text-muted-foreground",children:o.description})]}),Zn(t,n)]})},Stack:({props:e,children:t,loading:n})=>{const o=Se(Pa,e,{}),s={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"}[o.align??"stretch"],a={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between"}[o.justify??"start"];return r.jsx("div",{className:z("flex",o.direction==="row"?"flex-row":"flex-col",ts[o.gap??"md"],s,a),children:Zn(t,n)})},Grid:({props:e,children:t,loading:n})=>{const o=Se(Oa,e,{});return r.jsx("div",{className:z("grid",ts[o.gap??"md"]),style:{gridTemplateColumns:Ad(o.columns??1)},children:Zn(t,n)})},Heading:({props:e})=>{const t=Se(La,e,{text:""}),n=t.level??3,o={1:"text-xl font-bold",2:"text-lg font-bold",3:"text-base font-semibold",4:"text-sm font-semibold"}[n]??"text-base font-semibold";return u.createElement(`h${n}`,{className:z("text-foreground",o)},t.text)},Text:({props:e})=>{const t=Se($a,e,{text:""});if(t.variant==="code")return r.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:t.text});const n=t.variant==="muted"||t.variant==="caption";return r.jsx("p",{className:z("whitespace-pre-wrap",n?"text-xs text-muted-foreground":"text-sm text-foreground"),children:t.text})},Badge:({props:e})=>{const t=Se(Da,e,{text:""}),n={default:"bg-primary text-primary-foreground",secondary:"bg-secondary text-secondary-foreground",success:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",warning:"bg-amber-500/15 text-amber-600 dark:text-amber-400",destructive:"bg-destructive/15 text-destructive"}[t.variant??"secondary"];return r.jsx("span",{className:z("inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium",n),children:t.text})},List:({props:e,loading:t})=>{const n=Se(Ha,e,{items:[]});return n.items.length===0?t?r.jsx(xr,{}):r.jsx(rs,{translationKey:"json_no_items"}):r.jsx(Hd,{items:n.items,maxVisible:n.maxVisible})},Table:({props:e,loading:t})=>{const n=Se(Wa,e,{columns:[],rows:[]});return t&&n.rows.length===0?r.jsx(xr,{}):n.columns.length===0?r.jsx(rs,{translationKey:"json_no_data"}):r.jsx("div",{className:"overflow-x-auto rounded-lg border border-muted-foreground/15",children:r.jsxs("table",{className:"w-full text-sm",children:[n.caption&&r.jsx("caption",{className:"px-3 py-2 text-start text-xs text-muted-foreground",children:n.caption}),r.jsx("thead",{children:r.jsx("tr",{className:"border-b border-muted-foreground/15 bg-muted/40",children:n.columns.map((o,s)=>r.jsx("th",{className:"px-3 py-2 text-start font-medium text-foreground",children:o},s))})}),r.jsx("tbody",{children:n.rows.map((o,s)=>r.jsx("tr",{className:"border-b border-muted-foreground/10 last:border-0",children:o.map((a,i)=>r.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:a},i))},s))})]})})},Metric:({props:e})=>{const t=Se(Ba,e,{label:"",value:""});return r.jsx($d,{label:t.label,value:t.value,description:t.description,trend:t.trend,delta:t.delta})},Callout:({props:e})=>{const t=Se(Ua,e,{content:""}),n=Id[t.type??"info"],o=n.Icon;return r.jsxs("div",{className:z("flex gap-2 rounded-lg border-l-2 p-3",n.cls),children:[r.jsx(o,{className:"mt-0.5 size-4 shrink-0"}),r.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.title&&r.jsx("span",{className:"text-sm font-semibold",children:t.title}),r.jsx("span",{className:"text-sm",children:t.content})]})]})},PhoneAgentCard:({props:e})=>{const t=Se(Va,e,{agentId:"",agentName:""});return r.jsx(Md,{...t})},Chart:({props:e})=>{const t=Se(qa,e,{type:"bar",data:[]});return r.jsxs("div",{className:"flex flex-col gap-1",children:[t.title&&r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:t.title}),r.jsx(vd,{...t})]})}}}),Td=({element:e})=>{const{t}=rn();return r.jsx("div",{className:"rounded-lg border border-dashed border-muted-foreground/30 px-2 py-1.5 text-xs text-muted-foreground",children:t("json_unsupported",{type:e.type})})},Id={info:{Icon:M.Info,cls:"border-l-blue-500 bg-blue-500/5 text-foreground"},tip:{Icon:M.Lightbulb,cls:"border-l-emerald-500 bg-emerald-500/5 text-foreground"},warning:{Icon:M.AlertTriangle,cls:"border-l-amber-500 bg-amber-500/5 text-foreground"},important:{Icon:M.AlertCircle,cls:"border-l-red-500 bg-red-500/5 text-foreground"}};function Zn(e,t){return u.Children.toArray(e).length>0?e:t?r.jsx(xr,{}):null}function rs({translationKey:e}){const{t}=rn();return r.jsx("div",{className:"rounded-lg border border-muted-foreground/15 px-3 py-2 text-xs text-muted-foreground",children:t(e)})}const zd="oppie-vox-livekit";function Md({agentId:e,agentName:t,model:n}){const{t:o,onUiAction:s}=rn(),a=!!s&&!!e&&n===zd;return r.jsxs("div",{className:"flex w-full flex-col gap-3 rounded-xl border border-muted-foreground/15 p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:r.jsx(M.Phone,{className:"size-4","aria-hidden":!0})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:t}),r.jsx("div",{className:"text-xs text-muted-foreground",children:o("json_phone_agent")})]})]}),a&&r.jsxs("button",{type:"button",className:"flex w-full items-center justify-center gap-2 rounded-lg bg-secondary px-3 py-2 text-sm font-medium text-secondary-foreground hover:bg-secondary/80",onClick:()=>s==null?void 0:s({type:"test-phone-agent",payload:{agentId:e,model:n??null}}),children:[r.jsx(M.Play,{className:"size-4","aria-hidden":!0}),o("json_phone_agent_test")]})]})}const Rd={up:"↑",down:"↓",neutral:"→"},Pd={up:"text-emerald-600 dark:text-emerald-400",down:"text-red-600 dark:text-red-400",neutral:"text-muted-foreground"},Od={up:"↑",down:"↓",flat:"→"},Ld={up:"text-emerald-600 dark:text-emerald-400",down:"text-red-600 dark:text-red-400",flat:"text-muted-foreground"};function $d({label:e,value:t,description:n,trend:o,delta:s}){return r.jsxs("div",{className:"min-w-[140px] space-y-1 rounded-xl border border-muted-foreground/15 p-3",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:e}),r.jsxs("div",{className:"flex items-baseline gap-2",children:[r.jsx("span",{className:"text-2xl font-medium tracking-tight text-foreground",children:t}),o?r.jsx("span",{className:z("text-sm font-medium",Pd[o]),children:Rd[o]}):null]}),s?r.jsxs("div",{className:"flex items-baseline gap-1 text-xs",children:[r.jsxs("span",{className:z("font-medium",Ld[s.direction]),children:[Od[s.direction]," ",s.value]}),s.label?r.jsx("span",{className:"text-muted-foreground",children:s.label}):null]}):null,n?r.jsx("span",{className:"block text-xs text-muted-foreground",children:n}):null]})}const Dd={success:"bg-emerald-500",warning:"bg-amber-500",error:"bg-red-500",info:"bg-blue-500",neutral:"bg-muted-foreground/40"};function Fd({item:e,showBadge:t,showSecondary:n,showStatus:o}){return r.jsxs(r.Fragment,{children:[t&&(e.badge?r.jsx("span",{className:"block min-w-0 truncate text-xs font-medium",title:e.badge,children:e.badge}):r.jsx("span",{})),r.jsx("span",{className:"block min-w-0 truncate",title:e.label,children:e.label}),n&&(e.secondary?r.jsx("span",{className:"block min-w-0 truncate text-xs text-muted-foreground",title:e.secondary,children:e.secondary}):r.jsx("span",{})),o&&(e.status?r.jsx("span",{className:z("size-2 rounded-full",Dd[e.status]),"aria-hidden":!0}):r.jsx("span",{}))]})}function Hd({items:e,maxVisible:t}){const n=t??10,{anchorTarget:o,t:s}=rn(),[a,i]=u.useState(!1),c=e.length>n,d=a?e:e.slice(0,n),l=d.some(x=>!!x.badge),m=d.some(x=>!!x.secondary),p=d.some(x=>!!x.status),h=[l&&"auto","minmax(0,1fr)",m&&"minmax(0,2fr)",p&&"auto"].filter(Boolean).join(" "),f="grid min-w-0 grid-cols-[subgrid] col-span-full items-center gap-x-2.5 px-3 py-2 text-sm text-foreground";return r.jsxs("div",{className:"grid overflow-hidden rounded-lg border border-muted-foreground/15",style:{gridTemplateColumns:h},children:[d.map((x,g)=>{const y=x.id??`row-${g}`,w=r.jsx(Fd,{item:x,showBadge:l,showSecondary:m,showStatus:p});return x.href?r.jsx("a",{href:x.href,target:o||"_top",rel:"noopener noreferrer",className:z(f,"transition-colors hover:bg-muted/50",g>0&&"border-t border-muted-foreground/10"),children:w},y):r.jsx("div",{className:z(f,g>0&&"border-t border-muted-foreground/10"),children:w},y)}),c&&r.jsx("button",{type:"button",className:"col-span-full flex w-full items-center justify-center gap-1 border-t border-muted-foreground/10 py-2 text-xs text-muted-foreground transition-colors hover:bg-muted/50",onClick:()=>i(x=>!x),children:a?r.jsxs(r.Fragment,{children:[r.jsx(M.ChevronUp,{className:"size-3"}),s("json_see_less")]}):r.jsxs(r.Fragment,{children:[r.jsx(M.ChevronDown,{className:"size-3"}),s("json_see_more",{count:e.length-n})]})})]})}function Ya({spec:e,active:t=!1}){const{anchorTarget:n,onUiAction:o}=C.useConfig(),{t:s}=G(),a=u.useMemo(()=>({t:s,anchorTarget:n??"_blank",onUiAction:o}),[s,n,o]);return r.jsx(Xa,{spec:e,host:a,active:t})}function Wd({spec:e,language:t,onUiAction:n,anchorTarget:o}){const s=fd({language:t,onUiAction:n,anchorTarget:o});return r.jsx(Xa,{spec:e,host:s})}function Xa({spec:e,host:t,active:n=!1}){return r.jsx(hd,{host:t,children:r.jsx(gd,{resetKey:e,children:r.jsx(Bd,{spec:e,active:n})})})}function Bd({spec:e,active:t}){const n=u.useMemo(()=>e?xd(e):null,[e]);return!n||!va(n)?null:r.jsx(cd,{registry:ns,initialState:n.state,children:r.jsx(id,{spec:n,registry:ns,loading:t,fallback:Td})})}function Ga(e){if(!e)return[];const t=e.split(`
|
|
12
12
|
`),n=[];let o=[],s=[],a=[],i=!1,c=!1;function d(){if(o.length===0)return;const p=o.join(`
|
|
13
|
-
`);p.trim()&&n.push({type:"markdown",content:p}),o=[]}function l(){if(s.length===0)return;let p=null;if(a.length>0)try{p=
|
|
14
|
-
`),{root:"",elements:{}})}catch{}p&&Kd(p)?(d(),n.push({type:"ui",spec:p})):o.push(...s),a=[],s=[]}function m(){c&&(l(),c=!1)}for(let p=0;p<t.length;p+=1){const h=t[p]??"",f=h.trim(),x=p===t.length-1;if(!i&&f==="```spec"){m(),i=!0,s=[h];continue}if(i&&f==="```"){s.push(h),l(),i=!1;continue}if(i){s.push(h),f!==""&&hr(h)&&a.push(h);continue}if(f!==""&&hr(h)){c=!0,s.push(h),a.push(h);continue}if(c){if(f===""||x&&Jd(f)){s.push(h);continue}m()}o.push(h)}return l(),d(),n}function Kd(e){return ya(e)&&e.elements[e.root]!==void 0}const Zd='{"op":';function Jd(e){return!e.startsWith("{")||e.endsWith("}")?!1:/"op"\s*:/.test(e)?!0:Zd.startsWith(e.replace(/\s+/g,""))}function Qd(e){return bd(e)}function L(e){return{"data-component":e}}const wr=[{kind:"csv",label:"CSV",mimes:["text/csv","application/csv"],extensions:["csv"]},{kind:"excel",label:"Excel",mimes:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],extensions:["xls","xlsx"]}],eu=Object.fromEntries(wr.flatMap(e=>e.mimes.map(t=>[t,e.extensions.map(n=>`.${n}`)]))),tu={"video/mp4":[".mp4"],"video/webm":[".webm"],"video/quicktime":[".mov"],"video/x-m4v":[".m4v"],"video/x-matroska":[".mkv"],"video/3gpp":[".3gp"]};function Za({type:e,name:t}){var s,a;const n=((s=t.split(".").pop())==null?void 0:s.toLowerCase())??"",o=((a=e.toLowerCase().split(";")[0])==null?void 0:a.trim())??"";return wr.find(i=>n&&i.extensions.includes(n))??wr.find(i=>o&&i.mimes.includes(o))??null}function Pn(){const[e]=u.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(hover: hover) and (pointer: fine)").matches);return e}const Tt={x:2,y:2},Oe=u.memo(u.forwardRef(({children:e,className:t,scale:n=1.02,off:o=!1},s)=>{const[a,i]=u.useState(!1),[c,d]=u.useState({x:0,y:0}),l=Pn(),m=F.useReducedMotion();if(o||!l||m)return u.cloneElement(e,{ref:s??e.props.ref});if(/translate/.test(e.props.className||""))return e;const h=y=>{var A,O;const{clientX:w,clientY:j}=y,b=y.currentTarget.getBoundingClientRect(),_=w-(b.left+b.width/2),v=j-(b.top+b.height/2),k=Math.max(-1,Math.min(1,_/(b.width/2))),N=Math.max(-1,Math.min(1,v/(b.height/2))),R=k*Tt.x,T=N*Tt.y;d({x:R,y:T}),(O=(A=e.props).onMouseMove)==null||O.call(A,y)},f=y=>{var w,j;i(!0),(j=(w=e.props).onMouseEnter)==null||j.call(w,y)},x=y=>{var w,j;i(!1),d({x:0,y:0}),(j=(w=e.props).onMouseLeave)==null||j.call(w,y)},g={"--wobble-x":a?`${c.x}px`:"0px","--wobble-y":a?`${c.y}px`:"0px","--scale":1-(n-1)};return u.cloneElement(e,{ref:s,onMouseMove:h,onMouseEnter:f,onMouseLeave:x,style:{...g,...e.props.style},className:z("translate-x-[var(--wobble-x)]","translate-y-[var(--wobble-y)]","hover:scale-[var(--scale)] active:hover:scale-[calc(var(--scale)-0.02)]",t,e.props.className,"transition-transform duration-150 ease-[cubic-bezier(0.23,1,0.32,1)]")})}));Oe.displayName="Wobble";const $e=[.23,1,.32,1],nu=`cubic-bezier(${$e.join(", ")})`,ke={duration:.2,ease:$e},ge={duration:.15,ease:$e},It={type:"spring",stiffness:500,damping:45,mass:1},ru=[.32,.72,.24,1],ou=`cubic-bezier(${ru.join(", ")})`,su="0 2px 12px 0 rgba(0,0,0,0.18), 0 1px 4px 0 rgba(0,0,0,0), 0 0 0 1px rgba(255,255,255,0.08), inset 0 1px 0 0 rgba(255,255,255,0)",au="0 8px 28px 0 rgba(0,0,0,0.10), 0 1px 4px 0 rgba(0,0,0,0), 0 0 0 1px rgba(0,0,0,0.05), inset 0 1px 0 0 rgba(255,255,255,0.5)",iu="0 12px 40px 0 rgba(0,0,0,0.12), 0 2px 8px 0 rgba(0,0,0,0.04), 0 0 0 1px rgba(0,0,0,0.05), inset 0 1px 0 0 rgba(255,255,255,0.5)",cu="0 24px 48px -16px rgba(0,0,0,0.18), 0 4px 16px 0 rgba(0,0,0,0.05), 0 0 0 1px rgba(0,0,0,0.05), inset 0 1px 0 0 rgba(255,255,255,0.5)",lu=10,du=(e,t,n)=>({initial:{opacity:0,x:-e,...t.initial},animate:{opacity:1,x:0,...t.animate,transition:{...ke,delay:n}},exit:{opacity:0,x:e,...t.exit,transition:ge},transition:ke}),uu=(e,t,n)=>({initial:{opacity:0,x:e,...t.initial},animate:{opacity:1,x:0,...t.animate,transition:{...ke,delay:n}},exit:{opacity:0,x:-e,...t.exit,transition:ge},transition:ke}),pu=(e,t,n)=>({initial:{opacity:0,y:e,...t.initial},animate:{opacity:1,y:0,...t.animate,transition:{...ke,delay:n}},exit:{opacity:0,y:-e,...t.exit,transition:ge},transition:ke}),mu=(e,t,n)=>({initial:{opacity:0,y:-e,...t.initial},animate:{opacity:1,y:0,...t.animate,transition:{...ke,delay:n}},exit:{opacity:0,y:e,...t.exit,transition:ge},transition:ke}),hu={right:du,left:uu,up:pu,down:mu},oe=u.forwardRef(({fadeIn:e="down",distance:t=lu,children:n,snapExit:o=!1,overrides:s={},delay:a=0,...i},c)=>{const d=e?hu[e](t,s,a):{};return o&&d.exit&&typeof d.exit=="object"&&!Array.isArray(d.exit)&&(d.exit.transition={duration:0}),r.jsx(F.motion.div,{ref:c,...i,...d,children:n})});oe.displayName="MotionDiv";const vr=ca.cva(z("inline-flex shrink-0 items-center justify-center gap-2","text-sm font-medium whitespace-nowrap","ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50","active:scale-[0.97] motion-reduce:active:scale-100","rounded-xl","transition-transform duration-150 ease-[cubic-bezier(0.23,1,0.32,1)]"),{variants:{variant:{default:"bg-primary text-primary-foreground",destructive:"bg-destructive text-destructive-foreground",outline:"bg-background border",secondary:"bg-secondary text-secondary-foreground",ghost:"hover:bg-secondary",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"py-2 px-3.5 text-xs",lg:"min-h-12 px-4 rounded-[20px]",icon:"h-10 w-10",fit:"size-fit p-2",free:"p-2",selfless:"p-0"}},defaultVariants:{variant:"default",size:"default"}}),X=ot.forwardRef(({className:e,variant:t="default",size:n,asChild:o=!1,wobble:s=!0,...a},i)=>{const c=o?Hc.Slot:"button";return r.jsx(Oe,{ref:i,off:!s,children:r.jsx(c,{...L("ui_lib/btn"),"data-variant":t,className:z(vr({variant:t,size:n,className:e})),...a})})});X.displayName="Button";const Ja=u.createContext(null);function fu({children:e}){const[t,n]=u.useState(!1),[o,s]=u.useState(null),a=c=>{s(c),n(!0)},i=u.useCallback(()=>{n(!1),setTimeout(()=>{s(null)},200)},[]);return r.jsxs(Ja.Provider,{value:{open:a,close:i,isOpen:t,content:o},children:[r.jsx(gu,{}),e]})}function On(){const e=u.useContext(Ja);return e||(K.log.error("useDialoger must be used within a DialogerProvider"),{open:()=>{},close:()=>{},isOpen:!1,content:null})}function gu(){const{contentIframeRef:e}=C.useWidget(),{isOpen:t,content:n,close:o}=On();return u.useEffect(()=>{var i,c;if(!t)return;const s=d=>{d.defaultPrevented||d.key!=="Escape"||(d.preventDefault(),o())},a=(c=(i=e==null?void 0:e.current)==null?void 0:i.contentWindow)==null?void 0:c.document;return a==null||a.addEventListener("keydown",s),()=>a==null?void 0:a.removeEventListener("keydown",s)},[o,e,t]),r.jsx(F.AnimatePresence,{mode:"wait",children:t&&n&&r.jsx(oe,{overrides:{initial:{y:0},exit:{y:0}},className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",tabIndex:-1,onClick:o,children:n},"dialog-content")})}function on({children:e,className:t,withClose:n=!1}){const{close:o}=On(),{t:s}=G();return r.jsxs("div",{"data-opencx-escape-scope":!0,className:z("fixed left-[50%] top-[50%] z-50 flex flex-col gap-4 w-full max-w-[61.8%] translate-x-[-50%] translate-y-[-50%] border bg-background p-4 rounded-3xl",t),onClick:a=>a.stopPropagation(),children:[e,n&&r.jsxs(X,{size:"fit",className:"rounded-full absolute top-4 right-4 opacity-50 hover:opacity-100",onClick:o,children:[r.jsx(M.X,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:s("dialog_close")})]})]})}const Kr=({className:e,...t})=>r.jsx("div",{className:z("flex flex-col gap-2 text-center pt-2",e),...t});Kr.displayName="DialogerHeader";const Zr=({className:e,...t})=>r.jsx("div",{className:z("flex flex-col gap-2 text-center",e),...t});Zr.displayName="DialogerBody";const Qa=({className:e,...t})=>r.jsx("div",{className:z("flex flex-col gap-2",e),...t});Qa.displayName="DialogerFooter";const Jr=u.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:z("text-lg font-semibold leading-none tracking-tight",e),...t}));Jr.displayName="DialogerTitle";const Qr=u.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:z("text-sm text-muted-foreground",e),...t}));Qr.displayName="DialogerDescription";function sn({children:e,trigger:t}){const{open:n}=On();return u.cloneElement(t,{onClick:()=>{var s,a;n(e),(a=(s=t.props).onClick)==null||a.call(s)}})}const ss=1,as=5,is=.5,xu=2.5;function bu(e,t,n,o){if(!n||!o||t<=1)return{x:0,y:0};const s=n.getBoundingClientRect(),a=o.offsetWidth,i=o.offsetHeight,c=Math.max(0,(a*t-s.width)/(2*t)),d=Math.max(0,(i*t-s.height)/(2*t));return{x:Math.min(c,Math.max(-c,e.x)),y:Math.min(d,Math.max(-d,e.y))}}function ei({src:e,alt:t}){const{t:n}=G(),[o,s]=u.useState(1),[a,i]=u.useState({x:0,y:0}),[c,d]=u.useState(!1),l=u.useRef({x:0,y:0}),m=u.useRef({x:0,y:0}),p=u.useRef(null),h=u.useRef(null),f=u.useRef(!1),x=k=>Math.min(as,Math.max(ss,k)),g=u.useCallback(()=>{s(1),i({x:0,y:0})},[]),y=u.useCallback(()=>{s(k=>x(k+is))},[]),w=u.useCallback(()=>{s(k=>{const N=x(k-is);return N<=1&&i({x:0,y:0}),N})},[]),j=u.useCallback(k=>{k.preventDefault(),f.current=!1,d(!0),l.current={x:k.clientX,y:k.clientY},m.current={...a},k.target.setPointerCapture(k.pointerId)},[a]),b=u.useCallback(k=>{if(!c)return;const N=k.clientX-l.current.x,R=k.clientY-l.current.y;if((Math.abs(N)>3||Math.abs(R)>3)&&(f.current=!0),o<=1)return;const T={x:m.current.x+N/o,y:m.current.y+R/o};i(bu(T,o,p.current,h.current))},[c,o]),_=u.useCallback(()=>{const k=f.current;d(!1),!k&&s(N=>N>1?(i({x:0,y:0}),1):xu)},[]),v=o>1;return r.jsxs("div",{className:"relative size-full flex items-center justify-center select-none",onClick:k=>k.stopPropagation(),children:[r.jsx("div",{ref:p,className:z("overflow-hidden max-h-full max-w-full rounded-2xl flex items-center justify-center",v&&"size-full"),onPointerDown:j,onPointerMove:b,onPointerUp:_,onPointerCancel:_,style:{cursor:c?"grabbing":v?"grab":"zoom-in",touchAction:"none"},children:r.jsx("img",{ref:h,src:e,alt:t,className:"block max-w-full object-contain pointer-events-none",draggable:!1,style:{maxHeight:"100vh",transform:`scale(${o}) translate(${a.x}px, ${a.y}px)`,transformOrigin:"center center"}})}),r.jsxs("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1 bg-black/60 backdrop-blur-sm rounded-full px-1.5 py-1 transition opacity-50 hover:opacity-100",children:[r.jsx(Qn,{onClick:w,label:n("zoom_out"),disabled:o<=ss,children:r.jsx(M.ZoomOut,{className:"size-3.5"})}),r.jsxs("span",{className:"text-white text-xs font-medium min-w-[3ch] text-center tabular-nums",children:[Math.round(o*100),"%"]}),r.jsx(Qn,{onClick:y,label:n("zoom_in"),disabled:o>=as,children:r.jsx(M.ZoomIn,{className:"size-3.5"})}),v&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-px h-4 bg-white/30 mx-0.5"}),r.jsx(Qn,{onClick:g,label:n("reset_zoom"),children:r.jsx(M.RotateCcw,{className:"size-3.5"})})]})]})]})}function Qn({onClick:e,label:t,children:n,disabled:o}){return r.jsx("button",{onClick:e,"aria-label":t,disabled:o,className:"text-white/80 hover:text-white disabled:text-white/30 disabled:hover:bg-transparent p-1.5 rounded-full hover:bg-white/15 transition-colors",children:n})}function cs({url:e,name:t,size:n,icon:o,label:s}){return r.jsx(Oe,{children:r.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:z("block size-fit max-w-[min(100%,16rem)] shrink-0 rounded-2xl border","bg-background/80 transition-colors hover:bg-accent/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),children:r.jsxs("div",{className:"flex items-center gap-3 p-3 min-w-0",children:[r.jsx("div",{className:z("flex size-10 shrink-0 items-center justify-center rounded-xl","bg-secondary text-muted-foreground"),"aria-hidden":!0,children:o}),r.jsxs("div",{className:"min-w-0 flex-1 flex flex-col gap-0.5 text-left",children:[r.jsx("span",{className:z("text-xs font-medium text-foreground line-clamp-1","break-words [word-break:break-word]"),children:t}),r.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[(n/1024).toFixed(2)," KB · ",s]})]})]})})})}function ti({attachment:e}){const{name:t,size:n,type:o,url:s}=e,a=o.startsWith("image/"),i=o.startsWith("video/"),c=o.startsWith("audio/"),d=o==="application/pdf";if(c)return r.jsx(Oe,{children:r.jsx("div",{className:"w-full shrink-0 overflow-hidden",children:r.jsxs("audio",{controls:!0,className:"w-full",children:[r.jsx("source",{src:s,type:o}),"Your browser does not support the audio tag."]})})});if(i)return r.jsx(Oe,{children:r.jsx("div",{className:"w-full border shrink-0 rounded-2xl overflow-hidden",children:r.jsxs("video",{controls:!0,children:[r.jsx("source",{src:s,type:o}),"Your browser does not support the video tag."]})})});if(a)return r.jsx(sn,{trigger:r.jsx("div",{children:r.jsx(Oe,{children:r.jsx("div",{className:"size-fit border shrink-0 rounded-2xl overflow-hidden",children:r.jsx("img",{src:s,className:"object-cover size-16",alt:t})})})}),children:r.jsx(on,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx(ei,{src:s,alt:t})})});if(d)return r.jsx(cs,{url:s,name:t,size:n,icon:r.jsx(M.FileText,{className:"size-5",strokeWidth:1.75}),label:"PDF"});const l=Za({type:o,name:t});return l?r.jsx(cs,{url:s,name:t,size:n,icon:r.jsx(M.FileSpreadsheet,{className:"size-5",strokeWidth:1.75}),label:l.label}):r.jsx(Oe,{children:r.jsx("div",{className:"size-fit border shrink-0 rounded-2xl overflow-hidden",children:r.jsxs("div",{className:"flex items-end gap-2 p-2",children:[r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:z("text-xs text-blue-500 line-clamp-2 underline hover:text-blue-600","break-words [word-break:break-word]"),children:t}),r.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[(n/1024).toFixed(2)," KB"]})]})})})}function wu({replyTo:e}){const t=C.useBot(),{humanAgent:n}=C.useConfig(),{sender:o}=e,s=o.kind==="user"?"You":o.kind==="ai"?t.name:o.kind==="agent"?(n==null?void 0:n.name)||o.name||"Team":o.name;return r.jsxs("button",{...L("chat/agent_msg/reply_to"),type:"button",onClick:a=>{const i=a.currentTarget.ownerDocument.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`);i==null||i.scrollIntoView({behavior:"smooth",block:"center"}),i==null||i.animate([{opacity:.35},{opacity:1}],{duration:900,easing:"ease-out"})},className:z("not-prose mb-2 block w-full min-w-0 text-start","rounded-xl border-s-2 border-primary/50 bg-primary/[0.07] ps-2.5 pe-2 py-1.5","text-xs leading-snug text-muted-foreground","transition-colors hover:bg-primary/10 hover:text-foreground"),children:[s&&r.jsx("span",{className:"block font-medium text-foreground/80",children:s}),r.jsx("span",{className:"line-clamp-2 break-words",children:e.text})]})}const ni=u.memo(Wc,(e,t)=>e.children===t.children&&e.className===t.className);var ta,na,ra;const vu={...ye.defaultSchema,attributes:{...ye.defaultSchema.attributes,"*":[...((ta=ye.defaultSchema.attributes)==null?void 0:ta["*"])??[],"style"],code:[...((na=ye.defaultSchema.attributes)==null?void 0:na.code)??[],"className"],pre:[...((ra=ye.defaultSchema.attributes)==null?void 0:ra.pre)??[],"className"]}},yu=/^(color|background-color|font-(family|size|style|weight)|text-(align|decoration|transform)|line-height|letter-spacing|white-space|display|width|height|max-width|min-width|margin(-top|-right|-bottom|-left)?|padding(-top|-right|-bottom|-left)?|border(-width|-style|-color|-radius)?)$/i,ku=/^[\w\s#.,%()'"+-]+$/,ju=/\b(url|expression|var|attr)\s*\(/i;function Cu(){return function e(t){var o,s;const n=(o=t.properties)==null?void 0:o.style;typeof n=="string"&&t.properties&&(t.properties.style=n.split(";").filter(a=>{const i=a.indexOf(":");if(i<0)return!1;const c=a.slice(0,i).trim(),d=a.slice(i+1).trim();return yu.test(c)&&ku.test(d)&&!ju.test(d)}).join(";")),(s=t.children)==null||s.forEach(e)}}function ri(e){return e.replace(/<citations>[\s\S]*?<\/citations>/g,"").replace(/<citations[\s\S]*$/,"").replace(/<(?:ref|cite)\s[^>]*?\/?>/g,"").replace(/<r(?:e(?:f[^>]*)?)?$/,"").replace(/<c(?:i(?:t(?:a(?:t(?:i(?:o(?:n(?:s)?)?)?)?)?)?(?:e[^>]*)?)?)?$/,"").trimEnd()}const Su=/^[\w-]{11}$/,Nu=new Set(["youtube.com","www.youtube.com","m.youtube.com","youtube-nocookie.com","www.youtube-nocookie.com"]);function _u(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"&&t.protocol!=="http:")return null;const n=Eu(t);return n&&Su.test(n)?n:null}function Eu(e){const[t,n]=e.pathname.split("/").filter(Boolean);return e.hostname==="youtu.be"?t:Nu.has(e.hostname)?t==="watch"?e.searchParams.get("v"):t==="shorts"||t==="embed"?n:null:null}function Au({id:e,title:t}){return r.jsx(sn,{trigger:r.jsxs("button",{type:"button",className:"not-prose relative block w-full max-w-64 overflow-hidden rounded-xl border",children:[r.jsx("img",{src:`https://i.ytimg.com/vi/${e}/hqdefault.jpg`,alt:t,className:"aspect-video w-full object-cover"}),r.jsx("span",{className:"absolute inset-0 flex items-center justify-center",children:r.jsx("span",{className:"flex size-10 items-center justify-center rounded-full bg-black/60 text-white",children:r.jsx(M.Play,{className:"size-5 fill-current"})})})]}),children:r.jsx(on,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${e}?autoplay=1`,title:t,allow:"autoplay; encrypted-media; picture-in-picture; fullscreen",allowFullScreen:!0,className:"aspect-video w-full rounded-2xl"})})})}const Tu=new Map([["youtube",/^[\w-]{11}$/],["vimeo",/^\d+(?:\/[\da-f]+)?$/],["loom",/^[\da-f]{32}$/],["wistia",/^[\da-z]{10}$/]]),Iu=new Map([["youtube","YouTube video"],["vimeo","Vimeo video"],["loom","Loom video"],["wistia","Wistia video"]]);function zu(e,t){var o;if(typeof e!="string"||typeof t!="string"||!((o=Tu.get(e))!=null&&o.test(t)))return;const n=Iu.get(e)??"Video";switch(e){case"youtube":return{src:`https://www.youtube-nocookie.com/embed/${t}`,title:n};case"vimeo":{const[s,a]=t.split("/");return{src:`https://player.vimeo.com/video/${s}${a?`?h=${a}`:""}`,title:n}}case"loom":return{src:`https://www.loom.com/embed/${t}`,title:n};case"wistia":return{src:`https://fast.wistia.net/embed/iframe/${t}`,title:n};default:return}}var oa,sa;const yr={...ye.defaultSchema,attributes:{...ye.defaultSchema.attributes,code:[...((oa=ye.defaultSchema.attributes)==null?void 0:oa.code)??[],"className"],pre:[...((sa=ye.defaultSchema.attributes)==null?void 0:sa.pre)??[],"className"]}};var aa,ia;const Mu={...yr,attributes:{...yr.attributes,div:[...((aa=ye.defaultSchema.attributes)==null?void 0:aa.div)??[],"dataEmbed","dataEmbedId"],a:[...((ia=ye.defaultSchema.attributes)==null?void 0:ia.a)??[],"dataArticleSlug"]}};function eo(e){return r.jsx(to,{...e})}function Ru({openArticle:e,...t}){return r.jsx(to,{...t,articleEmbeds:!0,openArticle:e})}function Pu(e){return r.jsx(to,{...e,configuredStyles:!0})}function to({children:e,messageType:t,messageId:n,configuredStyles:o=!1,articleEmbeds:s=!1,openArticle:a}){const{anchorTarget:i}=C.useConfig();return r.jsx(ni,{"data-type":t,"data-id":n,remarkPlugins:[la],rehypePlugins:o?[pr,Cu,[ye,vu]]:[pr,[ye,s?Mu:yr]],components:{div:({node:c,...d})=>{const l=s?zu(c==null?void 0:c.properties.dataEmbed,c==null?void 0:c.properties.dataEmbedId):void 0;return l?r.jsx("iframe",{src:l.src,title:l.title,loading:"lazy",allow:"encrypted-media; picture-in-picture; fullscreen",allowFullScreen:!0,className:"not-prose my-4 aspect-video w-full rounded-xl border"}):r.jsx("div",{...d})},a:({node:c,children:d,...l})=>{const{href:m}=l,p=s?c==null?void 0:c.properties.dataArticleSlug:void 0;if(typeof p=="string")return a?r.jsx("a",{href:"#",onClick:f=>{f.preventDefault(),a(p)},children:d}):r.jsx(r.Fragment,{children:d});const h=m?_u(m):null;return m&&h?r.jsx(Au,{id:h,title:typeof d=="string"?d:m}):r.jsx("a",{target:l.target||i||"_top",...l,children:d})},img:({src:c,alt:d,...l})=>c?r.jsx(sn,{trigger:r.jsx("img",{src:c,alt:d,...l,className:"cursor-pointer rounded-xl"}),children:r.jsx(on,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx(ei,{src:c,alt:d})})}):r.jsx("img",{src:c,alt:d,...l})},children:ri(e)})}function qe(){const{widgetCtx:{org:e}}=C.useWidget(),{sessionState:{session:t}}=C.useSessions(),n=C.useConfig(),{messagesState:{messages:o}}=C.useMessages(),{routerState:{screen:s}}=C.useWidgetRouter();return{react:u,org:e,session:t,config:n,messages:o,currentScreen:s}}function Ou({currentMessage:e}){var o;const t=qe(),n=(o=t.config.customComponents)==null?void 0:o["message::after"];return n?r.jsx(n,{...t,currentMessage:e}):null}const oi=u.createContext(null);function Lu({children:e}){const{widgetCtx:t,config:n}=C.useWidget(),o=u.useRef({widgetCtx:t,config:n});u.useLayoutEffect(()=>{o.current={widgetCtx:t,config:n}},[t,n]);const s=u.useRef({kind:"main"}),a=u.useMemo(()=>({report:i=>{var x;const{widgetCtx:c,config:d}=o.current,l=(x=d.hooks)==null?void 0:x.onUserActivity;if(!l)return;const{screen:m}=c.routerCtx.state.get(),p=m==="home"?{screen:m,view:s.current}:{screen:m},{session:h}=c.sessionCtx.sessionState.get(),f=h?{...i,session:h,page:p}:{...i,page:p};try{l(f)}catch(g){K.log.error("onUserActivity hook failed",g)}},setHomeView:i=>{s.current=i}}),[]);return r.jsx(oi.Provider,{value:a,children:e})}function no(){return u.useContext(oi)}function ro(e){var n;const t=(n=no())==null?void 0:n.setHomeView;u.useLayoutEffect(()=>{t==null||t(e)},[t,e])}function an(){var n;const{sendMessage:e}=C.useMessages(),t=(n=no())==null?void 0:n.report;return u.useCallback(o=>e(t?{...o,onSubmitted:s=>{var a;(a=o.onSubmitted)==null||a.call(o,s),t({type:"message-sent",message:s})}}:o),[e,t])}function $u({messageId:e,messageOptions:t}){var d;const{messagesState:n}=C.useMessages(),o=an(),{sessionState:s}=C.useSessions(),{pickedOptionId:a}=t,i=((d=K.tappableOptionsMessage(n.messages,s.session))==null?void 0:d.id)===e,c=t.options.find(l=>l.id===a);return c?r.jsx("div",{...L("chat/agent_msg/options"),className:"flex",children:r.jsxs(X,{...L("chat/agent_msg/option_btn"),"data-picked":!0,"aria-pressed":!0,size:"sm",variant:"outline",className:"w-fit pl-2 text-sm text-muted-foreground disabled:opacity-100",disabled:!0,children:[r.jsx(M.CheckIcon,{"aria-hidden":"true",className:"size-3.5 shrink-0"}),c.label]})}):i?r.jsx("div",{...L("chat/agent_msg/options"),role:"group",className:"flex flex-row flex-wrap gap-1.5 [@media(pointer:coarse)]:gap-y-3",children:t.options.map(l=>r.jsxs(X,{...L("chat/agent_msg/option_btn"),size:"sm",variant:"outline",className:"relative w-fit text-sm hover:bg-secondary",onClick:()=>o({content:l.label,optionReply:{messageId:e,optionId:l.id}}),children:[r.jsx("span",{"aria-hidden":"true",className:"absolute top-1/2 left-1/2 size-[max(100%,3rem)] -translate-x-1/2 -translate-y-1/2 [@media(pointer:fine)]:hidden"}),l.label]},l.id))}):null}const Du=["[--tw-prose-body:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-headings:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-lead:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-bold:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-links:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-code:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-counters:hsl(var(--opencx-muted-foreground))]","[--tw-prose-bullets:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quotes:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quote-borders:hsl(var(--opencx-border))]","[--tw-prose-hr:hsl(var(--opencx-border))]","[--tw-prose-th-borders:hsl(var(--opencx-border))]","[--tw-prose-td-borders:hsl(var(--opencx-border))]","[--tw-prose-pre-bg:hsl(var(--opencx-muted))]","[--tw-prose-pre-code:hsl(var(--opencx-foreground))]"].join(" ");function kr(e){const{data:t,id:n,type:o,attachments:s,isFirstInGroup:a,isLastInGroup:i,isAloneInGroup:c,dataComponentNames:d,classNames:l}=e,m=o==="AI"||o==="AGENT"?t.message:"",p=u.useMemo(()=>o==="AI"?Ka(m):null,[o,m]);if(o!=="AI"&&o!=="AGENT")return null;const{variant:h="default"}=t,f=e.replyTo?r.jsx(wu,{replyTo:e.replyTo}):null,x=(j,b,_=!0,v=!0)=>r.jsxs("div",{className:"flex flex-row gap-2",children:[r.jsxs("div",{...L((d==null?void 0:d.message)??"chat/agent_msg/msg"),"data-first":a,"data-last":i,"data-alone":c,"data-variant":h,className:z("transition-all","w-fit py-3 px-4 rounded-3xl bg-secondary text-secondary-foreground","leading-snug text-sm prose prose-sm prose-a:decoration-primary prose-a:underline",Du,"break-words [word-break:break-word]",h==="error"&&"bg-destructive/15 text-destructive",a&&!c&&"rounded-bl-md",i&&!c&&"rounded-tl-md",!a&&!i&&!c&&"rounded-l-md",l==null?void 0:l.message),children:[v&&f,r.jsx(eo,{messageType:o,messageId:n,children:j})]}),_&&r.jsx(Ou,{currentMessage:e})]},b),g=(p==null?void 0:p.some(j=>j.type==="ui"))??!1,y=(p==null?void 0:p.reduce((j,b,_)=>b.type==="markdown"?_:j,-1))??-1,w=(p==null?void 0:p.findIndex(j=>j.type==="markdown"))??-1;return r.jsxs("div",{...L((d==null?void 0:d.messageContainer)??"chat/agent_msg/root"),"data-message-id":n,className:z("w-5/6 flex flex-col items-start gap-1",l==null?void 0:l.messageContainer),children:[s&&s.length>0&&r.jsx("div",{className:"w-full gap-1 flex flex-row flex-wrap items-center justify-start",children:s==null?void 0:s.map(j=>r.jsx(ti,{attachment:j},j.id))}),g&&p?p.map((j,b)=>j.type==="markdown"?x(j.content,`md-${b}`,b===y,b===w):r.jsx("div",{className:"w-full",children:r.jsx(Xa,{spec:j.spec})},`ui-${b}`)):m.length>0&&x(m),e.messageOptions&&r.jsx($u,{messageId:n,messageOptions:e.messageOptions})]})}function Fu(e){return r.jsx("div",{className:"w-full max-w-full overflow-auto shrink-0",children:r.jsx("pre",{className:"text-xs leading-tight whitespace-pre-wrap break-word",children:JSON.stringify(e,null,1)})})}const oo=ot.forwardRef(({className:e,...t},n)=>r.jsx(Rt.Root,{ref:n,className:z("relative flex size-6 aspect-square shrink-0 overflow-hidden rounded-full bg-secondary",e),...t}));oo.displayName=Rt.Root.displayName;const so=ot.forwardRef(({className:e,...t},n)=>r.jsx(Rt.Image,{ref:n,className:z("aspect-square h-full w-full",e),...t}));so.displayName=Rt.Image.displayName;const ao=ot.forwardRef(({className:e,...t},n)=>r.jsx(Rt.Fallback,{ref:n,className:z("flex size-full text-xs items-center justify-center rounded-lg",e),...t}));ao.displayName=Rt.Fallback.displayName;function jr({agent:e,...t}){var n,o;return r.jsxs(oo,{...t,children:[r.jsx(so,{src:(e==null?void 0:e.avatarUrl)||(e==null?void 0:e.avatar)||"",alt:"Agent Icon"}),(e==null?void 0:e.name)&&r.jsx(ao,{children:(o=(n=e==null?void 0:e.name)==null?void 0:n.slice(0,1))==null?void 0:o.toUpperCase()})]})}function Hu({agent:e}){return r.jsx(F.AnimatePresence,{children:r.jsxs(oe,{...L("chat/bot_loading/root"),className:"flex flex-row items-end w-full gap-2 animate-pulse",children:[r.jsx(jr,{agent:e}),r.jsxs("div",{...L("chat/bot_loading/bouncing_dots_container"),className:z("flex items-center [&_span]:bg-secondary-foreground [&_span]:size-1 gap-1 p-2 rounded-xl bg-secondary"),children:[r.jsx(F.motion.span,{className:"rounded-full animate-bounce [animation-delay:-0.3s]"}),r.jsx(F.motion.span,{className:"rounded-full animate-bounce [animation-delay:-0.15s]"}),r.jsx(F.motion.span,{className:"rounded-full animate-bounce"})]})]})})}const Wu='*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}*{-ms-overflow-style:none;scrollbar-width:none}*::-webkit-scrollbar{display:none}*{border-color:hsl(var(--opencx-border))}.\\!container{width:100%!important}.container{width:100%}@media(min-width:640px){.\\!container{max-width:640px!important}.container{max-width:640px}}@media(min-width:768px){.\\!container{max-width:768px!important}.container{max-width:768px}}@media(min-width:1024px){.\\!container{max-width:1024px!important}.container{max-width:1024px}}@media(min-width:1280px){.\\!container{max-width:1280px!important}.container{max-width:1280px}}@media(min-width:1536px){.\\!container{max-width:1536px!important}.container{max-width:1536px}}.prose{color:var(--tw-prose-body);max-width:65ch}.prose :where(p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where([class~=lead]):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-lead);font-size:1.25em;line-height:1.6;margin-top:1.2em;margin-bottom:1.2em}.prose :where(a):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-links);text-decoration:underline;font-weight:500}.prose :where(strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-bold);font-weight:600}.prose :where(a strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(blockquote strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(thead th strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(ol):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:decimal;margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em}.prose :where(ol[type=A]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=A s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=I]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type=I s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type="1"]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:decimal}.prose :where(ul):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:disc;margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{font-weight:400;color:var(--tw-prose-counters)}.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{color:var(--tw-prose-bullets)}.prose :where(dt):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;margin-top:1.25em}.prose :where(hr):not(:where([class~=not-prose],[class~=not-prose] *)){border-color:var(--tw-prose-hr);border-top-width:1px;margin-top:3em;margin-bottom:3em}.prose :where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:500;font-style:italic;color:var(--tw-prose-quotes);border-inline-start-width:.25rem;border-inline-start-color:var(--tw-prose-quote-borders);quotes:"“""”""‘""’";margin-top:1.6em;margin-bottom:1.6em;padding-inline-start:1em}.prose :where(blockquote p:first-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:open-quote}.prose :where(blockquote p:last-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:close-quote}.prose :where(h1):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:800;font-size:2.25em;margin-top:0;margin-bottom:.8888889em;line-height:1.1111111}.prose :where(h1 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:900;color:inherit}.prose :where(h2):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:700;font-size:1.5em;margin-top:2em;margin-bottom:1em;line-height:1.3333333}.prose :where(h2 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:800;color:inherit}.prose :where(h3):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;font-size:1.25em;margin-top:1.6em;margin-bottom:.6em;line-height:1.6}.prose :where(h3 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:700;color:inherit}.prose :where(h4):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;margin-top:1.5em;margin-bottom:.5em;line-height:1.5}.prose :where(h4 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:700;color:inherit}.prose :where(img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(picture):not(:where([class~=not-prose],[class~=not-prose] *)){display:block;margin-top:2em;margin-bottom:2em}.prose :where(video):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(kbd):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:500;font-family:inherit;color:var(--tw-prose-kbd);box-shadow:0 0 0 1px rgb(var(--tw-prose-kbd-shadows) / 10%),0 3px rgb(var(--tw-prose-kbd-shadows) / 10%);font-size:.875em;border-radius:.3125rem;padding-top:.1875em;padding-inline-end:.375em;padding-bottom:.1875em;padding-inline-start:.375em}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-code);font-weight:600;font-size:.875em}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:"`"}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:"`"}.prose :where(a code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(h1 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(h2 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.875em}.prose :where(h3 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.9em}.prose :where(h4 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(blockquote code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(thead th code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(pre):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-pre-code);background-color:var(--tw-prose-pre-bg);overflow-x:auto;font-weight:400;font-size:.875em;line-height:1.7142857;margin-top:1.7142857em;margin-bottom:1.7142857em;border-radius:.375rem;padding-top:.8571429em;padding-inline-end:1.1428571em;padding-bottom:.8571429em;padding-inline-start:1.1428571em}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)){background-color:transparent;border-width:0;border-radius:0;padding:0;font-weight:inherit;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:none}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:none}.prose :where(table):not(:where([class~=not-prose],[class~=not-prose] *)){width:100%;table-layout:auto;margin-top:2em;margin-bottom:2em;font-size:.875em;line-height:1.7142857}.prose :where(thead):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-th-borders)}.prose :where(thead th):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;vertical-align:bottom;padding-inline-end:.5714286em;padding-bottom:.5714286em;padding-inline-start:.5714286em}.prose :where(tbody tr):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-td-borders)}.prose :where(tbody tr:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:0}.prose :where(tbody td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:baseline}.prose :where(tfoot):not(:where([class~=not-prose],[class~=not-prose] *)){border-top-width:1px;border-top-color:var(--tw-prose-th-borders)}.prose :where(tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:top}.prose :where(th,td):not(:where([class~=not-prose],[class~=not-prose] *)){text-align:start}.prose :where(figure>*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(figcaption):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-captions);font-size:.875em;line-height:1.4285714;margin-top:.8571429em}.prose{--tw-prose-body: #374151;--tw-prose-headings: #111827;--tw-prose-lead: #4b5563;--tw-prose-links: #111827;--tw-prose-bold: #111827;--tw-prose-counters: #6b7280;--tw-prose-bullets: #d1d5db;--tw-prose-hr: #e5e7eb;--tw-prose-quotes: #111827;--tw-prose-quote-borders: #e5e7eb;--tw-prose-captions: #6b7280;--tw-prose-kbd: #111827;--tw-prose-kbd-shadows: 17 24 39;--tw-prose-code: #111827;--tw-prose-pre-code: #e5e7eb;--tw-prose-pre-bg: #1f2937;--tw-prose-th-borders: #d1d5db;--tw-prose-td-borders: #e5e7eb;--tw-prose-invert-body: #d1d5db;--tw-prose-invert-headings: #fff;--tw-prose-invert-lead: #9ca3af;--tw-prose-invert-links: #fff;--tw-prose-invert-bold: #fff;--tw-prose-invert-counters: #9ca3af;--tw-prose-invert-bullets: #4b5563;--tw-prose-invert-hr: #374151;--tw-prose-invert-quotes: #f3f4f6;--tw-prose-invert-quote-borders: #374151;--tw-prose-invert-captions: #9ca3af;--tw-prose-invert-kbd: #fff;--tw-prose-invert-kbd-shadows: 255 255 255;--tw-prose-invert-code: #fff;--tw-prose-invert-pre-code: #d1d5db;--tw-prose-invert-pre-bg: rgb(0 0 0 / 50%);--tw-prose-invert-th-borders: #4b5563;--tw-prose-invert-td-borders: #374151;font-size:1rem;line-height:1.75}.prose :where(picture>img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(li):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;margin-bottom:.5em}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.375em}.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.375em}.prose :where(.prose>ul>li p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(.prose>ul>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ul>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(.prose>ol>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ol>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(dl):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where(dd):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;padding-inline-start:1.625em}.prose :where(hr+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(h2+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(h3+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(h4+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(thead th:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(thead th:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(tbody td,tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){padding-top:.5714286em;padding-inline-end:.5714286em;padding-bottom:.5714286em;padding-inline-start:.5714286em}.prose :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(figure):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(.prose>:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(.prose>:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:0}.prose-sm{font-size:.875rem;line-height:1.7142857}.prose-sm :where(p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em}.prose-sm :where([class~=lead]):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:1.2857143em;line-height:1.5555556;margin-top:.8888889em;margin-bottom:.8888889em}.prose-sm :where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.3333333em;margin-bottom:1.3333333em;padding-inline-start:1.1111111em}.prose-sm :where(h1):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:2.1428571em;margin-top:0;margin-bottom:.8em;line-height:1.2}.prose-sm :where(h2):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:1.4285714em;margin-top:1.6em;margin-bottom:.8em;line-height:1.4}.prose-sm :where(h3):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:1.2857143em;margin-top:1.5555556em;margin-bottom:.4444444em;line-height:1.5555556}.prose-sm :where(h4):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.4285714em;margin-bottom:.5714286em;line-height:1.4285714}.prose-sm :where(img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(picture):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(picture>img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose-sm :where(video):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(kbd):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;border-radius:.3125rem;padding-top:.1428571em;padding-inline-end:.3571429em;padding-bottom:.1428571em;padding-inline-start:.3571429em}.prose-sm :where(code):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em}.prose-sm :where(h2 code):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.9em}.prose-sm :where(h3 code):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8888889em}.prose-sm :where(pre):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;line-height:1.6666667;margin-top:1.6666667em;margin-bottom:1.6666667em;border-radius:.25rem;padding-top:.6666667em;padding-inline-end:1em;padding-bottom:.6666667em;padding-inline-start:1em}.prose-sm :where(ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em;padding-inline-start:1.5714286em}.prose-sm :where(ul):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em;padding-inline-start:1.5714286em}.prose-sm :where(li):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.2857143em;margin-bottom:.2857143em}.prose-sm :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.4285714em}.prose-sm :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.4285714em}.prose-sm :where(.prose-sm>ul>li p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5714286em;margin-bottom:.5714286em}.prose-sm :where(.prose-sm>ul>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em}.prose-sm :where(.prose-sm>ul>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.1428571em}.prose-sm :where(.prose-sm>ol>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em}.prose-sm :where(.prose-sm>ol>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.1428571em}.prose-sm :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5714286em;margin-bottom:.5714286em}.prose-sm :where(dl):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em}.prose-sm :where(dt):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em}.prose-sm :where(dd):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.2857143em;padding-inline-start:1.5714286em}.prose-sm :where(hr):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2.8571429em;margin-bottom:2.8571429em}.prose-sm :where(hr+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(h2+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(h3+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(h4+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(table):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;line-height:1.5}.prose-sm :where(thead th):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:1em;padding-bottom:.6666667em;padding-inline-start:1em}.prose-sm :where(thead th:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose-sm :where(thead th:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose-sm :where(tbody td,tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){padding-top:.6666667em;padding-inline-end:1em;padding-bottom:.6666667em;padding-inline-start:1em}.prose-sm :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose-sm :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose-sm :where(figure):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(figure>*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose-sm :where(figcaption):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;line-height:1.3333333;margin-top:.6666667em}.prose-sm :where(.prose-sm>:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(.prose-sm>:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:0}.opencx-text-shimmer{animation:opencx-text-shimmer 2.5s ease-in-out infinite}.opencx-fade-up{animation:opencx-fade-up .3s cubic-bezier(.23,1,.32,1) both}.opencx-voice-shimmer{background-image:linear-gradient(100deg,currentColor 0%,currentColor 38%,hsl(var(--opencx-primary)) 50%,currentColor 62%,currentColor 100%);background-size:250% 100%;-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;animation:opencx-voice-shimmer 1.8s linear infinite}.opencx-voice-skeleton{background-color:hsl(var(--opencx-secondary));background-image:linear-gradient(100deg,transparent 30%,hsl(var(--opencx-background) / .7) 50%,transparent 70%);background-size:250% 100%;animation:opencx-voice-shimmer 1.6s linear infinite}[data-component="chat/voice_call/root"] [data-component="chat/user_msg/msg"],[data-component="chat/voice_call/root"] [data-component="chat/agent_msg/msg"] :is(p,li){unicode-bidi:plaintext}.opencx-voice-transcript-mask{mask-image:linear-gradient(to bottom,transparent 0,#000 3rem);-webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 3rem)}[data-component="trigger/unread"],[data-component="sessions/unread"],[data-component="home/tab_unread"]{pointer-events:none;border-radius:9999px;background-color:hsl(var(--opencx-destructive));text-align:center;font-weight:600;--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction);color:hsl(var(--opencx-destructive-foreground));font-size:11px;line-height:18px;box-shadow:0 0 0 2px hsl(var(--opencx-background))}[data-component="trigger/unread"]{position:absolute;z-index:1}[data-component="sessions/unread"]{flex-shrink:0;box-shadow:none}[data-component="home/tab_unread"]{position:absolute;top:-2px;inset-inline-end:-2px}[data-unread-look=dot]{width:9px;height:9px}[data-unread-look=count]{min-width:16px;height:16px;padding:0 4px;font-size:10px;line-height:16px}.opencx-placeholder-in{animation:opencx-placeholder-in .2s cubic-bezier(.23,1,.32,1) both}.opencx-placeholder-out{animation:opencx-placeholder-out .18s cubic-bezier(.23,1,.32,1) both}@keyframes opencx-text-shimmer{0%,to{opacity:.45}50%{opacity:1}}@keyframes opencx-voice-shimmer{0%{background-position:100% 0}to{background-position:0% 0}}@keyframes opencx-fade-up{0%{opacity:0;filter:blur(4px);transform:translateY(8px)}to{opacity:1;filter:blur(0px);transform:translateY(0)}}@keyframes opencx-placeholder-in{0%{opacity:0;transform:translateY(4px);filter:blur(1px)}to{opacity:1;transform:translateY(0);filter:blur(0)}}@keyframes opencx-placeholder-out{0%{opacity:1;transform:translateY(0);filter:blur(0)}to{opacity:0;transform:translateY(-8px);filter:blur(1px)}}.opencx-input-recall{animation:opencx-input-recall .15s cubic-bezier(.23,1,.32,1)}@keyframes opencx-input-recall{0%{opacity:.25;translate:0 -3px}to{opacity:1;translate:0 0}}@media(prefers-reduced-motion:reduce){.opencx-text-shimmer,.opencx-fade-up,.opencx-placeholder-in,.opencx-placeholder-out,.opencx-input-recall,.opencx-voice-skeleton{animation:none}.opencx-voice-shimmer{animation:none;background-image:none;-webkit-text-fill-color:currentColor;opacity:.7}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.\\!visible{visibility:visible!important}.visible{visibility:visible}.invisible{visibility:hidden}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.\\!sticky{position:sticky!important}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-0\\.5{top:.125rem;right:.125rem;bottom:.125rem;left:.125rem}.inset-x-0{left:0;right:0}.bottom-0{bottom:0}.bottom-3{bottom:.75rem}.end-1{inset-inline-end:.25rem}.end-4{inset-inline-end:1rem}.end-6{inset-inline-end:1.5rem}.left-1\\/2,.left-\\[50\\%\\]{left:50%}.right-4{right:1rem}.start-10{inset-inline-start:2.5rem}.start-2{inset-inline-start:.5rem}.start-4{inset-inline-start:1rem}.top-1{top:.25rem}.top-1\\/2{top:50%}.top-2{top:.5rem}.top-3{top:.75rem}.top-4{top:1rem}.top-6{top:1.5rem}.top-\\[50\\%\\]{top:50%}.top-full{top:100%}.isolate{isolation:isolate}.-z-10{z-index:-10}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.z-\\[60\\]{z-index:60}.order-1{order:1}.order-2{order:2}.col-span-full{grid-column:1 / -1}.m-2{margin:.5rem}.-mx-0\\.5{margin-left:-.125rem;margin-right:-.125rem}.-mx-2{margin-left:-.5rem;margin-right:-.5rem}.mx-0\\.5{margin-left:.125rem;margin-right:.125rem}.mx-3{margin-left:.75rem;margin-right:.75rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-top:.25rem;margin-bottom:.25rem}.my-4{margin-top:1rem;margin-bottom:1rem}.-mt-0\\.5{margin-top:-.125rem}.-mt-6{margin-top:-1.5rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.ml-auto{margin-left:auto}.ms-1\\.5{margin-inline-start:.375rem}.ms-\\[30px\\]{margin-inline-start:30px}.ms-auto{margin-inline-start:auto}.mt-0\\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-12{margin-top:3rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-auto{margin-top:auto}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.line-clamp-3{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.inline-grid{display:inline-grid}.contents{display:contents}.hidden{display:none}.aspect-square{aspect-ratio:1 / 1}.aspect-video{aspect-ratio:16 / 9}.size-0{width:0px;height:0px}.size-1\\.5{width:.375rem;height:.375rem}.size-10{width:2.5rem;height:2.5rem}.size-12{width:3rem;height:3rem}.size-14{width:3.5rem;height:3.5rem}.size-16{width:4rem;height:4rem}.size-2{width:.5rem;height:.5rem}.size-2\\.5{width:.625rem;height:.625rem}.size-3{width:.75rem;height:.75rem}.size-3\\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-5{width:1.25rem;height:1.25rem}.size-6{width:1.5rem;height:1.5rem}.size-7{width:1.75rem;height:1.75rem}.size-8{width:2rem;height:2rem}.size-9{width:2.25rem;height:2.25rem}.size-\\[18px\\]{width:18px;height:18px}.size-\\[max\\(100\\%\\,3rem\\)\\]{width:max(100%,3rem);height:max(100%,3rem)}.size-fit{width:fit-content;height:fit-content}.size-full{width:100%;height:100%}.h-0{height:0px}.h-1{height:.25rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-3{height:.75rem}.h-3\\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-9{height:2.25rem}.h-full{height:100%}.h-px{height:1px}.max-h-16{max-height:4rem}.max-h-40{max-height:10rem}.max-h-60{max-height:15rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-\\[160px\\]{max-height:160px}.max-h-\\[200px\\]{max-height:200px}.max-h-\\[50vh\\]{max-height:50vh}.max-h-full{max-height:100%}.min-h-0{min-height:0px}.min-h-11{min-height:2.75rem}.min-h-12{min-height:3rem}.min-h-14{min-height:3.5rem}.min-h-7{min-height:1.75rem}.min-h-8{min-height:2rem}.min-h-\\[4\\.5rem\\]{min-height:4.5rem}.w-0{width:0px}.w-1\\/2{width:50%}.w-1\\/4{width:25%}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-2\\/3{width:66.666667%}.w-2\\/5{width:40%}.w-3\\/4{width:75%}.w-3\\/5{width:60%}.w-4{width:1rem}.w-5\\/6{width:83.333333%}.w-7{width:1.75rem}.w-\\[32px\\]{width:32px}.w-\\[3px\\]{width:3px}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.w-px{width:1px}.w-screen{width:100vw}.w-svw{width:100svw}.min-w-0{min-width:0px}.min-w-80{min-width:20rem}.min-w-\\[140px\\]{min-width:140px}.min-w-\\[3ch\\]{min-width:3ch}.max-w-11{max-width:2.75rem}.max-w-40{max-width:10rem}.max-w-48{max-width:12rem}.max-w-64{max-width:16rem}.max-w-80{max-width:20rem}.max-w-96{max-width:24rem}.max-w-\\[30rem\\]{max-width:30rem}.max-w-\\[61\\.8\\%\\]{max-width:61.8%}.max-w-\\[85\\%\\]{max-width:85%}.max-w-\\[min\\(100\\%\\,16rem\\)\\]{max-width:min(100%,16rem)}.max-w-full{max-width:100%}.max-w-none{max-width:none}.max-w-xs{max-width:20rem}.flex-1{flex:1 1 0%}.flex-none{flex:none}.flex-shrink,.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.shrink-\\[2\\]{flex-shrink:2}.flex-grow,.grow{flex-grow:1}.border-collapse{border-collapse:collapse}.origin-\\[var\\(--radix-popover-content-transform-origin\\)\\]{transform-origin:var(--radix-popover-content-transform-origin)}.origin-\\[var\\(--radix-tooltip-content-transform-origin\\)\\]{transform-origin:var(--radix-tooltip-content-transform-origin)}.origin-center{transform-origin:center}.origin-top{transform-origin:top}.-translate-x-1\\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-\\[-50\\%\\]{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-\\[var\\(--wobble-x\\)\\]{--tw-translate-x: var(--wobble-x);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-\\[-50\\%\\]{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-\\[var\\(--wobble-y\\)\\]{--tw-translate-y: var(--wobble-y);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rotate-90{--tw-rotate: -90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-y-50{--tw-scale-y: .5;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes bounce{0%,to{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,.2,1)}}.animate-bounce{animation:bounce 1s infinite}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;user-select:none}.resize-none{resize:none}.resize{resize:both}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-\\[subgrid\\]{grid-template-columns:subgrid}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.items-stretch{align-items:stretch}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-\\[1px\\]{gap:1px}.gap-\\[3px\\]{gap:3px}.gap-x-2\\.5{column-gap:.625rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-foreground\\/10>:not([hidden])~:not([hidden]){border-color:hsl(var(--opencx-foreground) / .1)}.self-start{align-self:flex-start}.self-end{align-self:flex-end}.self-center{align-self:center}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-scroll{overflow:scroll}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overscroll-contain{overscroll-behavior:contain}.scroll-smooth{scroll-behavior:smooth}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text-ellipsis{text-overflow:ellipsis}.whitespace-normal{white-space:normal}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-balance{text-wrap:balance}.text-pretty{text-wrap:pretty}.break-words{overflow-wrap:break-word}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:1rem}.rounded-3xl{border-radius:1.5rem}.rounded-\\[19px\\]{border-radius:19px}.rounded-\\[1px\\]{border-radius:1px}.rounded-\\[20px\\]{border-radius:20px}.rounded-\\[calc\\(var\\(--opencx-inset-radius\\)\\+var\\(--cx-p\\)\\)\\]{border-radius:calc(var(--opencx-inset-radius) + var(--cx-p))}.rounded-\\[calc\\(var\\(--pk-r\\)-var\\(--pk-p\\)\\)\\]{border-radius:calc(var(--pk-r) - var(--pk-p))}.rounded-\\[var\\(--opencx-inset-radius\\)\\]{border-radius:var(--opencx-inset-radius)}.rounded-\\[var\\(--pk-r\\)\\]{border-radius:var(--pk-r)}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.rounded-b-2xl{border-bottom-right-radius:1rem;border-bottom-left-radius:1rem}.rounded-l-md{border-top-left-radius:.375rem;border-bottom-left-radius:.375rem}.rounded-r-md{border-top-right-radius:.375rem;border-bottom-right-radius:.375rem}.rounded-bl-md{border-bottom-left-radius:.375rem}.rounded-br-md{border-bottom-right-radius:.375rem}.rounded-ee-md{border-end-end-radius:.375rem}.rounded-tl-md{border-top-left-radius:.375rem}.rounded-tr-md{border-top-right-radius:.375rem}.border{border-width:1px}.border-\\[1\\.5px\\]{border-width:1.5px}.border-b{border-bottom-width:1px}.border-l-2{border-left-width:2px}.border-s{border-inline-start-width:1px}.border-s-2{border-inline-start-width:2px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-border{border-color:hsl(var(--opencx-border))}.border-destructive\\/30{border-color:hsl(var(--opencx-destructive) / .3)}.border-foreground\\/10{border-color:hsl(var(--opencx-foreground) / .1)}.border-foreground\\/15{border-color:hsl(var(--opencx-foreground) / .15)}.border-muted-foreground\\/10{border-color:hsl(var(--opencx-muted-foreground) / .1)}.border-muted-foreground\\/15{border-color:hsl(var(--opencx-muted-foreground) / .15)}.border-muted-foreground\\/20{border-color:hsl(var(--opencx-muted-foreground) / .2)}.border-muted-foreground\\/30{border-color:hsl(var(--opencx-muted-foreground) / .3)}.border-primary{border-color:hsl(var(--opencx-primary))}.border-primary\\/10{border-color:hsl(var(--opencx-primary) / .1)}.border-primary\\/50{border-color:hsl(var(--opencx-primary) / .5)}.border-l-amber-500{--tw-border-opacity: 1;border-left-color:rgb(245 158 11 / var(--tw-border-opacity, 1))}.border-l-blue-500{--tw-border-opacity: 1;border-left-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-l-emerald-500{--tw-border-opacity: 1;border-left-color:rgb(16 185 129 / var(--tw-border-opacity, 1))}.border-l-red-500{--tw-border-opacity: 1;border-left-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-t-current{border-top-color:currentColor}.bg-\\[white\\]{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(245 158 11 / var(--tw-bg-opacity, 1))}.bg-amber-500\\/15{background-color:#f59e0b26}.bg-amber-500\\/5{background-color:#f59e0b0d}.bg-background{background-color:hsl(var(--opencx-background))}.bg-background\\/80{background-color:hsl(var(--opencx-background) / .8)}.bg-black\\/50{background-color:#00000080}.bg-black\\/60{background-color:#0009}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\\/5{background-color:#3b82f60d}.bg-border{background-color:hsl(var(--opencx-border))}.bg-current{background-color:currentColor}.bg-destructive{background-color:hsl(var(--opencx-destructive))}.bg-destructive\\/10{background-color:hsl(var(--opencx-destructive) / .1)}.bg-destructive\\/15{background-color:hsl(var(--opencx-destructive) / .15)}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-emerald-500\\/10{background-color:#10b9811a}.bg-emerald-500\\/15{background-color:#10b98126}.bg-emerald-500\\/5{background-color:#10b9810d}.bg-foreground{background-color:hsl(var(--opencx-foreground))}.bg-foreground\\/5{background-color:hsl(var(--opencx-foreground) / .05)}.bg-foreground\\/50{background-color:hsl(var(--opencx-foreground) / .5)}.bg-foreground\\/60{background-color:hsl(var(--opencx-foreground) / .6)}.bg-muted{background-color:hsl(var(--opencx-muted))}.bg-muted-foreground{background-color:hsl(var(--opencx-muted-foreground))}.bg-muted-foreground\\/10{background-color:hsl(var(--opencx-muted-foreground) / .1)}.bg-muted-foreground\\/30{background-color:hsl(var(--opencx-muted-foreground) / .3)}.bg-muted-foreground\\/40{background-color:hsl(var(--opencx-muted-foreground) / .4)}.bg-muted\\/30{background-color:hsl(var(--opencx-muted) / .3)}.bg-muted\\/40{background-color:hsl(var(--opencx-muted) / .4)}.bg-primary{background-color:hsl(var(--opencx-primary))}.bg-primary-foreground\\/20{background-color:hsl(var(--opencx-primary-foreground) / .2)}.bg-primary\\/10{background-color:hsl(var(--opencx-primary) / .1)}.bg-primary\\/25{background-color:hsl(var(--opencx-primary) / .25)}.bg-primary\\/80{background-color:hsl(var(--opencx-primary) / .8)}.bg-primary\\/\\[0\\.07\\]{background-color:hsl(var(--opencx-primary) / .07)}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-500\\/5{background-color:#ef44440d}.bg-secondary{background-color:hsl(var(--opencx-secondary))}.bg-secondary-foreground\\/10{background-color:hsl(var(--opencx-secondary-foreground) / .1)}.bg-secondary-foreground\\/20{background-color:hsl(var(--opencx-secondary-foreground) / .2)}.bg-transparent{background-color:transparent}.bg-white\\/30{background-color:#ffffff4d}.bg-\\[radial-gradient\\(ellipse_at_top_left\\,hsl\\(var\\(--opencx-primary\\)\\)\\,transparent\\)\\,radial-gradient\\(ellipse_at_top_right\\,hsl\\(var\\(--opencx-primary\\)\\)\\,transparent\\)\\]{background-image:radial-gradient(ellipse at top left,hsl(var(--opencx-primary)),transparent),radial-gradient(ellipse at top right,hsl(var(--opencx-primary)),transparent)}.bg-gradient-to-t{background-image:linear-gradient(to top,var(--tw-gradient-stops))}.from-foreground\\/70{--tw-gradient-from: hsl(var(--opencx-foreground) / .7) var(--tw-gradient-from-position);--tw-gradient-to: hsl(var(--opencx-foreground) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-foreground\\/0{--tw-gradient-to: hsl(var(--opencx-foreground) / 0) var(--tw-gradient-to-position)}.fill-current{fill:currentColor}.fill-foreground{fill:hsl(var(--opencx-foreground))}.stroke-current{stroke:currentColor}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-left-top{object-position:left top}.p-0{padding:0}.p-0\\.5{padding:.125rem}.p-1{padding:.25rem}.p-1\\.5{padding:.375rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-\\[var\\(--cx-p\\)\\]{padding:var(--cx-p)}.p-\\[var\\(--pk-p\\)\\]{padding:var(--pk-p)}.px-0\\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-0{padding-top:0;padding-bottom:0}.py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-\\[3px\\]{padding-top:3px;padding-bottom:3px}.pb-0{padding-bottom:0}.pb-0\\.5{padding-bottom:.125rem}.pb-1{padding-bottom:.25rem}.pb-10{padding-bottom:2.5rem}.pb-14{padding-bottom:3.5rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pb-5{padding-bottom:1.25rem}.pe-1{padding-inline-end:.25rem}.pe-2{padding-inline-end:.5rem}.pe-2\\.5{padding-inline-end:.625rem}.pe-4{padding-inline-end:1rem}.pl-2{padding-left:.5rem}.pl-6{padding-left:1.5rem}.pr-16{padding-right:4rem}.ps-1{padding-inline-start:.25rem}.ps-1\\.5{padding-inline-start:.375rem}.ps-10{padding-inline-start:2.5rem}.ps-2{padding-inline-start:.5rem}.ps-2\\.5{padding-inline-start:.625rem}.ps-3{padding-inline-start:.75rem}.ps-4{padding-inline-start:1rem}.ps-8{padding-inline-start:2rem}.pt-0{padding-top:0}.pt-1{padding-top:.25rem}.pt-1\\.5{padding-top:.375rem}.pt-12{padding-top:3rem}.pt-2{padding-top:.5rem}.pt-2\\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.pt-6{padding-top:1.5rem}.pt-8{padding-top:2rem}.text-left{text-align:left}.text-center{text-align:center}.text-start{text-align:start}.align-middle{vertical-align:middle}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.font-sans{font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji"}.text-2xl{font-size:1.5rem;line-height:2rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-\\[0\\.8125rem\\]{font-size:.8125rem}.text-\\[1\\.75rem\\]{font-size:1.75rem}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.text-\\[12px\\]{font-size:12px}.text-\\[13px\\]{font-size:13px}.text-\\[14px\\]{font-size:14px}.text-\\[15px\\]{font-size:15px}.text-\\[16px\\]{font-size:16px}.text-\\[17px\\]{font-size:17px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-none{line-height:1}.leading-relaxed{line-height:1.625}.leading-snug{line-height:1.375}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-background{color:hsl(var(--opencx-background))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-destructive{color:hsl(var(--opencx-destructive))}.text-destructive-foreground{color:hsl(var(--opencx-destructive-foreground))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(5 150 105 / var(--tw-text-opacity, 1))}.text-foreground{color:hsl(var(--opencx-foreground))}.text-foreground\\/50{color:hsl(var(--opencx-foreground) / .5)}.text-foreground\\/60{color:hsl(var(--opencx-foreground) / .6)}.text-foreground\\/80{color:hsl(var(--opencx-foreground) / .8)}.text-foreground\\/90{color:hsl(var(--opencx-foreground) / .9)}.text-muted-foreground{color:hsl(var(--opencx-muted-foreground))}.text-muted-foreground\\/40{color:hsl(var(--opencx-muted-foreground) / .4)}.text-muted-foreground\\/50{color:hsl(var(--opencx-muted-foreground) / .5)}.text-muted-foreground\\/60{color:hsl(var(--opencx-muted-foreground) / .6)}.text-muted-foreground\\/70{color:hsl(var(--opencx-muted-foreground) / .7)}.text-muted-foreground\\/75{color:hsl(var(--opencx-muted-foreground) / .75)}.text-primary{color:hsl(var(--opencx-primary))}.text-primary-foreground{color:hsl(var(--opencx-primary-foreground))}.text-primary-foreground\\/60{color:hsl(var(--opencx-primary-foreground) / .6)}.text-primary\\/10{color:hsl(var(--opencx-primary) / .1)}.text-primary\\/40{color:hsl(var(--opencx-primary) / .4)}.text-primary\\/50{color:hsl(var(--opencx-primary) / .5)}.text-primary\\/60{color:hsl(var(--opencx-primary) / .6)}.text-primary\\/70{color:hsl(var(--opencx-primary) / .7)}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-secondary-foreground{color:hsl(var(--opencx-secondary-foreground))}.text-secondary-foreground\\/60{color:hsl(var(--opencx-secondary-foreground) / .6)}.text-secondary-foreground\\/70{color:hsl(var(--opencx-secondary-foreground) / .7)}.text-transparent{color:transparent}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-white\\/80{color:#fffc}.underline{text-decoration-line:underline}.line-through{text-decoration-line:line-through}.underline-offset-2{text-underline-offset:2px}.underline-offset-4{text-underline-offset:4px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.caret-foreground{caret-color:hsl(var(--opencx-foreground))}.accent-current{accent-color:currentColor}.opacity-0{opacity:0}.opacity-100{opacity:1}.opacity-20{opacity:.2}.opacity-35{opacity:.35}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-90{opacity:.9}.opacity-95{opacity:.95}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.outline-8{outline-width:8px}.outline-background{outline-color:hsl(var(--opencx-background))}.ring{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-border{--tw-ring-color: hsl(var(--opencx-border))}.ring-offset-background{--tw-ring-offset-color: hsl(var(--opencx-background))}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.drop-shadow{--tw-drop-shadow: drop-shadow(0 1px 2px rgb(0 0 0 / .1)) drop-shadow(0 1px 1px rgb(0 0 0 / .06));filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\\[background-color\\,color\\,transform\\]{transition-property:background-color,color,transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\\[height\\]{transition-property:height;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\\[transform\\,background-color\\,color\\]{transition-property:transform,background-color,color;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\\[width\\]{transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-100{transition-duration:.1s}.duration-150{transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.ease-opencx{transition-timing-function:cubic-bezier(.23,1,.32,1)}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.animate-in{animation-name:enter;animation-duration:.15s;--tw-enter-opacity: initial;--tw-enter-scale: initial;--tw-enter-rotate: initial;--tw-enter-translate-x: initial;--tw-enter-translate-y: initial}.fade-in-0{--tw-enter-opacity: 0}.zoom-in{--tw-enter-scale: 0}.zoom-in-95{--tw-enter-scale: .95}.duration-100{animation-duration:.1s}.duration-150{animation-duration:.15s}.duration-200{animation-duration:.2s}.duration-300{animation-duration:.3s}.ease-opencx{animation-timing-function:cubic-bezier(.23,1,.32,1)}.ease-out{animation-timing-function:cubic-bezier(0,0,.2,1)}.running{animation-play-state:running}.paused{animation-play-state:paused}.\\[--tw-prose-body\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-body: hsl(var(--opencx-foreground))}.\\[--tw-prose-body\\:hsl\\(var\\(--opencx-muted-foreground\\)\\)\\]{--tw-prose-body: hsl(var(--opencx-muted-foreground))}.\\[--tw-prose-body\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-body: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-bold\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-bold: hsl(var(--opencx-foreground))}.\\[--tw-prose-bold\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-bold: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-bullets\\:hsl\\(var\\(--opencx-muted-foreground\\)\\)\\]{--tw-prose-bullets: hsl(var(--opencx-muted-foreground))}.\\[--tw-prose-code\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-code: hsl(var(--opencx-foreground))}.\\[--tw-prose-code\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-code: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-counters\\:hsl\\(var\\(--opencx-muted-foreground\\)\\)\\]{--tw-prose-counters: hsl(var(--opencx-muted-foreground))}.\\[--tw-prose-headings\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-headings: hsl(var(--opencx-foreground))}.\\[--tw-prose-headings\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-headings: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-hr\\:hsl\\(var\\(--opencx-border\\)\\)\\]{--tw-prose-hr: hsl(var(--opencx-border))}.\\[--tw-prose-lead\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-lead: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-links\\:hsl\\(var\\(--opencx-primary\\)\\)\\]{--tw-prose-links: hsl(var(--opencx-primary))}.\\[--tw-prose-links\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-links: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-pre-bg\\:hsl\\(var\\(--opencx-muted\\)\\)\\]{--tw-prose-pre-bg: hsl(var(--opencx-muted))}.\\[--tw-prose-pre-code\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-pre-code: hsl(var(--opencx-foreground))}.\\[--tw-prose-quote-borders\\:hsl\\(var\\(--opencx-border\\)\\)\\]{--tw-prose-quote-borders: hsl(var(--opencx-border))}.\\[--tw-prose-quotes\\:hsl\\(var\\(--opencx-muted-foreground\\)\\)\\]{--tw-prose-quotes: hsl(var(--opencx-muted-foreground))}.\\[--tw-prose-td-borders\\:hsl\\(var\\(--opencx-border\\)\\)\\]{--tw-prose-td-borders: hsl(var(--opencx-border))}.\\[--tw-prose-th-borders\\:hsl\\(var\\(--opencx-border\\)\\)\\]{--tw-prose-th-borders: hsl(var(--opencx-border))}.\\[animation-delay\\:-0\\.15s\\]{animation-delay:-.15s}.\\[animation-delay\\:-0\\.3s\\]{animation-delay:-.3s}.\\[field-sizing\\:content\\;\\],.\\[field-sizing\\:content\\]{field-sizing:content}.\\[overflow-wrap\\:anywhere\\]{overflow-wrap:anywhere}.\\[word-break\\:break-word\\]{word-break:break-word}.file\\:border-0::file-selector-button{border-width:0px}.file\\:bg-transparent::file-selector-button{background-color:transparent}.file\\:text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:font-medium::file-selector-button{font-weight:500}.file\\:text-primary-foreground::file-selector-button{color:hsl(var(--opencx-primary-foreground))}.placeholder\\:text-muted-foreground::placeholder{color:hsl(var(--opencx-muted-foreground))}.placeholder\\:text-muted-foreground\\/75::placeholder{color:hsl(var(--opencx-muted-foreground) / .75)}.last\\:border-0:last-child{border-width:0px}.focus-within\\:opacity-100:focus-within{opacity:1}.hover\\:scale-\\[var\\(--scale\\)\\]:hover{--tw-scale-x: var(--scale);--tw-scale-y: var(--scale);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\\:bg-accent\\/60:hover{background-color:hsl(var(--opencx-accent) / .6)}.hover\\:bg-foreground:hover{background-color:hsl(var(--opencx-foreground))}.hover\\:bg-foreground\\/90:hover{background-color:hsl(var(--opencx-foreground) / .9)}.hover\\:bg-muted:hover{background-color:hsl(var(--opencx-muted))}.hover\\:bg-muted\\/50:hover{background-color:hsl(var(--opencx-muted) / .5)}.hover\\:bg-muted\\/60:hover{background-color:hsl(var(--opencx-muted) / .6)}.hover\\:bg-primary\\/10:hover{background-color:hsl(var(--opencx-primary) / .1)}.hover\\:bg-primary\\/90:hover{background-color:hsl(var(--opencx-primary) / .9)}.hover\\:bg-primary\\/\\[0\\.02\\]:hover{background-color:hsl(var(--opencx-primary) / .02)}.hover\\:bg-red-500:hover{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.hover\\:bg-secondary:hover{background-color:hsl(var(--opencx-secondary))}.hover\\:bg-secondary\\/80:hover{background-color:hsl(var(--opencx-secondary) / .8)}.hover\\:bg-transparent:hover{background-color:transparent}.hover\\:bg-white\\/15:hover{background-color:#ffffff26}.hover\\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.hover\\:text-foreground:hover{color:hsl(var(--opencx-foreground))}.hover\\:text-muted-foreground:hover{color:hsl(var(--opencx-muted-foreground))}.hover\\:text-primary:hover{color:hsl(var(--opencx-primary))}.hover\\:text-primary-foreground:hover{color:hsl(var(--opencx-primary-foreground))}.hover\\:text-secondary-foreground:hover{color:hsl(var(--opencx-secondary-foreground))}.hover\\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.hover\\:underline:hover{text-decoration-line:underline}.hover\\:opacity-100:hover{opacity:1}.hover\\:opacity-80:hover{opacity:.8}.focus-visible\\:opacity-100:focus-visible{opacity:1}.focus-visible\\:outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:outline:focus-visible{outline-style:solid}.focus-visible\\:outline-2:focus-visible{outline-width:2px}.focus-visible\\:outline-ring:focus-visible{outline-color:hsl(var(--opencx-ring))}.focus-visible\\:ring-1:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\\:ring-2:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\\:ring-inset:focus-visible{--tw-ring-inset: inset}.focus-visible\\:ring-primary\\/40:focus-visible{--tw-ring-color: hsl(var(--opencx-primary) / .4)}.focus-visible\\:ring-ring:focus-visible{--tw-ring-color: hsl(var(--opencx-ring))}.focus-visible\\:ring-offset-2:focus-visible{--tw-ring-offset-width: 2px}.active\\:scale-90:active{--tw-scale-x: .9;--tw-scale-y: .9;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.active\\:scale-95:active{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.active\\:scale-\\[0\\.97\\]:active{--tw-scale-x: .97;--tw-scale-y: .97;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.active\\:hover\\:scale-\\[calc\\(var\\(--scale\\)-0\\.02\\)\\]:hover:active{--tw-scale-x: calc(var(--scale) - .02);--tw-scale-y: calc(var(--scale) - .02);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\\:pointer-events-none:disabled{pointer-events:none}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:text-white\\/30:disabled{color:#ffffff4d}.disabled\\:opacity-100:disabled{opacity:1}.disabled\\:opacity-40:disabled{opacity:.4}.disabled\\:opacity-50:disabled{opacity:.5}.disabled\\:hover\\:bg-transparent:hover:disabled{background-color:transparent}.group:hover .group-hover\\:opacity-100{opacity:1}.aria-expanded\\:bg-muted[aria-expanded=true]{background-color:hsl(var(--opencx-muted))}.data-\\[state\\=closed\\]\\:animate-out[data-state=closed]{animation-name:exit;animation-duration:.15s;--tw-exit-opacity: initial;--tw-exit-scale: initial;--tw-exit-rotate: initial;--tw-exit-translate-x: initial;--tw-exit-translate-y: initial}.data-\\[state\\=closed\\]\\:fade-out-0[data-state=closed]{--tw-exit-opacity: 0}.data-\\[state\\=closed\\]\\:zoom-out-95[data-state=closed]{--tw-exit-scale: .95}.data-\\[side\\=bottom\\]\\:slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y: -.5rem}.data-\\[side\\=left\\]\\:slide-in-from-right-2[data-side=left]{--tw-enter-translate-x: .5rem}.data-\\[side\\=right\\]\\:slide-in-from-left-2[data-side=right]{--tw-enter-translate-x: -.5rem}.data-\\[side\\=top\\]\\:slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y: .5rem}.prose-headings\\:my-1\\.5 :is(:where(h1,h2,h3,h4,h5,h6,th):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.375rem;margin-bottom:.375rem}.prose-headings\\:text-\\[13px\\] :is(:where(h1,h2,h3,h4,h5,h6,th):not(:where([class~=not-prose],[class~=not-prose] *))){font-size:13px}.prose-p\\:my-1 :is(:where(p):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.25rem;margin-bottom:.25rem}.prose-a\\:underline :is(:where(a):not(:where([class~=not-prose],[class~=not-prose] *))){text-decoration-line:underline}.prose-a\\:decoration-primary :is(:where(a):not(:where([class~=not-prose],[class~=not-prose] *))){text-decoration-color:hsl(var(--opencx-primary))}.prose-pre\\:my-1\\.5 :is(:where(pre):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.375rem;margin-bottom:.375rem}.prose-pre\\:p-2 :is(:where(pre):not(:where([class~=not-prose],[class~=not-prose] *))){padding:.5rem}.prose-pre\\:text-\\[11px\\] :is(:where(pre):not(:where([class~=not-prose],[class~=not-prose] *))){font-size:11px}.prose-ol\\:my-1 :is(:where(ol):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.25rem;margin-bottom:.25rem}.prose-ul\\:my-1 :is(:where(ul):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.25rem;margin-bottom:.25rem}.prose-li\\:my-0\\.5 :is(:where(li):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.125rem;margin-bottom:.125rem}.prose-table\\:block :is(:where(table):not(:where([class~=not-prose],[class~=not-prose] *))){display:block}.prose-table\\:overflow-x-auto :is(:where(table):not(:where([class~=not-prose],[class~=not-prose] *))){overflow-x:auto}.prose-table\\:\\[overflow-wrap\\:normal\\] :is(:where(table):not(:where([class~=not-prose],[class~=not-prose] *))){overflow-wrap:normal}.prose-table\\:\\[word-break\\:normal\\] :is(:where(table):not(:where([class~=not-prose],[class~=not-prose] *))){word-break:normal}.prose-img\\:rounded-xl :is(:where(img):not(:where([class~=not-prose],[class~=not-prose] *))){border-radius:.75rem}.prose-hr\\:my-2 :is(:where(hr):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.5rem;margin-bottom:.5rem}@media(prefers-reduced-motion:reduce){.motion-reduce\\:animate-none{animation:none}.motion-reduce\\:active\\:scale-100:active{--tw-scale-x: 1;--tw-scale-y: 1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}}@media(min-width:640px){.sm\\:text-sm{font-size:.875rem;line-height:1.25rem}}.rtl\\:-scale-100:where([dir=rtl],[dir=rtl] *){--tw-scale-x: -1;--tw-scale-y: -1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@media(prefers-color-scheme:dark){.dark\\:text-amber-400{--tw-text-opacity: 1;color:rgb(251 191 36 / var(--tw-text-opacity, 1))}.dark\\:text-emerald-400{--tw-text-opacity: 1;color:rgb(52 211 153 / var(--tw-text-opacity, 1))}.dark\\:text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}}.\\[\\&\\>\\*\\:first-child\\]\\:mt-0>*:first-child{margin-top:0}.\\[\\&\\>\\*\\:last-child\\]\\:mb-0>*:last-child{margin-bottom:0}.\\[\\&_\\.animate-spin\\]\\:animate-none .animate-spin{animation:none}.\\[\\&_span\\]\\:size-1 span{width:.25rem;height:.25rem}.\\[\\&_span\\]\\:bg-secondary-foreground span{background-color:hsl(var(--opencx-secondary-foreground))}.\\[\\&_svg\\]\\:text-muted-foreground\\/70 svg{color:hsl(var(--opencx-muted-foreground) / .7)}.\\[\\&_svg\\]\\:hover\\:text-primary:hover svg{color:hsl(var(--opencx-primary))}@media(hover:none){.\\[\\@media\\(hover\\:none\\)\\]\\:opacity-100{opacity:1}}@media(pointer:coarse){.\\[\\@media\\(pointer\\:coarse\\)\\]\\:min-h-12{min-height:3rem}.\\[\\@media\\(pointer\\:coarse\\)\\]\\:gap-y-3{row-gap:.75rem}}@media(pointer:fine){.\\[\\@media\\(pointer\\:fine\\)\\]\\:hidden{display:none}}',Bu="5.16.0";function Uu(e,t){const n=typeof(e==null?void 0:e.right)=="number",o=typeof(e==null?void 0:e.left)=="number";return n&&!o?"right":o&&!n||t==="rtl"?"left":"right"}const ls=450;function je(){const[e,t]=u.useState(()=>(window.top||window).innerWidth<ls);return u.useEffect(()=>{const n=window.top||window,o=()=>{t(n.innerWidth<ls)};return o(),n.addEventListener("resize",o),()=>{n.removeEventListener("resize",o)}},[]),{isSmallScreen:e}}const xn={transitionTimingFunction:"cubic-bezier(0.16, 1, 0.3, 1)",transitionDuration:"1000ms"};function me(){var h,f,x,g,y,w,j,b,_,v,k,N,R,T,A,O,P,B,E,I,W,$,U,Y,q,se,D,V,Z,te,ae,xe,H,ee,J,ne,le,de,ie,De,Fe,pe,Ve,st,Ye,He,Xe,Ge;const{dir:e}=C.useDocumentDir(),{isSmallScreen:t}=je(),{theme:n,inline:o}=C.useConfig(),s=we=>o?"100%":we,a=(we,Re)=>t?`100dv${we}`:Re,i=(we,Re)=>s(a(we,Re)),c=Uu((h=n==null?void 0:n.widgetTrigger)==null?void 0:h.offset,e),d={zIndex:((f=n==null?void 0:n.widgetTrigger)==null?void 0:f.zIndex)??1e7,offset:{bottom:((g=(x=n==null?void 0:n.widgetTrigger)==null?void 0:x.offset)==null?void 0:g.bottom)??20,right:((w=(y=n==null?void 0:n.widgetTrigger)==null?void 0:y.offset)==null?void 0:w.right)??(c==="right"?20:"initial"),left:((b=(j=n==null?void 0:n.widgetTrigger)==null?void 0:j.offset)==null?void 0:b.left)??(c==="left"?20:"initial")},size:{button:((v=(_=n==null?void 0:n.widgetTrigger)==null?void 0:_.size)==null?void 0:v.button)??48,icon:((N=(k=n==null?void 0:n.widgetTrigger)==null?void 0:k.size)==null?void 0:N.icon)??24}},l=(()=>{const we=c==="right"?d.offset.right:d.offset.left;return typeof we!="number"?0:we})(),m={palette:(n==null?void 0:n.palette)??"neutral",primaryColor:(n==null?void 0:n.primaryColor)??"hsl(0 0% 9%)",widgetTrigger:d,widgetContentContainer:{borderRadius:t?"0px":((R=n==null?void 0:n.widgetContentContainer)==null?void 0:R.borderRadius)??"32px",zIndex:((T=n==null?void 0:n.widgetContentContainer)==null?void 0:T.zIndex)??d.zIndex+1,outline:((A=n==null?void 0:n.widgetContentContainer)==null?void 0:A.outline)??"none",outlineColor:((O=n==null?void 0:n.widgetContentContainer)==null?void 0:O.outlineColor)??"hsl(0 0% 50% / .5)",boxShadow:((P=n==null?void 0:n.widgetContentContainer)==null?void 0:P.boxShadow)??"0 0px 100px 0px rgb(0 0 0 / 0.25)",transitionProperty:((B=n==null?void 0:n.widgetContentContainer)==null?void 0:B.transitionProperty)??"all",transitionTimingFunction:((E=n==null?void 0:n.widgetContentContainer)==null?void 0:E.transitionTimingFunction)??xn.transitionTimingFunction,transitionDuration:((I=n==null?void 0:n.widgetContentContainer)==null?void 0:I.transitionDuration)??xn.transitionDuration,offset:{side:t?0:d.offset.bottom+d.size.button+Tt.y*2+((($=(W=n==null?void 0:n.widgetContentContainer)==null?void 0:W.offset)==null?void 0:$.side)??10),align:t?0:l+(((Y=(U=n==null?void 0:n.widgetContentContainer)==null?void 0:U.offset)==null?void 0:Y.align)??0)}},screens:{welcome:{width:i("w",((se=(q=n==null?void 0:n.screens)==null?void 0:q.welcome)==null?void 0:se.width)??"400px"),minHeight:i("h",((V=(D=n==null?void 0:n.screens)==null?void 0:D.welcome)==null?void 0:V.minHeight)??"1px")},sessions:{width:i("w",((te=(Z=n==null?void 0:n.screens)==null?void 0:Z.sessions)==null?void 0:te.width)??"450px"),height:i("h",((xe=(ae=n==null?void 0:n.screens)==null?void 0:ae.sessions)==null?void 0:xe.height)??"600px")},chat:{width:i("w",((ee=(H=n==null?void 0:n.screens)==null?void 0:H.chat)==null?void 0:ee.width)??"525px"),height:i("h",((ne=(J=n==null?void 0:n.screens)==null?void 0:J.chat)==null?void 0:ne.height)??"700px"),withCanvas:{width:i("w",((ie=(de=(le=n==null?void 0:n.screens)==null?void 0:le.chat)==null?void 0:de.withCanvas)==null?void 0:ie.width)??"min(1050px, 100vw)"),height:i("h",((pe=(Fe=(De=n==null?void 0:n.screens)==null?void 0:De.chat)==null?void 0:Fe.withCanvas)==null?void 0:pe.height)??"min(800px, 100vh)"),transitionTimingFunction:((Ye=(st=(Ve=n==null?void 0:n.screens)==null?void 0:Ve.chat)==null?void 0:st.withCanvas)==null?void 0:Ye.transitionTimingFunction)??xn.transitionTimingFunction,transitionDuration:((Ge=(Xe=(He=n==null?void 0:n.screens)==null?void 0:He.chat)==null?void 0:Xe.withCanvas)==null?void 0:Ge.transitionDuration)??xn.transitionDuration}}}},p={maxHeight:i("h",`calc(
|
|
13
|
+
`);p.trim()&&n.push({type:"markdown",content:p}),o=[]}function l(){if(s.length===0)return;let p=null;if(a.length>0)try{p=Vc(a.join(`
|
|
14
|
+
`),{root:"",elements:{}})}catch{}p&&Ud(p)?(d(),n.push({type:"ui",spec:p})):o.push(...s),a=[],s=[]}function m(){c&&(l(),c=!1)}for(let p=0;p<t.length;p+=1){const h=t[p]??"",f=h.trim(),x=p===t.length-1;if(!i&&f==="```spec"){m(),i=!0,s=[h];continue}if(i&&f==="```"){s.push(h),l(),i=!1;continue}if(i){s.push(h),f!==""&&mr(h)&&a.push(h);continue}if(f!==""&&mr(h)){c=!0,s.push(h),a.push(h);continue}if(c){if(f===""||x&&Vd(f)){s.push(h);continue}m()}o.push(h)}return l(),d(),n}function Ud(e){return va(e)&&e.elements[e.root]!==void 0}const qd='{"op":';function Vd(e){return!e.startsWith("{")||e.endsWith("}")?!1:/"op"\s*:/.test(e)?!0:qd.startsWith(e.replace(/\s+/g,""))}function Yd(e){return pd(e)}function L(e){return{"data-component":e}}const br=[{kind:"csv",label:"CSV",mimes:["text/csv","application/csv"],extensions:["csv"]},{kind:"excel",label:"Excel",mimes:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],extensions:["xls","xlsx"]}],Xd=Object.fromEntries(br.flatMap(e=>e.mimes.map(t=>[t,e.extensions.map(n=>`.${n}`)]))),Gd={"video/mp4":[".mp4"],"video/webm":[".webm"],"video/quicktime":[".mov"],"video/x-m4v":[".m4v"],"video/x-matroska":[".mkv"],"video/3gpp":[".3gp"]};function Ka({type:e,name:t}){var s,a;const n=((s=t.split(".").pop())==null?void 0:s.toLowerCase())??"",o=((a=e.toLowerCase().split(";")[0])==null?void 0:a.trim())??"";return br.find(i=>n&&i.extensions.includes(n))??br.find(i=>o&&i.mimes.includes(o))??null}function Pn(){const[e]=u.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(hover: hover) and (pointer: fine)").matches);return e}const Tt={x:2,y:2},Oe=u.memo(u.forwardRef(({children:e,className:t,scale:n=1.02,off:o=!1},s)=>{const[a,i]=u.useState(!1),[c,d]=u.useState({x:0,y:0}),l=Pn(),m=F.useReducedMotion();if(o||!l||m)return u.cloneElement(e,{ref:s??e.props.ref});if(/translate/.test(e.props.className||""))return e;const h=y=>{var A,O;const{clientX:w,clientY:j}=y,b=y.currentTarget.getBoundingClientRect(),_=w-(b.left+b.width/2),v=j-(b.top+b.height/2),k=Math.max(-1,Math.min(1,_/(b.width/2))),N=Math.max(-1,Math.min(1,v/(b.height/2))),R=k*Tt.x,T=N*Tt.y;d({x:R,y:T}),(O=(A=e.props).onMouseMove)==null||O.call(A,y)},f=y=>{var w,j;i(!0),(j=(w=e.props).onMouseEnter)==null||j.call(w,y)},x=y=>{var w,j;i(!1),d({x:0,y:0}),(j=(w=e.props).onMouseLeave)==null||j.call(w,y)},g={"--wobble-x":a?`${c.x}px`:"0px","--wobble-y":a?`${c.y}px`:"0px","--scale":1-(n-1)};return u.cloneElement(e,{ref:s,onMouseMove:h,onMouseEnter:f,onMouseLeave:x,style:{...g,...e.props.style},className:z("translate-x-[var(--wobble-x)]","translate-y-[var(--wobble-y)]","hover:scale-[var(--scale)] active:hover:scale-[calc(var(--scale)-0.02)]",t,e.props.className,"transition-transform duration-150 ease-[cubic-bezier(0.23,1,0.32,1)]")})}));Oe.displayName="Wobble";const $e=[.23,1,.32,1],Kd=`cubic-bezier(${$e.join(", ")})`,ke={duration:.2,ease:$e},ge={duration:.15,ease:$e},It={type:"spring",stiffness:500,damping:45,mass:1},Zd=[.32,.72,.24,1],Jd=`cubic-bezier(${Zd.join(", ")})`,Qd="0 2px 12px 0 rgba(0,0,0,0.18), 0 1px 4px 0 rgba(0,0,0,0), 0 0 0 1px rgba(255,255,255,0.08), inset 0 1px 0 0 rgba(255,255,255,0)",eu="0 8px 28px 0 rgba(0,0,0,0.10), 0 1px 4px 0 rgba(0,0,0,0), 0 0 0 1px rgba(0,0,0,0.05), inset 0 1px 0 0 rgba(255,255,255,0.5)",tu="0 12px 40px 0 rgba(0,0,0,0.12), 0 2px 8px 0 rgba(0,0,0,0.04), 0 0 0 1px rgba(0,0,0,0.05), inset 0 1px 0 0 rgba(255,255,255,0.5)",nu="0 24px 48px -16px rgba(0,0,0,0.18), 0 4px 16px 0 rgba(0,0,0,0.05), 0 0 0 1px rgba(0,0,0,0.05), inset 0 1px 0 0 rgba(255,255,255,0.5)",ru=10,ou=(e,t,n)=>({initial:{opacity:0,x:-e,...t.initial},animate:{opacity:1,x:0,...t.animate,transition:{...ke,delay:n}},exit:{opacity:0,x:e,...t.exit,transition:ge},transition:ke}),su=(e,t,n)=>({initial:{opacity:0,x:e,...t.initial},animate:{opacity:1,x:0,...t.animate,transition:{...ke,delay:n}},exit:{opacity:0,x:-e,...t.exit,transition:ge},transition:ke}),au=(e,t,n)=>({initial:{opacity:0,y:e,...t.initial},animate:{opacity:1,y:0,...t.animate,transition:{...ke,delay:n}},exit:{opacity:0,y:-e,...t.exit,transition:ge},transition:ke}),iu=(e,t,n)=>({initial:{opacity:0,y:-e,...t.initial},animate:{opacity:1,y:0,...t.animate,transition:{...ke,delay:n}},exit:{opacity:0,y:e,...t.exit,transition:ge},transition:ke}),cu={right:ou,left:su,up:au,down:iu},oe=u.forwardRef(({fadeIn:e="down",distance:t=ru,children:n,snapExit:o=!1,overrides:s={},delay:a=0,...i},c)=>{const d=e?cu[e](t,s,a):{};return o&&d.exit&&typeof d.exit=="object"&&!Array.isArray(d.exit)&&(d.exit.transition={duration:0}),r.jsx(F.motion.div,{ref:c,...i,...d,children:n})});oe.displayName="MotionDiv";const wr=ia.cva(z("inline-flex shrink-0 items-center justify-center gap-2","text-sm font-medium whitespace-nowrap","ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50","active:scale-[0.97] motion-reduce:active:scale-100","rounded-xl","transition-transform duration-150 ease-[cubic-bezier(0.23,1,0.32,1)]"),{variants:{variant:{default:"bg-primary text-primary-foreground",destructive:"bg-destructive text-destructive-foreground",outline:"bg-background border",secondary:"bg-secondary text-secondary-foreground",ghost:"hover:bg-secondary",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"py-2 px-3.5 text-xs",lg:"min-h-12 px-4 rounded-[20px]",icon:"h-10 w-10",fit:"size-fit p-2",free:"p-2",selfless:"p-0"}},defaultVariants:{variant:"default",size:"default"}}),X=ot.forwardRef(({className:e,variant:t="default",size:n,asChild:o=!1,wobble:s=!0,...a},i)=>{const c=o?Rc.Slot:"button";return r.jsx(Oe,{ref:i,off:!s,children:r.jsx(c,{...L("ui_lib/btn"),"data-variant":t,className:z(wr({variant:t,size:n,className:e})),...a})})});X.displayName="Button";const Za=u.createContext(null);function lu({children:e}){const[t,n]=u.useState(!1),[o,s]=u.useState(null),a=c=>{s(c),n(!0)},i=u.useCallback(()=>{n(!1),setTimeout(()=>{s(null)},200)},[]);return r.jsxs(Za.Provider,{value:{open:a,close:i,isOpen:t,content:o},children:[r.jsx(du,{}),e]})}function On(){const e=u.useContext(Za);return e||(K.log.error("useDialoger must be used within a DialogerProvider"),{open:()=>{},close:()=>{},isOpen:!1,content:null})}function du(){const{contentIframeRef:e}=C.useWidget(),{isOpen:t,content:n,close:o}=On();return u.useEffect(()=>{var i,c;if(!t)return;const s=d=>{d.defaultPrevented||d.key!=="Escape"||(d.preventDefault(),o())},a=(c=(i=e==null?void 0:e.current)==null?void 0:i.contentWindow)==null?void 0:c.document;return a==null||a.addEventListener("keydown",s),()=>a==null?void 0:a.removeEventListener("keydown",s)},[o,e,t]),r.jsx(F.AnimatePresence,{mode:"wait",children:t&&n&&r.jsx(oe,{overrides:{initial:{y:0},exit:{y:0}},className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",tabIndex:-1,onClick:o,children:n},"dialog-content")})}function on({children:e,className:t,withClose:n=!1}){const{close:o}=On(),{t:s}=G();return r.jsxs("div",{"data-opencx-escape-scope":!0,className:z("fixed left-[50%] top-[50%] z-50 flex flex-col gap-4 w-full max-w-[61.8%] translate-x-[-50%] translate-y-[-50%] border bg-background p-4 rounded-3xl",t),onClick:a=>a.stopPropagation(),children:[e,n&&r.jsxs(X,{size:"fit",className:"rounded-full absolute top-4 right-4 opacity-50 hover:opacity-100",onClick:o,children:[r.jsx(M.X,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:s("dialog_close")})]})]})}const Gr=({className:e,...t})=>r.jsx("div",{className:z("flex flex-col gap-2 text-center pt-2",e),...t});Gr.displayName="DialogerHeader";const Kr=({className:e,...t})=>r.jsx("div",{className:z("flex flex-col gap-2 text-center",e),...t});Kr.displayName="DialogerBody";const Ja=({className:e,...t})=>r.jsx("div",{className:z("flex flex-col gap-2",e),...t});Ja.displayName="DialogerFooter";const Zr=u.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:z("text-lg font-semibold leading-none tracking-tight",e),...t}));Zr.displayName="DialogerTitle";const Jr=u.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:z("text-sm text-muted-foreground",e),...t}));Jr.displayName="DialogerDescription";function sn({children:e,trigger:t}){const{open:n}=On();return u.cloneElement(t,{onClick:()=>{var s,a;n(e),(a=(s=t.props).onClick)==null||a.call(s)}})}const os=1,ss=5,as=.5,uu=2.5;function pu(e,t,n,o){if(!n||!o||t<=1)return{x:0,y:0};const s=n.getBoundingClientRect(),a=o.offsetWidth,i=o.offsetHeight,c=Math.max(0,(a*t-s.width)/(2*t)),d=Math.max(0,(i*t-s.height)/(2*t));return{x:Math.min(c,Math.max(-c,e.x)),y:Math.min(d,Math.max(-d,e.y))}}function Qa({src:e,alt:t}){const{t:n}=G(),[o,s]=u.useState(1),[a,i]=u.useState({x:0,y:0}),[c,d]=u.useState(!1),l=u.useRef({x:0,y:0}),m=u.useRef({x:0,y:0}),p=u.useRef(null),h=u.useRef(null),f=u.useRef(!1),x=k=>Math.min(ss,Math.max(os,k)),g=u.useCallback(()=>{s(1),i({x:0,y:0})},[]),y=u.useCallback(()=>{s(k=>x(k+as))},[]),w=u.useCallback(()=>{s(k=>{const N=x(k-as);return N<=1&&i({x:0,y:0}),N})},[]),j=u.useCallback(k=>{k.preventDefault(),f.current=!1,d(!0),l.current={x:k.clientX,y:k.clientY},m.current={...a},k.target.setPointerCapture(k.pointerId)},[a]),b=u.useCallback(k=>{if(!c)return;const N=k.clientX-l.current.x,R=k.clientY-l.current.y;if((Math.abs(N)>3||Math.abs(R)>3)&&(f.current=!0),o<=1)return;const T={x:m.current.x+N/o,y:m.current.y+R/o};i(pu(T,o,p.current,h.current))},[c,o]),_=u.useCallback(()=>{const k=f.current;d(!1),!k&&s(N=>N>1?(i({x:0,y:0}),1):uu)},[]),v=o>1;return r.jsxs("div",{className:"relative size-full flex items-center justify-center select-none",onClick:k=>k.stopPropagation(),children:[r.jsx("div",{ref:p,className:z("overflow-hidden max-h-full max-w-full rounded-2xl flex items-center justify-center",v&&"size-full"),onPointerDown:j,onPointerMove:b,onPointerUp:_,onPointerCancel:_,style:{cursor:c?"grabbing":v?"grab":"zoom-in",touchAction:"none"},children:r.jsx("img",{ref:h,src:e,alt:t,className:"block max-w-full object-contain pointer-events-none",draggable:!1,style:{maxHeight:"100vh",transform:`scale(${o}) translate(${a.x}px, ${a.y}px)`,transformOrigin:"center center"}})}),r.jsxs("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1 bg-black/60 backdrop-blur-sm rounded-full px-1.5 py-1 transition opacity-50 hover:opacity-100",children:[r.jsx(Jn,{onClick:w,label:n("zoom_out"),disabled:o<=os,children:r.jsx(M.ZoomOut,{className:"size-3.5"})}),r.jsxs("span",{className:"text-white text-xs font-medium min-w-[3ch] text-center tabular-nums",children:[Math.round(o*100),"%"]}),r.jsx(Jn,{onClick:y,label:n("zoom_in"),disabled:o>=ss,children:r.jsx(M.ZoomIn,{className:"size-3.5"})}),v&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-px h-4 bg-white/30 mx-0.5"}),r.jsx(Jn,{onClick:g,label:n("reset_zoom"),children:r.jsx(M.RotateCcw,{className:"size-3.5"})})]})]})]})}function Jn({onClick:e,label:t,children:n,disabled:o}){return r.jsx("button",{onClick:e,"aria-label":t,disabled:o,className:"text-white/80 hover:text-white disabled:text-white/30 disabled:hover:bg-transparent p-1.5 rounded-full hover:bg-white/15 transition-colors",children:n})}function is({url:e,name:t,size:n,icon:o,label:s}){return r.jsx(Oe,{children:r.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:z("block size-fit max-w-[min(100%,16rem)] shrink-0 rounded-2xl border","bg-background/80 transition-colors hover:bg-accent/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),children:r.jsxs("div",{className:"flex items-center gap-3 p-3 min-w-0",children:[r.jsx("div",{className:z("flex size-10 shrink-0 items-center justify-center rounded-xl","bg-secondary text-muted-foreground"),"aria-hidden":!0,children:o}),r.jsxs("div",{className:"min-w-0 flex-1 flex flex-col gap-0.5 text-left",children:[r.jsx("span",{className:z("text-xs font-medium text-foreground line-clamp-1","break-words [word-break:break-word]"),children:t}),r.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[(n/1024).toFixed(2)," KB · ",s]})]})]})})})}function ei({attachment:e}){const{name:t,size:n,type:o,url:s}=e,a=o.startsWith("image/"),i=o.startsWith("video/"),c=o.startsWith("audio/"),d=o==="application/pdf";if(c)return r.jsx(Oe,{children:r.jsx("div",{className:"w-full shrink-0 overflow-hidden",children:r.jsxs("audio",{controls:!0,className:"w-full",children:[r.jsx("source",{src:s,type:o}),"Your browser does not support the audio tag."]})})});if(i)return r.jsx(Oe,{children:r.jsx("div",{className:"w-full border shrink-0 rounded-2xl overflow-hidden",children:r.jsxs("video",{controls:!0,children:[r.jsx("source",{src:s,type:o}),"Your browser does not support the video tag."]})})});if(a)return r.jsx(sn,{trigger:r.jsx("div",{children:r.jsx(Oe,{children:r.jsx("div",{className:"size-fit border shrink-0 rounded-2xl overflow-hidden",children:r.jsx("img",{src:s,className:"object-cover size-16",alt:t})})})}),children:r.jsx(on,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx(Qa,{src:s,alt:t})})});if(d)return r.jsx(is,{url:s,name:t,size:n,icon:r.jsx(M.FileText,{className:"size-5",strokeWidth:1.75}),label:"PDF"});const l=Ka({type:o,name:t});return l?r.jsx(is,{url:s,name:t,size:n,icon:r.jsx(M.FileSpreadsheet,{className:"size-5",strokeWidth:1.75}),label:l.label}):r.jsx(Oe,{children:r.jsx("div",{className:"size-fit border shrink-0 rounded-2xl overflow-hidden",children:r.jsxs("div",{className:"flex items-end gap-2 p-2",children:[r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:z("text-xs text-blue-500 line-clamp-2 underline hover:text-blue-600","break-words [word-break:break-word]"),children:t}),r.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[(n/1024).toFixed(2)," KB"]})]})})})}function mu({replyTo:e}){const t=C.useBot(),{humanAgent:n}=C.useConfig(),{sender:o}=e,s=o.kind==="user"?"You":o.kind==="ai"?t.name:o.kind==="agent"?(n==null?void 0:n.name)||o.name||"Team":o.name;return r.jsxs("button",{...L("chat/agent_msg/reply_to"),type:"button",onClick:a=>{const i=a.currentTarget.ownerDocument.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`);i==null||i.scrollIntoView({behavior:"smooth",block:"center"}),i==null||i.animate([{opacity:.35},{opacity:1}],{duration:900,easing:"ease-out"})},className:z("not-prose mb-2 block w-full min-w-0 text-start","rounded-xl border-s-2 border-primary/50 bg-primary/[0.07] ps-2.5 pe-2 py-1.5","text-xs leading-snug text-muted-foreground","transition-colors hover:bg-primary/10 hover:text-foreground"),children:[s&&r.jsx("span",{className:"block font-medium text-foreground/80",children:s}),r.jsx("span",{className:"line-clamp-2 break-words",children:e.text})]})}const ti=u.memo(Pc,(e,t)=>e.children===t.children&&e.className===t.className);var ea,ta,na;const hu={...ye.defaultSchema,attributes:{...ye.defaultSchema.attributes,"*":[...((ea=ye.defaultSchema.attributes)==null?void 0:ea["*"])??[],"style"],code:[...((ta=ye.defaultSchema.attributes)==null?void 0:ta.code)??[],"className"],pre:[...((na=ye.defaultSchema.attributes)==null?void 0:na.pre)??[],"className"]}},fu=/^(color|background-color|font-(family|size|style|weight)|text-(align|decoration|transform)|line-height|letter-spacing|white-space|display|width|height|max-width|min-width|margin(-top|-right|-bottom|-left)?|padding(-top|-right|-bottom|-left)?|border(-width|-style|-color|-radius)?)$/i,gu=/^[\w\s#.,%()'"+-]+$/,xu=/\b(url|expression|var|attr)\s*\(/i;function bu(){return function e(t){var o,s;const n=(o=t.properties)==null?void 0:o.style;typeof n=="string"&&t.properties&&(t.properties.style=n.split(";").filter(a=>{const i=a.indexOf(":");if(i<0)return!1;const c=a.slice(0,i).trim(),d=a.slice(i+1).trim();return fu.test(c)&&gu.test(d)&&!xu.test(d)}).join(";")),(s=t.children)==null||s.forEach(e)}}function ni(e){return e.replace(/<citations>[\s\S]*?<\/citations>/g,"").replace(/<citations[\s\S]*$/,"").replace(/<(?:ref|cite)\s[^>]*?\/?>/g,"").replace(/<r(?:e(?:f[^>]*)?)?$/,"").replace(/<c(?:i(?:t(?:a(?:t(?:i(?:o(?:n(?:s)?)?)?)?)?)?(?:e[^>]*)?)?)?$/,"").trimEnd()}const wu=/^[\w-]{11}$/,vu=new Set(["youtube.com","www.youtube.com","m.youtube.com","youtube-nocookie.com","www.youtube-nocookie.com"]);function yu(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"&&t.protocol!=="http:")return null;const n=ku(t);return n&&wu.test(n)?n:null}function ku(e){const[t,n]=e.pathname.split("/").filter(Boolean);return e.hostname==="youtu.be"?t:vu.has(e.hostname)?t==="watch"?e.searchParams.get("v"):t==="shorts"||t==="embed"?n:null:null}function ju({id:e,title:t}){return r.jsx(sn,{trigger:r.jsxs("button",{type:"button",className:"not-prose relative block w-full max-w-64 overflow-hidden rounded-xl border",children:[r.jsx("img",{src:`https://i.ytimg.com/vi/${e}/hqdefault.jpg`,alt:t,className:"aspect-video w-full object-cover"}),r.jsx("span",{className:"absolute inset-0 flex items-center justify-center",children:r.jsx("span",{className:"flex size-10 items-center justify-center rounded-full bg-black/60 text-white",children:r.jsx(M.Play,{className:"size-5 fill-current"})})})]}),children:r.jsx(on,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${e}?autoplay=1`,title:t,allow:"autoplay; encrypted-media; picture-in-picture; fullscreen",allowFullScreen:!0,className:"aspect-video w-full rounded-2xl"})})})}const Cu=new Map([["youtube",/^[\w-]{11}$/],["vimeo",/^\d+(?:\/[\da-f]+)?$/],["loom",/^[\da-f]{32}$/],["wistia",/^[\da-z]{10}$/]]),Su=new Map([["youtube","YouTube video"],["vimeo","Vimeo video"],["loom","Loom video"],["wistia","Wistia video"]]);function Nu(e,t){var o;if(typeof e!="string"||typeof t!="string"||!((o=Cu.get(e))!=null&&o.test(t)))return;const n=Su.get(e)??"Video";switch(e){case"youtube":return{src:`https://www.youtube-nocookie.com/embed/${t}`,title:n};case"vimeo":{const[s,a]=t.split("/");return{src:`https://player.vimeo.com/video/${s}${a?`?h=${a}`:""}`,title:n}}case"loom":return{src:`https://www.loom.com/embed/${t}`,title:n};case"wistia":return{src:`https://fast.wistia.net/embed/iframe/${t}`,title:n};default:return}}var ra,oa;const vr={...ye.defaultSchema,attributes:{...ye.defaultSchema.attributes,code:[...((ra=ye.defaultSchema.attributes)==null?void 0:ra.code)??[],"className"],pre:[...((oa=ye.defaultSchema.attributes)==null?void 0:oa.pre)??[],"className"]}};var sa,aa;const _u={...vr,attributes:{...vr.attributes,div:[...((sa=ye.defaultSchema.attributes)==null?void 0:sa.div)??[],"dataEmbed","dataEmbedId"],a:[...((aa=ye.defaultSchema.attributes)==null?void 0:aa.a)??[],"dataArticleSlug"]}};function Qr(e){return r.jsx(eo,{...e})}function Eu({openArticle:e,...t}){return r.jsx(eo,{...t,articleEmbeds:!0,openArticle:e})}function Au(e){return r.jsx(eo,{...e,configuredStyles:!0})}function eo({children:e,messageType:t,messageId:n,configuredStyles:o=!1,articleEmbeds:s=!1,openArticle:a}){const{anchorTarget:i}=C.useConfig();return r.jsx(ti,{"data-type":t,"data-id":n,remarkPlugins:[ca],rehypePlugins:o?[ur,bu,[ye,hu]]:[ur,[ye,s?_u:vr]],components:{div:({node:c,...d})=>{const l=s?Nu(c==null?void 0:c.properties.dataEmbed,c==null?void 0:c.properties.dataEmbedId):void 0;return l?r.jsx("iframe",{src:l.src,title:l.title,loading:"lazy",allow:"encrypted-media; picture-in-picture; fullscreen",allowFullScreen:!0,className:"not-prose my-4 aspect-video w-full rounded-xl border"}):r.jsx("div",{...d})},a:({node:c,children:d,...l})=>{const{href:m}=l,p=s?c==null?void 0:c.properties.dataArticleSlug:void 0;if(typeof p=="string")return a?r.jsx("a",{href:"#",onClick:f=>{f.preventDefault(),a(p)},children:d}):r.jsx(r.Fragment,{children:d});const h=m?yu(m):null;return m&&h?r.jsx(ju,{id:h,title:typeof d=="string"?d:m}):r.jsx("a",{target:l.target||i||"_top",...l,children:d})},img:({src:c,alt:d,...l})=>c?r.jsx(sn,{trigger:r.jsx("img",{src:c,alt:d,...l,className:"cursor-pointer rounded-xl"}),children:r.jsx(on,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx(Qa,{src:c,alt:d})})}):r.jsx("img",{src:c,alt:d,...l})},children:ni(e)})}function qe(){const{widgetCtx:{org:e}}=C.useWidget(),{sessionState:{session:t}}=C.useSessions(),n=C.useConfig(),{messagesState:{messages:o}}=C.useMessages(),{routerState:{screen:s}}=C.useWidgetRouter();return{react:u,org:e,session:t,config:n,messages:o,currentScreen:s}}function Tu({currentMessage:e}){var o;const t=qe(),n=(o=t.config.customComponents)==null?void 0:o["message::after"];return n?r.jsx(n,{...t,currentMessage:e}):null}const ri=u.createContext(null);function Iu({children:e}){const{widgetCtx:t,config:n}=C.useWidget(),o=u.useRef({widgetCtx:t,config:n});u.useLayoutEffect(()=>{o.current={widgetCtx:t,config:n}},[t,n]);const s=u.useRef({kind:"main"}),a=u.useMemo(()=>({report:i=>{var x;const{widgetCtx:c,config:d}=o.current,l=(x=d.hooks)==null?void 0:x.onUserActivity;if(!l)return;const{screen:m}=c.routerCtx.state.get(),p=m==="home"?{screen:m,view:s.current}:{screen:m},{session:h}=c.sessionCtx.sessionState.get(),f=h?{...i,session:h,page:p}:{...i,page:p};try{l(f)}catch(g){K.log.error("onUserActivity hook failed",g)}},setHomeView:i=>{s.current=i}}),[]);return r.jsx(ri.Provider,{value:a,children:e})}function to(){return u.useContext(ri)}function no(e){var n;const t=(n=to())==null?void 0:n.setHomeView;u.useLayoutEffect(()=>{t==null||t(e)},[t,e])}function an(){var n;const{sendMessage:e}=C.useMessages(),t=(n=to())==null?void 0:n.report;return u.useCallback(o=>e(t?{...o,onSubmitted:s=>{var a;(a=o.onSubmitted)==null||a.call(o,s),t({type:"message-sent",message:s})}}:o),[e,t])}function zu({messageId:e,messageOptions:t}){var d;const{messagesState:n}=C.useMessages(),o=an(),{sessionState:s}=C.useSessions(),{pickedOptionId:a}=t,i=((d=K.tappableOptionsMessage(n.messages,s.session))==null?void 0:d.id)===e,c=t.options.find(l=>l.id===a);return c?r.jsx("div",{...L("chat/agent_msg/options"),className:"flex",children:r.jsxs(X,{...L("chat/agent_msg/option_btn"),"data-picked":!0,"aria-pressed":!0,size:"sm",variant:"outline",className:"w-fit pl-2 text-sm text-muted-foreground disabled:opacity-100",disabled:!0,children:[r.jsx(M.CheckIcon,{"aria-hidden":"true",className:"size-3.5 shrink-0"}),c.label]})}):i?r.jsx("div",{...L("chat/agent_msg/options"),role:"group",className:"flex flex-row flex-wrap gap-1.5 [@media(pointer:coarse)]:gap-y-3",children:t.options.map(l=>r.jsxs(X,{...L("chat/agent_msg/option_btn"),size:"sm",variant:"outline",className:"relative w-fit text-sm hover:bg-secondary",onClick:()=>o({content:l.label,optionReply:{messageId:e,optionId:l.id}}),children:[r.jsx("span",{"aria-hidden":"true",className:"absolute top-1/2 left-1/2 size-[max(100%,3rem)] -translate-x-1/2 -translate-y-1/2 [@media(pointer:fine)]:hidden"}),l.label]},l.id))}):null}const Mu=["[--tw-prose-body:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-headings:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-lead:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-bold:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-links:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-code:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-counters:hsl(var(--opencx-muted-foreground))]","[--tw-prose-bullets:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quotes:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quote-borders:hsl(var(--opencx-border))]","[--tw-prose-hr:hsl(var(--opencx-border))]","[--tw-prose-th-borders:hsl(var(--opencx-border))]","[--tw-prose-td-borders:hsl(var(--opencx-border))]","[--tw-prose-pre-bg:hsl(var(--opencx-muted))]","[--tw-prose-pre-code:hsl(var(--opencx-foreground))]"].join(" ");function yr(e){const{data:t,id:n,type:o,attachments:s,isFirstInGroup:a,isLastInGroup:i,isAloneInGroup:c,dataComponentNames:d,classNames:l}=e,m=o==="AI"||o==="AGENT"?t.message:"",p=u.useMemo(()=>o==="AI"?Ga(m):null,[o,m]);if(o!=="AI"&&o!=="AGENT")return null;const{variant:h="default"}=t,f=e.replyTo?r.jsx(mu,{replyTo:e.replyTo}):null,x=(j,b,_=!0,v=!0)=>r.jsxs("div",{className:"flex flex-row gap-2",children:[r.jsxs("div",{...L((d==null?void 0:d.message)??"chat/agent_msg/msg"),"data-first":a,"data-last":i,"data-alone":c,"data-variant":h,className:z("transition-all","w-fit py-3 px-4 rounded-3xl bg-secondary text-secondary-foreground","leading-snug text-sm prose prose-sm prose-a:decoration-primary prose-a:underline",Mu,"break-words [word-break:break-word]",h==="error"&&"bg-destructive/15 text-destructive",a&&!c&&"rounded-bl-md",i&&!c&&"rounded-tl-md",!a&&!i&&!c&&"rounded-l-md",l==null?void 0:l.message),children:[v&&f,r.jsx(Qr,{messageType:o,messageId:n,children:j})]}),_&&r.jsx(Tu,{currentMessage:e})]},b),g=(p==null?void 0:p.some(j=>j.type==="ui"))??!1,y=(p==null?void 0:p.reduce((j,b,_)=>b.type==="markdown"?_:j,-1))??-1,w=(p==null?void 0:p.findIndex(j=>j.type==="markdown"))??-1;return r.jsxs("div",{...L((d==null?void 0:d.messageContainer)??"chat/agent_msg/root"),"data-message-id":n,className:z("w-5/6 flex flex-col items-start gap-1",l==null?void 0:l.messageContainer),children:[s&&s.length>0&&r.jsx("div",{className:"w-full gap-1 flex flex-row flex-wrap items-center justify-start",children:s==null?void 0:s.map(j=>r.jsx(ei,{attachment:j},j.id))}),g&&p?p.map((j,b)=>j.type==="markdown"?x(j.content,`md-${b}`,b===y,b===w):r.jsx("div",{className:"w-full",children:r.jsx(Ya,{spec:j.spec})},`ui-${b}`)):m.length>0&&x(m),e.messageOptions&&r.jsx(zu,{messageId:n,messageOptions:e.messageOptions})]})}function Ru(e){return r.jsx("div",{className:"w-full max-w-full overflow-auto shrink-0",children:r.jsx("pre",{className:"text-xs leading-tight whitespace-pre-wrap break-word",children:JSON.stringify(e,null,1)})})}const ro=ot.forwardRef(({className:e,...t},n)=>r.jsx(Rt.Root,{ref:n,className:z("relative flex size-6 aspect-square shrink-0 overflow-hidden rounded-full bg-secondary",e),...t}));ro.displayName=Rt.Root.displayName;const oo=ot.forwardRef(({className:e,...t},n)=>r.jsx(Rt.Image,{ref:n,className:z("aspect-square h-full w-full",e),...t}));oo.displayName=Rt.Image.displayName;const so=ot.forwardRef(({className:e,...t},n)=>r.jsx(Rt.Fallback,{ref:n,className:z("flex size-full text-xs items-center justify-center rounded-lg",e),...t}));so.displayName=Rt.Fallback.displayName;function kr({agent:e,...t}){var n,o;return r.jsxs(ro,{...t,children:[r.jsx(oo,{src:(e==null?void 0:e.avatarUrl)||(e==null?void 0:e.avatar)||"",alt:"Agent Icon"}),(e==null?void 0:e.name)&&r.jsx(so,{children:(o=(n=e==null?void 0:e.name)==null?void 0:n.slice(0,1))==null?void 0:o.toUpperCase()})]})}function Pu({agent:e}){return r.jsx(F.AnimatePresence,{children:r.jsxs(oe,{...L("chat/bot_loading/root"),className:"flex flex-row items-end w-full gap-2 animate-pulse",children:[r.jsx(kr,{agent:e}),r.jsxs("div",{...L("chat/bot_loading/bouncing_dots_container"),className:z("flex items-center [&_span]:bg-secondary-foreground [&_span]:size-1 gap-1 p-2 rounded-xl bg-secondary"),children:[r.jsx(F.motion.span,{className:"rounded-full animate-bounce [animation-delay:-0.3s]"}),r.jsx(F.motion.span,{className:"rounded-full animate-bounce [animation-delay:-0.15s]"}),r.jsx(F.motion.span,{className:"rounded-full animate-bounce"})]})]})})}const Ou='*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}*{-ms-overflow-style:none;scrollbar-width:none}*::-webkit-scrollbar{display:none}*{border-color:hsl(var(--opencx-border))}.\\!container{width:100%!important}.container{width:100%}@media(min-width:640px){.\\!container{max-width:640px!important}.container{max-width:640px}}@media(min-width:768px){.\\!container{max-width:768px!important}.container{max-width:768px}}@media(min-width:1024px){.\\!container{max-width:1024px!important}.container{max-width:1024px}}@media(min-width:1280px){.\\!container{max-width:1280px!important}.container{max-width:1280px}}@media(min-width:1536px){.\\!container{max-width:1536px!important}.container{max-width:1536px}}.prose{color:var(--tw-prose-body);max-width:65ch}.prose :where(p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where([class~=lead]):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-lead);font-size:1.25em;line-height:1.6;margin-top:1.2em;margin-bottom:1.2em}.prose :where(a):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-links);text-decoration:underline;font-weight:500}.prose :where(strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-bold);font-weight:600}.prose :where(a strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(blockquote strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(thead th strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(ol):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:decimal;margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em}.prose :where(ol[type=A]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=A s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=I]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type=I s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type="1"]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:decimal}.prose :where(ul):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:disc;margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{font-weight:400;color:var(--tw-prose-counters)}.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{color:var(--tw-prose-bullets)}.prose :where(dt):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;margin-top:1.25em}.prose :where(hr):not(:where([class~=not-prose],[class~=not-prose] *)){border-color:var(--tw-prose-hr);border-top-width:1px;margin-top:3em;margin-bottom:3em}.prose :where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:500;font-style:italic;color:var(--tw-prose-quotes);border-inline-start-width:.25rem;border-inline-start-color:var(--tw-prose-quote-borders);quotes:"“""”""‘""’";margin-top:1.6em;margin-bottom:1.6em;padding-inline-start:1em}.prose :where(blockquote p:first-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:open-quote}.prose :where(blockquote p:last-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:close-quote}.prose :where(h1):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:800;font-size:2.25em;margin-top:0;margin-bottom:.8888889em;line-height:1.1111111}.prose :where(h1 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:900;color:inherit}.prose :where(h2):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:700;font-size:1.5em;margin-top:2em;margin-bottom:1em;line-height:1.3333333}.prose :where(h2 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:800;color:inherit}.prose :where(h3):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;font-size:1.25em;margin-top:1.6em;margin-bottom:.6em;line-height:1.6}.prose :where(h3 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:700;color:inherit}.prose :where(h4):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;margin-top:1.5em;margin-bottom:.5em;line-height:1.5}.prose :where(h4 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:700;color:inherit}.prose :where(img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(picture):not(:where([class~=not-prose],[class~=not-prose] *)){display:block;margin-top:2em;margin-bottom:2em}.prose :where(video):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(kbd):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:500;font-family:inherit;color:var(--tw-prose-kbd);box-shadow:0 0 0 1px rgb(var(--tw-prose-kbd-shadows) / 10%),0 3px rgb(var(--tw-prose-kbd-shadows) / 10%);font-size:.875em;border-radius:.3125rem;padding-top:.1875em;padding-inline-end:.375em;padding-bottom:.1875em;padding-inline-start:.375em}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-code);font-weight:600;font-size:.875em}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:"`"}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:"`"}.prose :where(a code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(h1 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(h2 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.875em}.prose :where(h3 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.9em}.prose :where(h4 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(blockquote code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(thead th code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(pre):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-pre-code);background-color:var(--tw-prose-pre-bg);overflow-x:auto;font-weight:400;font-size:.875em;line-height:1.7142857;margin-top:1.7142857em;margin-bottom:1.7142857em;border-radius:.375rem;padding-top:.8571429em;padding-inline-end:1.1428571em;padding-bottom:.8571429em;padding-inline-start:1.1428571em}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)){background-color:transparent;border-width:0;border-radius:0;padding:0;font-weight:inherit;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:none}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:none}.prose :where(table):not(:where([class~=not-prose],[class~=not-prose] *)){width:100%;table-layout:auto;margin-top:2em;margin-bottom:2em;font-size:.875em;line-height:1.7142857}.prose :where(thead):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-th-borders)}.prose :where(thead th):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;vertical-align:bottom;padding-inline-end:.5714286em;padding-bottom:.5714286em;padding-inline-start:.5714286em}.prose :where(tbody tr):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-td-borders)}.prose :where(tbody tr:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:0}.prose :where(tbody td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:baseline}.prose :where(tfoot):not(:where([class~=not-prose],[class~=not-prose] *)){border-top-width:1px;border-top-color:var(--tw-prose-th-borders)}.prose :where(tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:top}.prose :where(th,td):not(:where([class~=not-prose],[class~=not-prose] *)){text-align:start}.prose :where(figure>*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(figcaption):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-captions);font-size:.875em;line-height:1.4285714;margin-top:.8571429em}.prose{--tw-prose-body: #374151;--tw-prose-headings: #111827;--tw-prose-lead: #4b5563;--tw-prose-links: #111827;--tw-prose-bold: #111827;--tw-prose-counters: #6b7280;--tw-prose-bullets: #d1d5db;--tw-prose-hr: #e5e7eb;--tw-prose-quotes: #111827;--tw-prose-quote-borders: #e5e7eb;--tw-prose-captions: #6b7280;--tw-prose-kbd: #111827;--tw-prose-kbd-shadows: 17 24 39;--tw-prose-code: #111827;--tw-prose-pre-code: #e5e7eb;--tw-prose-pre-bg: #1f2937;--tw-prose-th-borders: #d1d5db;--tw-prose-td-borders: #e5e7eb;--tw-prose-invert-body: #d1d5db;--tw-prose-invert-headings: #fff;--tw-prose-invert-lead: #9ca3af;--tw-prose-invert-links: #fff;--tw-prose-invert-bold: #fff;--tw-prose-invert-counters: #9ca3af;--tw-prose-invert-bullets: #4b5563;--tw-prose-invert-hr: #374151;--tw-prose-invert-quotes: #f3f4f6;--tw-prose-invert-quote-borders: #374151;--tw-prose-invert-captions: #9ca3af;--tw-prose-invert-kbd: #fff;--tw-prose-invert-kbd-shadows: 255 255 255;--tw-prose-invert-code: #fff;--tw-prose-invert-pre-code: #d1d5db;--tw-prose-invert-pre-bg: rgb(0 0 0 / 50%);--tw-prose-invert-th-borders: #4b5563;--tw-prose-invert-td-borders: #374151;font-size:1rem;line-height:1.75}.prose :where(picture>img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(li):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;margin-bottom:.5em}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.375em}.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.375em}.prose :where(.prose>ul>li p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(.prose>ul>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ul>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(.prose>ol>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ol>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(dl):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where(dd):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;padding-inline-start:1.625em}.prose :where(hr+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(h2+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(h3+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(h4+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(thead th:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(thead th:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(tbody td,tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){padding-top:.5714286em;padding-inline-end:.5714286em;padding-bottom:.5714286em;padding-inline-start:.5714286em}.prose :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(figure):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(.prose>:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(.prose>:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:0}.prose-sm{font-size:.875rem;line-height:1.7142857}.prose-sm :where(p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em}.prose-sm :where([class~=lead]):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:1.2857143em;line-height:1.5555556;margin-top:.8888889em;margin-bottom:.8888889em}.prose-sm :where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.3333333em;margin-bottom:1.3333333em;padding-inline-start:1.1111111em}.prose-sm :where(h1):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:2.1428571em;margin-top:0;margin-bottom:.8em;line-height:1.2}.prose-sm :where(h2):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:1.4285714em;margin-top:1.6em;margin-bottom:.8em;line-height:1.4}.prose-sm :where(h3):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:1.2857143em;margin-top:1.5555556em;margin-bottom:.4444444em;line-height:1.5555556}.prose-sm :where(h4):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.4285714em;margin-bottom:.5714286em;line-height:1.4285714}.prose-sm :where(img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(picture):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(picture>img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose-sm :where(video):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(kbd):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;border-radius:.3125rem;padding-top:.1428571em;padding-inline-end:.3571429em;padding-bottom:.1428571em;padding-inline-start:.3571429em}.prose-sm :where(code):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em}.prose-sm :where(h2 code):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.9em}.prose-sm :where(h3 code):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8888889em}.prose-sm :where(pre):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;line-height:1.6666667;margin-top:1.6666667em;margin-bottom:1.6666667em;border-radius:.25rem;padding-top:.6666667em;padding-inline-end:1em;padding-bottom:.6666667em;padding-inline-start:1em}.prose-sm :where(ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em;padding-inline-start:1.5714286em}.prose-sm :where(ul):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em;padding-inline-start:1.5714286em}.prose-sm :where(li):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.2857143em;margin-bottom:.2857143em}.prose-sm :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.4285714em}.prose-sm :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.4285714em}.prose-sm :where(.prose-sm>ul>li p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5714286em;margin-bottom:.5714286em}.prose-sm :where(.prose-sm>ul>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em}.prose-sm :where(.prose-sm>ul>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.1428571em}.prose-sm :where(.prose-sm>ol>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em}.prose-sm :where(.prose-sm>ol>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.1428571em}.prose-sm :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5714286em;margin-bottom:.5714286em}.prose-sm :where(dl):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em}.prose-sm :where(dt):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em}.prose-sm :where(dd):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.2857143em;padding-inline-start:1.5714286em}.prose-sm :where(hr):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2.8571429em;margin-bottom:2.8571429em}.prose-sm :where(hr+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(h2+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(h3+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(h4+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(table):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;line-height:1.5}.prose-sm :where(thead th):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:1em;padding-bottom:.6666667em;padding-inline-start:1em}.prose-sm :where(thead th:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose-sm :where(thead th:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose-sm :where(tbody td,tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){padding-top:.6666667em;padding-inline-end:1em;padding-bottom:.6666667em;padding-inline-start:1em}.prose-sm :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose-sm :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose-sm :where(figure):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(figure>*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose-sm :where(figcaption):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;line-height:1.3333333;margin-top:.6666667em}.prose-sm :where(.prose-sm>:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(.prose-sm>:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:0}.opencx-text-shimmer{animation:opencx-text-shimmer 2.5s ease-in-out infinite}.opencx-fade-up{animation:opencx-fade-up .3s cubic-bezier(.23,1,.32,1) both}.opencx-voice-shimmer{background-image:linear-gradient(100deg,currentColor 0%,currentColor 38%,hsl(var(--opencx-primary)) 50%,currentColor 62%,currentColor 100%);background-size:250% 100%;-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;animation:opencx-voice-shimmer 1.8s linear infinite}.opencx-voice-skeleton{background-color:hsl(var(--opencx-secondary));background-image:linear-gradient(100deg,transparent 30%,hsl(var(--opencx-background) / .7) 50%,transparent 70%);background-size:250% 100%;animation:opencx-voice-shimmer 1.6s linear infinite}[data-component="chat/voice_call/root"] [data-component="chat/user_msg/msg"],[data-component="chat/voice_call/root"] [data-component="chat/agent_msg/msg"] :is(p,li){unicode-bidi:plaintext}.opencx-voice-transcript-mask{mask-image:linear-gradient(to bottom,transparent 0,#000 3rem);-webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 3rem)}[data-component="trigger/unread"],[data-component="sessions/unread"],[data-component="home/tab_unread"]{pointer-events:none;border-radius:9999px;background-color:hsl(var(--opencx-destructive));text-align:center;font-weight:600;--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction);color:hsl(var(--opencx-destructive-foreground));font-size:11px;line-height:18px;box-shadow:0 0 0 2px hsl(var(--opencx-background))}[data-component="trigger/unread"]{position:absolute;z-index:1}[data-component="sessions/unread"]{flex-shrink:0;box-shadow:none}[data-component="home/tab_unread"]{position:absolute;top:-2px;inset-inline-end:-2px}[data-unread-look=dot]{width:9px;height:9px}[data-unread-look=count]{min-width:16px;height:16px;padding:0 4px;font-size:10px;line-height:16px}.opencx-placeholder-in{animation:opencx-placeholder-in .2s cubic-bezier(.23,1,.32,1) both}.opencx-placeholder-out{animation:opencx-placeholder-out .18s cubic-bezier(.23,1,.32,1) both}@keyframes opencx-text-shimmer{0%,to{opacity:.45}50%{opacity:1}}@keyframes opencx-voice-shimmer{0%{background-position:100% 0}to{background-position:0% 0}}@keyframes opencx-fade-up{0%{opacity:0;filter:blur(4px);transform:translateY(8px)}to{opacity:1;filter:blur(0px);transform:translateY(0)}}@keyframes opencx-placeholder-in{0%{opacity:0;transform:translateY(4px);filter:blur(1px)}to{opacity:1;transform:translateY(0);filter:blur(0)}}@keyframes opencx-placeholder-out{0%{opacity:1;transform:translateY(0);filter:blur(0)}to{opacity:0;transform:translateY(-8px);filter:blur(1px)}}.opencx-input-recall{animation:opencx-input-recall .15s cubic-bezier(.23,1,.32,1)}@keyframes opencx-input-recall{0%{opacity:.25;translate:0 -3px}to{opacity:1;translate:0 0}}@media(prefers-reduced-motion:reduce){.opencx-text-shimmer,.opencx-fade-up,.opencx-placeholder-in,.opencx-placeholder-out,.opencx-input-recall,.opencx-voice-skeleton{animation:none}.opencx-voice-shimmer{animation:none;background-image:none;-webkit-text-fill-color:currentColor;opacity:.7}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.\\!visible{visibility:visible!important}.visible{visibility:visible}.invisible{visibility:hidden}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.\\!sticky{position:sticky!important}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-0\\.5{top:.125rem;right:.125rem;bottom:.125rem;left:.125rem}.inset-x-0{left:0;right:0}.bottom-0{bottom:0}.bottom-3{bottom:.75rem}.end-1{inset-inline-end:.25rem}.end-4{inset-inline-end:1rem}.end-6{inset-inline-end:1.5rem}.left-1\\/2,.left-\\[50\\%\\]{left:50%}.right-4{right:1rem}.start-10{inset-inline-start:2.5rem}.start-2{inset-inline-start:.5rem}.start-4{inset-inline-start:1rem}.top-1{top:.25rem}.top-1\\/2{top:50%}.top-2{top:.5rem}.top-3{top:.75rem}.top-4{top:1rem}.top-6{top:1.5rem}.top-\\[50\\%\\]{top:50%}.top-full{top:100%}.isolate{isolation:isolate}.-z-10{z-index:-10}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.z-\\[60\\]{z-index:60}.order-1{order:1}.order-2{order:2}.col-span-full{grid-column:1 / -1}.m-2{margin:.5rem}.-mx-0\\.5{margin-left:-.125rem;margin-right:-.125rem}.-mx-2{margin-left:-.5rem;margin-right:-.5rem}.mx-0\\.5{margin-left:.125rem;margin-right:.125rem}.mx-3{margin-left:.75rem;margin-right:.75rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-top:.25rem;margin-bottom:.25rem}.my-4{margin-top:1rem;margin-bottom:1rem}.-mt-0\\.5{margin-top:-.125rem}.-mt-6{margin-top:-1.5rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.ml-auto{margin-left:auto}.ms-1\\.5{margin-inline-start:.375rem}.ms-\\[30px\\]{margin-inline-start:30px}.ms-auto{margin-inline-start:auto}.mt-0\\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-12{margin-top:3rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-auto{margin-top:auto}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.line-clamp-3{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.inline-grid{display:inline-grid}.contents{display:contents}.hidden{display:none}.aspect-square{aspect-ratio:1 / 1}.aspect-video{aspect-ratio:16 / 9}.size-0{width:0px;height:0px}.size-1\\.5{width:.375rem;height:.375rem}.size-10{width:2.5rem;height:2.5rem}.size-12{width:3rem;height:3rem}.size-14{width:3.5rem;height:3.5rem}.size-16{width:4rem;height:4rem}.size-2{width:.5rem;height:.5rem}.size-2\\.5{width:.625rem;height:.625rem}.size-3{width:.75rem;height:.75rem}.size-3\\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-5{width:1.25rem;height:1.25rem}.size-6{width:1.5rem;height:1.5rem}.size-7{width:1.75rem;height:1.75rem}.size-8{width:2rem;height:2rem}.size-9{width:2.25rem;height:2.25rem}.size-\\[18px\\]{width:18px;height:18px}.size-\\[max\\(100\\%\\,3rem\\)\\]{width:max(100%,3rem);height:max(100%,3rem)}.size-fit{width:fit-content;height:fit-content}.size-full{width:100%;height:100%}.h-0{height:0px}.h-1{height:.25rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-3{height:.75rem}.h-3\\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-9{height:2.25rem}.h-full{height:100%}.h-px{height:1px}.max-h-16{max-height:4rem}.max-h-40{max-height:10rem}.max-h-60{max-height:15rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-\\[160px\\]{max-height:160px}.max-h-\\[200px\\]{max-height:200px}.max-h-\\[50vh\\]{max-height:50vh}.max-h-full{max-height:100%}.min-h-0{min-height:0px}.min-h-11{min-height:2.75rem}.min-h-12{min-height:3rem}.min-h-14{min-height:3.5rem}.min-h-7{min-height:1.75rem}.min-h-8{min-height:2rem}.min-h-\\[4\\.5rem\\]{min-height:4.5rem}.w-0{width:0px}.w-1\\/2{width:50%}.w-1\\/4{width:25%}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-2\\/3{width:66.666667%}.w-2\\/5{width:40%}.w-3\\/4{width:75%}.w-3\\/5{width:60%}.w-4{width:1rem}.w-5\\/6{width:83.333333%}.w-7{width:1.75rem}.w-\\[32px\\]{width:32px}.w-\\[3px\\]{width:3px}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.w-px{width:1px}.w-screen{width:100vw}.w-svw{width:100svw}.min-w-0{min-width:0px}.min-w-80{min-width:20rem}.min-w-\\[140px\\]{min-width:140px}.min-w-\\[3ch\\]{min-width:3ch}.max-w-11{max-width:2.75rem}.max-w-40{max-width:10rem}.max-w-48{max-width:12rem}.max-w-64{max-width:16rem}.max-w-80{max-width:20rem}.max-w-96{max-width:24rem}.max-w-\\[30rem\\]{max-width:30rem}.max-w-\\[61\\.8\\%\\]{max-width:61.8%}.max-w-\\[85\\%\\]{max-width:85%}.max-w-\\[min\\(100\\%\\,16rem\\)\\]{max-width:min(100%,16rem)}.max-w-full{max-width:100%}.max-w-none{max-width:none}.max-w-xs{max-width:20rem}.flex-1{flex:1 1 0%}.flex-none{flex:none}.flex-shrink,.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.shrink-\\[2\\]{flex-shrink:2}.flex-grow,.grow{flex-grow:1}.border-collapse{border-collapse:collapse}.origin-\\[var\\(--radix-popover-content-transform-origin\\)\\]{transform-origin:var(--radix-popover-content-transform-origin)}.origin-\\[var\\(--radix-tooltip-content-transform-origin\\)\\]{transform-origin:var(--radix-tooltip-content-transform-origin)}.origin-center{transform-origin:center}.origin-top{transform-origin:top}.-translate-x-1\\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-\\[-50\\%\\]{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-\\[var\\(--wobble-x\\)\\]{--tw-translate-x: var(--wobble-x);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-\\[-50\\%\\]{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-\\[var\\(--wobble-y\\)\\]{--tw-translate-y: var(--wobble-y);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rotate-90{--tw-rotate: -90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-y-50{--tw-scale-y: .5;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes bounce{0%,to{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,.2,1)}}.animate-bounce{animation:bounce 1s infinite}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;user-select:none}.resize-none{resize:none}.resize{resize:both}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-\\[subgrid\\]{grid-template-columns:subgrid}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.items-stretch{align-items:stretch}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-\\[1px\\]{gap:1px}.gap-\\[3px\\]{gap:3px}.gap-x-2\\.5{column-gap:.625rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-foreground\\/10>:not([hidden])~:not([hidden]){border-color:hsl(var(--opencx-foreground) / .1)}.self-start{align-self:flex-start}.self-end{align-self:flex-end}.self-center{align-self:center}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-scroll{overflow:scroll}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overscroll-contain{overscroll-behavior:contain}.scroll-smooth{scroll-behavior:smooth}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text-ellipsis{text-overflow:ellipsis}.whitespace-normal{white-space:normal}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-balance{text-wrap:balance}.text-pretty{text-wrap:pretty}.break-words{overflow-wrap:break-word}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:1rem}.rounded-3xl{border-radius:1.5rem}.rounded-\\[19px\\]{border-radius:19px}.rounded-\\[1px\\]{border-radius:1px}.rounded-\\[20px\\]{border-radius:20px}.rounded-\\[calc\\(var\\(--opencx-inset-radius\\)\\+var\\(--cx-p\\)\\)\\]{border-radius:calc(var(--opencx-inset-radius) + var(--cx-p))}.rounded-\\[calc\\(var\\(--pk-r\\)-var\\(--pk-p\\)\\)\\]{border-radius:calc(var(--pk-r) - var(--pk-p))}.rounded-\\[var\\(--opencx-inset-radius\\)\\]{border-radius:var(--opencx-inset-radius)}.rounded-\\[var\\(--pk-r\\)\\]{border-radius:var(--pk-r)}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.rounded-b-2xl{border-bottom-right-radius:1rem;border-bottom-left-radius:1rem}.rounded-l-md{border-top-left-radius:.375rem;border-bottom-left-radius:.375rem}.rounded-r-md{border-top-right-radius:.375rem;border-bottom-right-radius:.375rem}.rounded-bl-md{border-bottom-left-radius:.375rem}.rounded-br-md{border-bottom-right-radius:.375rem}.rounded-ee-md{border-end-end-radius:.375rem}.rounded-tl-md{border-top-left-radius:.375rem}.rounded-tr-md{border-top-right-radius:.375rem}.border{border-width:1px}.border-\\[1\\.5px\\]{border-width:1.5px}.border-b{border-bottom-width:1px}.border-l-2{border-left-width:2px}.border-s{border-inline-start-width:1px}.border-s-2{border-inline-start-width:2px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-border{border-color:hsl(var(--opencx-border))}.border-destructive\\/30{border-color:hsl(var(--opencx-destructive) / .3)}.border-foreground\\/10{border-color:hsl(var(--opencx-foreground) / .1)}.border-foreground\\/15{border-color:hsl(var(--opencx-foreground) / .15)}.border-muted-foreground\\/10{border-color:hsl(var(--opencx-muted-foreground) / .1)}.border-muted-foreground\\/15{border-color:hsl(var(--opencx-muted-foreground) / .15)}.border-muted-foreground\\/20{border-color:hsl(var(--opencx-muted-foreground) / .2)}.border-muted-foreground\\/30{border-color:hsl(var(--opencx-muted-foreground) / .3)}.border-primary{border-color:hsl(var(--opencx-primary))}.border-primary\\/10{border-color:hsl(var(--opencx-primary) / .1)}.border-primary\\/50{border-color:hsl(var(--opencx-primary) / .5)}.border-l-amber-500{--tw-border-opacity: 1;border-left-color:rgb(245 158 11 / var(--tw-border-opacity, 1))}.border-l-blue-500{--tw-border-opacity: 1;border-left-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-l-emerald-500{--tw-border-opacity: 1;border-left-color:rgb(16 185 129 / var(--tw-border-opacity, 1))}.border-l-red-500{--tw-border-opacity: 1;border-left-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-t-current{border-top-color:currentColor}.bg-\\[white\\]{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(245 158 11 / var(--tw-bg-opacity, 1))}.bg-amber-500\\/15{background-color:#f59e0b26}.bg-amber-500\\/5{background-color:#f59e0b0d}.bg-background{background-color:hsl(var(--opencx-background))}.bg-background\\/80{background-color:hsl(var(--opencx-background) / .8)}.bg-black\\/50{background-color:#00000080}.bg-black\\/60{background-color:#0009}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\\/5{background-color:#3b82f60d}.bg-border{background-color:hsl(var(--opencx-border))}.bg-current{background-color:currentColor}.bg-destructive{background-color:hsl(var(--opencx-destructive))}.bg-destructive\\/10{background-color:hsl(var(--opencx-destructive) / .1)}.bg-destructive\\/15{background-color:hsl(var(--opencx-destructive) / .15)}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-emerald-500\\/10{background-color:#10b9811a}.bg-emerald-500\\/15{background-color:#10b98126}.bg-emerald-500\\/5{background-color:#10b9810d}.bg-foreground{background-color:hsl(var(--opencx-foreground))}.bg-foreground\\/5{background-color:hsl(var(--opencx-foreground) / .05)}.bg-foreground\\/50{background-color:hsl(var(--opencx-foreground) / .5)}.bg-foreground\\/60{background-color:hsl(var(--opencx-foreground) / .6)}.bg-muted{background-color:hsl(var(--opencx-muted))}.bg-muted-foreground{background-color:hsl(var(--opencx-muted-foreground))}.bg-muted-foreground\\/10{background-color:hsl(var(--opencx-muted-foreground) / .1)}.bg-muted-foreground\\/30{background-color:hsl(var(--opencx-muted-foreground) / .3)}.bg-muted-foreground\\/40{background-color:hsl(var(--opencx-muted-foreground) / .4)}.bg-muted\\/30{background-color:hsl(var(--opencx-muted) / .3)}.bg-muted\\/40{background-color:hsl(var(--opencx-muted) / .4)}.bg-primary{background-color:hsl(var(--opencx-primary))}.bg-primary-foreground\\/20{background-color:hsl(var(--opencx-primary-foreground) / .2)}.bg-primary\\/10{background-color:hsl(var(--opencx-primary) / .1)}.bg-primary\\/25{background-color:hsl(var(--opencx-primary) / .25)}.bg-primary\\/80{background-color:hsl(var(--opencx-primary) / .8)}.bg-primary\\/\\[0\\.07\\]{background-color:hsl(var(--opencx-primary) / .07)}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-500\\/5{background-color:#ef44440d}.bg-secondary{background-color:hsl(var(--opencx-secondary))}.bg-secondary-foreground\\/10{background-color:hsl(var(--opencx-secondary-foreground) / .1)}.bg-secondary-foreground\\/20{background-color:hsl(var(--opencx-secondary-foreground) / .2)}.bg-transparent{background-color:transparent}.bg-white\\/30{background-color:#ffffff4d}.bg-\\[radial-gradient\\(ellipse_at_top_left\\,hsl\\(var\\(--opencx-primary\\)\\)\\,transparent\\)\\,radial-gradient\\(ellipse_at_top_right\\,hsl\\(var\\(--opencx-primary\\)\\)\\,transparent\\)\\]{background-image:radial-gradient(ellipse at top left,hsl(var(--opencx-primary)),transparent),radial-gradient(ellipse at top right,hsl(var(--opencx-primary)),transparent)}.bg-gradient-to-t{background-image:linear-gradient(to top,var(--tw-gradient-stops))}.from-foreground\\/70{--tw-gradient-from: hsl(var(--opencx-foreground) / .7) var(--tw-gradient-from-position);--tw-gradient-to: hsl(var(--opencx-foreground) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-foreground\\/0{--tw-gradient-to: hsl(var(--opencx-foreground) / 0) var(--tw-gradient-to-position)}.fill-current{fill:currentColor}.fill-foreground{fill:hsl(var(--opencx-foreground))}.stroke-current{stroke:currentColor}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-left-top{object-position:left top}.p-0{padding:0}.p-0\\.5{padding:.125rem}.p-1{padding:.25rem}.p-1\\.5{padding:.375rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-\\[var\\(--cx-p\\)\\]{padding:var(--cx-p)}.p-\\[var\\(--pk-p\\)\\]{padding:var(--pk-p)}.px-0\\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-0{padding-top:0;padding-bottom:0}.py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-\\[3px\\]{padding-top:3px;padding-bottom:3px}.pb-0{padding-bottom:0}.pb-0\\.5{padding-bottom:.125rem}.pb-1{padding-bottom:.25rem}.pb-10{padding-bottom:2.5rem}.pb-14{padding-bottom:3.5rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pb-5{padding-bottom:1.25rem}.pe-1{padding-inline-end:.25rem}.pe-2{padding-inline-end:.5rem}.pe-2\\.5{padding-inline-end:.625rem}.pe-4{padding-inline-end:1rem}.pl-2{padding-left:.5rem}.pl-6{padding-left:1.5rem}.pr-16{padding-right:4rem}.ps-1{padding-inline-start:.25rem}.ps-1\\.5{padding-inline-start:.375rem}.ps-10{padding-inline-start:2.5rem}.ps-2{padding-inline-start:.5rem}.ps-2\\.5{padding-inline-start:.625rem}.ps-3{padding-inline-start:.75rem}.ps-4{padding-inline-start:1rem}.ps-8{padding-inline-start:2rem}.pt-0{padding-top:0}.pt-1{padding-top:.25rem}.pt-1\\.5{padding-top:.375rem}.pt-12{padding-top:3rem}.pt-2{padding-top:.5rem}.pt-2\\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.pt-6{padding-top:1.5rem}.pt-8{padding-top:2rem}.text-left{text-align:left}.text-center{text-align:center}.text-start{text-align:start}.align-middle{vertical-align:middle}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.font-sans{font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji"}.text-2xl{font-size:1.5rem;line-height:2rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-\\[0\\.8125rem\\]{font-size:.8125rem}.text-\\[1\\.75rem\\]{font-size:1.75rem}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.text-\\[12px\\]{font-size:12px}.text-\\[13px\\]{font-size:13px}.text-\\[14px\\]{font-size:14px}.text-\\[15px\\]{font-size:15px}.text-\\[16px\\]{font-size:16px}.text-\\[17px\\]{font-size:17px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-none{line-height:1}.leading-relaxed{line-height:1.625}.leading-snug{line-height:1.375}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-background{color:hsl(var(--opencx-background))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-destructive{color:hsl(var(--opencx-destructive))}.text-destructive-foreground{color:hsl(var(--opencx-destructive-foreground))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(5 150 105 / var(--tw-text-opacity, 1))}.text-foreground{color:hsl(var(--opencx-foreground))}.text-foreground\\/50{color:hsl(var(--opencx-foreground) / .5)}.text-foreground\\/60{color:hsl(var(--opencx-foreground) / .6)}.text-foreground\\/80{color:hsl(var(--opencx-foreground) / .8)}.text-foreground\\/90{color:hsl(var(--opencx-foreground) / .9)}.text-muted-foreground{color:hsl(var(--opencx-muted-foreground))}.text-muted-foreground\\/40{color:hsl(var(--opencx-muted-foreground) / .4)}.text-muted-foreground\\/50{color:hsl(var(--opencx-muted-foreground) / .5)}.text-muted-foreground\\/60{color:hsl(var(--opencx-muted-foreground) / .6)}.text-muted-foreground\\/70{color:hsl(var(--opencx-muted-foreground) / .7)}.text-muted-foreground\\/75{color:hsl(var(--opencx-muted-foreground) / .75)}.text-primary{color:hsl(var(--opencx-primary))}.text-primary-foreground{color:hsl(var(--opencx-primary-foreground))}.text-primary-foreground\\/60{color:hsl(var(--opencx-primary-foreground) / .6)}.text-primary\\/10{color:hsl(var(--opencx-primary) / .1)}.text-primary\\/40{color:hsl(var(--opencx-primary) / .4)}.text-primary\\/50{color:hsl(var(--opencx-primary) / .5)}.text-primary\\/60{color:hsl(var(--opencx-primary) / .6)}.text-primary\\/70{color:hsl(var(--opencx-primary) / .7)}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-secondary-foreground{color:hsl(var(--opencx-secondary-foreground))}.text-secondary-foreground\\/60{color:hsl(var(--opencx-secondary-foreground) / .6)}.text-secondary-foreground\\/70{color:hsl(var(--opencx-secondary-foreground) / .7)}.text-transparent{color:transparent}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-white\\/80{color:#fffc}.underline{text-decoration-line:underline}.line-through{text-decoration-line:line-through}.underline-offset-2{text-underline-offset:2px}.underline-offset-4{text-underline-offset:4px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.caret-foreground{caret-color:hsl(var(--opencx-foreground))}.accent-current{accent-color:currentColor}.opacity-0{opacity:0}.opacity-100{opacity:1}.opacity-20{opacity:.2}.opacity-35{opacity:.35}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-90{opacity:.9}.opacity-95{opacity:.95}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.outline-8{outline-width:8px}.outline-background{outline-color:hsl(var(--opencx-background))}.ring{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-border{--tw-ring-color: hsl(var(--opencx-border))}.ring-offset-background{--tw-ring-offset-color: hsl(var(--opencx-background))}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.drop-shadow{--tw-drop-shadow: drop-shadow(0 1px 2px rgb(0 0 0 / .1)) drop-shadow(0 1px 1px rgb(0 0 0 / .06));filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\\[background-color\\,color\\,transform\\]{transition-property:background-color,color,transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\\[height\\]{transition-property:height;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\\[transform\\,background-color\\,color\\]{transition-property:transform,background-color,color;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\\[width\\]{transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-100{transition-duration:.1s}.duration-150{transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.ease-opencx{transition-timing-function:cubic-bezier(.23,1,.32,1)}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.animate-in{animation-name:enter;animation-duration:.15s;--tw-enter-opacity: initial;--tw-enter-scale: initial;--tw-enter-rotate: initial;--tw-enter-translate-x: initial;--tw-enter-translate-y: initial}.fade-in-0{--tw-enter-opacity: 0}.zoom-in{--tw-enter-scale: 0}.zoom-in-95{--tw-enter-scale: .95}.duration-100{animation-duration:.1s}.duration-150{animation-duration:.15s}.duration-200{animation-duration:.2s}.duration-300{animation-duration:.3s}.ease-opencx{animation-timing-function:cubic-bezier(.23,1,.32,1)}.ease-out{animation-timing-function:cubic-bezier(0,0,.2,1)}.running{animation-play-state:running}.paused{animation-play-state:paused}.\\[--tw-prose-body\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-body: hsl(var(--opencx-foreground))}.\\[--tw-prose-body\\:hsl\\(var\\(--opencx-muted-foreground\\)\\)\\]{--tw-prose-body: hsl(var(--opencx-muted-foreground))}.\\[--tw-prose-body\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-body: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-bold\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-bold: hsl(var(--opencx-foreground))}.\\[--tw-prose-bold\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-bold: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-bullets\\:hsl\\(var\\(--opencx-muted-foreground\\)\\)\\]{--tw-prose-bullets: hsl(var(--opencx-muted-foreground))}.\\[--tw-prose-code\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-code: hsl(var(--opencx-foreground))}.\\[--tw-prose-code\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-code: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-counters\\:hsl\\(var\\(--opencx-muted-foreground\\)\\)\\]{--tw-prose-counters: hsl(var(--opencx-muted-foreground))}.\\[--tw-prose-headings\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-headings: hsl(var(--opencx-foreground))}.\\[--tw-prose-headings\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-headings: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-hr\\:hsl\\(var\\(--opencx-border\\)\\)\\]{--tw-prose-hr: hsl(var(--opencx-border))}.\\[--tw-prose-lead\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-lead: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-links\\:hsl\\(var\\(--opencx-primary\\)\\)\\]{--tw-prose-links: hsl(var(--opencx-primary))}.\\[--tw-prose-links\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-links: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-pre-bg\\:hsl\\(var\\(--opencx-muted\\)\\)\\]{--tw-prose-pre-bg: hsl(var(--opencx-muted))}.\\[--tw-prose-pre-code\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-pre-code: hsl(var(--opencx-foreground))}.\\[--tw-prose-quote-borders\\:hsl\\(var\\(--opencx-border\\)\\)\\]{--tw-prose-quote-borders: hsl(var(--opencx-border))}.\\[--tw-prose-quotes\\:hsl\\(var\\(--opencx-muted-foreground\\)\\)\\]{--tw-prose-quotes: hsl(var(--opencx-muted-foreground))}.\\[--tw-prose-td-borders\\:hsl\\(var\\(--opencx-border\\)\\)\\]{--tw-prose-td-borders: hsl(var(--opencx-border))}.\\[--tw-prose-th-borders\\:hsl\\(var\\(--opencx-border\\)\\)\\]{--tw-prose-th-borders: hsl(var(--opencx-border))}.\\[animation-delay\\:-0\\.15s\\]{animation-delay:-.15s}.\\[animation-delay\\:-0\\.3s\\]{animation-delay:-.3s}.\\[field-sizing\\:content\\;\\],.\\[field-sizing\\:content\\]{field-sizing:content}.\\[overflow-wrap\\:anywhere\\]{overflow-wrap:anywhere}.\\[word-break\\:break-word\\]{word-break:break-word}.file\\:border-0::file-selector-button{border-width:0px}.file\\:bg-transparent::file-selector-button{background-color:transparent}.file\\:text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:font-medium::file-selector-button{font-weight:500}.file\\:text-primary-foreground::file-selector-button{color:hsl(var(--opencx-primary-foreground))}.placeholder\\:text-muted-foreground::placeholder{color:hsl(var(--opencx-muted-foreground))}.placeholder\\:text-muted-foreground\\/75::placeholder{color:hsl(var(--opencx-muted-foreground) / .75)}.last\\:border-0:last-child{border-width:0px}.focus-within\\:opacity-100:focus-within{opacity:1}.hover\\:scale-\\[var\\(--scale\\)\\]:hover{--tw-scale-x: var(--scale);--tw-scale-y: var(--scale);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\\:bg-accent\\/60:hover{background-color:hsl(var(--opencx-accent) / .6)}.hover\\:bg-foreground:hover{background-color:hsl(var(--opencx-foreground))}.hover\\:bg-foreground\\/90:hover{background-color:hsl(var(--opencx-foreground) / .9)}.hover\\:bg-muted:hover{background-color:hsl(var(--opencx-muted))}.hover\\:bg-muted\\/50:hover{background-color:hsl(var(--opencx-muted) / .5)}.hover\\:bg-muted\\/60:hover{background-color:hsl(var(--opencx-muted) / .6)}.hover\\:bg-primary\\/10:hover{background-color:hsl(var(--opencx-primary) / .1)}.hover\\:bg-primary\\/90:hover{background-color:hsl(var(--opencx-primary) / .9)}.hover\\:bg-primary\\/\\[0\\.02\\]:hover{background-color:hsl(var(--opencx-primary) / .02)}.hover\\:bg-red-500:hover{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.hover\\:bg-secondary:hover{background-color:hsl(var(--opencx-secondary))}.hover\\:bg-secondary\\/80:hover{background-color:hsl(var(--opencx-secondary) / .8)}.hover\\:bg-transparent:hover{background-color:transparent}.hover\\:bg-white\\/15:hover{background-color:#ffffff26}.hover\\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.hover\\:text-foreground:hover{color:hsl(var(--opencx-foreground))}.hover\\:text-muted-foreground:hover{color:hsl(var(--opencx-muted-foreground))}.hover\\:text-primary:hover{color:hsl(var(--opencx-primary))}.hover\\:text-primary-foreground:hover{color:hsl(var(--opencx-primary-foreground))}.hover\\:text-secondary-foreground:hover{color:hsl(var(--opencx-secondary-foreground))}.hover\\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.hover\\:underline:hover{text-decoration-line:underline}.hover\\:opacity-100:hover{opacity:1}.hover\\:opacity-80:hover{opacity:.8}.focus-visible\\:opacity-100:focus-visible{opacity:1}.focus-visible\\:outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:outline:focus-visible{outline-style:solid}.focus-visible\\:outline-2:focus-visible{outline-width:2px}.focus-visible\\:outline-ring:focus-visible{outline-color:hsl(var(--opencx-ring))}.focus-visible\\:ring-1:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\\:ring-2:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\\:ring-inset:focus-visible{--tw-ring-inset: inset}.focus-visible\\:ring-primary\\/40:focus-visible{--tw-ring-color: hsl(var(--opencx-primary) / .4)}.focus-visible\\:ring-ring:focus-visible{--tw-ring-color: hsl(var(--opencx-ring))}.focus-visible\\:ring-offset-2:focus-visible{--tw-ring-offset-width: 2px}.active\\:scale-90:active{--tw-scale-x: .9;--tw-scale-y: .9;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.active\\:scale-95:active{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.active\\:scale-\\[0\\.97\\]:active{--tw-scale-x: .97;--tw-scale-y: .97;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.active\\:hover\\:scale-\\[calc\\(var\\(--scale\\)-0\\.02\\)\\]:hover:active{--tw-scale-x: calc(var(--scale) - .02);--tw-scale-y: calc(var(--scale) - .02);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\\:pointer-events-none:disabled{pointer-events:none}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:text-white\\/30:disabled{color:#ffffff4d}.disabled\\:opacity-100:disabled{opacity:1}.disabled\\:opacity-40:disabled{opacity:.4}.disabled\\:opacity-50:disabled{opacity:.5}.disabled\\:hover\\:bg-transparent:hover:disabled{background-color:transparent}.group:hover .group-hover\\:opacity-100{opacity:1}.aria-expanded\\:bg-muted[aria-expanded=true]{background-color:hsl(var(--opencx-muted))}.data-\\[state\\=closed\\]\\:animate-out[data-state=closed]{animation-name:exit;animation-duration:.15s;--tw-exit-opacity: initial;--tw-exit-scale: initial;--tw-exit-rotate: initial;--tw-exit-translate-x: initial;--tw-exit-translate-y: initial}.data-\\[state\\=closed\\]\\:fade-out-0[data-state=closed]{--tw-exit-opacity: 0}.data-\\[state\\=closed\\]\\:zoom-out-95[data-state=closed]{--tw-exit-scale: .95}.data-\\[side\\=bottom\\]\\:slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y: -.5rem}.data-\\[side\\=left\\]\\:slide-in-from-right-2[data-side=left]{--tw-enter-translate-x: .5rem}.data-\\[side\\=right\\]\\:slide-in-from-left-2[data-side=right]{--tw-enter-translate-x: -.5rem}.data-\\[side\\=top\\]\\:slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y: .5rem}.prose-headings\\:my-1\\.5 :is(:where(h1,h2,h3,h4,h5,h6,th):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.375rem;margin-bottom:.375rem}.prose-headings\\:text-\\[13px\\] :is(:where(h1,h2,h3,h4,h5,h6,th):not(:where([class~=not-prose],[class~=not-prose] *))){font-size:13px}.prose-p\\:my-1 :is(:where(p):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.25rem;margin-bottom:.25rem}.prose-a\\:underline :is(:where(a):not(:where([class~=not-prose],[class~=not-prose] *))){text-decoration-line:underline}.prose-a\\:decoration-primary :is(:where(a):not(:where([class~=not-prose],[class~=not-prose] *))){text-decoration-color:hsl(var(--opencx-primary))}.prose-pre\\:my-1\\.5 :is(:where(pre):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.375rem;margin-bottom:.375rem}.prose-pre\\:p-2 :is(:where(pre):not(:where([class~=not-prose],[class~=not-prose] *))){padding:.5rem}.prose-pre\\:text-\\[11px\\] :is(:where(pre):not(:where([class~=not-prose],[class~=not-prose] *))){font-size:11px}.prose-ol\\:my-1 :is(:where(ol):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.25rem;margin-bottom:.25rem}.prose-ul\\:my-1 :is(:where(ul):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.25rem;margin-bottom:.25rem}.prose-li\\:my-0\\.5 :is(:where(li):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.125rem;margin-bottom:.125rem}.prose-table\\:block :is(:where(table):not(:where([class~=not-prose],[class~=not-prose] *))){display:block}.prose-table\\:overflow-x-auto :is(:where(table):not(:where([class~=not-prose],[class~=not-prose] *))){overflow-x:auto}.prose-table\\:\\[overflow-wrap\\:normal\\] :is(:where(table):not(:where([class~=not-prose],[class~=not-prose] *))){overflow-wrap:normal}.prose-table\\:\\[word-break\\:normal\\] :is(:where(table):not(:where([class~=not-prose],[class~=not-prose] *))){word-break:normal}.prose-img\\:rounded-xl :is(:where(img):not(:where([class~=not-prose],[class~=not-prose] *))){border-radius:.75rem}.prose-hr\\:my-2 :is(:where(hr):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.5rem;margin-bottom:.5rem}@media(prefers-reduced-motion:reduce){.motion-reduce\\:animate-none{animation:none}.motion-reduce\\:active\\:scale-100:active{--tw-scale-x: 1;--tw-scale-y: 1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}}@media(min-width:640px){.sm\\:text-sm{font-size:.875rem;line-height:1.25rem}}.rtl\\:-scale-100:where([dir=rtl],[dir=rtl] *){--tw-scale-x: -1;--tw-scale-y: -1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@media(prefers-color-scheme:dark){.dark\\:text-amber-400{--tw-text-opacity: 1;color:rgb(251 191 36 / var(--tw-text-opacity, 1))}.dark\\:text-emerald-400{--tw-text-opacity: 1;color:rgb(52 211 153 / var(--tw-text-opacity, 1))}.dark\\:text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}}.\\[\\&\\>\\*\\:first-child\\]\\:mt-0>*:first-child{margin-top:0}.\\[\\&\\>\\*\\:last-child\\]\\:mb-0>*:last-child{margin-bottom:0}.\\[\\&_\\.animate-spin\\]\\:animate-none .animate-spin{animation:none}.\\[\\&_span\\]\\:size-1 span{width:.25rem;height:.25rem}.\\[\\&_span\\]\\:bg-secondary-foreground span{background-color:hsl(var(--opencx-secondary-foreground))}.\\[\\&_svg\\]\\:text-muted-foreground\\/70 svg{color:hsl(var(--opencx-muted-foreground) / .7)}.\\[\\&_svg\\]\\:hover\\:text-primary:hover svg{color:hsl(var(--opencx-primary))}@media(hover:none){.\\[\\@media\\(hover\\:none\\)\\]\\:opacity-100{opacity:1}}@media(pointer:coarse){.\\[\\@media\\(pointer\\:coarse\\)\\]\\:min-h-12{min-height:3rem}.\\[\\@media\\(pointer\\:coarse\\)\\]\\:gap-y-3{row-gap:.75rem}}@media(pointer:fine){.\\[\\@media\\(pointer\\:fine\\)\\]\\:hidden{display:none}}',Lu="5.16.1";function $u(e,t){const n=typeof(e==null?void 0:e.right)=="number",o=typeof(e==null?void 0:e.left)=="number";return n&&!o?"right":o&&!n||t==="rtl"?"left":"right"}const cs=450;function je(){const[e,t]=u.useState(()=>(window.top||window).innerWidth<cs);return u.useEffect(()=>{const n=window.top||window,o=()=>{t(n.innerWidth<cs)};return o(),n.addEventListener("resize",o),()=>{n.removeEventListener("resize",o)}},[]),{isSmallScreen:e}}const xn={transitionTimingFunction:"cubic-bezier(0.16, 1, 0.3, 1)",transitionDuration:"1000ms"};function me(){var h,f,x,g,y,w,j,b,_,v,k,N,R,T,A,O,P,B,E,I,W,$,U,Y,q,se,D,V,Z,te,ae,xe,H,ee,J,ne,le,de,ie,De,Fe,pe,Ve,st,Ye,He,Xe,Ge;const{dir:e}=C.useDocumentDir(),{isSmallScreen:t}=je(),{theme:n,inline:o}=C.useConfig(),s=we=>o?"100%":we,a=(we,Re)=>t?`100dv${we}`:Re,i=(we,Re)=>s(a(we,Re)),c=$u((h=n==null?void 0:n.widgetTrigger)==null?void 0:h.offset,e),d={zIndex:((f=n==null?void 0:n.widgetTrigger)==null?void 0:f.zIndex)??1e7,offset:{bottom:((g=(x=n==null?void 0:n.widgetTrigger)==null?void 0:x.offset)==null?void 0:g.bottom)??20,right:((w=(y=n==null?void 0:n.widgetTrigger)==null?void 0:y.offset)==null?void 0:w.right)??(c==="right"?20:"initial"),left:((b=(j=n==null?void 0:n.widgetTrigger)==null?void 0:j.offset)==null?void 0:b.left)??(c==="left"?20:"initial")},size:{button:((v=(_=n==null?void 0:n.widgetTrigger)==null?void 0:_.size)==null?void 0:v.button)??48,icon:((N=(k=n==null?void 0:n.widgetTrigger)==null?void 0:k.size)==null?void 0:N.icon)??24}},l=(()=>{const we=c==="right"?d.offset.right:d.offset.left;return typeof we!="number"?0:we})(),m={palette:(n==null?void 0:n.palette)??"neutral",primaryColor:(n==null?void 0:n.primaryColor)??"hsl(0 0% 9%)",widgetTrigger:d,widgetContentContainer:{borderRadius:t?"0px":((R=n==null?void 0:n.widgetContentContainer)==null?void 0:R.borderRadius)??"32px",zIndex:((T=n==null?void 0:n.widgetContentContainer)==null?void 0:T.zIndex)??d.zIndex+1,outline:((A=n==null?void 0:n.widgetContentContainer)==null?void 0:A.outline)??"none",outlineColor:((O=n==null?void 0:n.widgetContentContainer)==null?void 0:O.outlineColor)??"hsl(0 0% 50% / .5)",boxShadow:((P=n==null?void 0:n.widgetContentContainer)==null?void 0:P.boxShadow)??"0 0px 100px 0px rgb(0 0 0 / 0.25)",transitionProperty:((B=n==null?void 0:n.widgetContentContainer)==null?void 0:B.transitionProperty)??"all",transitionTimingFunction:((E=n==null?void 0:n.widgetContentContainer)==null?void 0:E.transitionTimingFunction)??xn.transitionTimingFunction,transitionDuration:((I=n==null?void 0:n.widgetContentContainer)==null?void 0:I.transitionDuration)??xn.transitionDuration,offset:{side:t?0:d.offset.bottom+d.size.button+Tt.y*2+((($=(W=n==null?void 0:n.widgetContentContainer)==null?void 0:W.offset)==null?void 0:$.side)??10),align:t?0:l+(((Y=(U=n==null?void 0:n.widgetContentContainer)==null?void 0:U.offset)==null?void 0:Y.align)??0)}},screens:{welcome:{width:i("w",((se=(q=n==null?void 0:n.screens)==null?void 0:q.welcome)==null?void 0:se.width)??"400px"),minHeight:i("h",((V=(D=n==null?void 0:n.screens)==null?void 0:D.welcome)==null?void 0:V.minHeight)??"1px")},sessions:{width:i("w",((te=(Z=n==null?void 0:n.screens)==null?void 0:Z.sessions)==null?void 0:te.width)??"450px"),height:i("h",((xe=(ae=n==null?void 0:n.screens)==null?void 0:ae.sessions)==null?void 0:xe.height)??"600px")},chat:{width:i("w",((ee=(H=n==null?void 0:n.screens)==null?void 0:H.chat)==null?void 0:ee.width)??"525px"),height:i("h",((ne=(J=n==null?void 0:n.screens)==null?void 0:J.chat)==null?void 0:ne.height)??"700px"),withCanvas:{width:i("w",((ie=(de=(le=n==null?void 0:n.screens)==null?void 0:le.chat)==null?void 0:de.withCanvas)==null?void 0:ie.width)??"min(1050px, 100vw)"),height:i("h",((pe=(Fe=(De=n==null?void 0:n.screens)==null?void 0:De.chat)==null?void 0:Fe.withCanvas)==null?void 0:pe.height)??"min(800px, 100vh)"),transitionTimingFunction:((Ye=(st=(Ve=n==null?void 0:n.screens)==null?void 0:Ve.chat)==null?void 0:st.withCanvas)==null?void 0:Ye.transitionTimingFunction)??xn.transitionTimingFunction,transitionDuration:((Ge=(Xe=(He=n==null?void 0:n.screens)==null?void 0:He.chat)==null?void 0:Xe.withCanvas)==null?void 0:Ge.transitionDuration)??xn.transitionDuration}}}},p={maxHeight:i("h",`calc(
|
|
15
15
|
100vh
|
|
16
16
|
- ${m.widgetTrigger.offset.bottom}px
|
|
17
17
|
- ${m.widgetContentContainer.offset.side}px
|
|
@@ -27,11 +27,11 @@ Note: state patches appear right after the elements that use them, so the UI fil
|
|
|
27
27
|
${m.screens.welcome.width},
|
|
28
28
|
${m.screens.sessions.width},
|
|
29
29
|
${m.screens.chat.width}
|
|
30
|
-
)`)};return{theme:m,triggerSide:c,computed:p,cssVars:
|
|
30
|
+
)`)};return{theme:m,triggerSide:c,computed:p,cssVars:Du({palette:m.palette,primary:m.primaryColor})}}function Du({palette:e,primary:t}){const n=oi(e),o=Do(t).toHsl(),s=Do(t).isLight()?n[950]:n[50];return{"--opencx-primary":`${o.h} ${o.s*100}% ${o.l*100}%`,"--opencx-primary-foreground":s,"--opencx-background":n[100],"--opencx-foreground":n[950],"--opencx-destructive":"0 72.2% 50.6%","--opencx-destructive-foreground":n[50],"--opencx-accent":n[200],"--opencx-accent-foreground":"var(--opencx-foreground)","--opencx-secondary":n[200],"--opencx-secondary-foreground":"var(--opencx-foreground)","--opencx-muted":n[200],"--opencx-muted-foreground":n[500],"--opencx-input":n[300],"--opencx-border":n[300],"--opencx-ring":"var(--opencx-foreground)"}}function oi(e){const t={50:"0 0% 98%",100:"0 0% 96.1%",200:"0 0% 89.8%",300:"0 0% 83.1%",400:"0 0% 63.9%",500:"0 0% 45.1%",600:"0 0% 32.2%",700:"0 0% 25.1%",800:"0 0% 14.9%",900:"0 0% 9%",950:"0 0% 3.9%"},n={50:"60 9.1% 97.8%",100:"60 4.8% 95.9%",200:"20 5.9% 90%",300:"24 5.7% 82.9%",400:"24 5.4% 63.9%",500:"25 5.3% 44.7%",600:"33.3 5.5% 32.4%",700:"30 6.3% 25.1%",800:"12 6.5% 15.1%",900:"24 9.8% 10%",950:"20 14.3% 4.1%"},o={50:"0 0% 98%",100:"240 4.8% 95.9%",200:"240 5.9% 90%",300:"240 4.9% 83.9%",400:"240 5% 64.9%",500:"240 3.8% 46.1%",600:"240 5.2% 33.9%",700:"240 5.3% 26.1%",800:"240 3.7% 15.9%",900:"240 5.9% 10%",950:"240 10% 3.9%"},s={50:"210 40% 98%",100:"210 40% 96.1%",200:"214.3 31.8% 91.4%",300:"212.7 26.8% 83.9%",400:"215 20.2% 65.1%",500:"215.4 16.3% 46.9%",600:"215.3 19.3% 34.5%",700:"215.3 25% 26.7%",800:"217.2 32.6% 17.5%",900:"222.2 47.4% 11.2%",950:"222.2 84% 4.9%"};switch(e){case"neutral":return t;case"stone":return n;case"zinc":return o;case"slate":return s;default:return K.isExhaustive(e,oi.name),t}}const Fu=150,bn={capture:!0},Ke={capture:!0,passive:!0};function si(e,{scroll:t}){var o;const n=(o=to())==null?void 0:o.report;u.useEffect(()=>{if(!e||!n)return;const s=h=>{h.isTrusted&&(!("detail"in h)||typeof h.detail!="number"||h.detail>0&&n({type:"click"}))},a=h=>{h.isTrusted&&n({type:"keyboard"})};let i=!1,c;const d=()=>{i&&(i=!1,clearTimeout(c),n({type:"scroll-end"}))},l=()=>{clearTimeout(c),c=setTimeout(d,Fu)},m=h=>{h.isTrusted&&(i||(i=!0,n({type:"scroll-start"})),l())},p=()=>{i&&l()};return e.addEventListener("click",s,bn),e.addEventListener("keydown",a,bn),t&&(e.addEventListener("wheel",m,Ke),e.addEventListener("touchmove",m,Ke),e.addEventListener("scroll",p,Ke),e.addEventListener("scrollend",d,Ke)),()=>{e.removeEventListener("click",s,bn),e.removeEventListener("keydown",a,bn),e.removeEventListener("wheel",m,Ke),e.removeEventListener("touchmove",m,Ke),e.removeEventListener("scroll",p,Ke),e.removeEventListener("scrollend",d,Ke),d()}},[e,n,t])}const Hu=Ie.Provider,Wu=Ie.Root,Bu=Ie.Trigger,ai=ot.forwardRef(({className:e,sideOffset:t=4,...n},o)=>r.jsx(Ie.Content,{ref:o,sideOffset:t,className:z("z-50 overflow-hidden max-w-xs rounded-xl bg-primary border text-primary-foreground p-2 text-center align-middle text-xs origin-[var(--radix-tooltip-content-transform-origin)] animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));ai.displayName=Ie.Content.displayName;const ii=ot.createContext(!1);function Uu({children:e}){return r.jsx(ii.Provider,{value:!0,children:e})}function Ne({children:e,content:t,side:n,align:o,shortcut:s}){const{disableTooltips:a}=C.useConfig(),i=ot.useContext(ii);return!t||a||i?e:r.jsxs(Wu,{children:[r.jsx(Bu,{asChild:!0,children:e}),r.jsxs(ai,{side:n,align:o,collisionPadding:8,avoidCollisions:!0,children:[t,s&&r.jsx("span",{className:"ms-1.5 whitespace-nowrap text-primary-foreground/60",children:s})]})]})}const ci="OpenCX Live Chat";function ao({transparent:e=!1}={}){return`<!DOCTYPE html>
|
|
31
31
|
<html>
|
|
32
32
|
<head>
|
|
33
33
|
<style>
|
|
34
|
-
${
|
|
34
|
+
${Ou}
|
|
35
35
|
html, body {
|
|
36
36
|
height: 100%;
|
|
37
37
|
width: 100%;
|
|
@@ -45,7 +45,7 @@ html, body {
|
|
|
45
45
|
</head>
|
|
46
46
|
<body>
|
|
47
47
|
</body>
|
|
48
|
-
</html>`}function Ln({overrides:e,rootRef:t,style:n,shellRadius:o,children:s}){const{cssOverrides:a}=C.useConfig(),{cssVars:i,theme:c}=me(),{dir:d}=G(),[l,m]=u.useState(null),p=u.useCallback(f=>{m((f==null?void 0:f.ownerDocument)??null),typeof t=="function"?t(f):t&&(t.current=f)},[t]);
|
|
48
|
+
</html>`}function Ln({overrides:e,rootRef:t,style:n,shellRadius:o,children:s}){const{cssOverrides:a}=C.useConfig(),{cssVars:i,theme:c}=me(),{dir:d}=G(),[l,m]=u.useState(null),p=u.useCallback(f=>{m((f==null?void 0:f.ownerDocument)??null),typeof t=="function"?t(f):t&&(t.current=f)},[t]);si(l,{scroll:!0});const h={"--opencx-shell-radius":o??c.widgetContentContainer.borderRadius,"--opencx-inset-radius":"max(0.75rem, calc(var(--opencx-shell-radius) - 0.5rem))"};return r.jsxs(r.Fragment,{children:[e?r.jsx("style",{children:e}):null,a?r.jsx("style",{children:a}):null,r.jsx("div",{ref:p,style:{...i,...h,...n},"data-version":Lu,dir:d,className:z("antialiased font-sans size-full overflow-hidden relative text-secondary-foreground isolate"),children:r.jsx(Hu,{delayDuration:200,disableHoverableContent:!0,children:r.jsx(lu,{children:s})})})]})}function li(){const{contentIframeRef:e}=C.useWidget(),{inline:t}=C.useConfig();return{setWidth:n=>{var o;(o=e==null?void 0:e.current)==null||o.style.setProperty("--opencx-widget-width",t?"100%":n)},setHeight:n=>{var o;(o=e==null?void 0:e.current)==null||o.style.setProperty("--opencx-widget-height",t?"100%":n)}}}function Pt({width:e,height:t}){const{isSmallScreen:n}=je(),{setWidth:o,setHeight:s}=li();u.useEffect(()=>{e&&o(e),t&&s(t)},[n,t,e,o,s])}const ls=M.CircleDashedIcon;function zt({name:e,className:t}){const n=(()=>{switch(e){case"Check":return M.CheckIcon;case"CheckCheck":return M.CheckCheckIcon;case"CircleCheck":return M.CircleCheckIcon;case"CircleCheckBig":return M.CircleCheckBigIcon;case"CircleX":return M.CircleXIcon;case"Expand":return M.ExpandIcon;case"Maximize":return M.MaximizeIcon;case"Maximize2":return M.Maximize2Icon;case"Minimize":return M.MinimizeIcon;case"Minimize2":return M.Minimize2Icon;case"Shrink":return M.ShrinkIcon;case"SquareCheck":return M.SquareCheckIcon;case"SquareCheckBig":return M.SquareCheckBigIcon;case"SquareX":return M.SquareXIcon;case"X":return M.XIcon;case"AtSign":return M.AtSignIcon;case"Bot":return M.BotIcon;case"Book":return M.BookIcon;case"BookOpen":return M.BookOpenIcon;case"Building2":return M.Building2Icon;case"Calendar":return M.CalendarIcon;case"CreditCard":return M.CreditCardIcon;case"Database":return M.DatabaseIcon;case"FileText":return M.FileTextIcon;case"Folder":return M.FolderIcon;case"Globe":return M.GlobeIcon;case"Link":return M.LinkIcon;case"Mail":return M.MailIcon;case"Package":return M.PackageIcon;case"Plug":return M.PlugIcon;case"Settings":return M.SettingsIcon;case"ShoppingCart":return M.ShoppingCartIcon;case"Tag":return M.TagIcon;case"Ticket":return M.TicketIcon;case"User":return M.UserIcon;case"Users":return M.UsersIcon;case"Workflow":return M.WorkflowIcon;case"Zap":return M.ZapIcon;case void 0:return ls;default:return K.isExhaustive(e,zt.name),ls}})();return r.jsx(n,{className:z("size-4",t)})}function io(e){const{t}=G(),{session:n}=C.usePrimitiveState(e.ctx.sessionCtx.sessionState),{messages:o}=C.usePrimitiveState(e.ctx.messageCtx.state),s=C.usePrimitiveState(e.ctx.messageCtx.draftState),a=e.title||(n==null?void 0:n.title)||t("companion_chat_number",{count:e.id});let i=(n==null?void 0:n.lastMessage)??s.text??"";for(let l=o.length-1;l>=0;l--){const m=o[l],p=m.type==="USER"?m.content:m.type==="SYSTEM"?"":m.data.message;if(p.trim()){i=p;break}}const c=e.working?t("companion_working"):n!=null&&n.isOpened?t("companion_open"):t(n?"companion_closed":"companion_draft");return{title:!e.hasDraft&&!e.hasSession&&!e.working&&!n&&!e.title&&!o.length&&!s.text&&!s.mentions.length?t("new_conversation"):a,preview:i.replace(/\s+/g," ").trim(),status:c}}function co(){const e=Pn(),[t,n]=u.useState(null),[o,s]=u.useState(!1),[a,i]=u.useState(!1),[c,d]=u.useState(!1),l=u.useRef(!1),m=u.useRef(void 0),p=u.useCallback(()=>clearTimeout(m.current),[]);u.useEffect(()=>p,[p]);const h=u.useCallback((f=!1)=>{p(),l.current=!1,f&&i(!1),s(!1)},[p]);return{anchor:t,open:o,animate:a,autoFocus:c,close:h,toggle(f,x=!1){if(p(),o&&l.current){h(!x);return}l.current=!0,n(f),i(x),d(!0),s(!0)},hover(f){p(),!(!e||o)&&(m.current=setTimeout(()=>{l.current=!1,n(f),i(!0),d(!1),s(!0)},100))},enter:p,leave(){p(),l.current||(m.current=setTimeout(()=>h(),200))}}}function lo(){return r.jsx("style",{children:`
|
|
49
49
|
[data-companion-action] {
|
|
50
50
|
transition: transform 150ms ease-out, background-color 150ms ease-out, color 150ms ease-out, opacity 100ms ease-out;
|
|
51
51
|
}
|
|
@@ -57,10 +57,10 @@ html, body {
|
|
|
57
57
|
@media (prefers-reduced-motion: reduce), (pointer: coarse) {
|
|
58
58
|
[data-companion-action] { transform: none !important; transition: none; }
|
|
59
59
|
}
|
|
60
|
-
`})}function
|
|
60
|
+
`})}function qu({picker:e,...t}){return r.jsxs(r.Fragment,{children:[r.jsx(lo,{}),r.jsx(X,{...t,variant:"ghost",size:"selfless",type:"button","data-companion-action":"","aria-haspopup":"menu","aria-expanded":e.open,onPointerEnter:n=>e.hover(n.currentTarget),onPointerLeave:e.leave,onPointerDown:n=>{e.open&&n.preventDefault()},onClick:n=>{n.stopPropagation(),e.toggle(n.currentTarget,n.detail>0)},onKeyDown:n=>{(n.key==="ArrowDown"||n.key==="ArrowUp")&&(n.preventDefault(),e.toggle(n.currentTarget))}})]})}function Vu({chat:e,selected:t,onSelect:n,onClose:o}){const{t:s}=G(),{title:a,preview:i,status:c}=io(e);return r.jsx(Oe,{children:r.jsxs("div",{"data-chat-row":"","data-companion-action":"","data-selected":t||void 0,children:[r.jsx(Ae.RadioItem,{asChild:!0,value:String(e.id),textValue:a,onSelect:d=>{d.preventDefault(),n()},children:r.jsxs("button",{className:wr({size:"selfless",className:"bg-transparent"}),type:"button","data-companion-action":"","aria-description":i||void 0,"aria-label":`${a} — ${c}${t?` — ${s("companion_viewing")}`:""}`,"data-chat-select":e.id,children:[r.jsx("span",{"data-chat-indicator":"","aria-hidden":!0,children:r.jsx(Ae.ItemIndicator,{children:r.jsx(M.CheckIcon,{size:14})})}),r.jsx("span",{"data-chat-title":"",children:a}),e.working&&r.jsx(M.LoaderCircleIcon,{size:14,"data-working":"","aria-hidden":!0})]})}),r.jsx(Ae.Item,{asChild:!0,textValue:s("companion_close_chat",{title:a}),onSelect:d=>{d.preventDefault(),o()},children:r.jsx("button",{className:wr({size:"selfless",className:"bg-transparent"}),type:"button","data-companion-action":"","aria-label":s("companion_close_chat",{title:a}),"data-chat-close":e.id,children:r.jsx(M.XIcon,{size:14,"aria-hidden":!0})})})]})})}function uo(e){const{picker:t,portalTarget:n}=e;return t.anchor&&n?r.jsx(Yu,{...e,anchor:t.anchor,portalTarget:n}):null}function Yu({picker:e,anchor:t,portalTarget:n,placement:o,onSelected:s}){const{open:a,animate:i,autoFocus:c,close:d,enter:l,leave:m}=e,{chats:p,activeId:h,selectChat:f,newChat:x,closeChat:g}=C.useCompanionChats(),{canCreateNewSession:y}=C.useSessions(),{t:w,dir:j}=G(),{cssVars:b,theme:_}=me(),v=u.useRef(null),k=u.useRef(t.ownerDocument.activeElement),N=u.useCallback(E=>{E&&!v.current&&(k.current=t.ownerDocument.activeElement),v.current=E},[t]),R=u.useRef(!1),T=u.useRef({onClose:d,onSelected:s});T.current={onClose:d,onSelected:s};const A=u.useMemo(()=>({current:{getBoundingClientRect(){let E=t.getBoundingClientRect(),I=t.ownerDocument.defaultView;const W=n.ownerDocument.defaultView;for(;I&&I!==W;){const $=I.frameElement;if(!$)break;const U=$.getBoundingClientRect(),Y=U.width/$.offsetWidth||1,q=U.height/$.offsetHeight||1;E=new DOMRect(U.left+E.left*Y,U.top+E.top*q,E.width*Y,E.height*q),I=$.ownerDocument.defaultView}return E}}}),[t,n]),O=p.filter(E=>E.working).length;u.useEffect(()=>{if(!a||t.ownerDocument===n.ownerDocument)return;const E=W=>{W.composedPath().includes(t)||W.type==="focusin"&&!c&&W.target===k.current||T.current.onClose(W.type==="focusin")},I=t.ownerDocument;return I.addEventListener("pointerdown",E,!0),I.addEventListener("focusin",E),()=>{I.removeEventListener("pointerdown",E,!0),I.removeEventListener("focusin",E)}},[t,n,a,c]),u.useLayoutEffect(()=>{var E,I,W;(E=v.current)==null||E.toggleAttribute("inert",!a),a&&c&&((W=(I=v.current)==null?void 0:I.querySelector('[aria-checked="true"]'))==null||W.focus({preventScroll:!0}))},[a,c]);function P(E){var I,W;t.focus({preventScroll:!0}),E===void 0?x():f(E),T.current.onClose(!0),(W=(I=T.current).onSelected)==null||W.call(I)}function B(E){var $,U,Y,q;const I=p.findIndex(se=>se.id===E),W=p[I+1]??p[I-1];E===h?(t.focus({preventScroll:!0}),T.current.onClose(!0)):(U=($=v.current)==null?void 0:$.querySelector(W?`[data-chat-select="${W.id}"]`:"[data-new-chat]"))==null||U.focus({preventScroll:!0}),g(E),E===h&&((q=(Y=T.current).onSelected)==null||q.call(Y))}return Qt.createPortal(r.jsxs(Ae.Root,{open:a,onOpenChange:E=>{!E&&!R.current&&T.current.onClose()},modal:!1,dir:j==="rtl"?"rtl":"ltr",children:[r.jsx(Ae.Anchor,{virtualRef:A}),r.jsxs(Ae.Content,{ref:N,loop:!0,side:o==="above"?"top":"bottom",align:o==="below"?"start":"center",sideOffset:6,collisionPadding:12,updatePositionStrategy:"always","aria-label":w("companion_chats"),"data-companion-chat-picker":"","data-motion":i?"pointer":"instant",onEntryFocus:E=>{var I,W,$;E.preventDefault(),c?(W=(I=v.current)==null?void 0:I.querySelector('[aria-checked="true"]'))==null||W.focus({preventScroll:!0}):(R.current=!0,($=k.current)==null||$.focus({preventScroll:!0}),R.current=!1)},onCloseAutoFocus:E=>{E.preventDefault()},onEscapeKeyDown:E=>{E.preventDefault(),t.focus({preventScroll:!0}),T.current.onClose(!0)},onFocusOutside:E=>{var I,W;((I=v.current)!=null&&I.contains(E.detail.originalEvent.target)||E.detail.originalEvent.target===t||E.detail.originalEvent.target===((W=t.ownerDocument.defaultView)==null?void 0:W.frameElement)||!c&&E.detail.originalEvent.target===k.current)&&E.preventDefault()},onInteractOutside:E=>{E.detail.originalEvent.composedPath().includes(t)&&E.preventDefault()},onPointerEnter:l,onPointerLeave:m,onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>E.stopPropagation(),onKeyDown:E=>{E.key==="Tab"&&(E.preventDefault(),t.focus({preventScroll:!0}),T.current.onClose(!0))},style:{...b,zIndex:_.widgetContentContainer.zIndex+1,boxSizing:"border-box",width:"min(248px, calc(100vw - 24px))",maxHeight:"min(360px, var(--radix-popper-available-height))",padding:6,borderRadius:10,border:"1px solid hsl(var(--opencx-border) / .5)",background:"hsl(var(--opencx-background))",color:"hsl(var(--opencx-foreground))",boxShadow:"0 4px 16px rgb(0 0 0 / .08), 0 1px 3px rgb(0 0 0 / .06)",font:"13px/1.4 ui-sans-serif, system-ui, sans-serif",overflowY:"auto",outline:"none"},children:[r.jsx(lo,{}),r.jsx("style",{children:`
|
|
61
61
|
[data-companion-chat-picker] {
|
|
62
62
|
transform-origin: var(--radix-popper-transform-origin);
|
|
63
|
-
animation: opencx-menu-in ${ge.duration*1e3}ms ${
|
|
63
|
+
animation: opencx-menu-in ${ge.duration*1e3}ms ${Kd};
|
|
64
64
|
}
|
|
65
65
|
[data-companion-chat-picker][data-state="closed"] { animation-name: opencx-menu-out; pointer-events: none; }
|
|
66
66
|
[data-companion-chat-picker][data-motion="instant"] { animation: none; }
|
|
@@ -105,10 +105,10 @@ html, body {
|
|
|
105
105
|
[data-companion-chat-picker] [data-working] { animation: opencx-picker-spin 1.2s linear infinite; }
|
|
106
106
|
@keyframes opencx-picker-spin { to { transform: rotate(360deg); } }
|
|
107
107
|
@media (prefers-reduced-motion: reduce) { [data-companion-chat-picker] [data-working] { animation: none; } }
|
|
108
|
-
`}),r.jsxs(Ae.Label,{style:{display:"flex",justifyContent:"space-between",gap:8,padding:"5px 8px 7px",fontSize:12,color:"hsl(var(--opencx-muted-foreground))"},children:[r.jsx("span",{children:w("companion_chats")}),O>0&&r.jsx("span",{role:"status",children:w("companion_working_chats",{count:O})})]}),r.jsx(Ae.RadioGroup,{value:String(h),children:p.map(E=>r.jsx(Ju,{chat:E,selected:E.id===h,onSelect:()=>P(E.id),onClose:()=>B(E.id)},E.id))}),r.jsx(Ae.Separator,{style:{height:1,background:"hsl(var(--opencx-border) / .4)",margin:"5px 4px"}}),r.jsx(Ae.Group,{children:r.jsx(Ae.Item,{asChild:!0,disabled:!y,onSelect:E=>{E.preventDefault(),P()},children:r.jsxs(X,{variant:"ghost",size:"selfless",type:"button","data-companion-action":"","data-new-chat":"",disabled:!y,children:[r.jsx(M.PlusIcon,{size:14,"aria-hidden":!0}),w("new_conversation")]})})})]})]}),n)}function $n(){const[e,t]=u.useState(null);return u.useEffect(()=>{const n=document.createElement("div");return n.setAttribute("data-opencx-root",""),n.style.display="contents",document.documentElement.appendChild(n),t(n),()=>{n.remove(),t(null)}},[]),ai(e,{scroll:!1}),e}function ep(){const{chats:e,openChats:t,activeId:n}=C.useCompanionChats(),o=e.find(f=>f.id===n),s=co(o),{t:a}=G(),i=lo(),c=$n(),d=s.title,l=t.filter(f=>f.id!==n),m=l.filter(f=>f.working).length,p=`${a("companion_other_sessions",{count:l.length})}${m?` · ${a("companion_working_chats",{count:m})}`:""}`,h=`${a("companion_switch_chat")}: ${d}${l.length?` · ${p}`:""}`;return r.jsxs(r.Fragment,{children:[r.jsxs(Zu,{picker:i,"data-companion-conversation-title":"",className:"flex h-8 min-w-0 max-w-full items-center gap-1.5 rounded-md px-1 text-[13px] leading-5 text-start hover:bg-muted aria-expanded:bg-muted focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring","aria-label":h,children:[o.working&&r.jsx(M.LoaderCircleIcon,{"aria-label":a("companion_working"),className:"size-3.5 shrink-0 animate-spin motion-reduce:animate-none"}),r.jsx("span",{className:"truncate font-medium",children:d}),l.length>0&&r.jsxs("span",{"data-other-session-count":"",role:"status","aria-atomic":"true",className:"flex shrink-0 items-center gap-1 text-[11px] font-normal text-muted-foreground",children:[r.jsx("span",{className:"sr-only",children:p}),m>0&&r.jsx(M.LoaderCircleIcon,{"data-other-sessions-working":"","aria-hidden":!0,className:"size-3 animate-spin motion-reduce:animate-none"}),r.jsxs("span",{"aria-hidden":!0,className:"tabular-nums",children:["+",l.length]})]}),r.jsx(M.ChevronsUpDownIcon,{"aria-hidden":!0,className:"size-3 shrink-0 text-muted-foreground"})]}),i.anchor&&c&&r.jsx(po,{picker:i,portalTarget:c,placement:"below"})]})}function tp(){var n;const e=qe(),t=(n=e.config.customComponents)==null?void 0:n.headerBottom;return t?r.jsx(t,{...e}):null}function np({fallback:e}){var o;const t=qe(),n=(o=t.config.customComponents)==null?void 0:o.headerTitle;return n?r.jsx(n,{...t}):e}function ui(e,t,n){var o,s;switch(e){case"chat":return((o=t==null?void 0:t.chatScreen)==null?void 0:o.headerTitle)??n;case"sessions":return((s=t==null?void 0:t.sessionsScreen)==null?void 0:s.headerTitle)??n;case"welcome":case"home":return n;default:return K.isExhaustive(e,ui.name),n}}function pi(){const{widgetCtx:{org:e}}=C.useWidget(),{routerState:{screen:t}}=C.useWidgetRouter(),{textContent:n}=C.useConfig();return ui(t,n,e.name)}function rp(e){switch(e){case"chat":return L("chat/header");case"sessions":return L("sessions/header");case"welcome":return;case"home":return L("home/header");default:K.isExhaustive(e,pi.name);return}}function op(){const{router:e}=C.useConfig(),{routerState:{screen:t},toLandingScreen:n}=C.useWidgetRouter();return t!=="chat"||e!=null&&e.chatScreenOnly?null:r.jsx(X,{variant:"ghost",size:"fit",className:"rounded-full",onClick:n,children:r.jsx(M.ChevronLeftIcon,{className:"size-4 rtl:-scale-100"})})}function sp({button:e}){const{setIsOpen:t}=C.useWidgetTrigger(),{isSmallScreen:n}=je(),o=qe();if(n&&e.hideOnSmallScreen||!n&&e.hideOnLargeScreen)return null;const s=()=>{var a;e.handleClick?e.handleClick():t(!1),(a=e.onClicked)==null||a.call(e,o)};return r.jsx(X,{variant:"ghost",size:"fit",className:"rounded-full",onClick:s,children:r.jsx(zt,{name:e.icon})})}function Cr({button:e}){const[t,n]=u.useState(!1),{routerState:{screen:o}}=C.useWidgetRouter(),{isSmallScreen:s}=je(),{theme:a}=me(),{setWidth:i,setHeight:c}=di(),d=qe();if(o!=="chat"&&o!=="sessions")return null;const l=(()=>{switch(o){case"chat":return a.screens.chat.height;case"sessions":return a.screens.sessions.height;default:return K.isExhaustive(o,Cr.name),a.screens.chat.height}})(),m=(()=>{switch(o){case"chat":return a.screens.chat.width;case"sessions":return a.screens.sessions.width;default:return K.isExhaustive(o,Cr.name),a.screens.chat.width}})(),p=()=>{var h;n(f=>{const x=!f;return c(x?"100vh":l),i(x?`max(40vw, ${m})`:m),x}),(h=e.onClicked)==null||h.call(e,d)};return s&&e.hideOnSmallScreen||!s&&e.hideOnLargeScreen?null:r.jsx(X,{variant:"ghost",size:"fit",className:"rounded-full",onClick:p,children:r.jsx(zt,{name:e.icon||(t?e.shrinkIcon:e.expandIcon)})})}function mi({button:e}){var w,j;const{close:t}=On(),{widgetCtx:n}=C.useWidget(),{setIsOpen:o}=C.useWidgetTrigger(),{resolveSession:s,sessionState:a}=C.useSessions(),{isSmallScreen:i}=je(),c=qe(),{t:d}=G(),l=!a.session,m=((w=a.session)==null?void 0:w.isOpened)===!1,p=e.onResolved||"stay-in-chat",h=e.behaviorBeforeSessionCreation||"disabled",f=e.behaviorIfSessionIsResolved||"disabled",x=!!(a.isResolvingSession||l&&h==="disabled"||m&&f==="disabled"),g=async()=>{const{success:b,error:_}=await s();if(t(),!b)return K.log.error("failed to resolve session",_),!1;switch(p){case"stay-in-chat":break;case"close-widget":o(!1);break;case"reset-chat":n.resetChat();break;case"reset-chat-and-close-widget":o(!1),n.resetChat();break;default:K.isExhaustive(p,mi.name);break}return!0},y=()=>{if(l)switch(h){case"disabled":return;case"close-widget":o(!1);break;default:K.isExhaustive(h,y.name)}if(m)switch(f){case"disabled":return;case"close-widget":o(!1);break;case"reset-chat":n.resetChat();break;case"reset-chat-and-close-widget":o(!1),setTimeout(()=>{n.resetChat()},200);break;default:K.isExhaustive(f,y.name)}};return i&&e.hideOnSmallScreen||!i&&e.hideOnLargeScreen?null:((j=e.confirmation)==null?void 0:j.type)==="modal"&&!m&&!l?r.jsx(sn,{trigger:r.jsx(X,{variant:"ghost",size:"fit",className:"rounded-full",disabled:x,onClick:()=>{var b;return(b=e.onClicked)==null?void 0:b.call(e,c)},children:r.jsx(zt,{name:e.icon})}),children:r.jsxs(on,{children:[r.jsx(Kr,{children:r.jsx(Jr,{children:e.confirmation.title||d("close_conversation_title")})}),r.jsx(Zr,{children:r.jsx(Qr,{children:e.confirmation.description||d("close_conversation_description")})}),r.jsxs(Qa,{children:[r.jsx(X,{variant:"secondary",onClick:t,disabled:a.isResolvingSession,children:e.confirmation.cancelButtonText||d("close_conversation_cancel")}),r.jsx(X,{variant:"destructive",onClick:async()=>{var _,v;await g()&&((v=(_=e.confirmation)==null?void 0:_.onResolved)==null||v.call(_,c))},disabled:a.isResolvingSession,children:e.confirmation.confirmButtonText||d("close_conversation_confirm")})]})]})}):r.jsx(X,{variant:"ghost",size:"fit",className:"rounded-full",onClick:()=>{var b;m||l?y():g(),(b=e.onClicked)==null||b.call(e,c)},disabled:x,children:r.jsx(zt,{name:e.icon})})}function Sr({button:e}){switch(e.functionality){case"close-widget":return r.jsx(sp,{button:e});case"expand-shrink":return r.jsx(Cr,{button:e});case"resolve-session":return r.jsx(mi,{button:e});default:return K.isExhaustive(e,Sr.name),null}}const ap={functionality:"close-widget",hideOnLargeScreen:!0,icon:"X"};function ip(){const{routerState:{screen:e}}=C.useWidgetRouter(),{headerButtons:t}=C.useConfig(),n=e==="chat"?t==null?void 0:t.chatScreen:e==="sessions"?t==null?void 0:t.sessionsScreen:[];return!n||n.length===0?r.jsx(Sr,{button:ap}):r.jsx(r.Fragment,{children:n.map(o=>r.jsx(Sr,{button:o},`${o.functionality}-${o.icon}`))})}function hi(){const e=C.useConfig(),t=e.displayMode==="companion"&&!e.inline,{routerState:{screen:n}}=C.useWidgetRouter(),o=rp(n),s=pi();return r.jsxs("header",{...o,className:"py-2 px-4 shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2",style:{paddingInlineEnd:t?64:void 0},children:[r.jsx(op,{}),r.jsx("div",{className:z("min-w-0 flex-1 h-8 flex items-center",n==="sessions"&&"ps-2"),children:r.jsx(np,{fallback:t&&n!=="sessions"?r.jsx(ep,{}):r.jsx("h2",{className:"font-semibold",children:s})})}),r.jsx(ip,{})]}),r.jsx(tp,{})]})}function fi({className:e}){return r.jsx(M.LoaderIcon,{className:z("size-4 animate-spin",e)})}function cp(){const{messagesState:{isInitialFetchLoading:e}}=C.useMessages(),{isSmallScreen:t}=je(),{activeMode:n,Component:o}=C.useModes();return{isCanvasOpen:!e&&!t&&!!n&&!!o}}function lp({isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n,...o}){const{componentStore:s}=C.useWidget();if(o.type!=="AGENT"&&o.type!=="AI")return null;if(o.data.action){const i=s.getComponent(o.data.action.name);if(i)return r.jsx(i,{...o,id:o.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}const a=s.getComponent(o.component);return a?r.jsx(a,{...o,id:o.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n}):r.jsx(kr,{...o,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}function Yt({suggestion:e,className:t,...n}){const o=an(),s=()=>{const a=e.trim();a&&o({content:a})};return r.jsx(X,{...L("chat/suggested_reply_btn"),size:"sm",className:z("rounded-xl w-fit",t),...n,onClick:s,children:e})}function gi({messages:e,className:t,containerClassName:n}){var i,c;const{timestamps:o}=C.useConfig();if(!((i=o==null?void 0:o.perMessageGroup)!=null&&i.enabled))return null;const s=(c=e[e.length-1])==null?void 0:c.timestamp;if(!s)return null;const a=(()=>{try{return new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}catch(d){return K.log.error("failed to format timestamp",d),null}})();return a?r.jsx("div",{className:n,children:r.jsx("span",{className:z("text-xs text-muted-foreground",t),children:a})}):null}const dp=2e3;function up(e){return e.map(t=>ri(t.data.message).trim()).filter(t=>t.length>0).join(`
|
|
108
|
+
`}),r.jsxs(Ae.Label,{style:{display:"flex",justifyContent:"space-between",gap:8,padding:"5px 8px 7px",fontSize:12,color:"hsl(var(--opencx-muted-foreground))"},children:[r.jsx("span",{children:w("companion_chats")}),O>0&&r.jsx("span",{role:"status",children:w("companion_working_chats",{count:O})})]}),r.jsx(Ae.RadioGroup,{value:String(h),children:p.map(E=>r.jsx(Vu,{chat:E,selected:E.id===h,onSelect:()=>P(E.id),onClose:()=>B(E.id)},E.id))}),r.jsx(Ae.Separator,{style:{height:1,background:"hsl(var(--opencx-border) / .4)",margin:"5px 4px"}}),r.jsx(Ae.Group,{children:r.jsx(Ae.Item,{asChild:!0,disabled:!y,onSelect:E=>{E.preventDefault(),P()},children:r.jsxs(X,{variant:"ghost",size:"selfless",type:"button","data-companion-action":"","data-new-chat":"",disabled:!y,children:[r.jsx(M.PlusIcon,{size:14,"aria-hidden":!0}),w("new_conversation")]})})})]})]}),n)}function $n(){const[e,t]=u.useState(null);return u.useEffect(()=>{const n=document.createElement("div");return n.setAttribute("data-opencx-root",""),n.style.display="contents",document.documentElement.appendChild(n),t(n),()=>{n.remove(),t(null)}},[]),si(e,{scroll:!1}),e}function Xu(){const{chats:e,openChats:t,activeId:n}=C.useCompanionChats(),o=e.find(f=>f.id===n),s=io(o),{t:a}=G(),i=co(),c=$n(),d=s.title,l=t.filter(f=>f.id!==n),m=l.filter(f=>f.working).length,p=`${a("companion_other_sessions",{count:l.length})}${m?` · ${a("companion_working_chats",{count:m})}`:""}`,h=`${a("companion_switch_chat")}: ${d}${l.length?` · ${p}`:""}`;return r.jsxs(r.Fragment,{children:[r.jsxs(qu,{picker:i,"data-companion-conversation-title":"",className:"flex h-8 min-w-0 max-w-full items-center gap-1.5 rounded-md px-1 text-[13px] leading-5 text-start hover:bg-muted aria-expanded:bg-muted focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring","aria-label":h,children:[o.working&&r.jsx(M.LoaderCircleIcon,{"aria-label":a("companion_working"),className:"size-3.5 shrink-0 animate-spin motion-reduce:animate-none"}),r.jsx("span",{className:"truncate font-medium",children:d}),l.length>0&&r.jsxs("span",{"data-other-session-count":"",role:"status","aria-atomic":"true",className:"flex shrink-0 items-center gap-1 text-[11px] font-normal text-muted-foreground",children:[r.jsx("span",{className:"sr-only",children:p}),m>0&&r.jsx(M.LoaderCircleIcon,{"data-other-sessions-working":"","aria-hidden":!0,className:"size-3 animate-spin motion-reduce:animate-none"}),r.jsxs("span",{"aria-hidden":!0,className:"tabular-nums",children:["+",l.length]})]}),r.jsx(M.ChevronsUpDownIcon,{"aria-hidden":!0,className:"size-3 shrink-0 text-muted-foreground"})]}),i.anchor&&c&&r.jsx(uo,{picker:i,portalTarget:c,placement:"below"})]})}function Gu(){var n;const e=qe(),t=(n=e.config.customComponents)==null?void 0:n.headerBottom;return t?r.jsx(t,{...e}):null}function Ku({fallback:e}){var o;const t=qe(),n=(o=t.config.customComponents)==null?void 0:o.headerTitle;return n?r.jsx(n,{...t}):e}function di(e,t,n){var o,s;switch(e){case"chat":return((o=t==null?void 0:t.chatScreen)==null?void 0:o.headerTitle)??n;case"sessions":return((s=t==null?void 0:t.sessionsScreen)==null?void 0:s.headerTitle)??n;case"welcome":case"home":return n;default:return K.isExhaustive(e,di.name),n}}function ui(){const{widgetCtx:{org:e}}=C.useWidget(),{routerState:{screen:t}}=C.useWidgetRouter(),{textContent:n}=C.useConfig();return di(t,n,e.name)}function Zu(e){switch(e){case"chat":return L("chat/header");case"sessions":return L("sessions/header");case"welcome":return;case"home":return L("home/header");default:K.isExhaustive(e,ui.name);return}}function Ju(){const{router:e}=C.useConfig(),{routerState:{screen:t},toLandingScreen:n}=C.useWidgetRouter();return t!=="chat"||e!=null&&e.chatScreenOnly?null:r.jsx(X,{variant:"ghost",size:"fit",className:"rounded-full",onClick:n,children:r.jsx(M.ChevronLeftIcon,{className:"size-4 rtl:-scale-100"})})}function Qu({button:e}){const{setIsOpen:t}=C.useWidgetTrigger(),{isSmallScreen:n}=je(),o=qe();if(n&&e.hideOnSmallScreen||!n&&e.hideOnLargeScreen)return null;const s=()=>{var a;e.handleClick?e.handleClick():t(!1),(a=e.onClicked)==null||a.call(e,o)};return r.jsx(X,{variant:"ghost",size:"fit",className:"rounded-full",onClick:s,children:r.jsx(zt,{name:e.icon})})}function jr({button:e}){const[t,n]=u.useState(!1),{routerState:{screen:o}}=C.useWidgetRouter(),{isSmallScreen:s}=je(),{theme:a}=me(),{setWidth:i,setHeight:c}=li(),d=qe();if(o!=="chat"&&o!=="sessions")return null;const l=(()=>{switch(o){case"chat":return a.screens.chat.height;case"sessions":return a.screens.sessions.height;default:return K.isExhaustive(o,jr.name),a.screens.chat.height}})(),m=(()=>{switch(o){case"chat":return a.screens.chat.width;case"sessions":return a.screens.sessions.width;default:return K.isExhaustive(o,jr.name),a.screens.chat.width}})(),p=()=>{var h;n(f=>{const x=!f;return c(x?"100vh":l),i(x?`max(40vw, ${m})`:m),x}),(h=e.onClicked)==null||h.call(e,d)};return s&&e.hideOnSmallScreen||!s&&e.hideOnLargeScreen?null:r.jsx(X,{variant:"ghost",size:"fit",className:"rounded-full",onClick:p,children:r.jsx(zt,{name:e.icon||(t?e.shrinkIcon:e.expandIcon)})})}function pi({button:e}){var w,j;const{close:t}=On(),{widgetCtx:n}=C.useWidget(),{setIsOpen:o}=C.useWidgetTrigger(),{resolveSession:s,sessionState:a}=C.useSessions(),{isSmallScreen:i}=je(),c=qe(),{t:d}=G(),l=!a.session,m=((w=a.session)==null?void 0:w.isOpened)===!1,p=e.onResolved||"stay-in-chat",h=e.behaviorBeforeSessionCreation||"disabled",f=e.behaviorIfSessionIsResolved||"disabled",x=!!(a.isResolvingSession||l&&h==="disabled"||m&&f==="disabled"),g=async()=>{const{success:b,error:_}=await s();if(t(),!b)return K.log.error("failed to resolve session",_),!1;switch(p){case"stay-in-chat":break;case"close-widget":o(!1);break;case"reset-chat":n.resetChat();break;case"reset-chat-and-close-widget":o(!1),n.resetChat();break;default:K.isExhaustive(p,pi.name);break}return!0},y=()=>{if(l)switch(h){case"disabled":return;case"close-widget":o(!1);break;default:K.isExhaustive(h,y.name)}if(m)switch(f){case"disabled":return;case"close-widget":o(!1);break;case"reset-chat":n.resetChat();break;case"reset-chat-and-close-widget":o(!1),setTimeout(()=>{n.resetChat()},200);break;default:K.isExhaustive(f,y.name)}};return i&&e.hideOnSmallScreen||!i&&e.hideOnLargeScreen?null:((j=e.confirmation)==null?void 0:j.type)==="modal"&&!m&&!l?r.jsx(sn,{trigger:r.jsx(X,{variant:"ghost",size:"fit",className:"rounded-full",disabled:x,onClick:()=>{var b;return(b=e.onClicked)==null?void 0:b.call(e,c)},children:r.jsx(zt,{name:e.icon})}),children:r.jsxs(on,{children:[r.jsx(Gr,{children:r.jsx(Zr,{children:e.confirmation.title||d("close_conversation_title")})}),r.jsx(Kr,{children:r.jsx(Jr,{children:e.confirmation.description||d("close_conversation_description")})}),r.jsxs(Ja,{children:[r.jsx(X,{variant:"secondary",onClick:t,disabled:a.isResolvingSession,children:e.confirmation.cancelButtonText||d("close_conversation_cancel")}),r.jsx(X,{variant:"destructive",onClick:async()=>{var _,v;await g()&&((v=(_=e.confirmation)==null?void 0:_.onResolved)==null||v.call(_,c))},disabled:a.isResolvingSession,children:e.confirmation.confirmButtonText||d("close_conversation_confirm")})]})]})}):r.jsx(X,{variant:"ghost",size:"fit",className:"rounded-full",onClick:()=>{var b;m||l?y():g(),(b=e.onClicked)==null||b.call(e,c)},disabled:x,children:r.jsx(zt,{name:e.icon})})}function Cr({button:e}){switch(e.functionality){case"close-widget":return r.jsx(Qu,{button:e});case"expand-shrink":return r.jsx(jr,{button:e});case"resolve-session":return r.jsx(pi,{button:e});default:return K.isExhaustive(e,Cr.name),null}}const ep={functionality:"close-widget",hideOnLargeScreen:!0,icon:"X"};function tp(){const{routerState:{screen:e}}=C.useWidgetRouter(),{headerButtons:t}=C.useConfig(),n=e==="chat"?t==null?void 0:t.chatScreen:e==="sessions"?t==null?void 0:t.sessionsScreen:[];return!n||n.length===0?r.jsx(Cr,{button:ep}):r.jsx(r.Fragment,{children:n.map(o=>r.jsx(Cr,{button:o},`${o.functionality}-${o.icon}`))})}function mi(){const e=C.useConfig(),t=e.displayMode==="companion"&&!e.inline,{routerState:{screen:n}}=C.useWidgetRouter(),o=Zu(n),s=ui();return r.jsxs("header",{...o,className:"py-2 px-4 shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2",style:{paddingInlineEnd:t?64:void 0},children:[r.jsx(Ju,{}),r.jsx("div",{className:z("min-w-0 flex-1 h-8 flex items-center",n==="sessions"&&"ps-2"),children:r.jsx(Ku,{fallback:t&&n!=="sessions"?r.jsx(Xu,{}):r.jsx("h2",{className:"font-semibold",children:s})})}),r.jsx(tp,{})]}),r.jsx(Gu,{})]})}function hi({className:e}){return r.jsx(M.LoaderIcon,{className:z("size-4 animate-spin",e)})}function np(){const{messagesState:{isInitialFetchLoading:e}}=C.useMessages(),{isSmallScreen:t}=je(),{activeMode:n,Component:o}=C.useModes();return{isCanvasOpen:!e&&!t&&!!n&&!!o}}function rp({isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n,...o}){const{componentStore:s}=C.useWidget();if(o.type!=="AGENT"&&o.type!=="AI")return null;if(o.data.action){const i=s.getComponent(o.data.action.name);if(i)return r.jsx(i,{...o,id:o.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}const a=s.getComponent(o.component);return a?r.jsx(a,{...o,id:o.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n}):r.jsx(yr,{...o,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}function Yt({suggestion:e,className:t,...n}){const o=an(),s=()=>{const a=e.trim();a&&o({content:a})};return r.jsx(X,{...L("chat/suggested_reply_btn"),size:"sm",className:z("rounded-xl w-fit",t),...n,onClick:s,children:e})}function fi({messages:e,className:t,containerClassName:n}){var i,c;const{timestamps:o}=C.useConfig();if(!((i=o==null?void 0:o.perMessageGroup)!=null&&i.enabled))return null;const s=(c=e[e.length-1])==null?void 0:c.timestamp;if(!s)return null;const a=(()=>{try{return new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}catch(d){return K.log.error("failed to format timestamp",d),null}})();return a?r.jsx("div",{className:n,children:r.jsx("span",{className:z("text-xs text-muted-foreground",t),children:a})}):null}const op=2e3;function sp(e){return e.map(t=>ni(t.data.message).trim()).filter(t=>t.length>0).join(`
|
|
109
109
|
|
|
110
|
-
`)}function xi(){const{messageActions:e}=C.useConfig(),t=C.useDisplayMode();return(e==null?void 0:e.copy)??t==="companion"}function bi({messages:e}){const{t}=G(),{messageActions:n}=C.useConfig(),o=(n==null?void 0:n.display)==="always",[s,a]=u.useState(!1),i=u.useRef(null);u.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const c=up(e),d=typeof navigator<"u"?navigator.clipboard:void 0;if(!d||c.length===0)return null;const l=()=>{d.writeText(c).then(()=>{a(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>a(!1),dp)},p=>K.log.warn("copying the reply failed",p))},m=t(s?"copied":"copy_reply");return r.jsx("div",{...L("chat/agent_msg_group/actions"),className:z("flex items-center gap-1 -mt-0.5 transition-opacity duration-150",o?"opacity-100":z("opacity-0 group-hover:opacity-100 focus-within:opacity-100","[@media(hover:none)]:opacity-100")),children:r.jsx(Ne,{content:m,side:"bottom",align:"start",children:r.jsx("button",{...L("chat/agent_msg_group/actions/copy"),type:"button","aria-label":m,"aria-live":"polite",onClick:l,className:z("flex size-6 items-center justify-center rounded-md","text-muted-foreground/70 hover:bg-muted hover:text-foreground","transition-colors active:scale-95"),children:s?r.jsx(M.CheckIcon,{className:"size-3.5"}):r.jsx(M.CopyIcon,{className:"size-3.5"})})})})}function pp(e){return e.type==="AI"&&e.data.variant!=="error"}function Xt({messages:e,agent:t,suggestedReplies:n,actions:o=!0}){const s=xi(),a=e.filter(pp);return r.jsxs("div",{...L("chat/agent_msg_group/root"),className:z("group flex items-end gap-2"),children:[r.jsx(Ne,{content:t==null?void 0:t.name,side:"right",align:"end",children:r.jsx(jr,{...L("chat/agent_msg_group/root/avatar"),agent:t,className:"hidden"})}),r.jsxs("div",{className:z("flex-1 flex flex-col gap-1"),children:[r.jsxs("div",{...L("chat/agent_msg_group/avatar_and_msgs/root"),className:z("flex items-end gap-2"),children:[r.jsx(Ne,{content:t==null?void 0:t.name,side:"right",align:"end",children:r.jsx(jr,{...L("chat/agent_msg_group/avatar_and_msgs/avatar"),agent:t})}),r.jsxs("div",{...L("chat/agent_msg_group/avatar_and_msgs/msgs"),className:z("flex-1 flex flex-col gap-1"),children:[e.map((i,c,d)=>r.jsx(lp,{isFirstInGroup:c===0,isLastInGroup:c===d.length-1,isAloneInGroup:d.length===1,...i},i.id)),r.jsx(gi,{messages:e}),o&&s&&a.length>0&&r.jsx(bi,{messages:a})]})]}),n&&n.length>0&&r.jsx("div",{...L("chat/agent_msg_group/suggestions"),className:z("flex flex-col gap-1 ps-8"),children:n==null?void 0:n.map((i,c)=>r.jsx(Yt,{suggestion:i},`${i}-${c}`))})]})]})}const us=["⠏","⠗","⠧","⠷","⠾","⠽","⠻","⠟"];function mo({className:e}){const t=F.useReducedMotion(),[n,o]=u.useState(0);return u.useEffect(()=>{if(t)return;const s=setInterval(()=>o(a=>(a+1)%us.length),80);return()=>clearInterval(s)},[t]),r.jsx("span",{className:z("select-none",e),"aria-hidden":!0,children:us[n]})}function ps({turn:e,agent:t,timestamp:n}){const{componentStore:o,config:s,widgetCtx:a}=C.useWidget(),i=xi(),c=o.getComponent("agent_chat_steps"),d=o.getComponent("agent_chat_spec"),l=o.getComponent("loading"),[m]=u.useState(()=>new Date().toISOString()),p=n??m,h=K.resolveClientPresentation(a.agent.presentation,s.presentation),f=C.applyPresentation(e.items,h),x=e.active&&(h==null?void 0:h.streaming)===!1&&!f.some(g=>g.kind==="questions");return r.jsxs("div",{...L("chat/streaming_turn/root"),className:"group flex flex-col gap-2",children:[f.map((g,y)=>g.kind==="text"?r.jsx(Xt,{messages:[{id:`streaming-${y}`,type:"AI",component:"bot_message",timestamp:p,data:{message:g.text},agent:t}],agent:t,actions:!1},`text-${y}`):g.kind==="spec"?d&&r.jsx(d,{parts:g.parts,active:e.active},`spec-${y}`):g.kind==="questions"||g.kind==="plan"||g.kind==="connection"?null:c&&r.jsx(c,{active:e.active,steps:g.steps},`steps-${y}`)),x&&l?r.jsx(l,{agent:t}):e.active&&!mp(f)&&r.jsx("div",{...L("chat/streaming_turn/working"),className:"flex h-5 items-center ps-1",children:r.jsx(mo,{className:"text-[14px] leading-none text-primary/70"})}),!e.active&&i&&r.jsx(bi,{messages:f.flatMap(g=>g.kind==="text"?[{data:{message:g.text}}]:[])})]})}function mp(e){const t=e.at(-1);return(t==null?void 0:t.kind)==="steps"&&t.steps.some(n=>!n.done)}function hp({parts:e,active:t=!1}){const n=u.useMemo(()=>Qd(e),[e]);return r.jsx(Xa,{spec:n,active:t})}function fp({plan:e,active:t}){const[n,o]=u.useState(!1),s=u.useId(),a=F.useReducedMotion(),i=e.filter(m=>m.status==="completed").length,c=e.find(m=>m.status==="in_progress")??e.find(m=>m.status==="pending")??e[0],d=2*Math.PI*8,l=d*(1-(e.length>0?i/e.length:0));return r.jsxs("div",{className:"overflow-hidden rounded-xl border border-primary/10 bg-background shadow-sm","data-task-plan":!0,children:[r.jsxs("button",{type:"button",onClick:()=>o(m=>!m),"aria-expanded":n,"aria-controls":s,className:"flex w-full cursor-pointer items-center gap-3 px-3.5 py-2.5 text-start hover:bg-primary/[0.02] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary/40",children:[r.jsxs("svg",{"aria-hidden":"true",className:"size-5 shrink-0 -rotate-90",viewBox:"0 0 20 20",children:[r.jsx("circle",{cx:"10",cy:"10",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-primary/10"}),r.jsx(F.motion.circle,{cx:"10",cy:"10",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeDasharray:d,initial:!1,animate:{strokeDashoffset:l},transition:a?{duration:0}:ke,className:"text-emerald-600 dark:text-emerald-400"})]}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-primary",children:c==null?void 0:c.step}),r.jsxs("span",{className:"shrink-0 text-[0.8125rem] tabular-nums text-primary/50",children:[i,"/",e.length]}),r.jsx(F.motion.span,{"aria-hidden":"true",className:"flex size-3.5 shrink-0 items-center justify-center text-primary/50",initial:!1,animate:{rotate:n?0:180},transition:a?{duration:0}:ge,children:r.jsx(M.ChevronUp,{className:"size-3.5"})})]}),r.jsx("div",{id:s,"aria-hidden":!n,children:r.jsx(F.AnimatePresence,{initial:!1,children:n&&r.jsx(F.motion.div,{initial:{height:a?"auto":0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:a?"auto":0,opacity:0,transition:ge},transition:a?ge:ke,className:"overflow-hidden",children:r.jsx("ol",{className:"max-h-60 overflow-y-auto border-t border-primary/10 px-3.5 py-2",children:e.map((m,p)=>r.jsxs("li",{className:"flex items-start gap-2.5 py-1.5 text-sm","data-plan-status":m.status,children:[r.jsx("span",{"aria-hidden":"true",className:z("relative mt-0.5 size-4 shrink-0",!t&&"[&_.animate-spin]:animate-none"),children:r.jsx(F.AnimatePresence,{initial:!1,children:r.jsx(F.motion.span,{className:"absolute inset-0 flex items-center justify-center",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:ge,children:m.status==="completed"?r.jsx("span",{className:"flex size-4 items-center justify-center rounded-full bg-emerald-500/10",children:r.jsx(M.Check,{className:"size-2.5 text-emerald-600 dark:text-emerald-400"})}):m.status==="in_progress"?t?r.jsx(M.Loader2,{className:"size-4 animate-spin text-primary/60 motion-reduce:animate-none"}):r.jsx(M.CircleDashed,{className:"size-4 text-primary/40"}):r.jsx("span",{className:"size-1.5 rounded-full bg-primary/25"})},m.status)})}),r.jsx("span",{className:z(m.status==="completed"?"text-primary/50 line-through":m.status==="in_progress"?"font-medium text-primary":"text-primary/60"),children:m.step})]},p))})},"plan-steps")})})]})}function wi(){var n,o;const e=qe();if((n=e.session)!=null&&n.isOpened||!e.session)return null;const t=(o=e.config.customComponents)==null?void 0:o.onSessionResolved;return t?r.jsx(t,{...e}):null}function vi(){var n;const e=qe(),t=(n=e.config.customComponents)==null?void 0:n.chatBottomComponents;return t?r.jsx("div",{children:t.map(({key:o,component:s})=>r.jsx(s,{...e},o))}):null}function yi(e){const t=[];let n=null;return e.forEach(o=>{var s,a,i,c,d,l;(((s=n==null?void 0:n[0])==null?void 0:s.type)!==o.type||((a=n[0])==null?void 0:a.type)==="AGENT"&&o.type==="AGENT"&&(((i=o.agent)==null?void 0:i.id)!==((c=n[0].agent)==null?void 0:c.id)||((d=o.agent)==null?void 0:d.name)!==((l=n[0].agent)==null?void 0:l.name)))&&(n=[],t.push(n)),n.push(o)}),t}function Nr(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="USER"}function gp(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="AI"}function xp(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="AGENT"}function ki(){const{messagesState:{messages:e}}=C.useMessages(),{chatBannerItems:t}=C.useConfig();return!(t!=null&&t.length)||e.length>0&&t.every(n=>!n.persistent)?null:r.jsx("div",{className:"w-full text-center text-xs",children:t.map(({message:n,persistent:o},s)=>e.length>0&&!o?null:r.jsx("div",{children:r.jsx(eo,{children:n})},`${n}-${s}`))})}const bp=10*1024,ms=new Map;function wp(e){const t=ms.get(e);if(t!==void 0)return t;const n=vp(e);return ms.set(e,n),n}function vp(e){const t=e.trim();if(!t||t.length>bp||typeof DOMParser>"u")return null;const n=new DOMParser().parseFromString(t,"image/svg+xml"),o=n.documentElement;return o.localName!=="svg"||o.namespaceURI!=="http://www.w3.org/2000/svg"||n.getElementsByTagName("parsererror").length>0?null:`data:image/svg+xml,${encodeURIComponent(t)}`}const yp=ca.cva("inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium transition-colors",{variants:{variant:{default:"bg-primary text-primary-foreground",secondary:"bg-secondary text-secondary-foreground",outline:"border text-foreground"}},defaultVariants:{variant:"default"}});function kp({className:e,variant:t,...n}){return r.jsx("div",{className:z(yp({variant:t}),e),...n})}function ji({customStatus:e,className:t,dotClassName:n}){const o=e.icon?wp(e.icon):null,s=e.color||"currentColor";return o?r.jsx("span",{"aria-hidden":!0,className:z("size-3.5 shrink-0",t),style:{backgroundColor:s,maskImage:`url("${o}")`,maskSize:"contain",maskRepeat:"no-repeat",maskPosition:"center",WebkitMaskImage:`url("${o}")`,WebkitMaskSize:"contain",WebkitMaskRepeat:"no-repeat",WebkitMaskPosition:"center"}}):r.jsx("span",{"aria-hidden":!0,className:z("size-2 shrink-0 rounded-full",n),style:{backgroundColor:s}})}function Ci({customStatus:e,className:t}){return r.jsxs(kp,{variant:"secondary",className:z("relative isolate overflow-hidden max-w-full text-primary",t),title:e.description||void 0,style:e.color?{color:`color-mix(in srgb, ${e.color} 55%, hsl(var(--opencx-foreground)))`}:void 0,children:[e.color&&r.jsx("span",{"aria-hidden":!0,className:"absolute inset-0 -z-10 opacity-20",style:{backgroundColor:e.color}}),r.jsx(ji,{customStatus:e}),r.jsx("span",{className:"truncate",children:e.name})]})}function Si(){const{sessionState:{session:e}}=C.useSessions(),t=e==null?void 0:e.customStatus;return r.jsx(F.AnimatePresence,{mode:"wait",children:t&&r.jsx(oe,{className:"sticky top-2 z-10 self-center max-w-full",snapExit:!0,children:r.jsx(sn,{trigger:r.jsx(X,{variant:"ghost",size:"selfless",className:"rounded-full",children:r.jsx(Ci,{customStatus:t})}),children:r.jsxs(on,{withClose:!0,children:[r.jsxs(Kr,{children:[r.jsx(ji,{customStatus:t,className:"size-8 mx-auto",dotClassName:"size-3 mx-auto"}),r.jsx(Jr,{children:t.name})]}),t.description&&r.jsx(Zr,{children:r.jsx(Qr,{children:t.description})})]})})},t.id)})}function Ni({src:e,alt:t,title:n,note:o,shape:s="strip",className:a,children:i,...c}){const d=s==="tile";return r.jsxs("div",{...c,className:z("relative overflow-hidden bg-background ring-1 ring-border",d?"size-12 shrink-0 rounded-2xl":"max-w-full rounded-xl",a),children:[r.jsx("img",{src:e,alt:t,title:n,draggable:!1,className:z("block object-cover object-left-top",d?"size-full":"h-10 w-auto max-w-40")}),o&&r.jsx("div",{className:z("absolute inset-x-0 bottom-0 truncate px-1.5 py-0.5","bg-gradient-to-t from-foreground/70 to-foreground/0","text-[10px] font-medium leading-tight text-background"),children:o}),i]})}const ho=["#opencx-root","[data-opencx-root]","[data-opencx-overlay]"],gt='input,textarea,select,[contenteditable]:not([contenteditable="false"]),[role="textbox"],[role="searchbox"],[role="combobox"]',jp=[...ho,"[data-opencx-private]",'[aria-hidden="true"]',"[hidden]","script","style","noscript"].join(",");function _i(e){var n;if(e.matches(jp))return!0;const t=(n=e.ownerDocument.defaultView)==null?void 0:n.getComputedStyle(e);return(t==null?void 0:t.display)==="none"||(t==null?void 0:t.visibility)==="hidden"||(t==null?void 0:t.visibility)==="collapse"||(t==null?void 0:t.opacity)==="0"}function Me(e){for(let t=e;t;t=t.parentElement)if(_i(t))return!0;return!1}function Ei(e){if(Me(e)||e.closest(gt))return"";const t=[],n=o=>{if(o instanceof Element){if(o!==e&&_i(o)||o.matches(gt))return;const s=/^(ADDRESS|ARTICLE|ASIDE|BLOCKQUOTE|BR|DD|DETAILS|DIV|DL|DT|FIELDSET|FIGCAPTION|FIGURE|FOOTER|FORM|H[1-6]|HEADER|HR|LI|MAIN|NAV|OL|P|PRE|SECTION|SUMMARY|TABLE|TD|TH|TR|UL)$/.test(o.tagName);s&&t.push(" "),o.childNodes.forEach(n),s&&t.push(" ")}else o.nodeType===Node.TEXT_NODE&&t.push(o.textContent??"")};return n(e),t.join("").replace(/\s+/g," ").trim()}function fo(e){try{const t=new URL(e,window.location.href);return t.protocol==="http:"||t.protocol==="https:"?`${t.origin}${t.pathname}`:""}catch{return""}}function Gt(e){return e.getRootNode()===document&&!Me(e)&&!e.closest(gt)&&!e.matches("canvas,iframe,video,object,embed")&&!Array.from(e.querySelectorAll("*")).some(t=>Me(t)||t.matches(`${gt},canvas,iframe,video,object,embed`))}const Cp=480,Sp=3e3,Kt=new WeakMap,_r=new WeakMap;async function Np(e){if(!Gt(e))return null;const t=e.getBoundingClientRect();if(t.width<1||t.height<1)return null;const n=Math.min(2,Math.max(.5,Cp/Math.max(t.width,t.height))),o=Vc.toJpeg(e,{quality:.85,pixelRatio:n,backgroundColor:"#ffffff",filter:a=>!(a instanceof Element)||Gt(a)}),s=new Promise(a=>setTimeout(()=>a(null),Sp));try{return await Promise.race([o,s])}catch{return null}}function _p(e,t){_r.set(e,t),Kt.set(e,Np(t))}const Er=new WeakMap;function Ep(e,t){if(Er.has(e))return;const n=Kt.get(e);if(!n)return;const o=n.then(s=>{const a=_r.get(e);if(!(a!=null&&a.isConnected)||!Gt(a))return null;const i=s?Tp(s,"page-mark.jpg"):null;return i?t(i):null}).catch(()=>null).then(s=>{const a=_r.get(e);return!(a!=null&&a.isConnected)||!Gt(a)?null:(s&&(e.snapshotUrl=s),s)});Er.set(e,o)}async function Ap(e,t){if(e.snapshotUrl)return e.snapshotUrl;const n=Er.get(e);if(!n)return null;const o=new Promise(s=>setTimeout(()=>s(null),t));return Promise.race([n,o])}function Tp(e,t){const n=/^data:([^;,]+);base64,([\s\S]*)$/.exec(e);if(!n)return null;const[,o,s]=n;if(!o||s===void 0)return null;try{const a=atob(s),i=new Uint8Array(a.length);for(let c=0;c<a.length;c++)i[c]=a.charCodeAt(c);return new File([i],t,{type:o})}catch{return null}}function Ip(e){return Kt.get(e)}function zp(e,t){const n=Kt.get(e);n&&Kt.set(t,n)}function Ai(e){const[t,n]=u.useState(null);return u.useEffect(()=>{var s;if(n(null),!e)return;let o=!1;return(s=Ip(e))==null||s.then(a=>{!o&&a&&n(a)}),()=>{o=!0}},[e]),t}function Mp({element:e}){const t=Ai(e.mark)??e.snapshotUrl??null,n=e.note??e.name;return t?r.jsx(Ni,{src:t,alt:n,title:e.name,note:e.note}):r.jsxs("span",{className:z("inline-flex items-center gap-1.5 max-w-48","rounded-full py-1 ps-2 pe-2.5","bg-background ring-1 ring-border","text-xs text-foreground"),title:e.name,children:[r.jsx(M.PenLineIcon,{className:"size-3 shrink-0 text-primary"}),r.jsx("span",{className:"truncate",children:n})]})}const Rp=150,Pp=40,Op=3;function Lp(e,t){const n=new Map;for(const a of e){const i=n.get(a.type);i?i.push(a):n.set(a.type,[a])}const o=[],s=[];for(const[a,i]of Array.from(n)){const c=t.has(a)?i:i.slice(0,Op);o.push({type:a,items:c,hidden:i.length-c.length}),s.push(...c)}return{groups:o,visible:s}}function $p(e,t){const n=e.slice(0,t),o=/(?:^|\s)@(\S*)$/.exec(n);return o?{start:t-o[1].length-1,query:o[1]}:null}function Dp(e,t){const n=t.trim().toLowerCase();if(!n)return[...e];const o=s=>{var i;const a=s.title.toLowerCase();return a.startsWith(n)?0:a.includes(n)?1:(i=s.description)!=null&&i.toLowerCase().includes(n)?2:-1};return e.map((s,a)=>({item:s,index:a,rank:o(s)})).filter(s=>s.rank>=0).sort((s,a)=>s.rank-a.rank||s.index-a.index).map(s=>s.item)}const Ut=e=>`@${e.title}`;function hs(e,t){const n=[];for(const o of t){const s=Ut(o);let a=0;for(;;){const i=e.indexOf(s,a);if(i===-1)break;n.push({start:i,end:i+s.length}),a=i+s.length}}return n}function Fp({text:e,setText:t,inputRef:n}){const{mentions:o}=C.useConfig(),{widgetCtx:s}=C.useWidget(),a=o==null?void 0:o.items,i=o==null?void 0:o.search,c=u.useMemo(()=>{if(i)return i;if(a)return I=>Dp(a,I)},[i,a]),d=!!c&&s.features.pageContext,{mentions:l,setMentions:m}=C.useComposerDraft(),[p,h]=u.useState(null),[f,x]=u.useState([]),[g,y]=u.useState(()=>new Set),[w,j]=u.useState(0),[b,_]=u.useState(!1),{groups:v,visible:k}=u.useMemo(()=>Lp(f,g),[g,f]);u.useEffect(()=>{m(I=>{const W=I.filter($=>e.includes(Ut($)));return W.length===I.length?I:W})},[e,m]);const N=u.useCallback((I="nearest")=>{if(!d)return;const W=n.current;let $=(W==null?void 0:W.selectionStart)??e.length;if(W&&W.selectionStart===W.selectionEnd){const q=hs(e,l).find(se=>$>se.start&&$<se.end);q&&($=I==="forward"?q.end:I==="backward"||$-q.start<q.end-$?q.start:q.end,W.setSelectionRange($,$))}const U=$p(e,$),Y=U&&l.some(q=>e.startsWith(Ut(q),U.start))?null:U;h(q=>(q==null?void 0:q.start)===(Y==null?void 0:Y.start)&&(q==null?void 0:q.query)===(Y==null?void 0:Y.query)?q:Y)},[d,n,l,e]);u.useEffect(()=>N(),[N]);const R=u.useRef(0);u.useEffect(()=>{if(!p||!c){x([]),_(!1);return}const I=++R.current;_(!0);const W=setTimeout(()=>{Promise.resolve().then(()=>c(p.query)).then($=>{I===R.current&&(x($.slice(0,Pp)),y(new Set),j(0),_(!1))},$=>{I===R.current&&(K.log.warn("mentions search failed",$),x([]),_(!1))})},Rp);return()=>clearTimeout(W)},[p,c]);const T=u.useCallback(()=>{R.current+=1,h(null),x([]),_(!1)},[]),A=u.useCallback(I=>{if(!p)return;const W=p.start+1+p.query.length,$=`${Ut(I)} `,U=e.slice(0,p.start)+$+e.slice(W);t(U),m(q=>q.some(se=>se.type===I.type&&se.id===I.id)?q:[...q,I]),T();const Y=p.start+$.length;requestAnimationFrame(()=>{const q=n.current;q&&(q.focus(),q.setSelectionRange(Y,Y))})},[p,T,n,t,m,e]),O=u.useCallback(I=>{y(W=>new Set(W).add(I))},[]),P=d&&p!==null,B=u.useCallback(I=>{const W=n.current;if(d&&W&&W.selectionStart===W.selectionEnd&&(I.key==="Backspace"||I.key==="Delete")){const $=W.selectionStart,U=hs(e,l).find(Y=>I.key==="Backspace"?Y.end===$:Y.start===$);if(U){I.preventDefault();const Y=e[U.end]===" "?U.end+1:U.end;return t(e.slice(0,U.start)+e.slice(Y)),requestAnimationFrame(()=>W.setSelectionRange(U.start,U.start)),!0}}if(!P)return!1;if(I.key==="Escape")return I.preventDefault(),T(),!0;if(k.length===0)return!1;if(I.key==="ArrowDown")return I.preventDefault(),j($=>($+1)%k.length),!0;if(I.key==="ArrowUp")return I.preventDefault(),j($=>($-1+k.length)%k.length),!0;if(I.key==="Enter"||I.key==="Tab"){I.preventDefault();const $=k[w];return $&&A($),!0}return!1},[T,d,w,n,P,A,l,t,e,k]),E=u.useCallback(()=>{m([]),T()},[T,m]);return u.useMemo(()=>({picked:l,isOpen:P,anchorIndex:(p==null?void 0:p.start)??null,preview:(o==null?void 0:o.preview)!==!1,groups:v,visible:k,expandGroup:O,searching:b,highlighted:w,setHighlighted:j,pick:A,onKeyDown:B,onCaretMove:N,reset:E}),[l,P,p,o==null?void 0:o.preview,v,k,O,b,w,A,B,N,E])}function Ti({text:e,mentions:t,tokenClassName:n}){if(!t||t.length===0)return r.jsx(r.Fragment,{children:e});const o=Array.from(new Set(t.map(Ut))).sort((c,d)=>d.length-c.length),s=[];let a=e,i=0;for(;a.length>0;){let c=-1,d="";for(const l of o){const m=a.indexOf(l);m!==-1&&(c===-1||m<c)&&(c=m,d=l)}if(c===-1){s.push(a);break}c>0&&s.push(a.slice(0,c)),s.push(u.createElement("span",{...L("chat/mention"),key:i++,className:z("rounded-sm px-0.5 -mx-0.5",n)},d)),a=a.slice(c+d.length)}return r.jsx(r.Fragment,{children:s})}function Hp({message:e,isFirstInGroup:t,isLastInGroup:n,isAloneInGroup:o}){var s;return r.jsxs("div",{...L("chat/user_msg/root"),"data-message-id":e.id,className:"w-5/6 flex flex-col items-end gap-1",children:[e.markedElements&&e.markedElements.length>0&&r.jsx("div",{...L("chat/user_msg/marked_elements"),className:"w-full flex gap-1 flex-wrap justify-end",children:e.markedElements.map((a,i)=>r.jsx(Mp,{element:a},`${a.name}-${i}`))}),e.attachments&&e.attachments.length>0&&r.jsx("div",{className:"w-full flex gap-1 flex-wrap justify-end",children:(s=e.attachments)==null?void 0:s.map(a=>r.jsx(ti,{attachment:a},a.id))}),e.content.length>0&&r.jsx("div",{...L("chat/user_msg/msg"),"data-first":t,"data-last":n,"data-alone":o,"data-pending":e.pending===!0,className:z("transition-all","w-fit py-3 px-4 rounded-3xl text-sm","bg-primary text-primary-foreground",e.pending&&"opacity-60","break-words [word-break:break-word]","whitespace-pre-wrap",t&&!o&&"rounded-br-md",n&&!o&&"rounded-tr-md",!t&&!n&&!o&&"rounded-r-md"),children:r.jsx(Ti,{text:e.content,mentions:e.mentions,tokenClassName:"bg-primary-foreground/20 font-medium"})})]})}function Ii({messages:e}){return r.jsxs("div",{...L("chat/user_msg_group/root"),className:z("group","flex flex-col gap-1 justify-end items-end"),children:[e.map((t,n,o)=>r.jsx(Hp,{message:t,isFirstInGroup:n===0,isLastInGroup:n===o.length-1,isAloneInGroup:o.length===1},t.id)),r.jsx(gi,{messages:e,containerClassName:"ms-auto"})]})}function Ar(e){return e.replace(/<[^<>]*>/g," ").replace(/<[^<>]*$/,"").replace(/[ \t]{2,}/g," ").replace(/\s+([،,.؟?!…])/g,"$1").trim()}const Wp={start_call:"Start a voice call",connecting:"Connecting…",waiting:"Getting ready…",queued:"Waiting for the next agent…",listening:"Listening",speaking:"{name} is speaking",reconnecting:"Reconnecting…",ended:"Call ended",mute:"Mute",unmute:"Unmute",end_call:"End call",tap_to_hear:"Tap to hear",back_to_chat:"Back to chat",try_again:"Try again",muted_hint:"You are muted",call_card_title:"Voice call",show_full_transcript:"Show full transcript",show_less:"Show less",transcript_loading:"Loading the transcript…",transcript_empty:"No transcript for this call.",default_agent:"Agent",error_generic:"The call could not connect. Check your microphone and try again.",error_timeout:"No one picked up. Try again in a moment.",error_busy:"A call is already in progress."},Bp={start_call:"ابدأ مكالمة صوتية",connecting:"جارٍ الاتصال…",waiting:"جارٍ التجهيز…",queued:"بانتظار أول موظف متاح…",listening:"أستمع إليك",speaking:"{name} تتحدث",reconnecting:"جارٍ إعادة الاتصال…",ended:"انتهت المكالمة",mute:"كتم الصوت",unmute:"إلغاء الكتم",end_call:"إنهاء المكالمة",tap_to_hear:"اضغط لتسمع",back_to_chat:"العودة إلى المحادثة",try_again:"حاول مجددًا",muted_hint:"الميكروفون مكتوم",call_card_title:"مكالمة صوتية",show_full_transcript:"عرض نص المكالمة كاملًا",show_less:"عرض أقل",transcript_loading:"جارٍ تحميل نص المكالمة…",transcript_empty:"لا يوجد نص لهذه المكالمة.",default_agent:"المساعد",error_generic:"تعذّر الاتصال. تحقّق من الميكروفون وحاول مجددًا.",error_timeout:"لم يردّ أحد. حاول بعد قليل.",error_busy:"هناك مكالمة جارية بالفعل."};function go(e,t,n={}){return(e==="ar"?Bp:Wp)[t].replace(/\{(\w+)\}/g,(s,a)=>n[a]??s)}function Up(e,t){const n={hour:"numeric",minute:"2-digit",numberingSystem:"latn"};try{return new Intl.DateTimeFormat(e,n).format(t)}catch(o){return console.error("Voice call time failed to format",{_e:o,language:e}),new Intl.DateTimeFormat(void 0,n).format(t)}}function zi(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),o=Math.floor(t%3600/60),s=String(t%60).padStart(2,"0");return n>0?`${n}:${String(o).padStart(2,"0")}:${s}`:`${o}:${s}`}const qp=60;function Vp(e,t,n){const o=[];for(const s of t){const a=`voice-call-${e}-${s.id}`,i=s.at>0?new Date(s.at).toISOString():null,c=o.at(-1);if(s.role==="user"){const d={id:a,type:"USER",content:Ar(s.text),deliveredAt:i,timestamp:i};(c==null?void 0:c.role)==="user"?c.messages.push(d):o.push({role:"user",messages:[d]})}else{const d={id:a,type:"AI",component:"bot_message",data:{message:Ar(s.text)},timestamp:i,agent:n};(c==null?void 0:c.role)==="agent"?c.messages.push(d):o.push({role:"agent",messages:[d]})}}return o}function Yp({label:e}){return r.jsxs("div",{...L("chat/voice_call/loading"),role:"status","aria-label":e,className:"flex flex-col gap-2",children:[r.jsx("div",{className:"opencx-voice-skeleton h-10 w-3/4 rounded-3xl"}),r.jsx("div",{className:"opencx-voice-skeleton h-10 w-1/2 self-end rounded-3xl"}),r.jsx("div",{className:"opencx-voice-skeleton h-10 w-2/3 rounded-3xl"})]})}function _n({call:e}){const t=C.useBot(),{language:n}=G(),[o,s]=u.useState(!1),a=m=>go(n,m),i=e.transcript.length>qp,c=i&&!o,d=u.useMemo(()=>Vp(e.id,c?e.transcript.slice(-8):e.transcript,t),[e.id,e.transcript,c,t]),l=a("call_card_title");return r.jsxs("section",{...L("chat/voice_call/root"),"aria-label":l,className:"opencx-fade-up flex flex-col gap-3",children:[r.jsxs("header",{...L("chat/voice_call/header"),className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{"aria-hidden":"true",className:"h-px flex-1 bg-border"}),r.jsx(M.PhoneIcon,{"aria-hidden":"true",className:"size-3 shrink-0"}),r.jsx("span",{className:"font-medium",children:l}),r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx("span",{dir:"ltr",className:"tabular-nums",children:zi(e.durationMs)}),r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx("span",{className:"tabular-nums",children:Up(n,e.startedAt)}),r.jsx("span",{"aria-hidden":"true",className:"h-px flex-1 bg-border"})]}),e.transcriptLoading?r.jsx(Yp,{label:a("transcript_loading")}):e.transcript.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:a("transcript_empty")}):r.jsxs(r.Fragment,{children:[i&&r.jsx("button",{...L("chat/voice_call/toggle"),type:"button","aria-expanded":o,onClick:()=>s(m=>!m),className:"self-center rounded-full px-3 py-1 text-xs font-medium text-muted-foreground transition-colors duration-150 hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:a(o?"show_less":"show_full_transcript")}),r.jsx("div",{className:"flex flex-col gap-2",children:d.map(m=>{var h;const p=(h=m.messages[0])==null?void 0:h.id;return m.role==="user"?r.jsx(Ii,{messages:m.messages},p):r.jsx(Xt,{messages:m.messages,agent:t,actions:!1},p)})})]})]})}const Xp=1200;async function Gp(e,t){const{data:n,error:o}=await e.pollSessionAndHistory({sessionId:t,abortSignal:AbortSignal.timeout(1e4)});if(o||!n)throw new Error("Voice call history request failed");return n.history.flatMap(s=>{var d;const a=(d=s.content.text)==null?void 0:d.trim(),i=s.sender.kind==="user"?"user":s.sender.kind==="ai"||s.sender.kind==="agent"?"agent":null;if(!a||!i)return[];const c=s.sentAt?Date.parse(s.sentAt):0;return[{id:s.publicId,role:i,text:a,final:!0,at:c}]})}function Kp(e){var n;const t=e.routerCtx.state.get().screen==="chat"?e:e.routerCtx.toChatScreen()??e;return{ctx:t,sessionId:((n=t.sessionCtx.sessionState.get().session)==null?void 0:n.id)??null}}const Mi=u.createContext(null),Zp={enabled:!1,isOpen:!1,state:"idle",error:null,audioBlocked:!1,muted:!1,connectedAt:null,levelsRef:{current:{local:0,remote:0}},threadCalls:[],transcript:[],start:async()=>{K.log.warn("voice call unavailable: `voice` is not configured")},end:async()=>{},toggleMute:()=>{},resumeAudio:()=>{},close:()=>{}};function Ot(){return u.useContext(Mi)??Zp}function Jp({children:e}){const{voice:t,apiUrl:n}=C.useConfig(),{widgetCtx:o}=C.useWidget(),{sessionState:{session:s}}=C.useSessions(),a=(s==null?void 0:s.id)??null,[i,c]=u.useState(!1),[d,l]=u.useState("idle"),[m,p]=u.useState(null),[h,f]=u.useState(!1),[x,g]=u.useState(!1),[y,w]=u.useState(null),[j,b]=u.useState([]),[_,v]=u.useState([]),k=u.useRef(0),N=u.useRef({local:0,remote:0}),R=u.useRef(null),T=u.useRef(null),A=u.useRef(null),O=u.useRef(t==null?void 0:t.getToken);O.current=t==null?void 0:t.getToken;const P=u.useRef(o);P.current=o;const B=u.useCallback(()=>c(!1),[]);u.useEffect(()=>{a&&b(D=>D.some(V=>V.thread.ctx===o&&V.thread.sessionId===null)?D.map(V=>V.thread.ctx===o&&V.thread.sessionId===null?{...V,thread:{ctx:o,sessionId:a}}:V):D)},[o,a]);const E=u.useMemo(()=>j.filter(D=>D.thread.ctx===o&&(D.thread.sessionId===null||D.thread.sessionId===a)&&(a===null||D.voiceSessionId!==a)),[j,o,a]),I=u.useCallback(D=>{if(R.current!==D)return;R.current=null,N.current={local:0,remote:0};const V=A.current;if(A.current=null,V===null)return;const Z=++k.current,te=D.getTranscript().segments.filter(J=>J.text.trim()),ae=D.sessionId??null,xe=te.length===0&&ae!==null,H=Kp(P.current);if(b(J=>[...J,{id:Z,startedAt:V,durationMs:Date.now()-V,transcript:te,transcriptLoading:xe,voiceSessionId:ae,thread:H}]),!xe||ae===null)return;const ee=J=>b(ne=>ne.map(le=>le.id===Z?{...le,transcript:J,transcriptLoading:!1}:le));Gp(P.current.api,ae).then(ee).catch(J=>{console.error("Voice call transcript failed to load",{_e:J}),ee([])})},[]),W=u.useCallback(async()=>{const D=O.current;if(!D){K.log.warn("voice call unavailable: `voice` is not configured");return}if(c(!0),R.current)return;o.dictationCtx.stop({executeFinalCommand:!1}),A.current=null,N.current={local:0,remote:0},p(null),f(!1),g(!1),w(null),v([]),l("connecting");const V=T.current;T.current=null,V==null||V.dispose().catch(te=>{console.error("Previous voice call cleanup failed",{_e:te})});let Z;try{const{OpenCXVoice:te}=await import("@opencx/voice");Z=new te({getToken:D,apiUrl:n})}catch(te){console.error("Voice call failed to load",{_e:te}),p({code:"load_failed",message:"Voice is unavailable"}),l("ended");return}R.current=Z,T.current=Z,Z.on("stateChanged",te=>{R.current===Z&&(l(te),te==="connected"&&A.current===null&&(A.current=Date.now(),w(A.current)),te==="ended"&&I(Z))}),Z.on("error",te=>{if(T.current===Z){if(te.code==="audio_blocked"){f(!0);return}console.error("Voice call error",{_e:te,code:te.code}),c(!0),p({code:te.code,message:te.message})}}),Z.on("levels",te=>{N.current=te}),Z.on("transcript",te=>{R.current===Z&&v(te.segments)});try{await Z.start()}catch{}},[n,I,o]),$=u.useCallback(async()=>{const D=R.current;if(!D){B();return}try{await D.end()}catch{}},[B]),U=u.useCallback(()=>{const D=R.current;if(!D)return;const V=!x;g(V),D.setMuted(V).catch(Z=>{console.error("Voice mute failed",{_e:Z}),g(!V)})},[x]),Y=u.useCallback(()=>{const D=R.current;D&&D.resumeAudio().then(()=>f(!1)).catch(V=>{console.error("Voice audio resume failed",{_e:V})})},[]);u.useEffect(()=>{if(!i||d!=="ended"||m)return;const D=setTimeout(()=>c(!1),Xp);return()=>clearTimeout(D)},[i,d,m]),u.useEffect(()=>()=>{const D=T.current;R.current=null,T.current=null,D==null||D.dispose().catch(V=>{console.error("Voice call cleanup failed",{_e:V})})},[]);const q=!!t,se=u.useMemo(()=>({enabled:q,isOpen:i,state:d,error:m,audioBlocked:h,muted:x,connectedAt:y,levelsRef:N,threadCalls:E,transcript:_,start:W,end:$,toggleMute:U,resumeAudio:Y,close:B}),[q,i,d,m,h,x,y,E,_,W,$,U,Y,B]);return r.jsx(Mi.Provider,{value:se,children:e})}function Ri(e){const t=e.timestamp?Date.parse(e.timestamp):Number.POSITIVE_INFINITY;return Number.isNaN(t)?Number.POSITIVE_INFINITY:t}function Pi(e,t){const n=e.findIndex(o=>o.startedAt>=t);return e.splice(0,n===-1?e.length:n)}function Oi(){var c;const{messagesState:{messages:e}}=C.useMessages(),t=C.useConfig(),n=C.useBot(),{advancedInitialMessages:o=[],initialQuestions:s,initialQuestionsPosition:a}=t;if(e.length>0)return null;const i=o.length?o.map(d=>d.message):(c=t.initialMessages)!=null&&c.length?t.initialMessages:["Hello, how can I help you?"];return r.jsx(Xt,{messages:i.map((d,l)=>({component:"bot_message",data:{message:d},id:`${l}-${d}`,type:"AI",timestamp:null})),suggestedReplies:a==="below-initial-messages"?s:void 0,agent:n})}function Tr({groups:e,pendingReply:t=!1}){const{humanAgent:n}=C.useConfig(),o=C.useBot();return r.jsx(r.Fragment,{children:e.map((s,a)=>{var c,d;const i=(c=s[0])==null?void 0:c.id;if(!i)return null;if(Nr(s))return r.jsx(Ii,{messages:s},i);if(gp(s))return r.jsx(Xt,{messages:s,agent:o,actions:!t||a!==e.length-1},i);if(xp(s)){const l=(d=s[0])==null?void 0:d.agent;return r.jsx(Xt,{messages:s,agent:l?{...l,name:(n==null?void 0:n.name)||l.name||"",avatarUrl:(n==null?void 0:n.avatarUrl)||l.avatarUrl||null}:n?{isAi:!1,id:null,name:n.name||"",avatarUrl:n.avatarUrl||null}:void 0},i)}return null})})}const Qp=150;function em({scrollHeight:e,scrollTop:t,clientHeight:n},o=Qp){return e-t-n<o}function tm(e){const t=u.useRef(null),n=u.useRef(!0),[o,s]=u.useState(!1),a=u.useRef(null),[i]=u.useState(()=>new Set),c=u.useCallback(()=>{const l=t.current,m=l?em(l):!0;n.current=m,s(!m)},[]),d=u.useCallback(()=>{const l=t.current;l&&(l.scrollTo({top:l.scrollHeight,behavior:"smooth"}),n.current=!0,s(!1))},[]);return u.useEffect(()=>{if(!n.current)return;const l=setTimeout(()=>{const m=t.current;m&&(m.scrollTop=m.scrollHeight)},0);return()=>clearTimeout(l)},e),u.useEffect(()=>{const l=t.current;if(!l)return;const m=new ResizeObserver(()=>{n.current&&(l.scrollTop=l.scrollHeight)});return a.current=m,()=>{m.disconnect(),a.current=null,i.clear()}},[i]),u.useEffect(()=>{const l=t.current,m=a.current;!l||!m||(i.forEach(p=>{p.isConnected||(m.unobserve(p),i.delete(p))}),Array.from(l.children).forEach(p=>{i.has(p)||(m.observe(p),i.add(p))}))}),{containerRef:t,handleScroll:c,showScrollDown:o,scrollToBottom:d}}function nm(){const{messagesState:{messages:e}}=C.useMessages(),{isStreaming:t,liveItems:n,turnSources:o,liveTurnKey:s,turnFailed:a,retryFailedTurn:i}=C.useAgentChatUi(),{componentStore:c}=C.useWidget(),{t:d}=G(),l=C.useBot(),{sessionState:{session:m}}=C.useSessions(),p=u.useMemo(()=>C.sessionPlan({liveItems:n,turnSources:o}),[n,o]),h=u.useMemo(()=>yi(e),[e]),{threadCalls:f}=Ot(),x=u.useMemo(()=>{const T=new Map;for(const A of o)for(const O of A.rowIds)T.set(O,A);return T},[o]),g=u.useMemo(()=>{for(let T=h.length-1;T>=0;T-=1){const A=h[T];if(A&&Nr(A))return T}return-1},[h]),y=n.length>0,{nodes:w,renderedSourceKeys:j}=u.useMemo(()=>{const T=[],A=new Set,O=[...f];h.forEach((P,B)=>{const E=P[0],I=E==null?void 0:E.id;if(!E||!I)return;for(const U of Pi(O,Ri(E)))T.push(r.jsx(_n,{call:U},`voice-call-${U.id}`));if(Nr(P)){T.push(r.jsx(Tr,{groups:[P]},I));return}let W=[];const $=()=>{var Y;const U=(Y=W[0])==null?void 0:Y.id;U&&T.push(r.jsx(Tr,{groups:[W]},U)),W=[]};for(const U of P){const Y=x.get(U.id);Y?($(),A.has(Y.key)||(A.add(Y.key),T.push(r.jsx(ps,{turn:{active:!1,items:Y.items},agent:l,timestamp:U.timestamp},Y.key)))):y&&B>g||W.push(U)}$()});for(const P of O)T.push(r.jsx(_n,{call:P},`voice-call-${P.id}`));return{nodes:T,renderedSourceKeys:A}},[h,x,y,g,l,f]),b=s!==null&&n.length>0&&!j.has(s),_=c.getComponent("loading"),{containerRef:v,handleScroll:k,showScrollDown:N,scrollToBottom:R}=tm([e,n,f]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{...L("chat/msgs/wrapper"),className:"relative flex flex-1 flex-col min-h-0",children:[r.jsxs("div",{...L("chat/msgs/root"),ref:v,onScroll:k,className:"max-h-full relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[r.jsx(Si,{}),r.jsx(ki,{}),r.jsx(Oi,{}),[...w,...b?[r.jsx(ps,{turn:{active:t,items:n},agent:l},s)]:[]],t&&n.length===0&&_&&r.jsx(_,{agent:l}),a&&!t&&r.jsxs("div",{...L("chat/turn_failed/root"),className:"flex items-center gap-2 self-start rounded-xl border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[r.jsx("span",{children:d("turn_failed_message")}),r.jsx("button",{...L("chat/turn_failed/retry"),type:"button",onClick:i,className:"font-medium underline underline-offset-2 hover:opacity-80",children:d("turn_failed_retry")})]}),r.jsx(vi,{}),r.jsx(wi,{})]}),r.jsx(F.AnimatePresence,{children:N&&u.createElement(F.motion.button,{...L("chat/msgs/scroll-to-bottom"),key:"scroll-to-bottom",type:"button",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.15},onClick:R,"aria-label":d("scroll_to_bottom"),className:"absolute bottom-3 left-1/2 z-20 flex size-8 -translate-x-1/2 items-center justify-center rounded-full border border-border bg-background text-muted-foreground shadow-lg transition-colors hover:text-foreground"},r.jsx(M.ArrowDown,{className:"size-4"}))})]}),p&&p.length>0&&r.jsx("div",{...L("chat/session-plan"),className:"shrink-0 px-4 pb-2",children:r.jsx(fp,{plan:p,active:t},(m==null?void 0:m.id)??"new-session")})]})}function rm(){const e=qe(),{activeMode:t,Component:n}=C.useModes(),o=an(),{createStateCheckpoint:s}=C.useSessions(),[a,i]=u.useState(!1),c=async d=>{try{i(!0),await o(d)}catch(l){K.log.error("mode component send failed",l)}finally{i(!1)}};return!t||!n?null:r.jsx(n,{...e,mode:t,createStateCheckpoint:s,sendMessage:c,isSendingMessage:a})}function Li(){const{requireInitialQuestion:e,initialQuestions:t}=C.useConfig(),{messagesState:n}=C.useMessages();return e===!0&&n.messages.length===0&&(t==null?void 0:t.some(o=>o.trim().length>0))===!0}const om=5e3;function sm({stickyQuestions:e,messages:t,isHandedOff:n,isStreaming:o,isTyping:s,otherSuggestionsShowing:a}){const i=(e==null?void 0:e.filter(h=>h.trim().length>0))??[],c=t.findLast(h=>h.type!=="SYSTEM"),d=i.length>0&&!n&&!o&&(c==null?void 0:c.type)==="AI"&&c.data.variant!=="error"?c.id:null,[l,m]=u.useState(null);return u.useEffect(()=>{if(d===null)return;const h=setTimeout(()=>m(d),om);return()=>clearTimeout(h)},[d]),d!==null&&l===d&&!s&&!a?i:[]}function Ir({isStreaming:e,messages:t,session:n}){return!e&&K.isAwaitingRequiredTap(t,n)}const _e=u.forwardRef((e,t)=>{var n,o,s;return r.jsx(oe,{...e,ref:t,className:z("overflow-hidden",e.className),overrides:{initial:{height:0,opacity:0,...(n=e.overrides)==null?void 0:n.initial},animate:{height:"auto",opacity:1,...(o=e.overrides)==null?void 0:o.animate},exit:{height:0,opacity:0,...(s=e.overrides)==null?void 0:s.exit}}})});_e.displayName="MotionDiv__VerticalReveal";const am=[{label:"Terrible",value:1,emoji:"😡"},{label:"Poor",value:2,emoji:"😞"},{label:"Okay",value:3,emoji:"😐"},{label:"Good",value:4,emoji:"😊"},{label:"Great",value:5,emoji:"😍"}];function er({surveyType:e="csat"}){var n,o;const t=C.useCsat(e);return r.jsx(im,{surveyType:e,survey:t},((n=t.csatRequestedMessage)==null?void 0:n.id)??((o=t.csatSubmittedMessage)==null?void 0:o.id)??e)}function im({surveyType:e,survey:t}){const{isSmallScreen:n}=je(),{t:o}=G(),{submitCsat:s,isCsatRequested:a,isCsatSubmitted:i,submittedScore:c,submittedFeedback:d,question:l}=t,[m,p]=u.useState(!1),[h,f]=u.useState(!1),x=e==="csat"?am:Array.from({length:e==="nps"?11:5},(v,k)=>({value:k+(e==="nps"?0:1),emoji:String(k+(e==="nps"?0:1)),label:String(k+(e==="nps"?0:1))})),[g,y]=u.useState(null),[w,j]=u.useState(null),b=v=>{y(k=>k===v?null:v)},_=async()=>{if(!(g===null||m)){p(!0),f(!1);try{const v=await s({score:g,feedback:w||void 0});f(!!v.error)}catch(v){console.error("Unable to submit survey",{_e:v}),f(!0)}finally{p(!1)}}};return!a&&!i?null:r.jsxs("div",{className:z("mx-auto overflow-hidden",e==="csat"&&"w-1/2 min-w-80 max-w-96",e==="nps"&&"w-full max-w-[30rem]",e==="ces"&&"w-full max-w-80"),children:[r.jsx(F.AnimatePresence,{mode:"wait",children:a&&g===null?r.jsx(_e,{children:r.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:l??o("csat_title")})},"csat-requested-title"):i?r.jsx(_e,{children:r.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:o("csat_submitted_title")})},"csat-submitted-title"):null}),r.jsx("div",{dir:"ltr",className:z("flex pt-2 px-2 pb-2",e==="csat"?"gap-4 justify-between":"gap-0.5 justify-between","transition-all",i&&"gap-0 justify-center"),children:x.map(v=>r.jsx(X,{"aria-label":v.label,"aria-pressed":e==="csat"?void 0:v.value===(c??g),disabled:m||i,variant:v.value===g?"secondary":"ghost",size:"selfless",className:z("transition-all overflow-hidden",e==="csat"?"text-2xl size-8 rounded-full":"h-10 min-w-0 max-w-11 flex-1 rounded-full text-sm tabular-nums",e!=="csat"&&v.value===g&&"bg-foreground text-background hover:bg-foreground","opacity-35","hover:opacity-100",g===null&&"opacity-100",v.value===g&&"opacity-100",i&&v.value!==c&&"opacity-0 size-0",i&&v.value===c&&"opacity-100 size-fit text-4xl",e!=="csat"&&i&&(v.value===c?"flex-none bg-transparent text-foreground disabled:opacity-100":"hidden")),onClick:a?()=>b(v.value):void 0,children:v.emoji},v.value))}),e!=="csat"&&a&&g===null&&r.jsxs("p",{dir:"ltr",className:"flex justify-between gap-2 px-2 text-xs text-muted-foreground",children:[r.jsx("span",{dir:"auto",children:o(e==="nps"?"nps_low_label":"ces_low_label")}),r.jsx("span",{dir:"auto",children:o(e==="nps"?"nps_high_label":"ces_high_label")})]}),h&&r.jsx("p",{role:"alert",className:"text-sm text-center",children:o("survey_submit_error")}),r.jsx(F.AnimatePresence,{mode:"wait",children:(g!==null||i&&c!=null)&&r.jsx(_e,{children:r.jsxs("div",{className:"pb-2 px-2 flex items-end",children:[r.jsx("textarea",{rows:3,className:z("transition-all","max-h-40 [field-sizing:content]","w-full resize-none","bg-transparent outline-none","placeholder:text-muted-foreground",n?"text-[16px]":"text-sm",i&&"text-center"),value:i?d||"":w||"",onChange:a?v=>j(v.target.value):void 0,readOnly:i,placeholder:a?o("csat_feedback_placeholder"):void 0}),r.jsx(X,{size:"fit",onClick:()=>void _(),disabled:g===null||m,className:z("transition-all overflow-hidden","rounded-full size-8 flex items-center justify-center p-0",i&&"opacity-0 size-0"),children:r.jsx(M.ArrowUpIcon,{className:"size-4"})})]})},"feedback-box")}),r.jsx("div",{className:z("h-0 transition-[height]",i&&"h-4")})]})}function cm(){const{t:e}=G(),t=[e("i_need_more_help"),e("this_was_helpful")];return r.jsx("div",{...L("chat/might_solve_user_issue_suggested_replies_container"),className:"flex items-center gap-2 p-2 pb-0 flex-wrap",children:t.map(n=>r.jsx(Yt,{suggestion:n,className:"flex-1"},n))})}function zr(){const{sessionState:e}=C.useSessions(),{chatFooterItems:t}=C.useConfig(),n=!!e.session&&!e.session.isOpened,o=!n;return r.jsx(F.AnimatePresence,{mode:"wait",children:t==null?void 0:t.map((s,a)=>s.showWhenSessionIsOpen===!1&&o||s.showWhenSessionIsResolved===!1&&n?null:r.jsx(_e,{children:r.jsx("div",{className:"pb-2 text-center text-xs",children:r.jsx(Pu,{children:s.message})})},`${s.message}-${a}`))})}function En(){return r.jsxs("svg",{viewBox:"0 0 180 180",fill:"none",className:"size-5 shrink-0 stroke-current",strokeWidth:"12",strokeLinecap:"round","aria-hidden":!0,"data-mcp-icon":!0,children:[r.jsx("path",{d:"M18 84.8528L85.8822 16.9706C95.2548 7.59798 110.451 7.59798 119.823 16.9706V16.9706C129.196 26.3431 129.196 41.5391 119.823 50.9117L68.5581 102.177"}),r.jsx("path",{d:"M69.2652 101.47L119.823 50.9117C129.196 41.5391 144.392 41.5391 153.765 50.9117L154.118 51.2652C163.491 60.6378 163.491 75.8338 154.118 85.2063L92.7248 146.6C89.6006 149.724 89.6006 154.789 92.7248 157.913L105.331 170.52"}),r.jsx("path",{d:"M102.853 33.9411L52.6482 84.1457C43.2756 93.5183 43.2756 108.714 52.6482 118.087V118.087C62.0208 127.459 77.2167 127.459 86.5893 118.087L136.794 67.8822"})]})}function lm({sessionId:e,active:t}){var i;const{widgetCtx:n,config:o}=C.useWidget(),[s,a]=u.useState(null);return u.useEffect(()=>{var m;if(a(null),!t||((m=o.capabilities)==null?void 0:m.connections)!==!0)return;const c=new AbortController;let d;const l=async()=>{try{const p=await n.api.listElicitations(e,c.signal);c.signal.aborted||a(p[0]??null)}catch{a(p=>p&&p.expiresAt>Date.now()?p:null)}c.signal.aborted||(d=setTimeout(l,1500))};return l(),()=>{c.abort(),clearTimeout(d)}},[n,e,t,(i=o.capabilities)==null?void 0:i.connections]),r.jsxs(r.Fragment,{children:[" ",s&&s.expiresAt>Date.now()?r.jsx(dm,{request:s,onAnswer:async c=>{await n.api.answerElicitation(e,s.id,c),a(null)}},s.id):null]})}function dm({request:e,onAnswer:t}){var m,p;const[n,o]=u.useState(!1),[s,a]=u.useState(""),i=async h=>{if(!n){o(!0),a("");try{await t(h)}catch(f){a(f instanceof Error?f.message:"Could not submit. Try again.")}finally{o(!1)}}},c=e.form.requestedSchema.properties,d=Object.keys(c).length===1&&((m=c.approve)==null?void 0:m.type)==="boolean"&&((p=e.form.requestedSchema.required)==null?void 0:p.includes("approve")),l="w-full rounded-lg border border-foreground/15 bg-background px-2 py-1.5 text-base sm:text-sm";return r.jsxs("form",{"aria-label":`Request from ${e.serverName}`,className:`min-w-0 rounded-2xl border border-foreground/10 bg-background p-2 space-y-2 text-foreground ${d?"overflow-visible":"max-h-[50vh] overflow-y-auto"}`,onSubmit:h=>{if(h.preventDefault(),d){i({action:"accept",content:{approve:!0}});return}const f=new FormData(h.currentTarget),x={};for(const[g,y]of Object.entries(c)){const w=f.get(g);if(y.type==="boolean")x[g]=w==="on";else if(y.type==="array"){const j=f.getAll(g).filter(b=>typeof b=="string");if(y.minItems!==void 0&&j.length<y.minItems){a(`${y.title??g}: select at least ${y.minItems} options.`);return}if(y.maxItems!==void 0&&j.length>y.maxItems){a(`${y.title??g}: select no more than ${y.maxItems} options.`);return}x[g]=j}else typeof w=="string"&&w!==""&&(x[g]=y.type==="number"||y.type==="integer"?Number(w):w)}i({action:"accept",content:x})},children:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("div",{className:"mt-0.5 size-4 shrink-0 text-foreground/50",title:e.serverName,children:r.jsx(En,{})}),r.jsx("p",{className:"min-w-0 flex-1 text-sm leading-5 break-words",children:e.form.message}),r.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-foreground/50",wobble:!1,"aria-label":"Cancel request",disabled:n,onClick:()=>void i({action:"cancel"}),children:r.jsx(M.X,{className:"size-3.5"})})]}),!d&&r.jsx("fieldset",{disabled:n,className:"space-y-3",children:Object.entries(c).map(([h,f])=>{var w,j,b,_,v;const x=`${e.id}-${h}`,g=f.oneOf??((w=f.enum)==null?void 0:w.map(k=>({const:k,title:k})))??((j=f.items)==null?void 0:j.anyOf)??((_=(b=f.items)==null?void 0:b.enum)==null?void 0:_.map(k=>({const:k,title:k}))),y=(v=e.form.requestedSchema.required)==null?void 0:v.includes(h);return r.jsxs("div",{children:[r.jsxs("label",{htmlFor:x,className:"block text-sm font-medium mb-1",children:[f.title??h,y?" *":""]}),f.description&&r.jsx("p",{className:"text-sm text-foreground/60 mb-1",children:f.description}),f.type==="boolean"?r.jsx("input",{id:x,name:h,type:"checkbox",defaultChecked:f.default===!0,className:"size-5 accent-current"}):g?r.jsxs("select",{id:x,name:h,multiple:f.type==="array",required:y,className:l,defaultValue:typeof f.default=="string"||Array.isArray(f.default)?f.default:f.type==="array"?[]:"",children:[f.type!=="array"&&r.jsx("option",{value:"",children:"Choose…"}),g.map(k=>r.jsx("option",{value:k.const,children:k.title??k.const},k.const))]}):r.jsx("input",{id:x,name:h,className:l,type:f.type==="number"||f.type==="integer"?"number":f.format==="email"?"email":f.format==="uri"?"url":f.format==="date"?"date":"text",required:y,min:f.minimum,max:f.maximum,step:f.type==="integer"?1:"any",minLength:f.minLength,maxLength:f.maxLength,defaultValue:typeof f.default=="string"||typeof f.default=="number"?f.default:""})]},h)})}),s&&r.jsx("p",{role:"alert",className:"text-sm text-destructive",children:s}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2 pl-6",children:[r.jsx(X,{type:"submit",size:"sm",className:"h-7 rounded-lg px-2.5 py-0 text-xs",wobble:!1,disabled:n,children:n?"Submitting…":d?"Approve once":"Submit"}),d&&e.approvalKey&&r.jsx(X,{type:"button",size:"sm",variant:"secondary",className:"h-7 rounded-lg px-2.5 py-0 text-xs",wobble:!1,disabled:n,title:"Allow the same tool, account and inputs. Reset anytime.",onClick:()=>void i({action:"accept",content:{approve:!0},remember:!0}),children:"Always allow"}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-lg px-2.5 py-0 text-xs",wobble:!1,disabled:n,onClick:()=>void i({action:"decline"}),children:"Decline"})]})]})}function um({request:e}){const t=C.useConnection(e),{phase:n,authorization:o,continuation:s,error:a}=t,c=n==="loading"||n==="waiting"||s!==null,d=n==="connected"||n==="external",l=(a==null?void 0:a.toLowerCase().includes("expired"))??!1,m=s?s==="renew"?"Preparing a new connection request":"Continuing your request":n==="waiting"?"Waiting for approval":n==="loading"?"Preparing connection":n==="connected"?"Connected":n==="external"?"Setup page completed":"Not connected",p=s?s==="renew"?"Requesting…":"Continuing…":n==="loading"?"Preparing…":n==="waiting"?"Waiting…":l?"Reconnect":a?"Try again":d?"Continue":"Connect",h=()=>a||d?t.retryContinuation():t.start();return r.jsxs("section",{"aria-label":`Connect ${e.name}`,"data-component":"chat/connection",className:"min-w-0 rounded-2xl border border-foreground/10 bg-background p-2 text-foreground",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-secondary p-2",children:r.jsx(En,{})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium",title:(o==null?void 0:o.host)??e.name,children:e.name}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Connect your account to continue."})]}),r.jsxs("p",{role:"status","aria-live":"polite",className:"sr-only",children:[e.name,": ",m]}),n==="ready"&&o&&!s?r.jsx(X,{asChild:!0,wobble:!1,size:"sm",className:"h-7 shrink-0 px-2.5 text-xs order-2",children:r.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",onClick:t.opened,"aria-label":`Connect on ${o.host} (opens in a new tab)`,children:"Connect"})}):r.jsxs(X,{type:"button",wobble:!1,size:"sm",className:"h-7 shrink-0 px-2.5 text-xs order-2",disabled:c,"aria-busy":c,title:l?"Your access expired. Connect again to continue.":void 0,onClick:()=>void h(),children:[c&&r.jsx(mo,{}),p]}),r.jsx(X,{type:"button",wobble:!1,variant:"ghost",size:"fit",className:"h-7 shrink-0 px-2 text-xs order-1","aria-label":"Not now",title:"Not now",disabled:s!==null,onClick:()=>void t.cancel(),children:"Not now"})]}),a&&r.jsx("p",{role:"alert",className:"px-1 pt-2 text-sm text-pretty text-destructive",children:a})]})}const pm=["box","circle","crossed-off","arrow","bracket","underline","highlight","strike-through"];function mm(e){const t=new Map,n=[];for(const o of e){let s;for(const a of o.elements){const i=a.selector||a.name,c=t.get(i);if(c){s??(s=c);continue}const d={...a};t.set(i,d),n.push(d),s??(s=d)}o.note&&s&&(s.note=s.note?`${s.note}
|
|
111
|
-
${o.note}`:o.note)}return n}const fs=20,hm=4e3;function Mr(e,t){for(let n=e.nextElementSibling;n instanceof SVGSVGElement&&n.classList.contains("notation");n=n.nextElementSibling)n.setAttribute("data-opencx-overlay",""),n.style.zIndex=String(t),n.style.filter="drop-shadow(0 0 1px rgb(255 255 255 / 0.85))"}function fm(e,t,n,o){const s=document.createElement("div");s.setAttribute("data-opencx-overlay",""),Object.assign(s.style,{position:"absolute",left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",zIndex:String(o)}),document.documentElement.appendChild(s);let a=null;try{a=ua.annotate(s,{type:t,color:n,strokeWidth:2,wobble:.8}),a.show(),Mr(s,o)}catch(l){K.log.warn("page mark: could not be drawn",l)}let i=!1;const c=()=>{if(!i){i=!0;try{a==null||a.remove()}catch{}s.remove()}},d=l=>{if(!i)try{a==null||a.update(l),Mr(s,o)}catch{}};return{setRect(l){i||(s.style.left=`${l.x}px`,s.style.top=`${l.y}px`,s.style.width=`${l.width}px`,s.style.height=`${l.height}px`,d({}))},setShape(l){d({type:l})},undraw(){if(!i){if(!a)return c();try{a.hide(),a.finished.then(c)}catch{return c()}window.setTimeout(c,hm)}},remove:c}}const gm=60;function Qe(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function $i(e){return Ei(e)}function xm(e){return/[!/[\]():]/.test(e)||/^-?[a-z]{1,6}-\d/.test(e)||/^(flex|grid|block|inline|hidden|absolute|relative|fixed|sticky|static|truncate|container)$/.test(e)}function bm(e){const t=e.getAttribute("class");return t?t.split(/\s+/).map(o=>o.replace(/[_-][a-zA-Z0-9]{5,}.*$/,"")).find(o=>o.length>2&&!/^[a-z]{1,2}$/.test(o)&&!/[A-Z0-9]{5,}/.test(o)&&!xm(o))??null:null}function wm(e){if(Me(e))return"private region";const t=e.tagName.toLowerCase(),n=e.getAttribute("aria-label"),o=$i(e);if(t==="button"||e.getAttribute("role")==="button")return n?`button [${n}]`:o?`button "${Qe(o,30)}"`:"button";if(t==="a"){if(o)return`link "${Qe(o,30)}"`;const a=e.getAttribute("href"),i=a?fo(a):"",c=a!=null&&a.startsWith("/")&&!a.startsWith("//")&&i?new URL(i).pathname:i;return c?`link to ${Qe(c,40)}`:"link"}if(t==="input"||t==="textarea"||t==="select"){const a=e.getAttribute("placeholder"),i=e.getAttribute("name");return a?`${t} "${Qe(a,30)}"`:n?`${t} [${n}]`:i?`${t} [${i}]`:t==="input"?`${e.getAttribute("type")??"text"} input`:t}if(/^h[1-6]$/.test(t))return o?`${t} "${Qe(o,40)}"`:t;if(t==="img"){const a=e.getAttribute("alt");return a?`image "${Qe(a,30)}"`:"image"}if(t==="svg")return"icon";if(n)return`${t} [${n}]`;if(o&&o.length<=gm)return`${t} "${Qe(o,40)}"`;const s=bm(e);return s||(t==="div"?"container":t)}function gs(e,t){try{return e.querySelectorAll(t).length===1}catch{return!1}}function vm(e){const t=e.ownerDocument;if(e.id){const s=`#${CSS.escape(e.id)}`;if(gs(t,s))return s}const n=[];let o=e;for(;o&&o.tagName.toLowerCase()!=="html";){const s=o.tagName.toLowerCase();if(o.id){n.unshift(`${s}#${CSS.escape(o.id)}`);break}let a=s;const i=o.parentElement;if(i){const d=Array.from(i.children).filter(l=>l.tagName===(o==null?void 0:o.tagName));d.length>1&&(a+=`:nth-of-type(${d.indexOf(o)+1})`)}n.unshift(a);const c=n.join(" > ");if(gs(t,c))return c;o=i}return n.join(" > ")}function ym(e){const t=e.getBoundingClientRect();return{x:Math.round(t.x),y:Math.round(t.y),width:Math.round(t.width),height:Math.round(t.height)}}const km=8;function xs(e,t=km){const n=document.documentElement.clientWidth||window.innerWidth,o=document.documentElement.clientHeight||window.innerHeight,s=Math.max(e.x,t),a=Math.max(e.y,t),i=Math.min(e.x+e.width,n-t),c=Math.min(e.y+e.height,o-t);return{x:Math.round(s),y:Math.round(a),width:Math.round(Math.max(0,i-s)),height:Math.round(Math.max(0,c-a))}}function Di(e){if(Me(e)||e.closest(gt))return{name:"private region",selector:"",tag:"div"};const t=$i(e);return{name:wm(e),selector:vm(e),tag:e.tagName.toLowerCase(),text:t?Qe(t,200):void 0}}const jm=ho.join(", ");function cn(e){return e.closest(jm)!==null}function Rr(e,t){let n=document.elementFromPoint(e,t);if(!n)return null;const o=n.getRootNode();typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(n=o.host);let a=n.closest('button, a, input, textarea, select, [role="button"], [role="link"]')??n;for(;a&&!(a instanceof HTMLElement);)a=a.parentElement;if(!(a instanceof HTMLElement)||Me(n)||Me(a)||a.closest(gt))return null;const i=a.tagName.toLowerCase();return i==="html"||i==="body"?null:a}const xo=new WeakMap;function Cm(e,t){xo.set(e,[...t])}function Cn(e){const t=xo.get(e);return t!==void 0&&e.pageUrl===fo(window.location.href)&&t.every(n=>n.isConnected&&n.getRootNode()===document&&!Me(n)&&!n.closest(gt))}function Sm(e){const t=xo.get(e);if(!t||!Cn(e))return null;const n=t.map(Di),[o]=t,s=o!==void 0&&Gt(o)&&JSON.stringify(n[0])===JSON.stringify(e.elements[0]),a={...e,elements:n};return s?zp(e,a):delete a.snapshotUrl,a}const bs=120,ct=e=>e.replace(/\s+/g," ").trim(),Ze=e=>e.length>bs?`${e.slice(0,bs)}…`:e,An=Ei;function Nm(e){const t=e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.labels:null,n=t?Array.from(t).map(a=>An(a)).join(" "):"";if(n)return ct(n);const o=e.closest("fieldset"),s=o==null?void 0:o.querySelector("legend");return s?An(s):""}function Mt(e){if(Me(e))return"";const t=e.getAttribute("aria-labelledby");if(t){const i=t.split(/\s+/).map(c=>e.ownerDocument.getElementById(c)).filter(c=>c!==null).map(c=>An(c)).filter(Boolean).join(" ");if(i)return Ze(ct(i))}const n=e.getAttribute("aria-label");if(n!=null&&n.trim())return Ze(ct(n));const o=e.tagName.toLowerCase();if(o==="img"){const i=e.getAttribute("alt");if(i!=null&&i.trim())return Ze(ct(i))}if(o==="input"||o==="select"||o==="textarea"){const i=Nm(e);if(i)return Ze(i);const c=e.getAttribute("placeholder");if(c!=null&&c.trim())return Ze(ct(c));const d=e.getAttribute("title");return d!=null&&d.trim()?Ze(ct(d)):""}const s=An(e);if(s)return Ze(s);const a=e.getAttribute("title");return a!=null&&a.trim()?Ze(ct(a)):""}const _m=["click","fill","select","check","uncheck"],Em=3e3,Fi=new Set(["password","file","hidden"]);function Hi(e){const t=new WeakRef(e),n=ws(e).map(o=>{const s=vs(o);return{...s,element:new WeakRef(s.element),form:s.form?new WeakRef(s.form):null,labelControl:s.labelControl?new WeakRef(s.labelControl):null}});return()=>{const o=t.deref();if(!o||!o.isConnected||o.getRootNode()!==document)return!1;const s=ws(o).map(vs);return s.length===n.length&&s.every((a,i)=>{var d,l;const c=n[i];return a.allowed&&a.element===c.element.deref()&&a.form===(((d=c.form)==null?void 0:d.deref())??null)&&a.labelControl===(((l=c.labelControl)==null?void 0:l.deref())??null)&&a.semantics===c.semantics})}}function ws(e){const t=[],n=new Set,o=s=>{for(let a=s;a&&!n.has(a);a=a.parentElement)n.add(a),(a===e||a.matches("a[href],area[href],button,input,select,textarea,label"))&&t.push(a),a instanceof HTMLLabelElement&&a.control&&o(a.control)};return o(e),t}function vs(e){var a;const t=e instanceof HTMLAnchorElement||e instanceof HTMLAreaElement?e:null,n=e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e:null,o=(n==null?void 0:n.form)??null,s=(a=e.ownerDocument.querySelector("base[target]"))==null?void 0:a.getAttribute("target");return{element:e,form:o,labelControl:e instanceof HTMLLabelElement?e.control:null,allowed:!(e instanceof HTMLInputElement&&Fi.has(e.type)),semantics:JSON.stringify([e.tagName,e.getAttribute("role"),n==null?void 0:n.type,n==null?void 0:n.name,e instanceof HTMLButtonElement||e instanceof HTMLInputElement&&["submit","image","reset"].includes(e.type)?e.value:null,t==null?void 0:t.href,(t==null?void 0:t.getAttribute("target"))??s,t==null?void 0:t.getAttribute("download"),t==null?void 0:t.getAttribute("rel"),t==null?void 0:t.getAttribute("ping"),o==null?void 0:o.action,o==null?void 0:o.method,(o==null?void 0:o.getAttribute("target"))??s,o==null?void 0:o.enctype,o==null?void 0:o.noValidate,...["formaction","formmethod","formtarget","formenctype","formnovalidate"].map(i=>e.getAttribute(i)),e instanceof HTMLButtonElement||e instanceof HTMLInputElement?[e.formAction,e.formMethod,e.formTarget,e.formEnctype,e.formNoValidate]:null])}}const Am=2,Nt=[];let Tm=0,ys=new WeakMap,lt,ks,bo=new WeakMap,wo=new WeakMap,Tn=new WeakMap;const Im='tr,li,article,form,fieldset,section,dialog,aside,nav,main,header,footer,[role="row"],[role="listitem"],[role="group"],[role="region"],[role="dialog"],[role="tooltip"]',vo='tr,li,article,[role="row"],[role="listitem"]',tr='section,form,fieldset,dialog,[role="group"],[role="region"],[role="dialog"]',zm=new Set(["class","style","aria-busy"]);function Mm(e){var a,i;const t=e.closest(vo);if(t)return t;let n=e.closest(tr);if(n){let c=(a=n.parentElement)==null?void 0:a.closest(tr);for(;c;)n=c,c=(i=n.parentElement)==null?void 0:i.closest(tr);return n}const o=e.closest(Im);if(o)return o;const s=e.parentElement;return s&&s!==e.ownerDocument.body&&s!==e.ownerDocument.documentElement?s:e}function Rm(e){return cn(e)||e.closest('[role="tooltip"]')!==null}function Pm(e){const t=e.target.nodeType===1?e.target:e.target.parentElement;if(t&&cn(t)||e.type==="attributes"&&zm.has(e.attributeName??""))return!1;if(e.type==="childList"){const n=[...Array.from(e.addedNodes),...Array.from(e.removedNodes)];if(n.length&&n.every(o=>o.nodeType===1&&Rm(o)))return!1}return!0}function Wi(e){const t=new Set;for(const n of e){for(const s of Array.from(n.removedNodes)){const a=Tn.get(s);a&&t.add(a)}if(!Pm(n))continue;if(n.type==="attributes"){const s=Tn.get(n.target);s&&t.add(s)}let o=!0;for(let s=n.target;s;s=s.parentNode){const a=bo.get(s);if(a&&t.add(a),o){const i=wo.get(s);i&&t.add(i)}if(s instanceof Element&&(s.matches(vo)&&(o=!1),s.matches('[role="tooltip"]')&&!(n.type==="attributes"&&n.attributeName==="role")))break}}t.forEach(n=>n.value++)}function Om(e){const t=[],n=(s,a)=>{let i=a.get(s);i||(i={value:0},a.set(s,i)),t.push({revision:i,value:i.value})},o=Mm(e);n(o,bo);for(let s=e;s;s=s.parentNode)n(s,Tn),s!==o&&s instanceof Element&&s.matches(vo)&&n(s,wo);return()=>t.every(({revision:s,value:a})=>s.value===a)}function Pr(){lt&&Wi(lt.takeRecords())}function Lm(e){if(ks!==e){lt==null||lt.disconnect();for(const t of Nt)for(const n of Array.from(t.values()))n.valid=!1;ks=e,bo=new WeakMap,wo=new WeakMap,Tn=new WeakMap,lt=new MutationObserver(Wi),lt.observe(e.documentElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}}function Bi(e,t,n=Mt(t)){return e.valid&&(e.valid=t.isConnected&&e.url===t.ownerDocument.location.href&&e.name===n&&e.sameContext()&&e.sameMeaning()),e.valid}function $m(){Pr();const e=new Map;Nt.unshift(e),Nt.length=Math.min(Nt.length,Am);let t=0;const n=`s${++Tm}`;return(o,s=Mt(o))=>{Lm(o.ownerDocument),Pr();const a=ys.get(o),i=a?Nt.map(l=>l.get(a)).find(l=>l!==void 0):void 0,c=a&&i&&Bi(i,o,s)?a:`${n}c${t+=1}`,d=c===a&&i?i:{element:new WeakRef(o),sameContext:Om(o),name:s,url:o.ownerDocument.location.href,sameMeaning:Hi(o),valid:!0};return e.set(c,d),ys.set(o,c),c}}function js(e){const t=Ui(e);return t!=null&&t.isCurrent?t.element:null}function Ui(e){Pr();for(const t of Nt){const n=t.get(e);if(!n)continue;const o=n.element.deref();if(o&&o.isConnected)return{element:o,isCurrent:Bi(n,o)}}return null}const Dm="data-opencx-private",Fm=new Set(["password","file","hidden"]),Cs=300;function Or(e){if(cn(e))return"widget-owned";if(e.closest(`[${Dm}]`))return"private";if(e.getAttribute("aria-hidden")==="true"||e.closest('[aria-hidden="true"]'))return"hidden-from-assistive-tech";if(e.tagName.toLowerCase()==="input"){const t=(e.getAttribute("type")??"text").toLowerCase();if(Fm.has(t))return"credential-field"}return null}const Hm={private:"That part of the page is marked private and the agent never reads or uses it.","hidden-from-assistive-tech":"That control is hidden from assistive technology, so it is not treated as being on the page.","credential-field":"Password and file fields are never filled or clicked by the agent.","widget-owned":"That is part of the chat widget, not the page."},Ss=["a[href]","button","input","select","textarea","summary",'[contenteditable=""]','[contenteditable="true"]','[role="button"]','[role="link"]','[role="checkbox"]','[role="radio"]','[role="switch"]','[role="tab"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="combobox"]','[role="slider"]','[role="textbox"]','[role="searchbox"]'].join(","),Wm=["tr","li",'[role="row"]','[role="listitem"]','[role="gridcell"]',"[tabindex]","[onclick]"].join(","),Bm=400;function Um(e){var t;try{return((t=e.ownerDocument.defaultView)==null?void 0:t.getComputedStyle(e).cursor)==="pointer"}catch{return!1}}function qm(e){const t=e.getAttribute("role");if(t!=null&&t.trim())return t.trim().toLowerCase();const n=e.tagName.toLowerCase();if(n==="a")return"link";if(n==="button"||n==="summary")return"button";if(n==="select")return"combobox";if(n==="textarea")return"textbox";if(n==="input"){const o=(e.getAttribute("type")??"text").toLowerCase();return o==="checkbox"?"checkbox":o==="radio"?"radio":o==="submit"||o==="button"||o==="reset"?"button":o==="range"?"slider":o==="search"?"searchbox":"textbox"}return"textbox"}function Vm(e){const t=e.getAttribute("role");if(t!=null&&t.trim())return t.trim().toLowerCase();const n=e.tagName.toLowerCase();return n==="tr"?"row":n==="li"?"listitem":"button"}function Ns(e){if(typeof e.checkVisibility=="function"){if(!e.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}))return!1}else if(!e.isConnected)return!1;const t=e.getBoundingClientRect();return t.width>0&&t.height>0}function Ym(e){return"disabled"in e&&e.disabled===!0?!0:e.getAttribute("aria-disabled")==="true"}function Lr(e=document){const t=[],n=new Set;let o=!1;try{const s=$m(),a=Array.from(e.querySelectorAll(Ss));for(const c of a){if(Or(c)||!Ns(c))continue;const d=Mt(c);if(!d)continue;if(t.length>=Cs){o=!0;break}const l={ref:s(c,d),role:qm(c),name:d};Ym(c)&&(l.disabled=!0),t.push(l),n.add(c)}let i=0;if(!o){const c=Array.from(e.querySelectorAll(Wm));for(const d of c){if(t.length>=Cs){o=!0;break}if(i>=Bm)break;if(n.has(d)||Or(d)||d.querySelector(Ss)||!Ns(d))continue;const l=Mt(d);l&&(i+=1,Um(d)&&(t.push({ref:s(d,l),role:Vm(d),name:l}),n.add(d)))}}}catch{return{controls:[],truncated:!1}}return{controls:t,truncated:o}}function qi({marks:e,readsPage:t}){if(!t)return;const n={},o=e.flatMap(i=>{const c=Sm(i);return c?[c]:[]});o.length>0&&(n.page_marks=o,n.picked_elements=mm(o));const{controls:s,truncated:a}=Lr();return s.length>0&&(n.page_controls=s,a&&(n.page_controls_truncated=!0)),Object.keys(n).length>0?n:void 0}const Xm={click:"click",fill:"type into",select:"change",check:"switch on",uncheck:"switch off"};function Gm({request:e}){const{resolvePageAction:t}=C.useAgentChatUi(),n=Xm[e.action]??e.action,o=e.action==="select"?e.valueLabel??e.value:e.value;return r.jsxs("section",{"aria-label":`Allow the agent to ${n} ${e.controlName}`,"data-component":"chat/page_action",className:"min-w-0 rounded-2xl border border-foreground/10 bg-background p-2 text-foreground",children:[r.jsxs("p",{className:"px-1 pb-2 text-sm",children:["Let the agent ",n," ",r.jsx("span",{className:"font-medium",children:e.controlName})," on this page?"]}),(e.action==="fill"||e.action==="select")&&e.value!==void 0&&r.jsxs("div",{className:"mb-2 max-h-40 overflow-auto rounded-lg bg-foreground/5 px-2 py-1 text-sm",children:[r.jsx("span",{className:"font-medium",children:"New value: "}),r.jsx("span",{className:"whitespace-pre-wrap break-words",children:o===""?"(empty)":o})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{size:"sm",className:"flex-1",onClick:()=>t(e.callId,!0),children:"Allow"}),r.jsx(X,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>t(e.callId,!1),children:"No"})]})]})}const qt="rounded-full size-8 flex items-center justify-center p-0 overflow-hidden",Vi="bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground",Km=z("rounded-full p-0.5 text-muted-foreground","hover:bg-muted hover:text-foreground","transition-transform active:scale-90");function Zm({entity:e,onRemove:t}){const{t:n}=G();return r.jsxs("div",{...L("chat/input_box/page_context_pill"),className:z("flex items-center gap-1.5 max-w-full","rounded-full py-0.5 pe-1","text-xs text-foreground"),title:`${e.type}: ${e.title}`,children:[r.jsx(M.FileTextIcon,{className:"size-3 shrink-0 text-primary"}),r.jsx("span",{className:"truncate max-w-48 font-medium",children:e.title}),r.jsx("button",{type:"button","aria-label":n("page_context_remove"),className:Km,onClick:t,children:r.jsx(M.XIcon,{className:"size-3"})})]})}const Jm=S.z.object({type:S.z.string().min(1),id:S.z.string().min(1),title:S.z.string().min(1),meta:S.z.record(S.z.string(),S.z.unknown()).optional()});function Qm(){var o;const e=C.useConfig(),{widgetCtx:t}=C.useWidget();if(C.useHostLocation(),!t.features.pageContext)return null;const n=Jm.safeParse((o=K.resolveConfigContext(e))==null?void 0:o.entity);return n.success?n.data:null}function wn(e,t){var o;const n=(o=Object.entries(e).find(([s])=>s===t))==null?void 0:o[1];return typeof n=="string"?`hsl(${n})`:"currentColor"}function yo({cssVars:e,primaryColor:t,contentZIndex:n}){return{accent:t,surface:wn(e,"--opencx-background"),foreground:wn(e,"--opencx-foreground"),mutedForeground:wn(e,"--opencx-muted-foreground"),border:wn(e,"--opencx-border"),inkZIndex:n-2,chromeZIndex:n-1,editorZIndex:n+1}}function eh({isActive:e,draft:t,hover:n,onShapeChange:o,onAttach:s}){const a=$n(),{theme:i,cssVars:c}=me(),{t:d}=G();if(!a||!e)return null;const l=yo({cssVars:c,primaryColor:i.primaryColor,contentZIndex:i.widgetContentContainer.zIndex}),{accent:m}=l;return Qt.createPortal(r.jsxs("div",{"data-opencx-overlay":"",style:{pointerEvents:"none"},children:[r.jsx("style",{children:`
|
|
110
|
+
`)}function gi(){const{messageActions:e}=C.useConfig(),t=C.useDisplayMode();return(e==null?void 0:e.copy)??t==="companion"}function xi({messages:e}){const{t}=G(),{messageActions:n}=C.useConfig(),o=(n==null?void 0:n.display)==="always",[s,a]=u.useState(!1),i=u.useRef(null);u.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const c=sp(e),d=typeof navigator<"u"?navigator.clipboard:void 0;if(!d||c.length===0)return null;const l=()=>{d.writeText(c).then(()=>{a(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>a(!1),op)},p=>K.log.warn("copying the reply failed",p))},m=t(s?"copied":"copy_reply");return r.jsx("div",{...L("chat/agent_msg_group/actions"),className:z("flex items-center gap-1 -mt-0.5 transition-opacity duration-150",o?"opacity-100":z("opacity-0 group-hover:opacity-100 focus-within:opacity-100","[@media(hover:none)]:opacity-100")),children:r.jsx(Ne,{content:m,side:"bottom",align:"start",children:r.jsx("button",{...L("chat/agent_msg_group/actions/copy"),type:"button","aria-label":m,"aria-live":"polite",onClick:l,className:z("flex size-6 items-center justify-center rounded-md","text-muted-foreground/70 hover:bg-muted hover:text-foreground","transition-colors active:scale-95"),children:s?r.jsx(M.CheckIcon,{className:"size-3.5"}):r.jsx(M.CopyIcon,{className:"size-3.5"})})})})}function ap(e){return e.type==="AI"&&e.data.variant!=="error"}function Xt({messages:e,agent:t,suggestedReplies:n,actions:o=!0}){const s=gi(),a=e.filter(ap);return r.jsxs("div",{...L("chat/agent_msg_group/root"),className:z("group flex items-end gap-2"),children:[r.jsx(Ne,{content:t==null?void 0:t.name,side:"right",align:"end",children:r.jsx(kr,{...L("chat/agent_msg_group/root/avatar"),agent:t,className:"hidden"})}),r.jsxs("div",{className:z("flex-1 flex flex-col gap-1"),children:[r.jsxs("div",{...L("chat/agent_msg_group/avatar_and_msgs/root"),className:z("flex items-end gap-2"),children:[r.jsx(Ne,{content:t==null?void 0:t.name,side:"right",align:"end",children:r.jsx(kr,{...L("chat/agent_msg_group/avatar_and_msgs/avatar"),agent:t})}),r.jsxs("div",{...L("chat/agent_msg_group/avatar_and_msgs/msgs"),className:z("flex-1 flex flex-col gap-1"),children:[e.map((i,c,d)=>r.jsx(rp,{isFirstInGroup:c===0,isLastInGroup:c===d.length-1,isAloneInGroup:d.length===1,...i},i.id)),r.jsx(fi,{messages:e}),o&&s&&a.length>0&&r.jsx(xi,{messages:a})]})]}),n&&n.length>0&&r.jsx("div",{...L("chat/agent_msg_group/suggestions"),className:z("flex flex-col gap-1 ps-8"),children:n==null?void 0:n.map((i,c)=>r.jsx(Yt,{suggestion:i},`${i}-${c}`))})]})]})}const ds=["⠏","⠗","⠧","⠷","⠾","⠽","⠻","⠟"];function po({className:e}){const t=F.useReducedMotion(),[n,o]=u.useState(0);return u.useEffect(()=>{if(t)return;const s=setInterval(()=>o(a=>(a+1)%ds.length),80);return()=>clearInterval(s)},[t]),r.jsx("span",{className:z("select-none",e),"aria-hidden":!0,children:ds[n]})}function us({turn:e,agent:t,timestamp:n}){const{componentStore:o,config:s,widgetCtx:a}=C.useWidget(),i=gi(),c=o.getComponent("agent_chat_steps"),d=o.getComponent("agent_chat_spec"),l=o.getComponent("loading"),[m]=u.useState(()=>new Date().toISOString()),p=n??m,h=K.resolveClientPresentation(a.agent.presentation,s.presentation),f=C.applyPresentation(e.items,h),x=e.active&&(h==null?void 0:h.streaming)===!1&&!f.some(g=>g.kind==="questions");return r.jsxs("div",{...L("chat/streaming_turn/root"),className:"group flex flex-col gap-2",children:[f.map((g,y)=>g.kind==="text"?r.jsx(Xt,{messages:[{id:`streaming-${y}`,type:"AI",component:"bot_message",timestamp:p,data:{message:g.text},agent:t}],agent:t,actions:!1},`text-${y}`):g.kind==="spec"?d&&r.jsx(d,{parts:g.parts,active:e.active},`spec-${y}`):g.kind==="questions"||g.kind==="plan"||g.kind==="connection"?null:c&&r.jsx(c,{active:e.active,steps:g.steps},`steps-${y}`)),x&&l?r.jsx(l,{agent:t}):e.active&&!ip(f)&&r.jsx("div",{...L("chat/streaming_turn/working"),className:"flex h-5 items-center ps-1",children:r.jsx(po,{className:"text-[14px] leading-none text-primary/70"})}),!e.active&&i&&r.jsx(xi,{messages:f.flatMap(g=>g.kind==="text"?[{data:{message:g.text}}]:[])})]})}function ip(e){const t=e.at(-1);return(t==null?void 0:t.kind)==="steps"&&t.steps.some(n=>!n.done)}function cp({parts:e,active:t=!1}){const n=u.useMemo(()=>Yd(e),[e]);return r.jsx(Ya,{spec:n,active:t})}function lp({plan:e,active:t}){const[n,o]=u.useState(!1),s=u.useId(),a=F.useReducedMotion(),i=e.filter(m=>m.status==="completed").length,c=e.find(m=>m.status==="in_progress")??e.find(m=>m.status==="pending")??e[0],d=2*Math.PI*8,l=d*(1-(e.length>0?i/e.length:0));return r.jsxs("div",{className:"overflow-hidden rounded-xl border border-primary/10 bg-background shadow-sm","data-task-plan":!0,children:[r.jsxs("button",{type:"button",onClick:()=>o(m=>!m),"aria-expanded":n,"aria-controls":s,className:"flex w-full cursor-pointer items-center gap-3 px-3.5 py-2.5 text-start hover:bg-primary/[0.02] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary/40",children:[r.jsxs("svg",{"aria-hidden":"true",className:"size-5 shrink-0 -rotate-90",viewBox:"0 0 20 20",children:[r.jsx("circle",{cx:"10",cy:"10",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-primary/10"}),r.jsx(F.motion.circle,{cx:"10",cy:"10",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeDasharray:d,initial:!1,animate:{strokeDashoffset:l},transition:a?{duration:0}:ke,className:"text-emerald-600 dark:text-emerald-400"})]}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-primary",children:c==null?void 0:c.step}),r.jsxs("span",{className:"shrink-0 text-[0.8125rem] tabular-nums text-primary/50",children:[i,"/",e.length]}),r.jsx(F.motion.span,{"aria-hidden":"true",className:"flex size-3.5 shrink-0 items-center justify-center text-primary/50",initial:!1,animate:{rotate:n?0:180},transition:a?{duration:0}:ge,children:r.jsx(M.ChevronUp,{className:"size-3.5"})})]}),r.jsx("div",{id:s,"aria-hidden":!n,children:r.jsx(F.AnimatePresence,{initial:!1,children:n&&r.jsx(F.motion.div,{initial:{height:a?"auto":0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:a?"auto":0,opacity:0,transition:ge},transition:a?ge:ke,className:"overflow-hidden",children:r.jsx("ol",{className:"max-h-60 overflow-y-auto border-t border-primary/10 px-3.5 py-2",children:e.map((m,p)=>r.jsxs("li",{className:"flex items-start gap-2.5 py-1.5 text-sm","data-plan-status":m.status,children:[r.jsx("span",{"aria-hidden":"true",className:z("relative mt-0.5 size-4 shrink-0",!t&&"[&_.animate-spin]:animate-none"),children:r.jsx(F.AnimatePresence,{initial:!1,children:r.jsx(F.motion.span,{className:"absolute inset-0 flex items-center justify-center",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:ge,children:m.status==="completed"?r.jsx("span",{className:"flex size-4 items-center justify-center rounded-full bg-emerald-500/10",children:r.jsx(M.Check,{className:"size-2.5 text-emerald-600 dark:text-emerald-400"})}):m.status==="in_progress"?t?r.jsx(M.Loader2,{className:"size-4 animate-spin text-primary/60 motion-reduce:animate-none"}):r.jsx(M.CircleDashed,{className:"size-4 text-primary/40"}):r.jsx("span",{className:"size-1.5 rounded-full bg-primary/25"})},m.status)})}),r.jsx("span",{className:z(m.status==="completed"?"text-primary/50 line-through":m.status==="in_progress"?"font-medium text-primary":"text-primary/60"),children:m.step})]},p))})},"plan-steps")})})]})}function bi(){var n,o;const e=qe();if((n=e.session)!=null&&n.isOpened||!e.session)return null;const t=(o=e.config.customComponents)==null?void 0:o.onSessionResolved;return t?r.jsx(t,{...e}):null}function wi(){var n;const e=qe(),t=(n=e.config.customComponents)==null?void 0:n.chatBottomComponents;return t?r.jsx("div",{children:t.map(({key:o,component:s})=>r.jsx(s,{...e},o))}):null}function vi(e){const t=[];let n=null;return e.forEach(o=>{var s,a,i,c,d,l;(((s=n==null?void 0:n[0])==null?void 0:s.type)!==o.type||((a=n[0])==null?void 0:a.type)==="AGENT"&&o.type==="AGENT"&&(((i=o.agent)==null?void 0:i.id)!==((c=n[0].agent)==null?void 0:c.id)||((d=o.agent)==null?void 0:d.name)!==((l=n[0].agent)==null?void 0:l.name)))&&(n=[],t.push(n)),n.push(o)}),t}function Sr(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="USER"}function dp(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="AI"}function up(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="AGENT"}function yi(){const{messagesState:{messages:e}}=C.useMessages(),{chatBannerItems:t}=C.useConfig();return!(t!=null&&t.length)||e.length>0&&t.every(n=>!n.persistent)?null:r.jsx("div",{className:"w-full text-center text-xs",children:t.map(({message:n,persistent:o},s)=>e.length>0&&!o?null:r.jsx("div",{children:r.jsx(Qr,{children:n})},`${n}-${s}`))})}const pp=10*1024,ps=new Map;function mp(e){const t=ps.get(e);if(t!==void 0)return t;const n=hp(e);return ps.set(e,n),n}function hp(e){const t=e.trim();if(!t||t.length>pp||typeof DOMParser>"u")return null;const n=new DOMParser().parseFromString(t,"image/svg+xml"),o=n.documentElement;return o.localName!=="svg"||o.namespaceURI!=="http://www.w3.org/2000/svg"||n.getElementsByTagName("parsererror").length>0?null:`data:image/svg+xml,${encodeURIComponent(t)}`}const fp=ia.cva("inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium transition-colors",{variants:{variant:{default:"bg-primary text-primary-foreground",secondary:"bg-secondary text-secondary-foreground",outline:"border text-foreground"}},defaultVariants:{variant:"default"}});function gp({className:e,variant:t,...n}){return r.jsx("div",{className:z(fp({variant:t}),e),...n})}function ki({customStatus:e,className:t,dotClassName:n}){const o=e.icon?mp(e.icon):null,s=e.color||"currentColor";return o?r.jsx("span",{"aria-hidden":!0,className:z("size-3.5 shrink-0",t),style:{backgroundColor:s,maskImage:`url("${o}")`,maskSize:"contain",maskRepeat:"no-repeat",maskPosition:"center",WebkitMaskImage:`url("${o}")`,WebkitMaskSize:"contain",WebkitMaskRepeat:"no-repeat",WebkitMaskPosition:"center"}}):r.jsx("span",{"aria-hidden":!0,className:z("size-2 shrink-0 rounded-full",n),style:{backgroundColor:s}})}function ji({customStatus:e,className:t}){return r.jsxs(gp,{variant:"secondary",className:z("relative isolate overflow-hidden max-w-full text-primary",t),title:e.description||void 0,style:e.color?{color:`color-mix(in srgb, ${e.color} 55%, hsl(var(--opencx-foreground)))`}:void 0,children:[e.color&&r.jsx("span",{"aria-hidden":!0,className:"absolute inset-0 -z-10 opacity-20",style:{backgroundColor:e.color}}),r.jsx(ki,{customStatus:e}),r.jsx("span",{className:"truncate",children:e.name})]})}function Ci(){const{sessionState:{session:e}}=C.useSessions(),t=e==null?void 0:e.customStatus;return r.jsx(F.AnimatePresence,{mode:"wait",children:t&&r.jsx(oe,{className:"sticky top-2 z-10 self-center max-w-full",snapExit:!0,children:r.jsx(sn,{trigger:r.jsx(X,{variant:"ghost",size:"selfless",className:"rounded-full",children:r.jsx(ji,{customStatus:t})}),children:r.jsxs(on,{withClose:!0,children:[r.jsxs(Gr,{children:[r.jsx(ki,{customStatus:t,className:"size-8 mx-auto",dotClassName:"size-3 mx-auto"}),r.jsx(Zr,{children:t.name})]}),t.description&&r.jsx(Kr,{children:r.jsx(Jr,{children:t.description})})]})})},t.id)})}function Si({src:e,alt:t,title:n,note:o,shape:s="strip",className:a,children:i,...c}){const d=s==="tile";return r.jsxs("div",{...c,className:z("relative overflow-hidden bg-background ring-1 ring-border",d?"size-12 shrink-0 rounded-2xl":"max-w-full rounded-xl",a),children:[r.jsx("img",{src:e,alt:t,title:n,draggable:!1,className:z("block object-cover object-left-top",d?"size-full":"h-10 w-auto max-w-40")}),o&&r.jsx("div",{className:z("absolute inset-x-0 bottom-0 truncate px-1.5 py-0.5","bg-gradient-to-t from-foreground/70 to-foreground/0","text-[10px] font-medium leading-tight text-background"),children:o}),i]})}const mo=["#opencx-root","[data-opencx-root]","[data-opencx-overlay]"],gt='input,textarea,select,[contenteditable]:not([contenteditable="false"]),[role="textbox"],[role="searchbox"],[role="combobox"]',xp=[...mo,"[data-opencx-private]",'[aria-hidden="true"]',"[hidden]","script","style","noscript"].join(",");function Ni(e){var n;if(e.matches(xp))return!0;const t=(n=e.ownerDocument.defaultView)==null?void 0:n.getComputedStyle(e);return(t==null?void 0:t.display)==="none"||(t==null?void 0:t.visibility)==="hidden"||(t==null?void 0:t.visibility)==="collapse"||(t==null?void 0:t.opacity)==="0"}function Me(e){for(let t=e;t;t=t.parentElement)if(Ni(t))return!0;return!1}function _i(e){if(Me(e)||e.closest(gt))return"";const t=[],n=o=>{if(o instanceof Element){if(o!==e&&Ni(o)||o.matches(gt))return;const s=/^(ADDRESS|ARTICLE|ASIDE|BLOCKQUOTE|BR|DD|DETAILS|DIV|DL|DT|FIELDSET|FIGCAPTION|FIGURE|FOOTER|FORM|H[1-6]|HEADER|HR|LI|MAIN|NAV|OL|P|PRE|SECTION|SUMMARY|TABLE|TD|TH|TR|UL)$/.test(o.tagName);s&&t.push(" "),o.childNodes.forEach(n),s&&t.push(" ")}else o.nodeType===Node.TEXT_NODE&&t.push(o.textContent??"")};return n(e),t.join("").replace(/\s+/g," ").trim()}function ho(e){try{const t=new URL(e,window.location.href);return t.protocol==="http:"||t.protocol==="https:"?`${t.origin}${t.pathname}`:""}catch{return""}}function Gt(e){return e.getRootNode()===document&&!Me(e)&&!e.closest(gt)&&!e.matches("canvas,iframe,video,object,embed")&&!Array.from(e.querySelectorAll("*")).some(t=>Me(t)||t.matches(`${gt},canvas,iframe,video,object,embed`))}const bp=480,wp=3e3,Kt=new WeakMap,Nr=new WeakMap;async function vp(e){if(!Gt(e))return null;const t=e.getBoundingClientRect();if(t.width<1||t.height<1)return null;const n=Math.min(2,Math.max(.5,bp/Math.max(t.width,t.height))),o=Dc.toJpeg(e,{quality:.85,pixelRatio:n,backgroundColor:"#ffffff",filter:a=>!(a instanceof Element)||Gt(a)}),s=new Promise(a=>setTimeout(()=>a(null),wp));try{return await Promise.race([o,s])}catch{return null}}function yp(e,t){Nr.set(e,t),Kt.set(e,vp(t))}const _r=new WeakMap;function kp(e,t){if(_r.has(e))return;const n=Kt.get(e);if(!n)return;const o=n.then(s=>{const a=Nr.get(e);if(!(a!=null&&a.isConnected)||!Gt(a))return null;const i=s?Cp(s,"page-mark.jpg"):null;return i?t(i):null}).catch(()=>null).then(s=>{const a=Nr.get(e);return!(a!=null&&a.isConnected)||!Gt(a)?null:(s&&(e.snapshotUrl=s),s)});_r.set(e,o)}async function jp(e,t){if(e.snapshotUrl)return e.snapshotUrl;const n=_r.get(e);if(!n)return null;const o=new Promise(s=>setTimeout(()=>s(null),t));return Promise.race([n,o])}function Cp(e,t){const n=/^data:([^;,]+);base64,([\s\S]*)$/.exec(e);if(!n)return null;const[,o,s]=n;if(!o||s===void 0)return null;try{const a=atob(s),i=new Uint8Array(a.length);for(let c=0;c<a.length;c++)i[c]=a.charCodeAt(c);return new File([i],t,{type:o})}catch{return null}}function Sp(e){return Kt.get(e)}function Np(e,t){const n=Kt.get(e);n&&Kt.set(t,n)}function Ei(e){const[t,n]=u.useState(null);return u.useEffect(()=>{var s;if(n(null),!e)return;let o=!1;return(s=Sp(e))==null||s.then(a=>{!o&&a&&n(a)}),()=>{o=!0}},[e]),t}function _p({element:e}){const t=Ei(e.mark)??e.snapshotUrl??null,n=e.note??e.name;return t?r.jsx(Si,{src:t,alt:n,title:e.name,note:e.note}):r.jsxs("span",{className:z("inline-flex items-center gap-1.5 max-w-48","rounded-full py-1 ps-2 pe-2.5","bg-background ring-1 ring-border","text-xs text-foreground"),title:e.name,children:[r.jsx(M.PenLineIcon,{className:"size-3 shrink-0 text-primary"}),r.jsx("span",{className:"truncate",children:n})]})}const Ep=150,Ap=40,Tp=3;function Ip(e,t){const n=new Map;for(const a of e){const i=n.get(a.type);i?i.push(a):n.set(a.type,[a])}const o=[],s=[];for(const[a,i]of Array.from(n)){const c=t.has(a)?i:i.slice(0,Tp);o.push({type:a,items:c,hidden:i.length-c.length}),s.push(...c)}return{groups:o,visible:s}}function zp(e,t){const n=e.slice(0,t),o=/(?:^|\s)@(\S*)$/.exec(n);return o?{start:t-o[1].length-1,query:o[1]}:null}function Mp(e,t){const n=t.trim().toLowerCase();if(!n)return[...e];const o=s=>{var i;const a=s.title.toLowerCase();return a.startsWith(n)?0:a.includes(n)?1:(i=s.description)!=null&&i.toLowerCase().includes(n)?2:-1};return e.map((s,a)=>({item:s,index:a,rank:o(s)})).filter(s=>s.rank>=0).sort((s,a)=>s.rank-a.rank||s.index-a.index).map(s=>s.item)}const Ut=e=>`@${e.title}`;function ms(e,t){const n=[];for(const o of t){const s=Ut(o);let a=0;for(;;){const i=e.indexOf(s,a);if(i===-1)break;n.push({start:i,end:i+s.length}),a=i+s.length}}return n}function Rp({text:e,setText:t,inputRef:n}){const{mentions:o}=C.useConfig(),{widgetCtx:s}=C.useWidget(),a=o==null?void 0:o.items,i=o==null?void 0:o.search,c=u.useMemo(()=>{if(i)return i;if(a)return I=>Mp(a,I)},[i,a]),d=!!c&&s.features.pageContext,{mentions:l,setMentions:m}=C.useComposerDraft(),[p,h]=u.useState(null),[f,x]=u.useState([]),[g,y]=u.useState(()=>new Set),[w,j]=u.useState(0),[b,_]=u.useState(!1),{groups:v,visible:k}=u.useMemo(()=>Ip(f,g),[g,f]);u.useEffect(()=>{m(I=>{const W=I.filter($=>e.includes(Ut($)));return W.length===I.length?I:W})},[e,m]);const N=u.useCallback((I="nearest")=>{if(!d)return;const W=n.current;let $=(W==null?void 0:W.selectionStart)??e.length;if(W&&W.selectionStart===W.selectionEnd){const q=ms(e,l).find(se=>$>se.start&&$<se.end);q&&($=I==="forward"?q.end:I==="backward"||$-q.start<q.end-$?q.start:q.end,W.setSelectionRange($,$))}const U=zp(e,$),Y=U&&l.some(q=>e.startsWith(Ut(q),U.start))?null:U;h(q=>(q==null?void 0:q.start)===(Y==null?void 0:Y.start)&&(q==null?void 0:q.query)===(Y==null?void 0:Y.query)?q:Y)},[d,n,l,e]);u.useEffect(()=>N(),[N]);const R=u.useRef(0);u.useEffect(()=>{if(!p||!c){x([]),_(!1);return}const I=++R.current;_(!0);const W=setTimeout(()=>{Promise.resolve().then(()=>c(p.query)).then($=>{I===R.current&&(x($.slice(0,Ap)),y(new Set),j(0),_(!1))},$=>{I===R.current&&(K.log.warn("mentions search failed",$),x([]),_(!1))})},Ep);return()=>clearTimeout(W)},[p,c]);const T=u.useCallback(()=>{R.current+=1,h(null),x([]),_(!1)},[]),A=u.useCallback(I=>{if(!p)return;const W=p.start+1+p.query.length,$=`${Ut(I)} `,U=e.slice(0,p.start)+$+e.slice(W);t(U),m(q=>q.some(se=>se.type===I.type&&se.id===I.id)?q:[...q,I]),T();const Y=p.start+$.length;requestAnimationFrame(()=>{const q=n.current;q&&(q.focus(),q.setSelectionRange(Y,Y))})},[p,T,n,t,m,e]),O=u.useCallback(I=>{y(W=>new Set(W).add(I))},[]),P=d&&p!==null,B=u.useCallback(I=>{const W=n.current;if(d&&W&&W.selectionStart===W.selectionEnd&&(I.key==="Backspace"||I.key==="Delete")){const $=W.selectionStart,U=ms(e,l).find(Y=>I.key==="Backspace"?Y.end===$:Y.start===$);if(U){I.preventDefault();const Y=e[U.end]===" "?U.end+1:U.end;return t(e.slice(0,U.start)+e.slice(Y)),requestAnimationFrame(()=>W.setSelectionRange(U.start,U.start)),!0}}if(!P)return!1;if(I.key==="Escape")return I.preventDefault(),T(),!0;if(k.length===0)return!1;if(I.key==="ArrowDown")return I.preventDefault(),j($=>($+1)%k.length),!0;if(I.key==="ArrowUp")return I.preventDefault(),j($=>($-1+k.length)%k.length),!0;if(I.key==="Enter"||I.key==="Tab"){I.preventDefault();const $=k[w];return $&&A($),!0}return!1},[T,d,w,n,P,A,l,t,e,k]),E=u.useCallback(()=>{m([]),T()},[T,m]);return u.useMemo(()=>({picked:l,isOpen:P,anchorIndex:(p==null?void 0:p.start)??null,preview:(o==null?void 0:o.preview)!==!1,groups:v,visible:k,expandGroup:O,searching:b,highlighted:w,setHighlighted:j,pick:A,onKeyDown:B,onCaretMove:N,reset:E}),[l,P,p,o==null?void 0:o.preview,v,k,O,b,w,A,B,N,E])}function Ai({text:e,mentions:t,tokenClassName:n}){if(!t||t.length===0)return r.jsx(r.Fragment,{children:e});const o=Array.from(new Set(t.map(Ut))).sort((c,d)=>d.length-c.length),s=[];let a=e,i=0;for(;a.length>0;){let c=-1,d="";for(const l of o){const m=a.indexOf(l);m!==-1&&(c===-1||m<c)&&(c=m,d=l)}if(c===-1){s.push(a);break}c>0&&s.push(a.slice(0,c)),s.push(u.createElement("span",{...L("chat/mention"),key:i++,className:z("rounded-sm px-0.5 -mx-0.5",n)},d)),a=a.slice(c+d.length)}return r.jsx(r.Fragment,{children:s})}function Pp({message:e,isFirstInGroup:t,isLastInGroup:n,isAloneInGroup:o}){var s;return r.jsxs("div",{...L("chat/user_msg/root"),"data-message-id":e.id,className:"w-5/6 flex flex-col items-end gap-1",children:[e.markedElements&&e.markedElements.length>0&&r.jsx("div",{...L("chat/user_msg/marked_elements"),className:"w-full flex gap-1 flex-wrap justify-end",children:e.markedElements.map((a,i)=>r.jsx(_p,{element:a},`${a.name}-${i}`))}),e.attachments&&e.attachments.length>0&&r.jsx("div",{className:"w-full flex gap-1 flex-wrap justify-end",children:(s=e.attachments)==null?void 0:s.map(a=>r.jsx(ei,{attachment:a},a.id))}),e.content.length>0&&r.jsx("div",{...L("chat/user_msg/msg"),"data-first":t,"data-last":n,"data-alone":o,"data-pending":e.pending===!0,className:z("transition-all","w-fit py-3 px-4 rounded-3xl text-sm","bg-primary text-primary-foreground",e.pending&&"opacity-60","break-words [word-break:break-word]","whitespace-pre-wrap",t&&!o&&"rounded-br-md",n&&!o&&"rounded-tr-md",!t&&!n&&!o&&"rounded-r-md"),children:r.jsx(Ai,{text:e.content,mentions:e.mentions,tokenClassName:"bg-primary-foreground/20 font-medium"})})]})}function Ti({messages:e}){return r.jsxs("div",{...L("chat/user_msg_group/root"),className:z("group","flex flex-col gap-1 justify-end items-end"),children:[e.map((t,n,o)=>r.jsx(Pp,{message:t,isFirstInGroup:n===0,isLastInGroup:n===o.length-1,isAloneInGroup:o.length===1},t.id)),r.jsx(fi,{messages:e,containerClassName:"ms-auto"})]})}function Er(e){return e.replace(/<[^<>]*>/g," ").replace(/<[^<>]*$/,"").replace(/[ \t]{2,}/g," ").replace(/\s+([،,.؟?!…])/g,"$1").trim()}const Op={start_call:"Start a voice call",connecting:"Connecting…",waiting:"Getting ready…",queued:"Waiting for the next agent…",listening:"Listening",speaking:"{name} is speaking",reconnecting:"Reconnecting…",ended:"Call ended",mute:"Mute",unmute:"Unmute",end_call:"End call",tap_to_hear:"Tap to hear",back_to_chat:"Back to chat",try_again:"Try again",muted_hint:"You are muted",call_card_title:"Voice call",show_full_transcript:"Show full transcript",show_less:"Show less",transcript_loading:"Loading the transcript…",transcript_empty:"No transcript for this call.",default_agent:"Agent",error_generic:"The call could not connect. Check your microphone and try again.",error_timeout:"No one picked up. Try again in a moment.",error_busy:"A call is already in progress."},Lp={start_call:"ابدأ مكالمة صوتية",connecting:"جارٍ الاتصال…",waiting:"جارٍ التجهيز…",queued:"بانتظار أول موظف متاح…",listening:"أستمع إليك",speaking:"{name} تتحدث",reconnecting:"جارٍ إعادة الاتصال…",ended:"انتهت المكالمة",mute:"كتم الصوت",unmute:"إلغاء الكتم",end_call:"إنهاء المكالمة",tap_to_hear:"اضغط لتسمع",back_to_chat:"العودة إلى المحادثة",try_again:"حاول مجددًا",muted_hint:"الميكروفون مكتوم",call_card_title:"مكالمة صوتية",show_full_transcript:"عرض نص المكالمة كاملًا",show_less:"عرض أقل",transcript_loading:"جارٍ تحميل نص المكالمة…",transcript_empty:"لا يوجد نص لهذه المكالمة.",default_agent:"المساعد",error_generic:"تعذّر الاتصال. تحقّق من الميكروفون وحاول مجددًا.",error_timeout:"لم يردّ أحد. حاول بعد قليل.",error_busy:"هناك مكالمة جارية بالفعل."};function fo(e,t,n={}){return(e==="ar"?Lp:Op)[t].replace(/\{(\w+)\}/g,(s,a)=>n[a]??s)}function $p(e,t){const n={hour:"numeric",minute:"2-digit",numberingSystem:"latn"};try{return new Intl.DateTimeFormat(e,n).format(t)}catch(o){return console.error("Voice call time failed to format",{_e:o,language:e}),new Intl.DateTimeFormat(void 0,n).format(t)}}function Ii(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),o=Math.floor(t%3600/60),s=String(t%60).padStart(2,"0");return n>0?`${n}:${String(o).padStart(2,"0")}:${s}`:`${o}:${s}`}const Dp=60;function Fp(e,t,n){const o=[];for(const s of t){const a=`voice-call-${e}-${s.id}`,i=s.at>0?new Date(s.at).toISOString():null,c=o.at(-1);if(s.role==="user"){const d={id:a,type:"USER",content:Er(s.text),deliveredAt:i,timestamp:i};(c==null?void 0:c.role)==="user"?c.messages.push(d):o.push({role:"user",messages:[d]})}else{const d={id:a,type:"AI",component:"bot_message",data:{message:Er(s.text)},timestamp:i,agent:n};(c==null?void 0:c.role)==="agent"?c.messages.push(d):o.push({role:"agent",messages:[d]})}}return o}function Hp({label:e}){return r.jsxs("div",{...L("chat/voice_call/loading"),role:"status","aria-label":e,className:"flex flex-col gap-2",children:[r.jsx("div",{className:"opencx-voice-skeleton h-10 w-3/4 rounded-3xl"}),r.jsx("div",{className:"opencx-voice-skeleton h-10 w-1/2 self-end rounded-3xl"}),r.jsx("div",{className:"opencx-voice-skeleton h-10 w-2/3 rounded-3xl"})]})}function _n({call:e}){const t=C.useBot(),{language:n}=G(),[o,s]=u.useState(!1),a=m=>fo(n,m),i=e.transcript.length>Dp,c=i&&!o,d=u.useMemo(()=>Fp(e.id,c?e.transcript.slice(-8):e.transcript,t),[e.id,e.transcript,c,t]),l=a("call_card_title");return r.jsxs("section",{...L("chat/voice_call/root"),"aria-label":l,className:"opencx-fade-up flex flex-col gap-3",children:[r.jsxs("header",{...L("chat/voice_call/header"),className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{"aria-hidden":"true",className:"h-px flex-1 bg-border"}),r.jsx(M.PhoneIcon,{"aria-hidden":"true",className:"size-3 shrink-0"}),r.jsx("span",{className:"font-medium",children:l}),r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx("span",{dir:"ltr",className:"tabular-nums",children:Ii(e.durationMs)}),r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx("span",{className:"tabular-nums",children:$p(n,e.startedAt)}),r.jsx("span",{"aria-hidden":"true",className:"h-px flex-1 bg-border"})]}),e.transcriptLoading?r.jsx(Hp,{label:a("transcript_loading")}):e.transcript.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:a("transcript_empty")}):r.jsxs(r.Fragment,{children:[i&&r.jsx("button",{...L("chat/voice_call/toggle"),type:"button","aria-expanded":o,onClick:()=>s(m=>!m),className:"self-center rounded-full px-3 py-1 text-xs font-medium text-muted-foreground transition-colors duration-150 hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:a(o?"show_less":"show_full_transcript")}),r.jsx("div",{className:"flex flex-col gap-2",children:d.map(m=>{var h;const p=(h=m.messages[0])==null?void 0:h.id;return m.role==="user"?r.jsx(Ti,{messages:m.messages},p):r.jsx(Xt,{messages:m.messages,agent:t,actions:!1},p)})})]})]})}const Wp=1200;async function Bp(e,t){const{data:n,error:o}=await e.pollSessionAndHistory({sessionId:t,abortSignal:AbortSignal.timeout(1e4)});if(o||!n)throw new Error("Voice call history request failed");return n.history.flatMap(s=>{var d;const a=(d=s.content.text)==null?void 0:d.trim(),i=s.sender.kind==="user"?"user":s.sender.kind==="ai"||s.sender.kind==="agent"?"agent":null;if(!a||!i)return[];const c=s.sentAt?Date.parse(s.sentAt):0;return[{id:s.publicId,role:i,text:a,final:!0,at:c}]})}function Up(e){var n;const t=e.routerCtx.state.get().screen==="chat"?e:e.routerCtx.toChatScreen()??e;return{ctx:t,sessionId:((n=t.sessionCtx.sessionState.get().session)==null?void 0:n.id)??null}}const zi=u.createContext(null),qp={enabled:!1,isOpen:!1,state:"idle",error:null,audioBlocked:!1,muted:!1,connectedAt:null,levelsRef:{current:{local:0,remote:0}},threadCalls:[],transcript:[],start:async()=>{K.log.warn("voice call unavailable: `voice` is not configured")},end:async()=>{},toggleMute:()=>{},resumeAudio:()=>{},close:()=>{}};function Ot(){return u.useContext(zi)??qp}function Vp({children:e}){const{voice:t,apiUrl:n}=C.useConfig(),{widgetCtx:o}=C.useWidget(),{sessionState:{session:s}}=C.useSessions(),a=(s==null?void 0:s.id)??null,[i,c]=u.useState(!1),[d,l]=u.useState("idle"),[m,p]=u.useState(null),[h,f]=u.useState(!1),[x,g]=u.useState(!1),[y,w]=u.useState(null),[j,b]=u.useState([]),[_,v]=u.useState([]),k=u.useRef(0),N=u.useRef({local:0,remote:0}),R=u.useRef(null),T=u.useRef(null),A=u.useRef(null),O=u.useRef(t==null?void 0:t.getToken);O.current=t==null?void 0:t.getToken;const P=u.useRef(o);P.current=o;const B=u.useCallback(()=>c(!1),[]);u.useEffect(()=>{a&&b(D=>D.some(V=>V.thread.ctx===o&&V.thread.sessionId===null)?D.map(V=>V.thread.ctx===o&&V.thread.sessionId===null?{...V,thread:{ctx:o,sessionId:a}}:V):D)},[o,a]);const E=u.useMemo(()=>j.filter(D=>D.thread.ctx===o&&(D.thread.sessionId===null||D.thread.sessionId===a)&&(a===null||D.voiceSessionId!==a)),[j,o,a]),I=u.useCallback(D=>{if(R.current!==D)return;R.current=null,N.current={local:0,remote:0};const V=A.current;if(A.current=null,V===null)return;const Z=++k.current,te=D.getTranscript().segments.filter(J=>J.text.trim()),ae=D.sessionId??null,xe=te.length===0&&ae!==null,H=Up(P.current);if(b(J=>[...J,{id:Z,startedAt:V,durationMs:Date.now()-V,transcript:te,transcriptLoading:xe,voiceSessionId:ae,thread:H}]),!xe||ae===null)return;const ee=J=>b(ne=>ne.map(le=>le.id===Z?{...le,transcript:J,transcriptLoading:!1}:le));Bp(P.current.api,ae).then(ee).catch(J=>{console.error("Voice call transcript failed to load",{_e:J}),ee([])})},[]),W=u.useCallback(async()=>{const D=O.current;if(!D){K.log.warn("voice call unavailable: `voice` is not configured");return}if(c(!0),R.current)return;o.dictationCtx.stop({executeFinalCommand:!1}),A.current=null,N.current={local:0,remote:0},p(null),f(!1),g(!1),w(null),v([]),l("connecting");const V=T.current;T.current=null,V==null||V.dispose().catch(te=>{console.error("Previous voice call cleanup failed",{_e:te})});let Z;try{const{OpenCXVoice:te}=await Fc.loadVoiceSdk();Z=new te({getToken:D,apiUrl:n})}catch(te){console.error("Voice call failed to load",{_e:te}),p({code:"load_failed",message:"Voice is unavailable"}),l("ended");return}R.current=Z,T.current=Z,Z.on("stateChanged",te=>{R.current===Z&&(l(te),te==="connected"&&A.current===null&&(A.current=Date.now(),w(A.current)),te==="ended"&&I(Z))}),Z.on("error",te=>{if(T.current===Z){if(te.code==="audio_blocked"){f(!0);return}console.error("Voice call error",{_e:te,code:te.code}),c(!0),p({code:te.code,message:te.message})}}),Z.on("levels",te=>{N.current=te}),Z.on("transcript",te=>{R.current===Z&&v(te.segments)});try{await Z.start()}catch{}},[n,I,o]),$=u.useCallback(async()=>{const D=R.current;if(!D){B();return}try{await D.end()}catch{}},[B]),U=u.useCallback(()=>{const D=R.current;if(!D)return;const V=!x;g(V),D.setMuted(V).catch(Z=>{console.error("Voice mute failed",{_e:Z}),g(!V)})},[x]),Y=u.useCallback(()=>{const D=R.current;D&&D.resumeAudio().then(()=>f(!1)).catch(V=>{console.error("Voice audio resume failed",{_e:V})})},[]);u.useEffect(()=>{if(!i||d!=="ended"||m)return;const D=setTimeout(()=>c(!1),Wp);return()=>clearTimeout(D)},[i,d,m]),u.useEffect(()=>()=>{const D=T.current;R.current=null,T.current=null,D==null||D.dispose().catch(V=>{console.error("Voice call cleanup failed",{_e:V})})},[]);const q=!!t,se=u.useMemo(()=>({enabled:q,isOpen:i,state:d,error:m,audioBlocked:h,muted:x,connectedAt:y,levelsRef:N,threadCalls:E,transcript:_,start:W,end:$,toggleMute:U,resumeAudio:Y,close:B}),[q,i,d,m,h,x,y,E,_,W,$,U,Y,B]);return r.jsx(zi.Provider,{value:se,children:e})}function Mi(e){const t=e.timestamp?Date.parse(e.timestamp):Number.POSITIVE_INFINITY;return Number.isNaN(t)?Number.POSITIVE_INFINITY:t}function Ri(e,t){const n=e.findIndex(o=>o.startedAt>=t);return e.splice(0,n===-1?e.length:n)}function Pi(){var c;const{messagesState:{messages:e}}=C.useMessages(),t=C.useConfig(),n=C.useBot(),{advancedInitialMessages:o=[],initialQuestions:s,initialQuestionsPosition:a}=t;if(e.length>0)return null;const i=o.length?o.map(d=>d.message):(c=t.initialMessages)!=null&&c.length?t.initialMessages:["Hello, how can I help you?"];return r.jsx(Xt,{messages:i.map((d,l)=>({component:"bot_message",data:{message:d},id:`${l}-${d}`,type:"AI",timestamp:null})),suggestedReplies:a==="below-initial-messages"?s:void 0,agent:n})}function Ar({groups:e,pendingReply:t=!1}){const{humanAgent:n}=C.useConfig(),o=C.useBot();return r.jsx(r.Fragment,{children:e.map((s,a)=>{var c,d;const i=(c=s[0])==null?void 0:c.id;if(!i)return null;if(Sr(s))return r.jsx(Ti,{messages:s},i);if(dp(s))return r.jsx(Xt,{messages:s,agent:o,actions:!t||a!==e.length-1},i);if(up(s)){const l=(d=s[0])==null?void 0:d.agent;return r.jsx(Xt,{messages:s,agent:l?{...l,name:(n==null?void 0:n.name)||l.name||"",avatarUrl:(n==null?void 0:n.avatarUrl)||l.avatarUrl||null}:n?{isAi:!1,id:null,name:n.name||"",avatarUrl:n.avatarUrl||null}:void 0},i)}return null})})}const Yp=150;function Xp({scrollHeight:e,scrollTop:t,clientHeight:n},o=Yp){return e-t-n<o}function Gp(e){const t=u.useRef(null),n=u.useRef(!0),[o,s]=u.useState(!1),a=u.useRef(null),[i]=u.useState(()=>new Set),c=u.useCallback(()=>{const l=t.current,m=l?Xp(l):!0;n.current=m,s(!m)},[]),d=u.useCallback(()=>{const l=t.current;l&&(l.scrollTo({top:l.scrollHeight,behavior:"smooth"}),n.current=!0,s(!1))},[]);return u.useEffect(()=>{if(!n.current)return;const l=setTimeout(()=>{const m=t.current;m&&(m.scrollTop=m.scrollHeight)},0);return()=>clearTimeout(l)},e),u.useEffect(()=>{const l=t.current;if(!l)return;const m=new ResizeObserver(()=>{n.current&&(l.scrollTop=l.scrollHeight)});return a.current=m,()=>{m.disconnect(),a.current=null,i.clear()}},[i]),u.useEffect(()=>{const l=t.current,m=a.current;!l||!m||(i.forEach(p=>{p.isConnected||(m.unobserve(p),i.delete(p))}),Array.from(l.children).forEach(p=>{i.has(p)||(m.observe(p),i.add(p))}))}),{containerRef:t,handleScroll:c,showScrollDown:o,scrollToBottom:d}}function Kp(){const{messagesState:{messages:e}}=C.useMessages(),{isStreaming:t,liveItems:n,turnSources:o,liveTurnKey:s,turnFailed:a,retryFailedTurn:i}=C.useAgentChatUi(),{componentStore:c}=C.useWidget(),{t:d}=G(),l=C.useBot(),{sessionState:{session:m}}=C.useSessions(),p=u.useMemo(()=>C.sessionPlan({liveItems:n,turnSources:o}),[n,o]),h=u.useMemo(()=>vi(e),[e]),{threadCalls:f}=Ot(),x=u.useMemo(()=>{const T=new Map;for(const A of o)for(const O of A.rowIds)T.set(O,A);return T},[o]),g=u.useMemo(()=>{for(let T=h.length-1;T>=0;T-=1){const A=h[T];if(A&&Sr(A))return T}return-1},[h]),y=n.length>0,{nodes:w,renderedSourceKeys:j}=u.useMemo(()=>{const T=[],A=new Set,O=[...f];h.forEach((P,B)=>{const E=P[0],I=E==null?void 0:E.id;if(!E||!I)return;for(const U of Ri(O,Mi(E)))T.push(r.jsx(_n,{call:U},`voice-call-${U.id}`));if(Sr(P)){T.push(r.jsx(Ar,{groups:[P]},I));return}let W=[];const $=()=>{var Y;const U=(Y=W[0])==null?void 0:Y.id;U&&T.push(r.jsx(Ar,{groups:[W]},U)),W=[]};for(const U of P){const Y=x.get(U.id);Y?($(),A.has(Y.key)||(A.add(Y.key),T.push(r.jsx(us,{turn:{active:!1,items:Y.items},agent:l,timestamp:U.timestamp},Y.key)))):y&&B>g||W.push(U)}$()});for(const P of O)T.push(r.jsx(_n,{call:P},`voice-call-${P.id}`));return{nodes:T,renderedSourceKeys:A}},[h,x,y,g,l,f]),b=s!==null&&n.length>0&&!j.has(s),_=c.getComponent("loading"),{containerRef:v,handleScroll:k,showScrollDown:N,scrollToBottom:R}=Gp([e,n,f]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{...L("chat/msgs/wrapper"),className:"relative flex flex-1 flex-col min-h-0",children:[r.jsxs("div",{...L("chat/msgs/root"),ref:v,onScroll:k,className:"max-h-full relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[r.jsx(Ci,{}),r.jsx(yi,{}),r.jsx(Pi,{}),[...w,...b?[r.jsx(us,{turn:{active:t,items:n},agent:l},s)]:[]],t&&n.length===0&&_&&r.jsx(_,{agent:l}),a&&!t&&r.jsxs("div",{...L("chat/turn_failed/root"),className:"flex items-center gap-2 self-start rounded-xl border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[r.jsx("span",{children:d("turn_failed_message")}),r.jsx("button",{...L("chat/turn_failed/retry"),type:"button",onClick:i,className:"font-medium underline underline-offset-2 hover:opacity-80",children:d("turn_failed_retry")})]}),r.jsx(wi,{}),r.jsx(bi,{})]}),r.jsx(F.AnimatePresence,{children:N&&u.createElement(F.motion.button,{...L("chat/msgs/scroll-to-bottom"),key:"scroll-to-bottom",type:"button",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.15},onClick:R,"aria-label":d("scroll_to_bottom"),className:"absolute bottom-3 left-1/2 z-20 flex size-8 -translate-x-1/2 items-center justify-center rounded-full border border-border bg-background text-muted-foreground shadow-lg transition-colors hover:text-foreground"},r.jsx(M.ArrowDown,{className:"size-4"}))})]}),p&&p.length>0&&r.jsx("div",{...L("chat/session-plan"),className:"shrink-0 px-4 pb-2",children:r.jsx(lp,{plan:p,active:t},(m==null?void 0:m.id)??"new-session")})]})}function Zp(){const e=qe(),{activeMode:t,Component:n}=C.useModes(),o=an(),{createStateCheckpoint:s}=C.useSessions(),[a,i]=u.useState(!1),c=async d=>{try{i(!0),await o(d)}catch(l){K.log.error("mode component send failed",l)}finally{i(!1)}};return!t||!n?null:r.jsx(n,{...e,mode:t,createStateCheckpoint:s,sendMessage:c,isSendingMessage:a})}function Oi(){const{requireInitialQuestion:e,initialQuestions:t}=C.useConfig(),{messagesState:n}=C.useMessages();return e===!0&&n.messages.length===0&&(t==null?void 0:t.some(o=>o.trim().length>0))===!0}const Jp=5e3;function Qp({stickyQuestions:e,messages:t,isHandedOff:n,isStreaming:o,isTyping:s,otherSuggestionsShowing:a}){const i=(e==null?void 0:e.filter(h=>h.trim().length>0))??[],c=t.findLast(h=>h.type!=="SYSTEM"),d=i.length>0&&!n&&!o&&(c==null?void 0:c.type)==="AI"&&c.data.variant!=="error"?c.id:null,[l,m]=u.useState(null);return u.useEffect(()=>{if(d===null)return;const h=setTimeout(()=>m(d),Jp);return()=>clearTimeout(h)},[d]),d!==null&&l===d&&!s&&!a?i:[]}function Tr({isStreaming:e,messages:t,session:n}){return!e&&K.isAwaitingRequiredTap(t,n)}const _e=u.forwardRef((e,t)=>{var n,o,s;return r.jsx(oe,{...e,ref:t,className:z("overflow-hidden",e.className),overrides:{initial:{height:0,opacity:0,...(n=e.overrides)==null?void 0:n.initial},animate:{height:"auto",opacity:1,...(o=e.overrides)==null?void 0:o.animate},exit:{height:0,opacity:0,...(s=e.overrides)==null?void 0:s.exit}}})});_e.displayName="MotionDiv__VerticalReveal";const em=[{label:"Terrible",value:1,emoji:"😡"},{label:"Poor",value:2,emoji:"😞"},{label:"Okay",value:3,emoji:"😐"},{label:"Good",value:4,emoji:"😊"},{label:"Great",value:5,emoji:"😍"}];function Qn({surveyType:e="csat"}){var n,o;const t=C.useCsat(e);return r.jsx(tm,{surveyType:e,survey:t},((n=t.csatRequestedMessage)==null?void 0:n.id)??((o=t.csatSubmittedMessage)==null?void 0:o.id)??e)}function tm({surveyType:e,survey:t}){const{isSmallScreen:n}=je(),{t:o}=G(),{submitCsat:s,isCsatRequested:a,isCsatSubmitted:i,submittedScore:c,submittedFeedback:d,question:l}=t,[m,p]=u.useState(!1),[h,f]=u.useState(!1),x=e==="csat"?em:Array.from({length:e==="nps"?11:5},(v,k)=>({value:k+(e==="nps"?0:1),emoji:String(k+(e==="nps"?0:1)),label:String(k+(e==="nps"?0:1))})),[g,y]=u.useState(null),[w,j]=u.useState(null),b=v=>{y(k=>k===v?null:v)},_=async()=>{if(!(g===null||m)){p(!0),f(!1);try{const v=await s({score:g,feedback:w||void 0});f(!!v.error)}catch(v){console.error("Unable to submit survey",{_e:v}),f(!0)}finally{p(!1)}}};return!a&&!i?null:r.jsxs("div",{className:z("mx-auto overflow-hidden",e==="csat"&&"w-1/2 min-w-80 max-w-96",e==="nps"&&"w-full max-w-[30rem]",e==="ces"&&"w-full max-w-80"),children:[r.jsx(F.AnimatePresence,{mode:"wait",children:a&&g===null?r.jsx(_e,{children:r.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:l??o("csat_title")})},"csat-requested-title"):i?r.jsx(_e,{children:r.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:o("csat_submitted_title")})},"csat-submitted-title"):null}),r.jsx("div",{dir:"ltr",className:z("flex pt-2 px-2 pb-2",e==="csat"?"gap-4 justify-between":"gap-0.5 justify-between","transition-all",i&&"gap-0 justify-center"),children:x.map(v=>r.jsx(X,{"aria-label":v.label,"aria-pressed":e==="csat"?void 0:v.value===(c??g),disabled:m||i,variant:v.value===g?"secondary":"ghost",size:"selfless",className:z("transition-all overflow-hidden",e==="csat"?"text-2xl size-8 rounded-full":"h-10 min-w-0 max-w-11 flex-1 rounded-full text-sm tabular-nums",e!=="csat"&&v.value===g&&"bg-foreground text-background hover:bg-foreground","opacity-35","hover:opacity-100",g===null&&"opacity-100",v.value===g&&"opacity-100",i&&v.value!==c&&"opacity-0 size-0",i&&v.value===c&&"opacity-100 size-fit text-4xl",e!=="csat"&&i&&(v.value===c?"flex-none bg-transparent text-foreground disabled:opacity-100":"hidden")),onClick:a?()=>b(v.value):void 0,children:v.emoji},v.value))}),e!=="csat"&&a&&g===null&&r.jsxs("p",{dir:"ltr",className:"flex justify-between gap-2 px-2 text-xs text-muted-foreground",children:[r.jsx("span",{dir:"auto",children:o(e==="nps"?"nps_low_label":"ces_low_label")}),r.jsx("span",{dir:"auto",children:o(e==="nps"?"nps_high_label":"ces_high_label")})]}),h&&r.jsx("p",{role:"alert",className:"text-sm text-center",children:o("survey_submit_error")}),r.jsx(F.AnimatePresence,{mode:"wait",children:(g!==null||i&&c!=null)&&r.jsx(_e,{children:r.jsxs("div",{className:"pb-2 px-2 flex items-end",children:[r.jsx("textarea",{rows:3,className:z("transition-all","max-h-40 [field-sizing:content]","w-full resize-none","bg-transparent outline-none","placeholder:text-muted-foreground",n?"text-[16px]":"text-sm",i&&"text-center"),value:i?d||"":w||"",onChange:a?v=>j(v.target.value):void 0,readOnly:i,placeholder:a?o("csat_feedback_placeholder"):void 0}),r.jsx(X,{size:"fit",onClick:()=>void _(),disabled:g===null||m,className:z("transition-all overflow-hidden","rounded-full size-8 flex items-center justify-center p-0",i&&"opacity-0 size-0"),children:r.jsx(M.ArrowUpIcon,{className:"size-4"})})]})},"feedback-box")}),r.jsx("div",{className:z("h-0 transition-[height]",i&&"h-4")})]})}function nm(){const{t:e}=G(),t=[e("i_need_more_help"),e("this_was_helpful")];return r.jsx("div",{...L("chat/might_solve_user_issue_suggested_replies_container"),className:"flex items-center gap-2 p-2 pb-0 flex-wrap",children:t.map(n=>r.jsx(Yt,{suggestion:n,className:"flex-1"},n))})}function Ir(){const{sessionState:e}=C.useSessions(),{chatFooterItems:t}=C.useConfig(),n=!!e.session&&!e.session.isOpened,o=!n;return r.jsx(F.AnimatePresence,{mode:"wait",children:t==null?void 0:t.map((s,a)=>s.showWhenSessionIsOpen===!1&&o||s.showWhenSessionIsResolved===!1&&n?null:r.jsx(_e,{children:r.jsx("div",{className:"pb-2 text-center text-xs",children:r.jsx(Au,{children:s.message})})},`${s.message}-${a}`))})}function En(){return r.jsxs("svg",{viewBox:"0 0 180 180",fill:"none",className:"size-5 shrink-0 stroke-current",strokeWidth:"12",strokeLinecap:"round","aria-hidden":!0,"data-mcp-icon":!0,children:[r.jsx("path",{d:"M18 84.8528L85.8822 16.9706C95.2548 7.59798 110.451 7.59798 119.823 16.9706V16.9706C129.196 26.3431 129.196 41.5391 119.823 50.9117L68.5581 102.177"}),r.jsx("path",{d:"M69.2652 101.47L119.823 50.9117C129.196 41.5391 144.392 41.5391 153.765 50.9117L154.118 51.2652C163.491 60.6378 163.491 75.8338 154.118 85.2063L92.7248 146.6C89.6006 149.724 89.6006 154.789 92.7248 157.913L105.331 170.52"}),r.jsx("path",{d:"M102.853 33.9411L52.6482 84.1457C43.2756 93.5183 43.2756 108.714 52.6482 118.087V118.087C62.0208 127.459 77.2167 127.459 86.5893 118.087L136.794 67.8822"})]})}function rm({sessionId:e,active:t}){var i;const{widgetCtx:n,config:o}=C.useWidget(),[s,a]=u.useState(null);return u.useEffect(()=>{var m;if(a(null),!t||((m=o.capabilities)==null?void 0:m.connections)!==!0)return;const c=new AbortController;let d;const l=async()=>{try{const p=await n.api.listElicitations(e,c.signal);c.signal.aborted||a(p[0]??null)}catch{a(p=>p&&p.expiresAt>Date.now()?p:null)}c.signal.aborted||(d=setTimeout(l,1500))};return l(),()=>{c.abort(),clearTimeout(d)}},[n,e,t,(i=o.capabilities)==null?void 0:i.connections]),r.jsxs(r.Fragment,{children:[" ",s&&s.expiresAt>Date.now()?r.jsx(om,{request:s,onAnswer:async c=>{await n.api.answerElicitation(e,s.id,c),a(null)}},s.id):null]})}function om({request:e,onAnswer:t}){var m,p;const[n,o]=u.useState(!1),[s,a]=u.useState(""),i=async h=>{if(!n){o(!0),a("");try{await t(h)}catch(f){a(f instanceof Error?f.message:"Could not submit. Try again.")}finally{o(!1)}}},c=e.form.requestedSchema.properties,d=Object.keys(c).length===1&&((m=c.approve)==null?void 0:m.type)==="boolean"&&((p=e.form.requestedSchema.required)==null?void 0:p.includes("approve")),l="w-full rounded-lg border border-foreground/15 bg-background px-2 py-1.5 text-base sm:text-sm";return r.jsxs("form",{"aria-label":`Request from ${e.serverName}`,className:`min-w-0 rounded-2xl border border-foreground/10 bg-background p-2 space-y-2 text-foreground ${d?"overflow-visible":"max-h-[50vh] overflow-y-auto"}`,onSubmit:h=>{if(h.preventDefault(),d){i({action:"accept",content:{approve:!0}});return}const f=new FormData(h.currentTarget),x={};for(const[g,y]of Object.entries(c)){const w=f.get(g);if(y.type==="boolean")x[g]=w==="on";else if(y.type==="array"){const j=f.getAll(g).filter(b=>typeof b=="string");if(y.minItems!==void 0&&j.length<y.minItems){a(`${y.title??g}: select at least ${y.minItems} options.`);return}if(y.maxItems!==void 0&&j.length>y.maxItems){a(`${y.title??g}: select no more than ${y.maxItems} options.`);return}x[g]=j}else typeof w=="string"&&w!==""&&(x[g]=y.type==="number"||y.type==="integer"?Number(w):w)}i({action:"accept",content:x})},children:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("div",{className:"mt-0.5 size-4 shrink-0 text-foreground/50",title:e.serverName,children:r.jsx(En,{})}),r.jsx("p",{className:"min-w-0 flex-1 text-sm leading-5 break-words",children:e.form.message}),r.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-foreground/50",wobble:!1,"aria-label":"Cancel request",disabled:n,onClick:()=>void i({action:"cancel"}),children:r.jsx(M.X,{className:"size-3.5"})})]}),!d&&r.jsx("fieldset",{disabled:n,className:"space-y-3",children:Object.entries(c).map(([h,f])=>{var w,j,b,_,v;const x=`${e.id}-${h}`,g=f.oneOf??((w=f.enum)==null?void 0:w.map(k=>({const:k,title:k})))??((j=f.items)==null?void 0:j.anyOf)??((_=(b=f.items)==null?void 0:b.enum)==null?void 0:_.map(k=>({const:k,title:k}))),y=(v=e.form.requestedSchema.required)==null?void 0:v.includes(h);return r.jsxs("div",{children:[r.jsxs("label",{htmlFor:x,className:"block text-sm font-medium mb-1",children:[f.title??h,y?" *":""]}),f.description&&r.jsx("p",{className:"text-sm text-foreground/60 mb-1",children:f.description}),f.type==="boolean"?r.jsx("input",{id:x,name:h,type:"checkbox",defaultChecked:f.default===!0,className:"size-5 accent-current"}):g?r.jsxs("select",{id:x,name:h,multiple:f.type==="array",required:y,className:l,defaultValue:typeof f.default=="string"||Array.isArray(f.default)?f.default:f.type==="array"?[]:"",children:[f.type!=="array"&&r.jsx("option",{value:"",children:"Choose…"}),g.map(k=>r.jsx("option",{value:k.const,children:k.title??k.const},k.const))]}):r.jsx("input",{id:x,name:h,className:l,type:f.type==="number"||f.type==="integer"?"number":f.format==="email"?"email":f.format==="uri"?"url":f.format==="date"?"date":"text",required:y,min:f.minimum,max:f.maximum,step:f.type==="integer"?1:"any",minLength:f.minLength,maxLength:f.maxLength,defaultValue:typeof f.default=="string"||typeof f.default=="number"?f.default:""})]},h)})}),s&&r.jsx("p",{role:"alert",className:"text-sm text-destructive",children:s}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2 pl-6",children:[r.jsx(X,{type:"submit",size:"sm",className:"h-7 rounded-lg px-2.5 py-0 text-xs",wobble:!1,disabled:n,children:n?"Submitting…":d?"Approve once":"Submit"}),d&&e.approvalKey&&r.jsx(X,{type:"button",size:"sm",variant:"secondary",className:"h-7 rounded-lg px-2.5 py-0 text-xs",wobble:!1,disabled:n,title:"Allow the same tool, account and inputs. Reset anytime.",onClick:()=>void i({action:"accept",content:{approve:!0},remember:!0}),children:"Always allow"}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-lg px-2.5 py-0 text-xs",wobble:!1,disabled:n,onClick:()=>void i({action:"decline"}),children:"Decline"})]})]})}function sm({request:e}){const t=C.useConnection(e),{phase:n,authorization:o,continuation:s,error:a}=t,c=n==="loading"||n==="waiting"||s!==null,d=n==="connected"||n==="external",l=(a==null?void 0:a.toLowerCase().includes("expired"))??!1,m=s?s==="renew"?"Preparing a new connection request":"Continuing your request":n==="waiting"?"Waiting for approval":n==="loading"?"Preparing connection":n==="connected"?"Connected":n==="external"?"Setup page completed":"Not connected",p=s?s==="renew"?"Requesting…":"Continuing…":n==="loading"?"Preparing…":n==="waiting"?"Waiting…":l?"Reconnect":a?"Try again":d?"Continue":"Connect",h=()=>a||d?t.retryContinuation():t.start();return r.jsxs("section",{"aria-label":`Connect ${e.name}`,"data-component":"chat/connection",className:"min-w-0 rounded-2xl border border-foreground/10 bg-background p-2 text-foreground",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-secondary p-2",children:r.jsx(En,{})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium",title:(o==null?void 0:o.host)??e.name,children:e.name}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Connect your account to continue."})]}),r.jsxs("p",{role:"status","aria-live":"polite",className:"sr-only",children:[e.name,": ",m]}),n==="ready"&&o&&!s?r.jsx(X,{asChild:!0,wobble:!1,size:"sm",className:"h-7 shrink-0 px-2.5 text-xs order-2",children:r.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",onClick:t.opened,"aria-label":`Connect on ${o.host} (opens in a new tab)`,children:"Connect"})}):r.jsxs(X,{type:"button",wobble:!1,size:"sm",className:"h-7 shrink-0 px-2.5 text-xs order-2",disabled:c,"aria-busy":c,title:l?"Your access expired. Connect again to continue.":void 0,onClick:()=>void h(),children:[c&&r.jsx(po,{}),p]}),r.jsx(X,{type:"button",wobble:!1,variant:"ghost",size:"fit",className:"h-7 shrink-0 px-2 text-xs order-1","aria-label":"Not now",title:"Not now",disabled:s!==null,onClick:()=>void t.cancel(),children:"Not now"})]}),a&&r.jsx("p",{role:"alert",className:"px-1 pt-2 text-sm text-pretty text-destructive",children:a})]})}const am=["box","circle","crossed-off","arrow","bracket","underline","highlight","strike-through"];function im(e){const t=new Map,n=[];for(const o of e){let s;for(const a of o.elements){const i=a.selector||a.name,c=t.get(i);if(c){s??(s=c);continue}const d={...a};t.set(i,d),n.push(d),s??(s=d)}o.note&&s&&(s.note=s.note?`${s.note}
|
|
111
|
+
${o.note}`:o.note)}return n}const hs=20,cm=4e3;function zr(e,t){for(let n=e.nextElementSibling;n instanceof SVGSVGElement&&n.classList.contains("notation");n=n.nextElementSibling)n.setAttribute("data-opencx-overlay",""),n.style.zIndex=String(t),n.style.filter="drop-shadow(0 0 1px rgb(255 255 255 / 0.85))"}function lm(e,t,n,o){const s=document.createElement("div");s.setAttribute("data-opencx-overlay",""),Object.assign(s.style,{position:"absolute",left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",zIndex:String(o)}),document.documentElement.appendChild(s);let a=null;try{a=da.annotate(s,{type:t,color:n,strokeWidth:2,wobble:.8}),a.show(),zr(s,o)}catch(l){K.log.warn("page mark: could not be drawn",l)}let i=!1;const c=()=>{if(!i){i=!0;try{a==null||a.remove()}catch{}s.remove()}},d=l=>{if(!i)try{a==null||a.update(l),zr(s,o)}catch{}};return{setRect(l){i||(s.style.left=`${l.x}px`,s.style.top=`${l.y}px`,s.style.width=`${l.width}px`,s.style.height=`${l.height}px`,d({}))},setShape(l){d({type:l})},undraw(){if(!i){if(!a)return c();try{a.hide(),a.finished.then(c)}catch{return c()}window.setTimeout(c,cm)}},remove:c}}const dm=60;function Qe(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function Li(e){return _i(e)}function um(e){return/[!/[\]():]/.test(e)||/^-?[a-z]{1,6}-\d/.test(e)||/^(flex|grid|block|inline|hidden|absolute|relative|fixed|sticky|static|truncate|container)$/.test(e)}function pm(e){const t=e.getAttribute("class");return t?t.split(/\s+/).map(o=>o.replace(/[_-][a-zA-Z0-9]{5,}.*$/,"")).find(o=>o.length>2&&!/^[a-z]{1,2}$/.test(o)&&!/[A-Z0-9]{5,}/.test(o)&&!um(o))??null:null}function mm(e){if(Me(e))return"private region";const t=e.tagName.toLowerCase(),n=e.getAttribute("aria-label"),o=Li(e);if(t==="button"||e.getAttribute("role")==="button")return n?`button [${n}]`:o?`button "${Qe(o,30)}"`:"button";if(t==="a"){if(o)return`link "${Qe(o,30)}"`;const a=e.getAttribute("href"),i=a?ho(a):"",c=a!=null&&a.startsWith("/")&&!a.startsWith("//")&&i?new URL(i).pathname:i;return c?`link to ${Qe(c,40)}`:"link"}if(t==="input"||t==="textarea"||t==="select"){const a=e.getAttribute("placeholder"),i=e.getAttribute("name");return a?`${t} "${Qe(a,30)}"`:n?`${t} [${n}]`:i?`${t} [${i}]`:t==="input"?`${e.getAttribute("type")??"text"} input`:t}if(/^h[1-6]$/.test(t))return o?`${t} "${Qe(o,40)}"`:t;if(t==="img"){const a=e.getAttribute("alt");return a?`image "${Qe(a,30)}"`:"image"}if(t==="svg")return"icon";if(n)return`${t} [${n}]`;if(o&&o.length<=dm)return`${t} "${Qe(o,40)}"`;const s=pm(e);return s||(t==="div"?"container":t)}function fs(e,t){try{return e.querySelectorAll(t).length===1}catch{return!1}}function hm(e){const t=e.ownerDocument;if(e.id){const s=`#${CSS.escape(e.id)}`;if(fs(t,s))return s}const n=[];let o=e;for(;o&&o.tagName.toLowerCase()!=="html";){const s=o.tagName.toLowerCase();if(o.id){n.unshift(`${s}#${CSS.escape(o.id)}`);break}let a=s;const i=o.parentElement;if(i){const d=Array.from(i.children).filter(l=>l.tagName===(o==null?void 0:o.tagName));d.length>1&&(a+=`:nth-of-type(${d.indexOf(o)+1})`)}n.unshift(a);const c=n.join(" > ");if(fs(t,c))return c;o=i}return n.join(" > ")}function fm(e){const t=e.getBoundingClientRect();return{x:Math.round(t.x),y:Math.round(t.y),width:Math.round(t.width),height:Math.round(t.height)}}const gm=8;function gs(e,t=gm){const n=document.documentElement.clientWidth||window.innerWidth,o=document.documentElement.clientHeight||window.innerHeight,s=Math.max(e.x,t),a=Math.max(e.y,t),i=Math.min(e.x+e.width,n-t),c=Math.min(e.y+e.height,o-t);return{x:Math.round(s),y:Math.round(a),width:Math.round(Math.max(0,i-s)),height:Math.round(Math.max(0,c-a))}}function $i(e){if(Me(e)||e.closest(gt))return{name:"private region",selector:"",tag:"div"};const t=Li(e);return{name:mm(e),selector:hm(e),tag:e.tagName.toLowerCase(),text:t?Qe(t,200):void 0}}const xm=mo.join(", ");function cn(e){return e.closest(xm)!==null}function Mr(e,t){let n=document.elementFromPoint(e,t);if(!n)return null;const o=n.getRootNode();typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(n=o.host);let a=n.closest('button, a, input, textarea, select, [role="button"], [role="link"]')??n;for(;a&&!(a instanceof HTMLElement);)a=a.parentElement;if(!(a instanceof HTMLElement)||Me(n)||Me(a)||a.closest(gt))return null;const i=a.tagName.toLowerCase();return i==="html"||i==="body"?null:a}const go=new WeakMap;function bm(e,t){go.set(e,[...t])}function Cn(e){const t=go.get(e);return t!==void 0&&e.pageUrl===ho(window.location.href)&&t.every(n=>n.isConnected&&n.getRootNode()===document&&!Me(n)&&!n.closest(gt))}function wm(e){const t=go.get(e);if(!t||!Cn(e))return null;const n=t.map($i),[o]=t,s=o!==void 0&&Gt(o)&&JSON.stringify(n[0])===JSON.stringify(e.elements[0]),a={...e,elements:n};return s?Np(e,a):delete a.snapshotUrl,a}const xs=120,ct=e=>e.replace(/\s+/g," ").trim(),Ze=e=>e.length>xs?`${e.slice(0,xs)}…`:e,An=_i;function vm(e){const t=e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.labels:null,n=t?Array.from(t).map(a=>An(a)).join(" "):"";if(n)return ct(n);const o=e.closest("fieldset"),s=o==null?void 0:o.querySelector("legend");return s?An(s):""}function Mt(e){if(Me(e))return"";const t=e.getAttribute("aria-labelledby");if(t){const i=t.split(/\s+/).map(c=>e.ownerDocument.getElementById(c)).filter(c=>c!==null).map(c=>An(c)).filter(Boolean).join(" ");if(i)return Ze(ct(i))}const n=e.getAttribute("aria-label");if(n!=null&&n.trim())return Ze(ct(n));const o=e.tagName.toLowerCase();if(o==="img"){const i=e.getAttribute("alt");if(i!=null&&i.trim())return Ze(ct(i))}if(o==="input"||o==="select"||o==="textarea"){const i=vm(e);if(i)return Ze(i);const c=e.getAttribute("placeholder");if(c!=null&&c.trim())return Ze(ct(c));const d=e.getAttribute("title");return d!=null&&d.trim()?Ze(ct(d)):""}const s=An(e);if(s)return Ze(s);const a=e.getAttribute("title");return a!=null&&a.trim()?Ze(ct(a)):""}const ym=["click","fill","select","check","uncheck"],km=3e3,Di=new Set(["password","file","hidden"]);function Fi(e){const t=new WeakRef(e),n=bs(e).map(o=>{const s=ws(o);return{...s,element:new WeakRef(s.element),form:s.form?new WeakRef(s.form):null,labelControl:s.labelControl?new WeakRef(s.labelControl):null}});return()=>{const o=t.deref();if(!o||!o.isConnected||o.getRootNode()!==document)return!1;const s=bs(o).map(ws);return s.length===n.length&&s.every((a,i)=>{var d,l;const c=n[i];return a.allowed&&a.element===c.element.deref()&&a.form===(((d=c.form)==null?void 0:d.deref())??null)&&a.labelControl===(((l=c.labelControl)==null?void 0:l.deref())??null)&&a.semantics===c.semantics})}}function bs(e){const t=[],n=new Set,o=s=>{for(let a=s;a&&!n.has(a);a=a.parentElement)n.add(a),(a===e||a.matches("a[href],area[href],button,input,select,textarea,label"))&&t.push(a),a instanceof HTMLLabelElement&&a.control&&o(a.control)};return o(e),t}function ws(e){var a;const t=e instanceof HTMLAnchorElement||e instanceof HTMLAreaElement?e:null,n=e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e:null,o=(n==null?void 0:n.form)??null,s=(a=e.ownerDocument.querySelector("base[target]"))==null?void 0:a.getAttribute("target");return{element:e,form:o,labelControl:e instanceof HTMLLabelElement?e.control:null,allowed:!(e instanceof HTMLInputElement&&Di.has(e.type)),semantics:JSON.stringify([e.tagName,e.getAttribute("role"),n==null?void 0:n.type,n==null?void 0:n.name,e instanceof HTMLButtonElement||e instanceof HTMLInputElement&&["submit","image","reset"].includes(e.type)?e.value:null,t==null?void 0:t.href,(t==null?void 0:t.getAttribute("target"))??s,t==null?void 0:t.getAttribute("download"),t==null?void 0:t.getAttribute("rel"),t==null?void 0:t.getAttribute("ping"),o==null?void 0:o.action,o==null?void 0:o.method,(o==null?void 0:o.getAttribute("target"))??s,o==null?void 0:o.enctype,o==null?void 0:o.noValidate,...["formaction","formmethod","formtarget","formenctype","formnovalidate"].map(i=>e.getAttribute(i)),e instanceof HTMLButtonElement||e instanceof HTMLInputElement?[e.formAction,e.formMethod,e.formTarget,e.formEnctype,e.formNoValidate]:null])}}const jm=2,Nt=[];let Cm=0,vs=new WeakMap,lt,ys,xo=new WeakMap,bo=new WeakMap,Tn=new WeakMap;const Sm='tr,li,article,form,fieldset,section,dialog,aside,nav,main,header,footer,[role="row"],[role="listitem"],[role="group"],[role="region"],[role="dialog"],[role="tooltip"]',wo='tr,li,article,[role="row"],[role="listitem"]',er='section,form,fieldset,dialog,[role="group"],[role="region"],[role="dialog"]',Nm=new Set(["class","style","aria-busy"]);function _m(e){var a,i;const t=e.closest(wo);if(t)return t;let n=e.closest(er);if(n){let c=(a=n.parentElement)==null?void 0:a.closest(er);for(;c;)n=c,c=(i=n.parentElement)==null?void 0:i.closest(er);return n}const o=e.closest(Sm);if(o)return o;const s=e.parentElement;return s&&s!==e.ownerDocument.body&&s!==e.ownerDocument.documentElement?s:e}function Em(e){return cn(e)||e.closest('[role="tooltip"]')!==null}function Am(e){const t=e.target.nodeType===1?e.target:e.target.parentElement;if(t&&cn(t)||e.type==="attributes"&&Nm.has(e.attributeName??""))return!1;if(e.type==="childList"){const n=[...Array.from(e.addedNodes),...Array.from(e.removedNodes)];if(n.length&&n.every(o=>o.nodeType===1&&Em(o)))return!1}return!0}function Hi(e){const t=new Set;for(const n of e){for(const s of Array.from(n.removedNodes)){const a=Tn.get(s);a&&t.add(a)}if(!Am(n))continue;if(n.type==="attributes"){const s=Tn.get(n.target);s&&t.add(s)}let o=!0;for(let s=n.target;s;s=s.parentNode){const a=xo.get(s);if(a&&t.add(a),o){const i=bo.get(s);i&&t.add(i)}if(s instanceof Element&&(s.matches(wo)&&(o=!1),s.matches('[role="tooltip"]')&&!(n.type==="attributes"&&n.attributeName==="role")))break}}t.forEach(n=>n.value++)}function Tm(e){const t=[],n=(s,a)=>{let i=a.get(s);i||(i={value:0},a.set(s,i)),t.push({revision:i,value:i.value})},o=_m(e);n(o,xo);for(let s=e;s;s=s.parentNode)n(s,Tn),s!==o&&s instanceof Element&&s.matches(wo)&&n(s,bo);return()=>t.every(({revision:s,value:a})=>s.value===a)}function Rr(){lt&&Hi(lt.takeRecords())}function Im(e){if(ys!==e){lt==null||lt.disconnect();for(const t of Nt)for(const n of Array.from(t.values()))n.valid=!1;ys=e,xo=new WeakMap,bo=new WeakMap,Tn=new WeakMap,lt=new MutationObserver(Hi),lt.observe(e.documentElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}}function Wi(e,t,n=Mt(t)){return e.valid&&(e.valid=t.isConnected&&e.url===t.ownerDocument.location.href&&e.name===n&&e.sameContext()&&e.sameMeaning()),e.valid}function zm(){Rr();const e=new Map;Nt.unshift(e),Nt.length=Math.min(Nt.length,jm);let t=0;const n=`s${++Cm}`;return(o,s=Mt(o))=>{Im(o.ownerDocument),Rr();const a=vs.get(o),i=a?Nt.map(l=>l.get(a)).find(l=>l!==void 0):void 0,c=a&&i&&Wi(i,o,s)?a:`${n}c${t+=1}`,d=c===a&&i?i:{element:new WeakRef(o),sameContext:Tm(o),name:s,url:o.ownerDocument.location.href,sameMeaning:Fi(o),valid:!0};return e.set(c,d),vs.set(o,c),c}}function ks(e){const t=Bi(e);return t!=null&&t.isCurrent?t.element:null}function Bi(e){Rr();for(const t of Nt){const n=t.get(e);if(!n)continue;const o=n.element.deref();if(o&&o.isConnected)return{element:o,isCurrent:Wi(n,o)}}return null}const Mm="data-opencx-private",Rm=new Set(["password","file","hidden"]),js=300;function Pr(e){if(cn(e))return"widget-owned";if(e.closest(`[${Mm}]`))return"private";if(e.getAttribute("aria-hidden")==="true"||e.closest('[aria-hidden="true"]'))return"hidden-from-assistive-tech";if(e.tagName.toLowerCase()==="input"){const t=(e.getAttribute("type")??"text").toLowerCase();if(Rm.has(t))return"credential-field"}return null}const Pm={private:"That part of the page is marked private and the agent never reads or uses it.","hidden-from-assistive-tech":"That control is hidden from assistive technology, so it is not treated as being on the page.","credential-field":"Password and file fields are never filled or clicked by the agent.","widget-owned":"That is part of the chat widget, not the page."},Cs=["a[href]","button","input","select","textarea","summary",'[contenteditable=""]','[contenteditable="true"]','[role="button"]','[role="link"]','[role="checkbox"]','[role="radio"]','[role="switch"]','[role="tab"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="combobox"]','[role="slider"]','[role="textbox"]','[role="searchbox"]'].join(","),Om=["tr","li",'[role="row"]','[role="listitem"]','[role="gridcell"]',"[tabindex]","[onclick]"].join(","),Lm=400;function $m(e){var t;try{return((t=e.ownerDocument.defaultView)==null?void 0:t.getComputedStyle(e).cursor)==="pointer"}catch{return!1}}function Dm(e){const t=e.getAttribute("role");if(t!=null&&t.trim())return t.trim().toLowerCase();const n=e.tagName.toLowerCase();if(n==="a")return"link";if(n==="button"||n==="summary")return"button";if(n==="select")return"combobox";if(n==="textarea")return"textbox";if(n==="input"){const o=(e.getAttribute("type")??"text").toLowerCase();return o==="checkbox"?"checkbox":o==="radio"?"radio":o==="submit"||o==="button"||o==="reset"?"button":o==="range"?"slider":o==="search"?"searchbox":"textbox"}return"textbox"}function Fm(e){const t=e.getAttribute("role");if(t!=null&&t.trim())return t.trim().toLowerCase();const n=e.tagName.toLowerCase();return n==="tr"?"row":n==="li"?"listitem":"button"}function Ss(e){if(typeof e.checkVisibility=="function"){if(!e.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}))return!1}else if(!e.isConnected)return!1;const t=e.getBoundingClientRect();return t.width>0&&t.height>0}function Hm(e){return"disabled"in e&&e.disabled===!0?!0:e.getAttribute("aria-disabled")==="true"}function Or(e=document){const t=[],n=new Set;let o=!1;try{const s=zm(),a=Array.from(e.querySelectorAll(Cs));for(const c of a){if(Pr(c)||!Ss(c))continue;const d=Mt(c);if(!d)continue;if(t.length>=js){o=!0;break}const l={ref:s(c,d),role:Dm(c),name:d};Hm(c)&&(l.disabled=!0),t.push(l),n.add(c)}let i=0;if(!o){const c=Array.from(e.querySelectorAll(Om));for(const d of c){if(t.length>=js){o=!0;break}if(i>=Lm)break;if(n.has(d)||Pr(d)||d.querySelector(Cs)||!Ss(d))continue;const l=Mt(d);l&&(i+=1,$m(d)&&(t.push({ref:s(d,l),role:Fm(d),name:l}),n.add(d)))}}}catch{return{controls:[],truncated:!1}}return{controls:t,truncated:o}}function Ui({marks:e,readsPage:t}){if(!t)return;const n={},o=e.flatMap(i=>{const c=wm(i);return c?[c]:[]});o.length>0&&(n.page_marks=o,n.picked_elements=im(o));const{controls:s,truncated:a}=Or();return s.length>0&&(n.page_controls=s,a&&(n.page_controls_truncated=!0)),Object.keys(n).length>0?n:void 0}const Wm={click:"click",fill:"type into",select:"change",check:"switch on",uncheck:"switch off"};function Bm({request:e}){const{resolvePageAction:t}=C.useAgentChatUi(),n=Wm[e.action]??e.action,o=e.action==="select"?e.valueLabel??e.value:e.value;return r.jsxs("section",{"aria-label":`Allow the agent to ${n} ${e.controlName}`,"data-component":"chat/page_action",className:"min-w-0 rounded-2xl border border-foreground/10 bg-background p-2 text-foreground",children:[r.jsxs("p",{className:"px-1 pb-2 text-sm",children:["Let the agent ",n," ",r.jsx("span",{className:"font-medium",children:e.controlName})," on this page?"]}),(e.action==="fill"||e.action==="select")&&e.value!==void 0&&r.jsxs("div",{className:"mb-2 max-h-40 overflow-auto rounded-lg bg-foreground/5 px-2 py-1 text-sm",children:[r.jsx("span",{className:"font-medium",children:"New value: "}),r.jsx("span",{className:"whitespace-pre-wrap break-words",children:o===""?"(empty)":o})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{size:"sm",className:"flex-1",onClick:()=>t(e.callId,!0),children:"Allow"}),r.jsx(X,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>t(e.callId,!1),children:"No"})]})]})}const qt="rounded-full size-8 flex items-center justify-center p-0 overflow-hidden",qi="bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground",Um=z("rounded-full p-0.5 text-muted-foreground","hover:bg-muted hover:text-foreground","transition-transform active:scale-90");function qm({entity:e,onRemove:t}){const{t:n}=G();return r.jsxs("div",{...L("chat/input_box/page_context_pill"),className:z("flex items-center gap-1.5 max-w-full","rounded-full py-0.5 pe-1","text-xs text-foreground"),title:`${e.type}: ${e.title}`,children:[r.jsx(M.FileTextIcon,{className:"size-3 shrink-0 text-primary"}),r.jsx("span",{className:"truncate max-w-48 font-medium",children:e.title}),r.jsx("button",{type:"button","aria-label":n("page_context_remove"),className:Um,onClick:t,children:r.jsx(M.XIcon,{className:"size-3"})})]})}const Vm=S.z.object({type:S.z.string().min(1),id:S.z.string().min(1),title:S.z.string().min(1),meta:S.z.record(S.z.string(),S.z.unknown()).optional()});function Ym(){var o;const e=C.useConfig(),{widgetCtx:t}=C.useWidget();if(C.useHostLocation(),!t.features.pageContext)return null;const n=Vm.safeParse((o=K.resolveConfigContext(e))==null?void 0:o.entity);return n.success?n.data:null}function wn(e,t){var o;const n=(o=Object.entries(e).find(([s])=>s===t))==null?void 0:o[1];return typeof n=="string"?`hsl(${n})`:"currentColor"}function vo({cssVars:e,primaryColor:t,contentZIndex:n}){return{accent:t,surface:wn(e,"--opencx-background"),foreground:wn(e,"--opencx-foreground"),mutedForeground:wn(e,"--opencx-muted-foreground"),border:wn(e,"--opencx-border"),inkZIndex:n-2,chromeZIndex:n-1,editorZIndex:n+1}}function Xm({isActive:e,draft:t,hover:n,onShapeChange:o,onAttach:s}){const a=$n(),{theme:i,cssVars:c}=me(),{t:d}=G();if(!a||!e)return null;const l=vo({cssVars:c,primaryColor:i.primaryColor,contentZIndex:i.widgetContentContainer.zIndex}),{accent:m}=l;return Qt.createPortal(r.jsxs("div",{"data-opencx-overlay":"",style:{pointerEvents:"none"},children:[r.jsx("style",{children:`
|
|
112
112
|
@keyframes opencx-mark-hint-in {
|
|
113
113
|
from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
|
|
114
114
|
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
@@ -125,8 +125,8 @@ ${o.note}`:o.note)}return n}const fs=20,hm=4e3;function Mr(e,t){for(let n=e.next
|
|
|
125
125
|
[data-opencx-mark-hint], [data-opencx-mark-editor],
|
|
126
126
|
[data-opencx-mark-frame] { animation: none !important; }
|
|
127
127
|
}
|
|
128
|
-
`}),!t&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{"data-opencx-mark-hint":"",style:{position:"fixed",top:16,left:"50%",transform:"translateX(-50%)",zIndex:l.chromeZIndex,display:"flex",alignItems:"center",gap:8,background:`color-mix(in srgb, ${l.surface} 92%, transparent)`,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",color:l.foreground,font:"500 12px/1.4 system-ui, sans-serif",padding:"7px 12px 7px 10px",borderRadius:999,whiteSpace:"nowrap",boxShadow:`0 0 0 1px ${l.border}, 0 8px 24px color-mix(in srgb, ${l.foreground} 14%, transparent)`,animation:"opencx-mark-hint-in 200ms cubic-bezier(0.23, 1, 0.32, 1)"},children:[r.jsx("span",{style:{width:7,height:7,borderRadius:999,background:m}}),d("page_mark_hint"),r.jsx(th,{theme:l,children:d("page_mark_escape")})]}),n&&r.jsx("div",{"data-opencx-mark-frame":"",style:{position:"fixed",left:n.rect.x-4,top:n.rect.y-4,width:n.rect.width+8,height:n.rect.height+8,zIndex:l.chromeZIndex,borderRadius:10,boxShadow:`0 0 0 2px ${l.surface}, 0 0 0 3.5px ${m}, 0 12px 32px color-mix(in srgb, ${l.foreground} 16%, transparent)`,animation:"opencx-mark-frame-in 140ms cubic-bezier(0.23, 1, 0.32, 1)",transitionProperty:"left, top, width, height",transitionDuration:"90ms",transitionTimingFunction:"cubic-bezier(0.23, 1, 0.32, 1)",pointerEvents:"none"}},n.key)]}),t&&r.jsxs(r.Fragment,{children:[[[t.rect.x,t.rect.y],[t.rect.x+t.rect.width,t.rect.y],[t.rect.x,t.rect.y+t.rect.height],[t.rect.x+t.rect.width,t.rect.y+t.rect.height]].map(([p,h],f)=>r.jsx("div",{style:{position:"fixed",left:p-5,top:h-5,width:10,height:10,borderRadius:999,background:l.surface,boxShadow:`0 0 0 2px ${m}, 0 2px 6px color-mix(in srgb, ${l.foreground} 25%, transparent)`,zIndex:l.chromeZIndex,pointerEvents:"none"}},f)),r.jsx(oh,{draft:t,theme:l,onShapeChange:o,onAttach:s},"editor")]})]}),a)}function th({children:e,theme:t}){return r.jsx("span",{style:{font:"600 10px/1 system-ui, sans-serif",color:t.mutedForeground,background:`color-mix(in srgb, ${t.foreground} 7%, transparent)`,border:`1px solid ${t.border}`,borderRadius:5,padding:"3px 5px 2px"},children:e})}const nh={box:r.jsx("rect",{x:"3",y:"5",width:"14",height:"10",rx:"1"}),circle:r.jsx("ellipse",{cx:"10",cy:"10",rx:"7",ry:"5.5"}),arrow:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M3 10h13"}),r.jsx("path",{d:"M12 6l4 4-4 4"})]}),bracket:r.jsx("path",{d:"M7 4H4v12h3"}),underline:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 8h10",opacity:"0.35"}),r.jsx("path",{d:"M4 14h12"})]}),highlight:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"7",width:"14",height:"6",rx:"1",fill:"currentColor",opacity:"0.3",stroke:"none"}),r.jsx("path",{d:"M5 10h10"})]}),"strike-through":r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M6 6h8",opacity:"0.35"}),r.jsx("path",{d:"M6 14h8",opacity:"0.35"}),r.jsx("path",{d:"M4 10h12"})]}),"crossed-off":r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M4 5l12 10"}),r.jsx("path",{d:"M16 5L4 15"})]})},rh={box:"page_mark_shape_box",circle:"page_mark_shape_circle",arrow:"page_mark_shape_arrow",bracket:"page_mark_shape_bracket",underline:"page_mark_shape_underline",highlight:"page_mark_shape_highlight","strike-through":"page_mark_shape_strike_through","crossed-off":"page_mark_shape_crossed_off"};function oh({draft:e,theme:t,onShapeChange:n,onAttach:o}){const{accent:s}=t,{t:a}=G(),[i,c]=u.useState(""),d=u.useRef(null);u.useEffect(()=>{var y;(y=d.current)==null||y.focus()},[]);const l=320,m=window.innerWidth,p=window.innerHeight,{rect:h}=e,f=Math.max(12,Math.min(h.x+h.width/2-l/2,m-l-12)),x=h.y+h.height+16,g=x+138>p?Math.max(12,h.y-134):x;return r.jsxs("div",{"data-opencx-mark-editor":"",style:{position:"fixed",left:f,top:g,width:l,zIndex:t.editorZIndex,pointerEvents:"auto",display:"flex",flexDirection:"column",gap:6,background:`color-mix(in srgb, ${t.surface} 96%, transparent)`,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",padding:8,borderRadius:14,boxShadow:`0 0 0 1px ${t.border}, 0 12px 32px color-mix(in srgb, ${t.foreground} 18%, transparent)`,animation:"opencx-mark-editor-in 180ms cubic-bezier(0.23, 1, 0.32, 1)"},children:[r.jsx("div",{style:{display:"flex",gap:2,justifyContent:"space-between"},children:pm.map(y=>{const w=y===e.shape,j=a(rh[y]);return r.jsx("button",{type:"button",title:j,"aria-label":a("page_mark_shape_aria",{shape:j}),"aria-pressed":w,onClick:()=>n(y),style:{border:"none",cursor:"pointer",borderRadius:8,width:32,height:28,display:"flex",alignItems:"center",justifyContent:"center",background:w?s:"transparent",color:w?t.surface:t.mutedForeground},children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:nh[y]})},y)})}),r.jsxs("div",{style:{display:"flex",alignItems:"flex-end",gap:8},children:[r.jsx("textarea",{ref:d,rows:2,value:i,onChange:y=>c(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),o(i))},placeholder:a("page_mark_note_placeholder"),style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:t.foreground,font:"500 13px/1.4 system-ui, sans-serif",margin:0,paddingBlock:0,paddingInlineStart:4,paddingInlineEnd:0,resize:"none"}}),r.jsx("button",{type:"button","aria-label":a("page_mark_attach"),onClick:()=>o(i),style:{border:"none",borderRadius:999,width:26,height:26,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:s,color:t.surface,font:"600 13px/1 system-ui, sans-serif",cursor:"pointer"},children:"↑"})]})]})}function sh({mark:e,onRemove:t}){var c;const{t:n}=G(),o=Ai(e),s=e.note??((c=e.elements[0])==null?void 0:c.name)??n("page_mark_region"),a=n("page_mark_remove",{label:s}),i=e.elements.map(d=>d.name).join(", ");return o?r.jsx(Ni,{...L("chat/input_box/page_mark_pill"),className:"group",shape:"tile",src:o,alt:s,title:i,note:e.note,children:r.jsx("button",{type:"button","aria-label":a,className:z("absolute top-1 end-1 rounded-full p-0.5","bg-foreground/60 text-background backdrop-blur-sm","opacity-0 group-hover:opacity-100 focus-visible:opacity-100","transition-opacity active:scale-90"),onClick:t,children:r.jsx(M.XIcon,{className:"size-3"})})}):r.jsxs("div",{...L("chat/input_box/page_mark_pill"),title:i,className:z("group relative size-12 shrink-0 overflow-hidden","flex items-center justify-center","rounded-2xl bg-background ring-1 ring-border"),children:[r.jsx(M.PenLineIcon,{className:"size-4 shrink-0 text-primary"}),r.jsx("span",{className:z("absolute inset-x-0 bottom-0 truncate px-1.5 py-0.5","bg-gradient-to-t from-foreground/70 to-foreground/0","text-[10px] font-medium leading-tight text-background"),children:s}),r.jsx("button",{type:"button","aria-label":a,className:z("absolute top-1 end-1 rounded-full p-0.5","bg-foreground/60 text-background backdrop-blur-sm","opacity-0 group-hover:opacity-100 focus-visible:opacity-100","transition-opacity active:scale-90"),onClick:t,children:r.jsx(M.XIcon,{className:"size-3"})})]})}const Le={"close-panel":"Escape","toggle-fullscreen":"Mod+Shift+F",send:"Enter","send-alt":"Mod+Enter","history-prev":"ArrowUp","history-next":"ArrowDown"};function Yi(){return typeof navigator>"u"?!1:/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)}function xt(e,t,n=Yi()){const o=t.split("+"),s=o.at(-1)??"",a=new Set(o.slice(0,-1)),i=a.has("Cmd")||a.has("Mod")&&n,c=a.has("Ctrl")||a.has("Mod")&&!n;return e.metaKey!==i||e.ctrlKey!==c||e.altKey!==a.has("Alt")||e.shiftKey!==a.has("Shift")?!1:e.key.toLowerCase()===s.toLowerCase()}const ah={Mod:"⌘",Cmd:"⌘",Ctrl:"⌃",Alt:"⌥",Shift:"⇧"},ih={Escape:"Esc",Enter:"⏎",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→"};function ko(e,t=Yi()){const n=e.split("+"),o=n.at(-1)??"",s=n.slice(0,-1),a=ih[o]??(o.length===1?o.toUpperCase():o);return t?[...s.map(i=>ah[i]??i),a].join(""):[...s.map(i=>i==="Mod"?"Ctrl":i),a].join("+")}const ch=50*1024*1024,Xi={"application/pdf":[".pdf"],...eu,...tu},lh={"text/*":[".txt"],"image/*":[".png",".jpg",".jpeg",".gif"],...Xi},dh={"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"],...Xi};function uh({status:e}){switch(e){case"uploading":return r.jsx(M.Loader2,{className:"size-4 animate-spin"});case"error":return r.jsx(M.AlertCircle,{className:"size-4 text-destructive"});default:return null}}function ph({file:e,fileContent:t}){const n=e.type.split("/")[0];return n==="image"&&t?r.jsx("img",{src:typeof t=="string"?t:"",className:"object-cover bg-secondary size-full",alt:e.name}):n==="audio"?r.jsx(M.FileAudio2Icon,{className:"size-4 text-muted-foreground"}):n==="video"?r.jsx(M.FileVideo2Icon,{className:"size-4 text-muted-foreground"}):e.type==="application/pdf"?r.jsx(M.FileText,{className:"size-4 text-muted-foreground"}):Za({type:e.type,name:e.name})?r.jsx(M.FileSpreadsheet,{className:"size-4 text-muted-foreground"}):r.jsx(M.FileIcon,{className:"size-4 text-muted-foreground"})}function mh({file:{status:e,file:t,error:n},onCancel:o}){const{t:s}=G(),[a,i]=u.useState(null);return u.useEffect(()=>{if(!t.type.startsWith("image/"))return;const c=new FileReader;return c.onload=()=>i(c.result),c.onerror=()=>K.log.error("failed to read file for preview"),c.readAsDataURL(t),()=>c.abort()},[t]),r.jsx(Ne,{side:"bottom",content:e==="error"?r.jsx("span",{className:"text-destructive",children:s("upload_failed",{error:n??""})}):t.name,children:r.jsxs("div",{className:z(e==="uploading"&&"opacity-50","group","size-12 border rounded-2xl overflow-hidden relative","flex items-center justify-center shrink-0"),children:[r.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:r.jsx(uh,{status:e})}),r.jsx("button",{type:"button",className:z("absolute bg-foreground/50 inset-0 size-full z-10","flex items-center justify-center","opacity-0 group-hover:opacity-100 transition"),onClick:o,"aria-label":s("remove_attachment"),children:r.jsx(M.XIcon,{className:"size-4 text-primary-foreground"})}),r.jsx(ph,{file:t,fileContent:a})]})})}function hh(){const{queuedUserMessages:e,removeQueued:t,stop:n}=C.useAgentChatUi(),{messagesState:{messages:o}}=C.useMessages(),{t:s}=G(),a=u.useMemo(()=>e.filter(i=>!o.some(c=>c.id===i.id)),[e,o]);return r.jsx(F.AnimatePresence,{children:a.length>0&&r.jsx(_e,{children:r.jsxs("div",{...L("chat/queued_sends/root"),className:"mb-1 rounded-2xl border border-muted-foreground/15 bg-background shadow-sm",children:[r.jsxs("div",{...L("chat/queued_sends/header"),className:"flex items-center justify-between px-3 pt-2 pb-1",children:[r.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s("queued_label",{count:a.length})}),r.jsx("button",{type:"button",...L("chat/queued_sends/send_now"),"aria-label":s("send_queued_now"),title:s("send_queued_now"),onClick:n,className:"rounded-md p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground hover:bg-muted",children:r.jsx(M.CornerDownLeftIcon,{className:"size-3"})})]}),r.jsx("ul",{...L("chat/queued_sends/list"),className:"flex flex-col pb-1",children:a.map(i=>r.jsxs("li",{...L("chat/queued_sends/item"),className:"group flex items-center gap-2 px-3 py-1",children:[r.jsx("button",{type:"button",title:s("send_queued_now"),onClick:n,className:"min-w-0 flex-1 truncate text-start text-xs text-foreground/80 hover:text-foreground",children:i.content}),r.jsx("button",{type:"button",...L("chat/queued_sends/remove"),"aria-label":s("remove_queued_message"),onClick:()=>t(i.id),className:"shrink-0 rounded-md p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground hover:bg-muted",children:r.jsx(M.XIcon,{className:"size-3.5"})})]},i.id))})]})},"queued-sends-pill")})}function fh({levelRef:e}){const t=u.useRef(null);return u.useEffect(()=>{let n=0;const o=new K.DictationLevelSmoother({attack:.2,release:.07}),s=[],a=()=>{var c;const i=(c=t.current)==null?void 0:c.children;if(i){const d=o.next(e.current);for(let l=0;l<i.length;l++){const m=i[l];if(m instanceof HTMLElement){const p=.75+.25*Math.sin(Date.now()/260+l*1.7),h=`scaleY(${Math.max(.25,Math.min(1,d*1.8*p)).toFixed(3)})`;s[l]!==h&&(m.style.transform=h,s[l]=h)}}}n=requestAnimationFrame(a)};return n=requestAnimationFrame(a),()=>cancelAnimationFrame(n)},[e]),r.jsx("div",{ref:t,"aria-hidden":"true",className:"flex h-3.5 shrink-0 items-center gap-[3px]",children:[0,1,2,3].map(n=>r.jsx("span",{className:"h-full w-[3px] origin-center scale-y-50 rounded-full bg-current transition-transform duration-100 ease-out"},n))})}function gh({status:e,levelRef:t,onToggle:n,onPrewarm:o}){const{t:s}=G(),a=e==="listening",i=e==="connecting",c=s(a||i?"stop_dictation":"dictate");return r.jsx(Ne,{side:"top",align:"start",content:c,children:r.jsxs(X,{...L("chat/input_box/dictate_btn"),onClick:n,onPointerDown:d=>d.preventDefault(),onPointerEnter:o,onFocus:o,"aria-pressed":a||i,"aria-label":c,size:"fit",variant:"ghost",className:z("relative",qt,a&&Vi),children:[i&&r.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0.5 animate-spin rounded-full border-[1.5px] border-current/20 border-t-current"}),r.jsx(F.AnimatePresence,{mode:"wait",children:a?r.jsx(oe,{distance:0,children:r.jsx(fh,{levelRef:t})},"bars"):r.jsx(oe,{distance:0,children:r.jsx(M.MicIcon,{className:z("size-4",i&&"opacity-60")})},"mic")})]})})}function xh(){const e=Ot(),{language:t}=G();if(!e.enabled)return null;const n=go(t,"start_call");return r.jsx(Ne,{side:"top",align:"start",content:n,children:r.jsx(X,{...L("chat/input_box/voice_call_btn"),onClick:()=>void e.start(),"aria-label":n,size:"fit",variant:"ghost",className:qt,children:r.jsx(M.PhoneIcon,{className:"size-4"})})})}function bh(e,t){const n=e.ownerDocument;if(!n.defaultView)return null;const s=n.createElement("div");Gi(e,s),Object.assign(s.style,{position:"absolute",visibility:"hidden",top:"0",left:"-9999px",height:"auto",overflow:"hidden",whiteSpace:"pre-wrap",overflowWrap:"break-word",width:`${e.clientWidth}px`}),s.textContent=e.value.slice(0,t);const a=n.createElement("span");a.textContent="",s.appendChild(a),n.body.appendChild(s);const i=a.offsetLeft,c=a.offsetTop-e.scrollTop;return s.remove(),{left:i,top:c}}function Gi(e,t){const n=e.ownerDocument.defaultView;if(!n)return;const o=n.getComputedStyle(e);for(const s of wh)t.style.setProperty(s,o.getPropertyValue(s))}const wh=["box-sizing","font-family","font-size","font-weight","font-style","letter-spacing","line-height","text-transform","text-indent","word-spacing","tab-size","padding-top","padding-right","padding-bottom","padding-left","border-top-width","border-right-width","border-bottom-width","border-left-width"],vh=300,Ki=260,yh=8,Zi="rounded-xl border border-border bg-background shadow-lg";function kh({anchorRef:e,inputRef:t,anchorIndex:n,preview:o,groups:s,visible:a,searching:i,highlighted:c,onHighlight:d,onPick:l,onExpand:m}){var j;const{t:p}=G(),[h,f]=u.useState(null);u.useLayoutEffect(()=>{const b=e.current;if(!b)return;const _=b.ownerDocument.defaultView,v=()=>{const N=b.getBoundingClientRect(),R=(_==null?void 0:_.innerWidth)??N.right,T=Math.min(vh,Math.max(0,R-16)),A=t.current,O=A&&n!==null?bh(A,n):null,P=A==null?void 0:A.getBoundingClientRect(),B=O&&P?P.left+O.left:N.left+8,E=Math.max(8,Math.min(B,R-8-T)),I=O&&P?P.top+O.top-4:N.top-4;f({left:E,width:T,top:I,detailBeside:o&&E+T+yh+Ki<=R-8})};v(),_==null||_.addEventListener("resize",v);const k=typeof ResizeObserver>"u"?null:new ResizeObserver(v);return k==null||k.observe(b),()=>{_==null||_.removeEventListener("resize",v),k==null||k.disconnect()}},[n,e,t,o,a.length]);const x=(j=e.current)==null?void 0:j.closest("[data-version]");if(!x||!h||a.length===0&&i)return null;const g=a[c],y=g!=null&&g.description?g:null;let w=-1;return Qt.createPortal(r.jsxs("div",{...L("chat/input_box/mention_picker"),style:{position:"fixed",left:h.left,top:h.top,transform:"translateY(-100%)"},className:"z-50 flex items-end gap-2",children:[r.jsx("div",{role:"listbox",style:{width:h.width},className:z("flex max-h-72 flex-col overflow-hidden",Zi),children:r.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-1",children:a.length===0?r.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:p("mentions_empty")}):s.map(b=>u.createElement("div",{...L("chat/input_box/mention_picker/group"),key:b.type,role:"group","aria-label":b.type},r.jsx("div",{className:"px-2 pb-0.5 pt-1.5 text-xs capitalize text-muted-foreground",children:b.type}),b.items.map(_=>{const v=++w;return u.createElement("button",{...L("chat/input_box/mention_picker/option"),key:`${_.type}:${_.id}`,type:"button",role:"option","aria-selected":v===c,onMouseDown:k=>k.preventDefault(),onMouseEnter:()=>d(v),onClick:()=>l(_),className:z("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-sm",v===c?"bg-muted":"hover:bg-muted/60")},r.jsx(Ji,{item:_}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground",children:_.title}))}),b.hidden>0&&r.jsx("button",{...L("chat/input_box/mention_picker/more"),type:"button",onMouseDown:_=>_.preventDefault(),onClick:()=>m(b.type),className:z("w-full rounded-lg px-2 py-1 text-start text-xs","text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:p("json_see_more",{count:String(b.hidden)})})))})}),y&&h.detailBeside&&r.jsx(jh,{item:y})]}),x)}function jh({item:e}){return r.jsxs("div",{...L("chat/input_box/mention_picker/detail"),style:{width:Ki},className:z("flex gap-3 p-3",Zi),children:[r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted",children:r.jsx(Ji,{item:e,className:"size-4"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-[10px] uppercase tracking-wide text-muted-foreground",children:e.type}),r.jsx("span",{className:"block truncate text-sm font-medium text-foreground",children:e.title}),r.jsx("span",{className:"mt-0.5 line-clamp-3 text-xs text-muted-foreground",children:e.description})]})]})}function Ji({item:e,className:t}){return e.icon?r.jsx("img",{src:e.icon,alt:"",className:z("size-4 shrink-0 rounded-sm object-contain",t)}):r.jsx(zt,{name:e.iconName??"AtSign",className:z("size-3.5 shrink-0 text-primary",t)})}const Qi=u.createContext(null);function Ch({children:e}){const[t,n]=u.useState([]),[o,s]=u.useState(!1),a=u.useRef(new Map),i=u.useCallback(p=>{s(p)},[]),c=u.useCallback((p,h)=>{a.current.set(p,h),n(f=>[...f,p])},[]),d=u.useCallback(p=>{const h=a.current.get(p);h&&(a.current.delete(p),h.undraw()),n(f=>f.filter(x=>x!==p))},[]),l=u.useCallback(()=>{const p=Array.from(a.current.values());a.current.clear();for(const h of p)h.undraw();n([])},[]);u.useEffect(()=>()=>{a.current.forEach(p=>p.remove()),a.current.clear()},[]);const m=u.useMemo(()=>({marks:t,isArmed:o,setArmed:i,attach:c,detach:d,detachAll:l}),[t,o,i,c,d,l]);return r.jsx(Qi.Provider,{value:m,children:e})}function jo(){const e=u.useContext(Qi);if(!e)throw new Error("usePageMarks must be used within a PageMarksProvider");return e}const Sh="data-opencx-mark-cursor",Nh=5,vn=4,yn=6,nr={width:160,height:100},_h=10,Eh=ho.map(e=>`:not(${e}):not(${e} *)`).join(""),Ah=e=>e==="nw"||e==="se"?"nwse-resize":"nesw-resize";function Th({enabled:e,composerRef:t,onAttach:n,accentColor:o,zIndex:s}){const{isArmed:a,setArmed:i,attach:c}=jo(),d=e&&a,[l,m]=u.useState(null),[p,h]=u.useState(null),f=u.useRef(null),x=u.useRef(null);x.current=l;const g=u.useCallback(()=>{var v;(v=f.current)==null||v.undraw(),f.current=null,m(null)},[]),y=u.useCallback(()=>i(!1),[i]),w=u.useCallback(v=>{var k;m(N=>N&&{...N,rect:v}),(k=f.current)==null||k.setRect({x:v.x+window.scrollX,y:v.y+window.scrollY,width:v.width,height:v.height})},[]),j=u.useCallback(v=>{var k;m(N=>N&&{...N,shape:v}),(k=f.current)==null||k.setShape(v)},[]);u.useEffect(()=>{!e&&a&&i(!1)},[e,a,i]),u.useEffect(()=>{var xe;if(!d)return;const v=document.createElement("style");v.setAttribute(Sh,"");let k=null;const N=H=>{H!==k&&(k=H,v.textContent=`*${Eh} { cursor: ${H} !important; }`)};N("crosshair"),document.head.appendChild(v);let R=null;const T=H=>H.target instanceof Element&&cn(H.target),A=H=>T(H)?!1:(H.preventDefault(),H.stopPropagation(),H.stopImmediatePropagation(),!0),O=(H,ee,J)=>{const ne=[["nw",H.x,H.y],["ne",H.x+H.width,H.y],["sw",H.x,H.y+H.height],["se",H.x+H.width,H.y+H.height]];for(const[le,de,ie]of ne)if(Math.hypot(ee-de,J-ie)<=_h)return le;return null},P=(H,ee,J)=>ee>=H.x&&ee<=H.x+H.width&&J>=H.y&&J<=H.y+H.height,B=(H,ee)=>{var de;const J=Rr(H,ee),ne=xs(J?(()=>{const ie=J.getBoundingClientRect();return{x:ie.left-yn,y:ie.top-yn,width:ie.width+yn*2,height:ie.height+yn*2}})():{x:H-nr.width/2,y:ee-nr.height/2,...nr}),le=((de=x.current)==null?void 0:de.shape)??"box";h(null),f.current=fm({x:ne.x+window.scrollX,y:ne.y+window.scrollY,width:ne.width,height:ne.height},le,o,s),m({rect:ne,shape:le})},E=H=>{var ne;if(!A(H)||H.button!==0)return;const ee=x.current;if(!ee){B(H.clientX,H.clientY);return}const J=O(ee.rect,H.clientX,H.clientY);if(J){R={kind:"resize",corner:J};return}if(P(ee.rect,H.clientX,H.clientY)){R={kind:"move",grabX:H.clientX-ee.rect.x,grabY:H.clientY-ee.rect.y};return}(ne=f.current)==null||ne.undraw(),f.current=null,B(H.clientX,H.clientY)};let I=null,W=0;const $=H=>{if(!A(H))return;const ee=x.current;if(!ee){N("crosshair");const pe=Rr(H.clientX,H.clientY);if(!pe){I=null,h(null);return}pe!==I&&(I=pe,W+=1),h({rect:xs(ym(pe)),key:W});return}if(!R){const pe=O(ee.rect,H.clientX,H.clientY);N(pe?Ah(pe):P(ee.rect,H.clientX,H.clientY)?"move":"crosshair");return}const{rect:J}=ee;if(R.kind==="move"){w({...J,x:H.clientX-R.grabX,y:H.clientY-R.grabY});return}const ne=R.corner.includes("w")?J.x+J.width:J.x,le=R.corner.includes("n")?J.y+J.height:J.y,de=Math.min(ne,H.clientX),ie=Math.max(ne,H.clientX),De=Math.min(le,H.clientY),Fe=Math.max(le,H.clientY);w({x:de,y:De,width:Math.max(fs,ie-de),height:Math.max(fs,Fe-De)})},U=H=>{A(H)&&(R=null)},Y=H=>{T(H)||A(H),R=null},q=H=>{A(H)},se=H=>{var ee;if(H.key==="Escape"){if(H.preventDefault(),H.stopImmediatePropagation(),R=null,x.current){(ee=f.current)==null||ee.undraw(),f.current=null,m(null),N("crosshair");return}i(!1)}};let D=window.scrollX,V=window.scrollY;const Z=()=>{h(null);const H=window.scrollX-D,ee=window.scrollY-V;D=window.scrollX,V=window.scrollY,!(H===0&&ee===0)&&m(J=>J&&{...J,rect:{...J.rect,x:J.rect.x-H,y:J.rect.y-ee}})};document.addEventListener("pointerdown",E,!0),document.addEventListener("pointermove",$,!0),document.addEventListener("pointerup",U,!0),document.addEventListener("pointercancel",Y,!0),document.addEventListener("click",q,!0);const te=new Set([window]),ae=(xe=t==null?void 0:t.current)==null?void 0:xe.ownerDocument.defaultView;return ae&&te.add(ae),te.forEach(H=>H.addEventListener("keydown",se,!0)),document.addEventListener("scroll",Z,!0),()=>{v.remove(),document.removeEventListener("pointerdown",E,!0),document.removeEventListener("pointermove",$,!0),document.removeEventListener("pointerup",U,!0),document.removeEventListener("pointercancel",Y,!0),document.removeEventListener("click",q,!0),te.forEach(H=>H.removeEventListener("keydown",se,!0)),document.removeEventListener("scroll",Z,!0),h(null)}},[d,t,o,s,w,i]),u.useEffect(()=>{!d&&x.current&&g()},[d,g]),u.useEffect(()=>()=>{var v;(v=f.current)==null||v.remove(),f.current=null},[]);const b=u.useCallback(v=>{if(!e)return;const k=x.current,N=f.current;if(!k||!N)return;const R=v.trim(),T=Ih(k.rect),A={shape:k.shape,...R?{note:R}:{},pageUrl:fo(window.location.href),rect:k.rect,elements:T.map(Di)};Cm(A,T),T[0]&&_p(A,T[0]),f.current=null,m(null),i(!1),c(A,N),n==null||n(A)},[c,e,n,i]),_=u.useCallback(()=>{e&&i(!a)},[e,a,i]);return{isActive:d,draft:l,hover:p,setShape:j,attach:b,dropDraft:g,disarm:y,toggle:_}}function Ih(e){const t=new Set,n=(o,s)=>{const a=Rr(o,s);a&&t.add(a)};n(e.x+e.width/2,e.y+e.height/2);for(let o=0;o<=vn;o++)for(let s=0;s<=vn;s++)n(e.x+e.width*o/vn,e.y+e.height*s/vn);return Array.from(t).slice(0,Nh)}function zh({enabled:e,inputRef:t}){const{widgetCtx:n}=C.useWidget(),{theme:o,cssVars:s}=me(),a=yo({cssVars:s,primaryColor:o.primaryColor,contentZIndex:o.widgetContentContainer.zIndex}),{marks:i,detach:c}=jo(),d=u.useCallback(()=>{var p;(p=t.current)==null||p.focus()},[t]),l=u.useCallback(async p=>{if(!n.features.pageContext||!n.features.attachments)return null;try{const{fileUrl:h}=await n.api.uploadFile({file:p,abortSignal:new AbortController().signal});return h??null}catch(h){return K.log.warn("page mark snapshot upload failed",h),null}},[n]),m=Th({enabled:e,composerRef:t,onAttach:d,accentColor:a.accent,zIndex:a.inkZIndex});return{marks:i,detach:c,marking:m,uploadSnapshot:l}}function Mh({inputText:e,setInputText:t,inputRef:n,getSentTextHistory:o}){const s=u.useRef(null),a=u.useRef(""),i=()=>{const p=n.current;p&&(p.classList.remove("opencx-input-recall"),p.offsetWidth,p.classList.add("opencx-input-recall"))},c=(p,{animate:h=!0}={})=>{t(p),h&&i(),requestAnimationFrame(()=>{var f;return(f=n.current)==null?void 0:f.setSelectionRange(p.length,p.length)})};return{onKeyDown:p=>{if(xt(p,Le["history-prev"])){const h=o();if(h.length===0)return!1;const f=s.current;if(f===null){const x=n.current;if(!((x==null?void 0:x.selectionStart)===0&&(x==null?void 0:x.selectionEnd)===0)&&e!=="")return!1;a.current=e,s.current=h.length-1}else{if(f===0)return!1;s.current=f-1}return p.preventDefault(),c(h[s.current],{animate:!p.repeat}),!0}if(xt(p,Le["history-next"])){const h=s.current;if(h===null)return!1;p.preventDefault();const f=o();return h>=f.length-1?(s.current=null,c(a.current,{animate:!p.repeat}),a.current=""):(s.current=h+1,c(f[s.current],{animate:!p.repeat})),!0}return!1},onEdit:()=>{s.current=null},onSent:()=>{s.current=null,a.current=""}}}const _s="max-h-16 [field-sizing:content] w-full px-2",Rh=1e3;function ec(e={}){const{sessionEnded:t}=C.useTokenRenewal();return t?r.jsx(Ph,{}):r.jsx(Oh,{...e})}function Ph(){const{t:e}=G();return r.jsx("div",{className:"p-2",...L("chat/session_ended"),children:r.jsxs("div",{role:"status",className:"flex items-center gap-2 p-3 bg-muted rounded-[var(--opencx-inset-radius)] text-sm",children:[r.jsx(M.LockIcon,{className:"size-4 shrink-0 text-muted-foreground"}),r.jsx("span",{children:e("session_ended_sign_in_again")})]})})}function Oh({trailingActions:e,placeholder:t,hideAttachTools:n,disabled:o=!1}){var pn;const{isSmallScreen:s}=je(),a=u.useRef(null),i=u.useRef(null),c=u.useRef(null),d=u.useRef(!0),{messagesState:l,rememberSentText:m,getSentTextHistory:p}=C.useMessages(),h=an(),{widgetCtx:f,componentStore:x}=C.useWidget(),{attachments:g,pageContext:y}=f.features,{isStreaming:w,stop:j,queuedUserMessages:b,pendingClarification:_,pendingConnection:v,pendingPageAction:k}=C.useAgentChatUi(),{sessionState:N}=C.useSessions(),R=o||Ir({isStreaming:w,messages:l.messages,session:N.session}),T=u.useRef(w);T.current=w;const{t:A}=G(),{text:O,setText:P,clearSubmitted:B}=C.useComposerDraft(),E=Qm(),I=Fp({text:O,setText:P,inputRef:a}),W=I.picked.length>0;u.useLayoutEffect(()=>{const Q=a.current,be=c.current;!Q||!be||Gi(Q,be)},[W,O]);const[$,U]=u.useState(!1),Y=E?`${E.type}:${E.id}`:"";u.useEffect(()=>{U(!1)},[Y]);const[q,se]=u.useState(null),D=u.useRef(O);D.current=O;const V=u.useRef(()=>{}),Z=C.useDictation({getValue:()=>D.current,setValue:Q=>{D.current=Q,P(Q)},onSend:()=>V.current()}),{stop:te}=Z;u.useEffect(()=>{R&&te({executeFinalCommand:!1})},[R,te]),u.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]);const ae=Mh({inputText:O,setInputText:P,inputRef:a,getSentTextHistory:p}),xe=y&&!s,H=!R&&xe&&n!==!0,{marks:ee,detach:J,marking:ne,uploadSnapshot:le}=zh({enabled:H,inputRef:a});u.useEffect(()=>{y||ee.forEach(J)},[y,ee,J]);const{allFiles:de,handleCancelUpload:ie,appendFiles:De,emptyTheFiles:Fe,isUploading:pe,successFiles:Ve}=C.useUploadFiles();u.useEffect(()=>{!g&&de.length>0&&Fe()},[g,de.length,Fe]);const st=!!((pn=N.session)!=null&&pn.isHandedOff),{isAwaitingBotReply:Ye}=C.useIsAwaitingBotReply(),He=f.messageCtx.blocksSendWhileAwaitingReply&&Ye,Xe=Q=>{R||!g||(se(null),De(Q))},Ge=E!==null&&!$,we=de.length>0||ee.length>0,Re=!O.trim()&&Ve.length===0&&(!y||!ee.some(Cn)),We=w&&Re,Wn=We&&b.length>0,dn=R||pe||He||Re,ve=u.useRef(0),Lt=()=>{Date.now()-ve.current<Rh||j()},$t=()=>{if(Z.stop({executeFinalCommand:!1}),R||He||pe)return;const Q=D.current,be=f.messageCtx.captureConversation(),Dt=f.messageCtx.draftState.get(),Be=ee.filter(Ee=>f.features.pageContext&&Cn(Ee)?!0:(J(Ee),!1)),Pe=f.features.attachments?[...Ve]:[];if(!Q.trim()&&Pe.length===0&&Be.length===0)return;ve.current=Date.now();const at=de.map(Ee=>Ee.id);Be.forEach(Ee=>Ep(Ee,le)),Promise.all(Be.map(Ee=>Ap(Ee,Lh))).then(()=>wt({isCurrentConversation:be,submittedText:Q,submittedDraft:Dt,submittedMarks:Be,submittedFiles:Pe,submittedFileIds:at}))},wt=({isCurrentConversation:Q,submittedText:be,submittedDraft:Dt,submittedMarks:Be,submittedFiles:Pe,submittedFileIds:at})=>{if(!Q()||Ir({isStreaming:T.current,messages:f.messageCtx.state.get().messages,session:f.sessionCtx.sessionState.get().session}))return;const vt=f.features.pageContext,it=Be.filter(he=>vt&&Cn(he)?!0:(J(he),!1));if(!be.trim()&&Pe.length===0&&it.length===0)return;const mn=be.trim()||(it.length>0?$h(it)??A("page_mark_default_message"):"");let Ft=!1;const yt=I.picked;h({content:mn,withPageEntity:!$,mentions:yt.length>0?yt:void 0,attachments:Pe.flatMap(he=>he.fileUrl?[{url:he.fileUrl,type:he.file.type,name:he.file.name,id:he.id,size:he.file.size}]:[]),clientContext:qi({marks:it,readsPage:vt}),onAccepted:()=>{if(Ft||!Q())return;Ft=!0,m(mn),Be.forEach(kt=>J(kt)),at.forEach(kt=>ie(kt));const he=B(Dt);d.current&&(ae.onSent(),U(!1),he&&I.reset())}}).catch(he=>{K.log.error("failed to send message",he)})},{getRootProps:un,getInputProps:Bn,open:Un}=Yc.useDropzone({onDrop:Xe,noClick:!0,disabled:R||!g,onDropRejected(){se(A("file_rejected"))},maxSize:ch,accept:st?lh:dh}),qn=Q=>{const be=Q.clipboardData;be&&be.files.length>0&&Xe(Array.from(be.files))};V.current=$t;const Ce=x.getComponent("agent_chat_questions");return!v&&_&&Ce?r.jsx("div",{...L("chat/input_box/root"),className:"p-2 relative space-y-1",children:r.jsx(Ce,{request:_})}):r.jsxs("div",{...L("chat/input_box/root"),className:"p-2 relative space-y-1",...un({ref:i}),children:[N.session&&r.jsx(lm,{sessionId:N.session.id,active:w||Ye},N.session.id),v&&r.jsx(um,{request:v},v.request_id),k&&r.jsx(Gm,{request:k},k.callId),r.jsx("input",{...Bn()}),I.isOpen&&r.jsx(kh,{anchorRef:i,inputRef:a,anchorIndex:I.anchorIndex,preview:I.preview,groups:I.groups,visible:I.visible,searching:I.searching,highlighted:I.highlighted,onHighlight:I.setHighlighted,onPick:I.pick,onExpand:I.expandGroup}),H&&r.jsx(eh,{isActive:ne.isActive,draft:ne.draft,hover:ne.hover,onShapeChange:ne.setShape,onAttach:ne.attach}),r.jsx(hh,{}),q&&r.jsx("p",{role:"alert",className:"px-2 text-xs text-destructive",children:q}),Z.error&&r.jsx("p",{role:"alert",className:"px-2 text-xs text-destructive",children:Z.error==="microphone"?A("dictation_mic_blocked"):A("dictation_unavailable")}),r.jsxs("div",{...L("chat/input_box/attached_context_tray"),style:{"--cx-p":"0.25rem"},className:z("flex flex-col","rounded-[calc(var(--opencx-inset-radius)+var(--cx-p))] p-[var(--cx-p)]","transition-colors duration-200 ease-opencx",Ge?"bg-muted":"bg-transparent"),children:[r.jsx(F.AnimatePresence,{children:Ge&&r.jsx(_e,{children:r.jsx("div",{...L("chat/input_box/page_context_container"),className:"flex items-center gap-1 flex-wrap ps-3 pe-1 py-1",children:r.jsx(F.AnimatePresence,{mode:"popLayout",children:E&&!$&&r.jsx(oe,{snapExit:!0,children:r.jsx(Zm,{entity:E,onRemove:()=>U(!0)})},"page-entity")})})},"attached-context")}),r.jsxs("div",{...L("chat/input_box/inner_root"),className:z("transition-colors","bg-background","border border-border","relative rounded-[var(--opencx-inset-radius)] flex flex-col gap-2 p-2"),children:[r.jsxs("div",{...L("chat/input_box/textarea_and_attachments_container"),className:"flex flex-col gap-2",children:[we&&r.jsx("div",{...L("chat/input_box/attachments_container"),className:"flex items-center gap-1 overflow-x-auto",children:r.jsxs(F.AnimatePresence,{mode:"popLayout",children:[de.map(Q=>r.jsx(oe,{snapExit:!0,children:r.jsx(mh,{onCancel:()=>ie(Q.id),file:Q})},Q.id)),ee.map((Q,be)=>r.jsx(oe,{snapExit:!0,children:r.jsx(sh,{mark:Q,onRemove:()=>J(Q)})},`mark-${be}-${Q.note??""}`))]})}),r.jsxs("div",{className:"relative",children:[W&&r.jsx("div",{ref:c,"aria-hidden":!0,className:z(_s,"pointer-events-none absolute inset-0 overflow-hidden","whitespace-pre-wrap break-words text-foreground",!we&&"pt-1",s?"text-[16px]":"text-sm"),children:r.jsx(Ti,{text:O,mentions:I.picked,tokenClassName:"bg-primary/10 text-primary"})}),r.jsx("textarea",{...L("chat/input_box/textarea"),disabled:R,onPaste:qn,ref:a,id:"chat-input",value:O,rows:3,className:z(_s,"relative resize-none",!we&&"pt-1","bg-transparent outline-none","placeholder:text-muted-foreground",W&&"text-transparent caret-foreground",s?"text-[16px]":"text-sm"),onScroll:Q=>{c.current&&(c.current.scrollTop=Q.currentTarget.scrollTop)},onChange:Q=>{ae.onEdit(),P(Q.target.value),f.messageCtx.notifyTyping()},onClick:()=>I.onCaretMove("nearest"),onKeyUp:Q=>{Q.key==="ArrowRight"||Q.key==="ArrowDown"?I.onCaretMove("forward"):Q.key==="ArrowLeft"||Q.key==="ArrowUp"?I.onCaretMove("backward"):(Q.key==="Home"||Q.key==="End")&&I.onCaretMove("nearest")},onKeyDown:Q=>{if(!Q.nativeEvent.isComposing&&!I.onKeyDown(Q)){if(xt(Q,Le.send)||xt(Q,Le["send-alt"])){Q.preventDefault(),Wn?j():$t();return}ae.onKeyDown(Q)}},placeholder:t??A("write_a_message_placeholder")})]})]}),r.jsxs("div",{className:"gap-2 flex justify-between",children:[r.jsx("div",{className:"flex items-center gap-1",children:!R&&!n&&r.jsxs(r.Fragment,{children:[g&&r.jsx(Ne,{side:"top",align:"start",content:A("attach_files"),children:r.jsx(X,{onClick:Un,"aria-label":A("attach_files"),size:"fit",variant:"ghost",className:qt,children:r.jsx(F.AnimatePresence,{mode:"wait",children:He?r.jsx(oe,{distance:0,children:r.jsx(M.PaperclipIcon,{className:"size-4 opacity-50"})},"paper-clip-disabled"):r.jsx(oe,{distance:0,children:r.jsx(M.PaperclipIcon,{className:"size-4"})},"paper-clip")})})}),Z.enabled&&r.jsx(gh,{status:Z.status,levelRef:Z.levelRef,onToggle:Z.toggle,onPrewarm:Z.prewarm}),xe&&r.jsx(Ne,{side:"top",align:"start",content:ne.isActive?A("mark_page_active"):A("mark_page"),children:r.jsx(X,{...L("chat/input_box/page_mark_btn"),onClick:ne.toggle,"aria-label":ne.isActive?A("mark_page_active"):A("mark_page"),size:"fit",variant:"ghost",className:z(qt,ne.isActive&&Vi),children:r.jsx(M.MousePointerClickIcon,{className:"size-4"})})})]})}),r.jsxs("div",{className:"flex items-center gap-1",children:[e,!R&&r.jsx(xh,{}),r.jsx(Ne,{content:A(We?"stop_response":"send_message"),shortcut:We?void 0:ko(Le.send),side:"top",align:"end",children:r.jsx(X,{size:"fit",onClick:We?Lt:$t,"aria-label":A(We?"stop_response":"send_message"),disabled:R||!We&&dn,className:qt,children:r.jsx(F.AnimatePresence,{mode:"wait",children:We?r.jsx(oe,{snapExit:!0,distance:0,children:r.jsx(M.SquareIcon,{className:"size-3 fill-current"})},"stop"):!w&&(He||pe)?r.jsx(oe,{snapExit:!0,distance:0,children:r.jsx(M.CircleDashed,{className:"size-4 animate-spin animate-iteration-infinite"})},"loading"):r.jsx(oe,{snapExit:!0,distance:0,children:r.jsx(M.ArrowUpIcon,{className:"size-4"})},"send")})})})]})]})]})]})]})}const Lh=1500;function $h(e){const t=e.flatMap(n=>{var s;const o=(s=n.note)==null?void 0:s.trim();return o?[o]:[]});return t.length>0?t.join(`
|
|
129
|
-
`):null}function Es(){const{widgetCtx:e}=C.useWidget(),{router:t}=C.useConfig(),{canCreateNewSession:n}=C.useSessions(),{toSessionsScreen:o}=C.useWidgetRouter(),{t:s}=G();return r.jsx(r.Fragment,{children:n||t!=null&&t.chatScreenOnly?r.jsx(X,{onClick:e.resetChat,className:"rounded-2xl w-full",children:s("new_conversation")}):r.jsx(X,{onClick:o,className:"rounded-2xl w-full",children:s("back_to_conversations")})})}function Dh(){const{t:e}=G(),t=C.useCsat(),n=C.useCsat("nps"),o=C.useCsat("ces"),s=t.isCsatRequested||n.isCsatRequested||o.isCsatRequested,a=!s&&(t.isCsatSubmitted||n.isCsatSubmitted||o.isCsatSubmitted);return r.jsx("div",{className:"p-2",children:r.jsx("div",{className:"p-2 bg-muted rounded-[var(--opencx-inset-radius)]",children:r.jsx(F.AnimatePresence,{mode:"wait",children:s||a?r.jsxs(_e,{children:[r.jsx(er,{}),r.jsx(er,{surveyType:"nps"}),r.jsx(er,{surveyType:"ces"}),r.jsx(F.AnimatePresence,{mode:"wait",children:a&&r.jsx(_e,{children:r.jsx(Es,{})},"new-conv-or-back-to-convs-button")})]},"csat"):r.jsxs(_e,{children:[r.jsxs("div",{className:"ps-2 flex items-center gap-1 pb-2",children:[r.jsx(M.CircleCheckIcon,{className:"size-4 text-emerald-600"}),r.jsx("h2",{className:"text-sm font-medium",children:e("your_issue_has_been_resolved")})]}),r.jsx(Es,{})]},"session-closed")})})})}function Fh(){var y,w;const{initialQuestions:e,initialQuestionsPosition:t,stickyQuestions:n,thisWasHelpfulOrNot:o}=C.useConfig(),{sessionState:s}=C.useSessions(),{messagesState:a}=C.useMessages(),{isStreaming:i,pendingClarification:c,pendingConnection:d,pendingPageAction:l}=C.useAgentChatUi(),{text:m}=C.useComposerDraft(),p=a.messages.length===0,h=Li(),f=Ir({isStreaming:i,messages:a.messages,session:s.session}),x=a.lastAIResMightSolveUserIssue&&(o==null?void 0:o.enabled)!==!1,g=sm({stickyQuestions:n,messages:a.messages,isHandedOff:!!((y=s.session)!=null&&y.isHandedOff),isStreaming:i,isTyping:m.trim().length>0,otherSuggestionsShowing:x||f||c!==null||d!==null||l!==null});return r.jsx("footer",{children:r.jsx(F.AnimatePresence,{mode:"wait",children:s.session&&!((w=s.session)!=null&&w.isOpened)?r.jsxs(_e,{children:[r.jsx(Dh,{}),r.jsx(zr,{})]},"session-closed"):r.jsxs(_e,{children:[x&&r.jsx(cm,{}),p&&e&&t!=="below-initial-messages"&&r.jsx("div",{className:z("flex items-center flex-row justify-end gap-2 flex-wrap px-2",h&&"pb-4"),children:e==null?void 0:e.map((j,b)=>r.jsx(Yt,{suggestion:j},`${j}-${b}`))}),g.length>0&&r.jsx("div",{className:"flex items-center flex-row justify-end gap-2 flex-wrap px-2",children:g.map((j,b)=>r.jsx(Yt,{suggestion:j},`${j}-${b}`))}),!h&&!f&&r.jsx(ec,{}),r.jsx(zr,{})]},"chat-input")})})}function Hh(){var j;const{messagesState:{messages:e,isAgentTyping:t}}=C.useMessages(),{isAwaitingBotReply:n}=C.useIsAwaitingBotReply(),{componentStore:o}=C.useWidget(),s=C.useBot(),a=u.useMemo(()=>yi(e),[e]),{threadCalls:i}=Ot(),c=u.useMemo(()=>{const b=[...i],_=[];a.forEach((v,k)=>{const N=v[0];if(N){for(const R of Pi(b,Ri(N)))_.push(r.jsx(_n,{call:R},`voice-call-${R.id}`));_.push(r.jsx(Tr,{groups:[v],pendingReply:n&&k===a.length-1},N.id))}});for(const v of b)_.push(r.jsx(_n,{call:v},`voice-call-${v.id}`));return _},[a,i,n]),d=e.at(-1),l=d==null?void 0:d.id,m=d==null?void 0:d.type,p=u.useRef(l),[h,f]=u.useState(!1),x=n&&!h;u.useEffect(()=>{const b=p.current!==l;if(p.current=l,!n||m!=="AI"){f(!1);return}if(!b)return;f(!0);const _=setTimeout(()=>f(!1),600);return()=>clearTimeout(_)},[n,l,m]);const g=o.getComponent("loading"),y=u.useRef(null);function w(){setTimeout(()=>{const b=y.current;b&&(b.scrollTop=b.scrollHeight)},0)}return u.useEffect(()=>{w()},[e,x,t,i]),r.jsxs("div",{...L("chat/msgs/root"),ref:y,className:"max-h-full scroll-smooth relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[r.jsx(Si,{}),r.jsx(ki,{}),r.jsx(Oi,{}),c,x&&g&&r.jsx(g,{agent:s}),t&&!x&&g&&r.jsx(g,{agent:(j=e.findLast(b=>b.type==="AGENT"))==null?void 0:j.agent}),r.jsx(vi,{}),r.jsx(wi,{})]})}function Wh(){const{messagesState:{isInitialFetchLoading:e}}=C.useMessages(),{widgetCtx:t}=C.useWidget(),n=t.streaming,{sessionState:{session:o}}=C.useSessions(),{isCanvasOpen:s}=cp(),{theme:a}=me();Pt({width:s?a.screens.chat.withCanvas.width:a.screens.chat.width,height:s?a.screens.chat.withCanvas.height:a.screens.chat.height});const i=u.useRef((o==null?void 0:o.id)||"chat").current;return r.jsx("div",{...L("chat/root"),className:z("flex flex-col overflow-hidden"),style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:r.jsxs("div",{className:"relative size-full justify-between flex flex-col",children:[r.jsx(hi,{}),r.jsx(F.AnimatePresence,{mode:"wait",children:e?r.jsx(oe,{className:"flex flex-col items-center justify-center w-full flex-1",children:r.jsx(fi,{})},"loading"):r.jsxs(oe,{className:"flex items-start h-full flex-1 overflow-auto",snapExit:!0,children:[r.jsxs("div",{...L("chat/main/root"),className:z("flex flex-col h-full overflow-auto transition-all",s?"w-2/5":"w-full"),style:{transitionTimingFunction:a.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:a.screens.chat.withCanvas.transitionDuration},children:[n?r.jsx(nm,{}):r.jsx(Hh,{}),r.jsx(Fh,{})]}),r.jsx("div",{...L("chat/canvas/root"),className:z("h-full overflow-auto transition-all",s?"w-3/5":"w-0"),style:{transitionTimingFunction:a.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:a.screens.chat.withCanvas.transitionDuration},children:r.jsx(rm,{})})]},i)})]})})}const Vt=ot.forwardRef(({className:e,type:t,...n},o)=>{const{isSmallScreen:s}=je();return r.jsx("input",{ref:o,type:t,className:z(s?"text-[16px]":"text-sm","flex w-full rounded-xl p-2 ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-primary-foreground placeholder:text-muted-foreground/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition","rounded-2xl px-4","border shadow-sm",e),...n})});Vt.displayName="Input";function Bh({className:e}){return r.jsx("svg",{width:"26",height:"32",viewBox:"0 0 26 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:z("text-primary-foreground",e),children:r.jsx("path",{d:"M1.34103 25.6132H5.44245C5.74203 25.6228 6.02673 25.7462 6.23867 25.9582C6.45062 26.1703 6.5739 26.4551 6.58348 26.7548V30.8584C6.59305 31.1581 6.71634 31.443 6.92828 31.655C7.14023 31.8671 7.42492 31.9904 7.7245 32H18.2894C18.589 31.9904 18.8737 31.8671 19.0856 31.655C19.2976 31.443 19.4209 31.1581 19.4304 30.8584V26.7548C19.4401 26.4545 19.5638 26.1692 19.7765 25.957C19.9892 25.7449 20.2748 25.6219 20.5749 25.6132H24.659C24.9586 25.6036 25.2433 25.4803 25.4552 25.2682C25.6671 25.0562 25.7904 24.7713 25.8 24.4716V7.52839C25.7904 7.22865 25.6671 6.94381 25.4552 6.73176C25.2433 6.5197 24.9586 6.39635 24.659 6.38677H20.561C20.2603 6.37802 19.9742 6.25457 19.7614 6.04169C19.5487 5.82881 19.4253 5.54261 19.4165 5.24168V1.14161C19.4072 0.84419 19.2858 0.561291 19.0768 0.349589C18.8678 0.137887 18.5865 0.0130193 18.2894 0L7.7245 0C7.42492 0.00957792 7.14023 0.132929 6.92828 0.344983C6.71634 0.557036 6.59305 0.841878 6.58348 1.14161V5.24168C6.57477 5.54203 6.45187 5.82773 6.23983 6.04052C6.0278 6.25331 5.74262 6.37715 5.44245 6.38677H1.34103C1.04144 6.39635 0.756749 6.5197 0.544805 6.73176C0.332861 6.94381 0.209574 7.22865 0.200001 7.52839V24.4716C0.209574 24.7713 0.332861 25.0562 0.544805 25.2682C0.756749 25.4803 1.04144 25.6036 1.34103 25.6132ZM6.58348 24.4716V7.52839C6.59305 7.22865 6.71634 6.94381 6.92828 6.73176C7.14023 6.5197 7.42492 6.39635 7.7245 6.38677H18.2894C18.589 6.39635 18.8737 6.5197 19.0856 6.73176C19.2976 6.94381 19.4209 7.22865 19.4304 7.52839V24.4716C19.4209 24.7713 19.2976 25.0562 19.0856 25.2682C18.8737 25.4803 18.589 25.6036 18.2894 25.6132H7.7245C7.42492 25.6036 7.14023 25.4803 6.92828 25.2682C6.71634 25.0562 6.59305 24.7713 6.58348 24.4716Z",fill:"currentColor"})})}function ln({className:e}){const{token:t}=C.useConfig();return r.jsx("div",{className:z("flex items-center justify-center gap-2 p-2 pt-0",e),children:r.jsx(Oe,{children:r.jsxs("a",{dir:"ltr",href:`https://open.cx/?ref=${t}`,target:"_blank",rel:"noreferrer",className:z("text-[10px] flex items-center","text-muted-foreground/70 [&_svg]:text-muted-foreground/70","hover:text-primary [&_svg]:hover:text-primary"),children:[r.jsx("span",{children:"Powered by"}),r.jsx("span",{children:" "}),r.jsxs("span",{className:"flex items-center gap-[1px]",children:[r.jsx("span",{children:r.jsx(Bh,{className:"size-3 inline-block"})}),r.jsx("span",{className:"font-semibold",children:"open"})]})]})})})}function pt({className:e,...t}){return r.jsx("div",{className:z("animate-pulse rounded-md bg-secondary",e),...t})}const Uh=3;function tc(e,t){for(const n of e){if(n.id===t)return n;const o=tc(n.topics,t);if(o)return o}}function qh({articleId:e,siblings:t,popular:n}){const o=new Set([e]),s=[];for(const{id:a,title:i,slug:c}of[...t,...n])if(!o.has(a)&&(o.add(a),s.push({id:a,title:i,slug:c}),s.length===Uh))break;return s}const Co="w-full justify-between gap-3 rounded-[19px] px-3 py-2.5 text-start whitespace-normal";function bt({title:e,children:t,component:n}){return r.jsxs("section",{...L(n),className:"rounded-3xl border bg-background p-1",children:[e&&r.jsx("p",{className:"px-3 pt-2.5 pb-1 text-xs text-muted-foreground/75 uppercase font-semibold tracking-tight",children:e}),r.jsx("div",{className:"flex flex-col",children:t})]})}function nc({topic:e,onOpen:t}){return r.jsxs(X,{...L("home/topic_row"),variant:"ghost",wobble:!1,size:"free",className:Co,onClick:()=>t(e.id),children:[r.jsx(M.FolderIcon,{className:"size-4 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium leading-snug [overflow-wrap:anywhere]",children:e.name}),r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground tabular-nums",children:e.article_count}),r.jsx(M.ChevronRightIcon,{className:"size-4 shrink-0 text-muted-foreground rtl:-scale-100"})]})}function rc({article:e,onOpen:t}){return r.jsxs(X,{...L("home/article_link"),variant:"ghost",wobble:!1,size:"free",className:Co,onClick:()=>t(e.slug),children:[r.jsx("span",{className:"min-w-0 flex-1 text-sm leading-snug [overflow-wrap:anywhere]",children:e.title}),r.jsx(M.ChevronRightIcon,{className:"size-4 shrink-0 text-muted-foreground rtl:-scale-100"})]})}function oc({component:e,onBack:t,children:n}){const{setIsOpen:o}=C.useWidgetTrigger(),{isSmallScreen:s}=je(),{t:a}=G();return r.jsxs("header",{...L(e),className:"shrink-0 flex items-center gap-2 px-4 py-2 border-b",children:[r.jsx(X,{variant:"ghost",size:"fit",className:"shrink-0 rounded-full","aria-label":a("article_back"),onClick:t,children:r.jsx(M.ChevronLeftIcon,{className:"size-4 rtl:-scale-100"})}),n,s&&r.jsx(X,{variant:"ghost",size:"fit",className:"shrink-0 rounded-full",onClick:()=>o(!1),children:r.jsx(M.XIcon,{className:"size-4"})})]})}function In(){return r.jsxs("div",{className:"px-3 py-2.5 space-y-1.5",children:[r.jsx(pt,{className:"h-4 w-2/3"}),r.jsx(pt,{className:"h-3 w-full"})]})}function sc({onClick:e}){const{t}=G();return r.jsx(X,{...L("home/show_more"),variant:"ghost",wobble:!1,size:"free",className:"w-full justify-center rounded-[19px] px-3 py-2.5 text-sm font-medium text-primary",onClick:e,children:t("home_show_more")})}const As=99,Vh=e=>e?16:9,ac=(e,t)=>e/2*(1-Math.SQRT1_2)-Vh(t)/2;function ic({count:e,showCount:t,component:n="trigger/unread",style:o}){return e<=0?null:r.jsx(F.motion.span,{...L(n),"data-unread-look":t?"count":"dot","aria-hidden":!0,initial:{scale:0},animate:{scale:1},transition:ge,style:o,children:t?e>As?`${As}+`:e:null})}function Yh(){return r.jsx("style",{children:`
|
|
128
|
+
`}),!t&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{"data-opencx-mark-hint":"",style:{position:"fixed",top:16,left:"50%",transform:"translateX(-50%)",zIndex:l.chromeZIndex,display:"flex",alignItems:"center",gap:8,background:`color-mix(in srgb, ${l.surface} 92%, transparent)`,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",color:l.foreground,font:"500 12px/1.4 system-ui, sans-serif",padding:"7px 12px 7px 10px",borderRadius:999,whiteSpace:"nowrap",boxShadow:`0 0 0 1px ${l.border}, 0 8px 24px color-mix(in srgb, ${l.foreground} 14%, transparent)`,animation:"opencx-mark-hint-in 200ms cubic-bezier(0.23, 1, 0.32, 1)"},children:[r.jsx("span",{style:{width:7,height:7,borderRadius:999,background:m}}),d("page_mark_hint"),r.jsx(Gm,{theme:l,children:d("page_mark_escape")})]}),n&&r.jsx("div",{"data-opencx-mark-frame":"",style:{position:"fixed",left:n.rect.x-4,top:n.rect.y-4,width:n.rect.width+8,height:n.rect.height+8,zIndex:l.chromeZIndex,borderRadius:10,boxShadow:`0 0 0 2px ${l.surface}, 0 0 0 3.5px ${m}, 0 12px 32px color-mix(in srgb, ${l.foreground} 16%, transparent)`,animation:"opencx-mark-frame-in 140ms cubic-bezier(0.23, 1, 0.32, 1)",transitionProperty:"left, top, width, height",transitionDuration:"90ms",transitionTimingFunction:"cubic-bezier(0.23, 1, 0.32, 1)",pointerEvents:"none"}},n.key)]}),t&&r.jsxs(r.Fragment,{children:[[[t.rect.x,t.rect.y],[t.rect.x+t.rect.width,t.rect.y],[t.rect.x,t.rect.y+t.rect.height],[t.rect.x+t.rect.width,t.rect.y+t.rect.height]].map(([p,h],f)=>r.jsx("div",{style:{position:"fixed",left:p-5,top:h-5,width:10,height:10,borderRadius:999,background:l.surface,boxShadow:`0 0 0 2px ${m}, 0 2px 6px color-mix(in srgb, ${l.foreground} 25%, transparent)`,zIndex:l.chromeZIndex,pointerEvents:"none"}},f)),r.jsx(Jm,{draft:t,theme:l,onShapeChange:o,onAttach:s},"editor")]})]}),a)}function Gm({children:e,theme:t}){return r.jsx("span",{style:{font:"600 10px/1 system-ui, sans-serif",color:t.mutedForeground,background:`color-mix(in srgb, ${t.foreground} 7%, transparent)`,border:`1px solid ${t.border}`,borderRadius:5,padding:"3px 5px 2px"},children:e})}const Km={box:r.jsx("rect",{x:"3",y:"5",width:"14",height:"10",rx:"1"}),circle:r.jsx("ellipse",{cx:"10",cy:"10",rx:"7",ry:"5.5"}),arrow:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M3 10h13"}),r.jsx("path",{d:"M12 6l4 4-4 4"})]}),bracket:r.jsx("path",{d:"M7 4H4v12h3"}),underline:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 8h10",opacity:"0.35"}),r.jsx("path",{d:"M4 14h12"})]}),highlight:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"7",width:"14",height:"6",rx:"1",fill:"currentColor",opacity:"0.3",stroke:"none"}),r.jsx("path",{d:"M5 10h10"})]}),"strike-through":r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M6 6h8",opacity:"0.35"}),r.jsx("path",{d:"M6 14h8",opacity:"0.35"}),r.jsx("path",{d:"M4 10h12"})]}),"crossed-off":r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M4 5l12 10"}),r.jsx("path",{d:"M16 5L4 15"})]})},Zm={box:"page_mark_shape_box",circle:"page_mark_shape_circle",arrow:"page_mark_shape_arrow",bracket:"page_mark_shape_bracket",underline:"page_mark_shape_underline",highlight:"page_mark_shape_highlight","strike-through":"page_mark_shape_strike_through","crossed-off":"page_mark_shape_crossed_off"};function Jm({draft:e,theme:t,onShapeChange:n,onAttach:o}){const{accent:s}=t,{t:a}=G(),[i,c]=u.useState(""),d=u.useRef(null);u.useEffect(()=>{var y;(y=d.current)==null||y.focus()},[]);const l=320,m=window.innerWidth,p=window.innerHeight,{rect:h}=e,f=Math.max(12,Math.min(h.x+h.width/2-l/2,m-l-12)),x=h.y+h.height+16,g=x+138>p?Math.max(12,h.y-134):x;return r.jsxs("div",{"data-opencx-mark-editor":"",style:{position:"fixed",left:f,top:g,width:l,zIndex:t.editorZIndex,pointerEvents:"auto",display:"flex",flexDirection:"column",gap:6,background:`color-mix(in srgb, ${t.surface} 96%, transparent)`,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",padding:8,borderRadius:14,boxShadow:`0 0 0 1px ${t.border}, 0 12px 32px color-mix(in srgb, ${t.foreground} 18%, transparent)`,animation:"opencx-mark-editor-in 180ms cubic-bezier(0.23, 1, 0.32, 1)"},children:[r.jsx("div",{style:{display:"flex",gap:2,justifyContent:"space-between"},children:am.map(y=>{const w=y===e.shape,j=a(Zm[y]);return r.jsx("button",{type:"button",title:j,"aria-label":a("page_mark_shape_aria",{shape:j}),"aria-pressed":w,onClick:()=>n(y),style:{border:"none",cursor:"pointer",borderRadius:8,width:32,height:28,display:"flex",alignItems:"center",justifyContent:"center",background:w?s:"transparent",color:w?t.surface:t.mutedForeground},children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Km[y]})},y)})}),r.jsxs("div",{style:{display:"flex",alignItems:"flex-end",gap:8},children:[r.jsx("textarea",{ref:d,rows:2,value:i,onChange:y=>c(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),o(i))},placeholder:a("page_mark_note_placeholder"),style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:t.foreground,font:"500 13px/1.4 system-ui, sans-serif",margin:0,paddingBlock:0,paddingInlineStart:4,paddingInlineEnd:0,resize:"none"}}),r.jsx("button",{type:"button","aria-label":a("page_mark_attach"),onClick:()=>o(i),style:{border:"none",borderRadius:999,width:26,height:26,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:s,color:t.surface,font:"600 13px/1 system-ui, sans-serif",cursor:"pointer"},children:"↑"})]})]})}function Qm({mark:e,onRemove:t}){var c;const{t:n}=G(),o=Ei(e),s=e.note??((c=e.elements[0])==null?void 0:c.name)??n("page_mark_region"),a=n("page_mark_remove",{label:s}),i=e.elements.map(d=>d.name).join(", ");return o?r.jsx(Si,{...L("chat/input_box/page_mark_pill"),className:"group",shape:"tile",src:o,alt:s,title:i,note:e.note,children:r.jsx("button",{type:"button","aria-label":a,className:z("absolute top-1 end-1 rounded-full p-0.5","bg-foreground/60 text-background backdrop-blur-sm","opacity-0 group-hover:opacity-100 focus-visible:opacity-100","transition-opacity active:scale-90"),onClick:t,children:r.jsx(M.XIcon,{className:"size-3"})})}):r.jsxs("div",{...L("chat/input_box/page_mark_pill"),title:i,className:z("group relative size-12 shrink-0 overflow-hidden","flex items-center justify-center","rounded-2xl bg-background ring-1 ring-border"),children:[r.jsx(M.PenLineIcon,{className:"size-4 shrink-0 text-primary"}),r.jsx("span",{className:z("absolute inset-x-0 bottom-0 truncate px-1.5 py-0.5","bg-gradient-to-t from-foreground/70 to-foreground/0","text-[10px] font-medium leading-tight text-background"),children:s}),r.jsx("button",{type:"button","aria-label":a,className:z("absolute top-1 end-1 rounded-full p-0.5","bg-foreground/60 text-background backdrop-blur-sm","opacity-0 group-hover:opacity-100 focus-visible:opacity-100","transition-opacity active:scale-90"),onClick:t,children:r.jsx(M.XIcon,{className:"size-3"})})]})}const Le={"close-panel":"Escape","toggle-fullscreen":"Mod+Shift+F",send:"Enter","send-alt":"Mod+Enter","history-prev":"ArrowUp","history-next":"ArrowDown"};function Vi(){return typeof navigator>"u"?!1:/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)}function xt(e,t,n=Vi()){const o=t.split("+"),s=o.at(-1)??"",a=new Set(o.slice(0,-1)),i=a.has("Cmd")||a.has("Mod")&&n,c=a.has("Ctrl")||a.has("Mod")&&!n;return e.metaKey!==i||e.ctrlKey!==c||e.altKey!==a.has("Alt")||e.shiftKey!==a.has("Shift")?!1:e.key.toLowerCase()===s.toLowerCase()}const eh={Mod:"⌘",Cmd:"⌘",Ctrl:"⌃",Alt:"⌥",Shift:"⇧"},th={Escape:"Esc",Enter:"⏎",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→"};function yo(e,t=Vi()){const n=e.split("+"),o=n.at(-1)??"",s=n.slice(0,-1),a=th[o]??(o.length===1?o.toUpperCase():o);return t?[...s.map(i=>eh[i]??i),a].join(""):[...s.map(i=>i==="Mod"?"Ctrl":i),a].join("+")}const nh=50*1024*1024,Yi={"application/pdf":[".pdf"],...Xd,...Gd},rh={"text/*":[".txt"],"image/*":[".png",".jpg",".jpeg",".gif"],...Yi},oh={"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"],...Yi};function sh({status:e}){switch(e){case"uploading":return r.jsx(M.Loader2,{className:"size-4 animate-spin"});case"error":return r.jsx(M.AlertCircle,{className:"size-4 text-destructive"});default:return null}}function ah({file:e,fileContent:t}){const n=e.type.split("/")[0];return n==="image"&&t?r.jsx("img",{src:typeof t=="string"?t:"",className:"object-cover bg-secondary size-full",alt:e.name}):n==="audio"?r.jsx(M.FileAudio2Icon,{className:"size-4 text-muted-foreground"}):n==="video"?r.jsx(M.FileVideo2Icon,{className:"size-4 text-muted-foreground"}):e.type==="application/pdf"?r.jsx(M.FileText,{className:"size-4 text-muted-foreground"}):Ka({type:e.type,name:e.name})?r.jsx(M.FileSpreadsheet,{className:"size-4 text-muted-foreground"}):r.jsx(M.FileIcon,{className:"size-4 text-muted-foreground"})}function ih({file:{status:e,file:t,error:n},onCancel:o}){const{t:s}=G(),[a,i]=u.useState(null);return u.useEffect(()=>{if(!t.type.startsWith("image/"))return;const c=new FileReader;return c.onload=()=>i(c.result),c.onerror=()=>K.log.error("failed to read file for preview"),c.readAsDataURL(t),()=>c.abort()},[t]),r.jsx(Ne,{side:"bottom",content:e==="error"?r.jsx("span",{className:"text-destructive",children:s("upload_failed",{error:n??""})}):t.name,children:r.jsxs("div",{className:z(e==="uploading"&&"opacity-50","group","size-12 border rounded-2xl overflow-hidden relative","flex items-center justify-center shrink-0"),children:[r.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:r.jsx(sh,{status:e})}),r.jsx("button",{type:"button",className:z("absolute bg-foreground/50 inset-0 size-full z-10","flex items-center justify-center","opacity-0 group-hover:opacity-100 transition"),onClick:o,"aria-label":s("remove_attachment"),children:r.jsx(M.XIcon,{className:"size-4 text-primary-foreground"})}),r.jsx(ah,{file:t,fileContent:a})]})})}function ch(){const{queuedUserMessages:e,removeQueued:t,stop:n}=C.useAgentChatUi(),{messagesState:{messages:o}}=C.useMessages(),{t:s}=G(),a=u.useMemo(()=>e.filter(i=>!o.some(c=>c.id===i.id)),[e,o]);return r.jsx(F.AnimatePresence,{children:a.length>0&&r.jsx(_e,{children:r.jsxs("div",{...L("chat/queued_sends/root"),className:"mb-1 rounded-2xl border border-muted-foreground/15 bg-background shadow-sm",children:[r.jsxs("div",{...L("chat/queued_sends/header"),className:"flex items-center justify-between px-3 pt-2 pb-1",children:[r.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s("queued_label",{count:a.length})}),r.jsx("button",{type:"button",...L("chat/queued_sends/send_now"),"aria-label":s("send_queued_now"),title:s("send_queued_now"),onClick:n,className:"rounded-md p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground hover:bg-muted",children:r.jsx(M.CornerDownLeftIcon,{className:"size-3"})})]}),r.jsx("ul",{...L("chat/queued_sends/list"),className:"flex flex-col pb-1",children:a.map(i=>r.jsxs("li",{...L("chat/queued_sends/item"),className:"group flex items-center gap-2 px-3 py-1",children:[r.jsx("button",{type:"button",title:s("send_queued_now"),onClick:n,className:"min-w-0 flex-1 truncate text-start text-xs text-foreground/80 hover:text-foreground",children:i.content}),r.jsx("button",{type:"button",...L("chat/queued_sends/remove"),"aria-label":s("remove_queued_message"),onClick:()=>t(i.id),className:"shrink-0 rounded-md p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground hover:bg-muted",children:r.jsx(M.XIcon,{className:"size-3.5"})})]},i.id))})]})},"queued-sends-pill")})}function lh({levelRef:e}){const t=u.useRef(null);return u.useEffect(()=>{let n=0;const o=new K.DictationLevelSmoother({attack:.2,release:.07}),s=[],a=()=>{var c;const i=(c=t.current)==null?void 0:c.children;if(i){const d=o.next(e.current);for(let l=0;l<i.length;l++){const m=i[l];if(m instanceof HTMLElement){const p=.75+.25*Math.sin(Date.now()/260+l*1.7),h=`scaleY(${Math.max(.25,Math.min(1,d*1.8*p)).toFixed(3)})`;s[l]!==h&&(m.style.transform=h,s[l]=h)}}}n=requestAnimationFrame(a)};return n=requestAnimationFrame(a),()=>cancelAnimationFrame(n)},[e]),r.jsx("div",{ref:t,"aria-hidden":"true",className:"flex h-3.5 shrink-0 items-center gap-[3px]",children:[0,1,2,3].map(n=>r.jsx("span",{className:"h-full w-[3px] origin-center scale-y-50 rounded-full bg-current transition-transform duration-100 ease-out"},n))})}function dh({status:e,levelRef:t,onToggle:n,onPrewarm:o}){const{t:s}=G(),a=e==="listening",i=e==="connecting",c=s(a||i?"stop_dictation":"dictate");return r.jsx(Ne,{side:"top",align:"start",content:c,children:r.jsxs(X,{...L("chat/input_box/dictate_btn"),onClick:n,onPointerDown:d=>d.preventDefault(),onPointerEnter:o,onFocus:o,"aria-pressed":a||i,"aria-label":c,size:"fit",variant:"ghost",className:z("relative",qt,a&&qi),children:[i&&r.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0.5 animate-spin rounded-full border-[1.5px] border-current/20 border-t-current"}),r.jsx(F.AnimatePresence,{mode:"wait",children:a?r.jsx(oe,{distance:0,children:r.jsx(lh,{levelRef:t})},"bars"):r.jsx(oe,{distance:0,children:r.jsx(M.MicIcon,{className:z("size-4",i&&"opacity-60")})},"mic")})]})})}function uh(){const e=Ot(),{language:t}=G();if(!e.enabled)return null;const n=fo(t,"start_call");return r.jsx(Ne,{side:"top",align:"start",content:n,children:r.jsx(X,{...L("chat/input_box/voice_call_btn"),onClick:()=>void e.start(),"aria-label":n,size:"fit",variant:"ghost",className:qt,children:r.jsx(M.PhoneIcon,{className:"size-4"})})})}function ph(e,t){const n=e.ownerDocument;if(!n.defaultView)return null;const s=n.createElement("div");Xi(e,s),Object.assign(s.style,{position:"absolute",visibility:"hidden",top:"0",left:"-9999px",height:"auto",overflow:"hidden",whiteSpace:"pre-wrap",overflowWrap:"break-word",width:`${e.clientWidth}px`}),s.textContent=e.value.slice(0,t);const a=n.createElement("span");a.textContent="",s.appendChild(a),n.body.appendChild(s);const i=a.offsetLeft,c=a.offsetTop-e.scrollTop;return s.remove(),{left:i,top:c}}function Xi(e,t){const n=e.ownerDocument.defaultView;if(!n)return;const o=n.getComputedStyle(e);for(const s of mh)t.style.setProperty(s,o.getPropertyValue(s))}const mh=["box-sizing","font-family","font-size","font-weight","font-style","letter-spacing","line-height","text-transform","text-indent","word-spacing","tab-size","padding-top","padding-right","padding-bottom","padding-left","border-top-width","border-right-width","border-bottom-width","border-left-width"],hh=300,Gi=260,fh=8,Ki="rounded-xl border border-border bg-background shadow-lg";function gh({anchorRef:e,inputRef:t,anchorIndex:n,preview:o,groups:s,visible:a,searching:i,highlighted:c,onHighlight:d,onPick:l,onExpand:m}){var j;const{t:p}=G(),[h,f]=u.useState(null);u.useLayoutEffect(()=>{const b=e.current;if(!b)return;const _=b.ownerDocument.defaultView,v=()=>{const N=b.getBoundingClientRect(),R=(_==null?void 0:_.innerWidth)??N.right,T=Math.min(hh,Math.max(0,R-16)),A=t.current,O=A&&n!==null?ph(A,n):null,P=A==null?void 0:A.getBoundingClientRect(),B=O&&P?P.left+O.left:N.left+8,E=Math.max(8,Math.min(B,R-8-T)),I=O&&P?P.top+O.top-4:N.top-4;f({left:E,width:T,top:I,detailBeside:o&&E+T+fh+Gi<=R-8})};v(),_==null||_.addEventListener("resize",v);const k=typeof ResizeObserver>"u"?null:new ResizeObserver(v);return k==null||k.observe(b),()=>{_==null||_.removeEventListener("resize",v),k==null||k.disconnect()}},[n,e,t,o,a.length]);const x=(j=e.current)==null?void 0:j.closest("[data-version]");if(!x||!h||a.length===0&&i)return null;const g=a[c],y=g!=null&&g.description?g:null;let w=-1;return Qt.createPortal(r.jsxs("div",{...L("chat/input_box/mention_picker"),style:{position:"fixed",left:h.left,top:h.top,transform:"translateY(-100%)"},className:"z-50 flex items-end gap-2",children:[r.jsx("div",{role:"listbox",style:{width:h.width},className:z("flex max-h-72 flex-col overflow-hidden",Ki),children:r.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-1",children:a.length===0?r.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:p("mentions_empty")}):s.map(b=>u.createElement("div",{...L("chat/input_box/mention_picker/group"),key:b.type,role:"group","aria-label":b.type},r.jsx("div",{className:"px-2 pb-0.5 pt-1.5 text-xs capitalize text-muted-foreground",children:b.type}),b.items.map(_=>{const v=++w;return u.createElement("button",{...L("chat/input_box/mention_picker/option"),key:`${_.type}:${_.id}`,type:"button",role:"option","aria-selected":v===c,onMouseDown:k=>k.preventDefault(),onMouseEnter:()=>d(v),onClick:()=>l(_),className:z("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-sm",v===c?"bg-muted":"hover:bg-muted/60")},r.jsx(Zi,{item:_}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground",children:_.title}))}),b.hidden>0&&r.jsx("button",{...L("chat/input_box/mention_picker/more"),type:"button",onMouseDown:_=>_.preventDefault(),onClick:()=>m(b.type),className:z("w-full rounded-lg px-2 py-1 text-start text-xs","text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:p("json_see_more",{count:String(b.hidden)})})))})}),y&&h.detailBeside&&r.jsx(xh,{item:y})]}),x)}function xh({item:e}){return r.jsxs("div",{...L("chat/input_box/mention_picker/detail"),style:{width:Gi},className:z("flex gap-3 p-3",Ki),children:[r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted",children:r.jsx(Zi,{item:e,className:"size-4"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-[10px] uppercase tracking-wide text-muted-foreground",children:e.type}),r.jsx("span",{className:"block truncate text-sm font-medium text-foreground",children:e.title}),r.jsx("span",{className:"mt-0.5 line-clamp-3 text-xs text-muted-foreground",children:e.description})]})]})}function Zi({item:e,className:t}){return e.icon?r.jsx("img",{src:e.icon,alt:"",className:z("size-4 shrink-0 rounded-sm object-contain",t)}):r.jsx(zt,{name:e.iconName??"AtSign",className:z("size-3.5 shrink-0 text-primary",t)})}const Ji=u.createContext(null);function bh({children:e}){const[t,n]=u.useState([]),[o,s]=u.useState(!1),a=u.useRef(new Map),i=u.useCallback(p=>{s(p)},[]),c=u.useCallback((p,h)=>{a.current.set(p,h),n(f=>[...f,p])},[]),d=u.useCallback(p=>{const h=a.current.get(p);h&&(a.current.delete(p),h.undraw()),n(f=>f.filter(x=>x!==p))},[]),l=u.useCallback(()=>{const p=Array.from(a.current.values());a.current.clear();for(const h of p)h.undraw();n([])},[]);u.useEffect(()=>()=>{a.current.forEach(p=>p.remove()),a.current.clear()},[]);const m=u.useMemo(()=>({marks:t,isArmed:o,setArmed:i,attach:c,detach:d,detachAll:l}),[t,o,i,c,d,l]);return r.jsx(Ji.Provider,{value:m,children:e})}function ko(){const e=u.useContext(Ji);if(!e)throw new Error("usePageMarks must be used within a PageMarksProvider");return e}const wh="data-opencx-mark-cursor",vh=5,vn=4,yn=6,tr={width:160,height:100},yh=10,kh=mo.map(e=>`:not(${e}):not(${e} *)`).join(""),jh=e=>e==="nw"||e==="se"?"nwse-resize":"nesw-resize";function Ch({enabled:e,composerRef:t,onAttach:n,accentColor:o,zIndex:s}){const{isArmed:a,setArmed:i,attach:c}=ko(),d=e&&a,[l,m]=u.useState(null),[p,h]=u.useState(null),f=u.useRef(null),x=u.useRef(null);x.current=l;const g=u.useCallback(()=>{var v;(v=f.current)==null||v.undraw(),f.current=null,m(null)},[]),y=u.useCallback(()=>i(!1),[i]),w=u.useCallback(v=>{var k;m(N=>N&&{...N,rect:v}),(k=f.current)==null||k.setRect({x:v.x+window.scrollX,y:v.y+window.scrollY,width:v.width,height:v.height})},[]),j=u.useCallback(v=>{var k;m(N=>N&&{...N,shape:v}),(k=f.current)==null||k.setShape(v)},[]);u.useEffect(()=>{!e&&a&&i(!1)},[e,a,i]),u.useEffect(()=>{var xe;if(!d)return;const v=document.createElement("style");v.setAttribute(wh,"");let k=null;const N=H=>{H!==k&&(k=H,v.textContent=`*${kh} { cursor: ${H} !important; }`)};N("crosshair"),document.head.appendChild(v);let R=null;const T=H=>H.target instanceof Element&&cn(H.target),A=H=>T(H)?!1:(H.preventDefault(),H.stopPropagation(),H.stopImmediatePropagation(),!0),O=(H,ee,J)=>{const ne=[["nw",H.x,H.y],["ne",H.x+H.width,H.y],["sw",H.x,H.y+H.height],["se",H.x+H.width,H.y+H.height]];for(const[le,de,ie]of ne)if(Math.hypot(ee-de,J-ie)<=yh)return le;return null},P=(H,ee,J)=>ee>=H.x&&ee<=H.x+H.width&&J>=H.y&&J<=H.y+H.height,B=(H,ee)=>{var de;const J=Mr(H,ee),ne=gs(J?(()=>{const ie=J.getBoundingClientRect();return{x:ie.left-yn,y:ie.top-yn,width:ie.width+yn*2,height:ie.height+yn*2}})():{x:H-tr.width/2,y:ee-tr.height/2,...tr}),le=((de=x.current)==null?void 0:de.shape)??"box";h(null),f.current=lm({x:ne.x+window.scrollX,y:ne.y+window.scrollY,width:ne.width,height:ne.height},le,o,s),m({rect:ne,shape:le})},E=H=>{var ne;if(!A(H)||H.button!==0)return;const ee=x.current;if(!ee){B(H.clientX,H.clientY);return}const J=O(ee.rect,H.clientX,H.clientY);if(J){R={kind:"resize",corner:J};return}if(P(ee.rect,H.clientX,H.clientY)){R={kind:"move",grabX:H.clientX-ee.rect.x,grabY:H.clientY-ee.rect.y};return}(ne=f.current)==null||ne.undraw(),f.current=null,B(H.clientX,H.clientY)};let I=null,W=0;const $=H=>{if(!A(H))return;const ee=x.current;if(!ee){N("crosshair");const pe=Mr(H.clientX,H.clientY);if(!pe){I=null,h(null);return}pe!==I&&(I=pe,W+=1),h({rect:gs(fm(pe)),key:W});return}if(!R){const pe=O(ee.rect,H.clientX,H.clientY);N(pe?jh(pe):P(ee.rect,H.clientX,H.clientY)?"move":"crosshair");return}const{rect:J}=ee;if(R.kind==="move"){w({...J,x:H.clientX-R.grabX,y:H.clientY-R.grabY});return}const ne=R.corner.includes("w")?J.x+J.width:J.x,le=R.corner.includes("n")?J.y+J.height:J.y,de=Math.min(ne,H.clientX),ie=Math.max(ne,H.clientX),De=Math.min(le,H.clientY),Fe=Math.max(le,H.clientY);w({x:de,y:De,width:Math.max(hs,ie-de),height:Math.max(hs,Fe-De)})},U=H=>{A(H)&&(R=null)},Y=H=>{T(H)||A(H),R=null},q=H=>{A(H)},se=H=>{var ee;if(H.key==="Escape"){if(H.preventDefault(),H.stopImmediatePropagation(),R=null,x.current){(ee=f.current)==null||ee.undraw(),f.current=null,m(null),N("crosshair");return}i(!1)}};let D=window.scrollX,V=window.scrollY;const Z=()=>{h(null);const H=window.scrollX-D,ee=window.scrollY-V;D=window.scrollX,V=window.scrollY,!(H===0&&ee===0)&&m(J=>J&&{...J,rect:{...J.rect,x:J.rect.x-H,y:J.rect.y-ee}})};document.addEventListener("pointerdown",E,!0),document.addEventListener("pointermove",$,!0),document.addEventListener("pointerup",U,!0),document.addEventListener("pointercancel",Y,!0),document.addEventListener("click",q,!0);const te=new Set([window]),ae=(xe=t==null?void 0:t.current)==null?void 0:xe.ownerDocument.defaultView;return ae&&te.add(ae),te.forEach(H=>H.addEventListener("keydown",se,!0)),document.addEventListener("scroll",Z,!0),()=>{v.remove(),document.removeEventListener("pointerdown",E,!0),document.removeEventListener("pointermove",$,!0),document.removeEventListener("pointerup",U,!0),document.removeEventListener("pointercancel",Y,!0),document.removeEventListener("click",q,!0),te.forEach(H=>H.removeEventListener("keydown",se,!0)),document.removeEventListener("scroll",Z,!0),h(null)}},[d,t,o,s,w,i]),u.useEffect(()=>{!d&&x.current&&g()},[d,g]),u.useEffect(()=>()=>{var v;(v=f.current)==null||v.remove(),f.current=null},[]);const b=u.useCallback(v=>{if(!e)return;const k=x.current,N=f.current;if(!k||!N)return;const R=v.trim(),T=Sh(k.rect),A={shape:k.shape,...R?{note:R}:{},pageUrl:ho(window.location.href),rect:k.rect,elements:T.map($i)};bm(A,T),T[0]&&yp(A,T[0]),f.current=null,m(null),i(!1),c(A,N),n==null||n(A)},[c,e,n,i]),_=u.useCallback(()=>{e&&i(!a)},[e,a,i]);return{isActive:d,draft:l,hover:p,setShape:j,attach:b,dropDraft:g,disarm:y,toggle:_}}function Sh(e){const t=new Set,n=(o,s)=>{const a=Mr(o,s);a&&t.add(a)};n(e.x+e.width/2,e.y+e.height/2);for(let o=0;o<=vn;o++)for(let s=0;s<=vn;s++)n(e.x+e.width*o/vn,e.y+e.height*s/vn);return Array.from(t).slice(0,vh)}function Nh({enabled:e,inputRef:t}){const{widgetCtx:n}=C.useWidget(),{theme:o,cssVars:s}=me(),a=vo({cssVars:s,primaryColor:o.primaryColor,contentZIndex:o.widgetContentContainer.zIndex}),{marks:i,detach:c}=ko(),d=u.useCallback(()=>{var p;(p=t.current)==null||p.focus()},[t]),l=u.useCallback(async p=>{if(!n.features.pageContext||!n.features.attachments)return null;try{const{fileUrl:h}=await n.api.uploadFile({file:p,abortSignal:new AbortController().signal});return h??null}catch(h){return K.log.warn("page mark snapshot upload failed",h),null}},[n]),m=Ch({enabled:e,composerRef:t,onAttach:d,accentColor:a.accent,zIndex:a.inkZIndex});return{marks:i,detach:c,marking:m,uploadSnapshot:l}}function _h({inputText:e,setInputText:t,inputRef:n,getSentTextHistory:o}){const s=u.useRef(null),a=u.useRef(""),i=()=>{const p=n.current;p&&(p.classList.remove("opencx-input-recall"),p.offsetWidth,p.classList.add("opencx-input-recall"))},c=(p,{animate:h=!0}={})=>{t(p),h&&i(),requestAnimationFrame(()=>{var f;return(f=n.current)==null?void 0:f.setSelectionRange(p.length,p.length)})};return{onKeyDown:p=>{if(xt(p,Le["history-prev"])){const h=o();if(h.length===0)return!1;const f=s.current;if(f===null){const x=n.current;if(!((x==null?void 0:x.selectionStart)===0&&(x==null?void 0:x.selectionEnd)===0)&&e!=="")return!1;a.current=e,s.current=h.length-1}else{if(f===0)return!1;s.current=f-1}return p.preventDefault(),c(h[s.current],{animate:!p.repeat}),!0}if(xt(p,Le["history-next"])){const h=s.current;if(h===null)return!1;p.preventDefault();const f=o();return h>=f.length-1?(s.current=null,c(a.current,{animate:!p.repeat}),a.current=""):(s.current=h+1,c(f[s.current],{animate:!p.repeat})),!0}return!1},onEdit:()=>{s.current=null},onSent:()=>{s.current=null,a.current=""}}}const Ns="max-h-16 [field-sizing:content] w-full px-2",Eh=1e3;function Qi(e={}){const{sessionEnded:t}=C.useTokenRenewal();return t?r.jsx(Ah,{}):r.jsx(Th,{...e})}function Ah(){const{t:e}=G();return r.jsx("div",{className:"p-2",...L("chat/session_ended"),children:r.jsxs("div",{role:"status",className:"flex items-center gap-2 p-3 bg-muted rounded-[var(--opencx-inset-radius)] text-sm",children:[r.jsx(M.LockIcon,{className:"size-4 shrink-0 text-muted-foreground"}),r.jsx("span",{children:e("session_ended_sign_in_again")})]})})}function Th({trailingActions:e,placeholder:t,hideAttachTools:n,disabled:o=!1}){var pn;const{isSmallScreen:s}=je(),a=u.useRef(null),i=u.useRef(null),c=u.useRef(null),d=u.useRef(!0),{messagesState:l,rememberSentText:m,getSentTextHistory:p}=C.useMessages(),h=an(),{widgetCtx:f,componentStore:x}=C.useWidget(),{attachments:g,pageContext:y}=f.features,{isStreaming:w,stop:j,queuedUserMessages:b,pendingClarification:_,pendingConnection:v,pendingPageAction:k}=C.useAgentChatUi(),{sessionState:N}=C.useSessions(),R=o||Tr({isStreaming:w,messages:l.messages,session:N.session}),T=u.useRef(w);T.current=w;const{t:A}=G(),{text:O,setText:P,clearSubmitted:B}=C.useComposerDraft(),E=Ym(),I=Rp({text:O,setText:P,inputRef:a}),W=I.picked.length>0;u.useLayoutEffect(()=>{const Q=a.current,be=c.current;!Q||!be||Xi(Q,be)},[W,O]);const[$,U]=u.useState(!1),Y=E?`${E.type}:${E.id}`:"";u.useEffect(()=>{U(!1)},[Y]);const[q,se]=u.useState(null),D=u.useRef(O);D.current=O;const V=u.useRef(()=>{}),Z=C.useDictation({getValue:()=>D.current,setValue:Q=>{D.current=Q,P(Q)},onSend:()=>V.current()}),{stop:te}=Z;u.useEffect(()=>{R&&te({executeFinalCommand:!1})},[R,te]),u.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]);const ae=_h({inputText:O,setInputText:P,inputRef:a,getSentTextHistory:p}),xe=y&&!s,H=!R&&xe&&n!==!0,{marks:ee,detach:J,marking:ne,uploadSnapshot:le}=Nh({enabled:H,inputRef:a});u.useEffect(()=>{y||ee.forEach(J)},[y,ee,J]);const{allFiles:de,handleCancelUpload:ie,appendFiles:De,emptyTheFiles:Fe,isUploading:pe,successFiles:Ve}=C.useUploadFiles();u.useEffect(()=>{!g&&de.length>0&&Fe()},[g,de.length,Fe]);const st=!!((pn=N.session)!=null&&pn.isHandedOff),{isAwaitingBotReply:Ye}=C.useIsAwaitingBotReply(),He=f.messageCtx.blocksSendWhileAwaitingReply&&Ye,Xe=Q=>{R||!g||(se(null),De(Q))},Ge=E!==null&&!$,we=de.length>0||ee.length>0,Re=!O.trim()&&Ve.length===0&&(!y||!ee.some(Cn)),We=w&&Re,Wn=We&&b.length>0,dn=R||pe||He||Re,ve=u.useRef(0),Lt=()=>{Date.now()-ve.current<Eh||j()},$t=()=>{if(Z.stop({executeFinalCommand:!1}),R||He||pe)return;const Q=D.current,be=f.messageCtx.captureConversation(),Dt=f.messageCtx.draftState.get(),Be=ee.filter(Ee=>f.features.pageContext&&Cn(Ee)?!0:(J(Ee),!1)),Pe=f.features.attachments?[...Ve]:[];if(!Q.trim()&&Pe.length===0&&Be.length===0)return;ve.current=Date.now();const at=de.map(Ee=>Ee.id);Be.forEach(Ee=>kp(Ee,le)),Promise.all(Be.map(Ee=>jp(Ee,Ih))).then(()=>wt({isCurrentConversation:be,submittedText:Q,submittedDraft:Dt,submittedMarks:Be,submittedFiles:Pe,submittedFileIds:at}))},wt=({isCurrentConversation:Q,submittedText:be,submittedDraft:Dt,submittedMarks:Be,submittedFiles:Pe,submittedFileIds:at})=>{if(!Q()||Tr({isStreaming:T.current,messages:f.messageCtx.state.get().messages,session:f.sessionCtx.sessionState.get().session}))return;const vt=f.features.pageContext,it=Be.filter(he=>vt&&Cn(he)?!0:(J(he),!1));if(!be.trim()&&Pe.length===0&&it.length===0)return;const mn=be.trim()||(it.length>0?zh(it)??A("page_mark_default_message"):"");let Ft=!1;const yt=I.picked;h({content:mn,withPageEntity:!$,mentions:yt.length>0?yt:void 0,attachments:Pe.flatMap(he=>he.fileUrl?[{url:he.fileUrl,type:he.file.type,name:he.file.name,id:he.id,size:he.file.size}]:[]),clientContext:Ui({marks:it,readsPage:vt}),onAccepted:()=>{if(Ft||!Q())return;Ft=!0,m(mn),Be.forEach(kt=>J(kt)),at.forEach(kt=>ie(kt));const he=B(Dt);d.current&&(ae.onSent(),U(!1),he&&I.reset())}}).catch(he=>{K.log.error("failed to send message",he)})},{getRootProps:un,getInputProps:Bn,open:Un}=Hc.useDropzone({onDrop:Xe,noClick:!0,disabled:R||!g,onDropRejected(){se(A("file_rejected"))},maxSize:nh,accept:st?rh:oh}),qn=Q=>{const be=Q.clipboardData;be&&be.files.length>0&&Xe(Array.from(be.files))};V.current=$t;const Ce=x.getComponent("agent_chat_questions");return!v&&_&&Ce?r.jsx("div",{...L("chat/input_box/root"),className:"p-2 relative space-y-1",children:r.jsx(Ce,{request:_})}):r.jsxs("div",{...L("chat/input_box/root"),className:"p-2 relative space-y-1",...un({ref:i}),children:[N.session&&r.jsx(rm,{sessionId:N.session.id,active:w||Ye},N.session.id),v&&r.jsx(sm,{request:v},v.request_id),k&&r.jsx(Bm,{request:k},k.callId),r.jsx("input",{...Bn()}),I.isOpen&&r.jsx(gh,{anchorRef:i,inputRef:a,anchorIndex:I.anchorIndex,preview:I.preview,groups:I.groups,visible:I.visible,searching:I.searching,highlighted:I.highlighted,onHighlight:I.setHighlighted,onPick:I.pick,onExpand:I.expandGroup}),H&&r.jsx(Xm,{isActive:ne.isActive,draft:ne.draft,hover:ne.hover,onShapeChange:ne.setShape,onAttach:ne.attach}),r.jsx(ch,{}),q&&r.jsx("p",{role:"alert",className:"px-2 text-xs text-destructive",children:q}),Z.error&&r.jsx("p",{role:"alert",className:"px-2 text-xs text-destructive",children:Z.error==="microphone"?A("dictation_mic_blocked"):A("dictation_unavailable")}),r.jsxs("div",{...L("chat/input_box/attached_context_tray"),style:{"--cx-p":"0.25rem"},className:z("flex flex-col","rounded-[calc(var(--opencx-inset-radius)+var(--cx-p))] p-[var(--cx-p)]","transition-colors duration-200 ease-opencx",Ge?"bg-muted":"bg-transparent"),children:[r.jsx(F.AnimatePresence,{children:Ge&&r.jsx(_e,{children:r.jsx("div",{...L("chat/input_box/page_context_container"),className:"flex items-center gap-1 flex-wrap ps-3 pe-1 py-1",children:r.jsx(F.AnimatePresence,{mode:"popLayout",children:E&&!$&&r.jsx(oe,{snapExit:!0,children:r.jsx(qm,{entity:E,onRemove:()=>U(!0)})},"page-entity")})})},"attached-context")}),r.jsxs("div",{...L("chat/input_box/inner_root"),className:z("transition-colors","bg-background","border border-border","relative rounded-[var(--opencx-inset-radius)] flex flex-col gap-2 p-2"),children:[r.jsxs("div",{...L("chat/input_box/textarea_and_attachments_container"),className:"flex flex-col gap-2",children:[we&&r.jsx("div",{...L("chat/input_box/attachments_container"),className:"flex items-center gap-1 overflow-x-auto",children:r.jsxs(F.AnimatePresence,{mode:"popLayout",children:[de.map(Q=>r.jsx(oe,{snapExit:!0,children:r.jsx(ih,{onCancel:()=>ie(Q.id),file:Q})},Q.id)),ee.map((Q,be)=>r.jsx(oe,{snapExit:!0,children:r.jsx(Qm,{mark:Q,onRemove:()=>J(Q)})},`mark-${be}-${Q.note??""}`))]})}),r.jsxs("div",{className:"relative",children:[W&&r.jsx("div",{ref:c,"aria-hidden":!0,className:z(Ns,"pointer-events-none absolute inset-0 overflow-hidden","whitespace-pre-wrap break-words text-foreground",!we&&"pt-1",s?"text-[16px]":"text-sm"),children:r.jsx(Ai,{text:O,mentions:I.picked,tokenClassName:"bg-primary/10 text-primary"})}),r.jsx("textarea",{...L("chat/input_box/textarea"),disabled:R,onPaste:qn,ref:a,id:"chat-input",value:O,rows:3,className:z(Ns,"relative resize-none",!we&&"pt-1","bg-transparent outline-none","placeholder:text-muted-foreground",W&&"text-transparent caret-foreground",s?"text-[16px]":"text-sm"),onScroll:Q=>{c.current&&(c.current.scrollTop=Q.currentTarget.scrollTop)},onChange:Q=>{ae.onEdit(),P(Q.target.value),f.messageCtx.notifyTyping()},onClick:()=>I.onCaretMove("nearest"),onKeyUp:Q=>{Q.key==="ArrowRight"||Q.key==="ArrowDown"?I.onCaretMove("forward"):Q.key==="ArrowLeft"||Q.key==="ArrowUp"?I.onCaretMove("backward"):(Q.key==="Home"||Q.key==="End")&&I.onCaretMove("nearest")},onKeyDown:Q=>{if(!Q.nativeEvent.isComposing&&!I.onKeyDown(Q)){if(xt(Q,Le.send)||xt(Q,Le["send-alt"])){Q.preventDefault(),Wn?j():$t();return}ae.onKeyDown(Q)}},placeholder:t??A("write_a_message_placeholder")})]})]}),r.jsxs("div",{className:"gap-2 flex justify-between",children:[r.jsx("div",{className:"flex items-center gap-1",children:!R&&!n&&r.jsxs(r.Fragment,{children:[g&&r.jsx(Ne,{side:"top",align:"start",content:A("attach_files"),children:r.jsx(X,{onClick:Un,"aria-label":A("attach_files"),size:"fit",variant:"ghost",className:qt,children:r.jsx(F.AnimatePresence,{mode:"wait",children:He?r.jsx(oe,{distance:0,children:r.jsx(M.PaperclipIcon,{className:"size-4 opacity-50"})},"paper-clip-disabled"):r.jsx(oe,{distance:0,children:r.jsx(M.PaperclipIcon,{className:"size-4"})},"paper-clip")})})}),Z.enabled&&r.jsx(dh,{status:Z.status,levelRef:Z.levelRef,onToggle:Z.toggle,onPrewarm:Z.prewarm}),xe&&r.jsx(Ne,{side:"top",align:"start",content:ne.isActive?A("mark_page_active"):A("mark_page"),children:r.jsx(X,{...L("chat/input_box/page_mark_btn"),onClick:ne.toggle,"aria-label":ne.isActive?A("mark_page_active"):A("mark_page"),size:"fit",variant:"ghost",className:z(qt,ne.isActive&&qi),children:r.jsx(M.MousePointerClickIcon,{className:"size-4"})})})]})}),r.jsxs("div",{className:"flex items-center gap-1",children:[e,!R&&r.jsx(uh,{}),r.jsx(Ne,{content:A(We?"stop_response":"send_message"),shortcut:We?void 0:yo(Le.send),side:"top",align:"end",children:r.jsx(X,{size:"fit",onClick:We?Lt:$t,"aria-label":A(We?"stop_response":"send_message"),disabled:R||!We&&dn,className:qt,children:r.jsx(F.AnimatePresence,{mode:"wait",children:We?r.jsx(oe,{snapExit:!0,distance:0,children:r.jsx(M.SquareIcon,{className:"size-3 fill-current"})},"stop"):!w&&(He||pe)?r.jsx(oe,{snapExit:!0,distance:0,children:r.jsx(M.CircleDashed,{className:"size-4 animate-spin animate-iteration-infinite"})},"loading"):r.jsx(oe,{snapExit:!0,distance:0,children:r.jsx(M.ArrowUpIcon,{className:"size-4"})},"send")})})})]})]})]})]})]})}const Ih=1500;function zh(e){const t=e.flatMap(n=>{var s;const o=(s=n.note)==null?void 0:s.trim();return o?[o]:[]});return t.length>0?t.join(`
|
|
129
|
+
`):null}function _s(){const{widgetCtx:e}=C.useWidget(),{router:t}=C.useConfig(),{canCreateNewSession:n}=C.useSessions(),{toSessionsScreen:o}=C.useWidgetRouter(),{t:s}=G();return r.jsx(r.Fragment,{children:n||t!=null&&t.chatScreenOnly?r.jsx(X,{onClick:e.resetChat,className:"rounded-2xl w-full",children:s("new_conversation")}):r.jsx(X,{onClick:o,className:"rounded-2xl w-full",children:s("back_to_conversations")})})}function Mh(){const{t:e}=G(),t=C.useCsat(),n=C.useCsat("nps"),o=C.useCsat("ces"),s=t.isCsatRequested||n.isCsatRequested||o.isCsatRequested,a=!s&&(t.isCsatSubmitted||n.isCsatSubmitted||o.isCsatSubmitted);return r.jsx("div",{className:"p-2",children:r.jsx("div",{className:"p-2 bg-muted rounded-[var(--opencx-inset-radius)]",children:r.jsx(F.AnimatePresence,{mode:"wait",children:s||a?r.jsxs(_e,{children:[r.jsx(Qn,{}),r.jsx(Qn,{surveyType:"nps"}),r.jsx(Qn,{surveyType:"ces"}),r.jsx(F.AnimatePresence,{mode:"wait",children:a&&r.jsx(_e,{children:r.jsx(_s,{})},"new-conv-or-back-to-convs-button")})]},"csat"):r.jsxs(_e,{children:[r.jsxs("div",{className:"ps-2 flex items-center gap-1 pb-2",children:[r.jsx(M.CircleCheckIcon,{className:"size-4 text-emerald-600"}),r.jsx("h2",{className:"text-sm font-medium",children:e("your_issue_has_been_resolved")})]}),r.jsx(_s,{})]},"session-closed")})})})}function Rh(){var y,w;const{initialQuestions:e,initialQuestionsPosition:t,stickyQuestions:n,thisWasHelpfulOrNot:o}=C.useConfig(),{sessionState:s}=C.useSessions(),{messagesState:a}=C.useMessages(),{isStreaming:i,pendingClarification:c,pendingConnection:d,pendingPageAction:l}=C.useAgentChatUi(),{text:m}=C.useComposerDraft(),p=a.messages.length===0,h=Oi(),f=Tr({isStreaming:i,messages:a.messages,session:s.session}),x=a.lastAIResMightSolveUserIssue&&(o==null?void 0:o.enabled)!==!1,g=Qp({stickyQuestions:n,messages:a.messages,isHandedOff:!!((y=s.session)!=null&&y.isHandedOff),isStreaming:i,isTyping:m.trim().length>0,otherSuggestionsShowing:x||f||c!==null||d!==null||l!==null});return r.jsx("footer",{children:r.jsx(F.AnimatePresence,{mode:"wait",children:s.session&&!((w=s.session)!=null&&w.isOpened)?r.jsxs(_e,{children:[r.jsx(Mh,{}),r.jsx(Ir,{})]},"session-closed"):r.jsxs(_e,{children:[x&&r.jsx(nm,{}),p&&e&&t!=="below-initial-messages"&&r.jsx("div",{className:z("flex items-center flex-row justify-end gap-2 flex-wrap px-2",h&&"pb-4"),children:e==null?void 0:e.map((j,b)=>r.jsx(Yt,{suggestion:j},`${j}-${b}`))}),g.length>0&&r.jsx("div",{className:"flex items-center flex-row justify-end gap-2 flex-wrap px-2",children:g.map((j,b)=>r.jsx(Yt,{suggestion:j},`${j}-${b}`))}),!h&&!f&&r.jsx(Qi,{}),r.jsx(Ir,{})]},"chat-input")})})}function Ph(){var j;const{messagesState:{messages:e,isAgentTyping:t}}=C.useMessages(),{isAwaitingBotReply:n}=C.useIsAwaitingBotReply(),{componentStore:o}=C.useWidget(),s=C.useBot(),a=u.useMemo(()=>vi(e),[e]),{threadCalls:i}=Ot(),c=u.useMemo(()=>{const b=[...i],_=[];a.forEach((v,k)=>{const N=v[0];if(N){for(const R of Ri(b,Mi(N)))_.push(r.jsx(_n,{call:R},`voice-call-${R.id}`));_.push(r.jsx(Ar,{groups:[v],pendingReply:n&&k===a.length-1},N.id))}});for(const v of b)_.push(r.jsx(_n,{call:v},`voice-call-${v.id}`));return _},[a,i,n]),d=e.at(-1),l=d==null?void 0:d.id,m=d==null?void 0:d.type,p=u.useRef(l),[h,f]=u.useState(!1),x=n&&!h;u.useEffect(()=>{const b=p.current!==l;if(p.current=l,!n||m!=="AI"){f(!1);return}if(!b)return;f(!0);const _=setTimeout(()=>f(!1),600);return()=>clearTimeout(_)},[n,l,m]);const g=o.getComponent("loading"),y=u.useRef(null);function w(){setTimeout(()=>{const b=y.current;b&&(b.scrollTop=b.scrollHeight)},0)}return u.useEffect(()=>{w()},[e,x,t,i]),r.jsxs("div",{...L("chat/msgs/root"),ref:y,className:"max-h-full scroll-smooth relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[r.jsx(Ci,{}),r.jsx(yi,{}),r.jsx(Pi,{}),c,x&&g&&r.jsx(g,{agent:s}),t&&!x&&g&&r.jsx(g,{agent:(j=e.findLast(b=>b.type==="AGENT"))==null?void 0:j.agent}),r.jsx(wi,{}),r.jsx(bi,{})]})}function Oh(){const{messagesState:{isInitialFetchLoading:e}}=C.useMessages(),{widgetCtx:t}=C.useWidget(),n=t.streaming,{sessionState:{session:o}}=C.useSessions(),{isCanvasOpen:s}=np(),{theme:a}=me();Pt({width:s?a.screens.chat.withCanvas.width:a.screens.chat.width,height:s?a.screens.chat.withCanvas.height:a.screens.chat.height});const i=u.useRef((o==null?void 0:o.id)||"chat").current;return r.jsx("div",{...L("chat/root"),className:z("flex flex-col overflow-hidden"),style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:r.jsxs("div",{className:"relative size-full justify-between flex flex-col",children:[r.jsx(mi,{}),r.jsx(F.AnimatePresence,{mode:"wait",children:e?r.jsx(oe,{className:"flex flex-col items-center justify-center w-full flex-1",children:r.jsx(hi,{})},"loading"):r.jsxs(oe,{className:"flex items-start h-full flex-1 overflow-auto",snapExit:!0,children:[r.jsxs("div",{...L("chat/main/root"),className:z("flex flex-col h-full overflow-auto transition-all",s?"w-2/5":"w-full"),style:{transitionTimingFunction:a.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:a.screens.chat.withCanvas.transitionDuration},children:[n?r.jsx(Kp,{}):r.jsx(Ph,{}),r.jsx(Rh,{})]}),r.jsx("div",{...L("chat/canvas/root"),className:z("h-full overflow-auto transition-all",s?"w-3/5":"w-0"),style:{transitionTimingFunction:a.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:a.screens.chat.withCanvas.transitionDuration},children:r.jsx(Zp,{})})]},i)})]})})}const Vt=ot.forwardRef(({className:e,type:t,...n},o)=>{const{isSmallScreen:s}=je();return r.jsx("input",{ref:o,type:t,className:z(s?"text-[16px]":"text-sm","flex w-full rounded-xl p-2 ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-primary-foreground placeholder:text-muted-foreground/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition","rounded-2xl px-4","border shadow-sm",e),...n})});Vt.displayName="Input";function Lh({className:e}){return r.jsx("svg",{width:"26",height:"32",viewBox:"0 0 26 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:z("text-primary-foreground",e),children:r.jsx("path",{d:"M1.34103 25.6132H5.44245C5.74203 25.6228 6.02673 25.7462 6.23867 25.9582C6.45062 26.1703 6.5739 26.4551 6.58348 26.7548V30.8584C6.59305 31.1581 6.71634 31.443 6.92828 31.655C7.14023 31.8671 7.42492 31.9904 7.7245 32H18.2894C18.589 31.9904 18.8737 31.8671 19.0856 31.655C19.2976 31.443 19.4209 31.1581 19.4304 30.8584V26.7548C19.4401 26.4545 19.5638 26.1692 19.7765 25.957C19.9892 25.7449 20.2748 25.6219 20.5749 25.6132H24.659C24.9586 25.6036 25.2433 25.4803 25.4552 25.2682C25.6671 25.0562 25.7904 24.7713 25.8 24.4716V7.52839C25.7904 7.22865 25.6671 6.94381 25.4552 6.73176C25.2433 6.5197 24.9586 6.39635 24.659 6.38677H20.561C20.2603 6.37802 19.9742 6.25457 19.7614 6.04169C19.5487 5.82881 19.4253 5.54261 19.4165 5.24168V1.14161C19.4072 0.84419 19.2858 0.561291 19.0768 0.349589C18.8678 0.137887 18.5865 0.0130193 18.2894 0L7.7245 0C7.42492 0.00957792 7.14023 0.132929 6.92828 0.344983C6.71634 0.557036 6.59305 0.841878 6.58348 1.14161V5.24168C6.57477 5.54203 6.45187 5.82773 6.23983 6.04052C6.0278 6.25331 5.74262 6.37715 5.44245 6.38677H1.34103C1.04144 6.39635 0.756749 6.5197 0.544805 6.73176C0.332861 6.94381 0.209574 7.22865 0.200001 7.52839V24.4716C0.209574 24.7713 0.332861 25.0562 0.544805 25.2682C0.756749 25.4803 1.04144 25.6036 1.34103 25.6132ZM6.58348 24.4716V7.52839C6.59305 7.22865 6.71634 6.94381 6.92828 6.73176C7.14023 6.5197 7.42492 6.39635 7.7245 6.38677H18.2894C18.589 6.39635 18.8737 6.5197 19.0856 6.73176C19.2976 6.94381 19.4209 7.22865 19.4304 7.52839V24.4716C19.4209 24.7713 19.2976 25.0562 19.0856 25.2682C18.8737 25.4803 18.589 25.6036 18.2894 25.6132H7.7245C7.42492 25.6036 7.14023 25.4803 6.92828 25.2682C6.71634 25.0562 6.59305 24.7713 6.58348 24.4716Z",fill:"currentColor"})})}function ln({className:e}){const{token:t}=C.useConfig();return r.jsx("div",{className:z("flex items-center justify-center gap-2 p-2 pt-0",e),children:r.jsx(Oe,{children:r.jsxs("a",{dir:"ltr",href:`https://open.cx/?ref=${t}`,target:"_blank",rel:"noreferrer",className:z("text-[10px] flex items-center","text-muted-foreground/70 [&_svg]:text-muted-foreground/70","hover:text-primary [&_svg]:hover:text-primary"),children:[r.jsx("span",{children:"Powered by"}),r.jsx("span",{children:" "}),r.jsxs("span",{className:"flex items-center gap-[1px]",children:[r.jsx("span",{children:r.jsx(Lh,{className:"size-3 inline-block"})}),r.jsx("span",{className:"font-semibold",children:"open"})]})]})})})}function pt({className:e,...t}){return r.jsx("div",{className:z("animate-pulse rounded-md bg-secondary",e),...t})}const $h=3;function ec(e,t){for(const n of e){if(n.id===t)return n;const o=ec(n.topics,t);if(o)return o}}function Dh({articleId:e,siblings:t,popular:n}){const o=new Set([e]),s=[];for(const{id:a,title:i,slug:c}of[...t,...n])if(!o.has(a)&&(o.add(a),s.push({id:a,title:i,slug:c}),s.length===$h))break;return s}const jo="w-full justify-between gap-3 rounded-[19px] px-3 py-2.5 text-start whitespace-normal";function bt({title:e,children:t,component:n}){return r.jsxs("section",{...L(n),className:"rounded-3xl border bg-background p-1",children:[e&&r.jsx("p",{className:"px-3 pt-2.5 pb-1 text-xs text-muted-foreground/75 uppercase font-semibold tracking-tight",children:e}),r.jsx("div",{className:"flex flex-col",children:t})]})}function tc({topic:e,onOpen:t}){return r.jsxs(X,{...L("home/topic_row"),variant:"ghost",wobble:!1,size:"free",className:jo,onClick:()=>t(e.id),children:[r.jsx(M.FolderIcon,{className:"size-4 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium leading-snug [overflow-wrap:anywhere]",children:e.name}),r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground tabular-nums",children:e.article_count}),r.jsx(M.ChevronRightIcon,{className:"size-4 shrink-0 text-muted-foreground rtl:-scale-100"})]})}function nc({article:e,onOpen:t}){return r.jsxs(X,{...L("home/article_link"),variant:"ghost",wobble:!1,size:"free",className:jo,onClick:()=>t(e.slug),children:[r.jsx("span",{className:"min-w-0 flex-1 text-sm leading-snug [overflow-wrap:anywhere]",children:e.title}),r.jsx(M.ChevronRightIcon,{className:"size-4 shrink-0 text-muted-foreground rtl:-scale-100"})]})}function rc({component:e,onBack:t,children:n}){const{setIsOpen:o}=C.useWidgetTrigger(),{isSmallScreen:s}=je(),{t:a}=G();return r.jsxs("header",{...L(e),className:"shrink-0 flex items-center gap-2 px-4 py-2 border-b",children:[r.jsx(X,{variant:"ghost",size:"fit",className:"shrink-0 rounded-full","aria-label":a("article_back"),onClick:t,children:r.jsx(M.ChevronLeftIcon,{className:"size-4 rtl:-scale-100"})}),n,s&&r.jsx(X,{variant:"ghost",size:"fit",className:"shrink-0 rounded-full",onClick:()=>o(!1),children:r.jsx(M.XIcon,{className:"size-4"})})]})}function In(){return r.jsxs("div",{className:"px-3 py-2.5 space-y-1.5",children:[r.jsx(pt,{className:"h-4 w-2/3"}),r.jsx(pt,{className:"h-3 w-full"})]})}function oc({onClick:e}){const{t}=G();return r.jsx(X,{...L("home/show_more"),variant:"ghost",wobble:!1,size:"free",className:"w-full justify-center rounded-[19px] px-3 py-2.5 text-sm font-medium text-primary",onClick:e,children:t("home_show_more")})}const Es=99,Fh=e=>e?16:9,sc=(e,t)=>e/2*(1-Math.SQRT1_2)-Fh(t)/2;function ac({count:e,showCount:t,component:n="trigger/unread",style:o}){return e<=0?null:r.jsx(F.motion.span,{...L(n),"data-unread-look":t?"count":"dot","aria-hidden":!0,initial:{scale:0},animate:{scale:1},transition:ge,style:o,children:t?e>Es?`${Es}+`:e:null})}function Hh(){return r.jsx("style",{children:`
|
|
130
130
|
[data-component='trigger/unread'] {
|
|
131
131
|
position: absolute;
|
|
132
132
|
z-index: 1;
|
|
@@ -141,10 +141,10 @@ ${o.note}`:o.note)}return n}const fs=20,hm=4e3;function Mr(e,t){for(let n=e.next
|
|
|
141
141
|
}
|
|
142
142
|
[data-unread-look='dot'] { width: 9px; height: 9px; }
|
|
143
143
|
[data-unread-look='count'] { min-width: 16px; height: 16px; padding: 0 4px; }
|
|
144
|
-
`})}function Dn(){return C.useConfig().unreadIndicator??"dot"}function So({count:e,indicator:t,component:n,style:o}){const s=Dn();return s===!1?null:r.jsx(ic,{count:e,showCount:(t??s)==="count",component:n,style:o})}function Fn(e){const t=Dn(),{t:n}=G();return t===!1||e<=0?null:n("unread_sessions",{count:e})}const Xh={duration:.3,ease:$e};function Hn({onArticles:e}={}){const{widgetCtx:t}=C.useWidget(),{routerState:{screen:n},toHomeScreen:o,toSessionsScreen:s}=C.useWidgetRouter(),{count:a}=C.useUnread(),i=Fn(a),{t:c}=G();if(!t.home)return null;const d=[{key:"home",label:c("home_tab_articles"),Icon:M.BookOpenIcon,onClick:o,onReselect:e,unread:0},{key:"sessions",label:c("home_tab_chat"),Icon:M.MessageCircleIcon,onClick:s,onReselect:void 0,unread:a}];return r.jsx("nav",{...L("home/tabs"),className:"px-3 py-2",children:r.jsx("div",{role:"tablist",className:"grid grid-cols-2 gap-0.5 rounded-full border bg-secondary p-0.5",children:d.map(({key:l,label:m,Icon:p,onClick:h,onReselect:f,unread:x})=>{const g=n===l;return u.createElement(X,{...L("home/tab"),key:l,role:"tab","aria-selected":g,variant:"ghost",size:"free",className:z("relative h-9 min-w-0 rounded-full px-3 text-sm font-medium",g?"text-foreground hover:bg-transparent":"z-10 text-muted-foreground"),onClick:g?f:h},g&&r.jsx(F.motion.span,{layoutId:"home-tab-pill",className:"absolute inset-0 rounded-full border border-border bg-background shadow-sm",transition:Xh},"pill"),r.jsxs("span",{className:"relative z-10 flex min-w-0 items-center justify-center gap-1.5",children:[r.jsxs("span",{className:"relative shrink-0",children:[r.jsx(p,{className:"size-4"}),r.jsx(So,{count:x,indicator:"dot",component:"home/tab_unread"})]}),r.jsx("span",{className:"truncate",children:m}),x>0&&i&&r.jsx("span",{className:"sr-only",children:i})]},"label"))})})})}function cc({key:e,fetchPage:t}){const[n,o]=u.useState(null),s=u.useRef(t);u.useEffect(()=>{s.current=t});const a=u.useCallback((p,h)=>{o(f=>({key:p,items:(f==null?void 0:f.key)===p&&h>0?f.items:[],nextOffset:(f==null?void 0:f.key)===p?f.nextOffset:null,fetching:!0,error:void 0})),s.current(h).then(f=>o(x=>(x==null?void 0:x.key)===p?{key:p,items:h===0?f.items:[...x.items,...f.items],nextOffset:f.nextOffset,fetching:!1,error:void 0}:x),f=>o(x=>(x==null?void 0:x.key)===p?{...x,fetching:!1,error:f}:x))},[]);u.useEffect(()=>{e!==null&&a(e,0)},[e,a]);const i=e!==null&&(n==null?void 0:n.key)===e?n:null,c=e!==null&&(!i||i.fetching),d=(i==null?void 0:i.nextOffset)??null,l=u.useCallback(()=>{e!==null&&d!==null&&!c&&a(e,d)},[e,d,c,a]),m=u.useCallback(()=>{e!==null&&a(e,0)},[e,a]);return{items:(i==null?void 0:i.items)??[],loading:c,error:i==null?void 0:i.error,hasMore:d!==null,loadMore:l,reload:m}}function lc({helpCenterId:e,topicId:t}){const{widgetCtx:n}=C.useWidget(),o=cc({key:t===null?null:`${e}:${t}`,fetchPage:s=>t===null?Promise.resolve({items:[],nextOffset:null}):n.api.listTopicArticles({helpCenterId:e,topicId:t,offset:s}).then(a=>({items:a.articles,nextOffset:a.next_offset}))});return u.useEffect(()=>{o.error&&K.log.error("home: could not load the topic articles",{_e:o.error,helpCenterId:e,topicId:t})},[o.error,e,t]),o}const Gh=["[--tw-prose-body:hsl(var(--opencx-foreground))]","[--tw-prose-headings:hsl(var(--opencx-foreground))]","[--tw-prose-bold:hsl(var(--opencx-foreground))]","[--tw-prose-links:hsl(var(--opencx-primary))]","[--tw-prose-code:hsl(var(--opencx-foreground))]","[--tw-prose-counters:hsl(var(--opencx-muted-foreground))]","[--tw-prose-bullets:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quotes:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quote-borders:hsl(var(--opencx-border))]","[--tw-prose-hr:hsl(var(--opencx-border))]","[--tw-prose-th-borders:hsl(var(--opencx-border))]","[--tw-prose-td-borders:hsl(var(--opencx-border))]","[--tw-prose-pre-bg:hsl(var(--opencx-muted))]","[--tw-prose-pre-code:hsl(var(--opencx-foreground))]"].join(" ");function Kh({helpCenterId:e,slug:t,popular:n,onBack:o,onHome:s,onOpenArticle:a,onOpenTopicPath:i,onRedirect:c}){var j,b,_;const{widgetCtx:d}=C.useWidget(),{t:l}=G(),{theme:m}=me();Pt({width:m.screens.chat.width,height:m.screens.chat.height});const p=Rn.useAsync(()=>d.api.getHelpCenterArticle({helpCenterId:e,slug:t}),[d,e,t]),h=(j=p.value)==null?void 0:j.article,f=u.useMemo(()=>({kind:"article",article:h?{slug:t,id:h.id,title:h.title}:{slug:t}}),[t,h]);ro(f);const x=h?null:(b=p.value)==null?void 0:b.redirect_slug;u.useEffect(()=>{x&&c(x)},[x,c]),u.useEffect(()=>{p.error?K.log.error("home: could not load the article",{_e:p.error,helpCenterId:e,slug:t}):p.value&&!p.value.article&&!p.value.redirect_slug&&K.log.warn("home: article not found",{helpCenterId:e,slug:t})},[p.error,p.value,e,t]);const g=(h==null?void 0:h.topic_path)??[],y=lc({helpCenterId:e,topicId:((_=g.at(-1))==null?void 0:_.id)??null}),w=h?qh({articleId:h.id,siblings:y.items,popular:n}):[];return r.jsxs("div",{...L("article/root"),className:"flex flex-col bg-background",style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:[r.jsx(oc,{component:"article/header",onBack:o,children:r.jsx("nav",{...L("article/trail"),className:"min-w-0 flex-1 flex items-center gap-0.5 text-sm",children:g.map((v,k)=>r.jsxs(u.Fragment,{children:[k>0&&r.jsx(M.ChevronRightIcon,{className:"size-3 shrink-0 text-muted-foreground rtl:-scale-100"}),r.jsx(X,{variant:"ghost",size:"free",wobble:!1,className:z("min-w-0 rounded-full px-1.5 py-1",k===g.length-1?"font-semibold":"shrink-[2] text-muted-foreground"),onClick:()=>i(g.slice(0,k+1).map(N=>N.id)),children:r.jsx("span",{className:"truncate",children:v.name})})]},v.id))})}),r.jsx("article",{...L("article/content"),className:"flex-1 overflow-y-auto px-5 py-4",children:p.loading||x?r.jsxs("div",{className:"space-y-3",children:[r.jsx(pt,{className:"h-6 w-3/4"}),r.jsx(pt,{className:"h-3 w-1/4"}),r.jsx(pt,{className:"h-4 w-full"}),r.jsx(pt,{className:"h-4 w-5/6"})]}):h?r.jsxs(r.Fragment,{children:[r.jsx("h1",{className:"text-xl font-semibold tracking-tight leading-snug",children:h.title}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:l("article_reading_minutes",{count:h.reading_minutes})}),h.content_html&&r.jsx("div",{className:z("mt-4 prose prose-sm max-w-none break-words [word-break:break-word]","prose-table:block prose-table:overflow-x-auto prose-table:[word-break:normal] prose-table:[overflow-wrap:normal]","prose-a:underline prose-img:rounded-xl",Gh),children:r.jsx(Ru,{openArticle:a,children:h.content_html})}),w.length>0&&r.jsx("div",{...L("article/suggested"),className:"mt-6 -mx-2",children:r.jsx(bt,{component:"home/articles",title:l("home_suggested_articles"),children:w.map(v=>r.jsx(rc,{article:v,onOpen:a},v.id))})})]}):r.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:l("home_load_failed")})}),r.jsxs("footer",{className:"shrink-0 pt-1",children:[r.jsx(Hn,{onArticles:s}),r.jsx(ln,{})]})]})}function Zh({helpCenterId:e,topic:t,onBack:n,onHome:o,onOpenTopic:s,onOpenArticle:a}){const{theme:i}=me(),{t:c}=G();Pt({width:i.screens.sessions.width,height:i.screens.sessions.height});const d=u.useMemo(()=>({kind:"topic",topic:{id:t.id,name:t.name}}),[t.id,t.name]);ro(d);const l=t.topics.filter(p=>p.article_count>0),m=lc({helpCenterId:e,topicId:t.id});return r.jsxs("div",{...L("topic/root"),className:"flex flex-col overflow-hidden bg-background",style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:[r.jsx(oc,{component:"topic/header",onBack:n,children:r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:t.name})}),r.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto flex flex-col gap-3 p-3",children:[t.description&&r.jsx("p",{className:"px-2 text-sm text-muted-foreground [overflow-wrap:anywhere]",children:t.description}),l.length>0&&r.jsx(bt,{component:"home/topics",title:c("home_topics"),children:l.map(p=>r.jsx(nc,{topic:p,onOpen:s},p.id))}),m.error&&m.items.length===0?r.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:c("home_load_failed")}):(m.loading||m.items.length>0)&&r.jsxs(bt,{component:"home/articles",title:c("home_tab_articles"),children:[m.items.map(p=>r.jsx(rc,{article:p,onOpen:a},p.id)),m.loading?r.jsx(In,{}):m.hasMore?r.jsx(sc,{onClick:m.loadMore}):null]})]}),r.jsxs("footer",{className:"shrink-0 pt-1",children:[r.jsx(Hn,{onArticles:o}),r.jsx(ln,{})]})]})}const No=u.createContext({data:void 0,loading:!1,failed:!1,request:()=>{}});function Jh({children:e}){var c;const{widgetCtx:t}=C.useWidget(),n=(c=t.home)==null?void 0:c.helpCenterId,[o,s]=u.useState(!1),a=u.useCallback(()=>s(!0),[]),i=Rn.useAsync(async()=>o&&n?t.api.listHomeArticles({helpCenterId:n}):void 0,[t,n,o]);return u.useEffect(()=>{i.error&&K.log.error("home: could not load the help center",{_e:i.error,helpCenterId:n})},[i.error,n]),r.jsx(No.Provider,{value:{data:i.value,loading:i.loading||!o&&!!n,failed:!!i.error,request:a},children:e})}function Qh(){const e=u.useContext(No),{request:t}=e;return u.useEffect(t,[t]),e}const ef=400,tf=6;function nf(e){const[t,n]=u.useState(""),[o,s]=u.useState(""),[a,i]=u.useState(0),c=p=>p.length>=tf||e.includes(p),d=p=>{const h=p.trim();s(c(h)?h:"")};return Rn.useDebounce(()=>d(t),ef,[t]),{query:t,setQuery:n,search:o,searchNow:p=>{n(p),d(p),i(h=>h+1)},retry:a,reset:()=>{n(""),s("")}}}const dc=u.createContext(null);function rf({children:e}){var l;const{widgetCtx:t}=C.useWidget(),n=((l=t.home)==null?void 0:l.helpCenterId)??null,{data:o}=u.useContext(No),[s,a]=u.useState([]),i=nf((o==null?void 0:o.popularSearches)??[]),[c,d]=u.useState(n);return c!==n&&(d(n),a([]),i.reset()),r.jsx(dc.Provider,{value:{stack:s,setStack:a,homeSearch:i},children:e})}function of(){const e=u.useContext(dc);if(!e)throw new Error("useHomeState must be used inside HomeStateProvider");return e}const sf=24,af={initial:{opacity:1,x:0}},uc=u.createContext({direction:null,settle:()=>{}}),$r={home:0,sessions:1};function Ts(e){return e in $r}function cf({from:e,to:t,rtl:n}){return!Ts(e)||!Ts(t)||e===t?null:$r[t]>$r[e]!==n?"left":"right"}function pc({children:e,...t}){const{direction:n,settle:o}=u.useContext(uc);return u.useEffect(()=>{n&&o()},[n,o]),r.jsx(oe,{...t,fadeIn:n??"right",distance:sf,overrides:n?{}:af,children:e})}const lf=200,df=3,uf=3500,pf={kind:"main"},mf={duration:.55,ease:$e};function hf(){var y,w,j;const{widgetCtx:e}=C.useWidget(),t=(y=e.home)==null?void 0:y.helpCenterId,{stack:n,setStack:o,homeSearch:s}=of(),a=Qh(),i=u.useCallback(b=>o(_=>[..._.slice(0,-1),{kind:"article",slug:b}]),[o]);if(!t)return null;const c=b=>o(_=>[..._,b]),d=()=>o(b=>b.slice(0,-1)),l=()=>o([]),m=b=>c({kind:"article",slug:b}),p=b=>c({kind:"topic",topicId:b}),h=b=>o(b.map(_=>({kind:"topic",topicId:_}))),f=n[n.length-1],x=((w=a.data)==null?void 0:w.topics)??[],g=(f==null?void 0:f.kind)==="topic"?tc(x,f.topicId):null;return r.jsx(F.AnimatePresence,{mode:"wait",initial:!1,children:(f==null?void 0:f.kind)==="article"?r.jsx(oe,{fadeIn:"left",snapExit:!0,className:"size-full",children:r.jsx(Kh,{helpCenterId:t,slug:f.slug,popular:((j=a.data)==null?void 0:j.articles)??[],onBack:d,onHome:l,onOpenArticle:m,onRedirect:i,onOpenTopicPath:h})},`${n.length}:${f.slug}`):g?r.jsx(oe,{fadeIn:"left",snapExit:!0,className:"size-full",children:r.jsx(Zh,{helpCenterId:t,topic:g,onBack:d,onHome:l,onOpenTopic:p,onOpenArticle:m})},`${n.length}:${g.id}`):r.jsx(oe,{fadeIn:"right",snapExit:!0,className:"size-full",children:r.jsx(ff,{helpCenterId:t,data:a.data,loading:a.loading,failed:a.failed,homeSearch:s,onOpenArticle:m,onOpenTopic:p})},"home")})}function ff({helpCenterId:e,data:t,loading:n,failed:o,homeSearch:{query:s,setQuery:a,search:i,searchNow:c,retry:d},onOpenArticle:l,onOpenTopic:m}){const{theme:p}=me(),{t:h}=G();ro(pf);const f=(t==null?void 0:t.popularSearches)??[],x=((t==null?void 0:t.topics)??[]).filter(g=>g.article_count>0);return Pt({width:p.screens.sessions.width,height:p.screens.sessions.height}),r.jsxs("div",{...L("home/root"),className:"flex flex-col overflow-hidden bg-background",style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:[r.jsxs(pc,{className:"flex-1 min-h-0 flex flex-col",children:[r.jsx(gf,{}),r.jsx("div",{className:"shrink-0 px-3 -mt-6 relative z-10",children:r.jsx(xf,{value:s,hints:f,onChange:a,onSubmit:()=>c(s)})}),r.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto flex flex-col gap-3 p-3",children:i?r.jsx(yf,{helpCenterId:e,search:i,retry:d,onOpenArticle:l}):r.jsxs(r.Fragment,{children:[r.jsx(wf,{searches:f,onPick:c}),r.jsx(vf,{articles:t==null?void 0:t.articles,loading:n,failed:o,onOpenArticle:l}),x.length>0&&r.jsx(bt,{component:"home/topics",title:h("home_topics"),children:x.map(g=>r.jsx(nc,{topic:g,onOpen:m},g.id))})]})})]}),r.jsxs("footer",{className:"shrink-0 pt-1",children:[r.jsx(Hn,{}),r.jsx(ln,{})]})]})}function gf(){var i,c;const{widgetCtx:{org:e}}=C.useWidget(),{assets:t,textContent:n}=C.useConfig(),{setIsOpen:o}=C.useWidgetTrigger(),{isSmallScreen:s}=je(),{t:a}=G();return r.jsxs("header",{...L("home/header"),className:z("shrink-0 px-5 pt-6 pb-14 space-y-4 text-primary-foreground","bg-[radial-gradient(ellipse_at_top_left,hsl(var(--opencx-primary)),transparent),radial-gradient(ellipse_at_top_right,hsl(var(--opencx-primary)),transparent)]"),children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 min-h-8",children:[t!=null&&t.organizationLogo?r.jsx("img",{src:t.organizationLogo,alt:e.name,className:"h-8 w-auto object-contain"}):r.jsx("h2",{className:"font-bold text-sm",children:e.name}),s&&r.jsx(X,{size:"selfless",onClick:()=>o(!1),children:r.jsx(M.XIcon,{className:"size-4"})})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("h1",{className:"text-2xl font-semibold tracking-tight leading-tight",children:((i=n==null?void 0:n.homeScreen)==null?void 0:i.title)||a("home_title")}),r.jsx("p",{className:"text-sm opacity-90",children:((c=n==null?void 0:n.homeScreen)==null?void 0:c.description)||a("home_description")})]})]})}function xf({value:e,hints:t,onChange:n,onSubmit:o}){const{t:s}=G();return r.jsxs("form",{...L("home/search"),role:"search",className:"relative block",onSubmit:a=>{a.preventDefault(),o()},children:[r.jsx(M.SearchIcon,{className:"pointer-events-none absolute start-4 top-1/2 -translate-y-1/2 size-4 text-muted-foreground"}),r.jsx(Vt,{type:"text",enterKeyHint:"search",maxLength:lf,value:e,onChange:a=>n(a.target.value),placeholder:t.length>0?void 0:s("home_search_placeholder"),"aria-label":s("home_search_placeholder"),className:"h-12 ps-10 rounded-3xl bg-background"}),t.length>0&&!e&&r.jsx(bf,{hints:t})]})}function bf({hints:e}){const t=F.useReducedMotion(),[n,o]=u.useState(0);u.useEffect(()=>{if(e.length<2||t)return;const a=setInterval(()=>o(i=>(i+1)%e.length),uf);return()=>clearInterval(a)},[e.length,t]);const s=e[n%e.length];return r.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute top-1/2 start-10 end-4 h-6 -translate-y-1/2 overflow-hidden text-muted-foreground/75",children:r.jsx(F.AnimatePresence,{initial:!1,children:r.jsx(F.motion.span,{className:"absolute inset-0 truncate leading-6",initial:{y:"70%",opacity:0,filter:"blur(2px)"},animate:{y:0,opacity:1,filter:"blur(0px)"},exit:{y:"-70%",opacity:0,filter:"blur(2px)"},transition:mf,children:s},s)})})}function wf({searches:e,onPick:t}){return e.length===0?null:r.jsx("div",{...L("home/popular_searches"),className:"flex flex-wrap gap-1.5",children:e.map(n=>r.jsx(X,{variant:"outline",size:"free",title:n,className:"max-w-full rounded-full bg-background px-3 py-1 text-xs font-normal",onClick:()=>t(n),children:r.jsx("span",{className:"min-w-0 truncate",children:n})},n))})}function vf({articles:e,loading:t,failed:n,onOpenArticle:o}){const{t:s}=G();return n?r.jsx(Dr,{children:s("home_load_failed")}):!t&&(e==null?void 0:e.length)===0?null:r.jsx(bt,{component:"home/articles",title:s("home_suggested_articles"),children:t||!e?Array.from({length:df},(a,i)=>r.jsx(In,{},i)):e.map(a=>r.jsx(mc,{article:a,onOpen:o},a.id))})}function yf({helpCenterId:e,search:t,retry:n,onOpenArticle:o}){const{widgetCtx:s}=C.useWidget(),{t:a}=G(),i=cc({key:`${e}:${t}`,fetchPage:p=>s.api.searchHelpCenter({helpCenterId:e,query:t,offset:p}).then(h=>({items:h.results,nextOffset:h.next_offset}))}),c=i.error instanceof K.HelpCenterSearchError&&i.error.busy;u.useEffect(()=>{i.error&&!c&&K.log.error("home: help center search failed",{_e:i.error,helpCenterId:e})},[i.error,c,e]);const d=u.useRef(n),{error:l,reload:m}=i;return u.useEffect(()=>{n!==d.current&&(d.current=n,l&&m())},[n,l,m]),i.items.length===0?i.error?r.jsx(Dr,{onRetry:i.reload,children:a(c?"home_search_busy":"home_load_failed")}):i.loading?r.jsx(bt,{component:"home/articles",children:r.jsx(In,{})}):r.jsx(Dr,{children:a("home_search_no_results")}):r.jsxs(bt,{component:"home/articles",children:[i.items.map(p=>r.jsx(mc,{article:p,topicName:p.topic.name,onOpen:o},p.id)),i.loading?r.jsx(In,{}):i.hasMore?r.jsx(sc,{onClick:i.loadMore}):null]})}function mc({article:e,topicName:t,onOpen:n}){return r.jsxs(X,{...L("home/article_card"),variant:"ghost",wobble:!1,size:"free",className:Co,onClick:()=>n(e.slug),children:[r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-sm font-medium leading-snug [overflow-wrap:anywhere]",children:e.title}),t&&r.jsxs("span",{className:"mt-0.5 flex items-center gap-1 text-xs text-muted-foreground",children:[r.jsx(M.FolderIcon,{className:"size-3 shrink-0"}),r.jsx("span",{className:"truncate",children:t})]}),e.excerpt&&r.jsx("span",{className:z("mt-0.5 text-xs text-muted-foreground [overflow-wrap:anywhere]",t?"line-clamp-2":"line-clamp-1"),children:e.excerpt})]}),r.jsx(M.ChevronRightIcon,{className:"size-4 shrink-0 text-muted-foreground rtl:-scale-100"})]})}function Dr({children:e,onRetry:t}){const{t:n}=G();return r.jsxs("div",{className:"rounded-3xl border bg-background px-4 py-6 text-center text-sm text-muted-foreground",children:[r.jsx("p",{children:e}),t&&r.jsx(X,{variant:"outline",size:"free",className:"mt-3 rounded-full bg-background px-3 py-1 text-xs",onClick:t,children:n("turn_failed_retry")})]})}function kf({children:e}){var j,b,_;const{widgetCtx:t,config:n}=C.useWidget(),[o,s]=u.useState(!1),[a,i]=u.useState(null),[c,d]=u.useState(""),[l,m]=u.useState([]),[p,h]=u.useState([]),[f,x]=u.useState(!1),[g,y]=u.useState("");u.useEffect(()=>{var k;let v=!1;if(((k=n.capabilities)==null?void 0:k.connections)===!0)return Promise.all([t.api.listConnections(),t.api.listApprovalPreferences()]).then(([N,R])=>{v||(m(N.filter(T=>T.status!=="not_connected")),h(R))}).catch(()=>{}),()=>{v=!0}},[t,(j=n.capabilities)==null?void 0:j.connections]);const w=async v=>{x(!0),y("");try{await v()}catch{y("Could not save the change. Try again.")}finally{x(!1)}};return!o||((b=n.capabilities)==null?void 0:b.connections)!==!0?r.jsxs(r.Fragment,{children:[r.jsx(hi,{}),((_=n.capabilities)==null?void 0:_.connections)===!0&&l.length>0&&r.jsxs(X,{variant:"ghost",className:"mx-3 my-1 h-9 justify-start gap-2 text-sm",onClick:()=>s(!0),children:[r.jsx(M.Unplug,{className:"size-4"})," Connections"," ",r.jsx(M.ChevronRight,{className:"ml-auto size-4"})]}),e]}):r.jsxs("section",{className:"flex-1 overflow-y-auto px-4 pb-4 pt-3 space-y-5","aria-label":"Connections",children:[r.jsxs("div",{className:"flex h-8 items-center gap-2 pr-16",children:[r.jsx(X,{variant:"ghost",size:"icon",className:"size-7","aria-label":a?"Back to connections":"Back to sessions",onClick:()=>a?i(null):s(!1),children:r.jsx(M.ArrowLeft,{className:"size-4"})}),r.jsx("h2",{className:"text-sm font-medium",children:"Connections"})]}),!l.length&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"No connected services."}),!a&&r.jsxs(r.Fragment,{children:[r.jsx("input",{type:"search","aria-label":"Search connections",placeholder:"Search connections",value:c,onChange:v=>d(v.target.value),className:"h-8 w-full rounded-full border border-foreground/15 bg-transparent px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring"}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("h3",{className:"border-b border-foreground/10 pb-2 text-xs font-medium",children:"Connected services"}),l.filter(v=>v.name.toLowerCase().includes(c.toLowerCase())).map(v=>r.jsxs("button",{type:"button",onClick:()=>i(v.server_id),className:"flex w-full items-center gap-3 rounded-xl px-2 py-3 text-left hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[r.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-xl border border-foreground/10 bg-background p-2",children:r.jsx(En,{})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-sm font-medium",children:v.name}),r.jsx("span",{className:"block text-xs text-muted-foreground",children:v.status==="connected"?"Connected":"Reconnect required"})]}),r.jsx(M.ChevronRight,{className:"size-4 text-muted-foreground"})]},v.server_id)),l.length>0&&!l.some(v=>v.name.toLowerCase().includes(c.toLowerCase()))&&r.jsx("p",{className:"py-3 text-xs text-muted-foreground",children:"No matching connections."})]})]}),l.filter(v=>v.server_id===a).map(v=>r.jsxs("div",{className:"border-b border-foreground/10 pb-5 space-y-3 last:border-0",children:[r.jsx("div",{className:"flex size-12 items-center justify-center rounded-xl border border-foreground/10 bg-background p-3",children:r.jsx(En,{})}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium",children:v.name}),r.jsx("p",{className:"text-xs text-muted-foreground",children:v.status==="connected"?"Connected":"Reconnect required"})]}),r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",disabled:f,onClick:()=>void w(async()=>{await t.api.disconnectConnection(v.server_id),i(null),m(k=>k.filter(N=>N.server_id!==v.server_id)),h(k=>k.filter(N=>N.serverId!==v.server_id))}),children:"Disconnect"})]}),p.some(k=>k.serverId===v.server_id)?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("h3",{className:"text-xs font-medium",children:["Saved approvals (",p.filter(k=>k.serverId===v.server_id).length,")"]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Removing an approval makes the widget ask again next time."}),r.jsx("ul",{className:"max-h-64 overflow-y-auto divide-y divide-foreground/10 rounded-xl border border-foreground/10","aria-label":`${v.name} saved approvals`,children:p.filter(k=>k.serverId===v.server_id).map(k=>r.jsxs("li",{className:"flex items-start gap-3 p-3",children:[r.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[r.jsx("p",{className:"text-xs font-medium break-words",children:k.toolName.replace(/[_-]+/g," ")}),r.jsx("p",{className:"text-xs text-muted-foreground break-words",children:k.message})]}),r.jsx(X,{variant:"secondary",size:"sm",className:"h-7 shrink-0 px-2 text-xs",disabled:f,onClick:()=>void w(async()=>{await t.api.revokeApprovalPreference(k.serverId,k.key),h(N=>N.filter(R=>R.serverId!==k.serverId||R.key!==k.key))}),children:"Remove approval"})]},k.key))})]}):r.jsx("p",{className:"text-xs text-muted-foreground",children:"No saved approvals"})]},v.server_id)),g&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:g})]})}function jf({children:e}){return r.jsx("p",{className:"ps-4 text-xs text-muted-foreground/75 uppercase font-semibold tracking-tight",children:e})}function Is({session:e,className:t}){const{humanAgent:n}=C.useConfig(),o=C.useBot(),{toChatScreen:s}=C.useWidgetRouter(),{isUnread:a}=C.useUnread(),i=Fn(a(e.id)?1:0),c=e.assignee.kind==="human"?(n==null?void 0:n.name)||e.assignee.name||"Support Agent":o.name,d=e.assignee.kind==="human"?(n==null?void 0:n.avatarUrl)||e.assignee.avatarUrl||"":o.avatarUrl||o.avatar||"";return r.jsxs(X,{variant:"ghost",size:"lg",className:z("rounded-full p-2 pe-4 flex text-start justify-between w-full whitespace-normal",t),onClick:()=>s(e.id),children:[r.jsxs("div",{className:"flex-1 flex gap-2 items-center min-w-0",children:[r.jsx(F.AnimatePresence,{mode:"wait",children:r.jsx(oe,{snapExit:!0,children:r.jsxs(oo,{className:"size-10",children:[r.jsx(so,{src:d,alt:"Agent Icon"}),r.jsx(ao,{children:r.jsx(M.UserRoundIcon,{className:"size-4"})})]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx(F.AnimatePresence,{mode:"wait",children:r.jsx(oe,{snapExit:!0,children:c},c)}),r.jsx(F.AnimatePresence,{mode:"wait",children:e.lastMessage?r.jsx(oe,{snapExit:!0,children:r.jsx(ni,{remarkPlugins:[la],rehypePlugins:[pr],className:"line-clamp-1 overflow-hidden text-ellipsis text-xs text-muted-foreground",children:e.lastMessage})},e.lastMessage||"content"):r.jsx(oe,{className:"w-1/2",snapExit:!0,children:r.jsx(pt,{className:"h-4 w-full"})},"skeleton")}),r.jsx(F.AnimatePresence,{mode:"wait",children:e.customStatus&&r.jsx(oe,{className:"mt-1",snapExit:!0,children:r.jsx(Ci,{customStatus:e.customStatus})},e.customStatus.id)})]})]}),i&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"sr-only",children:i}),r.jsx(So,{count:1,indicator:"dot",component:"sessions/unread"})]}),r.jsx(M.ChevronRightIcon,{className:"size-4 text-muted-foreground shrink-0 rtl:-scale-100"})]})}function Cf(){const{t:e}=G(),{toChatScreen:t}=C.useWidgetRouter(),{sessionsState:{data:n,isInitialFetchLoading:o},openSessions:s,closedSessions:a,canCreateNewSession:i}=C.useSessions();return r.jsx("div",{...L("sessions/list"),className:"flex-1 flex flex-col overflow-scroll py-2 px-2",children:r.jsx(F.AnimatePresence,{mode:"wait",children:o?r.jsx(oe,{className:"flex-1 flex items-center justify-center",children:r.jsx(fi,{})},"loading"):r.jsx(oe,{className:"flex-1 flex flex-col gap-2 relative",children:n.length?r.jsxs(r.Fragment,{children:[r.jsxs(F.AnimatePresence,{children:[s.length>0&&r.jsx(oe,{fadeIn:"up",delay:.2,className:"space-y-2",snapExit:!0,children:s.map(c=>r.jsx(Is,{session:c},c.id))},"open-sessions"),a.length>0&&r.jsxs(oe,{className:"space-y-2",delay:.2,snapExit:!0,children:[r.jsx(jf,{children:e("closed_conversations")}),a.map(c=>r.jsx(Is,{session:c,className:"opacity-50 hover:opacity-100"},c.id))]},"closed-sessions")]}),i&&r.jsx("div",{className:"mt-auto w-full rounded-3xl sticky bottom-0 outline outline-8 outline-background bg-background",children:u.createElement(X,{...L("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full",onClick:()=>t()},e("new_conversation"))})]}):r.jsxs("div",{className:"flex-1 flex flex-col gap-2 items-center",children:[r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx("p",{className:"text-muted-foreground",children:e("no_conversations_yet")})}),u.createElement(X,{...L("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full",onClick:()=>t()},e("new_conversation"))]})},"sessions")})})}function Sf(){const{theme:e}=me();return Pt({width:e.screens.sessions.width,height:e.screens.sessions.height}),r.jsx("div",{...L("sessions/root"),className:z("flex flex-col overflow-hidden bg-background"),style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:r.jsxs("div",{className:"size-full flex flex-col",children:[r.jsx(pc,{className:"flex-1 min-h-0 flex flex-col",children:r.jsx(kf,{children:r.jsx(Cf,{})})}),r.jsx(Hn,{}),r.jsx(ln,{})]})})}function Nf(){const{contentIframeRef:e}=C.useWidget(),{inline:t}=C.useConfig(),n=u.useRef(null);return u.useEffect(()=>{const o=e==null?void 0:e.current;if(o&&n.current){const s=n.current;let a;const i=new ResizeObserver(()=>{a=requestAnimationFrame(()=>{const c=s.offsetHeight;o.style.setProperty("--opencx-widget-height",t?"100%":`${c.toFixed(1)}px`)})});return i.observe(s),()=>{cancelAnimationFrame(a),i.unobserve(s)}}},[e,t]),{observedElementRef:n}}const _f=S.z.object({name:S.z.string().min(2),email:S.z.string().email()});function Ef(){var w,j,b,_,v,k,N,R;const{widgetCtx:{org:e}}=C.useWidget(),{setIsOpen:t}=C.useWidgetTrigger(),{createUnverifiedContact:n}=C.useContact(),{isSmallScreen:o}=je(),s=C.useConfig(),{theme:a}=me(),{t:i}=G(),{observedElementRef:c}=Nf();Pt({height:void 0,width:a.screens.welcome.width});const[d,l]=u.useState(((w=s.prefillUserData)==null?void 0:w.name)||""),[m,p]=u.useState(((j=s.prefillUserData)==null?void 0:j.email)||""),h=(s.extraDataCollectionFields||[]).filter(T=>T!=="name"&&T!=="email"&&!!T),[f,x]=u.useState({}),[g,y]=Rn.useAsyncFn(async T=>{T.preventDefault();const A=_f.safeParse({name:d,email:m});A.success&&await n({email:A.data.email,non_verified_name:A.data.name},Object.values(f).filter(Boolean).length?f:void 0)},[d,m,f]);return r.jsx("div",{style:{width:"100vw",maxWidth:"100vw",minHeight:a.screens.welcome.minHeight,height:"100vh",maxHeight:"100vh",overflowY:"auto"},children:r.jsxs("div",{ref:c,className:z("flex flex-col",o&&"h-full","bg-[radial-gradient(ellipse_at_top_left,hsl(var(--opencx-primary)),transparent),radial-gradient(ellipse_at_top_right,hsl(var(--opencx-primary)),transparent)]"),children:[r.jsxs("div",{className:z("flex-1 flex flex-col px-4 py-12 text-start space-y-4 relative z-10","text-primary-foreground"),children:[o&&r.jsx(oe,{className:"absolute top-6 end-6",children:r.jsx(X,{size:"selfless",onClick:()=>t(!1),children:r.jsx(M.XIcon,{className:"size-4"})})}),r.jsx("div",{className:"flex items-center justify-between w-full mb-2",children:(b=s.assets)!=null&&b.organizationLogo?r.jsx("img",{src:(_=s.assets)==null?void 0:_.organizationLogo,alt:"Company Logo",className:"h-8 w-auto object-contain"}):r.jsx("h2",{className:"font-bold text-sm",children:e.name})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h1",{className:"text-[1.75rem] font-semibold tracking-tight leading-none",children:((k=(v=s.textContent)==null?void 0:v.welcomeScreen)==null?void 0:k.title)||i("welcome_screen_title")}),r.jsx("p",{className:"text-sm",children:((R=(N=s.textContent)==null?void 0:N.welcomeScreen)==null?void 0:R.description)||i("welcome_screen_description")})]})]}),r.jsxs("div",{className:z("z-10 m-2 px-2 pt-2 bp-0 space-y-2","bg-[white]","border shadow","rounded-3xl"),children:[r.jsxs("form",{onSubmit:y,className:"space-y-2",children:[r.jsx(Vt,{value:d,onChange:T=>l(T.target.value),required:!0,placeholder:i("your_name_placeholder"),name:"name"}),r.jsx(Vt,{required:!0,value:m,onChange:T=>p(T.target.value),type:"email",placeholder:i("your_email_placeholder"),name:"email"}),h.map(T=>r.jsx(Vt,{value:f[T],onChange:A=>x(O=>({...O,[T]:A.target.value})),placeholder:`${T} (${i("optional")})`},T)),r.jsxs(X,{disabled:g.loading,className:"w-full",size:"lg",children:[g.loading?i("start_chat_button_loading"):i("start_chat_button"),r.jsx(M.SendHorizontal,{className:"size-4 rtl:-scale-100"})]})]}),r.jsx(ln,{})]})]})})}const Af={initial:{opacity:1,x:0}};function Tf(e){const{dir:t}=G(),[,n]=u.useReducer(a=>a+1,0),o=u.useRef({screen:e,direction:null});o.current.screen!==e&&(o.current={screen:e,direction:cf({from:o.current.screen,to:e,rtl:t==="rtl"})});const s=u.useCallback(()=>{o.current.direction&&(o.current={...o.current,direction:null},n())},[]);return{direction:o.current.direction,settle:s}}function _o(){const{routerState:{screen:e}}=C.useWidgetRouter(),t=Tf(e),n=t.direction?Af:void 0;return r.jsx(Jh,{children:r.jsx(rf,{children:r.jsx(uc.Provider,{value:t,children:r.jsx("div",{className:"relative bg-background size-full",children:(()=>{switch(e){case"welcome":return r.jsx(oe,{fadeIn:"right",className:"size-full",snapExit:!0,children:r.jsx(Ef,{})},e);case"home":return r.jsx(oe,{fadeIn:"right",className:"size-full",snapExit:!0,overrides:n,children:r.jsx(hf,{})},e);case"sessions":return r.jsx(oe,{fadeIn:"right",className:"size-full",snapExit:!0,overrides:n,children:r.jsx(Sf,{})},e);case"chat":return r.jsx(oe,{fadeIn:"right",className:"size-full",snapExit:!0,children:r.jsx(Wh,{})},e);default:return K.isExhaustive(e,_o.name),null}})()})})})})}const If=`
|
|
144
|
+
`})}function Dn(){return C.useConfig().unreadIndicator??"dot"}function Co({count:e,indicator:t,component:n,style:o}){const s=Dn();return s===!1?null:r.jsx(ac,{count:e,showCount:(t??s)==="count",component:n,style:o})}function Fn(e){const t=Dn(),{t:n}=G();return t===!1||e<=0?null:n("unread_sessions",{count:e})}const Wh={duration:.3,ease:$e};function Hn({onArticles:e}={}){const{widgetCtx:t}=C.useWidget(),{routerState:{screen:n},toHomeScreen:o,toSessionsScreen:s}=C.useWidgetRouter(),{count:a}=C.useUnread(),i=Fn(a),{t:c}=G();if(!t.home)return null;const d=[{key:"home",label:c("home_tab_articles"),Icon:M.BookOpenIcon,onClick:o,onReselect:e,unread:0},{key:"sessions",label:c("home_tab_chat"),Icon:M.MessageCircleIcon,onClick:s,onReselect:void 0,unread:a}];return r.jsx("nav",{...L("home/tabs"),className:"px-3 py-2",children:r.jsx("div",{role:"tablist",className:"grid grid-cols-2 gap-0.5 rounded-full border bg-secondary p-0.5",children:d.map(({key:l,label:m,Icon:p,onClick:h,onReselect:f,unread:x})=>{const g=n===l;return u.createElement(X,{...L("home/tab"),key:l,role:"tab","aria-selected":g,variant:"ghost",size:"free",className:z("relative h-9 min-w-0 rounded-full px-3 text-sm font-medium",g?"text-foreground hover:bg-transparent":"z-10 text-muted-foreground"),onClick:g?f:h},g&&r.jsx(F.motion.span,{layoutId:"home-tab-pill",className:"absolute inset-0 rounded-full border border-border bg-background shadow-sm",transition:Wh},"pill"),r.jsxs("span",{className:"relative z-10 flex min-w-0 items-center justify-center gap-1.5",children:[r.jsxs("span",{className:"relative shrink-0",children:[r.jsx(p,{className:"size-4"}),r.jsx(Co,{count:x,indicator:"dot",component:"home/tab_unread"})]}),r.jsx("span",{className:"truncate",children:m}),x>0&&i&&r.jsx("span",{className:"sr-only",children:i})]},"label"))})})})}function ic({key:e,fetchPage:t}){const[n,o]=u.useState(null),s=u.useRef(t);u.useEffect(()=>{s.current=t});const a=u.useCallback((p,h)=>{o(f=>({key:p,items:(f==null?void 0:f.key)===p&&h>0?f.items:[],nextOffset:(f==null?void 0:f.key)===p?f.nextOffset:null,fetching:!0,error:void 0})),s.current(h).then(f=>o(x=>(x==null?void 0:x.key)===p?{key:p,items:h===0?f.items:[...x.items,...f.items],nextOffset:f.nextOffset,fetching:!1,error:void 0}:x),f=>o(x=>(x==null?void 0:x.key)===p?{...x,fetching:!1,error:f}:x))},[]);u.useEffect(()=>{e!==null&&a(e,0)},[e,a]);const i=e!==null&&(n==null?void 0:n.key)===e?n:null,c=e!==null&&(!i||i.fetching),d=(i==null?void 0:i.nextOffset)??null,l=u.useCallback(()=>{e!==null&&d!==null&&!c&&a(e,d)},[e,d,c,a]),m=u.useCallback(()=>{e!==null&&a(e,0)},[e,a]);return{items:(i==null?void 0:i.items)??[],loading:c,error:i==null?void 0:i.error,hasMore:d!==null,loadMore:l,reload:m}}function cc({helpCenterId:e,topicId:t}){const{widgetCtx:n}=C.useWidget(),o=ic({key:t===null?null:`${e}:${t}`,fetchPage:s=>t===null?Promise.resolve({items:[],nextOffset:null}):n.api.listTopicArticles({helpCenterId:e,topicId:t,offset:s}).then(a=>({items:a.articles,nextOffset:a.next_offset}))});return u.useEffect(()=>{o.error&&K.log.error("home: could not load the topic articles",{_e:o.error,helpCenterId:e,topicId:t})},[o.error,e,t]),o}const Bh=["[--tw-prose-body:hsl(var(--opencx-foreground))]","[--tw-prose-headings:hsl(var(--opencx-foreground))]","[--tw-prose-bold:hsl(var(--opencx-foreground))]","[--tw-prose-links:hsl(var(--opencx-primary))]","[--tw-prose-code:hsl(var(--opencx-foreground))]","[--tw-prose-counters:hsl(var(--opencx-muted-foreground))]","[--tw-prose-bullets:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quotes:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quote-borders:hsl(var(--opencx-border))]","[--tw-prose-hr:hsl(var(--opencx-border))]","[--tw-prose-th-borders:hsl(var(--opencx-border))]","[--tw-prose-td-borders:hsl(var(--opencx-border))]","[--tw-prose-pre-bg:hsl(var(--opencx-muted))]","[--tw-prose-pre-code:hsl(var(--opencx-foreground))]"].join(" ");function Uh({helpCenterId:e,slug:t,popular:n,onBack:o,onHome:s,onOpenArticle:a,onOpenTopicPath:i,onRedirect:c}){var j,b,_;const{widgetCtx:d}=C.useWidget(),{t:l}=G(),{theme:m}=me();Pt({width:m.screens.chat.width,height:m.screens.chat.height});const p=Rn.useAsync(()=>d.api.getHelpCenterArticle({helpCenterId:e,slug:t}),[d,e,t]),h=(j=p.value)==null?void 0:j.article,f=u.useMemo(()=>({kind:"article",article:h?{slug:t,id:h.id,title:h.title}:{slug:t}}),[t,h]);no(f);const x=h?null:(b=p.value)==null?void 0:b.redirect_slug;u.useEffect(()=>{x&&c(x)},[x,c]),u.useEffect(()=>{p.error?K.log.error("home: could not load the article",{_e:p.error,helpCenterId:e,slug:t}):p.value&&!p.value.article&&!p.value.redirect_slug&&K.log.warn("home: article not found",{helpCenterId:e,slug:t})},[p.error,p.value,e,t]);const g=(h==null?void 0:h.topic_path)??[],y=cc({helpCenterId:e,topicId:((_=g.at(-1))==null?void 0:_.id)??null}),w=h?Dh({articleId:h.id,siblings:y.items,popular:n}):[];return r.jsxs("div",{...L("article/root"),className:"flex flex-col bg-background",style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:[r.jsx(rc,{component:"article/header",onBack:o,children:r.jsx("nav",{...L("article/trail"),className:"min-w-0 flex-1 flex items-center gap-0.5 text-sm",children:g.map((v,k)=>r.jsxs(u.Fragment,{children:[k>0&&r.jsx(M.ChevronRightIcon,{className:"size-3 shrink-0 text-muted-foreground rtl:-scale-100"}),r.jsx(X,{variant:"ghost",size:"free",wobble:!1,className:z("min-w-0 rounded-full px-1.5 py-1",k===g.length-1?"font-semibold":"shrink-[2] text-muted-foreground"),onClick:()=>i(g.slice(0,k+1).map(N=>N.id)),children:r.jsx("span",{className:"truncate",children:v.name})})]},v.id))})}),r.jsx("article",{...L("article/content"),className:"flex-1 overflow-y-auto px-5 py-4",children:p.loading||x?r.jsxs("div",{className:"space-y-3",children:[r.jsx(pt,{className:"h-6 w-3/4"}),r.jsx(pt,{className:"h-3 w-1/4"}),r.jsx(pt,{className:"h-4 w-full"}),r.jsx(pt,{className:"h-4 w-5/6"})]}):h?r.jsxs(r.Fragment,{children:[r.jsx("h1",{className:"text-xl font-semibold tracking-tight leading-snug",children:h.title}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:l("article_reading_minutes",{count:h.reading_minutes})}),h.content_html&&r.jsx("div",{className:z("mt-4 prose prose-sm max-w-none break-words [word-break:break-word]","prose-table:block prose-table:overflow-x-auto prose-table:[word-break:normal] prose-table:[overflow-wrap:normal]","prose-a:underline prose-img:rounded-xl",Bh),children:r.jsx(Eu,{openArticle:a,children:h.content_html})}),w.length>0&&r.jsx("div",{...L("article/suggested"),className:"mt-6 -mx-2",children:r.jsx(bt,{component:"home/articles",title:l("home_suggested_articles"),children:w.map(v=>r.jsx(nc,{article:v,onOpen:a},v.id))})})]}):r.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:l("home_load_failed")})}),r.jsxs("footer",{className:"shrink-0 pt-1",children:[r.jsx(Hn,{onArticles:s}),r.jsx(ln,{})]})]})}function qh({helpCenterId:e,topic:t,onBack:n,onHome:o,onOpenTopic:s,onOpenArticle:a}){const{theme:i}=me(),{t:c}=G();Pt({width:i.screens.sessions.width,height:i.screens.sessions.height});const d=u.useMemo(()=>({kind:"topic",topic:{id:t.id,name:t.name}}),[t.id,t.name]);no(d);const l=t.topics.filter(p=>p.article_count>0),m=cc({helpCenterId:e,topicId:t.id});return r.jsxs("div",{...L("topic/root"),className:"flex flex-col overflow-hidden bg-background",style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:[r.jsx(rc,{component:"topic/header",onBack:n,children:r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:t.name})}),r.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto flex flex-col gap-3 p-3",children:[t.description&&r.jsx("p",{className:"px-2 text-sm text-muted-foreground [overflow-wrap:anywhere]",children:t.description}),l.length>0&&r.jsx(bt,{component:"home/topics",title:c("home_topics"),children:l.map(p=>r.jsx(tc,{topic:p,onOpen:s},p.id))}),m.error&&m.items.length===0?r.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:c("home_load_failed")}):(m.loading||m.items.length>0)&&r.jsxs(bt,{component:"home/articles",title:c("home_tab_articles"),children:[m.items.map(p=>r.jsx(nc,{article:p,onOpen:a},p.id)),m.loading?r.jsx(In,{}):m.hasMore?r.jsx(oc,{onClick:m.loadMore}):null]})]}),r.jsxs("footer",{className:"shrink-0 pt-1",children:[r.jsx(Hn,{onArticles:o}),r.jsx(ln,{})]})]})}const So=u.createContext({data:void 0,loading:!1,failed:!1,request:()=>{}});function Vh({children:e}){var c;const{widgetCtx:t}=C.useWidget(),n=(c=t.home)==null?void 0:c.helpCenterId,[o,s]=u.useState(!1),a=u.useCallback(()=>s(!0),[]),i=Rn.useAsync(async()=>o&&n?t.api.listHomeArticles({helpCenterId:n}):void 0,[t,n,o]);return u.useEffect(()=>{i.error&&K.log.error("home: could not load the help center",{_e:i.error,helpCenterId:n})},[i.error,n]),r.jsx(So.Provider,{value:{data:i.value,loading:i.loading||!o&&!!n,failed:!!i.error,request:a},children:e})}function Yh(){const e=u.useContext(So),{request:t}=e;return u.useEffect(t,[t]),e}const Xh=400,Gh=6;function Kh(e){const[t,n]=u.useState(""),[o,s]=u.useState(""),[a,i]=u.useState(0),c=p=>p.length>=Gh||e.includes(p),d=p=>{const h=p.trim();s(c(h)?h:"")};return Rn.useDebounce(()=>d(t),Xh,[t]),{query:t,setQuery:n,search:o,searchNow:p=>{n(p),d(p),i(h=>h+1)},retry:a,reset:()=>{n(""),s("")}}}const lc=u.createContext(null);function Zh({children:e}){var l;const{widgetCtx:t}=C.useWidget(),n=((l=t.home)==null?void 0:l.helpCenterId)??null,{data:o}=u.useContext(So),[s,a]=u.useState([]),i=Kh((o==null?void 0:o.popularSearches)??[]),[c,d]=u.useState(n);return c!==n&&(d(n),a([]),i.reset()),r.jsx(lc.Provider,{value:{stack:s,setStack:a,homeSearch:i},children:e})}function Jh(){const e=u.useContext(lc);if(!e)throw new Error("useHomeState must be used inside HomeStateProvider");return e}const Qh=24,ef={initial:{opacity:1,x:0}},dc=u.createContext({direction:null,settle:()=>{}}),Lr={home:0,sessions:1};function As(e){return e in Lr}function tf({from:e,to:t,rtl:n}){return!As(e)||!As(t)||e===t?null:Lr[t]>Lr[e]!==n?"left":"right"}function uc({children:e,...t}){const{direction:n,settle:o}=u.useContext(dc);return u.useEffect(()=>{n&&o()},[n,o]),r.jsx(oe,{...t,fadeIn:n??"right",distance:Qh,overrides:n?{}:ef,children:e})}const nf=200,rf=3,of=3500,sf={kind:"main"},af={duration:.55,ease:$e};function cf(){var y,w,j;const{widgetCtx:e}=C.useWidget(),t=(y=e.home)==null?void 0:y.helpCenterId,{stack:n,setStack:o,homeSearch:s}=Jh(),a=Yh(),i=u.useCallback(b=>o(_=>[..._.slice(0,-1),{kind:"article",slug:b}]),[o]);if(!t)return null;const c=b=>o(_=>[..._,b]),d=()=>o(b=>b.slice(0,-1)),l=()=>o([]),m=b=>c({kind:"article",slug:b}),p=b=>c({kind:"topic",topicId:b}),h=b=>o(b.map(_=>({kind:"topic",topicId:_}))),f=n[n.length-1],x=((w=a.data)==null?void 0:w.topics)??[],g=(f==null?void 0:f.kind)==="topic"?ec(x,f.topicId):null;return r.jsx(F.AnimatePresence,{mode:"wait",initial:!1,children:(f==null?void 0:f.kind)==="article"?r.jsx(oe,{fadeIn:"left",snapExit:!0,className:"size-full",children:r.jsx(Uh,{helpCenterId:t,slug:f.slug,popular:((j=a.data)==null?void 0:j.articles)??[],onBack:d,onHome:l,onOpenArticle:m,onRedirect:i,onOpenTopicPath:h})},`${n.length}:${f.slug}`):g?r.jsx(oe,{fadeIn:"left",snapExit:!0,className:"size-full",children:r.jsx(qh,{helpCenterId:t,topic:g,onBack:d,onHome:l,onOpenTopic:p,onOpenArticle:m})},`${n.length}:${g.id}`):r.jsx(oe,{fadeIn:"right",snapExit:!0,className:"size-full",children:r.jsx(lf,{helpCenterId:t,data:a.data,loading:a.loading,failed:a.failed,homeSearch:s,onOpenArticle:m,onOpenTopic:p})},"home")})}function lf({helpCenterId:e,data:t,loading:n,failed:o,homeSearch:{query:s,setQuery:a,search:i,searchNow:c,retry:d},onOpenArticle:l,onOpenTopic:m}){const{theme:p}=me(),{t:h}=G();no(sf);const f=(t==null?void 0:t.popularSearches)??[],x=((t==null?void 0:t.topics)??[]).filter(g=>g.article_count>0);return Pt({width:p.screens.sessions.width,height:p.screens.sessions.height}),r.jsxs("div",{...L("home/root"),className:"flex flex-col overflow-hidden bg-background",style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:[r.jsxs(uc,{className:"flex-1 min-h-0 flex flex-col",children:[r.jsx(df,{}),r.jsx("div",{className:"shrink-0 px-3 -mt-6 relative z-10",children:r.jsx(uf,{value:s,hints:f,onChange:a,onSubmit:()=>c(s)})}),r.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto flex flex-col gap-3 p-3",children:i?r.jsx(ff,{helpCenterId:e,search:i,retry:d,onOpenArticle:l}):r.jsxs(r.Fragment,{children:[r.jsx(mf,{searches:f,onPick:c}),r.jsx(hf,{articles:t==null?void 0:t.articles,loading:n,failed:o,onOpenArticle:l}),x.length>0&&r.jsx(bt,{component:"home/topics",title:h("home_topics"),children:x.map(g=>r.jsx(tc,{topic:g,onOpen:m},g.id))})]})})]}),r.jsxs("footer",{className:"shrink-0 pt-1",children:[r.jsx(Hn,{}),r.jsx(ln,{})]})]})}function df(){var i,c;const{widgetCtx:{org:e}}=C.useWidget(),{assets:t,textContent:n}=C.useConfig(),{setIsOpen:o}=C.useWidgetTrigger(),{isSmallScreen:s}=je(),{t:a}=G();return r.jsxs("header",{...L("home/header"),className:z("shrink-0 px-5 pt-6 pb-14 space-y-4 text-primary-foreground","bg-[radial-gradient(ellipse_at_top_left,hsl(var(--opencx-primary)),transparent),radial-gradient(ellipse_at_top_right,hsl(var(--opencx-primary)),transparent)]"),children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 min-h-8",children:[t!=null&&t.organizationLogo?r.jsx("img",{src:t.organizationLogo,alt:e.name,className:"h-8 w-auto object-contain"}):r.jsx("h2",{className:"font-bold text-sm",children:e.name}),s&&r.jsx(X,{size:"selfless",onClick:()=>o(!1),children:r.jsx(M.XIcon,{className:"size-4"})})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("h1",{className:"text-2xl font-semibold tracking-tight leading-tight",children:((i=n==null?void 0:n.homeScreen)==null?void 0:i.title)||a("home_title")}),r.jsx("p",{className:"text-sm opacity-90",children:((c=n==null?void 0:n.homeScreen)==null?void 0:c.description)||a("home_description")})]})]})}function uf({value:e,hints:t,onChange:n,onSubmit:o}){const{t:s}=G();return r.jsxs("form",{...L("home/search"),role:"search",className:"relative block",onSubmit:a=>{a.preventDefault(),o()},children:[r.jsx(M.SearchIcon,{className:"pointer-events-none absolute start-4 top-1/2 -translate-y-1/2 size-4 text-muted-foreground"}),r.jsx(Vt,{type:"text",enterKeyHint:"search",maxLength:nf,value:e,onChange:a=>n(a.target.value),placeholder:t.length>0?void 0:s("home_search_placeholder"),"aria-label":s("home_search_placeholder"),className:"h-12 ps-10 rounded-3xl bg-background"}),t.length>0&&!e&&r.jsx(pf,{hints:t})]})}function pf({hints:e}){const t=F.useReducedMotion(),[n,o]=u.useState(0);u.useEffect(()=>{if(e.length<2||t)return;const a=setInterval(()=>o(i=>(i+1)%e.length),of);return()=>clearInterval(a)},[e.length,t]);const s=e[n%e.length];return r.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute top-1/2 start-10 end-4 h-6 -translate-y-1/2 overflow-hidden text-muted-foreground/75",children:r.jsx(F.AnimatePresence,{initial:!1,children:r.jsx(F.motion.span,{className:"absolute inset-0 truncate leading-6",initial:{y:"70%",opacity:0,filter:"blur(2px)"},animate:{y:0,opacity:1,filter:"blur(0px)"},exit:{y:"-70%",opacity:0,filter:"blur(2px)"},transition:af,children:s},s)})})}function mf({searches:e,onPick:t}){return e.length===0?null:r.jsx("div",{...L("home/popular_searches"),className:"flex flex-wrap gap-1.5",children:e.map(n=>r.jsx(X,{variant:"outline",size:"free",title:n,className:"max-w-full rounded-full bg-background px-3 py-1 text-xs font-normal",onClick:()=>t(n),children:r.jsx("span",{className:"min-w-0 truncate",children:n})},n))})}function hf({articles:e,loading:t,failed:n,onOpenArticle:o}){const{t:s}=G();return n?r.jsx($r,{children:s("home_load_failed")}):!t&&(e==null?void 0:e.length)===0?null:r.jsx(bt,{component:"home/articles",title:s("home_suggested_articles"),children:t||!e?Array.from({length:rf},(a,i)=>r.jsx(In,{},i)):e.map(a=>r.jsx(pc,{article:a,onOpen:o},a.id))})}function ff({helpCenterId:e,search:t,retry:n,onOpenArticle:o}){const{widgetCtx:s}=C.useWidget(),{t:a}=G(),i=ic({key:`${e}:${t}`,fetchPage:p=>s.api.searchHelpCenter({helpCenterId:e,query:t,offset:p}).then(h=>({items:h.results,nextOffset:h.next_offset}))}),c=i.error instanceof K.HelpCenterSearchError&&i.error.busy;u.useEffect(()=>{i.error&&!c&&K.log.error("home: help center search failed",{_e:i.error,helpCenterId:e})},[i.error,c,e]);const d=u.useRef(n),{error:l,reload:m}=i;return u.useEffect(()=>{n!==d.current&&(d.current=n,l&&m())},[n,l,m]),i.items.length===0?i.error?r.jsx($r,{onRetry:i.reload,children:a(c?"home_search_busy":"home_load_failed")}):i.loading?r.jsx(bt,{component:"home/articles",children:r.jsx(In,{})}):r.jsx($r,{children:a("home_search_no_results")}):r.jsxs(bt,{component:"home/articles",children:[i.items.map(p=>r.jsx(pc,{article:p,topicName:p.topic.name,onOpen:o},p.id)),i.loading?r.jsx(In,{}):i.hasMore?r.jsx(oc,{onClick:i.loadMore}):null]})}function pc({article:e,topicName:t,onOpen:n}){return r.jsxs(X,{...L("home/article_card"),variant:"ghost",wobble:!1,size:"free",className:jo,onClick:()=>n(e.slug),children:[r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-sm font-medium leading-snug [overflow-wrap:anywhere]",children:e.title}),t&&r.jsxs("span",{className:"mt-0.5 flex items-center gap-1 text-xs text-muted-foreground",children:[r.jsx(M.FolderIcon,{className:"size-3 shrink-0"}),r.jsx("span",{className:"truncate",children:t})]}),e.excerpt&&r.jsx("span",{className:z("mt-0.5 text-xs text-muted-foreground [overflow-wrap:anywhere]",t?"line-clamp-2":"line-clamp-1"),children:e.excerpt})]}),r.jsx(M.ChevronRightIcon,{className:"size-4 shrink-0 text-muted-foreground rtl:-scale-100"})]})}function $r({children:e,onRetry:t}){const{t:n}=G();return r.jsxs("div",{className:"rounded-3xl border bg-background px-4 py-6 text-center text-sm text-muted-foreground",children:[r.jsx("p",{children:e}),t&&r.jsx(X,{variant:"outline",size:"free",className:"mt-3 rounded-full bg-background px-3 py-1 text-xs",onClick:t,children:n("turn_failed_retry")})]})}function gf({children:e}){var j,b,_;const{widgetCtx:t,config:n}=C.useWidget(),[o,s]=u.useState(!1),[a,i]=u.useState(null),[c,d]=u.useState(""),[l,m]=u.useState([]),[p,h]=u.useState([]),[f,x]=u.useState(!1),[g,y]=u.useState("");u.useEffect(()=>{var k;let v=!1;if(((k=n.capabilities)==null?void 0:k.connections)===!0)return Promise.all([t.api.listConnections(),t.api.listApprovalPreferences()]).then(([N,R])=>{v||(m(N.filter(T=>T.status!=="not_connected")),h(R))}).catch(()=>{}),()=>{v=!0}},[t,(j=n.capabilities)==null?void 0:j.connections]);const w=async v=>{x(!0),y("");try{await v()}catch{y("Could not save the change. Try again.")}finally{x(!1)}};return!o||((b=n.capabilities)==null?void 0:b.connections)!==!0?r.jsxs(r.Fragment,{children:[r.jsx(mi,{}),((_=n.capabilities)==null?void 0:_.connections)===!0&&l.length>0&&r.jsxs(X,{variant:"ghost",className:"mx-3 my-1 h-9 justify-start gap-2 text-sm",onClick:()=>s(!0),children:[r.jsx(M.Unplug,{className:"size-4"})," Connections"," ",r.jsx(M.ChevronRight,{className:"ml-auto size-4"})]}),e]}):r.jsxs("section",{className:"flex-1 overflow-y-auto px-4 pb-4 pt-3 space-y-5","aria-label":"Connections",children:[r.jsxs("div",{className:"flex h-8 items-center gap-2 pr-16",children:[r.jsx(X,{variant:"ghost",size:"icon",className:"size-7","aria-label":a?"Back to connections":"Back to sessions",onClick:()=>a?i(null):s(!1),children:r.jsx(M.ArrowLeft,{className:"size-4"})}),r.jsx("h2",{className:"text-sm font-medium",children:"Connections"})]}),!l.length&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"No connected services."}),!a&&r.jsxs(r.Fragment,{children:[r.jsx("input",{type:"search","aria-label":"Search connections",placeholder:"Search connections",value:c,onChange:v=>d(v.target.value),className:"h-8 w-full rounded-full border border-foreground/15 bg-transparent px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring"}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("h3",{className:"border-b border-foreground/10 pb-2 text-xs font-medium",children:"Connected services"}),l.filter(v=>v.name.toLowerCase().includes(c.toLowerCase())).map(v=>r.jsxs("button",{type:"button",onClick:()=>i(v.server_id),className:"flex w-full items-center gap-3 rounded-xl px-2 py-3 text-left hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[r.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-xl border border-foreground/10 bg-background p-2",children:r.jsx(En,{})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-sm font-medium",children:v.name}),r.jsx("span",{className:"block text-xs text-muted-foreground",children:v.status==="connected"?"Connected":"Reconnect required"})]}),r.jsx(M.ChevronRight,{className:"size-4 text-muted-foreground"})]},v.server_id)),l.length>0&&!l.some(v=>v.name.toLowerCase().includes(c.toLowerCase()))&&r.jsx("p",{className:"py-3 text-xs text-muted-foreground",children:"No matching connections."})]})]}),l.filter(v=>v.server_id===a).map(v=>r.jsxs("div",{className:"border-b border-foreground/10 pb-5 space-y-3 last:border-0",children:[r.jsx("div",{className:"flex size-12 items-center justify-center rounded-xl border border-foreground/10 bg-background p-3",children:r.jsx(En,{})}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium",children:v.name}),r.jsx("p",{className:"text-xs text-muted-foreground",children:v.status==="connected"?"Connected":"Reconnect required"})]}),r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",disabled:f,onClick:()=>void w(async()=>{await t.api.disconnectConnection(v.server_id),i(null),m(k=>k.filter(N=>N.server_id!==v.server_id)),h(k=>k.filter(N=>N.serverId!==v.server_id))}),children:"Disconnect"})]}),p.some(k=>k.serverId===v.server_id)?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("h3",{className:"text-xs font-medium",children:["Saved approvals (",p.filter(k=>k.serverId===v.server_id).length,")"]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Removing an approval makes the widget ask again next time."}),r.jsx("ul",{className:"max-h-64 overflow-y-auto divide-y divide-foreground/10 rounded-xl border border-foreground/10","aria-label":`${v.name} saved approvals`,children:p.filter(k=>k.serverId===v.server_id).map(k=>r.jsxs("li",{className:"flex items-start gap-3 p-3",children:[r.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[r.jsx("p",{className:"text-xs font-medium break-words",children:k.toolName.replace(/[_-]+/g," ")}),r.jsx("p",{className:"text-xs text-muted-foreground break-words",children:k.message})]}),r.jsx(X,{variant:"secondary",size:"sm",className:"h-7 shrink-0 px-2 text-xs",disabled:f,onClick:()=>void w(async()=>{await t.api.revokeApprovalPreference(k.serverId,k.key),h(N=>N.filter(R=>R.serverId!==k.serverId||R.key!==k.key))}),children:"Remove approval"})]},k.key))})]}):r.jsx("p",{className:"text-xs text-muted-foreground",children:"No saved approvals"})]},v.server_id)),g&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:g})]})}function xf({children:e}){return r.jsx("p",{className:"ps-4 text-xs text-muted-foreground/75 uppercase font-semibold tracking-tight",children:e})}function Ts({session:e,className:t}){const{humanAgent:n}=C.useConfig(),o=C.useBot(),{toChatScreen:s}=C.useWidgetRouter(),{isUnread:a}=C.useUnread(),i=Fn(a(e.id)?1:0),c=e.assignee.kind==="human"?(n==null?void 0:n.name)||e.assignee.name||"Support Agent":o.name,d=e.assignee.kind==="human"?(n==null?void 0:n.avatarUrl)||e.assignee.avatarUrl||"":o.avatarUrl||o.avatar||"";return r.jsxs(X,{variant:"ghost",size:"lg",className:z("rounded-full p-2 pe-4 flex text-start justify-between w-full whitespace-normal",t),onClick:()=>s(e.id),children:[r.jsxs("div",{className:"flex-1 flex gap-2 items-center min-w-0",children:[r.jsx(F.AnimatePresence,{mode:"wait",children:r.jsx(oe,{snapExit:!0,children:r.jsxs(ro,{className:"size-10",children:[r.jsx(oo,{src:d,alt:"Agent Icon"}),r.jsx(so,{children:r.jsx(M.UserRoundIcon,{className:"size-4"})})]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx(F.AnimatePresence,{mode:"wait",children:r.jsx(oe,{snapExit:!0,children:c},c)}),r.jsx(F.AnimatePresence,{mode:"wait",children:e.lastMessage?r.jsx(oe,{snapExit:!0,children:r.jsx(ti,{remarkPlugins:[ca],rehypePlugins:[ur],className:"line-clamp-1 overflow-hidden text-ellipsis text-xs text-muted-foreground",children:e.lastMessage})},e.lastMessage||"content"):r.jsx(oe,{className:"w-1/2",snapExit:!0,children:r.jsx(pt,{className:"h-4 w-full"})},"skeleton")}),r.jsx(F.AnimatePresence,{mode:"wait",children:e.customStatus&&r.jsx(oe,{className:"mt-1",snapExit:!0,children:r.jsx(ji,{customStatus:e.customStatus})},e.customStatus.id)})]})]}),i&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"sr-only",children:i}),r.jsx(Co,{count:1,indicator:"dot",component:"sessions/unread"})]}),r.jsx(M.ChevronRightIcon,{className:"size-4 text-muted-foreground shrink-0 rtl:-scale-100"})]})}function bf(){const{t:e}=G(),{toChatScreen:t}=C.useWidgetRouter(),{sessionsState:{data:n,isInitialFetchLoading:o},openSessions:s,closedSessions:a,canCreateNewSession:i}=C.useSessions();return r.jsx("div",{...L("sessions/list"),className:"flex-1 flex flex-col overflow-scroll py-2 px-2",children:r.jsx(F.AnimatePresence,{mode:"wait",children:o?r.jsx(oe,{className:"flex-1 flex items-center justify-center",children:r.jsx(hi,{})},"loading"):r.jsx(oe,{className:"flex-1 flex flex-col gap-2 relative",children:n.length?r.jsxs(r.Fragment,{children:[r.jsxs(F.AnimatePresence,{children:[s.length>0&&r.jsx(oe,{fadeIn:"up",delay:.2,className:"space-y-2",snapExit:!0,children:s.map(c=>r.jsx(Ts,{session:c},c.id))},"open-sessions"),a.length>0&&r.jsxs(oe,{className:"space-y-2",delay:.2,snapExit:!0,children:[r.jsx(xf,{children:e("closed_conversations")}),a.map(c=>r.jsx(Ts,{session:c,className:"opacity-50 hover:opacity-100"},c.id))]},"closed-sessions")]}),i&&r.jsx("div",{className:"mt-auto w-full rounded-3xl sticky bottom-0 outline outline-8 outline-background bg-background",children:u.createElement(X,{...L("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full",onClick:()=>t()},e("new_conversation"))})]}):r.jsxs("div",{className:"flex-1 flex flex-col gap-2 items-center",children:[r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx("p",{className:"text-muted-foreground",children:e("no_conversations_yet")})}),u.createElement(X,{...L("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full",onClick:()=>t()},e("new_conversation"))]})},"sessions")})})}function wf(){const{theme:e}=me();return Pt({width:e.screens.sessions.width,height:e.screens.sessions.height}),r.jsx("div",{...L("sessions/root"),className:z("flex flex-col overflow-hidden bg-background"),style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:r.jsxs("div",{className:"size-full flex flex-col",children:[r.jsx(uc,{className:"flex-1 min-h-0 flex flex-col",children:r.jsx(gf,{children:r.jsx(bf,{})})}),r.jsx(Hn,{}),r.jsx(ln,{})]})})}function vf(){const{contentIframeRef:e}=C.useWidget(),{inline:t}=C.useConfig(),n=u.useRef(null);return u.useEffect(()=>{const o=e==null?void 0:e.current;if(o&&n.current){const s=n.current;let a;const i=new ResizeObserver(()=>{a=requestAnimationFrame(()=>{const c=s.offsetHeight;o.style.setProperty("--opencx-widget-height",t?"100%":`${c.toFixed(1)}px`)})});return i.observe(s),()=>{cancelAnimationFrame(a),i.unobserve(s)}}},[e,t]),{observedElementRef:n}}const yf=S.z.object({name:S.z.string().min(2),email:S.z.string().email()});function kf(){var w,j,b,_,v,k,N,R;const{widgetCtx:{org:e}}=C.useWidget(),{setIsOpen:t}=C.useWidgetTrigger(),{createUnverifiedContact:n}=C.useContact(),{isSmallScreen:o}=je(),s=C.useConfig(),{theme:a}=me(),{t:i}=G(),{observedElementRef:c}=vf();Pt({height:void 0,width:a.screens.welcome.width});const[d,l]=u.useState(((w=s.prefillUserData)==null?void 0:w.name)||""),[m,p]=u.useState(((j=s.prefillUserData)==null?void 0:j.email)||""),h=(s.extraDataCollectionFields||[]).filter(T=>T!=="name"&&T!=="email"&&!!T),[f,x]=u.useState({}),[g,y]=Rn.useAsyncFn(async T=>{T.preventDefault();const A=yf.safeParse({name:d,email:m});A.success&&await n({email:A.data.email,non_verified_name:A.data.name},Object.values(f).filter(Boolean).length?f:void 0)},[d,m,f]);return r.jsx("div",{style:{width:"100vw",maxWidth:"100vw",minHeight:a.screens.welcome.minHeight,height:"100vh",maxHeight:"100vh",overflowY:"auto"},children:r.jsxs("div",{ref:c,className:z("flex flex-col",o&&"h-full","bg-[radial-gradient(ellipse_at_top_left,hsl(var(--opencx-primary)),transparent),radial-gradient(ellipse_at_top_right,hsl(var(--opencx-primary)),transparent)]"),children:[r.jsxs("div",{className:z("flex-1 flex flex-col px-4 py-12 text-start space-y-4 relative z-10","text-primary-foreground"),children:[o&&r.jsx(oe,{className:"absolute top-6 end-6",children:r.jsx(X,{size:"selfless",onClick:()=>t(!1),children:r.jsx(M.XIcon,{className:"size-4"})})}),r.jsx("div",{className:"flex items-center justify-between w-full mb-2",children:(b=s.assets)!=null&&b.organizationLogo?r.jsx("img",{src:(_=s.assets)==null?void 0:_.organizationLogo,alt:"Company Logo",className:"h-8 w-auto object-contain"}):r.jsx("h2",{className:"font-bold text-sm",children:e.name})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h1",{className:"text-[1.75rem] font-semibold tracking-tight leading-none",children:((k=(v=s.textContent)==null?void 0:v.welcomeScreen)==null?void 0:k.title)||i("welcome_screen_title")}),r.jsx("p",{className:"text-sm",children:((R=(N=s.textContent)==null?void 0:N.welcomeScreen)==null?void 0:R.description)||i("welcome_screen_description")})]})]}),r.jsxs("div",{className:z("z-10 m-2 px-2 pt-2 bp-0 space-y-2","bg-[white]","border shadow","rounded-3xl"),children:[r.jsxs("form",{onSubmit:y,className:"space-y-2",children:[r.jsx(Vt,{value:d,onChange:T=>l(T.target.value),required:!0,placeholder:i("your_name_placeholder"),name:"name"}),r.jsx(Vt,{required:!0,value:m,onChange:T=>p(T.target.value),type:"email",placeholder:i("your_email_placeholder"),name:"email"}),h.map(T=>r.jsx(Vt,{value:f[T],onChange:A=>x(O=>({...O,[T]:A.target.value})),placeholder:`${T} (${i("optional")})`},T)),r.jsxs(X,{disabled:g.loading,className:"w-full",size:"lg",children:[g.loading?i("start_chat_button_loading"):i("start_chat_button"),r.jsx(M.SendHorizontal,{className:"size-4 rtl:-scale-100"})]})]}),r.jsx(ln,{})]})]})})}const jf={initial:{opacity:1,x:0}};function Cf(e){const{dir:t}=G(),[,n]=u.useReducer(a=>a+1,0),o=u.useRef({screen:e,direction:null});o.current.screen!==e&&(o.current={screen:e,direction:tf({from:o.current.screen,to:e,rtl:t==="rtl"})});const s=u.useCallback(()=>{o.current.direction&&(o.current={...o.current,direction:null},n())},[]);return{direction:o.current.direction,settle:s}}function No(){const{routerState:{screen:e}}=C.useWidgetRouter(),t=Cf(e),n=t.direction?jf:void 0;return r.jsx(Vh,{children:r.jsx(Zh,{children:r.jsx(dc.Provider,{value:t,children:r.jsx("div",{className:"relative bg-background size-full",children:(()=>{switch(e){case"welcome":return r.jsx(oe,{fadeIn:"right",className:"size-full",snapExit:!0,children:r.jsx(kf,{})},e);case"home":return r.jsx(oe,{fadeIn:"right",className:"size-full",snapExit:!0,overrides:n,children:r.jsx(cf,{})},e);case"sessions":return r.jsx(oe,{fadeIn:"right",className:"size-full",snapExit:!0,overrides:n,children:r.jsx(wf,{})},e);case"chat":return r.jsx(oe,{fadeIn:"right",className:"size-full",snapExit:!0,children:r.jsx(Oh,{})},e);default:return K.isExhaustive(e,No.name),null}})()})})})})}const Sf=`
|
|
145
145
|
attribute vec2 a_position;
|
|
146
146
|
void main() { gl_Position = vec4(a_position, 0.0, 1.0); }
|
|
147
|
-
`,
|
|
147
|
+
`,Nf=`
|
|
148
148
|
precision highp float;
|
|
149
149
|
uniform vec2 u_resolution;
|
|
150
150
|
uniform float u_time;
|
|
@@ -211,7 +211,7 @@ void main() {
|
|
|
211
211
|
color += grain * 0.032;
|
|
212
212
|
gl_FragColor = vec4(clamp(color, 0.0, 1.0), alpha);
|
|
213
213
|
}
|
|
214
|
-
`;function Mf(e){const t=/^#([\da-f])([\da-f])([\da-f])$/i.exec(e),n=t?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:e;if(!/^#[\da-f]{6}$/i.test(n))throw new Error("VoiceOrb colors must be #RGB or #RRGGBB hex colors.");const o=Number.parseInt(n.slice(1),16);return[(o>>16&255)/255,(o>>8&255)/255,(o&255)/255]}function Rf(e,t,n){const o=e.getContext("webgl",{alpha:!0,antialias:!1,premultipliedAlpha:!1,powerPreference:"low-power"});if(!o)throw new Error("WebGL is unavailable in this browser.");let s=!1,a=0,i=0,c=0,d=!0,l=!1,m=!1,p=null,h=null,f=[],x={},g=null,y={width:e.clientWidth,height:e.clientHeight};const w=()=>{h&&o.deleteBuffer(h),p&&o.deleteProgram(p);for(const O of f)o.deleteShader(O);h=null,p=null,f=[]},j=()=>{const O=(I,W)=>{const $=o.createShader(I);if(!$)throw new Error("Could not allocate an orb shader.");if(f.push($),o.shaderSource($,W),o.compileShader($),!o.getShaderParameter($,o.COMPILE_STATUS))throw new Error(o.getShaderInfoLog($)||"Could not compile the orb shader.");return $},P=O(o.VERTEX_SHADER,If),B=O(o.FRAGMENT_SHADER,zf);if(p=o.createProgram(),!p)throw new Error("Could not allocate the orb program.");if(o.attachShader(p,P),o.attachShader(p,B),o.linkProgram(p),!o.getProgramParameter(p,o.LINK_STATUS))throw new Error(o.getProgramInfoLog(p)||"Could not link the orb program.");if(o.useProgram(p),h=o.createBuffer(),!h)throw new Error("Could not allocate the orb buffer.");o.bindBuffer(o.ARRAY_BUFFER,h),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),o.STATIC_DRAW);const E=o.getAttribLocation(p,"a_position");o.enableVertexAttribArray(E),o.vertexAttribPointer(E,2,o.FLOAT,!1,0,0),x=Object.fromEntries(["u_resolution","u_time","u_activity","u_base","u_light","u_dark"].map(I=>[I,o.getUniformLocation(p,I)])),g=null},b=()=>{cancelAnimationFrame(a),a=0,c=0},_=O=>{if(a=0,s||l||!d||document.hidden){c=0;return}try{const P=t();P.animated&&c&&(i+=Math.min(.05,(O-c)/1e3)*P.speed*(1+P.activity*.6)),c=P.animated?O:0;const B=Math.min(window.devicePixelRatio||1,2),E=Math.max(1,Math.round(y.width*B)),I=Math.max(1,Math.round(y.height*B));if((e.width!==E||e.height!==I)&&(e.width=E,e.height=I),o.viewport(0,0,E,I),o.uniform2f(x.u_resolution??null,E,I),o.uniform1f(x.u_time??null,i),o.uniform1f(x.u_activity??null,P.activity),!g||g.some((W,$)=>W!==P.colors[$])){const[W,$,U]=P.colors.map(Mf);W&&$&&U&&(o.uniform3fv(x.u_base??null,W),o.uniform3fv(x.u_light??null,$),o.uniform3fv(x.u_dark??null,U),g=P.colors)}o.drawArrays(o.TRIANGLES,0,6),P.animated&&(a=requestAnimationFrame(_))}catch(P){m=!0,b(),n(P instanceof Error?P:new Error(String(P)))}},v=()=>{!s&&!l&&!m&&d&&!document.hidden&&!a&&(a=requestAnimationFrame(_))},k=()=>{document.hidden?b():v()},N=O=>{O.preventDefault(),l=!0,b()},R=()=>{try{w(),j(),l=!1,v()}catch(O){n(O instanceof Error?O:new Error(String(O)))}};try{j()}catch(O){throw w(),O}const T=new ResizeObserver(([O])=>{O&&(y={width:O.contentRect.width,height:O.contentRect.height}),v()});T.observe(e);const A=new IntersectionObserver(([O])=>{d=(O==null?void 0:O.isIntersecting)??!0,d?v():b()});return A.observe(e),e.addEventListener("webglcontextlost",N),e.addEventListener("webglcontextrestored",R),document.addEventListener("visibilitychange",k),v(),{requestDraw:v,dispose:()=>{s=!0,b(),T.disconnect(),A.disconnect(),e.removeEventListener("webglcontextlost",N),e.removeEventListener("webglcontextrestored",R),document.removeEventListener("visibilitychange",k),w()}}}const Pf={stiffness:700,damping:50,mass:.5},rr=e=>Number.isFinite(e)?Math.max(0,Math.min(1,e)):0;function Of({activity:e=0,colors:t,active:n=!0,speed:o=1,className:s,style:a,...i}){const c=F.useReducedMotion()??!1,d=u.useRef(null),l=u.useRef(null),[m,p]=u.useState(!1),h=F.useMotionValue(0),f=F.useSpring(h,Pf),x=F.useTransform(f,y=>`translate3d(0, ${-y*2}px, 0) scale(${1+y*.04}, ${1-y*.018})`),g=u.useRef({activity:e,colors:t,active:n,speed:o,reducedMotion:c});return u.useLayoutEffect(()=>{var w;g.current={activity:e,colors:t,active:n,speed:o,reducedMotion:c};const y=n&&!c?rr(F.isMotionValue(e)?e.get():e):0;c?(f.jump(0),h.set(0)):h.set(y),(w=l.current)==null||w.requestDraw()}),u.useEffect(()=>{if(F.isMotionValue(e))return e.on("change",y=>{var w;g.current.active&&!g.current.reducedMotion&&h.set(rr(y)),(w=l.current)==null||w.requestDraw()})},[e,h]),u.useEffect(()=>f.on("change",()=>{var y;return(y=l.current)==null?void 0:y.requestDraw()}),[f]),u.useEffect(()=>{const y=d.current;if(!y)return;const w=j=>{console.error("[voice] orb rendering unavailable",{_e:j.message}),p(!0)};try{l.current=Rf(y,()=>{const j=g.current;return{activity:j.active&&!j.reducedMotion?rr(f.get()):0,colors:j.colors,speed:Number.isFinite(j.speed)?Math.max(0,j.speed):1,animated:j.active&&!j.reducedMotion&&j.speed>0}},w)}catch(j){w(j instanceof Error?j:new Error(String(j)))}return()=>{var j;(j=l.current)==null||j.dispose(),l.current=null}},[f,h]),r.jsx("div",{...i,"aria-hidden":"true",className:z("relative aspect-square shrink-0",s),style:a,children:m?r.jsx("div",{className:"size-full rounded-full bg-primary/80"}):r.jsx(F.motion.div,{className:"size-full",style:{transform:c?"none":x},children:r.jsx("canvas",{ref:d,className:"block size-full"})})})}const zs={h:32,s:88,l:59},Lf=.09,$f=.04;function Df(e,t){const n=e.ownerDocument.defaultView;if(!n)return null;const o=n.getComputedStyle(e).getPropertyValue(t).trim(),s=/^(-?[\d.]+)(?:deg)?[\s,]+([\d.]+)%[\s,]+([\d.]+)%/.exec(o);return s?{h:Number(s[1]),s:Number(s[2]),l:Number(s[3])}:null}function or({h:e,s:t,l:n}){const o=Math.max(0,Math.min(100,t))/100,s=Math.max(0,Math.min(100,n))/100,a=d=>(d+e/30)%12,i=o*Math.min(s,1-s),c=d=>{const l=s-i*Math.max(-1,Math.min(a(d)-3,Math.min(9-a(d),1)));return Math.round(l*255).toString(16).padStart(2,"0")};return`#${c(0)}${c(8)}${c(4)}`}function Ms(e){return[or(e),or({h:e.h+10,s:Math.min(e.s,90),l:90}),or({h:e.h-8,s:e.s*.75,l:Math.max(18,e.l-30)})]}function Ff({levelsRef:e,state:t,muted:n,reducedMotion:o,onSpeakingChange:s}){const a=u.useRef(null),i=F.useMotionValue(0),[c,d]=u.useState(()=>Ms(zs)),l=u.useRef({state:t,muted:n,reducedMotion:o,onSpeakingChange:s});return l.current={state:t,muted:n,reducedMotion:o,onSpeakingChange:s},u.useEffect(()=>{const m=a.current;m&&d(Ms(Df(m,"--opencx-primary")??zs))},[]),u.useEffect(()=>{var w;const m=(w=a.current)==null?void 0:w.ownerDocument.defaultView;if(!m)return;let p=0,h=0,f=0,x=!1;const g=m.performance.now(),y=j=>{p=m.requestAnimationFrame(y);const{state:b,muted:_,reducedMotion:v,onSpeakingChange:k}=l.current,N=e.current,R=b==="connected"||b==="waiting",T=R&&N?N.remote:0,A=R&&N&&!_?N.local:0;h+=(T-h)*(T>h?.22:.06),f+=(A-f)*(A>f?.3:.08);const O=x?h>$f:h>Lf;if(O!==x&&(x=O,k(x)),v||b==="ended"||b==="idle"){i.set(0);return}const P=(j-g)/1e3,B=.08+(Math.sin(P*1.1)+1)/2*.1;i.set(Math.min(1,Math.max(B,h*1.6,f*1.1)))};return p=m.requestAnimationFrame(y),()=>m.cancelAnimationFrame(p)},[i,e]),r.jsx("div",{ref:a,className:"size-full",children:r.jsx(Of,{activity:i,colors:c,active:t!=="ended",className:"size-full"})})}const Hf=48;function Wf({segments:e,className:t,style:n}){const o=u.useRef(null),s=u.useRef(!0);return u.useLayoutEffect(()=>{const a=o.current;a&&s.current&&(a.scrollTop=a.scrollHeight)},[e]),r.jsx("div",{...L("voice/transcript"),ref:o,onScroll:a=>{const i=a.currentTarget;s.current=i.scrollHeight-i.scrollTop-i.clientHeight<Hf},className:z("opencx-voice-transcript-mask flex flex-col overflow-y-auto overscroll-contain px-6",t),style:n,children:r.jsx("ol",{className:"mt-auto flex flex-col gap-3 pb-2 pt-12",children:e.map(a=>u.createElement("li",{...L("voice/transcript_line"),key:a.id,"data-role":a.role,"data-final":a.final,className:z("opencx-fade-up flex",a.role==="user"?"justify-end":"justify-start")},r.jsx("p",{dir:"auto",className:z("whitespace-pre-wrap text-pretty break-words",a.role==="user"?"max-w-[85%] rounded-2xl rounded-ee-md bg-secondary px-3.5 py-2 text-[15px] leading-snug text-foreground":"max-w-full text-[17px] font-medium leading-relaxed text-foreground"),children:r.jsx("span",{children:Ar(a.text)})})))})})}const Rs="rounded-full p-0 flex items-center justify-center transition-[transform,background-color,color] duration-150";function Bf({connectedAt:e}){const[t,n]=u.useState(()=>Date.now());return u.useEffect(()=>{if(e===null)return;const o=setInterval(()=>n(Date.now()),500);return()=>clearInterval(o)},[e]),r.jsx("span",{dir:"ltr",className:z("text-sm tabular-nums text-muted-foreground transition-opacity duration-200",e===null&&"opacity-0"),children:zi(e===null?0:t-e)})}const Ps=300,Os=136,sr="cubic-bezier(0.23, 1, 0.32, 1)";function Uf(e){return e==="connection_timeout"?"error_timeout":e==="already_started"?"error_busy":"error_generic"}function hc(){var y,w,j,b;const e=Ot(),t=C.useConfig(),{language:n,dir:o}=G(),s=F.useReducedMotion()??!1,[a,i]=u.useState(!1),c=u.useRef(null),d=(_,v)=>go(n,_,v),l=((y=t.voice)==null?void 0:y.agentName)??((w=t.bot)==null?void 0:w.name)??d("default_agent");u.useEffect(()=>{var _;e.isOpen&&((_=c.current)==null||_.focus({preventScroll:!0}))},[e.isOpen]),u.useEffect(()=>{e.state!=="connected"&&i(!1)},[e.state]);const m=e.state==="ended"||e.state==="idle",p=e.error?d(Uf(e.error.code)):e.state==="connected"?a?d("speaking",{name:l}):d("listening"):e.state==="waiting"?d("waiting"):e.state==="queued"?d("queued"):e.state==="reconnecting"?d("reconnecting"):d(m?"ended":"connecting"),h=!e.error&&!!((j=t.voice)!=null&&j.greeting)&&e.connectedAt===null&&!m,f=e.transcript.filter(_=>_.text.trim()),x=f.length>0,g=s?"none":`flex-grow 0.5s ${sr}, width 0.5s ${sr}, height 0.5s ${sr}`;return r.jsx(F.AnimatePresence,{children:e.enabled&&e.isOpen&&u.createElement(F.motion.div,{...L("voice/root"),key:"voice-call",role:"dialog","aria-modal":"true","aria-label":l,dir:o,initial:{opacity:0,scale:s?1:1.03},animate:{opacity:1,scale:1,transition:{duration:.32,ease:$e}},exit:{opacity:0,scale:s?1:.98,transition:{duration:.22,ease:$e}},className:"absolute inset-0 z-[60] flex flex-col overflow-hidden bg-background text-foreground",style:{backgroundImage:"radial-gradient(120% 70% at 50% 40%, hsl(var(--opencx-primary) / 0.12), transparent 70%)"}},r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsxs("header",{className:"flex flex-col items-center gap-0.5 px-6 pt-8 text-center",children:[r.jsx("span",{className:"text-base font-semibold text-foreground",children:l}),r.jsx(Bf,{connectedAt:e.connectedAt})]}),r.jsx("div",{className:"relative flex min-h-0 items-center justify-center",style:{flexGrow:1,flexBasis:0,transition:g},children:r.jsx("div",{className:"relative max-w-full",style:{width:x?Os:Ps,height:x?Os:Ps,transition:g},children:r.jsx(Ff,{levelsRef:e.levelsRef,state:e.error?"ended":e.state,muted:e.muted,reducedMotion:s,onSpeakingChange:i})})}),r.jsxs("div",{className:z("flex flex-col items-center gap-1 px-6 text-center",!x&&"min-h-[4.5rem]"),children:[r.jsx("div",{"aria-live":"polite",className:"min-h-7",children:r.jsx(F.AnimatePresence,{mode:"wait",initial:!1,children:r.jsx(F.motion.p,{initial:{opacity:0,y:s?0:4},animate:{opacity:1,y:0,transition:ke},exit:{opacity:0,y:s?0:-4,transition:ge},className:z("font-medium text-balance",e.error?"text-destructive text-sm":x?"text-sm text-muted-foreground":"text-lg text-foreground"),children:p},p)})}),h&&!x&&r.jsx("p",{className:"text-sm text-muted-foreground text-balance",children:(b=t.voice)==null?void 0:b.greeting}),e.muted&&!m&&!e.error&&r.jsx("p",{className:"text-xs text-muted-foreground",children:d("muted_hint")})]}),r.jsx(Wf,{segments:f,className:"min-h-0",style:{flexGrow:x?1.6:1e-4,flexBasis:0,transition:g}}),r.jsx("div",{className:"flex min-h-14 items-center justify-center px-6 pt-2",children:r.jsx(F.AnimatePresence,{children:e.audioBlocked&&!m&&r.jsx(F.motion.div,{initial:{opacity:0,y:s?0:6},animate:{opacity:1,y:0,transition:ke},exit:{opacity:0,transition:ge},children:r.jsxs(X,{...L("voice/resume_audio_btn"),onClick:e.resumeAudio,className:"min-h-11 rounded-full px-5 shadow-sm",children:[r.jsx(M.Volume2Icon,{className:"size-4"}),d("tap_to_hear")]})})})}),r.jsx("footer",{className:"flex items-center justify-center gap-6 px-6 pb-10 pt-4",children:e.error?r.jsxs(r.Fragment,{children:[r.jsx(X,{...L("voice/back_btn"),variant:"secondary",onClick:e.close,className:"min-h-12 rounded-full px-5",children:d("back_to_chat")}),r.jsxs(X,{...L("voice/retry_btn"),onClick:()=>void e.start(),className:"min-h-12 rounded-full px-5",children:[r.jsx(M.RotateCcwIcon,{className:"size-4"}),d("try_again")]})]}):r.jsxs(r.Fragment,{children:[r.jsx(X,{...L("voice/mute_btn"),variant:"secondary",onClick:e.toggleMute,disabled:m,"aria-pressed":e.muted,"aria-label":e.muted?d("unmute"):d("mute"),className:z(Rs,"size-14",e.muted&&"bg-foreground text-background hover:bg-foreground/90"),children:e.muted?r.jsx(M.MicOffIcon,{className:"size-6"}):r.jsx(M.MicIcon,{className:"size-6"})}),r.jsx(X,{...L("voice/end_btn"),ref:c,variant:"destructive",onClick:()=>void e.end(),disabled:m,"aria-label":d("end_call"),className:z(Rs,"size-16 shadow-lg"),children:r.jsx(M.PhoneOffIcon,{className:"size-7"})})]})})]}))})}const qf=io(),Vf=()=>{};function fc(){const{isOpen:e}=C.useWidgetTrigger(),{contentIframeRef:t,widgetCtx:n}=C.useWidget(),{inline:o}=C.useConfig(),{theme:s,computed:a}=me();return u.useEffect(()=>{e||n.dictationCtx.stop({executeFinalCommand:!1})},[e,n]),r.jsx(F.motion.div,{onUpdate:Vf,animate:e?"visible":"hidden",initial:"hidden",style:{transformOrigin:o?void 0:"bottom right"},variants:{hidden:{opacity:0,scale:o?1:.9,y:8,transitionEnd:{display:"none"},transition:It},visible:{opacity:1,scale:1,y:0,display:"block",height:o?"100%":void 0,transition:{...It,height:{duration:0}}}},children:r.jsx(da,{ref:t,initialContent:qf,allowFullScreen:!0,title:li,style:{"--opencx-widget-width":a.minWidth,"--opencx-widget-height":a.minHeight,minWidth:a.minWidth,width:"var(--opencx-widget-width)",maxWidth:a.maxWidth,minHeight:a.minHeight,height:"var(--opencx-widget-height)",maxHeight:a.maxHeight,overflow:"hidden",outline:s.widgetContentContainer.outline,outlineColor:s.widgetContentContainer.outlineColor,borderRadius:s.widgetContentContainer.borderRadius,boxShadow:s.widgetContentContainer.boxShadow,transitionProperty:s.widgetContentContainer.transitionProperty,transitionTimingFunction:s.widgetContentContainer.transitionTimingFunction,transitionDuration:s.widgetContentContainer.transitionDuration,boxSizing:"border-box",borderWidth:"0px"},children:r.jsxs(Ln,{style:{zIndex:s.widgetContentContainer.zIndex},children:[r.jsx(_o,{}),r.jsx(hc,{})]})})})}function Yf(){const{theme:e,triggerSide:t}=me(),{dir:n}=C.useDocumentDir(),{t:o}=G(),s=(n==="rtl"?t==="left":t==="right")?"end":"start";return r.jsx(et.Content,{onInteractOutside:a=>a.preventDefault(),forceMount:!0,style:{zIndex:e.widgetContentContainer.zIndex,fontSize:"16px"},side:"top",align:s,"aria-modal":"false","aria-label":o("support_chat_aria_label"),sideOffset:e.widgetContentContainer.offset.side,alignOffset:e.widgetContentContainer.offset.align,avoidCollisions:!1,children:r.jsx(fc,{})})}function Xf({className:e,style:t}){return r.jsxs("svg",{width:"32",height:"30",viewBox:"0 0 32 30",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:z("text-primary-foreground",e),style:t,children:[r.jsx("path",{d:"M0 6.94263C0 3.62892 2.68629 0.942627 6 0.942627H26C29.3137 0.942627 32 3.62892 32 6.94263V17.9426C32 21.2563 29.3137 23.9426 26 23.9426H6C2.68629 23.9426 0 21.2563 0 17.9426V6.94263Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.9945 23.8935L26.237 23.8934C26.1982 24.3557 26.1712 25.2778 26.1704 26.2318C26.1688 28.2839 26.1376 28.7041 25.974 28.868C25.583 29.2598 25.2686 29.0967 24.0616 27.8754C23.4162 27.2222 22.1141 25.9522 21.1682 25.0531L19.9945 23.8935Z",fill:"currentColor"})]})}function gc(){var t;const{accessibility:e}=C.useConfig();return((t=e==null?void 0:e.widgetTriggerButton)==null?void 0:t.label)??"Chat with us"}function xc(e,t,n,o){return e({react:u,isOpen:t,setIsOpen:s=>n(s),unreadCount:o})}const Gf=io({transparent:!0}),Fr=6,Ls={x:Tt.x+Fr,y:Tt.y+Fr},ar=e=>typeof e=="number"?e-Fr:e;function Kf(){var h,f;const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger(),{assets:n,customComponents:o}=C.useConfig(),{count:s}=C.useUnread(),a=Fn(s),i=Dn()==="count",{theme:c,triggerSide:d}=me(),l=ac(c.widgetTrigger.size.button,i),m=gc(),p=a&&!e?`${m} · ${a}`:m;return o!=null&&o.widgetTrigger?xc(o.widgetTrigger,e,t,s):r.jsx(da,{initialContent:Gf,title:"OpenCX Live Chat Trigger",style:{height:`calc(${c.widgetTrigger.size.button}px + ${Ls.y*2}px)`,width:`calc(${c.widgetTrigger.size.button}px + ${Ls.x*2}px)`,fontSize:"16px",position:"fixed",zIndex:c.widgetTrigger.zIndex,right:ar(c.widgetTrigger.offset.right),bottom:ar(c.widgetTrigger.offset.bottom),left:ar(c.widgetTrigger.offset.left),boxSizing:"border-box",borderWidth:"0px",background:"transparent"},children:r.jsx(Ln,{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsxs(et.PopoverTrigger,{"aria-label":p,title:p,className:z("relative font-sans flex items-center justify-center rounded-full"),style:{height:c.widgetTrigger.size.button,width:c.widgetTrigger.size.button},children:[!e&&r.jsx(So,{count:s,style:{top:l,[d]:l}}),r.jsx(Oe,{children:r.jsx("div",{...L("trigger/btn"),className:z("relative size-full rounded-full","flex items-center justify-center","overflow-hidden","transition-all","bg-primary","text-primary-foreground"),children:r.jsx(F.AnimatePresence,{mode:"wait",children:e?r.jsx(oe,{snapExit:!0,fadeIn:"up",overrides:{initial:{rotate:45},animate:{rotate:0}},children:(h=n==null?void 0:n.widgetTrigger)!=null&&h.closeIcon?r.jsx("img",{src:n.widgetTrigger.closeIcon,alt:"Widget trigger close icon",style:{width:c.widgetTrigger.size.icon,height:c.widgetTrigger.size.icon}}):r.jsx(M.ChevronDownIcon,{style:{width:c.widgetTrigger.size.icon,height:c.widgetTrigger.size.icon}})},"x-icon"):r.jsx(oe,{snapExit:!0,overrides:{initial:{rotate:45},animate:{rotate:0}},children:(f=n==null?void 0:n.widgetTrigger)!=null&&f.openIcon?r.jsx("img",{src:n.widgetTrigger.openIcon,alt:"Widget trigger open icon",style:{width:c.widgetTrigger.size.icon,height:c.widgetTrigger.size.icon}}):r.jsx(Xf,{style:{width:c.widgetTrigger.size.icon,height:c.widgetTrigger.size.icon},className:"mt-0.5 opacity-95"})},"message-icon")})})})]})})})}function Zf(){const{triggerSide:e}=me();return r.jsx(et.Anchor,{style:{position:"fixed",bottom:0,right:e==="right"?0:void 0,left:e==="left"?0:void 0}})}const Jf="[data-opencx-escape-scope]";function Qf(e){var n;const t=e.target;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,Jf))!=null}function eg(e,{state:t,onToggleFullscreen:n}){e.defaultPrevented||t!=="chat"||xt(e,Le["toggle-fullscreen"])&&(e.preventDefault(),n())}function bc(e,{state:t,onDismiss:n,onToggleFullscreen:o}){if(!e.defaultPrevented){if(xt(e,Le["close-panel"])){Qf(e)||n();return}t==="chat"&&xt(e,Le["toggle-fullscreen"])&&(e.preventDefault(),o())}}function tg({panelLayout:e,previousLayout:t,defaultLayout:n,allowedLayouts:o}){if(e!=="fullscreen")return{kind:"close"};const s=[t,n];for(const i of s)if(i!=="fullscreen"&&o.includes(i))return{kind:"layout",layout:i};const a=o.find(i=>i!=="fullscreen");return a?{kind:"layout",layout:a}:{kind:"close"}}function ng({onHeightChange:e,maxHeight:t,onDismiss:n,onToggleFullscreen:o}){const s=u.useRef(null);return u.useLayoutEffect(()=>{var l;const a=s.current;if(!a)return;const i=()=>e(a.offsetHeight);i();const c=(l=a.ownerDocument.defaultView)==null?void 0:l.ResizeObserver;if(!c)return;const d=new c(i);return d.observe(a),()=>d.disconnect()},[e,t]),r.jsx(Ln,{children:r.jsx("div",{ref:s,onKeyDown:a=>bc(a.nativeEvent,{state:"input",onDismiss:n,onToggleFullscreen:o}),"data-companion-questions":!0,style:{maxHeight:t},className:"flex min-w-0 flex-col items-start gap-2 overflow-y-auto p-1",children:r.jsx(rg,{})})})}function rg(){const{initialQuestions:e}=C.useConfig(),t=F.useReducedMotion();return r.jsx(r.Fragment,{children:e==null?void 0:e.filter(n=>n.trim().length>0).map((n,o)=>r.jsx(F.motion.div,{className:"max-w-full",initial:{opacity:0,y:t?0:8},animate:{opacity:1,y:0},transition:{duration:t?0:.3,delay:t?0:.2+Math.min(o,5)*.1,ease:$e},children:r.jsx(Yt,{suggestion:n,type:"button",variant:"secondary",wobble:!1,className:"max-w-full whitespace-normal break-words rounded-full bg-muted-foreground px-4 py-2 text-start text-base text-background hover:bg-foreground [@media(pointer:coarse)]:min-h-12"})},`${n}-${o}`))})}const wc=new WeakSet;function og(e){return wc.has(e)}function $s(e,t=()=>!0){var p;let n=!1;const o=h=>h?"completed":n?"interrupted":"not-started",s=e.getBoundingClientRect(),a=s.left+s.width/2,i=s.top+s.height/2,c={bubbles:!0,cancelable:!0,composed:!0,clientX:a,clientY:i},d=h=>t()?(n=!0,wc.add(h),e.dispatchEvent(h),!0):!1,l=h=>d(new PointerEvent(h,{...c,pointerId:1,pointerType:"mouse",isPrimary:!0})),m=(h,f=0)=>d(new MouseEvent(h,{...c,detail:f,button:0,buttons:1}));return!l("pointerover")||!l("pointerenter")||!m("mouseover")||!m("mousemove")||!l("pointerdown")||!m("mousedown",1)||!t()?o(!1):((p=e.focus)==null||p.call(e),o(l("pointerup")&&m("mouseup",1)&&m("click",1)))}const Eo=u.forwardRef(function({label:t,className:n,...o},s){return r.jsx("button",{ref:s,type:"button","aria-label":t,...o,className:z("flex shrink-0 items-center justify-center rounded-lg","text-secondary-foreground/60 hover:text-secondary-foreground hover:bg-muted","active:scale-[0.97] transition-[background-color,color,transform] duration-150 ease-out",n)})});function dt(e,t,n){return Math.min(Math.max(e,t),n)}const Hr=16,ze=16,tt=32,sg=44,ag=240,ig=440,vc=32,cg=280,lg=420,dg=640,ug=48,ir=12,Ao=400,yc=320,pg=560,mg="#f4f4f5",kc=120,jc=yc+kc+ze*3,nt={pill:999,input:16,fullscreen:16,sidebar:20,compact:20};function To(e,t){if(e.width<=jc)return Math.max(0,e.width-ze*2);const n=e.width-kc-ze*3;return Math.max(0,Math.min(t,n))}function Et(e,t,n=0){return typeof e=="number"&&Number.isFinite(e)?Math.max(n,e):t}function Cc(e,t={}){const n=Math.max(0,e.width),o=Et(t.maxWidth,ig),s=Math.min(o,Et(t.minWidth,cg));return Math.min(n,o,Math.max(s,n-vc))}function hg(e,t,n={}){const o=Math.max(0,e.height),s=Et(n.minHeight,lg),a=Et(n.maxHeight,dg,s),i=Math.min(1,Et(n.viewportHeightRatio,.65)),c=Math.max(0,o-Math.max(0,t)-ug);return Math.min(a,c,Math.max(s,o*i))}function fg(e){const{layout:t,region:n,sidebarWidth:o,bottomOffset:s,compact:a}=e;return t==="fullscreen"?{width:Math.max(0,n.width-Hr*2),height:Math.max(0,n.height-Hr*2),borderRadius:nt.fullscreen}:t==="sidebar"?{width:To(n,o),height:Math.max(0,n.height-ze*2),borderRadius:nt.sidebar}:{width:Cc(n,a),height:hg(n,s,a),borderRadius:Et(a==null?void 0:a.borderRadius,nt.compact)}}function gg(e){const{isChatOpen:t,layout:n,region:o,sidebarWidth:s,sidebarSide:a,bottomOffset:i}=e,c=t?n:"compact",d=To(o,s),l=c==="fullscreen"?Hr:c==="sidebar"?ze:i;return{centerX:c==="sidebar"?a==="left"?ze+d/2:o.width-ze-d/2:o.width/2,bottom:l}}const fe="[data-companion-root]",xg=`
|
|
214
|
+
`;function _f(e){const t=/^#([\da-f])([\da-f])([\da-f])$/i.exec(e),n=t?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:e;if(!/^#[\da-f]{6}$/i.test(n))throw new Error("VoiceOrb colors must be #RGB or #RRGGBB hex colors.");const o=Number.parseInt(n.slice(1),16);return[(o>>16&255)/255,(o>>8&255)/255,(o&255)/255]}function Ef(e,t,n){const o=e.getContext("webgl",{alpha:!0,antialias:!1,premultipliedAlpha:!1,powerPreference:"low-power"});if(!o)throw new Error("WebGL is unavailable in this browser.");let s=!1,a=0,i=0,c=0,d=!0,l=!1,m=!1,p=null,h=null,f=[],x={},g=null,y={width:e.clientWidth,height:e.clientHeight};const w=()=>{h&&o.deleteBuffer(h),p&&o.deleteProgram(p);for(const O of f)o.deleteShader(O);h=null,p=null,f=[]},j=()=>{const O=(I,W)=>{const $=o.createShader(I);if(!$)throw new Error("Could not allocate an orb shader.");if(f.push($),o.shaderSource($,W),o.compileShader($),!o.getShaderParameter($,o.COMPILE_STATUS))throw new Error(o.getShaderInfoLog($)||"Could not compile the orb shader.");return $},P=O(o.VERTEX_SHADER,Sf),B=O(o.FRAGMENT_SHADER,Nf);if(p=o.createProgram(),!p)throw new Error("Could not allocate the orb program.");if(o.attachShader(p,P),o.attachShader(p,B),o.linkProgram(p),!o.getProgramParameter(p,o.LINK_STATUS))throw new Error(o.getProgramInfoLog(p)||"Could not link the orb program.");if(o.useProgram(p),h=o.createBuffer(),!h)throw new Error("Could not allocate the orb buffer.");o.bindBuffer(o.ARRAY_BUFFER,h),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),o.STATIC_DRAW);const E=o.getAttribLocation(p,"a_position");o.enableVertexAttribArray(E),o.vertexAttribPointer(E,2,o.FLOAT,!1,0,0),x=Object.fromEntries(["u_resolution","u_time","u_activity","u_base","u_light","u_dark"].map(I=>[I,o.getUniformLocation(p,I)])),g=null},b=()=>{cancelAnimationFrame(a),a=0,c=0},_=O=>{if(a=0,s||l||!d||document.hidden){c=0;return}try{const P=t();P.animated&&c&&(i+=Math.min(.05,(O-c)/1e3)*P.speed*(1+P.activity*.6)),c=P.animated?O:0;const B=Math.min(window.devicePixelRatio||1,2),E=Math.max(1,Math.round(y.width*B)),I=Math.max(1,Math.round(y.height*B));if((e.width!==E||e.height!==I)&&(e.width=E,e.height=I),o.viewport(0,0,E,I),o.uniform2f(x.u_resolution??null,E,I),o.uniform1f(x.u_time??null,i),o.uniform1f(x.u_activity??null,P.activity),!g||g.some((W,$)=>W!==P.colors[$])){const[W,$,U]=P.colors.map(_f);W&&$&&U&&(o.uniform3fv(x.u_base??null,W),o.uniform3fv(x.u_light??null,$),o.uniform3fv(x.u_dark??null,U),g=P.colors)}o.drawArrays(o.TRIANGLES,0,6),P.animated&&(a=requestAnimationFrame(_))}catch(P){m=!0,b(),n(P instanceof Error?P:new Error(String(P)))}},v=()=>{!s&&!l&&!m&&d&&!document.hidden&&!a&&(a=requestAnimationFrame(_))},k=()=>{document.hidden?b():v()},N=O=>{O.preventDefault(),l=!0,b()},R=()=>{try{w(),j(),l=!1,v()}catch(O){n(O instanceof Error?O:new Error(String(O)))}};try{j()}catch(O){throw w(),O}const T=new ResizeObserver(([O])=>{O&&(y={width:O.contentRect.width,height:O.contentRect.height}),v()});T.observe(e);const A=new IntersectionObserver(([O])=>{d=(O==null?void 0:O.isIntersecting)??!0,d?v():b()});return A.observe(e),e.addEventListener("webglcontextlost",N),e.addEventListener("webglcontextrestored",R),document.addEventListener("visibilitychange",k),v(),{requestDraw:v,dispose:()=>{s=!0,b(),T.disconnect(),A.disconnect(),e.removeEventListener("webglcontextlost",N),e.removeEventListener("webglcontextrestored",R),document.removeEventListener("visibilitychange",k),w()}}}const Af={stiffness:700,damping:50,mass:.5},nr=e=>Number.isFinite(e)?Math.max(0,Math.min(1,e)):0;function Tf({activity:e=0,colors:t,active:n=!0,speed:o=1,className:s,style:a,...i}){const c=F.useReducedMotion()??!1,d=u.useRef(null),l=u.useRef(null),[m,p]=u.useState(!1),h=F.useMotionValue(0),f=F.useSpring(h,Af),x=F.useTransform(f,y=>`translate3d(0, ${-y*2}px, 0) scale(${1+y*.04}, ${1-y*.018})`),g=u.useRef({activity:e,colors:t,active:n,speed:o,reducedMotion:c});return u.useLayoutEffect(()=>{var w;g.current={activity:e,colors:t,active:n,speed:o,reducedMotion:c};const y=n&&!c?nr(F.isMotionValue(e)?e.get():e):0;c?(f.jump(0),h.set(0)):h.set(y),(w=l.current)==null||w.requestDraw()}),u.useEffect(()=>{if(F.isMotionValue(e))return e.on("change",y=>{var w;g.current.active&&!g.current.reducedMotion&&h.set(nr(y)),(w=l.current)==null||w.requestDraw()})},[e,h]),u.useEffect(()=>f.on("change",()=>{var y;return(y=l.current)==null?void 0:y.requestDraw()}),[f]),u.useEffect(()=>{const y=d.current;if(!y)return;const w=j=>{console.error("[voice] orb rendering unavailable",{_e:j.message}),p(!0)};try{l.current=Ef(y,()=>{const j=g.current;return{activity:j.active&&!j.reducedMotion?nr(f.get()):0,colors:j.colors,speed:Number.isFinite(j.speed)?Math.max(0,j.speed):1,animated:j.active&&!j.reducedMotion&&j.speed>0}},w)}catch(j){w(j instanceof Error?j:new Error(String(j)))}return()=>{var j;(j=l.current)==null||j.dispose(),l.current=null}},[f,h]),r.jsx("div",{...i,"aria-hidden":"true",className:z("relative aspect-square shrink-0",s),style:a,children:m?r.jsx("div",{className:"size-full rounded-full bg-primary/80"}):r.jsx(F.motion.div,{className:"size-full",style:{transform:c?"none":x},children:r.jsx("canvas",{ref:d,className:"block size-full"})})})}const Is={h:32,s:88,l:59},If=.09,zf=.04;function Mf(e,t){const n=e.ownerDocument.defaultView;if(!n)return null;const o=n.getComputedStyle(e).getPropertyValue(t).trim(),s=/^(-?[\d.]+)(?:deg)?[\s,]+([\d.]+)%[\s,]+([\d.]+)%/.exec(o);return s?{h:Number(s[1]),s:Number(s[2]),l:Number(s[3])}:null}function rr({h:e,s:t,l:n}){const o=Math.max(0,Math.min(100,t))/100,s=Math.max(0,Math.min(100,n))/100,a=d=>(d+e/30)%12,i=o*Math.min(s,1-s),c=d=>{const l=s-i*Math.max(-1,Math.min(a(d)-3,Math.min(9-a(d),1)));return Math.round(l*255).toString(16).padStart(2,"0")};return`#${c(0)}${c(8)}${c(4)}`}function zs(e){return[rr(e),rr({h:e.h+10,s:Math.min(e.s,90),l:90}),rr({h:e.h-8,s:e.s*.75,l:Math.max(18,e.l-30)})]}function Rf({levelsRef:e,state:t,muted:n,reducedMotion:o,onSpeakingChange:s}){const a=u.useRef(null),i=F.useMotionValue(0),[c,d]=u.useState(()=>zs(Is)),l=u.useRef({state:t,muted:n,reducedMotion:o,onSpeakingChange:s});return l.current={state:t,muted:n,reducedMotion:o,onSpeakingChange:s},u.useEffect(()=>{const m=a.current;m&&d(zs(Mf(m,"--opencx-primary")??Is))},[]),u.useEffect(()=>{var w;const m=(w=a.current)==null?void 0:w.ownerDocument.defaultView;if(!m)return;let p=0,h=0,f=0,x=!1;const g=m.performance.now(),y=j=>{p=m.requestAnimationFrame(y);const{state:b,muted:_,reducedMotion:v,onSpeakingChange:k}=l.current,N=e.current,R=b==="connected"||b==="waiting",T=R&&N?N.remote:0,A=R&&N&&!_?N.local:0;h+=(T-h)*(T>h?.22:.06),f+=(A-f)*(A>f?.3:.08);const O=x?h>zf:h>If;if(O!==x&&(x=O,k(x)),v||b==="ended"||b==="idle"){i.set(0);return}const P=(j-g)/1e3,B=.08+(Math.sin(P*1.1)+1)/2*.1;i.set(Math.min(1,Math.max(B,h*1.6,f*1.1)))};return p=m.requestAnimationFrame(y),()=>m.cancelAnimationFrame(p)},[i,e]),r.jsx("div",{ref:a,className:"size-full",children:r.jsx(Tf,{activity:i,colors:c,active:t!=="ended",className:"size-full"})})}const Pf=48;function Of({segments:e,className:t,style:n}){const o=u.useRef(null),s=u.useRef(!0);return u.useLayoutEffect(()=>{const a=o.current;a&&s.current&&(a.scrollTop=a.scrollHeight)},[e]),r.jsx("div",{...L("voice/transcript"),ref:o,onScroll:a=>{const i=a.currentTarget;s.current=i.scrollHeight-i.scrollTop-i.clientHeight<Pf},className:z("opencx-voice-transcript-mask flex flex-col overflow-y-auto overscroll-contain px-6",t),style:n,children:r.jsx("ol",{className:"mt-auto flex flex-col gap-3 pb-2 pt-12",children:e.map(a=>u.createElement("li",{...L("voice/transcript_line"),key:a.id,"data-role":a.role,"data-final":a.final,className:z("opencx-fade-up flex",a.role==="user"?"justify-end":"justify-start")},r.jsx("p",{dir:"auto",className:z("whitespace-pre-wrap text-pretty break-words",a.role==="user"?"max-w-[85%] rounded-2xl rounded-ee-md bg-secondary px-3.5 py-2 text-[15px] leading-snug text-foreground":"max-w-full text-[17px] font-medium leading-relaxed text-foreground"),children:r.jsx("span",{children:Er(a.text)})})))})})}const Ms="rounded-full p-0 flex items-center justify-center transition-[transform,background-color,color] duration-150";function Lf({connectedAt:e}){const[t,n]=u.useState(()=>Date.now());return u.useEffect(()=>{if(e===null)return;const o=setInterval(()=>n(Date.now()),500);return()=>clearInterval(o)},[e]),r.jsx("span",{dir:"ltr",className:z("text-sm tabular-nums text-muted-foreground transition-opacity duration-200",e===null&&"opacity-0"),children:Ii(e===null?0:t-e)})}const Rs=300,Ps=136,or="cubic-bezier(0.23, 1, 0.32, 1)";function $f(e){return e==="connection_timeout"?"error_timeout":e==="already_started"?"error_busy":"error_generic"}function mc(){var y,w,j,b;const e=Ot(),t=C.useConfig(),{language:n,dir:o}=G(),s=F.useReducedMotion()??!1,[a,i]=u.useState(!1),c=u.useRef(null),d=(_,v)=>fo(n,_,v),l=((y=t.voice)==null?void 0:y.agentName)??((w=t.bot)==null?void 0:w.name)??d("default_agent");u.useEffect(()=>{var _;e.isOpen&&((_=c.current)==null||_.focus({preventScroll:!0}))},[e.isOpen]),u.useEffect(()=>{e.state!=="connected"&&i(!1)},[e.state]);const m=e.state==="ended"||e.state==="idle",p=e.error?d($f(e.error.code)):e.state==="connected"?a?d("speaking",{name:l}):d("listening"):e.state==="waiting"?d("waiting"):e.state==="queued"?d("queued"):e.state==="reconnecting"?d("reconnecting"):d(m?"ended":"connecting"),h=!e.error&&!!((j=t.voice)!=null&&j.greeting)&&e.connectedAt===null&&!m,f=e.transcript.filter(_=>_.text.trim()),x=f.length>0,g=s?"none":`flex-grow 0.5s ${or}, width 0.5s ${or}, height 0.5s ${or}`;return r.jsx(F.AnimatePresence,{children:e.enabled&&e.isOpen&&u.createElement(F.motion.div,{...L("voice/root"),key:"voice-call",role:"dialog","aria-modal":"true","aria-label":l,dir:o,initial:{opacity:0,scale:s?1:1.03},animate:{opacity:1,scale:1,transition:{duration:.32,ease:$e}},exit:{opacity:0,scale:s?1:.98,transition:{duration:.22,ease:$e}},className:"absolute inset-0 z-[60] flex flex-col overflow-hidden bg-background text-foreground",style:{backgroundImage:"radial-gradient(120% 70% at 50% 40%, hsl(var(--opencx-primary) / 0.12), transparent 70%)"}},r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsxs("header",{className:"flex flex-col items-center gap-0.5 px-6 pt-8 text-center",children:[r.jsx("span",{className:"text-base font-semibold text-foreground",children:l}),r.jsx(Lf,{connectedAt:e.connectedAt})]}),r.jsx("div",{className:"relative flex min-h-0 items-center justify-center",style:{flexGrow:1,flexBasis:0,transition:g},children:r.jsx("div",{className:"relative max-w-full",style:{width:x?Ps:Rs,height:x?Ps:Rs,transition:g},children:r.jsx(Rf,{levelsRef:e.levelsRef,state:e.error?"ended":e.state,muted:e.muted,reducedMotion:s,onSpeakingChange:i})})}),r.jsxs("div",{className:z("flex flex-col items-center gap-1 px-6 text-center",!x&&"min-h-[4.5rem]"),children:[r.jsx("div",{"aria-live":"polite",className:"min-h-7",children:r.jsx(F.AnimatePresence,{mode:"wait",initial:!1,children:r.jsx(F.motion.p,{initial:{opacity:0,y:s?0:4},animate:{opacity:1,y:0,transition:ke},exit:{opacity:0,y:s?0:-4,transition:ge},className:z("font-medium text-balance",e.error?"text-destructive text-sm":x?"text-sm text-muted-foreground":"text-lg text-foreground"),children:p},p)})}),h&&!x&&r.jsx("p",{className:"text-sm text-muted-foreground text-balance",children:(b=t.voice)==null?void 0:b.greeting}),e.muted&&!m&&!e.error&&r.jsx("p",{className:"text-xs text-muted-foreground",children:d("muted_hint")})]}),r.jsx(Of,{segments:f,className:"min-h-0",style:{flexGrow:x?1.6:1e-4,flexBasis:0,transition:g}}),r.jsx("div",{className:"flex min-h-14 items-center justify-center px-6 pt-2",children:r.jsx(F.AnimatePresence,{children:e.audioBlocked&&!m&&r.jsx(F.motion.div,{initial:{opacity:0,y:s?0:6},animate:{opacity:1,y:0,transition:ke},exit:{opacity:0,transition:ge},children:r.jsxs(X,{...L("voice/resume_audio_btn"),onClick:e.resumeAudio,className:"min-h-11 rounded-full px-5 shadow-sm",children:[r.jsx(M.Volume2Icon,{className:"size-4"}),d("tap_to_hear")]})})})}),r.jsx("footer",{className:"flex items-center justify-center gap-6 px-6 pb-10 pt-4",children:e.error?r.jsxs(r.Fragment,{children:[r.jsx(X,{...L("voice/back_btn"),variant:"secondary",onClick:e.close,className:"min-h-12 rounded-full px-5",children:d("back_to_chat")}),r.jsxs(X,{...L("voice/retry_btn"),onClick:()=>void e.start(),className:"min-h-12 rounded-full px-5",children:[r.jsx(M.RotateCcwIcon,{className:"size-4"}),d("try_again")]})]}):r.jsxs(r.Fragment,{children:[r.jsx(X,{...L("voice/mute_btn"),variant:"secondary",onClick:e.toggleMute,disabled:m,"aria-pressed":e.muted,"aria-label":e.muted?d("unmute"):d("mute"),className:z(Ms,"size-14",e.muted&&"bg-foreground text-background hover:bg-foreground/90"),children:e.muted?r.jsx(M.MicOffIcon,{className:"size-6"}):r.jsx(M.MicIcon,{className:"size-6"})}),r.jsx(X,{...L("voice/end_btn"),ref:c,variant:"destructive",onClick:()=>void e.end(),disabled:m,"aria-label":d("end_call"),className:z(Ms,"size-16 shadow-lg"),children:r.jsx(M.PhoneOffIcon,{className:"size-7"})})]})})]}))})}const Df=ao(),Ff=()=>{};function hc(){const{isOpen:e}=C.useWidgetTrigger(),{contentIframeRef:t,widgetCtx:n}=C.useWidget(),{inline:o}=C.useConfig(),{theme:s,computed:a}=me();return u.useEffect(()=>{e||n.dictationCtx.stop({executeFinalCommand:!1})},[e,n]),r.jsx(F.motion.div,{onUpdate:Ff,animate:e?"visible":"hidden",initial:"hidden",style:{transformOrigin:o?void 0:"bottom right"},variants:{hidden:{opacity:0,scale:o?1:.9,y:8,transitionEnd:{display:"none"},transition:It},visible:{opacity:1,scale:1,y:0,display:"block",height:o?"100%":void 0,transition:{...It,height:{duration:0}}}},children:r.jsx(la,{ref:t,initialContent:Df,allowFullScreen:!0,title:ci,style:{"--opencx-widget-width":a.minWidth,"--opencx-widget-height":a.minHeight,minWidth:a.minWidth,width:"var(--opencx-widget-width)",maxWidth:a.maxWidth,minHeight:a.minHeight,height:"var(--opencx-widget-height)",maxHeight:a.maxHeight,overflow:"hidden",outline:s.widgetContentContainer.outline,outlineColor:s.widgetContentContainer.outlineColor,borderRadius:s.widgetContentContainer.borderRadius,boxShadow:s.widgetContentContainer.boxShadow,transitionProperty:s.widgetContentContainer.transitionProperty,transitionTimingFunction:s.widgetContentContainer.transitionTimingFunction,transitionDuration:s.widgetContentContainer.transitionDuration,boxSizing:"border-box",borderWidth:"0px"},children:r.jsxs(Ln,{style:{zIndex:s.widgetContentContainer.zIndex},children:[r.jsx(No,{}),r.jsx(mc,{})]})})})}function Hf(){const{theme:e,triggerSide:t}=me(),{dir:n}=C.useDocumentDir(),{t:o}=G(),s=(n==="rtl"?t==="left":t==="right")?"end":"start";return r.jsx(et.Content,{onInteractOutside:a=>a.preventDefault(),forceMount:!0,style:{zIndex:e.widgetContentContainer.zIndex,fontSize:"16px"},side:"top",align:s,"aria-modal":"false","aria-label":o("support_chat_aria_label"),sideOffset:e.widgetContentContainer.offset.side,alignOffset:e.widgetContentContainer.offset.align,avoidCollisions:!1,children:r.jsx(hc,{})})}function Wf({className:e,style:t}){return r.jsxs("svg",{width:"32",height:"30",viewBox:"0 0 32 30",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:z("text-primary-foreground",e),style:t,children:[r.jsx("path",{d:"M0 6.94263C0 3.62892 2.68629 0.942627 6 0.942627H26C29.3137 0.942627 32 3.62892 32 6.94263V17.9426C32 21.2563 29.3137 23.9426 26 23.9426H6C2.68629 23.9426 0 21.2563 0 17.9426V6.94263Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.9945 23.8935L26.237 23.8934C26.1982 24.3557 26.1712 25.2778 26.1704 26.2318C26.1688 28.2839 26.1376 28.7041 25.974 28.868C25.583 29.2598 25.2686 29.0967 24.0616 27.8754C23.4162 27.2222 22.1141 25.9522 21.1682 25.0531L19.9945 23.8935Z",fill:"currentColor"})]})}function fc(){var t;const{accessibility:e}=C.useConfig();return((t=e==null?void 0:e.widgetTriggerButton)==null?void 0:t.label)??"Chat with us"}function gc(e,t,n,o){return e({react:u,isOpen:t,setIsOpen:s=>n(s),unreadCount:o})}const Bf=ao({transparent:!0}),Dr=6,Os={x:Tt.x+Dr,y:Tt.y+Dr},sr=e=>typeof e=="number"?e-Dr:e;function Uf(){var h,f;const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger(),{assets:n,customComponents:o}=C.useConfig(),{count:s}=C.useUnread(),a=Fn(s),i=Dn()==="count",{theme:c,triggerSide:d}=me(),l=sc(c.widgetTrigger.size.button,i),m=fc(),p=a&&!e?`${m} · ${a}`:m;return o!=null&&o.widgetTrigger?gc(o.widgetTrigger,e,t,s):r.jsx(la,{initialContent:Bf,title:"OpenCX Live Chat Trigger",style:{height:`calc(${c.widgetTrigger.size.button}px + ${Os.y*2}px)`,width:`calc(${c.widgetTrigger.size.button}px + ${Os.x*2}px)`,fontSize:"16px",position:"fixed",zIndex:c.widgetTrigger.zIndex,right:sr(c.widgetTrigger.offset.right),bottom:sr(c.widgetTrigger.offset.bottom),left:sr(c.widgetTrigger.offset.left),boxSizing:"border-box",borderWidth:"0px",background:"transparent"},children:r.jsx(Ln,{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsxs(et.PopoverTrigger,{"aria-label":p,title:p,className:z("relative font-sans flex items-center justify-center rounded-full"),style:{height:c.widgetTrigger.size.button,width:c.widgetTrigger.size.button},children:[!e&&r.jsx(Co,{count:s,style:{top:l,[d]:l}}),r.jsx(Oe,{children:r.jsx("div",{...L("trigger/btn"),className:z("relative size-full rounded-full","flex items-center justify-center","overflow-hidden","transition-all","bg-primary","text-primary-foreground"),children:r.jsx(F.AnimatePresence,{mode:"wait",children:e?r.jsx(oe,{snapExit:!0,fadeIn:"up",overrides:{initial:{rotate:45},animate:{rotate:0}},children:(h=n==null?void 0:n.widgetTrigger)!=null&&h.closeIcon?r.jsx("img",{src:n.widgetTrigger.closeIcon,alt:"Widget trigger close icon",style:{width:c.widgetTrigger.size.icon,height:c.widgetTrigger.size.icon}}):r.jsx(M.ChevronDownIcon,{style:{width:c.widgetTrigger.size.icon,height:c.widgetTrigger.size.icon}})},"x-icon"):r.jsx(oe,{snapExit:!0,overrides:{initial:{rotate:45},animate:{rotate:0}},children:(f=n==null?void 0:n.widgetTrigger)!=null&&f.openIcon?r.jsx("img",{src:n.widgetTrigger.openIcon,alt:"Widget trigger open icon",style:{width:c.widgetTrigger.size.icon,height:c.widgetTrigger.size.icon}}):r.jsx(Wf,{style:{width:c.widgetTrigger.size.icon,height:c.widgetTrigger.size.icon},className:"mt-0.5 opacity-95"})},"message-icon")})})})]})})})}function qf(){const{triggerSide:e}=me();return r.jsx(et.Anchor,{style:{position:"fixed",bottom:0,right:e==="right"?0:void 0,left:e==="left"?0:void 0}})}const Vf="[data-opencx-escape-scope]";function Yf(e){var n;const t=e.target;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,Vf))!=null}function Xf(e,{state:t,onToggleFullscreen:n}){e.defaultPrevented||t!=="chat"||xt(e,Le["toggle-fullscreen"])&&(e.preventDefault(),n())}function xc(e,{state:t,onDismiss:n,onToggleFullscreen:o}){if(!e.defaultPrevented){if(xt(e,Le["close-panel"])){Yf(e)||n();return}t==="chat"&&xt(e,Le["toggle-fullscreen"])&&(e.preventDefault(),o())}}function Gf({panelLayout:e,previousLayout:t,defaultLayout:n,allowedLayouts:o}){if(e!=="fullscreen")return{kind:"close"};const s=[t,n];for(const i of s)if(i!=="fullscreen"&&o.includes(i))return{kind:"layout",layout:i};const a=o.find(i=>i!=="fullscreen");return a?{kind:"layout",layout:a}:{kind:"close"}}function Kf({onHeightChange:e,maxHeight:t,onDismiss:n,onToggleFullscreen:o}){const s=u.useRef(null);return u.useLayoutEffect(()=>{var l;const a=s.current;if(!a)return;const i=()=>e(a.offsetHeight);i();const c=(l=a.ownerDocument.defaultView)==null?void 0:l.ResizeObserver;if(!c)return;const d=new c(i);return d.observe(a),()=>d.disconnect()},[e,t]),r.jsx(Ln,{children:r.jsx("div",{ref:s,onKeyDown:a=>xc(a.nativeEvent,{state:"input",onDismiss:n,onToggleFullscreen:o}),"data-companion-questions":!0,style:{maxHeight:t},className:"flex min-w-0 flex-col items-start gap-2 overflow-y-auto p-1",children:r.jsx(Zf,{})})})}function Zf(){const{initialQuestions:e}=C.useConfig(),t=F.useReducedMotion();return r.jsx(r.Fragment,{children:e==null?void 0:e.filter(n=>n.trim().length>0).map((n,o)=>r.jsx(F.motion.div,{className:"max-w-full",initial:{opacity:0,y:t?0:8},animate:{opacity:1,y:0},transition:{duration:t?0:.3,delay:t?0:.2+Math.min(o,5)*.1,ease:$e},children:r.jsx(Yt,{suggestion:n,type:"button",variant:"secondary",wobble:!1,className:"max-w-full whitespace-normal break-words rounded-full bg-muted-foreground px-4 py-2 text-start text-base text-background hover:bg-foreground [@media(pointer:coarse)]:min-h-12"})},`${n}-${o}`))})}const bc=new WeakSet;function Jf(e){return bc.has(e)}function Ls(e,t=()=>!0){var p;let n=!1;const o=h=>h?"completed":n?"interrupted":"not-started",s=e.getBoundingClientRect(),a=s.left+s.width/2,i=s.top+s.height/2,c={bubbles:!0,cancelable:!0,composed:!0,clientX:a,clientY:i},d=h=>t()?(n=!0,bc.add(h),e.dispatchEvent(h),!0):!1,l=h=>d(new PointerEvent(h,{...c,pointerId:1,pointerType:"mouse",isPrimary:!0})),m=(h,f=0)=>d(new MouseEvent(h,{...c,detail:f,button:0,buttons:1}));return!l("pointerover")||!l("pointerenter")||!m("mouseover")||!m("mousemove")||!l("pointerdown")||!m("mousedown",1)||!t()?o(!1):((p=e.focus)==null||p.call(e),o(l("pointerup")&&m("mouseup",1)&&m("click",1)))}const _o=u.forwardRef(function({label:t,className:n,...o},s){return r.jsx("button",{ref:s,type:"button","aria-label":t,...o,className:z("flex shrink-0 items-center justify-center rounded-lg","text-secondary-foreground/60 hover:text-secondary-foreground hover:bg-muted","active:scale-[0.97] transition-[background-color,color,transform] duration-150 ease-out",n)})});function dt(e,t,n){return Math.min(Math.max(e,t),n)}const Fr=16,ze=16,tt=32,Qf=44,eg=240,tg=440,wc=32,ng=280,rg=420,og=640,sg=48,ar=12,Eo=400,vc=320,ag=560,ig="#f4f4f5",yc=120,kc=vc+yc+ze*3,nt={pill:999,input:16,fullscreen:16,sidebar:20,compact:20};function Ao(e,t){if(e.width<=kc)return Math.max(0,e.width-ze*2);const n=e.width-yc-ze*3;return Math.max(0,Math.min(t,n))}function Et(e,t,n=0){return typeof e=="number"&&Number.isFinite(e)?Math.max(n,e):t}function jc(e,t={}){const n=Math.max(0,e.width),o=Et(t.maxWidth,tg),s=Math.min(o,Et(t.minWidth,ng));return Math.min(n,o,Math.max(s,n-wc))}function cg(e,t,n={}){const o=Math.max(0,e.height),s=Et(n.minHeight,rg),a=Et(n.maxHeight,og,s),i=Math.min(1,Et(n.viewportHeightRatio,.65)),c=Math.max(0,o-Math.max(0,t)-sg);return Math.min(a,c,Math.max(s,o*i))}function lg(e){const{layout:t,region:n,sidebarWidth:o,bottomOffset:s,compact:a}=e;return t==="fullscreen"?{width:Math.max(0,n.width-Fr*2),height:Math.max(0,n.height-Fr*2),borderRadius:nt.fullscreen}:t==="sidebar"?{width:Ao(n,o),height:Math.max(0,n.height-ze*2),borderRadius:nt.sidebar}:{width:jc(n,a),height:cg(n,s,a),borderRadius:Et(a==null?void 0:a.borderRadius,nt.compact)}}function dg(e){const{isChatOpen:t,layout:n,region:o,sidebarWidth:s,sidebarSide:a,bottomOffset:i}=e,c=t?n:"compact",d=Ao(o,s),l=c==="fullscreen"?Fr:c==="sidebar"?ze:i;return{centerX:c==="sidebar"?a==="left"?ze+d/2:o.width-ze-d/2:o.width/2,bottom:l}}const fe="[data-companion-root]",ug=`
|
|
215
215
|
${fe} [data-component="chat/msgs/root"] {
|
|
216
216
|
overflow-x: hidden !important;
|
|
217
217
|
}
|
|
@@ -251,12 +251,12 @@ ${fe} [data-component="chat/user_msg/msg"] {
|
|
|
251
251
|
padding: 8px 12px !important;
|
|
252
252
|
border-radius: 10px !important;
|
|
253
253
|
}
|
|
254
|
-
`,
|
|
254
|
+
`,pg=`
|
|
255
255
|
${fe} [data-component="chat/agent_msg_group/root/avatar"],
|
|
256
256
|
${fe} [data-component="chat/agent_msg_group/avatar_and_msgs/avatar"] {
|
|
257
257
|
display: none !important;
|
|
258
258
|
}
|
|
259
|
-
`,
|
|
259
|
+
`,mg=`
|
|
260
260
|
${fe} [data-component="chat/agent_msg_group/avatar_and_msgs/root"] {
|
|
261
261
|
align-items: flex-start !important;
|
|
262
262
|
}
|
|
@@ -283,7 +283,7 @@ ${fe} [data-component="chat/bot_loading/root"] > :first-child {
|
|
|
283
283
|
height: 20px !important;
|
|
284
284
|
margin-top: 2px !important;
|
|
285
285
|
}
|
|
286
|
-
`;function
|
|
286
|
+
`;function $s({layout:e,sidebarSide:t}){const n={width:18,height:18,viewBox:"0 0 18 18",fill:"none","aria-hidden":!0},o=r.jsx("rect",{x:2,y:2.5,width:14,height:13,rx:2.5,stroke:"currentColor",strokeWidth:1.4});return e==="fullscreen"?r.jsxs("svg",{...n,children:[o,r.jsx("rect",{x:4.5,y:5,width:9,height:8,rx:1.4,fill:"currentColor"})]}):e==="sidebar"?r.jsxs("svg",{...n,children:[o,r.jsx("rect",{x:t==="left"?2:10.5,y:2.5,width:5.5,height:13,rx:2.5,fill:"currentColor"})]}):r.jsxs("svg",{...n,children:[o,r.jsx("rect",{x:5,y:9,width:8,height:4.5,rx:1.6,fill:"currentColor"})]})}function hg({side:e}){return r.jsxs("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:[r.jsx("rect",{x:1,y:2,width:12,height:10,rx:2,stroke:"currentColor",strokeWidth:1.2,opacity:.5}),r.jsx("rect",{x:e==="left"?1:8.5,y:2,width:4.5,height:10,rx:2,fill:"currentColor"})]})}function fg({anchored:e,side:t,onSelectSide:n,docked:o,onToggleDock:s}){const{t:a}=G();return r.jsx(F.motion.div,{...L("companion/layout_picker/sidebar_options"),initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.18,ease:$e},style:e?{left:"50%",x:"-50%"}:void 0,className:z("origin-top",e&&"absolute top-full z-10 pt-3"),children:r.jsxs("div",{className:z("flex flex-col gap-1.5 whitespace-nowrap",e&&"rounded-[var(--pk-r)] border bg-background p-[var(--pk-p)] shadow-lg"),children:[r.jsx(Ds,{label:a("companion_sidebar_dock_label"),children:r.jsx(gg,{label:a("companion_sidebar_dock_label"),checked:o,onToggle:s})}),r.jsx(Ds,{label:a("companion_sidebar_side_label"),children:r.jsx(xg,{label:a("companion_sidebar_side_label"),side:t,onSelect:n})})]})})}function Ds({label:e,children:t}){return r.jsxs("div",{className:"flex items-center justify-between gap-4 ps-1.5",children:[r.jsx("span",{"aria-hidden":!0,className:"text-[11px] font-medium leading-none text-secondary-foreground/70",children:e}),t]})}function gg({label:e,checked:t,onToggle:n}){return r.jsx("button",{...L("companion/layout_picker/sidebar_option"),type:"button",role:"switch","aria-checked":t,"aria-label":e,onClick:n,className:z("relative flex h-4 w-7 shrink-0 items-center rounded-full px-0.5","transition-colors duration-150","active:scale-[0.97]",t?"bg-primary":"bg-secondary-foreground/20"),children:r.jsx(F.motion.span,{"aria-hidden":!0,initial:!1,animate:{x:t?12:0},transition:It,className:"size-3 rounded-full bg-background shadow-sm"})})}function xg({label:e,side:t,onSelect:n}){const{t:o}=G(),s=[{value:"left",labelKey:"companion_sidebar_left"},{value:"right",labelKey:"companion_sidebar_right"}];return r.jsx("div",{role:"radiogroup","aria-label":e,className:"flex items-center gap-0.5 rounded-full bg-secondary-foreground/10 p-0.5",children:s.map(({value:a,labelKey:i})=>{const c=a===t;return r.jsxs("button",{...L("companion/layout_picker/sidebar_option"),type:"button",role:"radio","aria-checked":c,"aria-label":o(i),onClick:()=>n(a),className:z("relative flex items-center justify-center rounded-full p-1","transition-colors duration-150","active:scale-[0.97]",c?"text-primary":"text-secondary-foreground/60"),children:[c&&r.jsx(F.motion.span,{"aria-hidden":!0,layoutId:"opencx-sidebar-side-indicator",transition:It,className:"absolute inset-0 rounded-full bg-background shadow-sm"}),r.jsx("span",{className:"relative",children:r.jsx(hg,{side:a})})]},a)})})}const bg={compact:"companion_layout_floating",sidebar:"companion_layout_sidebar",fullscreen:"companion_layout_fullscreen"};function wg(e){try{return e.matches(":focus-visible")}catch{return!0}}function vg({current:e,onSelect:t}){const{t:n}=G(),{allowedLayouts:o,sidebarSide:s,setSidebarSide:a,sidebarMode:i,setSidebarMode:c}=C.useWidgetLayout(),[d,l]=u.useState(!1),m=Pn(),p=o.map(w=>({layout:w,label:bg[w]})),h=p.length>=2,f=o.includes("sidebar");if(!h&&!f)return null;const x=f&&(h?m?d:e==="sidebar":!0),g=w=>{w(),e!=="sidebar"&&t("sidebar")},y=r.jsx(F.AnimatePresence,{initial:!1,children:x&&r.jsx(fg,{anchored:h,side:s,onSelectSide:w=>g(()=>a(w)),docked:i==="docked",onToggleDock:()=>g(()=>c(i==="docked"?"floating":"docked"))})});return r.jsxs(et.Root,{onOpenChange:()=>l(!1),children:[r.jsx(Ne,{content:n("companion_layout_label"),side:"bottom",children:r.jsx(et.Trigger,{asChild:!0,children:r.jsx(_o,{...L("companion/layout_picker/trigger"),label:n("companion_layout_label"),className:"size-7",children:r.jsx($s,{layout:e,sidebarSide:s})})})}),r.jsx(et.Content,{...L("companion/layout_picker/menu"),"data-opencx-escape-scope":"",side:"bottom",align:"end",sideOffset:6,collisionPadding:8,onPointerLeave:()=>l(!1),style:{"--pk-r":"16px","--pk-p":"6px"},className:z("z-50 flex flex-col rounded-[var(--pk-r)] border bg-background p-[var(--pk-p)] shadow-lg","origin-[var(--radix-popover-content-transform-origin)]","animate-in fade-in-0 zoom-in-95","data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95"),children:h?r.jsx("div",{className:"flex items-stretch gap-0.5",children:p.map(({layout:w,label:j})=>{const b=w===e,_=n(j),v=w==="sidebar",k=r.jsx(et.Close,{asChild:!0,children:r.jsxs("button",{...L("companion/layout_picker/option"),type:"button","aria-label":_,"aria-pressed":b,"aria-expanded":v?x:void 0,onClick:()=>t(w),onPointerEnter:()=>l(v),onFocus:N=>l(v&&wg(N.currentTarget)),className:z("flex w-14 flex-col items-center gap-1 rounded-[calc(var(--pk-r)-var(--pk-p))] px-1.5 py-1.5","transition-colors duration-150",b?"bg-primary/10 text-primary":"text-secondary-foreground/60 hover:bg-muted hover:text-secondary-foreground"),children:[r.jsx($s,{layout:w,sidebarSide:s}),r.jsx("span",{className:"whitespace-nowrap text-[10px] font-medium leading-none",children:_})]})});return v?r.jsxs("div",{className:"relative flex",children:[k,y]},w):w!=="fullscreen"?r.jsx(u.Fragment,{children:k},w):r.jsx(Ne,{content:_,shortcut:yo(Le["toggle-fullscreen"]),side:"bottom",children:k},w)})}):y})]})}function yg({layout:e,onSelectLayout:t,onClose:n}){const{t:o}=G();return r.jsxs("div",{...L("companion/controls/root"),className:"absolute top-2 z-10 flex items-center gap-1",style:{insetInlineEnd:8},children:[r.jsx(vg,{current:e,onSelect:t}),r.jsx(Ne,{content:o("companion_close"),shortcut:yo(Le["close-panel"]),side:"bottom",children:r.jsx(_o,{...L("companion/close_btn"),label:o("companion_close"),onClick:n,className:"size-7",children:r.jsx(M.XIcon,{className:"size-4"})})})]})}const kg=`
|
|
287
287
|
/* Quick-ask (resting) composer: the stock card is a two-row layout (textarea
|
|
288
288
|
over an attach/send row) wrapped in outer padding. In the companion pill it
|
|
289
289
|
reads as a single quick-ask bar, so drop the outer pad and lay the card out
|
|
@@ -351,7 +351,7 @@ ${fe} [data-component="chat/bot_loading/root"] > :first-child {
|
|
|
351
351
|
[data-companion-root][data-layout="fullscreen"] [data-component="sessions/list"] {
|
|
352
352
|
padding-inline: max(16px, calc((100% - var(--opencx-companion-content-max-width)) / 2)) !important;
|
|
353
353
|
}
|
|
354
|
-
`;function
|
|
354
|
+
`;function jg({state:e,layout:t,shellRadius:n,onMinimize:o,onDismiss:s,onToggleFullscreen:a,onSelectLayout:i,onExpand:c,canExpand:d,placeholder:l,hideAttachTools:m,onInputHeightChange:p}){const{companion:h}=C.useConfig(),f=Oi(),{t:x}=G(),g=u.useRef(null),y=u.useRef(null),w=u.useRef(null),j=(h==null?void 0:h.bubbles)===!0,b=(h==null?void 0:h.avatars)??j,_=kg+(j?"":ug)+(b?"":pg)+(b&&!j?mg:"");return u.useEffect(()=>{var N;const v=(N=g.current)==null?void 0:N.ownerDocument;if(!v)return;function k(R){xc(R,{state:e,onDismiss:s,onToggleFullscreen:a})}return v.addEventListener("keydown",k),()=>v.removeEventListener("keydown",k)},[s,a,e]),u.useLayoutEffect(()=>{var T;if(e!=="input")return;const v=y.current,k=(T=v==null?void 0:v.ownerDocument.defaultView)==null?void 0:T.ResizeObserver;if(!v||!k)return;const N=()=>p(v.offsetHeight);N();const R=new k(N);return R.observe(v),()=>R.disconnect()},[e,p]),u.useLayoutEffect(()=>{e!=="input"||d||f||ir(y.current)},[e,d,f]),u.useLayoutEffect(()=>{var N;if(e!=="chat"||ir(w.current))return;const v=(N=w.current)==null?void 0:N.ownerDocument.defaultView;if(!v)return;const k=v.requestAnimationFrame(()=>ir(w.current));return()=>v.cancelAnimationFrame(k)},[e]),r.jsx(Ln,{overrides:_,rootRef:g,shellRadius:`${n}px`,children:e==="input"?r.jsxs("div",{ref:y,"data-companion-input":!0,style:{position:"absolute",left:0,right:0,bottom:0,"--opencx-companion-input-radius":`${nt.input}px`},children:[r.jsxs("div",{className:"relative",children:[r.jsx(Uu,{children:r.jsx(Qi,{disabled:f,hideAttachTools:m,placeholder:l,trailingActions:f?r.jsx(_o,{label:x("companion_close"),onClick:s,className:"size-8",children:r.jsx(M.XIcon,{className:"size-4"})}):void 0})}),d?r.jsx("button",{type:"button","aria-label":x("companion_expand_chat"),onClick:c,className:"absolute inset-0 z-10 cursor-pointer"}):null]}),r.jsx(Ir,{})]}):r.jsxs("div",{ref:w,"data-companion-root":!0,"data-layout":t,style:{position:"absolute",inset:0,"--opencx-companion-content-max-width":(h==null?void 0:h.contentMaxWidth)??"48rem"},children:[r.jsx(No,{}),r.jsx(yg,{layout:t,onSelectLayout:i,onClose:o}),r.jsx(mc,{})]})})}function ir(e){const t=e==null?void 0:e.querySelector("textarea");return t?(t.focus({preventScroll:!0}),!0):!1}function Fs({initialContent:e,title:t=ci,style:n,iframeRef:o,children:s}){const[a,i]=u.useState(null),c=u.useCallback(d=>{if(o&&(o.current=d),!d)return;const l=d.contentDocument;l&&(l.open(),l.write(e),l.close(),i(l.body))},[]);return r.jsxs(r.Fragment,{children:[r.jsx("iframe",{ref:c,title:t,style:n,allowFullScreen:!0}),a&&Qt.createPortal(s,a)]})}function Cg({size:e,headColor:t,eyeColor:n}){const o=u.useRef(null),[s,a]=u.useState(!1),[i,c]=u.useState(!1),d=F.useReducedMotion(),l=F.useMotionValue(0),m=F.useMotionValue(0),p=F.useSpring(l,{stiffness:300,damping:30}),h=F.useSpring(m,{stiffness:300,damping:30}),f=F.useTransform(p,b=>8+b*1.2),x=F.useTransform(h,b=>11.5+b*1.2),g=F.useTransform(p,b=>16+b*1.2),y=F.useTransform(h,b=>11.5+b*1.2),w=u.useCallback(b=>{const _=o.current;if(!_)return;const v=_.getBoundingClientRect(),k=v.left+v.width/2,N=v.top+v.height/2,R=(b.clientX-k)/(v.width*2),T=(b.clientY-N)/(v.height*2),A=Math.min(Math.sqrt(R*R+T*T),1),O=Math.atan2(T,R);l.set(Math.cos(O)*A),m.set(Math.sin(O)*A)},[l,m]);u.useEffect(()=>(s&&!d?window.addEventListener("mousemove",w):(l.set(0),m.set(0)),()=>window.removeEventListener("mousemove",w)),[s,w,l,m,d]),u.useEffect(()=>{if(d)return;let b,_;function v(){clearTimeout(b),clearTimeout(_)}function k(){b=setTimeout(()=>{c(!0),_=setTimeout(()=>c(!1),150),k()},1200+Math.random()*1800)}function N(){v(),document.visibilityState==="visible"&&k()}return document.visibilityState==="visible"&&k(),document.addEventListener("visibilitychange",N),()=>{v(),document.removeEventListener("visibilitychange",N)}},[d]);const j=i?.15:1;return r.jsxs("svg",{ref:o,viewBox:"0 0 24 24",style:{width:e,height:e,flexShrink:0,display:"block"},"aria-hidden":!0,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[r.jsx("circle",{cx:12,cy:12,r:11,fill:t}),r.jsx("circle",{cx:8,cy:11.5,r:3.2,fill:n}),r.jsx("circle",{cx:16,cy:11.5,r:3.2,fill:n}),r.jsx(F.motion.circle,{cx:f,cy:x,r:1.4,fill:t,animate:{scaleY:j},style:{originX:"8px",originY:"11.5px"},transition:{duration:.08}}),r.jsx(F.motion.circle,{cx:g,cy:y,r:1.4,fill:t,animate:{scaleY:j},style:{originX:"16px",originY:"11.5px"},transition:{duration:.08}})]})}function Sg({icon:e,pillBackground:t,size:n}){return e?r.jsx("img",{src:e,alt:"",style:{width:n,height:n,objectFit:"cover",borderRadius:999,flexShrink:0}}):r.jsx(Cg,{size:n,headColor:t,eyeColor:"hsl(var(--opencx-primary-foreground))"})}function Ng(e){return{initial:!1,animate:{opacity:e?1:0},transition:{...ge,delay:e?.25:0}}}function _g({visible:e,docked:t,label:n,icon:o,pillBackground:s,dir:a,measureRef:i,activeCount:c=0,countLabel:d,onOpenChats:l,pickerOpen:m=!1,working:p=!1,sessions:h,unreadCount:f=0,unreadShowCount:x=!1}){const g=F.useReducedMotion(),y=Math.max(3,sc(tt,x));return r.jsxs(F.motion.div,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",borderRadius:"inherit",overflow:"hidden",pointerEvents:"none",userSelect:"none",background:"hsl(var(--opencx-background))"},...Ng(e),children:[e&&!t&&c>0&&r.jsx("button",{type:"button","data-companion-count-trigger":"","aria-label":d,"aria-haspopup":"menu","aria-expanded":m,onClick:w=>{w.stopPropagation(),l==null||l(w.currentTarget,w.detail>0)},style:{position:"absolute",insetInlineStart:12,top:0,zIndex:2,width:24,height:24,padding:0,border:0,background:"transparent",pointerEvents:"auto",cursor:"pointer"},children:r.jsxs("span",{"aria-hidden":!0,style:{position:"absolute",insetInlineStart:6,top:0,width:14,height:14,display:"grid",placeItems:"center",borderRadius:999,background:"hsl(var(--opencx-background))",color:"hsl(var(--opencx-foreground))",font:"9px ui-sans-serif,system-ui,sans-serif",fontVariantNumeric:"tabular-nums"},children:[c,p&&r.jsx(F.motion.span,{style:{position:"absolute",inset:-2,display:"flex"},animate:g?void 0:{rotate:360},transition:{duration:1.2,repeat:1/0,ease:"linear"},children:r.jsx(M.LoaderCircleIcon,{size:18})})]})}),r.jsxs("div",{ref:i,dir:a,style:{display:"flex",alignItems:"center",gap:8,height:"100%",width:"max-content",paddingInlineEnd:12,fontFamily:"ui-sans-serif, system-ui, sans-serif"},children:[r.jsxs("span",{style:{position:"relative",display:"flex",flexShrink:0,width:tt,height:tt},children:[r.jsx(Sg,{icon:o,pillBackground:s,size:tt}),e&&f>0&&r.jsxs(r.Fragment,{children:[r.jsx(Hh,{}),r.jsx(ac,{count:f,showCount:x,style:{top:y,insetInlineEnd:y}})]})]}),r.jsx(F.motion.span,{initial:!1,animate:{opacity:t?1:0},transition:{duration:.12,ease:$e},style:{fontSize:13,color:"hsl(var(--opencx-muted-foreground))",whiteSpace:"nowrap"},children:n}),h&&r.jsx("div",{style:{position:"relative",zIndex:2,paddingInlineStart:4,opacity:t?1:0},children:h})]})]})}function Eg({chat:e,number:t,selected:n,interactive:o,onSelect:s,onClose:a,portalTarget:i}){const{t:c}=G(),{cssVars:d,theme:l}=me(),[m,p]=u.useState(!1);u.useEffect(()=>{o||p(!1)},[o]);const{title:h}=io(e),f=`${h}${e.working?` — ${c("thinking")}`:""}`;function x(y){return i&&r.jsx(Ie.Portal,{container:i,children:r.jsxs(Ie.Content,{side:"top",sideOffset:8,collisionPadding:12,"data-companion-session-tooltip":"",style:{...d,zIndex:l.widgetContentContainer.zIndex+2,maxWidth:"min(280px, calc(100vw - 24px))",padding:"7px 10px",borderRadius:9,background:"hsl(var(--opencx-foreground))",color:"hsl(var(--opencx-background))",font:"12px/1.4 ui-sans-serif, system-ui, sans-serif",overflowWrap:"anywhere",textAlign:"center",boxShadow:"0 4px 14px rgb(0 0 0 / .12)"},children:[y,r.jsx(Ie.Arrow,{width:8,height:4,style:{fill:"hsl(var(--opencx-foreground))"}})]})})}const g=c("companion_close_chat",{title:h});return r.jsxs("div",{"data-session-item":"",children:[r.jsxs(Ie.Root,{open:o&&m,onOpenChange:p,children:[r.jsx(Ie.Trigger,{asChild:!0,children:r.jsxs(X,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","data-session-circle":e.id,"aria-label":f,"aria-pressed":n,tabIndex:o?0:-1,onClick:y=>{y.stopPropagation(),s()},children:[e.working&&r.jsx(M.LoaderCircleIcon,{size:28,"aria-hidden":!0,"data-session-working":""}),r.jsx("span",{"aria-hidden":!0,children:t})]})}),x(f)]}),r.jsx(X,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","data-session-close":e.id,"aria-label":g,tabIndex:o?0:-1,onClick:y=>{y.stopPropagation(),p(!1),a(y.currentTarget)},children:r.jsx(M.XIcon,{size:10,"aria-hidden":!0})})]})}function Ag({onSelected:e=()=>{},onLastClosed:t=()=>{},interactive:n=!0}){const{openChats:o,activeId:s,selectChat:a,newChat:i,closeChat:c}=C.useCompanionChats(),{canCreateNewSession:d}=C.useSessions(),{isSmallScreen:l}=je(),{t:m,dir:p}=G(),h=co(),f=$n(),x=l?2:3,g=o.slice(0,o.length>x?x-1:x),y=o.find(k=>k.id===s);y&&!g.includes(y)&&(g[g.length-1]=y);const w=o.length-g.length,j=o.some(k=>k.working&&!g.includes(k)),b=u.useRef(h.close);b.current=h.close,u.useEffect(()=>{n||b.current(!0)},[n]);function _(k){h.close(!0),k===void 0?i():a(k),e()}function v(k,N){var A,O;h.close(!0);const R=g.findIndex(P=>P.id===k),T=g[R+1]??g[R-1];(O=(A=N.closest("[data-companion-session-circles]"))==null?void 0:A.querySelector(T?`[data-session-circle="${T.id}"]`:"[data-new-session]"))==null||O.focus({preventScroll:!0}),c(k),o.length===1&&t()}return r.jsx(Ie.Provider,{delayDuration:150,skipDelayDuration:300,children:r.jsxs("div",{role:"group","aria-label":m("companion_active_chats",{count:o.length}),"aria-hidden":!n||void 0,"data-companion-session-circles":"",dir:p,onPointerDown:k=>k.stopPropagation(),style:{position:"relative",zIndex:0,display:"flex",alignItems:"center",gap:4,flexShrink:0,pointerEvents:n?"auto":"none"},children:[r.jsx(lo,{}),r.jsx("style",{children:`
|
|
355
355
|
[data-companion-session-tooltip][data-state="delayed-open"] { animation: opencx-session-tooltip-in 120ms ease-out; }
|
|
356
356
|
@keyframes opencx-session-tooltip-in { from { opacity: 0; } to { opacity: 1; } }
|
|
357
357
|
@media (prefers-reduced-motion: reduce) { [data-companion-session-tooltip] { animation: none !important; } }
|
|
@@ -400,7 +400,7 @@ ${fe} [data-component="chat/bot_loading/root"] > :first-child {
|
|
|
400
400
|
}
|
|
401
401
|
@keyframes opencx-session-spin { to { transform: rotate(360deg); } }
|
|
402
402
|
@media (prefers-reduced-motion: reduce) { [data-companion-session-circles] [data-session-working] { animation: none; } }
|
|
403
|
-
`}),g.map(k=>r.jsx(
|
|
403
|
+
`}),g.map(k=>r.jsx(Eg,{chat:k,number:k.id,selected:k.id===s,interactive:n,portalTarget:f,onSelect:()=>_(k.id),onClose:N=>v(k.id,N)},k.id)),w>0&&r.jsxs(X,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","aria-label":m("companion_chats"),"aria-haspopup":"menu","aria-expanded":h.open,tabIndex:n?0:-1,onPointerEnter:k=>h.hover(k.currentTarget),onPointerLeave:h.leave,onClick:k=>{k.stopPropagation(),h.toggle(k.currentTarget,k.detail>0)},children:[j&&r.jsx(M.LoaderCircleIcon,{size:28,"aria-hidden":!0,"data-session-working":""}),r.jsxs("span",{"aria-hidden":!0,children:["+",w]})]}),r.jsx(X,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","data-new-session":"","aria-label":m("new_conversation"),disabled:!d,tabIndex:n?0:-1,onClick:k=>{k.stopPropagation(),_()},children:r.jsx(M.PlusIcon,{size:14,"aria-hidden":!0})}),h.anchor&&f&&r.jsx(uo,{picker:h,portalTarget:f,placement:"above",onSelected:e})]})})}function Tg({panelOpen:e,isOpen:t,setIsOpen:n,onOpen:o,onClose:s}){const a=u.useRef(t),i=u.useRef({onOpen:o,onClose:s});i.current={onOpen:o,onClose:s},u.useEffect(()=>{a.current=e,n(e)},[e,n]),u.useEffect(()=>{t!==a.current&&(a.current=t,t?i.current.onOpen():i.current.onClose())},[t])}function To({transcriptVisible:e=!0}){return C.useUnreadViewing({transcriptVisible:e}),null}const mt="data-opencx-app-frame",Ig="data-opencx-app-frame-style",Zt="data-opencx-sidebar-open",zn="data-opencx-frame-no-anim",Jt="data-opencx-fixed-fit",Io="--opencx-sidebar-w",St=Jd;let rt=null,_t=null,Hs=0;const Bt=new Map,Ws={setOpen:()=>{},setWidth:()=>{},setAnimated:()=>{},release:()=>{}};function zg(){let e,t;return Bt.forEach(n=>{(!e||n.order>e.order)&&(e=n),n.open&&(!t||n.order>t.order)&&(t=n)}),t??e}function cr(){const e=zg();if(!e||!rt)return;rt.textContent=Mg(e.canvas,e.side,e.pageBackground);const t=document.documentElement;e.open?t.setAttribute(Zt,""):t.removeAttribute(Zt),e.animated?t.removeAttribute(zn):t.setAttribute(zn,""),t.style.setProperty(Io,`${e.width}px`)}function Bs(e){getComputedStyle(e).position==="fixed"&&e.setAttribute(Jt,"");for(const t of Array.from(e.querySelectorAll("*")))getComputedStyle(t).position==="fixed"&&t.setAttribute(Jt,"")}function Mg(e,t,n){const[o,s]=t==="left"?["right","left"]:["left","right"];return`
|
|
404
404
|
html[${mt}] {
|
|
405
405
|
overflow: hidden !important;
|
|
406
406
|
background: ${e} !important;
|
|
@@ -439,22 +439,22 @@ html[${Zt}] body {
|
|
|
439
439
|
top: ${ze}px !important;
|
|
440
440
|
bottom: ${ze}px !important;
|
|
441
441
|
${o}: ${ze}px !important;
|
|
442
|
-
${s}: calc(var(${
|
|
442
|
+
${s}: calc(var(${Io}, ${Eo}px) + ${ze*2}px) !important;
|
|
443
443
|
border-radius: ${nt.sidebar}px !important;
|
|
444
444
|
box-shadow: 0 0 0 1px rgba(0,0,0,0.06), 0 10px 24px -6px rgba(0,0,0,0.10) !important;
|
|
445
445
|
}
|
|
446
|
-
@media (max-width: ${
|
|
446
|
+
@media (max-width: ${kc}px) {
|
|
447
447
|
html[${Zt}] body {
|
|
448
448
|
inset: 0 !important;
|
|
449
449
|
border-radius: 0 !important;
|
|
450
450
|
box-shadow: 0 0 0 1px rgba(0,0,0,0), 0 10px 24px -6px rgba(0,0,0,0) !important;
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
|
-
`}function Fg({canvas:e,side:t,pageBackground:n}){if(typeof document>"u")return Bs;const o=document.documentElement;if(!rt&&o.hasAttribute(mt))return Bs;if(!rt){const d=document.createElement("style");d.setAttribute(Lg,""),document.head.appendChild(d);const l=window.scrollY;o.setAttribute(mt,""),document.body.scrollTop=l,Us(document.body),_t=new MutationObserver(m=>{for(const p of m)for(const h of Array.from(p.addedNodes))h instanceof Element&&Us(h)}),_t.observe(document.body,{childList:!0,subtree:!0}),rt=d}const s=Symbol("opencx-app-frame-owner"),a={canvas:e,side:t,pageBackground:n,open:!1,width:Ao,animated:!0,order:++Ws};Bt.set(s,a),lr();let i=!1;const c=d=>{if(i)return;const l=Bt.get(s);l&&(d(l),lr())};return{setOpen(d){c(l=>{l.open=d,d&&(l.order=++Ws)})},setWidth(d){c(l=>{l.width=d})},setAnimated(d){c(l=>{l.animated=d})},release(){i||(i=!0,Bt.delete(s),Bt.size===0?Hg():lr())}}}function Hg(){if(!rt)return;const e=document.body.scrollTop,t=document.documentElement;t.removeAttribute(mt),t.removeAttribute(Zt),t.removeAttribute(zn),t.style.removeProperty(zo),_t==null||_t.disconnect(),_t=null;for(const n of Array.from(document.querySelectorAll(`[${Jt}]`)))n.removeAttribute(Jt);rt.remove(),rt=null,window.scrollTo({top:e})}let Wt=0,dr="";function qs(){if(typeof document>"u")return()=>{};Wt===0&&(dr=document.body.style.overflow,document.body.style.overflow="hidden"),Wt+=1;let e=!1;return()=>{e||(e=!0,Wt=Math.max(0,Wt-1),Wt===0&&(document.body.style.overflow=dr,dr=""))}}const Wg="(max-width: 520px)";function Bg(e,t){return e[t]??""}function Ug({companion:e,layout:t,state:n,region:o,sidebarSide:s,sidebarMode:a,cssVars:i,storage:c,resizeLabel:d}){var W,$,U,Y,q,se;const l=Math.max(0,((W=e==null?void 0:e.sidebar)==null?void 0:W.minWidth)??yc),m=Math.max(l,(($=e==null?void 0:e.sidebar)==null?void 0:$.maxWidth)??pg),[p,h]=u.useState(()=>{var D;return dt(((D=e==null?void 0:e.sidebar)==null?void 0:D.width)??Ao,l,m)}),[f,x]=u.useState(!1),g=u.useRef(null);u.useEffect(()=>{h(D=>{var V;return dt(((V=e==null?void 0:e.sidebar)==null?void 0:V.width)??D,l,m)})},[(U=e==null?void 0:e.sidebar)==null?void 0:U.width,m,l]),u.useEffect(()=>{var V;let D=!1;if(!(!c||((V=e==null?void 0:e.sidebar)==null?void 0:V.width)!==void 0))return c.getCompanionSidebarWidth().then(Z=>{D||Z===null||h(dt(Z,l,m))}).catch(()=>{}),()=>{D=!0}},[(Y=e==null?void 0:e.sidebar)==null?void 0:Y.width,m,l,c]);const y=u.useCallback(D=>dt(s==="left"?D:window.innerWidth-D,l,m),[m,l,s]),w=u.useCallback(D=>{var V;D.currentTarget.setPointerCapture(D.pointerId),x(!0),(V=g.current)==null||V.setAnimated(!1)},[]),j=u.useCallback(D=>{D.currentTarget.hasPointerCapture(D.pointerId)&&h(y(D.clientX))},[y]),b=u.useCallback(D=>{var Z;const V=y(D.clientX);D.currentTarget.hasPointerCapture(D.pointerId)&&D.currentTarget.releasePointerCapture(D.pointerId),h(V),x(!1),(Z=g.current)==null||Z.setAnimated(!0),c==null||c.setCompanionSidebarWidth(V).catch(()=>{})},[c,y]),_=u.useCallback(D=>{var V;D.currentTarget.hasPointerCapture(D.pointerId)&&D.currentTarget.releasePointerCapture(D.pointerId),x(!1),(V=g.current)==null||V.setAnimated(!0)},[]),v=u.useCallback(D=>{let V=null;if(D.key==="Home"&&(V=l),D.key==="End"&&(V=m),D.key==="ArrowLeft"||D.key==="ArrowRight"){const Z=D.key===(s==="left"?"ArrowRight":"ArrowLeft");V=dt(p+(Z?16:-16),l,m)}V!==null&&(D.preventDefault(),h(V),c==null||c.setCompanionSidebarWidth(V).catch(()=>{}))},[m,l,s,p,c]),k=t==="sidebar",N=a==="docked",R=To(o,p),T=((q=e==null?void 0:e.sidebar)==null?void 0:q.canvasColor)??mg,A=`hsl(${Bg(i,"--opencx-background")})`,O=u.useRef({open:n!=="pill",width:R});O.current={open:n!=="pill",width:R},u.useEffect(()=>{if(!k||!N)return;const D=Fg({canvas:T,side:s,pageBackground:A});return g.current=D,D.setWidth(O.current.width),D.setOpen(O.current.open),()=>{g.current===D&&(g.current=null),D.release()}},[T,N,k,A,s]),u.useEffect(()=>{var D;k&&N&&((D=g.current)==null||D.setWidth(R))},[R,N,k]),u.useEffect(()=>{var D;k&&N&&((D=g.current)==null||D.setOpen(n!=="pill"))},[N,k,n]);const P=n==="chat"&&t==="fullscreen",B=((se=e==null?void 0:e.fullscreen)==null?void 0:se.lockScroll)!==!1;u.useEffect(()=>{if(!(!P||!B))return qs()},[P,B]);const E=n==="chat"&&t==="compact";u.useEffect(()=>{if(!(!E||!B)&&!(typeof window>"u"||!window.matchMedia(Wg).matches))return qs()},[E,B]);const I=u.useMemo(()=>({role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":d,"aria-valuemin":l,"aria-valuemax":m,"aria-valuenow":p,onPointerDown:w,onPointerMove:j,onPointerUp:b,onPointerCancel:_,onKeyDown:v}),[m,l,v,w,j,_,b,d,p]);return{sidebarWidth:p,sidebarResizing:f,resizeHandleProps:I}}const qg={width:1440,height:900};function Vs(){return typeof window>"u"?qg:{width:window.innerWidth,height:window.innerHeight}}function Vg(){const[e,t]=u.useState(Vs),[n,o]=u.useState(null),s=u.useRef(null),a=u.useCallback(c=>{var l;if((l=s.current)==null||l.disconnect(),s.current=null,!c)return;const d=new ResizeObserver(()=>{o(c.offsetWidth)});d.observe(c),s.current=d},[]);u.useEffect(()=>{function c(){t(Vs())}return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]),u.useEffect(()=>()=>{var c;(c=s.current)==null||c.disconnect(),s.current=null},[]);const i=Math.min(n??ag,Math.max(0,e.width-vc));return{region:e,dockWidth:i,dockContentRef:a}}function Yg({storage:e,state:t,layout:n,viewportWidth:o,currentWidth:s,restingWidth:a,shouldReduceMotion:i}){const[c,d]=u.useState(0),l=F.useMotionValue(0),m=u.useRef(!1);u.useEffect(()=>{let y=!1;if(e)return e.getCompanionPillOffsetX().then(w=>{y||w===null||d(w)}).catch(()=>{}),()=>{y=!0}},[l,e]),u.useEffect(()=>{const y=i?ge:It;if(t==="pill"){const j=Math.max(0,o/2-a/2-ir),b=dt(c,-j,j);Math.abs(l.get())>j?l.set(b):F.animate(l,b,y);return}if(t==="chat"&&(n==="fullscreen"||n==="sidebar")){F.animate(l,0,y);return}const w=Math.max(0,o/2-s/2-ir);F.animate(l,dt(c,-w,w),y)},[s,l,n,c,a,i,t,o]);const p=Math.max(0,o/2-a/2-ir),h=u.useMemo(()=>({left:-p,right:p,top:0,bottom:0}),[p]),f=u.useCallback(()=>{m.current=!0},[]),x=u.useCallback(()=>{const y=l.get();d(w=>w===y?w:y),e==null||e.setCompanionPillOffsetX(y).catch(()=>{}),requestAnimationFrame(()=>{m.current=!1})},[l,e]),g=u.useCallback(()=>m.current,[]);return{dragX:l,dragConstraints:h,onDragStart:f,onDragEnd:x,shouldIgnoreLaunch:g}}function Xg({state:e,layout:t,sidebarMode:n,isPageMarkModeArmed:o}){return e==="pill"||o?!1:!(t==="sidebar"&&n==="docked")}const Gg=96,Ys=io({transparent:!0});function Kg(){var Oo,Lo,$o;const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger(),{openChats:n,activeId:o}=C.useCompanionChats(),s=n.length,{count:a}=C.useUnread(),i=n.filter(re=>re.working).length,{widgetCtx:c,contentIframeRef:d}=C.useWidget(),{companion:l,assets:m,customComponents:p,initialQuestions:h}=C.useConfig(),{theme:f,cssVars:x}=me(),{t:g,dir:y}=G(),{sessionState:w}=C.useSessions(),{messagesState:j}=C.useMessages(),{isArmed:b}=jo(),{region:_,dockWidth:v,dockContentRef:k}=Vg(),[N,R]=u.useState(e?"chat":"pill"),{layout:T,setLayout:A,setLayoutPreference:O,allowedLayouts:P,defaultLayout:B,sidebarSide:E,sidebarMode:I}=C.useWidgetLayout(),[W,$]=u.useState(Gg),{sidebarWidth:U,sidebarResizing:Y,resizeHandleProps:q}=Ug({companion:l,layout:T,state:N,region:_,sidebarSide:E,sidebarMode:I,cssVars:x,storage:c.storageCtx,resizeLabel:g("companion_resize_chat")}),se=F.useReducedMotion(),D=Y?{duration:0}:se?ge:It,V=Pn(),Z=u.useRef(null),te=u.useRef(!1),ae=N==="pill",xe=N==="input"&&j.messages.length===0&&(h==null?void 0:h.some(re=>re.trim().length>0))===!0,[H,ee]=u.useState(0),J=s>0,ne=lo(),le=u.useRef(ne.close);le.current=ne.close,u.useEffect(()=>{(!ae||!J)&&le.current(!0)},[ae,J]);const de=p==null?void 0:p.widgetTrigger,ie=!!de,De=(l==null?void 0:l.pillBackground)??"hsl(var(--opencx-primary))",Fe=(l==null?void 0:l.icon)??((Oo=m==null?void 0:m.widgetTrigger)==null?void 0:Oo.openIcon),pe=f.widgetTrigger.offset.bottom,Ve=Dn(),st=Fn(a),Ye=gc(),He=st?`${Ye} · ${st}`:Ye,Xe=!!((Lo=w.session)!=null&&Lo.id),Ge=Xe?g("follow_up_placeholder"):void 0,we=(l==null?void 0:l.pillLabel)??(l==null?void 0:l.placeholder)??Ge??g("write_a_message_placeholder"),Re=(l==null?void 0:l.pillLabelDisplay)??"always",We=(l==null?void 0:l.placeholder)??Ge??g("write_a_message_placeholder"),[Wn,dn]=u.useState(!1),ve=ae&&!ie&&Re!=="never"&&(Re==="always"||V&&Wn),Lt=Cc(_,l==null?void 0:l.compact),$t=T==="sidebar",wt=fg({layout:T,region:_,sidebarWidth:U,bottomOffset:pe,compact:l==null?void 0:l.compact}),un=N==="chat"?wt.width:Lt,Bn=wt.height,{centerX:Un,bottom:qn}=gg({isChatOpen:N==="chat",layout:T,region:_,sidebarWidth:U,sidebarSide:E,bottomOffset:pe}),Ce=u.useMemo(()=>N==="pill"?ve?{width:v,height:sg,borderRadius:nt.pill}:{width:tt,height:tt,borderRadius:nt.pill}:N==="input"?{width:Lt,height:W,borderRadius:nt.input}:wt,[N,ve,v,Lt,wt,W]),pn=N==="pill"&&ve&&Re==="hover"?(y==="rtl"?-1:1)*(v-tt)/2:0,{dragX:Q,dragConstraints:be,onDragStart:Dt,onDragEnd:Be,shouldIgnoreLaunch:Pe}=Yg({storage:c.storageCtx,state:N,layout:T,viewportWidth:_.width,currentWidth:Ce.width,restingWidth:ve?v:tt,shouldReduceMotion:se}),at=u.useCallback(()=>{var Ht;const re=c.routerCtx.state.get().screen,ue=!!((Ht=c.sessionCtx.sessionState.get().session)!=null&&Ht.id);R(re==="welcome"||ue?"chat":"input")},[c]),Ee=u.useCallback(()=>{if(!Pe()){if(le.current(!0),T==="sidebar"){R("chat");return}at()}},[at,T,Pe]),vt=u.useCallback(()=>{if(T==="fullscreen"&&B!=="fullscreen"){A(B);return}if(T==="sidebar"){R("pill");return}R(re=>{var ue;return re==="chat"&&((ue=c.sessionCtx.sessionState.get().session)!=null&&ue.id)?"input":"pill"})},[B,T,A,c]),it=u.useCallback(()=>{const re=tg({panelLayout:T,previousLayout:jt.current,defaultLayout:B,allowedLayouts:P});if(re.kind==="layout"){A(re.layout);return}R("pill")},[P,B,T,A]),mn=u.useCallback(()=>{R("pill")},[]);u.useEffect(()=>{N==="chat"&&(te.current=!0)},[N]),u.useEffect(()=>{N!=="chat"&&te.current&&T==="fullscreen"&&B!=="fullscreen"&&A(B)},[B,T,A,N]);const Ft=N==="chat"&&T==="fullscreen";Og({panelOpen:N!=="pill",isOpen:e,setIsOpen:t,onOpen:at,onClose:mn}),u.useEffect(()=>{if(!Xg({state:N,layout:T,sidebarMode:I,isPageMarkModeArmed:b}))return;function re(ue){if(og(ue))return;const Ht=Z.current;Ht&&(ue.composedPath().includes(Ht)||vt())}return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[vt,N,T,I,b]);const yt=(($o=j.messages.findLast(re=>re.type==="USER"))==null?void 0:$o.id)??null,he=u.useRef(null);u.useEffect(()=>{N==="input"&&(he.current=yt)},[N]),u.useEffect(()=>{N==="input"&&yt!==he.current&&(c.routerCtx.state.get().screen!=="chat"&&c.routerCtx.state.setPartial({screen:"chat"}),R("chat"))},[yt,N,c]);const{isOpen:kt}=Ot();u.useEffect(()=>{kt&&R("chat")},[kt]);const Ac=u.useCallback(()=>{var re;c.routerCtx.state.get().screen!=="chat"&&((re=c.sessionCtx.sessionState.get().session)!=null&&re.id)&&c.routerCtx.state.setPartial({screen:"chat"}),R("chat")},[c]),hn=u.useCallback(re=>{var ue;P.includes(re)&&(re==="fullscreen"&&c.routerCtx.state.get().screen==="sessions"&&c.routerCtx.toChatScreen((ue=c.sessionCtx.sessionState.get().session)==null?void 0:ue.id),O(re))},[P,c,O]),Vn=P.find(re=>re!=="fullscreen"),jt=u.useRef(Vn??B);u.useEffect(()=>{T!=="fullscreen"&&P.includes(T)?jt.current=T:(jt.current==="fullscreen"||!P.includes(jt.current))&&(jt.current=Vn??B)},[P,B,Vn,T]);const fn=u.useCallback(()=>{if(!P.includes("fullscreen"))return;if(T!=="fullscreen"){hn("fullscreen");return}const re=jt.current;re!=="fullscreen"&&P.includes(re)&&hn(re)},[P,T,hn]);u.useEffect(()=>{function re(ue){eg(ue,{state:N,onToggleFullscreen:fn})}return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[fn,N]);const Yn=$n();return Yn?Qt.createPortal(r.jsxs(r.Fragment,{children:[r.jsx(Io,{transcriptVisible:N==="chat"}),de&&xc(de,e,t,a),ae&&ne.anchor&&!ie&&r.jsx(po,{placement:"above",picker:ne,portalTarget:Yn,onSelected:()=>R("chat")}),r.jsx(F.motion.div,{"aria-hidden":!0,style:{position:"fixed",inset:0,background:"transparent",zIndex:f.widgetContentContainer.zIndex,pointerEvents:Ft?"auto":"none"},initial:!1,animate:{opacity:Ft?1:0},transition:ke}),r.jsxs(F.motion.div,{ref:Z,style:{...x,position:"fixed",x:Q,translateX:"-50%",zIndex:f.widgetContentContainer.zIndex,visibility:ie&&ae?"hidden":void 0},initial:!1,animate:{left:Un,bottom:qn},drag:ae&&!ie&&!ne.open?"x":!1,dragMomentum:!1,dragElastic:.15,dragConstraints:be,onDragStart:Dt,onDragEnd:Be,transition:D,children:[xe&&r.jsx("div",{"data-companion-starters":!0,style:{position:"absolute",bottom:"calc(100% + 12px)",left:"50%",transform:"translateX(-50%)",width:un,height:H},children:r.jsx(Hs,{title:"Suggested questions",initialContent:Ys,style:{width:"100%",height:"100%",border:0,background:"transparent"},children:r.jsx(ng,{onHeightChange:ee,onDismiss:it,onToggleFullscreen:fn,maxHeight:Math.max(48,_.height-Ce.height-pe-32)})})}),r.jsxs(F.motion.div,{onPointerEnter:ae&&!ie?re=>{dn(!0);const ue=re.currentTarget.querySelector("[data-companion-count-trigger]");ue&&!Pe()&&ne.hover(ue)}:void 0,onPointerLeave:()=>{dn(!1),ne.leave()},style:{position:"relative",overflow:"hidden",transformOrigin:"center bottom",cursor:ae&&!ie?ve?"pointer":"grab":"default",background:"hsl(var(--opencx-background))"},initial:!1,animate:{x:pn,width:Ce.width,height:Ce.height,borderTopLeftRadius:Ce.borderRadius,borderTopRightRadius:Ce.borderRadius,borderBottomLeftRadius:Ce.borderRadius,borderBottomRightRadius:Ce.borderRadius,boxShadow:ae?ve?au:su:N==="input"?iu:cu},whileHover:ae&&!ie&&V&&!se?{scale:ve?1.01:1.12}:void 0,whileTap:ae&&!ie?{scale:ve?.995:.92}:void 0,transition:D,children:[ae&&!ie&&r.jsx("button",{type:"button","data-companion-launcher":"",onClick:Ee,"aria-label":He,"aria-expanded":!1,style:{position:"absolute",inset:0,zIndex:1,border:0,padding:0,background:"transparent",cursor:"pointer",borderRadius:"inherit"}}),!ie&&r.jsx(Mg,{visible:ae,docked:ve,label:we,sessions:s>0?r.jsx(Pg,{interactive:ae&&ve,onSelected:()=>R("chat"),onLastClosed:()=>{requestAnimationFrame(()=>{var re,ue;(ue=(re=Z.current)==null?void 0:re.querySelector("[data-companion-launcher]"))==null||ue.focus({preventScroll:!0})})}}):void 0,activeCount:s,countLabel:`${g("companion_chats")} · ${g("companion_active_chats",{count:s})}${i?` · ${g("companion_working_chats",{count:i})}`:""}`,pickerOpen:ne.open,onOpenChats:(re,ue)=>{Pe()||ne.toggle(re,ue)},working:i>0,icon:Fe,pillBackground:De,dir:y,measureRef:k,unreadCount:Ve===!1?0:a,unreadShowCount:Ve==="count"}),N!=="pill"&&r.jsx(F.motion.div,{style:{position:"absolute",bottom:0,left:"50%",translateX:"-50%",width:un,height:Bn},initial:{opacity:0},animate:{opacity:1,transition:{...ge,delay:se?0:.1}},children:r.jsx(Hs,{iframeRef:d,initialContent:Ys,style:{width:"100%",height:"100%",overflow:"hidden",backgroundColor:"transparent",boxSizing:"border-box",borderWidth:"0px"},children:r.jsx(Ag,{state:N==="chat"?"chat":"input",layout:T,shellRadius:Ce.borderRadius,onMinimize:vt,onDismiss:it,onToggleFullscreen:fn,onSelectLayout:hn,onExpand:Ac,canExpand:Xe,placeholder:We,hideAttachTools:((l==null?void 0:l.quickAskTools)??"history-only")==="history-only",onInputHeightChange:$},o)})}),$t&&N==="chat"&&r.jsx("div",{...q,style:{position:"absolute",top:0,bottom:0,...E==="left"?{right:0}:{left:0},width:8,cursor:"ew-resize",zIndex:2}})]})]})]}),Yn):null}function Zg(e){const t=e.getBoundingClientRect(),n=t.left+t.width/2,o=t.top+t.height/2,s=e.ownerDocument,a=s.documentElement.clientWidth||window.innerWidth,i=s.documentElement.clientHeight||window.innerHeight;if(n<0||o<0||n>a||o>i||typeof s.elementFromPoint!="function")return!0;const c=s.elementFromPoint(n,o);return c?c===e||e.contains(c)||c.contains(e):!0}function Wr(e){const t=Ui(e);if(!t)return{ok:!1,reason:"gone"};const{element:n}=t,o=Or(n);if(o)return{ok:!1,reason:"off-limits",detail:Hm[o]};const s=typeof n.checkVisibility=="function"?n.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}):n.isConnected,a=n.getBoundingClientRect();return!s||a.width===0||a.height===0?{ok:!1,reason:"hidden"}:Zg(n)?t.isCurrent?{ok:!0,element:n}:{ok:!1,reason:"gone"}:{ok:!1,reason:"covered"}}function Xs(e,t){var s;const n=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:null;if(!n)return!1;const o=(s=Object.getOwnPropertyDescriptor(n,"value"))==null?void 0:s.set;return o?(o.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),!0):!1}function Br(e,t){if(!(e instanceof HTMLSelectElement)||t===void 0)return null;const n=Array.from(e.options),o=n.filter(a=>a.value===t||a.label.trim().toLowerCase()===t.trim().toLowerCase()),[s]=o;return o.length!==1||!s||s.disabled||s.parentElement instanceof HTMLOptGroupElement&&s.parentElement.disabled||n.filter(a=>a.value===s.value).length!==1?null:s}function kn(e,t,n){const o=e.ownerDocument,s=h=>h.contains(e)||e.contains(h)||(e.getAttribute("aria-controls")??"").split(/\s+/).some(f=>{const x=o.getElementById(f);return x!==null&&(h.contains(x)||x.contains(h))}),a=Array.from(o.querySelectorAll('[aria-busy="true"]')).filter(h=>!Me(h)&&!s(h)),i=h=>{for(let f=a.length-1;f>=0;f--)s(a[f])&&a.splice(f,1);return a.some(f=>f.contains(h))};let c=!1,d=performance.now(),l;const m=new MutationObserver(h=>{h.some(x=>{const g=x.target instanceof Element?x.target:x.target.parentElement;return g!==null&&!cn(g)&&!i(g)})&&(c=!0,d=performance.now())});m.observe(o.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});const p=()=>{clearTimeout(l),m.disconnect()};return{settle:()=>new Promise(h=>{const f=performance.now()+t,x=()=>{if(!n()){p(),h({mutated:c,loading:!1});return}const g=Array.from(o.querySelectorAll('[aria-busy="true"]')).some(w=>!i(w)&&!Me(w)),y=performance.now();y>=f||!g&&y-d>=100?(p(),h({mutated:c,loading:g})):l=setTimeout(x,Math.min(100,f-y))};l=setTimeout(x,Math.min(100,t))}),cancel:p}}function Jg(e){if(e.tagName.toLowerCase()==="input"){const t=(e.getAttribute("type")??"text").toLowerCase();if(Fi.has(t))return"Password and file fields are never filled or clicked by the agent."}return e.ownerDocument!==document?"That control is inside another site embedded in this page.":null}async function Qg(e){try{return await ex(e)}catch{return{outcome:"unsupported",detail:"That could not be done on this page."}}}async function ex({ref:e,action:t,value:n,settleMs:o=Em,consentIsCurrent:s=()=>!0,observationIsCurrent:a=()=>!0}){var x;if(!s())return{outcome:"declined"};const i=Wr(e);if(!i.ok)return i.reason==="off-limits"?{outcome:"unsupported",detail:i.detail}:{outcome:i.reason};const c=i.element,d=Jg(c);if(d)return{outcome:"unsupported",detail:d};const l=c.ownerDocument,m=l.location.href;let p,h,f=!1;try{switch(t){case"click":{p=kn(c,o,a);const j=$s(c,s);if(j==="not-started")return p.cancel(),{outcome:"declined"};f=j==="interrupted";break}case"fill":{if(n===void 0)return{outcome:"unsupported",detail:"No value was given to type."};if(p=kn(c,o,a),(x=c.focus)==null||x.call(c),!s()){f=!0;break}if(!Xs(c,n))return p.cancel(),{outcome:"unsupported",detail:"That control is not something text can be typed into."};break}case"select":{if(!(c instanceof HTMLSelectElement))return{outcome:"unsupported",detail:"That control is not a dropdown."};if(n===void 0)return{outcome:"unsupported",detail:"No option was given to choose."};const j=Br(c,n);if(!j)return{outcome:"no_change",detail:"That option is not in the list or cannot be selected unambiguously."};p=kn(c,o,a),h=j.value,Xs(c,j.value);break}case"check":case"uncheck":{const j=t==="check",b=c instanceof HTMLInputElement&&(c.type==="checkbox"||c.type==="radio")?c:null,_=c.getAttribute("aria-checked");if(!b&&_===null)return{outcome:"unsupported",detail:"That control is not a checkbox or switch."};if((b?b.checked:_==="true")===j)return{outcome:"no_change",detail:`It is already ${j?"on":"off"}.`};p=kn(c,o,a);const k=$s(c,s);if(k==="not-started")return p.cancel(),{outcome:"declined"};f=k==="interrupted";break}}const{mutated:g,loading:y}=await(p==null?void 0:p.settle())??{mutated:!1,loading:!1};if(f)return{outcome:"no_change",detail:(g||l.location.href!==m?"The page changed. ":"")+"The requested action was interrupted after input events were dispatched. Its final result is unknown. Do not repeat it automatically."};const w=y?"The page is still loading. The action was dispatched; its final result is unknown. Do not repeat it automatically.":void 0;if(t==="fill"||t==="select"){const j=c instanceof HTMLInputElement||c instanceof HTMLTextAreaElement||c instanceof HTMLSelectElement?c.value:null;return t==="fill"&&j!==n?{outcome:"no_change",detail:"The field did not keep what was typed."}:t==="select"&&j!==h?{outcome:"no_change",detail:"The dropdown did not keep the selected option."}:{outcome:"done",...w?{detail:w}:{}}}if(t==="check"||t==="uncheck"){const j=t==="check",b=c instanceof HTMLInputElement&&(c.type==="checkbox"||c.type==="radio")?c:null;return(b?b.checked:c.getAttribute("aria-checked")==="true")===j?{outcome:"done",...w?{detail:w}:{}}:{outcome:"no_change",detail:"It did not change."}}return g||l.location.href!==m?{outcome:"done",...w?{detail:w}:{}}:{outcome:"no_change",detail:w??"The control was clicked and nothing on the page changed during observation. Its final result is unknown. Do not repeat it automatically."}}finally{p==null||p.cancel()}}const tx="cubic-bezier(0.32, 0.72, 0, 1)",ur=260,nx=1600,rx=180,Gs=240,Ks=.13,ox=e=>e*e*e*(10-15*e+6*e*e);function sx(e,t,n,o){const s=1-o;return{x:s*s*e.x+2*s*o*t.x+o*o*n.x,y:s*s*e.y+2*s*o*t.y+o*o*n.y}}function ax(e,t,n=48){const o=t.x-e.x,s=t.y-e.y,a=Math.hypot(o,s)||1,i={x:e.x+o/2-s/a*a*Ks,y:e.y+s/2+o/a*a*Ks},c=[];for(let d=0;d<=n;d+=1){const l=sx(e,i,t,ox(d/n));c.push({transform:`translate(${l.x-Sn}px, ${l.y-Nn}px)`})}return c}const Sn=2,Nn=1.7,ix="M2 1.7 L9.6 8 L6.5 8.4 L7.7 11 L6.3 11.6 L5.1 9 L2.6 10.6 Z";function Mo(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const Zs=e=>new Promise(t=>{window.setTimeout(t,Mo()?0:e)});let ht=null,Ur;const cx=4e3;function Mn(){clearTimeout(Ur),ht==null||ht.release(),ht=null,document.querySelectorAll("[data-opencx-cursor]").forEach(e=>e.remove())}function qr(){clearTimeout(Ur),Ur=setTimeout(Mn,cx)}function lx(e){if(ht)return qr(),ht;try{Mn();const t=document.createElement("div");t.setAttribute("data-opencx-overlay",""),t.setAttribute("data-opencx-cursor",""),t.setAttribute("aria-hidden","true"),Object.assign(t.style,{position:"fixed",inset:"0",overflow:"hidden",pointerEvents:"none",zIndex:"2147483646",contain:"strict"});const n=document.createElement("div");n.setAttribute("data-opencx-cursor-tip",""),Object.assign(n.style,{position:"absolute",left:"0",top:"0",width:"14px",height:"14px",pointerEvents:"none",opacity:"0",transition:`opacity ${ur}ms ease`,willChange:"transform"}),t.appendChild(n),n.innerHTML=`<svg viewBox="0 0 14 14" width="14" height="14" style="display:block">
|
|
454
|
-
<path d="${
|
|
453
|
+
`}function Rg({canvas:e,side:t,pageBackground:n}){if(typeof document>"u")return Ws;const o=document.documentElement;if(!rt&&o.hasAttribute(mt))return Ws;if(!rt){const d=document.createElement("style");d.setAttribute(Ig,""),document.head.appendChild(d);const l=window.scrollY;o.setAttribute(mt,""),document.body.scrollTop=l,Bs(document.body),_t=new MutationObserver(m=>{for(const p of m)for(const h of Array.from(p.addedNodes))h instanceof Element&&Bs(h)}),_t.observe(document.body,{childList:!0,subtree:!0}),rt=d}const s=Symbol("opencx-app-frame-owner"),a={canvas:e,side:t,pageBackground:n,open:!1,width:Eo,animated:!0,order:++Hs};Bt.set(s,a),cr();let i=!1;const c=d=>{if(i)return;const l=Bt.get(s);l&&(d(l),cr())};return{setOpen(d){c(l=>{l.open=d,d&&(l.order=++Hs)})},setWidth(d){c(l=>{l.width=d})},setAnimated(d){c(l=>{l.animated=d})},release(){i||(i=!0,Bt.delete(s),Bt.size===0?Pg():cr())}}}function Pg(){if(!rt)return;const e=document.body.scrollTop,t=document.documentElement;t.removeAttribute(mt),t.removeAttribute(Zt),t.removeAttribute(zn),t.style.removeProperty(Io),_t==null||_t.disconnect(),_t=null;for(const n of Array.from(document.querySelectorAll(`[${Jt}]`)))n.removeAttribute(Jt);rt.remove(),rt=null,window.scrollTo({top:e})}let Wt=0,lr="";function Us(){if(typeof document>"u")return()=>{};Wt===0&&(lr=document.body.style.overflow,document.body.style.overflow="hidden"),Wt+=1;let e=!1;return()=>{e||(e=!0,Wt=Math.max(0,Wt-1),Wt===0&&(document.body.style.overflow=lr,lr=""))}}const Og="(max-width: 520px)";function Lg(e,t){return e[t]??""}function $g({companion:e,layout:t,state:n,region:o,sidebarSide:s,sidebarMode:a,cssVars:i,storage:c,resizeLabel:d}){var W,$,U,Y,q,se;const l=Math.max(0,((W=e==null?void 0:e.sidebar)==null?void 0:W.minWidth)??vc),m=Math.max(l,(($=e==null?void 0:e.sidebar)==null?void 0:$.maxWidth)??ag),[p,h]=u.useState(()=>{var D;return dt(((D=e==null?void 0:e.sidebar)==null?void 0:D.width)??Eo,l,m)}),[f,x]=u.useState(!1),g=u.useRef(null);u.useEffect(()=>{h(D=>{var V;return dt(((V=e==null?void 0:e.sidebar)==null?void 0:V.width)??D,l,m)})},[(U=e==null?void 0:e.sidebar)==null?void 0:U.width,m,l]),u.useEffect(()=>{var V;let D=!1;if(!(!c||((V=e==null?void 0:e.sidebar)==null?void 0:V.width)!==void 0))return c.getCompanionSidebarWidth().then(Z=>{D||Z===null||h(dt(Z,l,m))}).catch(()=>{}),()=>{D=!0}},[(Y=e==null?void 0:e.sidebar)==null?void 0:Y.width,m,l,c]);const y=u.useCallback(D=>dt(s==="left"?D:window.innerWidth-D,l,m),[m,l,s]),w=u.useCallback(D=>{var V;D.currentTarget.setPointerCapture(D.pointerId),x(!0),(V=g.current)==null||V.setAnimated(!1)},[]),j=u.useCallback(D=>{D.currentTarget.hasPointerCapture(D.pointerId)&&h(y(D.clientX))},[y]),b=u.useCallback(D=>{var Z;const V=y(D.clientX);D.currentTarget.hasPointerCapture(D.pointerId)&&D.currentTarget.releasePointerCapture(D.pointerId),h(V),x(!1),(Z=g.current)==null||Z.setAnimated(!0),c==null||c.setCompanionSidebarWidth(V).catch(()=>{})},[c,y]),_=u.useCallback(D=>{var V;D.currentTarget.hasPointerCapture(D.pointerId)&&D.currentTarget.releasePointerCapture(D.pointerId),x(!1),(V=g.current)==null||V.setAnimated(!0)},[]),v=u.useCallback(D=>{let V=null;if(D.key==="Home"&&(V=l),D.key==="End"&&(V=m),D.key==="ArrowLeft"||D.key==="ArrowRight"){const Z=D.key===(s==="left"?"ArrowRight":"ArrowLeft");V=dt(p+(Z?16:-16),l,m)}V!==null&&(D.preventDefault(),h(V),c==null||c.setCompanionSidebarWidth(V).catch(()=>{}))},[m,l,s,p,c]),k=t==="sidebar",N=a==="docked",R=Ao(o,p),T=((q=e==null?void 0:e.sidebar)==null?void 0:q.canvasColor)??ig,A=`hsl(${Lg(i,"--opencx-background")})`,O=u.useRef({open:n!=="pill",width:R});O.current={open:n!=="pill",width:R},u.useEffect(()=>{if(!k||!N)return;const D=Rg({canvas:T,side:s,pageBackground:A});return g.current=D,D.setWidth(O.current.width),D.setOpen(O.current.open),()=>{g.current===D&&(g.current=null),D.release()}},[T,N,k,A,s]),u.useEffect(()=>{var D;k&&N&&((D=g.current)==null||D.setWidth(R))},[R,N,k]),u.useEffect(()=>{var D;k&&N&&((D=g.current)==null||D.setOpen(n!=="pill"))},[N,k,n]);const P=n==="chat"&&t==="fullscreen",B=((se=e==null?void 0:e.fullscreen)==null?void 0:se.lockScroll)!==!1;u.useEffect(()=>{if(!(!P||!B))return Us()},[P,B]);const E=n==="chat"&&t==="compact";u.useEffect(()=>{if(!(!E||!B)&&!(typeof window>"u"||!window.matchMedia(Og).matches))return Us()},[E,B]);const I=u.useMemo(()=>({role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":d,"aria-valuemin":l,"aria-valuemax":m,"aria-valuenow":p,onPointerDown:w,onPointerMove:j,onPointerUp:b,onPointerCancel:_,onKeyDown:v}),[m,l,v,w,j,_,b,d,p]);return{sidebarWidth:p,sidebarResizing:f,resizeHandleProps:I}}const Dg={width:1440,height:900};function qs(){return typeof window>"u"?Dg:{width:window.innerWidth,height:window.innerHeight}}function Fg(){const[e,t]=u.useState(qs),[n,o]=u.useState(null),s=u.useRef(null),a=u.useCallback(c=>{var l;if((l=s.current)==null||l.disconnect(),s.current=null,!c)return;const d=new ResizeObserver(()=>{o(c.offsetWidth)});d.observe(c),s.current=d},[]);u.useEffect(()=>{function c(){t(qs())}return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]),u.useEffect(()=>()=>{var c;(c=s.current)==null||c.disconnect(),s.current=null},[]);const i=Math.min(n??eg,Math.max(0,e.width-wc));return{region:e,dockWidth:i,dockContentRef:a}}function Hg({storage:e,state:t,layout:n,viewportWidth:o,currentWidth:s,restingWidth:a,shouldReduceMotion:i}){const[c,d]=u.useState(0),l=F.useMotionValue(0),m=u.useRef(!1);u.useEffect(()=>{let y=!1;if(e)return e.getCompanionPillOffsetX().then(w=>{y||w===null||d(w)}).catch(()=>{}),()=>{y=!0}},[l,e]),u.useEffect(()=>{const y=i?ge:It;if(t==="pill"){const j=Math.max(0,o/2-a/2-ar),b=dt(c,-j,j);Math.abs(l.get())>j?l.set(b):F.animate(l,b,y);return}if(t==="chat"&&(n==="fullscreen"||n==="sidebar")){F.animate(l,0,y);return}const w=Math.max(0,o/2-s/2-ar);F.animate(l,dt(c,-w,w),y)},[s,l,n,c,a,i,t,o]);const p=Math.max(0,o/2-a/2-ar),h=u.useMemo(()=>({left:-p,right:p,top:0,bottom:0}),[p]),f=u.useCallback(()=>{m.current=!0},[]),x=u.useCallback(()=>{const y=l.get();d(w=>w===y?w:y),e==null||e.setCompanionPillOffsetX(y).catch(()=>{}),requestAnimationFrame(()=>{m.current=!1})},[l,e]),g=u.useCallback(()=>m.current,[]);return{dragX:l,dragConstraints:h,onDragStart:f,onDragEnd:x,shouldIgnoreLaunch:g}}function Wg({state:e,layout:t,sidebarMode:n,isPageMarkModeArmed:o}){return e==="pill"||o?!1:!(t==="sidebar"&&n==="docked")}const Bg=96,Vs=ao({transparent:!0});function Ug(){var Po,Oo,Lo;const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger(),{openChats:n,activeId:o}=C.useCompanionChats(),s=n.length,{count:a}=C.useUnread(),i=n.filter(re=>re.working).length,{widgetCtx:c,contentIframeRef:d}=C.useWidget(),{companion:l,assets:m,customComponents:p,initialQuestions:h}=C.useConfig(),{theme:f,cssVars:x}=me(),{t:g,dir:y}=G(),{sessionState:w}=C.useSessions(),{messagesState:j}=C.useMessages(),{isArmed:b}=ko(),{region:_,dockWidth:v,dockContentRef:k}=Fg(),[N,R]=u.useState(e?"chat":"pill"),{layout:T,setLayout:A,setLayoutPreference:O,allowedLayouts:P,defaultLayout:B,sidebarSide:E,sidebarMode:I}=C.useWidgetLayout(),[W,$]=u.useState(Bg),{sidebarWidth:U,sidebarResizing:Y,resizeHandleProps:q}=$g({companion:l,layout:T,state:N,region:_,sidebarSide:E,sidebarMode:I,cssVars:x,storage:c.storageCtx,resizeLabel:g("companion_resize_chat")}),se=F.useReducedMotion(),D=Y?{duration:0}:se?ge:It,V=Pn(),Z=u.useRef(null),te=u.useRef(!1),ae=N==="pill",xe=N==="input"&&j.messages.length===0&&(h==null?void 0:h.some(re=>re.trim().length>0))===!0,[H,ee]=u.useState(0),J=s>0,ne=co(),le=u.useRef(ne.close);le.current=ne.close,u.useEffect(()=>{(!ae||!J)&&le.current(!0)},[ae,J]);const de=p==null?void 0:p.widgetTrigger,ie=!!de,De=(l==null?void 0:l.pillBackground)??"hsl(var(--opencx-primary))",Fe=(l==null?void 0:l.icon)??((Po=m==null?void 0:m.widgetTrigger)==null?void 0:Po.openIcon),pe=f.widgetTrigger.offset.bottom,Ve=Dn(),st=Fn(a),Ye=fc(),He=st?`${Ye} · ${st}`:Ye,Xe=!!((Oo=w.session)!=null&&Oo.id),Ge=Xe?g("follow_up_placeholder"):void 0,we=(l==null?void 0:l.pillLabel)??(l==null?void 0:l.placeholder)??Ge??g("write_a_message_placeholder"),Re=(l==null?void 0:l.pillLabelDisplay)??"always",We=(l==null?void 0:l.placeholder)??Ge??g("write_a_message_placeholder"),[Wn,dn]=u.useState(!1),ve=ae&&!ie&&Re!=="never"&&(Re==="always"||V&&Wn),Lt=jc(_,l==null?void 0:l.compact),$t=T==="sidebar",wt=lg({layout:T,region:_,sidebarWidth:U,bottomOffset:pe,compact:l==null?void 0:l.compact}),un=N==="chat"?wt.width:Lt,Bn=wt.height,{centerX:Un,bottom:qn}=dg({isChatOpen:N==="chat",layout:T,region:_,sidebarWidth:U,sidebarSide:E,bottomOffset:pe}),Ce=u.useMemo(()=>N==="pill"?ve?{width:v,height:Qf,borderRadius:nt.pill}:{width:tt,height:tt,borderRadius:nt.pill}:N==="input"?{width:Lt,height:W,borderRadius:nt.input}:wt,[N,ve,v,Lt,wt,W]),pn=N==="pill"&&ve&&Re==="hover"?(y==="rtl"?-1:1)*(v-tt)/2:0,{dragX:Q,dragConstraints:be,onDragStart:Dt,onDragEnd:Be,shouldIgnoreLaunch:Pe}=Hg({storage:c.storageCtx,state:N,layout:T,viewportWidth:_.width,currentWidth:Ce.width,restingWidth:ve?v:tt,shouldReduceMotion:se}),at=u.useCallback(()=>{var Ht;const re=c.routerCtx.state.get().screen,ue=!!((Ht=c.sessionCtx.sessionState.get().session)!=null&&Ht.id);R(re==="welcome"||ue?"chat":"input")},[c]),Ee=u.useCallback(()=>{if(!Pe()){if(le.current(!0),T==="sidebar"){R("chat");return}at()}},[at,T,Pe]),vt=u.useCallback(()=>{if(T==="fullscreen"&&B!=="fullscreen"){A(B);return}if(T==="sidebar"){R("pill");return}R(re=>{var ue;return re==="chat"&&((ue=c.sessionCtx.sessionState.get().session)!=null&&ue.id)?"input":"pill"})},[B,T,A,c]),it=u.useCallback(()=>{const re=Gf({panelLayout:T,previousLayout:jt.current,defaultLayout:B,allowedLayouts:P});if(re.kind==="layout"){A(re.layout);return}R("pill")},[P,B,T,A]),mn=u.useCallback(()=>{R("pill")},[]);u.useEffect(()=>{N==="chat"&&(te.current=!0)},[N]),u.useEffect(()=>{N!=="chat"&&te.current&&T==="fullscreen"&&B!=="fullscreen"&&A(B)},[B,T,A,N]);const Ft=N==="chat"&&T==="fullscreen";Tg({panelOpen:N!=="pill",isOpen:e,setIsOpen:t,onOpen:at,onClose:mn}),u.useEffect(()=>{if(!Wg({state:N,layout:T,sidebarMode:I,isPageMarkModeArmed:b}))return;function re(ue){if(Jf(ue))return;const Ht=Z.current;Ht&&(ue.composedPath().includes(Ht)||vt())}return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[vt,N,T,I,b]);const yt=((Lo=j.messages.findLast(re=>re.type==="USER"))==null?void 0:Lo.id)??null,he=u.useRef(null);u.useEffect(()=>{N==="input"&&(he.current=yt)},[N]),u.useEffect(()=>{N==="input"&&yt!==he.current&&(c.routerCtx.state.get().screen!=="chat"&&c.routerCtx.state.setPartial({screen:"chat"}),R("chat"))},[yt,N,c]);const{isOpen:kt}=Ot();u.useEffect(()=>{kt&&R("chat")},[kt]);const Ec=u.useCallback(()=>{var re;c.routerCtx.state.get().screen!=="chat"&&((re=c.sessionCtx.sessionState.get().session)!=null&&re.id)&&c.routerCtx.state.setPartial({screen:"chat"}),R("chat")},[c]),hn=u.useCallback(re=>{var ue;P.includes(re)&&(re==="fullscreen"&&c.routerCtx.state.get().screen==="sessions"&&c.routerCtx.toChatScreen((ue=c.sessionCtx.sessionState.get().session)==null?void 0:ue.id),O(re))},[P,c,O]),Vn=P.find(re=>re!=="fullscreen"),jt=u.useRef(Vn??B);u.useEffect(()=>{T!=="fullscreen"&&P.includes(T)?jt.current=T:(jt.current==="fullscreen"||!P.includes(jt.current))&&(jt.current=Vn??B)},[P,B,Vn,T]);const fn=u.useCallback(()=>{if(!P.includes("fullscreen"))return;if(T!=="fullscreen"){hn("fullscreen");return}const re=jt.current;re!=="fullscreen"&&P.includes(re)&&hn(re)},[P,T,hn]);u.useEffect(()=>{function re(ue){Xf(ue,{state:N,onToggleFullscreen:fn})}return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[fn,N]);const Yn=$n();return Yn?Qt.createPortal(r.jsxs(r.Fragment,{children:[r.jsx(To,{transcriptVisible:N==="chat"}),de&&gc(de,e,t,a),ae&&ne.anchor&&!ie&&r.jsx(uo,{placement:"above",picker:ne,portalTarget:Yn,onSelected:()=>R("chat")}),r.jsx(F.motion.div,{"aria-hidden":!0,style:{position:"fixed",inset:0,background:"transparent",zIndex:f.widgetContentContainer.zIndex,pointerEvents:Ft?"auto":"none"},initial:!1,animate:{opacity:Ft?1:0},transition:ke}),r.jsxs(F.motion.div,{ref:Z,style:{...x,position:"fixed",x:Q,translateX:"-50%",zIndex:f.widgetContentContainer.zIndex,visibility:ie&&ae?"hidden":void 0},initial:!1,animate:{left:Un,bottom:qn},drag:ae&&!ie&&!ne.open?"x":!1,dragMomentum:!1,dragElastic:.15,dragConstraints:be,onDragStart:Dt,onDragEnd:Be,transition:D,children:[xe&&r.jsx("div",{"data-companion-starters":!0,style:{position:"absolute",bottom:"calc(100% + 12px)",left:"50%",transform:"translateX(-50%)",width:un,height:H},children:r.jsx(Fs,{title:"Suggested questions",initialContent:Vs,style:{width:"100%",height:"100%",border:0,background:"transparent"},children:r.jsx(Kf,{onHeightChange:ee,onDismiss:it,onToggleFullscreen:fn,maxHeight:Math.max(48,_.height-Ce.height-pe-32)})})}),r.jsxs(F.motion.div,{onPointerEnter:ae&&!ie?re=>{dn(!0);const ue=re.currentTarget.querySelector("[data-companion-count-trigger]");ue&&!Pe()&&ne.hover(ue)}:void 0,onPointerLeave:()=>{dn(!1),ne.leave()},style:{position:"relative",overflow:"hidden",transformOrigin:"center bottom",cursor:ae&&!ie?ve?"pointer":"grab":"default",background:"hsl(var(--opencx-background))"},initial:!1,animate:{x:pn,width:Ce.width,height:Ce.height,borderTopLeftRadius:Ce.borderRadius,borderTopRightRadius:Ce.borderRadius,borderBottomLeftRadius:Ce.borderRadius,borderBottomRightRadius:Ce.borderRadius,boxShadow:ae?ve?eu:Qd:N==="input"?tu:nu},whileHover:ae&&!ie&&V&&!se?{scale:ve?1.01:1.12}:void 0,whileTap:ae&&!ie?{scale:ve?.995:.92}:void 0,transition:D,children:[ae&&!ie&&r.jsx("button",{type:"button","data-companion-launcher":"",onClick:Ee,"aria-label":He,"aria-expanded":!1,style:{position:"absolute",inset:0,zIndex:1,border:0,padding:0,background:"transparent",cursor:"pointer",borderRadius:"inherit"}}),!ie&&r.jsx(_g,{visible:ae,docked:ve,label:we,sessions:s>0?r.jsx(Ag,{interactive:ae&&ve,onSelected:()=>R("chat"),onLastClosed:()=>{requestAnimationFrame(()=>{var re,ue;(ue=(re=Z.current)==null?void 0:re.querySelector("[data-companion-launcher]"))==null||ue.focus({preventScroll:!0})})}}):void 0,activeCount:s,countLabel:`${g("companion_chats")} · ${g("companion_active_chats",{count:s})}${i?` · ${g("companion_working_chats",{count:i})}`:""}`,pickerOpen:ne.open,onOpenChats:(re,ue)=>{Pe()||ne.toggle(re,ue)},working:i>0,icon:Fe,pillBackground:De,dir:y,measureRef:k,unreadCount:Ve===!1?0:a,unreadShowCount:Ve==="count"}),N!=="pill"&&r.jsx(F.motion.div,{style:{position:"absolute",bottom:0,left:"50%",translateX:"-50%",width:un,height:Bn},initial:{opacity:0},animate:{opacity:1,transition:{...ge,delay:se?0:.1}},children:r.jsx(Fs,{iframeRef:d,initialContent:Vs,style:{width:"100%",height:"100%",overflow:"hidden",backgroundColor:"transparent",boxSizing:"border-box",borderWidth:"0px"},children:r.jsx(jg,{state:N==="chat"?"chat":"input",layout:T,shellRadius:Ce.borderRadius,onMinimize:vt,onDismiss:it,onToggleFullscreen:fn,onSelectLayout:hn,onExpand:Ec,canExpand:Xe,placeholder:We,hideAttachTools:((l==null?void 0:l.quickAskTools)??"history-only")==="history-only",onInputHeightChange:$},o)})}),$t&&N==="chat"&&r.jsx("div",{...q,style:{position:"absolute",top:0,bottom:0,...E==="left"?{right:0}:{left:0},width:8,cursor:"ew-resize",zIndex:2}})]})]})]}),Yn):null}function qg(e){const t=e.getBoundingClientRect(),n=t.left+t.width/2,o=t.top+t.height/2,s=e.ownerDocument,a=s.documentElement.clientWidth||window.innerWidth,i=s.documentElement.clientHeight||window.innerHeight;if(n<0||o<0||n>a||o>i||typeof s.elementFromPoint!="function")return!0;const c=s.elementFromPoint(n,o);return c?c===e||e.contains(c)||c.contains(e):!0}function Hr(e){const t=Bi(e);if(!t)return{ok:!1,reason:"gone"};const{element:n}=t,o=Pr(n);if(o)return{ok:!1,reason:"off-limits",detail:Pm[o]};const s=typeof n.checkVisibility=="function"?n.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}):n.isConnected,a=n.getBoundingClientRect();return!s||a.width===0||a.height===0?{ok:!1,reason:"hidden"}:qg(n)?t.isCurrent?{ok:!0,element:n}:{ok:!1,reason:"gone"}:{ok:!1,reason:"covered"}}function Ys(e,t){var s;const n=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:null;if(!n)return!1;const o=(s=Object.getOwnPropertyDescriptor(n,"value"))==null?void 0:s.set;return o?(o.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),!0):!1}function Wr(e,t){if(!(e instanceof HTMLSelectElement)||t===void 0)return null;const n=Array.from(e.options),o=n.filter(a=>a.value===t||a.label.trim().toLowerCase()===t.trim().toLowerCase()),[s]=o;return o.length!==1||!s||s.disabled||s.parentElement instanceof HTMLOptGroupElement&&s.parentElement.disabled||n.filter(a=>a.value===s.value).length!==1?null:s}function kn(e,t,n){const o=e.ownerDocument,s=h=>h.contains(e)||e.contains(h)||(e.getAttribute("aria-controls")??"").split(/\s+/).some(f=>{const x=o.getElementById(f);return x!==null&&(h.contains(x)||x.contains(h))}),a=Array.from(o.querySelectorAll('[aria-busy="true"]')).filter(h=>!Me(h)&&!s(h)),i=h=>{for(let f=a.length-1;f>=0;f--)s(a[f])&&a.splice(f,1);return a.some(f=>f.contains(h))};let c=!1,d=performance.now(),l;const m=new MutationObserver(h=>{h.some(x=>{const g=x.target instanceof Element?x.target:x.target.parentElement;return g!==null&&!cn(g)&&!i(g)})&&(c=!0,d=performance.now())});m.observe(o.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});const p=()=>{clearTimeout(l),m.disconnect()};return{settle:()=>new Promise(h=>{const f=performance.now()+t,x=()=>{if(!n()){p(),h({mutated:c,loading:!1});return}const g=Array.from(o.querySelectorAll('[aria-busy="true"]')).some(w=>!i(w)&&!Me(w)),y=performance.now();y>=f||!g&&y-d>=100?(p(),h({mutated:c,loading:g})):l=setTimeout(x,Math.min(100,f-y))};l=setTimeout(x,Math.min(100,t))}),cancel:p}}function Vg(e){if(e.tagName.toLowerCase()==="input"){const t=(e.getAttribute("type")??"text").toLowerCase();if(Di.has(t))return"Password and file fields are never filled or clicked by the agent."}return e.ownerDocument!==document?"That control is inside another site embedded in this page.":null}async function Yg(e){try{return await Xg(e)}catch{return{outcome:"unsupported",detail:"That could not be done on this page."}}}async function Xg({ref:e,action:t,value:n,settleMs:o=km,consentIsCurrent:s=()=>!0,observationIsCurrent:a=()=>!0}){var x;if(!s())return{outcome:"declined"};const i=Hr(e);if(!i.ok)return i.reason==="off-limits"?{outcome:"unsupported",detail:i.detail}:{outcome:i.reason};const c=i.element,d=Vg(c);if(d)return{outcome:"unsupported",detail:d};const l=c.ownerDocument,m=l.location.href;let p,h,f=!1;try{switch(t){case"click":{p=kn(c,o,a);const j=Ls(c,s);if(j==="not-started")return p.cancel(),{outcome:"declined"};f=j==="interrupted";break}case"fill":{if(n===void 0)return{outcome:"unsupported",detail:"No value was given to type."};if(p=kn(c,o,a),(x=c.focus)==null||x.call(c),!s()){f=!0;break}if(!Ys(c,n))return p.cancel(),{outcome:"unsupported",detail:"That control is not something text can be typed into."};break}case"select":{if(!(c instanceof HTMLSelectElement))return{outcome:"unsupported",detail:"That control is not a dropdown."};if(n===void 0)return{outcome:"unsupported",detail:"No option was given to choose."};const j=Wr(c,n);if(!j)return{outcome:"no_change",detail:"That option is not in the list or cannot be selected unambiguously."};p=kn(c,o,a),h=j.value,Ys(c,j.value);break}case"check":case"uncheck":{const j=t==="check",b=c instanceof HTMLInputElement&&(c.type==="checkbox"||c.type==="radio")?c:null,_=c.getAttribute("aria-checked");if(!b&&_===null)return{outcome:"unsupported",detail:"That control is not a checkbox or switch."};if((b?b.checked:_==="true")===j)return{outcome:"no_change",detail:`It is already ${j?"on":"off"}.`};p=kn(c,o,a);const k=Ls(c,s);if(k==="not-started")return p.cancel(),{outcome:"declined"};f=k==="interrupted";break}}const{mutated:g,loading:y}=await(p==null?void 0:p.settle())??{mutated:!1,loading:!1};if(f)return{outcome:"no_change",detail:(g||l.location.href!==m?"The page changed. ":"")+"The requested action was interrupted after input events were dispatched. Its final result is unknown. Do not repeat it automatically."};const w=y?"The page is still loading. The action was dispatched; its final result is unknown. Do not repeat it automatically.":void 0;if(t==="fill"||t==="select"){const j=c instanceof HTMLInputElement||c instanceof HTMLTextAreaElement||c instanceof HTMLSelectElement?c.value:null;return t==="fill"&&j!==n?{outcome:"no_change",detail:"The field did not keep what was typed."}:t==="select"&&j!==h?{outcome:"no_change",detail:"The dropdown did not keep the selected option."}:{outcome:"done",...w?{detail:w}:{}}}if(t==="check"||t==="uncheck"){const j=t==="check",b=c instanceof HTMLInputElement&&(c.type==="checkbox"||c.type==="radio")?c:null;return(b?b.checked:c.getAttribute("aria-checked")==="true")===j?{outcome:"done",...w?{detail:w}:{}}:{outcome:"no_change",detail:"It did not change."}}return g||l.location.href!==m?{outcome:"done",...w?{detail:w}:{}}:{outcome:"no_change",detail:w??"The control was clicked and nothing on the page changed during observation. Its final result is unknown. Do not repeat it automatically."}}finally{p==null||p.cancel()}}const Gg="cubic-bezier(0.32, 0.72, 0, 1)",dr=260,Kg=1600,Zg=180,Xs=240,Gs=.13,Jg=e=>e*e*e*(10-15*e+6*e*e);function Qg(e,t,n,o){const s=1-o;return{x:s*s*e.x+2*s*o*t.x+o*o*n.x,y:s*s*e.y+2*s*o*t.y+o*o*n.y}}function ex(e,t,n=48){const o=t.x-e.x,s=t.y-e.y,a=Math.hypot(o,s)||1,i={x:e.x+o/2-s/a*a*Gs,y:e.y+s/2+o/a*a*Gs},c=[];for(let d=0;d<=n;d+=1){const l=Qg(e,i,t,Jg(d/n));c.push({transform:`translate(${l.x-Sn}px, ${l.y-Nn}px)`})}return c}const Sn=2,Nn=1.7,tx="M2 1.7 L9.6 8 L6.5 8.4 L7.7 11 L6.3 11.6 L5.1 9 L2.6 10.6 Z";function zo(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const Ks=e=>new Promise(t=>{window.setTimeout(t,zo()?0:e)});let ht=null,Br;const nx=4e3;function Mn(){clearTimeout(Br),ht==null||ht.release(),ht=null,document.querySelectorAll("[data-opencx-cursor]").forEach(e=>e.remove())}function Ur(){clearTimeout(Br),Br=setTimeout(Mn,nx)}function rx(e){if(ht)return Ur(),ht;try{Mn();const t=document.createElement("div");t.setAttribute("data-opencx-overlay",""),t.setAttribute("data-opencx-cursor",""),t.setAttribute("aria-hidden","true"),Object.assign(t.style,{position:"fixed",inset:"0",overflow:"hidden",pointerEvents:"none",zIndex:"2147483646",contain:"strict"});const n=document.createElement("div");n.setAttribute("data-opencx-cursor-tip",""),Object.assign(n.style,{position:"absolute",left:"0",top:"0",width:"14px",height:"14px",pointerEvents:"none",opacity:"0",transition:`opacity ${dr}ms ease`,willChange:"transform"}),t.appendChild(n),n.innerHTML=`<svg viewBox="0 0 14 14" width="14" height="14" style="display:block">
|
|
454
|
+
<path d="${tx}" fill="currentColor" stroke="currentColor" stroke-width="1.7"
|
|
455
455
|
stroke-linejoin="round" stroke-linecap="round" paint-order="stroke"
|
|
456
|
-
style="transition: transform ${
|
|
457
|
-
</svg>`;const o=e??{x:window.innerWidth-40,y:window.innerHeight-40};let s=o;n.style.transform=`translate(${o.x-Sn}px, ${o.y-Nn}px)`,document.documentElement.appendChild(t);const a=n.querySelector("path");n.offsetWidth,n.style.opacity="1";let i=!1;const c={async moveTo(d,l){if(i)return;const m=`translate(${d-Sn}px, ${l-Nn}px)`;if(
|
|
458
|
-
`).find(s=>s.trim());if(!n)return t;const o=
|
|
459
|
-
`).filter(m=>m.trim()),l=Vr(d[d.length-1]??"");return l?l.length>80?`${l.slice(0,80)}...`:l:n})():a;return r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:z("flex min-w-0 items-center gap-2.5 py-[3px]",i&&"cursor-pointer"),onClick:()=>i&&s(d=>!d),children:[r.jsx("div",{className:"relative z-10 flex size-[18px] shrink-0 items-center justify-center rounded-full bg-background",children:t?r.jsx(mo,{className:"text-[14px] leading-none text-primary/70"}):r.jsx("span",{className:"text-[14px] leading-none text-muted-foreground/40",children:"⠿"})}),r.jsx("span",{className:z("min-w-0 truncate text-[13px] italic text-muted-foreground/60",t&&"opencx-text-shimmer"),children:c}),i&&r.jsx(M.ChevronRightIcon,{className:z("size-2.5 shrink-0 text-muted-foreground/40 transition-transform duration-200",o&&"rotate-90")})]}),i&&o&&r.jsx("div",{className:"opencx-fade-up ms-[30px]",children:r.jsx("div",{className:z("max-h-[160px] overflow-y-auto py-1.5 text-[13px] leading-relaxed [overflow-wrap:anywhere]",_x),children:r.jsx(eo,{children:e.label})})})]})}const Js=4e3;function Ax(e){const t=typeof e=="string"?e:Tx(e)??String(e);return t.length>Js?`${t.slice(0,Js)}…`:t}function Tx(e){try{return JSON.stringify(e,null,2)}catch{return null}}function Qs({label:e,value:t}){return r.jsxs("div",{className:"pt-1.5",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground/50",children:e}),r.jsx("pre",{className:"mt-0.5 max-h-[200px] overflow-auto whitespace-pre-wrap [overflow-wrap:anywhere] rounded-lg bg-muted/40 p-2 font-mono text-[11px] leading-relaxed text-muted-foreground",children:Ax(t)})]})}function Ix({step:e,showIO:t}){const{t:n}=G(),[o,s]=u.useState(!1),a=t&&(e.input!==void 0||e.output!==void 0);return r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:z("flex min-w-0 items-center gap-2.5 py-[3px]",a&&"cursor-pointer"),onClick:()=>a&&s(i=>!i),children:[r.jsx("div",{className:"relative z-10 flex size-[18px] shrink-0 items-center justify-center rounded-full bg-background",children:e.done?r.jsx("div",{className:"size-1.5 rounded-full bg-muted-foreground/30"}):r.jsx(_c,{})}),r.jsx("span",{className:z("min-w-0 truncate text-[13px] text-muted-foreground/70",!e.done&&"opencx-text-shimmer"),children:Po(e.label)}),a&&r.jsx(M.ChevronRightIcon,{className:z("size-2.5 shrink-0 text-muted-foreground/40 transition-transform duration-200",o&&"rotate-90")})]}),a&&o&&r.jsxs("div",{className:"opencx-fade-up ms-[30px] pb-1",children:[e.input!==void 0&&r.jsx(Qs,{label:n("step_arguments"),value:e.input}),e.output!==void 0&&r.jsx(Qs,{label:n("step_result"),value:e.output})]})]})}function zx({steps:e,active:t}){var x;const{t:n}=G(),{showStepToolIO:o,presentation:s}=C.useConfig(),{widgetCtx:a}=C.useWidget(),i=(x=K.resolveClientPresentation(a.agent.presentation,s))==null?void 0:x.toolActivity,c=o!==!1&&(i==="details"||i===void 0&&o===!0),d=n("thinking"),l=t?e:e.map(g=>g.done?g:{...g,done:!0}),m=l.some(g=>!g.done),[p,h]=u.useState(t),f=u.useRef(t);return u.useEffect(()=>{f.current&&!t?h(!1):!f.current&&t&&h(!0),f.current=t},[t]),l.length===0?null:r.jsxs("div",{...L("chat/streaming_turn/steps"),className:"w-full min-w-0 overflow-hidden",children:[r.jsx("button",{type:"button",className:"flex min-w-0 max-w-full items-center gap-1.5 py-0.5 text-[12px] text-muted-foreground/60 transition-colors duration-150 hover:text-muted-foreground",onClick:()=>h(g=>!g),children:p?r.jsxs(r.Fragment,{children:[r.jsx(M.ChevronDownIcon,{className:"size-2.5 shrink-0"}),r.jsx("span",{className:"text-[11px] font-medium tabular-nums",children:l.length}),r.jsx("span",{className:z("text-muted-foreground/40",m&&"opencx-text-shimmer"),children:n(m?"running":"steps")})]}):m?r.jsxs(r.Fragment,{children:[r.jsx(_c,{className:"opacity-70"}),r.jsx("span",{className:"text-[11px] font-medium tabular-nums",children:l.length}),r.jsx(Sx,{labels:l.map(g=>Ro(g,d)),active:m})]}):r.jsxs(r.Fragment,{children:[r.jsx(M.ChevronRightIcon,{className:"size-2.5 shrink-0"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-start text-[12px] text-muted-foreground/50",children:Nx(l,d)})]})}),p&&r.jsxs("div",{className:"relative pt-1",children:[l.length>1&&r.jsx("div",{className:"absolute bottom-3 start-2 top-3 border-s border-dashed border-muted-foreground/20"}),l.map((g,y)=>r.jsx("div",{className:"opencx-fade-up",style:{animationDelay:`${y*40}ms`},children:g.kind==="reasoning"?r.jsx(Ex,{step:g,isLive:m&&y===l.length-1,thinkingLabel:d}):r.jsx(Ix,{step:g,showIO:c})},y))]})]})}function Po(e){const n=e.replace(/^mcp_[a-f0-9]{16}__/,"").replaceAll(/[_-]+/g," ").trim();return n.charAt(0).toUpperCase()+n.slice(1)}function ea(e){var n;if(e.manual){const o=e.manualText.trim();return o.length>0?o:void 0}if(e.question.selection==="single")return e.singleId?(n=e.question.options.find(o=>o.id===e.singleId))==null?void 0:n.label:void 0;const t=Array.from(e.multiIds).map(o=>{var s;return(s=e.question.options.find(a=>a.id===o))==null?void 0:s.label}).filter(o=>typeof o=="string"&&o.length>0);return t.length>0?t.join(", "):void 0}function Mx({request:e}){const{t}=G(),n=an(),{widgetCtx:o}=C.useWidget(),s=e.questions,[a,i]=u.useState(0),[c,d]=u.useState(!1),[l,m]=u.useState({}),[p,h]=u.useState({}),[f,x]=u.useState({}),[g,y]=u.useState({}),w=s[a],j=s.length,b=u.useCallback(P=>ea({question:P,manual:!!l[P.id],manualText:p[P.id]??"",singleId:f[P.id],multiIds:g[P.id]??new Set})!==void 0,[l,p,g,f]),_=w?b(w):!1,v=u.useMemo(()=>s.every(P=>b(P)),[b,s]),k=u.useCallback((P,B)=>{x(E=>({...E,[P]:B})),m(E=>({...E,[P]:!1}))},[]),N=u.useCallback((P,B)=>{y(E=>{const I=new Set(E[P]??[]);return I.has(B)?I.delete(B):I.add(B),{...E,[P]:I}}),m(E=>({...E,[P]:!1}))},[]),R=u.useCallback(P=>{m(B=>({...B,[P]:!0})),x(B=>({...B,[P]:void 0})),y(B=>({...B,[P]:new Set}))},[]),T=u.useCallback(()=>{_&&i(P=>Math.min(j-1,P+1))},[_,j]),A=u.useCallback(()=>{if(c||!v)return;const P=new Map;for(const E of s){const I=ea({question:E,manual:!!l[E.id],manualText:p[E.id]??"",singleId:f[E.id],multiIds:g[E.id]??new Set});I&&P.set(E.id,I)}const B=C.formatAskQuestionsAnswers(e,P);B.trim().length!==0&&(d(!0),n({content:B,clientContext:qi({marks:[],readsPage:o.features.pageContext})}))},[v,c,l,p,g,s,e,n,f,o]);if(!w)return null;const O=!!l[w.id];return r.jsxs("div",{...L("chat/clarification_questions/root"),className:z("w-full rounded-2xl border border-border bg-background shadow-sm",c&&"pointer-events-none opacity-60"),children:[r.jsxs("div",{className:"flex items-start gap-2.5 px-4 pt-4",children:[r.jsx("span",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md bg-primary text-primary-foreground",children:r.jsx(M.SparklesIcon,{className:"size-4"})}),r.jsx("p",{...L("chat/clarification_questions/prompt"),className:"min-w-0 flex-1 text-sm font-medium leading-snug text-foreground",children:w.prompt})]}),r.jsx("div",{className:"px-4 pb-3 pt-3",children:O?r.jsx("textarea",{...L("chat/clarification_questions/manual_input"),value:p[w.id]??"",onChange:P=>h(B=>({...B,[w.id]:P.target.value})),placeholder:t("questions_answer_placeholder"),rows:3,className:z("w-full resize-none rounded-xl border border-border bg-muted/30 px-3 py-2.5","text-sm text-foreground placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"),onKeyDown:P=>{P.key!=="Enter"||P.shiftKey||(P.preventDefault(),a<j-1?T():A())}}):r.jsxs("div",{className:"flex flex-wrap gap-2",children:[w.options.map(P=>{var E;const B=w.selection==="single"?f[w.id]===P.id:((E=g[w.id])==null?void 0:E.has(P.id))??!1;return u.createElement("button",{...L("chat/clarification_questions/option"),key:P.id,type:"button","aria-pressed":B,onClick:()=>w.selection==="single"?k(w.id,P.id):N(w.id,P.id),className:z("rounded-full border px-3 py-1.5 text-sm transition-colors",B?"border-primary bg-primary/10 text-foreground":"border-border bg-muted/40 text-foreground/90 hover:bg-muted")},P.label)}),r.jsx("button",{...L("chat/clarification_questions/type_it"),type:"button",onClick:()=>R(w.id),className:z("rounded-full border border-dashed border-border px-3 py-1.5 text-sm","text-muted-foreground hover:bg-muted hover:text-foreground"),children:t("questions_type_answer")})]})}),r.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-border px-3 py-2",children:[r.jsxs("button",{...L("chat/clarification_questions/back"),type:"button",onClick:()=>i(P=>Math.max(0,P-1)),disabled:a===0,className:"inline-flex items-center gap-1 rounded-lg px-2 py-1.5 text-xs font-medium text-muted-foreground hover:bg-muted disabled:opacity-40",children:[r.jsx(M.ChevronLeftIcon,{className:"size-3.5"}),t("questions_back")]}),j>1?r.jsxs("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[a+1," / ",j]}):null,a<j-1?r.jsxs("button",{...L("chat/clarification_questions/next"),type:"button",onClick:T,disabled:!_,className:"inline-flex items-center gap-1 rounded-lg px-2 py-1.5 text-xs font-medium text-primary hover:bg-muted disabled:opacity-40",children:[t("questions_next"),r.jsx(M.ChevronRightIcon,{className:"size-3.5"})]}):r.jsx("button",{...L("chat/clarification_questions/send"),type:"button",onClick:A,disabled:!v,className:"inline-flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs font-medium text-primary hover:bg-muted disabled:opacity-40",children:t("questions_send")})]}),r.jsx("div",{className:"h-1 w-full overflow-hidden rounded-b-2xl bg-muted",children:r.jsx("div",{className:"h-full bg-primary transition-[width] duration-300 ease-out",style:{width:`${(a+1)/Math.max(1,j)*100}%`}})})]})}function Rx({widgetRef:e}){const{contactState:t}=C.useContact(),{setIsOpen:n}=C.useWidgetTrigger(),{toChatScreen:o}=C.useWidgetRouter(),{renewUserToken:s}=C.useTokenRenewal(),a=Ot();return u.useImperativeHandle(e,()=>({newChat:async i=>{var d;if(!((d=t.contact)!=null&&d.token)){K.log.warn("cannot start a new chat: contact not yet initialized");return}n(!0);const c=o();c&&(i!=null&&i.message)&&await c.messageCtx.sendMessage({content:i.message})},renewUserToken:s,startVoiceCall:async()=>{var i;if(!a.enabled){K.log.warn("cannot start a voice call: `voice` is not configured");return}if(!((i=t.contact)!=null&&i.token)){K.log.warn("cannot start a voice call: contact not yet initialized");return}n(!0),await a.start()}}),[t,n,o,s,a]),null}function Px(){const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger();return r.jsxs(et.Root,{open:e,onOpenChange:t,children:[r.jsx(Io,{}),r.jsx(Zf,{}),r.jsx(Kf,{}),r.jsx(Yf,{})]})}function Ox(){return C.useDisplayMode()==="companion"?r.jsx(C.WidgetLayoutProvider,{children:r.jsx(Kg,{})}):r.jsx(Px,{})}const Lx=[{key:"loading",component:Hu},{key:"fallback",component:Fu},{key:"bot_message",component:kr},{key:"agent_message",component:kr},{key:"agent_chat_steps",component:zx},{key:"agent_chat_spec",component:hp},{key:"agent_chat_questions",component:Mx}],$x={get:async e=>localStorage.getItem(e),set:async(e,t)=>{localStorage.setItem(e,t)},remove:async e=>{localStorage.removeItem(e)}},Ec=u.forwardRef(function({options:t,components:n=[],loadingComponent:o,errorComponent:s},a){var i,c,d,l;return r.jsx(F.MotionConfig,{reducedMotion:"user",children:r.jsx(C.WidgetProvider,{components:[...Lx,...n],options:{...t,capabilities:{...t.capabilities,richReplies:((i=t.capabilities)==null?void 0:i.richReplies)??!n.some(({key:m})=>["AGENT_CHAT_SPEC","BOT_MESSAGE","AGENT_MESSAGE"].includes(m.toUpperCase())),connections:((c=t.capabilities)==null?void 0:c.connections)===!0,pageEffects:((d=t.capabilities)==null?void 0:d.pageEffects)??!0,structuredQuestions:((l=t.capabilities)==null?void 0:l.structuredQuestions)??!n.some(({key:m})=>m.toUpperCase()==="AGENT_CHAT_QUESTIONS")}},storage:$x,loadingComponent:o,errorComponent:s,children:r.jsx(Lu,{children:r.jsx(C.WidgetTriggerProvider,{children:r.jsx(Ch,{children:r.jsxs(Jp,{children:[r.jsx(yx,{}),r.jsx(mx,{}),r.jsx(Rx,{widgetRef:a}),t.inline?r.jsxs(r.Fragment,{children:[r.jsx(Io,{}),r.jsx(fc,{})]}):r.jsx(Ox,{})]})})})})})})});Ec.displayName="Widget";exports.HostedSpecRenderer=Xd;exports.Widget=Ec;exports.segmentContent=Ka;exports.useJsonRenderHost=rn;
|
|
460
|
-
//# sourceMappingURL=index-
|
|
456
|
+
style="transition: transform ${Xs}ms ${Gg}; transform-origin: ${Sn}px ${Nn}px"/>
|
|
457
|
+
</svg>`;const o=e??{x:window.innerWidth-40,y:window.innerHeight-40};let s=o;n.style.transform=`translate(${o.x-Sn}px, ${o.y-Nn}px)`,document.documentElement.appendChild(t);const a=n.querySelector("path");n.offsetWidth,n.style.opacity="1";let i=!1;const c={async moveTo(d,l){if(i)return;const m=`translate(${d-Sn}px, ${l-Nn}px)`;if(zo()||typeof n.animate!="function"){n.style.transform=m;return}n.style.transition=`opacity ${dr}ms ease`;const p=ex(s,{x:d,y:l});await n.animate(p,{duration:Kg,easing:"linear",fill:"forwards"}).finished.catch(()=>{}),!i&&(n.style.transform=m,s={x:d,y:l},await Ks(Zg))},async press(){i||!a||(a.style.transform="scale(0.86)",await Ks(Xs),a.style.transform="")},release(){i||(i=!0,n.style.opacity="0",window.setTimeout(()=>t.remove(),dr+60))}};return ht=c,Ur(),c}catch{return null}}function ox(e){const t=e.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}async function Cc(e,{press:t=!1}={}){var o;const n=rx();if(!n)return{done:()=>{}};try{(o=e.scrollIntoView)==null||o.call(e,{behavior:zo()?"auto":"smooth",block:"center",inline:"nearest"});const{x:s,y:a}=ox(e);await n.moveTo(s,a),t&&await n.press()}catch{}return{done:Ur}}const sx=S.z.object({ref:S.z.string().min(1),action:S.z.enum(ym),value:S.z.string().max(500).optional()});function Sc(e,t){const n=u.useRef({effects:e,isStreaming:t});n.current={effects:e,isStreaming:t};const o=u.useRef(!1);return u.useEffect(()=>(o.current=!0,()=>{o.current=!1}),[]),u.useCallback(s=>o.current&&n.current.isStreaming&&n.current.effects.some(a=>a.key===s),[])}const ax=200;function ix(){const{widgetCtx:e}=C.useWidget(),{pageEffects:t,replyToPageCall:n,requestPageActionConsent:o,isStreaming:s}=C.useAgentChatUi(),a=u.useRef(new Set),i=Sc(t,s);return u.useEffect(()=>{const c=a.current;for(const d of t){if(d.type!=="act-on-page"||c.has(d.key))continue;for(c.add(d.key);c.size>ax;){const f=c.values().next().value;if(f===void 0)break;c.delete(f)}const l=sx.safeParse(d.input);if(!l.success){K.log.warn("act_on_page: invalid tool input",{issues:l.error.issues}),n(d.callId,"unsupported");continue}const{ref:m,action:p,value:h}=l.data;(async()=>{let f;try{const x=()=>i(d.key)&&e.features.pageContext&&e.features.clientTools&&e.features.pageActions;if(!x()){n(d.callId,"declined");return}const g=ks(m);if(!g){n(d.callId,"gone",void 0,x()?Or():void 0);return}const y=Mt(g)||"this control",w=p==="select"?Wr(g,h):null;if(p==="select"&&!w){n(d.callId,"no_change","That option is unavailable or ambiguous.");return}const j=w==null?void 0:w.value,b=w==null?void 0:w.label.trim(),_=Fi(g),v=()=>x()&&ks(m)===g&&_()&&y===(Mt(g)||"this control")&&(!w||Wr(g,h)===w&&w.value===j&&w.label.trim()===b);if(!await o({callId:d.callId,action:p,controlName:y,...p==="fill"||p==="select"?{value:h}:{},...w?{valueLabel:b||"(empty option)"}:{}})){n(d.callId,"declined");return}if(!v()){n(d.callId,"declined");return}if(f=await Cc(g,{press:!0}),!v()){n(d.callId,"declined");return}const N=await Yg({ref:m,action:p,value:h,consentIsCurrent:v,observationIsCurrent:x}),R=x()&&N.outcome!=="declined"&&N.outcome!=="unsupported"?Or():null;n(d.callId,N.outcome,N.detail,R?{controls:R.controls,truncated:R.truncated}:void 0)}catch{n(d.callId,"unsupported","The page action could not be completed.")}finally{f==null||f.done()}})()}},[t,n,o,e,i]),null}const cx=["circle","box","underline","bracket","arrow"],lx=S.z.object({ref:S.z.string().min(1),label:S.z.string().optional(),type:S.z.enum(cx).optional().catch(void 0)}),dx=8e3;function ux(e,t,n){return t.display==="inline"&&e.height<=n*2.5?"underline":e.width<=220&&e.height<=80?"circle":"box"}let Ue=null;function px(){Ue==null||Ue()}function mx(e,t,{accentColor:n="hsl(0 0% 9%)",surfaceColor:o="hsl(0 0% 9%)",foregroundColor:s="hsl(0 0% 98%)",zIndex:a=10000002,durationMs:i=dx,seed:c}={}){if(!e.isConnected)return!1;Ue==null||Ue();const d=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;e.scrollIntoView({behavior:d?"auto":"smooth",block:"center",inline:"nearest"});const l=e.getBoundingClientRect(),m=getComputedStyle(e),p=parseFloat(m.fontSize)||16,h=l.width<160&&l.height<56,f=da.annotate(e,{type:t.type??ux(l,m,p),color:n,strokeWidth:Math.min(3,Math.max(1.6,p*.11)),wobble:h?.6:.9,rtl:m.direction==="rtl",seed:c});let x=!1;const g=()=>{if(!x)try{f.show(),zr(e,a)}catch(A){K.log.warn("highlight_element: mark could not be drawn",A)}},y=document.fonts;y!=null&&y.ready&&typeof y.ready.then=="function"?y.ready.then(g):g();const w=document.createElement("div");w.setAttribute("data-opencx-overlay",""),w.style.pointerEvents="none";let j=null,b=null;t.label&&(j=document.createElement("div"),j.setAttribute("data-cx-role","callout"),Object.assign(j.style,{position:"fixed",zIndex:String(a+1),background:o,color:s,font:"500 13px/1.4 system-ui, sans-serif",padding:"9px 13px",borderRadius:"11px",maxWidth:"240px",boxShadow:`0 10px 30px -8px color-mix(in srgb, ${s} 35%, transparent)`,opacity:"0",transform:d?"none":"translateY(4px)",transition:"opacity 280ms cubic-bezier(0.23, 1, 0.32, 1), transform 280ms cubic-bezier(0.23, 1, 0.32, 1)",pointerEvents:"none"}),j.textContent=t.label,b=document.createElement("div"),Object.assign(b.style,{position:"absolute",width:"10px",height:"10px",background:o,transform:"rotate(45deg)"}),j.appendChild(b),w.appendChild(j)),document.documentElement.appendChild(w);let _=0;if(j&&b){const A=j,O=b,P=()=>{const B=e.getBoundingClientRect(),E=window.innerWidth,I=B.top>90?"top":"bottom",W=Math.min(240,A.offsetWidth||240),$=Math.max(12,Math.min(B.left+B.width/2-W/2,E-W-12));A.style.left=`${$}px`,A.style.width=`${W}px`,A.style.top=I==="top"?`${B.top-A.offsetHeight-12}px`:`${B.bottom+12}px`,O.style.left=`${Math.max(10,Math.min(B.left+B.width/2-$-5,W-20))}px`,I==="top"?(O.style.bottom="-4px",O.style.top=""):(O.style.top="-4px",O.style.bottom=""),_=requestAnimationFrame(P)};P()}const v=j?window.setTimeout(()=>{j&&(j.style.opacity="1",j.style.transform="translateY(0)")},350):0,k=()=>{if(!x){x=!0,Ue===k&&(Ue=null),cancelAnimationFrame(_),window.clearTimeout(T),window.clearTimeout(v),document.removeEventListener("click",N,!0),document.removeEventListener("keydown",R,!0),j&&(j.style.opacity="0",j.style.transform=d?"none":"translateY(4px)");try{f.hide(),f.finished.then(()=>f.remove())}catch{f.remove()}window.setTimeout(()=>w.remove(),300)}},N=()=>k(),R=A=>{A.key==="Escape"&&k()},T=window.setTimeout(k,Math.max(0,i));return document.addEventListener("click",N,!0),document.addEventListener("keydown",R,!0),Ue=k,!0}const hx=200;function fx(){const{pageMarkHighlightDurationMs:e}=C.useConfig(),{pageEffects:t,replyToPageCall:n,isStreaming:o}=C.useAgentChatUi(),{widgetCtx:s}=C.useWidget(),a=Sc(t,o),{theme:i,cssVars:c}=me(),d=vo({cssVars:c,primaryColor:i.primaryColor,contentZIndex:i.widgetContentContainer.zIndex}),l=u.useRef(new Set);return u.useEffect(()=>()=>{px(),Mn()},[]),u.useEffect(()=>{o||Mn()},[o]),u.useEffect(()=>{const m=l.current;for(const p of t){if(p.type!=="highlight-element"||m.has(p.key))continue;for(m.add(p.key);m.size>hx;){const j=m.values().next().value;if(j===void 0)break;m.delete(j)}const h=()=>a(p.key)&&s.features.pageContext&&s.features.clientTools;if(!h()){n(p.callId,"declined");continue}const f=lx.safeParse(p.input);if(!f.success){K.log.warn("highlight_element: invalid tool input",{issues:f.error.issues}),n(p.callId,"unsupported");continue}const x=Hr(f.data.ref);if(!x.ok){K.log.warn("highlight_element: not drawn",{ref:f.data.ref,reason:x.reason}),x.reason==="off-limits"?n(p.callId,"unsupported",x.detail):n(p.callId,x.reason);continue}const g=x.element,y=p.callId,w=f.data;(async()=>{let j;try{if(j=await Cc(g),!h()){n(y,"declined");return}const b=Hr(w.ref);if(!b.ok){n(y,b.reason==="off-limits"?"unsupported":b.reason);return}const _=mx(g,w,{accentColor:d.accent,surfaceColor:d.surface,foregroundColor:d.foreground,zIndex:d.inkZIndex,durationMs:e});n(y,_?"done":"gone"),_||K.log.warn("highlight_element: the mark could not be drawn",w)}catch{n(y,"unsupported","The page highlight could not be completed.")}finally{j==null||j.done()}})()}},[t,n,e,d.accent,d.surface,d.foreground,d.inkZIndex,a,s]),null}const gx=/(\*\*\*|\*\*|\*|~~|`+)(?=\S)([\s\S]*?\S)\1/g,xx=/(^|[^\w`])(___|__|_)(?=\S)([\s\S]*?\S)\2(?!\w)/g,bx=3;function qr(e){let t=e.replace(/^\s{0,3}(?:```+|~~~+)\S*\s*/,"").replace(/^\s{0,3}(?:#{1,6}\s+|>\s?|[-*+]\s+|\d+[.)]\s+)/,"").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1");for(let n=0;n<bx;n++){const o=t.replace(gx,"$2").replace(xx,"$1$3");if(o===t)break;t=o}return t.trim()}function Nc({className:e}){const[t,n]=u.useState(()=>new Set);return u.useEffect(()=>{const o=Array.from({length:9},(a,i)=>i),s=setInterval(()=>{const a=2+Math.floor(Math.random()*3),i=[...o].sort(()=>Math.random()-.5).slice(0,a);n(new Set(i))},110);return()=>clearInterval(s)},[]),r.jsx("div",{className:z("inline-grid shrink-0 grid-cols-3",e),style:{gap:1,width:14,height:14},children:Array.from({length:9},(o,s)=>r.jsx("div",{className:"rounded-[1px]",style:{width:4,height:4,background:t.has(s)?"hsl(var(--opencx-foreground))":"hsl(var(--opencx-border))",transition:"background 66ms ease"}},s))})}function wx({labels:e,active:t}){const n=u.useRef(e);n.current=e;const[o,s]=u.useState(()=>e[e.length-1]??""),[a,i]=u.useState("in"),c=u.useRef(e.length);return u.useEffect(()=>{const d=n.current.length;if(!t||d<=c.current){c.current=d;return}c.current=d;const l=n.current[d-1]??"";i("out");const m=setTimeout(()=>{s(l),i("in")},180);return()=>clearTimeout(m)},[t,e.length]),r.jsx("span",{className:z("truncate text-[12px] text-muted-foreground/60",t&&(a==="in"?"opencx-placeholder-in":"opencx-placeholder-out")),children:o})}function Mo(e,t){if(e.kind==="tool")return Ro(e.label);const n=e.label.split(`
|
|
458
|
+
`).find(s=>s.trim());if(!n)return t;const o=qr(n);return o?o.length>40?`${o.slice(0,40)}...`:o:t}function vx(e,t,n=3){const o=e.filter(s=>s.kind==="tool").map(s=>Ro(s.label));if(o.length===0){const s=e.find(a=>a.kind==="reasoning");return s?Mo(s,t):t}return o.length<=n?o.join(" → "):`${o.slice(0,n).join(" → ")} → ...`}const yx=["prose prose-sm max-w-none","[--tw-prose-body:hsl(var(--opencx-muted-foreground))]","[--tw-prose-headings:hsl(var(--opencx-foreground))]","[--tw-prose-bold:hsl(var(--opencx-foreground))]","[--tw-prose-code:hsl(var(--opencx-foreground))]","[--tw-prose-links:hsl(var(--opencx-primary))]","[--tw-prose-bullets:hsl(var(--opencx-muted-foreground))]","[--tw-prose-counters:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quotes:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quote-borders:hsl(var(--opencx-border))]","[--tw-prose-hr:hsl(var(--opencx-border))]","[--tw-prose-pre-bg:hsl(var(--opencx-muted))]","[--tw-prose-pre-code:hsl(var(--opencx-foreground))]","prose-p:my-1 prose-headings:my-1.5 prose-headings:text-[13px]","prose-ul:my-1 prose-ol:my-1 prose-li:my-0.5","prose-pre:my-1.5 prose-pre:p-2 prose-pre:text-[11px] prose-hr:my-2","[&>*:first-child]:mt-0 [&>*:last-child]:mb-0"].join(" ");function kx({step:e,isLive:t,thinkingLabel:n}){const[o,s]=u.useState(!1),a=Mo(e,n),i=a!==qr(e.label),c=t?(()=>{const d=e.label.split(`
|
|
459
|
+
`).filter(m=>m.trim()),l=qr(d[d.length-1]??"");return l?l.length>80?`${l.slice(0,80)}...`:l:n})():a;return r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:z("flex min-w-0 items-center gap-2.5 py-[3px]",i&&"cursor-pointer"),onClick:()=>i&&s(d=>!d),children:[r.jsx("div",{className:"relative z-10 flex size-[18px] shrink-0 items-center justify-center rounded-full bg-background",children:t?r.jsx(po,{className:"text-[14px] leading-none text-primary/70"}):r.jsx("span",{className:"text-[14px] leading-none text-muted-foreground/40",children:"⠿"})}),r.jsx("span",{className:z("min-w-0 truncate text-[13px] italic text-muted-foreground/60",t&&"opencx-text-shimmer"),children:c}),i&&r.jsx(M.ChevronRightIcon,{className:z("size-2.5 shrink-0 text-muted-foreground/40 transition-transform duration-200",o&&"rotate-90")})]}),i&&o&&r.jsx("div",{className:"opencx-fade-up ms-[30px]",children:r.jsx("div",{className:z("max-h-[160px] overflow-y-auto py-1.5 text-[13px] leading-relaxed [overflow-wrap:anywhere]",yx),children:r.jsx(Qr,{children:e.label})})})]})}const Zs=4e3;function jx(e){const t=typeof e=="string"?e:Cx(e)??String(e);return t.length>Zs?`${t.slice(0,Zs)}…`:t}function Cx(e){try{return JSON.stringify(e,null,2)}catch{return null}}function Js({label:e,value:t}){return r.jsxs("div",{className:"pt-1.5",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground/50",children:e}),r.jsx("pre",{className:"mt-0.5 max-h-[200px] overflow-auto whitespace-pre-wrap [overflow-wrap:anywhere] rounded-lg bg-muted/40 p-2 font-mono text-[11px] leading-relaxed text-muted-foreground",children:jx(t)})]})}function Sx({step:e,showIO:t}){const{t:n}=G(),[o,s]=u.useState(!1),a=t&&(e.input!==void 0||e.output!==void 0);return r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:z("flex min-w-0 items-center gap-2.5 py-[3px]",a&&"cursor-pointer"),onClick:()=>a&&s(i=>!i),children:[r.jsx("div",{className:"relative z-10 flex size-[18px] shrink-0 items-center justify-center rounded-full bg-background",children:e.done?r.jsx("div",{className:"size-1.5 rounded-full bg-muted-foreground/30"}):r.jsx(Nc,{})}),r.jsx("span",{className:z("min-w-0 truncate text-[13px] text-muted-foreground/70",!e.done&&"opencx-text-shimmer"),children:Ro(e.label)}),a&&r.jsx(M.ChevronRightIcon,{className:z("size-2.5 shrink-0 text-muted-foreground/40 transition-transform duration-200",o&&"rotate-90")})]}),a&&o&&r.jsxs("div",{className:"opencx-fade-up ms-[30px] pb-1",children:[e.input!==void 0&&r.jsx(Js,{label:n("step_arguments"),value:e.input}),e.output!==void 0&&r.jsx(Js,{label:n("step_result"),value:e.output})]})]})}function Nx({steps:e,active:t}){var x;const{t:n}=G(),{showStepToolIO:o,presentation:s}=C.useConfig(),{widgetCtx:a}=C.useWidget(),i=(x=K.resolveClientPresentation(a.agent.presentation,s))==null?void 0:x.toolActivity,c=o!==!1&&(i==="details"||i===void 0&&o===!0),d=n("thinking"),l=t?e:e.map(g=>g.done?g:{...g,done:!0}),m=l.some(g=>!g.done),[p,h]=u.useState(t),f=u.useRef(t);return u.useEffect(()=>{f.current&&!t?h(!1):!f.current&&t&&h(!0),f.current=t},[t]),l.length===0?null:r.jsxs("div",{...L("chat/streaming_turn/steps"),className:"w-full min-w-0 overflow-hidden",children:[r.jsx("button",{type:"button",className:"flex min-w-0 max-w-full items-center gap-1.5 py-0.5 text-[12px] text-muted-foreground/60 transition-colors duration-150 hover:text-muted-foreground",onClick:()=>h(g=>!g),children:p?r.jsxs(r.Fragment,{children:[r.jsx(M.ChevronDownIcon,{className:"size-2.5 shrink-0"}),r.jsx("span",{className:"text-[11px] font-medium tabular-nums",children:l.length}),r.jsx("span",{className:z("text-muted-foreground/40",m&&"opencx-text-shimmer"),children:n(m?"running":"steps")})]}):m?r.jsxs(r.Fragment,{children:[r.jsx(Nc,{className:"opacity-70"}),r.jsx("span",{className:"text-[11px] font-medium tabular-nums",children:l.length}),r.jsx(wx,{labels:l.map(g=>Mo(g,d)),active:m})]}):r.jsxs(r.Fragment,{children:[r.jsx(M.ChevronRightIcon,{className:"size-2.5 shrink-0"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-start text-[12px] text-muted-foreground/50",children:vx(l,d)})]})}),p&&r.jsxs("div",{className:"relative pt-1",children:[l.length>1&&r.jsx("div",{className:"absolute bottom-3 start-2 top-3 border-s border-dashed border-muted-foreground/20"}),l.map((g,y)=>r.jsx("div",{className:"opencx-fade-up",style:{animationDelay:`${y*40}ms`},children:g.kind==="reasoning"?r.jsx(kx,{step:g,isLive:m&&y===l.length-1,thinkingLabel:d}):r.jsx(Sx,{step:g,showIO:c})},y))]})]})}function Ro(e){const n=e.replace(/^mcp_[a-f0-9]{16}__/,"").replaceAll(/[_-]+/g," ").trim();return n.charAt(0).toUpperCase()+n.slice(1)}function Qs(e){var n;if(e.manual){const o=e.manualText.trim();return o.length>0?o:void 0}if(e.question.selection==="single")return e.singleId?(n=e.question.options.find(o=>o.id===e.singleId))==null?void 0:n.label:void 0;const t=Array.from(e.multiIds).map(o=>{var s;return(s=e.question.options.find(a=>a.id===o))==null?void 0:s.label}).filter(o=>typeof o=="string"&&o.length>0);return t.length>0?t.join(", "):void 0}function _x({request:e}){const{t}=G(),n=an(),{widgetCtx:o}=C.useWidget(),s=e.questions,[a,i]=u.useState(0),[c,d]=u.useState(!1),[l,m]=u.useState({}),[p,h]=u.useState({}),[f,x]=u.useState({}),[g,y]=u.useState({}),w=s[a],j=s.length,b=u.useCallback(P=>Qs({question:P,manual:!!l[P.id],manualText:p[P.id]??"",singleId:f[P.id],multiIds:g[P.id]??new Set})!==void 0,[l,p,g,f]),_=w?b(w):!1,v=u.useMemo(()=>s.every(P=>b(P)),[b,s]),k=u.useCallback((P,B)=>{x(E=>({...E,[P]:B})),m(E=>({...E,[P]:!1}))},[]),N=u.useCallback((P,B)=>{y(E=>{const I=new Set(E[P]??[]);return I.has(B)?I.delete(B):I.add(B),{...E,[P]:I}}),m(E=>({...E,[P]:!1}))},[]),R=u.useCallback(P=>{m(B=>({...B,[P]:!0})),x(B=>({...B,[P]:void 0})),y(B=>({...B,[P]:new Set}))},[]),T=u.useCallback(()=>{_&&i(P=>Math.min(j-1,P+1))},[_,j]),A=u.useCallback(()=>{if(c||!v)return;const P=new Map;for(const E of s){const I=Qs({question:E,manual:!!l[E.id],manualText:p[E.id]??"",singleId:f[E.id],multiIds:g[E.id]??new Set});I&&P.set(E.id,I)}const B=C.formatAskQuestionsAnswers(e,P);B.trim().length!==0&&(d(!0),n({content:B,clientContext:Ui({marks:[],readsPage:o.features.pageContext})}))},[v,c,l,p,g,s,e,n,f,o]);if(!w)return null;const O=!!l[w.id];return r.jsxs("div",{...L("chat/clarification_questions/root"),className:z("w-full rounded-2xl border border-border bg-background shadow-sm",c&&"pointer-events-none opacity-60"),children:[r.jsxs("div",{className:"flex items-start gap-2.5 px-4 pt-4",children:[r.jsx("span",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md bg-primary text-primary-foreground",children:r.jsx(M.SparklesIcon,{className:"size-4"})}),r.jsx("p",{...L("chat/clarification_questions/prompt"),className:"min-w-0 flex-1 text-sm font-medium leading-snug text-foreground",children:w.prompt})]}),r.jsx("div",{className:"px-4 pb-3 pt-3",children:O?r.jsx("textarea",{...L("chat/clarification_questions/manual_input"),value:p[w.id]??"",onChange:P=>h(B=>({...B,[w.id]:P.target.value})),placeholder:t("questions_answer_placeholder"),rows:3,className:z("w-full resize-none rounded-xl border border-border bg-muted/30 px-3 py-2.5","text-sm text-foreground placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"),onKeyDown:P=>{P.key!=="Enter"||P.shiftKey||(P.preventDefault(),a<j-1?T():A())}}):r.jsxs("div",{className:"flex flex-wrap gap-2",children:[w.options.map(P=>{var E;const B=w.selection==="single"?f[w.id]===P.id:((E=g[w.id])==null?void 0:E.has(P.id))??!1;return u.createElement("button",{...L("chat/clarification_questions/option"),key:P.id,type:"button","aria-pressed":B,onClick:()=>w.selection==="single"?k(w.id,P.id):N(w.id,P.id),className:z("rounded-full border px-3 py-1.5 text-sm transition-colors",B?"border-primary bg-primary/10 text-foreground":"border-border bg-muted/40 text-foreground/90 hover:bg-muted")},P.label)}),r.jsx("button",{...L("chat/clarification_questions/type_it"),type:"button",onClick:()=>R(w.id),className:z("rounded-full border border-dashed border-border px-3 py-1.5 text-sm","text-muted-foreground hover:bg-muted hover:text-foreground"),children:t("questions_type_answer")})]})}),r.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-border px-3 py-2",children:[r.jsxs("button",{...L("chat/clarification_questions/back"),type:"button",onClick:()=>i(P=>Math.max(0,P-1)),disabled:a===0,className:"inline-flex items-center gap-1 rounded-lg px-2 py-1.5 text-xs font-medium text-muted-foreground hover:bg-muted disabled:opacity-40",children:[r.jsx(M.ChevronLeftIcon,{className:"size-3.5"}),t("questions_back")]}),j>1?r.jsxs("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[a+1," / ",j]}):null,a<j-1?r.jsxs("button",{...L("chat/clarification_questions/next"),type:"button",onClick:T,disabled:!_,className:"inline-flex items-center gap-1 rounded-lg px-2 py-1.5 text-xs font-medium text-primary hover:bg-muted disabled:opacity-40",children:[t("questions_next"),r.jsx(M.ChevronRightIcon,{className:"size-3.5"})]}):r.jsx("button",{...L("chat/clarification_questions/send"),type:"button",onClick:A,disabled:!v,className:"inline-flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs font-medium text-primary hover:bg-muted disabled:opacity-40",children:t("questions_send")})]}),r.jsx("div",{className:"h-1 w-full overflow-hidden rounded-b-2xl bg-muted",children:r.jsx("div",{className:"h-full bg-primary transition-[width] duration-300 ease-out",style:{width:`${(a+1)/Math.max(1,j)*100}%`}})})]})}function Ex({widgetRef:e}){const{contactState:t}=C.useContact(),{setIsOpen:n}=C.useWidgetTrigger(),{toChatScreen:o}=C.useWidgetRouter(),{renewUserToken:s}=C.useTokenRenewal(),a=Ot();return u.useImperativeHandle(e,()=>({newChat:async i=>{var d;if(!((d=t.contact)!=null&&d.token)){K.log.warn("cannot start a new chat: contact not yet initialized");return}n(!0);const c=o();c&&(i!=null&&i.message)&&await c.messageCtx.sendMessage({content:i.message})},renewUserToken:s,startVoiceCall:async()=>{var i;if(!a.enabled){K.log.warn("cannot start a voice call: `voice` is not configured");return}if(!((i=t.contact)!=null&&i.token)){K.log.warn("cannot start a voice call: contact not yet initialized");return}n(!0),await a.start()}}),[t,n,o,s,a]),null}function Ax(){const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger();return r.jsxs(et.Root,{open:e,onOpenChange:t,children:[r.jsx(To,{}),r.jsx(qf,{}),r.jsx(Uf,{}),r.jsx(Hf,{})]})}function Tx(){return C.useDisplayMode()==="companion"?r.jsx(C.WidgetLayoutProvider,{children:r.jsx(Ug,{})}):r.jsx(Ax,{})}const Ix=[{key:"loading",component:Pu},{key:"fallback",component:Ru},{key:"bot_message",component:yr},{key:"agent_message",component:yr},{key:"agent_chat_steps",component:Nx},{key:"agent_chat_spec",component:cp},{key:"agent_chat_questions",component:_x}],zx={get:async e=>localStorage.getItem(e),set:async(e,t)=>{localStorage.setItem(e,t)},remove:async e=>{localStorage.removeItem(e)}},_c=u.forwardRef(function({options:t,components:n=[],loadingComponent:o,errorComponent:s},a){var i,c,d,l;return r.jsx(F.MotionConfig,{reducedMotion:"user",children:r.jsx(C.WidgetProvider,{components:[...Ix,...n],options:{...t,capabilities:{...t.capabilities,richReplies:((i=t.capabilities)==null?void 0:i.richReplies)??!n.some(({key:m})=>["AGENT_CHAT_SPEC","BOT_MESSAGE","AGENT_MESSAGE"].includes(m.toUpperCase())),connections:((c=t.capabilities)==null?void 0:c.connections)===!0,pageEffects:((d=t.capabilities)==null?void 0:d.pageEffects)??!0,structuredQuestions:((l=t.capabilities)==null?void 0:l.structuredQuestions)??!n.some(({key:m})=>m.toUpperCase()==="AGENT_CHAT_QUESTIONS")}},storage:zx,loadingComponent:o,errorComponent:s,children:r.jsx(Iu,{children:r.jsx(C.WidgetTriggerProvider,{children:r.jsx(bh,{children:r.jsxs(Vp,{children:[r.jsx(fx,{}),r.jsx(ix,{}),r.jsx(Ex,{widgetRef:a}),t.inline?r.jsxs(r.Fragment,{children:[r.jsx(To,{}),r.jsx(hc,{})]}):r.jsx(Tx,{})]})})})})})})});_c.displayName="Widget";exports.HostedSpecRenderer=Wd;exports.Widget=_c;exports.segmentContent=Ga;exports.useJsonRenderHost=rn;
|
|
460
|
+
//# sourceMappingURL=index-B5DF6TVa.cjs.map
|