@opencx/widget-react 5.0.0-beta.7 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/Chart.impl--lw4WUeY.cjs +2 -0
  2. package/dist/Chart.impl--lw4WUeY.cjs.map +1 -0
  3. package/dist/Chart.impl-B5gmO6Us.js +207 -0
  4. package/dist/Chart.impl-B5gmO6Us.js.map +1 -0
  5. package/dist/{index-D_f1MZUH.js → index-BiL9m1to.js} +6452 -5051
  6. package/dist/index-BiL9m1to.js.map +1 -0
  7. package/dist/index-rkpSpEfw.cjs +375 -0
  8. package/dist/index-rkpSpEfw.cjs.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +1 -1
  11. package/dist/package.json.d.ts +1 -1
  12. package/dist/src/WidgetPopoverContent.d.ts.map +1 -1
  13. package/dist/src/companion/CompanionContent.d.ts.map +1 -1
  14. package/dist/src/companion/CompanionFrame.d.ts +2 -1
  15. package/dist/src/companion/CompanionFrame.d.ts.map +1 -1
  16. package/dist/src/companion/CompanionQuestions.d.ts +11 -0
  17. package/dist/src/companion/CompanionQuestions.d.ts.map +1 -0
  18. package/dist/src/companion/WidgetCompanion.d.ts.map +1 -1
  19. package/dist/src/companion/message-styles.d.ts +8 -1
  20. package/dist/src/companion/message-styles.d.ts.map +1 -1
  21. package/dist/src/components/ClarificationQuestions.d.ts.map +1 -1
  22. package/dist/src/components/ConnectionsSettings.d.ts.map +1 -1
  23. package/dist/src/components/Header.d.ts.map +1 -1
  24. package/dist/src/components/PageActionCard.d.ts +17 -0
  25. package/dist/src/components/PageActionCard.d.ts.map +1 -0
  26. package/dist/src/components/ReplyQuote.d.ts +7 -0
  27. package/dist/src/components/ReplyQuote.d.ts.map +1 -0
  28. package/dist/src/components/RichText.d.ts +6 -2
  29. package/dist/src/components/RichText.d.ts.map +1 -1
  30. package/dist/src/components/StreamingTurn.d.ts +7 -1
  31. package/dist/src/components/StreamingTurn.d.ts.map +1 -1
  32. package/dist/src/components/UserMessage.d.ts.map +1 -1
  33. package/dist/src/components/configured-text-styles.d.ts +11 -0
  34. package/dist/src/components/configured-text-styles.d.ts.map +1 -0
  35. package/dist/src/components/custom-components/AgentMessageDefaultComponent.d.ts.map +1 -1
  36. package/dist/src/hooks/useInitialQuestionRequired.d.ts +3 -0
  37. package/dist/src/hooks/useInitialQuestionRequired.d.ts.map +1 -0
  38. package/dist/src/index.d.ts.map +1 -1
  39. package/dist/src/json-render/Chart.impl.d.ts.map +1 -1
  40. package/dist/src/json-render/SpecRenderer.d.ts +6 -1
  41. package/dist/src/json-render/SpecRenderer.d.ts.map +1 -1
  42. package/dist/src/json-render/StreamingShimmer.d.ts +12 -0
  43. package/dist/src/json-render/StreamingShimmer.d.ts.map +1 -0
  44. package/dist/src/json-render/chart-axis.d.ts +30 -0
  45. package/dist/src/json-render/chart-axis.d.ts.map +1 -0
  46. package/dist/src/json-render/registry.d.ts.map +1 -1
  47. package/dist/src/json-render/segment-content.d.ts +14 -6
  48. package/dist/src/json-render/segment-content.d.ts.map +1 -1
  49. package/dist/src/page-controls/accessible-name.d.ts +7 -0
  50. package/dist/src/page-controls/accessible-name.d.ts.map +1 -0
  51. package/dist/src/page-controls/act-input.d.ts +18 -0
  52. package/dist/src/page-controls/act-input.d.ts.map +1 -0
  53. package/dist/src/page-controls/act-types.d.ts +28 -0
  54. package/dist/src/page-controls/act-types.d.ts.map +1 -0
  55. package/dist/src/page-controls/act.d.ts +10 -0
  56. package/dist/src/page-controls/act.d.ts.map +1 -0
  57. package/dist/src/page-controls/action-meaning.d.ts +7 -0
  58. package/dist/src/page-controls/action-meaning.d.ts.map +1 -0
  59. package/dist/src/page-controls/control-ref.d.ts +18 -0
  60. package/dist/src/page-controls/control-ref.d.ts.map +1 -0
  61. package/dist/src/page-controls/cursor.d.ts +72 -0
  62. package/dist/src/page-controls/cursor.d.ts.map +1 -0
  63. package/dist/src/page-controls/guard.d.ts +47 -0
  64. package/dist/src/page-controls/guard.d.ts.map +1 -0
  65. package/dist/src/page-controls/native-setter.d.ts +16 -0
  66. package/dist/src/page-controls/native-setter.d.ts.map +1 -0
  67. package/dist/src/page-controls/off-limits.d.ts +16 -0
  68. package/dist/src/page-controls/off-limits.d.ts.map +1 -0
  69. package/dist/src/page-controls/pointer-sequence.d.ts +16 -0
  70. package/dist/src/page-controls/pointer-sequence.d.ts.map +1 -0
  71. package/dist/src/page-controls/read-controls.d.ts +4 -0
  72. package/dist/src/page-controls/read-controls.d.ts.map +1 -0
  73. package/dist/src/page-controls/select-option.d.ts +3 -0
  74. package/dist/src/page-controls/select-option.d.ts.map +1 -0
  75. package/dist/src/page-controls/send-context.d.ts +20 -0
  76. package/dist/src/page-controls/send-context.d.ts.map +1 -0
  77. package/dist/src/page-controls/types.d.ts +52 -0
  78. package/dist/src/page-controls/types.d.ts.map +1 -0
  79. package/dist/src/page-marks/agent-mark.d.ts +6 -5
  80. package/dist/src/page-marks/agent-mark.d.ts.map +1 -1
  81. package/dist/src/page-marks/mark-source.d.ts +6 -0
  82. package/dist/src/page-marks/mark-source.d.ts.map +1 -0
  83. package/dist/src/page-marks/mark-thumbnail.d.ts +2 -0
  84. package/dist/src/page-marks/mark-thumbnail.d.ts.map +1 -1
  85. package/dist/src/page-marks/page-element.d.ts +1 -7
  86. package/dist/src/page-marks/page-element.d.ts.map +1 -1
  87. package/dist/src/page-marks/usePageMarking.d.ts +1 -6
  88. package/dist/src/page-marks/usePageMarking.d.ts.map +1 -1
  89. package/dist/src/page-privacy.d.ts +11 -0
  90. package/dist/src/page-privacy.d.ts.map +1 -0
  91. package/dist/src/screens/chat/ChatFooter.d.ts.map +1 -1
  92. package/dist/src/screens/chat/ChatInput.d.ts +3 -1
  93. package/dist/src/screens/chat/ChatInput.d.ts.map +1 -1
  94. package/dist/src/screens/chat/agent/AgentChatPageActions.d.ts +13 -0
  95. package/dist/src/screens/chat/agent/AgentChatPageActions.d.ts.map +1 -0
  96. package/dist/src/screens/chat/agent/AgentChatPageEffects.d.ts.map +1 -1
  97. package/dist/src/screens/chat/agent/use-page-effect-is-current.d.ts +5 -0
  98. package/dist/src/screens/chat/agent/use-page-effect-is-current.d.ts.map +1 -0
  99. package/dist/src/screens/chat/agent/useStreamFollow.d.ts +4 -0
  100. package/dist/src/screens/chat/agent/useStreamFollow.d.ts.map +1 -1
  101. package/dist/src/screens/chat/usePageMarkComposer.d.ts +1 -0
  102. package/dist/src/screens/chat/usePageMarkComposer.d.ts.map +1 -1
  103. package/dist/src/screens/index.d.ts.map +1 -1
  104. package/package.json +3 -3
  105. package/dist/Chart.impl-C-1c9nkk.js +0 -153
  106. package/dist/Chart.impl-C-1c9nkk.js.map +0 -1
  107. package/dist/Chart.impl-Ck7Md2bC.cjs +0 -2
  108. package/dist/Chart.impl-Ck7Md2bC.cjs.map +0 -1
  109. package/dist/index-B3pRBUF2.cjs +0 -343
  110. package/dist/index-B3pRBUF2.cjs.map +0 -1
  111. package/dist/index-D_f1MZUH.js.map +0 -1
@@ -0,0 +1,375 @@
1
+ "use strict";var gi=Object.defineProperty;var xi=(e,t,n)=>t in e?gi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var eo=(e,t,n)=>xi(e,typeof t!="symbol"?t+"":t,n);const r=require("react/jsx-runtime"),bi=require("@radix-ui/react-popover"),H=require("framer-motion"),u=require("react"),C=require("@opencx/widget-react-headless"),v=require("zod"),Q=require("@opencx/widget-core"),z=require("lucide-react"),wi=require("clsx"),yi=require("tailwind-merge"),vi=require("@radix-ui/react-slot"),ms=require("class-variance-authority"),hs=require("remark-gfm"),ki=require("react-markdown"),Fn=require("rehype-raw"),Ce=require("rehype-sanitize"),ji=require("@radix-ui/react-avatar"),fs=require("@uiw/react-iframe"),to=require("tinycolor2"),Ci=require("@radix-ui/react-tooltip"),Dt=require("react-dom"),Si=require("@radix-ui/react-menu"),Ni=require("html-to-image"),_i=require("react-dropzone"),gs=require("@shardsui/notation"),Ei=require("react-use/lib/useAsyncFn");function Ft(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 Ye=Ft(bi),Ke=Ft(u),Ct=Ft(ji),Se=Ft(Ci),ke=Ft(Si);var xs=v.z.union([v.z.string(),v.z.number(),v.z.boolean(),v.z.null(),v.z.object({$state:v.z.string()})]);v.z.union([v.z.string(),v.z.object({$state:v.z.string()})]);v.z.union([v.z.number(),v.z.object({$state:v.z.string()})]);v.z.union([v.z.boolean(),v.z.object({$state:v.z.string()})]);function bs(e,t){if(e!=null)return typeof e=="object"&&"$state"in e?ie(t,e.$state):e}function Ti(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Wt(e){return(e.startsWith("/")?e.slice(1).split("/"):e.split("/")).map(Ti)}function ie(e,t){if(!t||t==="/")return e;const n=Wt(t);let o=e;for(const s of n){if(o==null)return;if(Array.isArray(o)){const i=parseInt(s,10);o=o[i]}else if(typeof o=="object")o=o[s];else return}return o}function ws(e){return/^\d+$/.test(e)}function Ai(e,t,n){const o=Wt(t);if(o.length===0)return;let s=e;for(let a=0;a<o.length-1;a++){const c=o[a],l=o[a+1],d=l!==void 0&&(ws(l)||l==="-");if(Array.isArray(s)){const p=parseInt(c,10);(s[p]===void 0||typeof s[p]!="object")&&(s[p]=d?[]:{}),s=s[p]}else(!(c in s)||typeof s[c]!="object")&&(s[c]=d?[]:{}),s=s[c]}const i=o[o.length-1];if(Array.isArray(s))if(i==="-")s.push(n);else{const a=parseInt(i,10);s[a]=n}else s[i]=n}function En(e,t,n){const o=Wt(t);if(o.length===0)return;let s=e;for(let a=0;a<o.length-1;a++){const c=o[a],l=o[a+1],d=l!==void 0&&(ws(l)||l==="-");if(Array.isArray(s)){const p=parseInt(c,10);(s[p]===void 0||typeof s[p]!="object")&&(s[p]=d?[]:{}),s=s[p]}else(!(c in s)||typeof s[c]!="object")&&(s[c]=d?[]:{}),s=s[c]}const i=o[o.length-1];if(Array.isArray(s))if(i==="-")s.push(n);else{const a=parseInt(i,10);s.splice(a,0,n)}else s[i]=n}function no(e,t){const n=Wt(t);if(n.length===0)return;let o=e;for(let i=0;i<n.length-1;i++){const a=n[i];if(Array.isArray(o)){const c=parseInt(a,10);if(o[c]===void 0||typeof o[c]!="object")return;o=o[c]}else{if(!(a in o)||typeof o[a]!="object")return;o=o[a]}}const s=n[n.length-1];if(Array.isArray(o)){const i=parseInt(s,10);i>=0&&i<o.length&&o.splice(i,1)}else delete o[s]}function Wn(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((a,c)=>Wn(a,t[c]));const n=e,o=t,s=Object.keys(n),i=Object.keys(o);return s.length!==i.length?!1:s.every(a=>Wn(n[a],o[a]))}function Hn(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 ys(e,t){switch(t.op){case"add":En(e,t.path,t.value);break;case"replace":Ai(e,t.path,t.value);break;case"remove":no(e,t.path);break;case"move":{if(!t.from)break;const n=ie(e,t.from);no(e,t.from),En(e,t.path,n);break}case"copy":{if(!t.from)break;const n=ie(e,t.from);En(e,t.path,n);break}case"test":{const n=ie(e,t.path);if(!Wn(n,t.value))throw new Error(`Test operation failed: value at "${t.path}" does not match`);break}}return e}function zi(e,t){return ys(e,t),e}function Ii(e){const t={};let n=0;function o(a){const c=`el-${n++}`,{type:l,props:d,children:p,...m}=a,h=[];if(Array.isArray(p))for(const y of p)y&&typeof y=="object"&&"type"in y&&h.push(o(y));const f={type:l??"unknown",props:d??{},children:h};for(const[y,w]of Object.entries(m))y!=="state"&&w!==void 0&&(f[y]=w);return t[c]=f,c}const i={root:o(e),elements:t};return e.state&&typeof e.state=="object"&&!Array.isArray(e.state)&&(i.state=e.state),i}function Mi(e,t={}){const n=e.split(`
2
+ `),o={...t};for(const s of n){const i=Hn(s);i&&ys(o,i)}return o}var Ri="spec",Pi=`data-${Ri}`;function ro(e,t,n){const o=Wt(t);if(o.length===0)return e;const s={...e};let i=s;for(let c=0;c<o.length-1;c++){const l=o[c],d=i[l];if(Array.isArray(d))i[l]=[...d];else if(d!==null&&typeof d=="object")i[l]={...d};else{const p=o[c+1];i[l]=p!==void 0&&/^\d+$/.test(p)?[]:{}}i=i[l]}const a=o[o.length-1];return Array.isArray(i)?a==="-"?i.push(n):i[parseInt(a,10)]=n:i[a]=n,s}function Oi(e={}){let t={...e};const n=new Set;function o(){for(const s of n)s()}return{get(s){return ie(t,s)},set(s,i){ie(t,s)!==i&&(t=ro(t,s,i),o())},update(s){let i=!1,a=t;for(const[c,l]of Object.entries(s))ie(a,c)!==l&&(a=ro(a,c,l),i=!0);i&&(t=a,o())},getSnapshot(){return t},getServerSnapshot(){return t},subscribe(s){return n.add(s),()=>{n.delete(s)}}}}var Tn=20;function fr(e,t="",n=0,o,s){const i=o??new Set,a=s??{current:!1},c={};for(const[l,d]of Object.entries(e)){const p=`${t}/${l}`;n<Tn&&d!==null&&typeof d=="object"&&!Array.isArray(d)&&Object.getPrototypeOf(d)===Object.prototype&&!i.has(d)?(i.add(d),Object.assign(c,fr(d,p,n+1,i,a))):(process.env.NODE_ENV!=="production"&&!a.current&&n>=Tn&&d!==null&&typeof d=="object"&&!Array.isArray(d)&&Object.getPrototypeOf(d)===Object.prototype&&!i.has(d)&&(a.current=!0,console.warn(`flattenToPointers: depth limit (${Tn}) reached. Nested state beyond this depth will be treated as a leaf value.`)),c[p]=d)}return c}var Zt=v.z.union([v.z.number(),v.z.object({$state:v.z.string()})]),gr={eq:v.z.unknown().optional(),neq:v.z.unknown().optional(),gt:Zt.optional(),gte:Zt.optional(),lt:Zt.optional(),lte:Zt.optional(),not:v.z.literal(!0).optional()},$i=v.z.object({$state:v.z.string(),...gr}),Li=v.z.object({$item:v.z.string(),...gr}),Di=v.z.object({$index:v.z.literal(!0),...gr}),oo=v.z.union([$i,Li,Di]),Bn=v.z.lazy(()=>v.z.union([v.z.boolean(),oo,v.z.array(oo),v.z.object({$and:v.z.array(Bn)}),v.z.object({$or:v.z.array(Bn)})]));function ht(e,t){return typeof e=="object"&&e!==null&&"$state"in e&&typeof e.$state=="string"?ie(t.stateModel,e.$state):e}function Fi(e){return"$item"in e}function Wi(e){return"$index"in e}function Hi(e,t){return Wi(e)?t.repeatIndex:Fi(e)?t.repeatItem===void 0?void 0:e.$item===""?t.repeatItem:ie(t.repeatItem,e.$item):ie(t.stateModel,e.$state)}function so(e,t){const n=Hi(e,t);let o;if(e.eq!==void 0){const s=ht(e.eq,t);o=n===s}else if(e.neq!==void 0){const s=ht(e.neq,t);o=n!==s}else if(e.gt!==void 0){const s=ht(e.gt,t);o=typeof n=="number"&&typeof s=="number"?n>s:!1}else if(e.gte!==void 0){const s=ht(e.gte,t);o=typeof n=="number"&&typeof s=="number"?n>=s:!1}else if(e.lt!==void 0){const s=ht(e.lt,t);o=typeof n=="number"&&typeof s=="number"?n<s:!1}else if(e.lte!==void 0){const s=ht(e.lte,t);o=typeof n=="number"&&typeof s=="number"?n<=s:!1}else o=!!n;return e.not===!0?!o:o}function Bi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"$and"in e}function Ui(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"$or"in e}function wt(e,t){return e===void 0?!0:typeof e=="boolean"?e:Array.isArray(e)?e.every(n=>so(n,t)):Bi(e)?e.$and.every(n=>wt(n,t)):Ui(e)?e.$or.some(n=>wt(n,t)):so(e,t)}function qi(e){const t=new Map;for(const n of e)t.set(n.name,n);return t}function Vi(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 Yi(e){return typeof e=="object"&&e!==null&&"$state"in e&&typeof e.$state=="string"}function vs(e){return typeof e=="object"&&e!==null&&"$item"in e&&typeof e.$item=="string"}function ks(e){return typeof e=="object"&&e!==null&&"$index"in e&&e.$index===!0}function js(e){return typeof e=="object"&&e!==null&&"$bindState"in e&&typeof e.$bindState=="string"}function Cs(e){return typeof e=="object"&&e!==null&&"$bindItem"in e&&typeof e.$bindItem=="string"}function Xi(e){return typeof e=="object"&&e!==null&&"$cond"in e&&"$then"in e&&"$else"in e}function Gi(e){return typeof e=="object"&&e!==null&&"$computed"in e&&typeof e.$computed=="string"}function Ki(e){return typeof e=="object"&&e!==null&&"$template"in e&&typeof e.$template=="string"}var Zi=100,An=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 nt(e,t){var n;if(e==null)return e;if(Yi(e))return ie(t.stateModel,e.$state);if(vs(e))return t.repeatItem===void 0?void 0:e.$item===""?t.repeatItem:ie(t.repeatItem,e.$item);if(ks(e))return t.repeatIndex;if(js(e))return ie(t.stateModel,e.$bindState);if(Cs(e)){const o=xr(e.$bindItem,t);return o===void 0?void 0:ie(t.stateModel,o)}if(Xi(e)){const o=wt(e.$cond,t);return nt(o?e.$then:e.$else,t)}if(Gi(e)){const o=(n=t.functions)==null?void 0:n[e.$computed];if(!o){An.has(e.$computed)||(An.size<Zi&&An.add(e.$computed),console.warn(`Unknown $computed function: "${e.$computed}"`));return}const s={};if(e.args)for(const[i,a]of Object.entries(e.args))s[i]=nt(a,t);return o(s)}if(Ki(e))return e.$template.replace(/\$\{([^}]+)\}/g,(o,s)=>{if(s.startsWith("/")){const a=ie(t.stateModel,s);return a!=null?String(a):""}if(t.repeatItem!==void 0){const a=ie(t.repeatItem,s);if(a!=null)return String(a)}const i=ie(t.stateModel,"/"+s);return i!=null?String(i):""});if(Array.isArray(e))return e.map(o=>nt(o,t));if(typeof e=="object"){const o=Vi(e,t.directives);if(o)return o.resolve(e,t);const s={};for(const[i,a]of Object.entries(e))s[i]=nt(a,t);return s}return e}function Ji(e,t){const n={};for(const[o,s]of Object.entries(e))n[o]=nt(s,t);return n}function Qi(e,t){let n;for(const[o,s]of Object.entries(e))if(js(s))n||(n={}),n[o]=s.$bindState;else if(Cs(s)){const i=xr(s.$bindItem,t);i!==void 0&&(n||(n={}),n[o]=i)}return n}function ao(e,t){return vs(e)?xr(e.$item,t):ks(e)?t.repeatIndex:nt(e,t)}var Ss=new Set;function ec(e){for(const t of Ss){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 tc(e){for(const t of Ss){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 io=0;function nc(){return io+=1,`${Date.now()}-${io}`}var rc=0,co=new Set;function oc(){return rc>0}function sc(e){return co.add(e),()=>{co.delete(e)}}var ac=v.z.object({title:v.z.string(),message:v.z.string(),confirmLabel:v.z.string().optional(),cancelLabel:v.z.string().optional(),variant:v.z.enum(["default","danger"]).optional()}),ic=v.z.union([v.z.object({navigate:v.z.string()}),v.z.object({set:v.z.record(v.z.string(),v.z.unknown())}),v.z.object({action:v.z.string()})]),cc=v.z.union([v.z.object({set:v.z.record(v.z.string(),v.z.unknown())}),v.z.object({action:v.z.string()})]);v.z.object({action:v.z.string(),params:v.z.record(v.z.string(),xs).optional(),confirm:ac.optional(),onSuccess:ic.optional(),onError:cc.optional(),preventDefault:v.z.boolean().optional()});function lc(e,t){const n={};if(e.params)for(const[s,i]of Object.entries(e.params))n[s]=bs(i,t);let o=e.confirm;return o&&(o={...o,message:lo(o.message,t),title:lo(o.title,t)}),{action:e.action,params:n,confirm:o,onSuccess:e.onSuccess,onError:e.onError}}function lo(e,t){return e.replace(/\$\{([^}]+)\}/g,(n,o)=>{const s=bs({$state:o},t);return String(s??"")})}async function uo(e){const{action:t,handler:n,setState:o,navigate:s,executeAction:i}=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[a,c]of Object.entries(t.onSuccess.set))o(a,c);else"action"in t.onSuccess&&i&&await i(t.onSuccess.action)}catch(a){if(t.onError)if("set"in t.onError)for(const[c,l]of Object.entries(t.onError.set)){const d=typeof l=="string"&&l==="$error.message"?a.message:l;o(c,d)}else"action"in t.onError&&i&&await i(t.onError.action);else throw a}}var dc=v.z.object({type:v.z.string(),args:v.z.record(v.z.string(),xs).optional(),message:v.z.string()});v.z.object({checks:v.z.array(dc).optional(),validateOn:v.z.enum(["change","blur","submit"]).optional(),enabled:Bn.optional()});var po=(e,t)=>{const n=t==null?void 0:t.other;return e===n},uc={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:po,equalTo:po,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 pc(e,t){const{value:n,stateModel:o,customFunctions:s}=t,i={};if(e.args)for(const[l,d]of Object.entries(e.args))i[l]=nt(d,{stateModel:o});const a=uc[e.type]??(s==null?void 0:s[e.type]);if(!a)return console.warn(`Unknown validation function: ${e.type}`),{type:e.type,valid:!0,message:e.message};const c=a(n,i);return{type:e.type,valid:c,message:e.message}}function mc(e,t){const n=[],o=[];if(e.enabled&&!wt(e.enabled,{stateModel:t.stateModel}))return{valid:!0,errors:[],checks:[]};if(e.checks)for(const s of e.checks){const i=pc(s,t);n.push(i),i.valid||o.push(i.message)}return{valid:o.length===0,errors:o,checks:n}}var hc=["patch"];function fc(e){var t;return(t=e==null?void 0:e.modes)!=null&&t.length?e.modes:hc}function gc(){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 xc(){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 bc(){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 wc(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 yc(e,t){const n=fc(e),o=[];o.push("EDITING EXISTING SPECS:"),o.push("");const s=wc(n);s&&(o.push(s),o.push(""));for(const i of n){switch(i){case"patch":o.push(gc());break;case"merge":o.push(xc());break;case"diff":o.push(bc());break}o.push("")}return o.join(`
7
+ `)}function Ns(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 vc(){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 kc(e,t){const n=vc();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 jc(this,s)}}}function jc(e,t){const n=t.components,o=t.actions,s=n?Object.keys(n):[],i=o?Object.keys(o):[],a=Cc(e.definition,t);return{schema:e,data:t,componentNames:s,actionNames:i,prompt(c={}){return _c(this,c)},jsonSchema(c={}){return qe(a,c.strict??!1)},validate(c){const l=a.safeParse(c);return l.success?{success:!0,data:l.data}:{success:!1,error:l.error}},zodSchema(){return a},get _specType(){throw new Error("_specType is only for type inference")}}}function Cc(e,t){return rn(e.spec,t)}function rn(e,t){switch(e.kind){case"string":return v.z.string();case"number":return v.z.number();case"boolean":return v.z.boolean();case"any":return v.z.any();case"array":{const n=rn(e.inner,t);return v.z.array(n)}case"object":{const n=e.inner,o={};for(const[s,i]of Object.entries(n)){let a=rn(i,t);i.optional&&(a=a.optional()),o[s]=a}return v.z.object(o)}case"record":{const n=rn(e.inner,t);return v.z.record(v.z.string(),n)}case"ref":{const n=e.inner,o=Sc(n,t);return o.length===0?v.z.string():o.length===1?v.z.literal(o[0]):v.z.enum(o)}case"propsOf":{const n=e.inner,o=Nc(n,t);return o.length===0?v.z.record(v.z.string(),v.z.unknown()):o.length===1?o[0]:v.z.record(v.z.string(),v.z.unknown())}default:return v.z.unknown()}}function Sc(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 Nc(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 _c(e,t){if(e.schema.promptTemplate){const E={catalog:e.data,componentNames:e.componentNames,actionNames:e.actionNames,options:t,formatZodType:je};return e.schema.promptTemplate(E)}const{system:n="You are a UI generator that outputs JSON.",customRules:o=[],mode:s="standalone"}=t,i=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,a=[];a.push(n),a.push(""),i==="inline"?(a.push("OUTPUT FORMAT (text + JSONL, RFC 6902 JSON Patch):"),a.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."),a.push("The JSONL lines use RFC 6902 JSON Patch operations to build a UI tree. Always wrap them in a ```spec fence block:"),a.push(" ```spec"),a.push(' {"op":"add","path":"/root","value":"main"}'),a.push(' {"op":"add","path":"/elements/main","value":{"type":"Card","props":{"title":"Hello"},"children":[]}}'),a.push(" ```"),a.push("If the user's message does not require a UI (e.g. a greeting or clarifying question), respond with text only — no JSONL.")):(a.push("OUTPUT FORMAT (JSONL, RFC 6902 JSON Patch):"),a.push("Output JSONL (one JSON object per line) using RFC 6902 JSON Patch operations to build a UI tree.")),a.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."),a.push(""),a.push("Example output (each line is a separate JSON object):"),a.push("");const c=e.data.components,l=e.componentNames,d=l[0]||"Component",p=l.length>1?l[1]:d,m=c==null?void 0:c[d],h=c==null?void 0:c[p],f=m?mo(m):{},y=h?mo(h):{},w=h!=null&&h.props?Ec(h.props):null,k=w?{...y,[w]:{$item:"title"}}:y,x=[JSON.stringify({op:"add",path:"/root",value:"main"}),JSON.stringify({op:"add",path:"/elements/main",value:{type:d,props:f,children:["child-1","list"]}}),JSON.stringify({op:"add",path:"/elements/child-1",value:{type:p,props:y,children:[]}}),JSON.stringify({op:"add",path:"/elements/list",value:{type:d,props:f,repeat:{statePath:"/items",key:"id"},children:["item"]}}),JSON.stringify({op:"add",path:"/elements/item",value:{type:p,props:k,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
+ `);a.push(`${x}
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.`),a.push(""),a.push("INITIAL STATE:"),a.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."),a.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."),a.push("Output state patches right after the elements that reference them, so the UI fills in progressively as it streams."),a.push("Stream state progressively - output one patch per array item instead of one giant blob:"),a.push(' For arrays: {"op":"add","path":"/state/posts/0","value":{"id":"1","title":"First Post",...}} then /state/posts/1, /state/posts/2, etc.'),a.push(' For scalars: {"op":"add","path":"/state/newTodoText","value":""}'),a.push(' Initialize the array first if needed: {"op":"add","path":"/state/posts","value":[]}'),a.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.'),a.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."),a.push(""),a.push("DYNAMIC LISTS (repeat field):"),a.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" } }.'),a.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.'),a.push(`Example: ${JSON.stringify({type:d,props:f,repeat:{statePath:"/todos",key:"id"},children:["todo-item"]})}`),a.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.'),a.push("ALWAYS use the repeat field for lists backed by state arrays. NEVER hardcode individual elements for each array item."),a.push('IMPORTANT: "repeat" is a top-level field on the element (sibling of type/props/children), NOT inside props.'),a.push(""),a.push("ARRAY STATE ACTIONS:"),a.push('Use action "pushState" to append items to arrays. Params: { statePath: "/arrayPath", value: { ...item }, clearStatePath: "/inputPath" }.'),a.push('Values inside pushState can contain { "$state": "/statePath" } references to read current state (e.g. the text from an input field).'),a.push('Use "$id" inside a pushState value to auto-generate a unique ID.'),a.push('Example: on: { "press": { "action": "pushState", "params": { "statePath": "/todos", "value": { "id": "$id", "title": { "$state": "/newTodoText" }, "completed": false }, "clearStatePath": "/newTodoText" } } }'),a.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.`),a.push("For lists where users can add/remove items (todos, carts, etc.), use pushState and removeState instead of hardcoding with setState."),a.push(""),a.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.'),a.push("");const S=c;if(S){a.push(`AVAILABLE COMPONENTS (${e.componentNames.length}):`),a.push("");for(const[E,M]of Object.entries(S)){const W=M.props?je(M.props):"{}",q=M.slots&&M.slots.length>0?" [accepts children]":"",V=M.events&&M.events.length>0?` [events: ${M.events.join(", ")}]`:"",U=M.description?` - ${M.description}`:"";a.push(`- ${E}: ${W}${U}${q}${V}`)}a.push("")}const b=e.data.actions,N=e.schema.builtInActions??[],j=b&&e.actionNames.length>0,g=N.length>0;if(j||g){a.push("AVAILABLE ACTIONS:"),a.push("");for(const E of N)a.push(`- ${E.name}: ${E.description} [built-in]`);if(j)for(const[E,M]of Object.entries(b))a.push(`- ${E}${M.description?`: ${M.description}`:""}`);a.push("")}a.push("EVENTS (the `on` field):"),a.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."),a.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": { ... } }`.'),a.push(""),a.push("Example:"),a.push(` ${JSON.stringify({type:d,props:f,on:{press:{action:"setState",params:{statePath:"/saved",value:!0}}},children:[]})}`),a.push(""),a.push('Action params can use dynamic references to read from state: { "$state": "/statePath" }.'),a.push("IMPORTANT: Do NOT put action/actionParams inside props. Always use the `on` field for event bindings."),a.push(""),a.push("VISIBILITY CONDITIONS:"),a.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."),a.push(`Correct: ${JSON.stringify({type:d,props:f,visible:{$state:"/activeTab",eq:"home"},children:["..."]})}`),a.push('- `{ "$state": "/path" }` - visible when state at path is truthy'),a.push('- `{ "$state": "/path", "not": true }` - visible when state at path is falsy'),a.push('- `{ "$state": "/path", "eq": "value" }` - visible when state equals value'),a.push('- `{ "$state": "/path", "neq": "value" }` - visible when state does not equal value'),a.push('- `{ "$state": "/path", "gt": N }` / `gte` / `lt` / `lte` - numeric comparisons'),a.push("- Use ONE operator per condition (eq, neq, gt, gte, lt, lte). Do not combine multiple operators."),a.push('- Any condition can add `"not": true` to invert its result'),a.push("- `[condition, condition]` - all conditions must be true (implicit AND)"),a.push('- `{ "$and": [condition, condition] }` - explicit AND (use when nesting inside $or)'),a.push('- `{ "$or": [condition, condition] }` - at least one must be true (OR)'),a.push("- `true` / `false` - always visible/hidden"),a.push(""),a.push("Use a component with on.press bound to setState to update state and drive visibility."),a.push(`Example: A ${d} 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.`),a.push(""),a.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.'),a.push(""),a.push("DYNAMIC PROPS:"),a.push("Any prop value can be a dynamic expression that resolves based on state. Three forms are supported:"),a.push(""),a.push('1. Read-only state: `{ "$state": "/statePath" }` - resolves to the value at that state path (one-way read).'),a.push(' Example: `"color": { "$state": "/theme/primary" }` reads the color from state.'),a.push(""),a.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.).'),a.push(' Example: `"value": { "$bindState": "/form/email" }` binds the input value to /form/email.'),a.push(' Inside repeat scopes: `"checked": { "$bindItem": "completed" }` binds to the current item\'s completed field.'),a.push(""),a.push('3. Conditional: `{ "$cond": <condition>, "$then": <value>, "$else": <value> }` - evaluates the condition (same syntax as visibility conditions) and picks the matching value.'),a.push(' Example: `"color": { "$cond": { "$state": "/activeTab", "eq": "home" }, "$then": "#007AFF", "$else": "#8E8E93" }`'),a.push(""),a.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."),a.push(""),a.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>`.'),a.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.'),a.push("");const _=e.data.functions;if(_&&Object.keys(_).length>0){a.push('5. Computed: `{ "$computed": "<functionName>", "args": { "key": <expression> } }` - calls a registered function with resolved args and returns the result.'),a.push(' Example: `"value": { "$computed": "fullName", "args": { "first": { "$state": "/form/firstName" }, "last": { "$state": "/form/lastName" } } }`'),a.push(" Available functions:");for(const E of Object.keys(_))a.push(` - ${E}`);a.push("")}const A=t.directives;if(A&&A.length>0){a.push("CUSTOM DYNAMIC VALUES:"),a.push("");for(const E of A){const M=E.description?` (${E.description})`:"";a.push(`- ${E.name}${M}: ${je(E.schema)}`)}a.push(""),a.push("Directives compose: any value field can contain another directive or a $state expression, resolved inside-out."),a.push("")}(c?Object.entries(c).some(([,E])=>E.props?je(E.props).includes("checks"):!1):!1)&&(a.push("VALIDATION:"),a.push("Form components that accept a `checks` prop support client-side validation."),a.push('Each check is an object: { "type": "<name>", "message": "...", "args": { ... } }'),a.push(""),a.push("Built-in validation types:"),a.push(" - required — value must be non-empty"),a.push(" - email — valid email format"),a.push(' - minLength — minimum string length (args: { "min": N })'),a.push(' - maxLength — maximum string length (args: { "max": N })'),a.push(' - pattern — match a regex (args: { "pattern": "regex" })'),a.push(' - min — minimum numeric value (args: { "min": N })'),a.push(' - max — maximum numeric value (args: { "max": N })'),a.push(" - numeric — value must be a number"),a.push(" - url — valid URL format"),a.push(' - matches — must equal another field (args: { "other": { "$state": "/path" } })'),a.push(' - equalTo — alias for matches (args: { "other": { "$state": "/path" } })'),a.push(' - lessThan — value must be less than another field (args: { "other": { "$state": "/path" } })'),a.push(' - greaterThan — value must be greater than another field (args: { "other": { "$state": "/path" } })'),a.push(' - requiredIf — required only when another field is truthy (args: { "field": { "$state": "/path" } })'),a.push(""),a.push("Example:"),a.push(' "checks": [{ "type": "required", "message": "Email is required" }, { "type": "email", "message": "Invalid email" }]'),a.push(""),a.push("IMPORTANT: When using checks, the component must also have a { $bindState } or { $bindItem } on its value/checked prop for two-way binding."),a.push("Always include validation checks on form inputs for a good user experience (e.g. required, email, minLength)."),a.push("")),(j||g)&&(a.push("STATE WATCHERS:"),a.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."),a.push("Maps state paths (JSON Pointers) to action bindings. When the value at a watched path changes, the bound actions fire automatically."),a.push(""),a.push("Example (cascading select — country changes trigger city loading):"),a.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:[]})}`),a.push(""),a.push("Use `watch` for cascading dependencies where changing one field should trigger side effects (loading data, resetting dependent fields, computing derived values)."),a.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."),a.push(""));const P=t.editModes;P&&P.length>0&&a.push(yc({modes:P})),a.push("RULES:");const O=i==="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')"],I=e.schema.defaultRules??[];return[...O,...I,...o].forEach((E,M)=>{a.push(`${M+1}. ${E}`)}),a.join(`
11
+ `)}function mo(e){return e.example&&Object.keys(e.example).length>0?e.example:e.props?_s(e.props):{}}function _s(e){if(!e||!e._def)return{};const t=e._def,n=st(e);if(n!=="ZodObject"&&n!=="object")return{};const o=typeof t.shape=="function"?t.shape():t.shape;if(!o)return{};const s={};for(const[i,a]of Object.entries(o)){const c=st(a);c==="ZodOptional"||c==="optional"||c==="ZodNullable"||c==="nullable"||(s[i]=Un(a))}return s}function Un(e){if(!e||!e._def)return"...";const t=e._def;switch(st(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?Un(o):null}case"ZodArray":case"array":return[];case"ZodObject":case"object":return _s(e);case"ZodUnion":case"union":{const o=t.options;return o&&o.length>0?Un(o[0]):"..."}default:return"..."}}function Ec(e){if(!e||!e._def)return null;const t=e._def,n=st(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,i]of Object.entries(o)){const a=st(i);if(!(a==="ZodOptional"||a==="optional"||a==="ZodNullable"||a==="nullable")&&(a==="ZodString"||a==="string"))return s}return null}function st(e){if(!e||!e._def)return"";const t=e._def;return t.typeName??t.type??""}function je(e){if(!e||!e._def)return"unknown";const t=e._def;switch(st(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<${je(o)}>`:"Array<unknown>"}case"ZodObject":case"object":{const o=typeof t.shape=="function"?t.shape():t.shape;return o?`{ ${Object.entries(o).map(([i,a])=>{const c=st(a);return`${i}${c==="ZodOptional"||c==="ZodNullable"||c==="optional"||c==="nullable"?"?":""}: ${je(a)}`}).join(", ")} }`:"object"}case"ZodOptional":case"optional":case"ZodNullable":case"nullable":{const o=t.innerType??t.wrapped;return o?je(o):"unknown"}case"ZodUnion":case"union":{const o=t.options;return o?o.map(s=>je(s)).join(" | "):"unknown"}case"ZodRecord":case"record":{const o=t.keyType??void 0,s=t.valueType??t.element??void 0,i=o?je(o):"string",a=s?je(s):"unknown";return`Record<${i}, ${a}>`}case"ZodDefault":case"default":{const o=t.innerType??t.wrapped;return o?je(o):"unknown"}default:return"unknown"}}function ho(e){return typeof e.type=="string"?e.type:typeof e.typeName=="string"?e.typeName:""}function fo(e){return e.startsWith("Zod")?e.slice(3).toLowerCase():e.toLowerCase()}function qe(e,t=!1){const n=e._def;switch(fo(ho(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?qe(s,t):{}}}case"object":{const s=n.shape,i=typeof s=="function"?s():s;if(!i)return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{type:"object"};const a={},c=[];for(const[l,d]of Object.entries(i)){const p=d._def,m=fo(ho(p)),h=m==="optional"||m==="nullable";if(t)if(c.push(l),h){const f=qe(d,t);a[l]={anyOf:[f,{type:"null"}]}}else a[l]=qe(d,t);else a[l]=qe(d),h||c.push(l)}return{type:"object",properties:a,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?qe(s):!0}}case"optional":case"nullable":{const s=n.innerType;return s?qe(s,t):{}}case"union":{const s=n.options;return s?{anyOf:s.map(i=>qe(i,t))}:{}}case"any":case"unknown":return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{};default:return{}}}function Tc(e,t){return e.createCatalog(t)}var Ac=kc(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."]}),Es=u.createContext(null);function zc(e,t){return e?null:Object.keys(t).length===0?{}:fr(t)}function Ic({store:e,initialState:t={},onStateChange:n,children:o}){const s=u.useRef(void 0);!e&&!s.current&&(s.current=Oi(t));const i=e??s.current,a=u.useRef(i);a.current=i;const c=u.useRef(!!e);c.current=!!e;const l=u.useRef(e?"controlled":"uncontrolled"),d=u.useRef(!1);if(process.env.NODE_ENV!=="production"){const b=e?"controlled":"uncontrolled";b!==l.current&&!d.current&&(d.current=!0,console.warn(`StateProvider: switching from ${l.current} to ${b} mode is not supported.`))}const p=u.useRef(t),m=u.useRef(zc(!!e,t));u.useEffect(()=>{if(e||t===p.current)return;p.current=t;const b=t&&Object.keys(t).length>0?fr(t):{},N=m.current??{},j=new Set([...Object.keys(N),...Object.keys(b)]),g={};for(const _ of j)N[_]!==b[_]&&(g[_]=_ in b?b[_]:void 0);m.current=b,Object.keys(g).length>0&&i.update(g)},[e,t,i]);const h=u.useSyncExternalStore(i.subscribe,i.getSnapshot,i.getServerSnapshot??i.getSnapshot),f=u.useRef(n);f.current=n;const y=u.useCallback((b,N)=>{var _;const j=a.current,g=j.getSnapshot();j.set(b,N),!c.current&&j.getSnapshot()!==g&&((_=f.current)==null||_.call(f,[{path:b,value:N}]))},[]),w=u.useCallback(b=>{var g;const N=a.current,j=N.getSnapshot();if(N.update(b),!c.current&&N.getSnapshot()!==j){const _=[];for(const[A,R]of Object.entries(b))ie(j,A)!==R&&_.push({path:A,value:R});_.length>0&&((g=f.current)==null||g.call(f,_))}},[]),k=u.useCallback(b=>a.current.get(b),[]),x=u.useCallback(()=>a.current.getSnapshot(),[]),S=u.useMemo(()=>({state:h,get:k,set:y,update:w,getSnapshot:x}),[h,k,y,w,x]);return r.jsx(Es.Provider,{value:S,children:o})}function Ht(){const e=u.useContext(Es);if(!e)throw new Error("useStateStore must be used within a StateProvider");return e}var Ts=u.createContext(null);function Mc({children:e}){const{state:t}=Ht(),n=u.useMemo(()=>({stateModel:t}),[t]),o=u.useMemo(()=>i=>wt(i,n),[n]),s=u.useMemo(()=>({isVisible:o,ctx:n}),[o,n]);return r.jsx(Ts.Provider,{value:s,children:e})}function Rc(){const e=u.useContext(Ts);if(!e)throw new Error("useVisibility must be used within a VisibilityProvider");return e}var As=u.createContext(null);function Pc(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 i=e[s],a=t[s];if(i!==a){if(typeof i=="object"&&i!==null&&typeof a=="object"&&a!==null){const c=i.$state,l=a.$state;if(typeof c=="string"&&c===l)continue}return!1}}return!0}function Oc(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 i=n[s],a=o[s];if(i.type!==a.type||i.message!==a.message||!Pc(i.args,a.args))return!1}return!0}function $c({customFunctions:e={},children:t}){const{state:n,getSnapshot:o}=Ht(),[s,i]=u.useState({}),a=u.useRef({}),[c,l]=u.useState({}),d=u.useCallback((w,k)=>{l(x=>{const S=x[w];return S&&Oc(S,k)?x:{...x,[w]:k}})},[]),p=u.useCallback((w,k)=>{var g;const x=o(),S=w.split("/").filter(Boolean);let b=x;for(const _ of S)if(b!=null&&typeof b=="object")b=b[_];else{b=void 0;break}const N=mc(k,{value:b,stateModel:x,customFunctions:e}),j={touched:((g=a.current[w])==null?void 0:g.touched)??!0,validated:!0,result:N};return a.current={...a.current,[w]:j},i(a.current),N},[e,o]),m=u.useCallback(w=>{var k,x;a.current={...a.current,[w]:{...a.current[w],touched:!0,validated:((k=a.current[w])==null?void 0:k.validated)??!1,result:((x=a.current[w])==null?void 0:x.result)??null}},i(a.current)},[]),h=u.useCallback(w=>{const{[w]:k,...x}=a.current;a.current=x,i(x)},[]),f=u.useCallback(()=>{let w=!0;for(const[k,x]of Object.entries(c))p(k,x).valid||(w=!1);return w},[c,p]),y=u.useMemo(()=>({customFunctions:e,get fieldStates(){return a.current},validate:p,touch:m,clear:h,validateAll:f,registerField:d}),[e,s,p,m,h,f,d]);return r.jsx(As.Provider,{value:y,children:t})}function Lc(){return u.useContext(As)}var go=0;function xo(){return go+=1,`${Date.now()}-${go}`}function qn(e,t){if(e==null)return e;if(e==="$id")return xo();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 xo()}if(Array.isArray(e))return e.map(n=>qn(n,t));if(typeof e=="object"){const n={};for(const[o,s]of Object.entries(e))n[o]=qn(s,t);return n}return e}var zs=u.createContext(null);function Dc({handlers:e={},navigate:t,children:n}){const{get:o,set:s,getSnapshot:i}=Ht(),a=Lc(),[c,l]=u.useState(e),[d,p]=u.useState(new Set),[m,h]=u.useState(null),f=u.useCallback((S,b)=>{l(N=>({...N,[S]:b}))},[]),y=u.useCallback(async S=>{var A;const b=lc(S,i()),N=nc(),j=Date.now();ec({id:N,name:b.action,params:b.params,at:j});let g=!0,_;try{if(b.action==="setState"&&b.params){const P=b.params.statePath,O=b.params.value;P&&s(P,O);return}if(b.action==="pushState"&&b.params){const P=b.params.statePath,O=b.params.value;if(P){const I=qn(O,o),B=o(P)??[];s(P,[...B,I]);const E=b.params.clearStatePath;E&&s(E,"")}return}if(b.action==="removeState"&&b.params){const P=b.params.statePath,O=b.params.index;if(P!==void 0&&O!==void 0){const I=o(P)??[];s(P,I.filter((B,E)=>E!==O))}return}if(b.action==="push"&&b.params){const P=b.params.screen;if(P){const O=o("/currentScreen"),I=o("/navStack")??[];O?s("/navStack",[...I,O]):s("/navStack",[...I,""]),s("/currentScreen",P)}return}if(b.action==="pop"){const P=o("/navStack")??[];if(P.length>0){const O=P[P.length-1];s("/navStack",P.slice(0,-1)),O?s("/currentScreen",O):s("/currentScreen",void 0)}return}if(b.action==="validateForm"){const P=a==null?void 0:a.validateAll;if(!P){console.warn("validateForm action was dispatched but no ValidationProvider is connected. Ensure ValidationProvider is rendered inside the provider tree.");return}const O=P(),I={};for(const[E,M]of Object.entries(a.fieldStates))M.result&&!M.result.valid&&(I[E]=M.result.errors);const B=((A=b.params)==null?void 0:A.statePath)||"/formValidation";s(B,{valid:O,errors:I});return}const R=c[b.action];if(!R){console.warn(`No handler registered for action: ${b.action}`);return}if(b.confirm)return new Promise((P,O)=>{h({action:b,handler:R,resolve:()=>{h(null),P()},reject:()=>{h(null),O(new Error("Action cancelled"))}})}).then(async()=>{p(P=>new Set(P).add(b.action));try{await uo({action:b,handler:R,setState:s,navigate:t,executeAction:async P=>{await y({action:P})}})}finally{p(P=>{const O=new Set(P);return O.delete(b.action),O})}});p(P=>new Set(P).add(b.action));try{await uo({action:b,handler:R,setState:s,navigate:t,executeAction:async P=>{await y({action:P})}})}finally{p(P=>{const O=new Set(P);return O.delete(b.action),O})}}catch(R){throw g=!1,_=R,R}finally{const R=Date.now();tc({id:N,name:b.action,ok:g,at:R,durationMs:R-j,error:_})}},[c,o,s,i,t,a]),w=u.useCallback(()=>{m==null||m.resolve()},[m]),k=u.useCallback(()=>{m==null||m.reject()},[m]),x=u.useMemo(()=>({handlers:c,loadingActions:d,pendingConfirmation:m,execute:y,confirm:w,cancel:k,registerHandler:f}),[c,d,m,y,w,k,f]);return r.jsx(zs.Provider,{value:x,children:n})}function Is(){const e=u.useContext(zs);if(!e)throw new Error("useActions must be used within an ActionProvider");return e}function Fc({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 Ms=u.createContext(null);function Wc({item:e,index:t,basePath:n,children:o}){return r.jsx(Ms.Provider,{value:{item:e,index:t,basePath:n},children:o})}function Hc(){return u.useContext(Ms)}var Bc=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}},Rs={},Ps=u.createContext(Rs);function Uc(){return u.useContext(Ps)}var Os=u.createContext(void 0);function qc(){return u.useContext(Os)}function Vc(){return u.useSyncExternalStore(sc,oc,()=>!1)}var $s=u.memo(function e({element:t,elementKey:n,spec:o,registry:s,loading:i,fallback:a}){var W;const c=Vc(),l=Hc(),{ctx:d}=Rc(),{execute:p}=Is(),{getSnapshot:m,state:h}=Ht(),f=Uc(),y=qc(),w=u.useMemo(()=>{const $=l?{...d,repeatItem:l.item,repeatIndex:l.index,repeatBasePath:l.basePath}:{...d};return $.functions=f,$.directives=y,$},[d,l,f,y]),k=t.visible===void 0?!0:wt(t.visible,w),x=t.on,S=u.useCallback(async $=>{const q=x==null?void 0:x[$];if(!q)return;const V=Array.isArray(q)?q:[q];for(const U of V){if(!U.params){await p(U);continue}const D={...w,stateModel:m()},Z={};for(const[ne,L]of Object.entries(U.params))Z[ne]=ao(L,D);await p({...U,params:Z})}},[x,p,w,m]),b=u.useCallback($=>{const q=x==null?void 0:x[$];if(!q)return{emit:()=>{},shouldPreventDefault:!1,bound:!1};const U=(Array.isArray(q)?q:[q]).some(D=>D.preventDefault);return{emit:()=>S($),shouldPreventDefault:U,bound:!0}},[x,S]),N=t.watch,j=u.useRef(null),g=u.useRef(void 0),_=u.useMemo(()=>{if(!N)return;const $={};for(const V of Object.keys(N))$[V]=ie(h,V);const q=g.current;if(q){const V=Object.keys($);if(V.length===Object.keys(q).length&&V.every(U=>$[U]===q[U]))return q}return g.current=$,$},[N,h]);if(u.useEffect(()=>{if(!N||!_)return;const $=Object.keys(N);if($.length===0)return;const q=j.current;if(j.current=_,q===null)return;let V=!1;return(async()=>{for(const U of $){if(V)break;if(_[U]!==q[U]){const D=N[U];if(!D)continue;const Z=Array.isArray(D)?D:[D];for(const ne of Z){if(V)break;if(!ne.params){if(await p(ne),V)break;continue}const L={...w,stateModel:m()},X={};for(const[K,re]of Object.entries(ne.params))X[K]=ao(re,L);if(await p({...ne,params:X}),V)break}}}})().catch(console.error),()=>{V=!0}},[N,_,p,w,m]),!k)return null;const A=t.props,R=Qi(A,w),P=Ji(A,w),O=P!==t.props?{...t,props:P}:t,I=s[O.type]??a;if(!I)return console.warn(`No renderer for component type: ${O.type}`),null;const B=O.repeat?r.jsx(Yc,{element:O,spec:o,registry:s,loading:i,fallback:a}):(W=O.children)==null?void 0:W.map($=>{const q=o.elements[$];return q?r.jsx(e,{element:q,elementKey:$,spec:o,registry:s,loading:i,fallback:a},$):(i||console.warn(`[json-render] Missing element "${$}" referenced as child of "${O.type}". This element will not render.`),null)}),E=r.jsx(I,{element:O,emit:S,on:b,bindings:R,loading:i,children:B}),M=c&&n?r.jsx("span",{"data-jr-key":n,style:{display:"contents"},children:E}):E;return r.jsx(Bc,{elementType:O.type,children:M})});function Yc({element:e,spec:t,registry:n,loading:o,fallback:s}){const{state:i}=Ht(),a=e.repeat,c=a.statePath,l=ie(i,c)??[];return r.jsx(r.Fragment,{children:l.map((d,p)=>{var h;const m=a.key&&typeof d=="object"&&d!==null?String(d[a.key]??p):String(p);return r.jsx(Wc,{item:d,index:p,basePath:`${c}/${p}`,children:(h=e.children)==null?void 0:h.map(f=>{const y=t.elements[f];return y?r.jsx($s,{element:y,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)})},m)})})}function Xc({spec:e,registry:t,loading:n,fallback:o}){if(!e||!e.root)return null;const s=e.elements[e.root];return s?r.jsx($s,{element:s,elementKey:e.root,spec:e,registry:t,loading:n,fallback:o}):null}function Gc({registry:e,store:t,initialState:n,handlers:o,navigate:s,validationFunctions:i,functions:a,directives:c,onStateChange:l,children:d}){const p=u.useMemo(()=>c?qi(c):void 0,[c]);return r.jsx(Ic,{store:t,initialState:n,onStateChange:l,children:r.jsx(Mc,{children:r.jsx($c,{customFunctions:i,children:r.jsx(Dc,{handlers:o,navigate:s,children:r.jsx(Ps.Provider,{value:a??Rs,children:r.jsxs(Os.Provider,{value:p,children:[d,r.jsx(Kc,{})]})})})})})})}function Kc(){const{pendingConfirmation:e,confirm:t,cancel:n}=Is();return e!=null&&e.action.confirm?r.jsx(Fc,{confirm:e.action.confirm,onConfirm:t,onCancel:n}):null}function Zc(e,t){const n={};if(t.components)for(const[a,c]of Object.entries(t.components))n[a]=({element:l,children:d,emit:p,on:m,bindings:h,loading:f})=>c({props:l.props,children:d,emit:p,on:m,bindings:h,loading:f});const o=t.actions?Object.entries(t.actions):[];return{registry:n,handlers:(a,c)=>{const l={};for(const[d,p]of o)l[d]=async m=>{const h=a(),f=c();h&&await p(m,h,f)};return l},executeAction:async(a,c,l,d={})=>{const p=o.find(([m])=>m===a);p?await p[1](c,l,d):console.warn(`Unknown action: ${a}`)}}}function Jc(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 Qc(e){const t={root:"",elements:{}};let n=!1;for(const o of e)if(o.type===Pi){if(!Jc(o.data))continue;const s=o.data;if(s.type==="patch")n=!0,zi(t,s.patch);else if(s.type==="flat")n=!0,Object.assign(t,s.spec);else if(s.type==="nested"){n=!0;const i=Ii(s.spec);Object.assign(t,i)}}return n?t:null}function ee(){const{dir:e}=C.useDocumentDir(),t=C.useConfig();return u.useMemo(()=>{const n=Q.resolveLanguage(t.language);return{t:(s,i)=>Q.getTranslation(s,n,t.translationOverrides,i),language:n,dir:Q.isRtlLanguage(n)?"rtl":"ltr",hostDocumentDir:e}},[t.language,t.translationOverrides,e])}function Ls(e){const t=Q.resolveLanguage(e);return(n,o)=>Q.getTranslation(n,t,void 0,o)}const el={t:Ls("en"),anchorTarget:"_blank"},Ds=u.createContext(el);function tl({host:e,children:t}){return r.jsx(Ds.Provider,{value:e,children:t})}function Bt(){return u.useContext(Ds)}function nl({language:e,onUiAction:t,anchorTarget:n="_blank"}){return u.useMemo(()=>({t:Ls(e),anchorTarget:n,onUiAction:t}),[e,n,t])}class rl extends u.Component{constructor(){super(...arguments);eo(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n){Q.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 ol(e){if(!e.elements)return e;let t=!1;const n={};for(const[o,s]of Object.entries(e.elements)){const i=sl(s,e);i!==s&&(t=!0),n[o]=i}return t?{...e,elements:n}:e}function sl(e,t){if(e.type!=="List")return e;const n=e.repeat;if(!n||typeof n.statePath!="string")return e;const o=Q.isRecord(e.props)?e.props:{},s=o.items;if(Array.isArray(s)&&s.length>0)return e;const a=ie(t.state??{},n.statePath);if(!Array.isArray(a)||a.length===0)return e;const{repeat:c,...l}=e;return{...l,props:{...o,items:a}}}function T(...e){return yi.twMerge(wi.clsx(e))}const al=u.lazy(()=>Promise.resolve().then(()=>require("./Chart.impl--lw4WUeY.cjs")));function il(e){const t=e.height??220;return r.jsx(u.Suspense,{fallback:r.jsx(cl,{height:t}),children:r.jsx(al,{...e})})}function cl({height:e}){return r.jsx("div",{className:"w-full animate-pulse rounded-lg bg-muted-foreground/10",style:{height:e},"aria-hidden":!0})}const Fs=v.z.object({title:v.z.string().nullish(),description:v.z.string().nullish()}),Ws=v.z.object({direction:v.z.enum(["row","column"]).nullish(),gap:v.z.enum(["sm","md","lg"]).nullish(),align:v.z.enum(["start","center","end","stretch"]).nullish(),justify:v.z.enum(["start","center","end","between"]).nullish()}),Hs=v.z.object({columns:v.z.union([v.z.literal(1),v.z.literal(2),v.z.literal(3)]).nullish(),gap:v.z.enum(["sm","md","lg"]).nullish()}),Bs=v.z.object({text:v.z.string(),level:v.z.union([v.z.literal(1),v.z.literal(2),v.z.literal(3),v.z.literal(4)]).nullish()}),Us=v.z.object({text:v.z.string(),variant:v.z.enum(["body","caption","muted","code"]).nullish()}),qs=v.z.object({text:v.z.string(),variant:v.z.enum(["default","secondary","success","warning","destructive"]).nullish()}),ll=new Set(["http:","https:","mailto:"]),dl=v.z.string().nullish().transform(e=>{if(!e)return null;try{return ll.has(new URL(e).protocol)?e:null}catch{return null}}),Vs=v.z.object({id:v.z.string().nullish(),label:v.z.string(),secondary:v.z.string().nullish(),badge:v.z.string().nullish(),status:v.z.enum(["success","warning","error","info","neutral"]).nullish(),href:dl}),Ys=v.z.object({items:v.z.array(Vs),maxVisible:v.z.number().int().positive().nullish()}),ul=v.z.object({items:v.z.array(Vs.extend({href:v.z.string().nullish()})),maxVisible:Ys.shape.maxVisible}),Xs=v.z.object({columns:v.z.array(v.z.string()),rows:v.z.array(v.z.array(v.z.string())),caption:v.z.string().nullish()}),pl=v.z.object({value:v.z.string(),direction:v.z.enum(["up","down","flat"]),label:v.z.string().nullish()}),Gs=v.z.object({label:v.z.string(),value:v.z.string(),description:v.z.string().nullish(),trend:v.z.enum(["up","down","neutral"]).nullish(),delta:pl.nullish()}),Ks=v.z.object({type:v.z.enum(["info","tip","warning","important"]).nullish(),title:v.z.string().nullish(),content:v.z.string()}),ml=v.z.object({label:v.z.string(),value:v.z.number()}),Zs=v.z.object({type:v.z.enum(["bar","line","pie"]),data:v.z.array(ml),title:v.z.string().nullish(),height:v.z.number().int().positive().nullish(),centerLabel:v.z.string().nullish()}),Js=v.z.object({agentId:v.z.string(),agentName:v.z.string(),model:v.z.string().nullish()});function ye(e,t,n){const o=e.safeParse(t);return o.success?o.data:n}const hl=Tc(Ac,{components:{Card:{props:Fs,slots:["default"],description:"Container card with an optional title/description. Group related content.",example:{title:"Order summary",description:"Placed 2 days ago"}},Stack:{props:Ws,slots:["default"],description:'Flex layout. Use direction="row" for side-by-side, "column" (default) to stack.'},Grid:{props:Hs,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:Bs,description:"Section heading. level 1 (largest) to 4.",example:{text:"Your orders",level:3}},Text:{props:Us,description:'A paragraph of text. variant "muted"/"caption" for secondary text, "code" for monospace.'},Badge:{props:qs,description:"Small status pill. Use variant to convey state (success/warning/destructive).",example:{text:"Delivered",variant:"success"}},List:{props:ul,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:Xs,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:Gs,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:Ks,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:Js,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:Zs,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 Vn({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 bo={sm:"gap-1.5",md:"gap-3",lg:"gap-4"},fl="10rem";function gl(e){return e===1?"minmax(0, 1fr)":`repeat(auto-fit, minmax(max(${fl}, calc(100% / ${e} - 1rem)), 1fr))`}const{registry:wo}=Zc(hl,{components:{Card:({props:e,children:t,loading:n})=>{const o=ye(Fs,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=ye(Ws,e,{}),s={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"}[o.align??"stretch"],i={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between"}[o.justify??"start"];return r.jsx("div",{className:T("flex",o.direction==="row"?"flex-row":"flex-col",bo[o.gap??"md"],s,i),children:zn(t,n)})},Grid:({props:e,children:t,loading:n})=>{const o=ye(Hs,e,{});return r.jsx("div",{className:T("grid",bo[o.gap??"md"]),style:{gridTemplateColumns:gl(o.columns??1)},children:zn(t,n)})},Heading:({props:e})=>{const t=ye(Bs,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:T("text-foreground",o)},t.text)},Text:({props:e})=>{const t=ye(Us,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:T("whitespace-pre-wrap",n?"text-xs text-muted-foreground":"text-sm text-foreground"),children:t.text})},Badge:({props:e})=>{const t=ye(qs,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:T("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=ye(Ys,e,{items:[]});return n.items.length===0?t?r.jsx(Vn,{}):r.jsx(yo,{translationKey:"json_no_items"}):r.jsx(El,{items:n.items,maxVisible:n.maxVisible})},Table:({props:e,loading:t})=>{const n=ye(Xs,e,{columns:[],rows:[]});return t&&n.rows.length===0?r.jsx(Vn,{}):n.columns.length===0?r.jsx(yo,{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((i,a)=>r.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:i},a))},s))})]})})},Metric:({props:e})=>{const t=ye(Gs,e,{label:"",value:""});return r.jsx(Sl,{label:t.label,value:t.value,description:t.description,trend:t.trend,delta:t.delta})},Callout:({props:e})=>{const t=ye(Ks,e,{content:""}),n=bl[t.type??"info"],o=n.Icon;return r.jsxs("div",{className:T("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=ye(Js,e,{agentId:"",agentName:""});return r.jsx(yl,{...t})},Chart:({props:e})=>{const t=ye(Zs,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(il,{...t})]})}}}),xl=({element:e})=>{const{t}=Bt();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})})},bl={info:{Icon:z.Info,cls:"border-l-blue-500 bg-blue-500/5 text-foreground"},tip:{Icon:z.Lightbulb,cls:"border-l-emerald-500 bg-emerald-500/5 text-foreground"},warning:{Icon:z.AlertTriangle,cls:"border-l-amber-500 bg-amber-500/5 text-foreground"},important:{Icon:z.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(Vn,{}):null}function yo({translationKey:e}){const{t}=Bt();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 wl="oppie-vox-livekit";function yl({agentId:e,agentName:t,model:n}){const{t:o,onUiAction:s}=Bt(),i=!!s&&!!e&&n===wl;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(z.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")})]})]}),i&&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(z.Play,{className:"size-4","aria-hidden":!0}),o("json_phone_agent_test")]})]})}const vl={up:"↑",down:"↓",neutral:"→"},kl={up:"text-emerald-600 dark:text-emerald-400",down:"text-red-600 dark:text-red-400",neutral:"text-muted-foreground"},jl={up:"↑",down:"↓",flat:"→"},Cl={up:"text-emerald-600 dark:text-emerald-400",down:"text-red-600 dark:text-red-400",flat:"text-muted-foreground"};function Sl({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:T("text-sm font-medium",kl[o]),children:vl[o]}):null]}),s?r.jsxs("div",{className:"flex items-baseline gap-1 text-xs",children:[r.jsxs("span",{className:T("font-medium",Cl[s.direction]),children:[jl[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 Nl={success:"bg-emerald-500",warning:"bg-amber-500",error:"bg-red-500",info:"bg-blue-500",neutral:"bg-muted-foreground/40"};function _l({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:T("size-2 rounded-full",Nl[e.status]),"aria-hidden":!0}):r.jsx("span",{}))]})}function El({items:e,maxVisible:t}){const n=t??10,{anchorTarget:o,t:s}=Bt(),[i,a]=u.useState(!1),c=e.length>n,l=i?e:e.slice(0,n),d=l.some(y=>!!y.badge),p=l.some(y=>!!y.secondary),m=l.some(y=>!!y.status),h=[d&&"auto","minmax(0,1fr)",p&&"minmax(0,2fr)",m&&"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:[l.map((y,w)=>{const k=y.id??`row-${w}`,x=r.jsx(_l,{item:y,showBadge:d,showSecondary:p,showStatus:m});return y.href?r.jsx("a",{href:y.href,target:o||"_top",rel:"noopener noreferrer",className:T(f,"transition-colors hover:bg-muted/50",w>0&&"border-t border-muted-foreground/10"),children:x},k):r.jsx("div",{className:T(f,w>0&&"border-t border-muted-foreground/10"),children:x},k)}),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:()=>a(y=>!y),children:i?r.jsxs(r.Fragment,{children:[r.jsx(z.ChevronUp,{className:"size-3"}),s("json_see_less")]}):r.jsxs(r.Fragment,{children:[r.jsx(z.ChevronDown,{className:"size-3"}),s("json_see_more",{count:e.length-n})]})})]})}function Qs({spec:e,active:t=!1}){const{anchorTarget:n,onUiAction:o}=C.useConfig(),{t:s}=ee(),i=u.useMemo(()=>({t:s,anchorTarget:n??"_blank",onUiAction:o}),[s,n,o]);return r.jsx(ea,{spec:e,host:i,active:t})}function Tl({spec:e,language:t,onUiAction:n,anchorTarget:o}){const s=nl({language:t,onUiAction:n,anchorTarget:o});return r.jsx(ea,{spec:e,host:s})}function ea({spec:e,host:t,active:n=!1}){return r.jsx(tl,{host:t,children:r.jsx(rl,{resetKey:e,children:r.jsx(Al,{spec:e,active:n})})})}function Al({spec:e,active:t}){const n=u.useMemo(()=>e?ol(e):null,[e]);return!n||!Ns(n)?null:r.jsx(Gc,{registry:wo,initialState:n.state,children:r.jsx(Xc,{spec:n,registry:wo,loading:t,fallback:xl})})}function ta(e){if(!e)return[];const t=e.split(`
12
+ `),n=[];let o=[],s=[],i=[],a=!1,c=!1;function l(){if(o.length===0)return;const m=o.join(`
13
+ `);m.trim()&&n.push({type:"markdown",content:m}),o=[]}function d(){if(s.length===0)return;let m=null;if(i.length>0)try{m=Mi(i.join(`
14
+ `),{root:"",elements:{}})}catch{}m&&zl(m)?(l(),n.push({type:"ui",spec:m})):o.push(...s),i=[],s=[]}function p(){c&&(d(),c=!1)}for(let m=0;m<t.length;m+=1){const h=t[m]??"",f=h.trim(),y=m===t.length-1;if(!a&&f==="```spec"){p(),a=!0,s=[h];continue}if(a&&f==="```"){s.push(h),d(),a=!1;continue}if(a){s.push(h),f!==""&&Hn(h)&&i.push(h);continue}if(f!==""&&Hn(h)){c=!0,s.push(h),i.push(h);continue}if(c){if(f===""||y&&Ml(f)){s.push(h);continue}p()}o.push(h)}return d(),l(),n}function zl(e){return Ns(e)&&e.elements[e.root]!==void 0}const Il='{"op":';function Ml(e){return!e.startsWith("{")||e.endsWith("}")?!1:/"op"\s*:/.test(e)?!0:Il.startsWith(e.replace(/\s+/g,""))}function Rl(e){return Qc(e)}function F(e){return{"data-component":e}}const Yn=[{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"]}],Pl=Object.fromEntries(Yn.flatMap(e=>e.mimes.map(t=>[t,e.extensions.map(n=>`.${n}`)]))),Ol={"video/mp4":[".mp4"],"video/webm":[".webm"],"video/quicktime":[".mov"]};function na({type:e,name:t}){var s,i;const n=((s=t.split(".").pop())==null?void 0:s.toLowerCase())??"",o=((i=e.toLowerCase().split(";")[0])==null?void 0:i.trim())??"";return Yn.find(a=>n&&a.extensions.includes(n))??Yn.find(a=>o&&a.mimes.includes(o))??null}function gn(){const[e]=u.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(hover: hover) and (pointer: fine)").matches);return e}const yt={x:2,y:2},Ie=u.memo(u.forwardRef(({children:e,className:t,scale:n=1.02,off:o=!1},s)=>{const[i,a]=u.useState(!1),[c,l]=u.useState({x:0,y:0}),d=gn(),p=H.useReducedMotion();if(o||!d||p)return u.cloneElement(e,{ref:s??e.props.ref});if(/translate/.test(e.props.className||""))return e;const h=k=>{var P,O;const{clientX:x,clientY:S}=k,b=k.currentTarget.getBoundingClientRect(),N=x-(b.left+b.width/2),j=S-(b.top+b.height/2),g=Math.max(-1,Math.min(1,N/(b.width/2))),_=Math.max(-1,Math.min(1,j/(b.height/2))),A=g*yt.x,R=_*yt.y;l({x:A,y:R}),(O=(P=e.props).onMouseMove)==null||O.call(P,k)},f=k=>{var x,S;a(!0),(S=(x=e.props).onMouseEnter)==null||S.call(x,k)},y=k=>{var x,S;a(!1),l({x:0,y:0}),(S=(x=e.props).onMouseLeave)==null||S.call(x,k)},w={"--wobble-x":i?`${c.x}px`:"0px","--wobble-y":i?`${c.y}px`:"0px","--scale":1-(n-1)};return u.cloneElement(e,{ref:s,onMouseMove:h,onMouseEnter:f,onMouseLeave:y,style:{...w,...e.props.style},className:T("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)]")})}));Ie.displayName="Wobble";const St=[.23,1,.32,1],$l=`cubic-bezier(${St.join(", ")})`,Ee={duration:.2,ease:St},xe={duration:.15,ease:St},vt={type:"spring",stiffness:500,damping:45,mass:1},Ll=[.32,.72,.24,1],Dl=`cubic-bezier(${Ll.join(", ")})`,Fl="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)",Wl="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)",Hl="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)",Bl="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)",Ul=10,ql=(e,t,n)=>({initial:{opacity:0,x:-e,...t.initial},animate:{opacity:1,x:0,...t.animate,transition:{...Ee,delay:n}},exit:{opacity:0,x:e,...t.exit,transition:xe},transition:Ee}),Vl=(e,t,n)=>({initial:{opacity:0,x:e,...t.initial},animate:{opacity:1,x:0,...t.animate,transition:{...Ee,delay:n}},exit:{opacity:0,x:-e,...t.exit,transition:xe},transition:Ee}),Yl=(e,t,n)=>({initial:{opacity:0,y:e,...t.initial},animate:{opacity:1,y:0,...t.animate,transition:{...Ee,delay:n}},exit:{opacity:0,y:-e,...t.exit,transition:xe},transition:Ee}),Xl=(e,t,n)=>({initial:{opacity:0,y:-e,...t.initial},animate:{opacity:1,y:0,...t.animate,transition:{...Ee,delay:n}},exit:{opacity:0,y:e,...t.exit,transition:xe},transition:Ee}),Gl={right:ql,left:Vl,up:Yl,down:Xl},te=u.forwardRef(({fadeIn:e="down",distance:t=Ul,children:n,snapExit:o=!1,overrides:s={},delay:i=0,...a},c)=>{const l=e?Gl[e](t,s,i):{};return o&&l.exit&&typeof l.exit=="object"&&!Array.isArray(l.exit)&&(l.exit.transition={duration:0}),r.jsx(H.motion.div,{ref:c,...a,...l,children:n})});te.displayName="MotionDiv";const Xn=ms.cva(T("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"}}),G=Ke.forwardRef(({className:e,variant:t="default",size:n,asChild:o=!1,wobble:s=!0,...i},a)=>{const c=o?vi.Slot:"button";return r.jsx(Ie,{ref:a,off:!s,children:r.jsx(c,{...F("ui_lib/btn"),"data-variant":t,className:T(Xn({variant:t,size:n,className:e})),...i})})});G.displayName="Button";const ra=u.createContext(null);function Kl({children:e}){const[t,n]=u.useState(!1),[o,s]=u.useState(null),i=c=>{s(c),n(!0)},a=u.useCallback(()=>{n(!1),setTimeout(()=>{s(null)},200)},[]);return r.jsxs(ra.Provider,{value:{open:i,close:a,isOpen:t,content:o},children:[r.jsx(Zl,{}),e]})}function xn(){const e=u.useContext(ra);return e||(Q.log.error("useDialoger must be used within a DialogerProvider"),{open:()=>{},close:()=>{},isOpen:!1,content:null})}function Zl(){const{contentIframeRef:e}=C.useWidget(),{isOpen:t,content:n,close:o}=xn();return u.useEffect(()=>{var a,c;if(!t)return;const s=l=>{l.defaultPrevented||l.key!=="Escape"||(l.preventDefault(),o())},i=(c=(a=e==null?void 0:e.current)==null?void 0:a.contentWindow)==null?void 0:c.document;return i==null||i.addEventListener("keydown",s),()=>i==null?void 0:i.removeEventListener("keydown",s)},[o,e,t]),r.jsx(H.AnimatePresence,{mode:"wait",children:t&&n&&r.jsx(te,{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 bn({children:e,className:t,withClose:n=!1}){const{close:o}=xn(),{t:s}=ee();return r.jsxs("div",{"data-opencx-escape-scope":!0,className:T("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:i=>i.stopPropagation(),children:[e,n&&r.jsxs(G,{size:"fit",className:"rounded-full absolute top-4 right-4 opacity-50 hover:opacity-100",onClick:o,children:[r.jsx(z.X,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:s("dialog_close")})]})]})}const br=({className:e,...t})=>r.jsx("div",{className:T("flex flex-col gap-2 text-center pt-2",e),...t});br.displayName="DialogerHeader";const wr=({className:e,...t})=>r.jsx("div",{className:T("flex flex-col gap-2 text-center",e),...t});wr.displayName="DialogerBody";const oa=({className:e,...t})=>r.jsx("div",{className:T("flex flex-col gap-2",e),...t});oa.displayName="DialogerFooter";const yr=u.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:T("text-lg font-semibold leading-none tracking-tight",e),...t}));yr.displayName="DialogerTitle";const vr=u.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:T("text-sm text-muted-foreground",e),...t}));vr.displayName="DialogerDescription";function wn({children:e,trigger:t}){const{open:n}=xn();return u.cloneElement(t,{onClick:()=>{var s,i;n(e),(i=(s=t.props).onClick)==null||i.call(s)}})}const vo=1,ko=5,jo=.5,Jl=2.5;function Ql(e,t,n,o){if(!n||!o||t<=1)return{x:0,y:0};const s=n.getBoundingClientRect(),i=o.offsetWidth,a=o.offsetHeight,c=Math.max(0,(i*t-s.width)/(2*t)),l=Math.max(0,(a*t-s.height)/(2*t));return{x:Math.min(c,Math.max(-c,e.x)),y:Math.min(l,Math.max(-l,e.y))}}function sa({src:e,alt:t}){const{t:n}=ee(),[o,s]=u.useState(1),[i,a]=u.useState({x:0,y:0}),[c,l]=u.useState(!1),d=u.useRef({x:0,y:0}),p=u.useRef({x:0,y:0}),m=u.useRef(null),h=u.useRef(null),f=u.useRef(!1),y=g=>Math.min(ko,Math.max(vo,g)),w=u.useCallback(()=>{s(1),a({x:0,y:0})},[]),k=u.useCallback(()=>{s(g=>y(g+jo))},[]),x=u.useCallback(()=>{s(g=>{const _=y(g-jo);return _<=1&&a({x:0,y:0}),_})},[]),S=u.useCallback(g=>{g.preventDefault(),f.current=!1,l(!0),d.current={x:g.clientX,y:g.clientY},p.current={...i},g.target.setPointerCapture(g.pointerId)},[i]),b=u.useCallback(g=>{if(!c)return;const _=g.clientX-d.current.x,A=g.clientY-d.current.y;if((Math.abs(_)>3||Math.abs(A)>3)&&(f.current=!0),o<=1)return;const R={x:p.current.x+_/o,y:p.current.y+A/o};a(Ql(R,o,m.current,h.current))},[c,o]),N=u.useCallback(()=>{const g=f.current;l(!1),!g&&s(_=>_>1?(a({x:0,y:0}),1):Jl)},[]),j=o>1;return r.jsxs("div",{className:"relative size-full flex items-center justify-center select-none",onClick:g=>g.stopPropagation(),children:[r.jsx("div",{ref:m,className:T("overflow-hidden max-h-full max-w-full rounded-2xl flex items-center justify-center",j&&"size-full"),onPointerDown:S,onPointerMove:b,onPointerUp:N,onPointerCancel:N,style:{cursor:c?"grabbing":j?"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(${i.x}px, ${i.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(In,{onClick:x,label:n("zoom_out"),disabled:o<=vo,children:r.jsx(z.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(In,{onClick:k,label:n("zoom_in"),disabled:o>=ko,children:r.jsx(z.ZoomIn,{className:"size-3.5"})}),j&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-px h-4 bg-white/30 mx-0.5"}),r.jsx(In,{onClick:w,label:n("reset_zoom"),children:r.jsx(z.RotateCcw,{className:"size-3.5"})})]})]})]})}function In({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 Co({url:e,name:t,size:n,icon:o,label:s}){return r.jsx(Ie,{children:r.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:T("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:T("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:T("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 aa({attachment:e}){const{name:t,size:n,type:o,url:s}=e,i=o.startsWith("image/"),a=o.startsWith("video/"),c=o.startsWith("audio/"),l=o==="application/pdf";if(c)return r.jsx(Ie,{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(a)return r.jsx(Ie,{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(i)return r.jsx(wn,{trigger:r.jsx("div",{children:r.jsx(Ie,{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(bn,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx(sa,{src:s,alt:t})})});if(l)return r.jsx(Co,{url:s,name:t,size:n,icon:r.jsx(z.FileText,{className:"size-5",strokeWidth:1.75}),label:"PDF"});const d=na({type:o,name:t});return d?r.jsx(Co,{url:s,name:t,size:n,icon:r.jsx(z.FileSpreadsheet,{className:"size-5",strokeWidth:1.75}),label:d.label}):r.jsx(Ie,{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:T("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 ed({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",{...F("chat/agent_msg/reply_to"),type:"button",onClick:i=>{const a=i.currentTarget.ownerDocument.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`);a==null||a.scrollIntoView({behavior:"smooth",block:"center"}),a==null||a.animate([{opacity:.35},{opacity:1}],{duration:900,easing:"ease-out"})},className:T("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 ia=u.memo(ki,(e,t)=>e.children===t.children&&e.className===t.className);var cs,ls,ds;const td={...Ce.defaultSchema,attributes:{...Ce.defaultSchema.attributes,"*":[...((cs=Ce.defaultSchema.attributes)==null?void 0:cs["*"])??[],"style"],code:[...((ls=Ce.defaultSchema.attributes)==null?void 0:ls.code)??[],"className"],pre:[...((ds=Ce.defaultSchema.attributes)==null?void 0:ds.pre)??[],"className"]}},nd=/^(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,rd=/^[\w\s#.,%()'"+-]+$/,od=/\b(url|expression|var|attr)\s*\(/i;function sd(){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(i=>{const a=i.indexOf(":");if(a<0)return!1;const c=i.slice(0,a).trim(),l=i.slice(a+1).trim();return nd.test(c)&&rd.test(l)&&!od.test(l)}).join(";")),(s=t.children)==null||s.forEach(e)}}function ca(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()}var us,ps;const ad={...Ce.defaultSchema,attributes:{...Ce.defaultSchema.attributes,code:[...((us=Ce.defaultSchema.attributes)==null?void 0:us.code)??[],"className"],pre:[...((ps=Ce.defaultSchema.attributes)==null?void 0:ps.pre)??[],"className"]}};function kr(e){return r.jsx(la,{...e})}function id(e){return r.jsx(la,{...e,configuredStyles:!0})}function la({children:e,messageType:t,messageId:n,configuredStyles:o=!1}){const{anchorTarget:s}=C.useConfig();return r.jsx(ia,{"data-type":t,"data-id":n,remarkPlugins:[hs],rehypePlugins:o?[Fn,sd,[Ce,td]]:[Fn,[Ce,ad]],components:{a:({children:i,...a})=>r.jsx("a",{target:a.target||s||"_top",...a,children:i}),img:({src:i,alt:a,...c})=>i?r.jsx(wn,{trigger:r.jsx("img",{src:i,alt:a,...c,className:"cursor-pointer rounded-xl"}),children:r.jsx(bn,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx(sa,{src:i,alt:a})})}):r.jsx("img",{src:i,alt:a,...c})},children:ca(e)})}function De(){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 cd({currentMessage:e}){var o;const t=De(),n=(o=t.config.customComponents)==null?void 0:o["message::after"];return n?r.jsx(n,{...t,currentMessage:e}):null}const ld=["[--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 Gn(e){const{data:t,id:n,type:o,attachments:s,isFirstInGroup:i,isLastInGroup:a,isAloneInGroup:c,dataComponentNames:l,classNames:d}=e,p=o==="AI"||o==="AGENT"?t.message:"",m=u.useMemo(()=>o==="AI"?ta(p):null,[o,p]);if(o!=="AI"&&o!=="AGENT")return null;const{variant:h="default"}=t,f=e.replyTo?r.jsx(ed,{replyTo:e.replyTo}):null,y=(S,b,N=!0,j=!0)=>r.jsxs("div",{className:"flex flex-row gap-2",children:[r.jsxs("div",{...F((l==null?void 0:l.message)??"chat/agent_msg/msg"),"data-first":i,"data-last":a,"data-alone":c,"data-variant":h,className:T("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",ld,"break-words [word-break:break-word]",h==="error"&&"bg-destructive/15 text-destructive",i&&!c&&"rounded-bl-md",a&&!c&&"rounded-tl-md",!i&&!a&&!c&&"rounded-l-md",d==null?void 0:d.message),children:[j&&f,r.jsx(kr,{messageType:o,messageId:n,children:S})]}),N&&r.jsx(cd,{currentMessage:e})]},b),w=(m==null?void 0:m.some(S=>S.type==="ui"))??!1,k=(m==null?void 0:m.reduce((S,b,N)=>b.type==="markdown"?N:S,-1))??-1,x=(m==null?void 0:m.findIndex(S=>S.type==="markdown"))??-1;return r.jsxs("div",{...F((l==null?void 0:l.messageContainer)??"chat/agent_msg/root"),"data-message-id":n,className:T("w-5/6 flex flex-col items-start gap-1",d==null?void 0:d.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(S=>r.jsx(aa,{attachment:S},S.id))}),w&&m?m.map((S,b)=>S.type==="markdown"?y(S.content,`md-${b}`,b===k,b===x):r.jsx("div",{className:"w-full",children:r.jsx(Qs,{spec:S.spec})},`ui-${b}`)):p.length>0&&y(p)]})}function dd(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 jr=Ke.forwardRef(({className:e,...t},n)=>r.jsx(Ct.Root,{ref:n,className:T("relative flex size-6 aspect-square shrink-0 overflow-hidden rounded-full bg-secondary",e),...t}));jr.displayName=Ct.Root.displayName;const Cr=Ke.forwardRef(({className:e,...t},n)=>r.jsx(Ct.Image,{ref:n,className:T("aspect-square h-full w-full",e),...t}));Cr.displayName=Ct.Image.displayName;const Sr=Ke.forwardRef(({className:e,...t},n)=>r.jsx(Ct.Fallback,{ref:n,className:T("flex size-full text-xs items-center justify-center rounded-lg",e),...t}));Sr.displayName=Ct.Fallback.displayName;function Kn({agent:e,...t}){var n,o;return r.jsxs(jr,{...t,children:[r.jsx(Cr,{src:(e==null?void 0:e.avatarUrl)||(e==null?void 0:e.avatar)||"",alt:"Agent Icon"}),(e==null?void 0:e.name)&&r.jsx(Sr,{children:(o=(n=e==null?void 0:e.name)==null?void 0:n.slice(0,1))==null?void 0:o.toUpperCase()})]})}function ud({agent:e}){return r.jsx(H.AnimatePresence,{children:r.jsxs(te,{...F("chat/bot_loading/root"),className:"flex flex-row items-end w-full gap-2 animate-pulse",children:[r.jsx(Kn,{agent:e}),r.jsxs("div",{...F("chat/bot_loading/bouncing_dots_container"),className:T("flex items-center [&_span]:bg-secondary-foreground [&_span]:size-1 gap-1 p-2 rounded-xl bg-secondary"),children:[r.jsx(H.motion.span,{className:"rounded-full animate-bounce [animation-delay:-0.3s]"}),r.jsx(H.motion.span,{className:"rounded-full animate-bounce [animation-delay:-0.15s]"}),r.jsx(H.motion.span,{className:"rounded-full animate-bounce"})]})]})})}const pd='*,: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-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-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{animation:none}}.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}.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-6{inset-inline-end:1.5rem}.left-1\\/2,.left-\\[50\\%\\]{left:50%}.right-4{right:1rem}.start-2{inset-inline-start:.5rem}.top-1{top:.25rem}.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}.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-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}.-mt-0\\.5{margin-top:-.125rem}.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-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}.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-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-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-3\\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-9{height:2.25rem}.h-full{height:100%}.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-12{min-height:3rem}.w-0{width:0px}.w-1\\/2{width:50%}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-2\\/5{width:40%}.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-40{max-width:10rem}.max-w-48{max-width:12rem}.max-w-96{max-width:24rem}.max-w-\\[61\\.8\\%\\]{max-width:61.8%}.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-shrink,.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.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,.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-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-\\[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-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-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}.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-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-\\[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-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-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\\/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\\/\\[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}.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-\\[3px\\]{padding-top:3px;padding-bottom:3px}.pb-0{padding-bottom:0}.pb-0\\.5{padding-bottom:.125rem}.pb-1{padding-bottom:.25rem}.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-6{padding-left:1.5rem}.pr-16{padding-right:4rem}.ps-1{padding-inline-start:.25rem}.ps-1\\.5{padding-inline-start:.375rem}.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-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.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-\\[16px\\]{font-size:16px}.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-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-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-\\[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-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-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-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-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-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}}',md="5.0.0";function hd(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 So=450;function Ae(){const[e,t]=u.useState(()=>(window.top||window).innerWidth<So);return u.useEffect(()=>{const n=window.top||window,o=()=>{t(n.innerWidth<So)};return o(),n.addEventListener("resize",o),()=>{n.removeEventListener("resize",o)}},[]),{isSmallScreen:e}}const Jt={transitionTimingFunction:"cubic-bezier(0.16, 1, 0.3, 1)",transitionDuration:"1000ms"};function fe(){var h,f,y,w,k,x,S,b,N,j,g,_,A,R,P,O,I,B,E,M,W,$,q,V,U,D,Z,ne,L,X,K,re,oe,pe,se,be,ze,ae,Ze,ct,Re,Pe,Fe,We,He,Oe,we,lt;const{dir:e}=C.useDocumentDir(),{isSmallScreen:t}=Ae(),{theme:n,inline:o}=C.useConfig(),s=ge=>o?"100%":ge,i=(ge,le)=>t?`100dv${ge}`:le,a=(ge,le)=>s(i(ge,le)),c=hd((h=n==null?void 0:n.widgetTrigger)==null?void 0:h.offset,e),l={zIndex:((f=n==null?void 0:n.widgetTrigger)==null?void 0:f.zIndex)??1e7,offset:{bottom:((w=(y=n==null?void 0:n.widgetTrigger)==null?void 0:y.offset)==null?void 0:w.bottom)??20,right:((x=(k=n==null?void 0:n.widgetTrigger)==null?void 0:k.offset)==null?void 0:x.right)??(c==="right"?20:"initial"),left:((b=(S=n==null?void 0:n.widgetTrigger)==null?void 0:S.offset)==null?void 0:b.left)??(c==="left"?20:"initial")},size:{button:((j=(N=n==null?void 0:n.widgetTrigger)==null?void 0:N.size)==null?void 0:j.button)??48,icon:((_=(g=n==null?void 0:n.widgetTrigger)==null?void 0:g.size)==null?void 0:_.icon)??24}},d=(()=>{const ge=c==="right"?l.offset.right:l.offset.left;return typeof ge!="number"?0:ge})(),p={palette:(n==null?void 0:n.palette)??"neutral",primaryColor:(n==null?void 0:n.primaryColor)??"hsl(0 0% 9%)",widgetTrigger:l,widgetContentContainer:{borderRadius:t?"0px":((A=n==null?void 0:n.widgetContentContainer)==null?void 0:A.borderRadius)??"32px",zIndex:((R=n==null?void 0:n.widgetContentContainer)==null?void 0:R.zIndex)??l.zIndex+1,outline:((P=n==null?void 0:n.widgetContentContainer)==null?void 0:P.outline)??"none",outlineColor:((O=n==null?void 0:n.widgetContentContainer)==null?void 0:O.outlineColor)??"hsl(0 0% 50% / .5)",boxShadow:((I=n==null?void 0:n.widgetContentContainer)==null?void 0:I.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)??Jt.transitionTimingFunction,transitionDuration:((M=n==null?void 0:n.widgetContentContainer)==null?void 0:M.transitionDuration)??Jt.transitionDuration,offset:{side:t?0:l.offset.bottom+l.size.button+yt.y*2+((($=(W=n==null?void 0:n.widgetContentContainer)==null?void 0:W.offset)==null?void 0:$.side)??10),align:t?0:d+(((V=(q=n==null?void 0:n.widgetContentContainer)==null?void 0:q.offset)==null?void 0:V.align)??0)}},screens:{welcome:{width:a("w",((D=(U=n==null?void 0:n.screens)==null?void 0:U.welcome)==null?void 0:D.width)??"400px"),minHeight:a("h",((ne=(Z=n==null?void 0:n.screens)==null?void 0:Z.welcome)==null?void 0:ne.minHeight)??"1px")},sessions:{width:a("w",((X=(L=n==null?void 0:n.screens)==null?void 0:L.sessions)==null?void 0:X.width)??"450px"),height:a("h",((re=(K=n==null?void 0:n.screens)==null?void 0:K.sessions)==null?void 0:re.height)??"600px")},chat:{width:a("w",((pe=(oe=n==null?void 0:n.screens)==null?void 0:oe.chat)==null?void 0:pe.width)??"525px"),height:a("h",((be=(se=n==null?void 0:n.screens)==null?void 0:se.chat)==null?void 0:be.height)??"700px"),withCanvas:{width:a("w",((Ze=(ae=(ze=n==null?void 0:n.screens)==null?void 0:ze.chat)==null?void 0:ae.withCanvas)==null?void 0:Ze.width)??"min(1050px, 100vw)"),height:a("h",((Pe=(Re=(ct=n==null?void 0:n.screens)==null?void 0:ct.chat)==null?void 0:Re.withCanvas)==null?void 0:Pe.height)??"min(800px, 100vh)"),transitionTimingFunction:((He=(We=(Fe=n==null?void 0:n.screens)==null?void 0:Fe.chat)==null?void 0:We.withCanvas)==null?void 0:He.transitionTimingFunction)??Jt.transitionTimingFunction,transitionDuration:((lt=(we=(Oe=n==null?void 0:n.screens)==null?void 0:Oe.chat)==null?void 0:we.withCanvas)==null?void 0:lt.transitionDuration)??Jt.transitionDuration}}}},m={maxHeight:a("h",`calc(
15
+ 100vh
16
+ - ${p.widgetTrigger.offset.bottom}px
17
+ - ${p.widgetContentContainer.offset.side}px
18
+ - ${yt.y*2}px
19
+ )`),maxWidth:a("w",`calc(
20
+ 100vw
21
+ - ${d*2}px
22
+ )`),minHeight:a("h",`min(
23
+ ${p.screens.welcome.minHeight},
24
+ ${p.screens.sessions.height},
25
+ ${p.screens.chat.height}
26
+ )`),minWidth:a("w",`min(
27
+ ${p.screens.welcome.width},
28
+ ${p.screens.sessions.width},
29
+ ${p.screens.chat.width}
30
+ )`)};return{theme:p,triggerSide:c,computed:m,cssVars:fd({palette:p.palette,primary:p.primaryColor})}}function fd({palette:e,primary:t}){const n=da(e),o=to(t).toHsl(),s=to(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 da(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 Q.isExhaustive(e,da.name),t}}const gd=Se.Provider,xd=Se.Root,bd=Se.Trigger,ua=Ke.forwardRef(({className:e,sideOffset:t=4,...n},o)=>r.jsx(Se.Content,{ref:o,sideOffset:t,className:T("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}));ua.displayName=Se.Content.displayName;const pa=Ke.createContext(!1);function wd({children:e}){return r.jsx(pa.Provider,{value:!0,children:e})}function _e({children:e,content:t,side:n,align:o,shortcut:s}){const{disableTooltips:i}=C.useConfig(),a=Ke.useContext(pa);return!t||i||a?e:r.jsxs(xd,{children:[r.jsx(bd,{asChild:!0,children:e}),r.jsxs(ua,{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 ma="OpenCX Live Chat";function Nr({transparent:e=!1}={}){return`<!DOCTYPE html>
31
+ <html>
32
+ <head>
33
+ <style>
34
+ ${pd}
35
+ html, body {
36
+ height: 100%;
37
+ width: 100%;
38
+ margin: 0;
39
+ padding: 0;
40
+ font-size: 16px;${e?`
41
+ background: transparent;`:""}
42
+ }
43
+ </style>
44
+ <meta name="viewport" content="width=device-width, initial-scale=1, interactive-widget=resizes-content">
45
+ </head>
46
+ <body>
47
+ </body>
48
+ </html>`}function yn({overrides:e,rootRef:t,style:n,shellRadius:o,children:s}){const{cssOverrides:i}=C.useConfig(),{cssVars:a,theme:c}=fe(),{dir:l}=ee(),d={"--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,i?r.jsx("style",{children:i}):null,r.jsx("div",{ref:t,style:{...a,...d,...n},"data-version":md,dir:l,className:T("antialiased font-sans size-full overflow-hidden relative text-secondary-foreground isolate"),children:r.jsx(gd,{delayDuration:200,disableHoverableContent:!0,children:r.jsx(Kl,{children:s})})})]})}function ha(){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 _r({width:e,height:t}){const{isSmallScreen:n}=Ae(),{setWidth:o,setHeight:s}=ha();u.useEffect(()=>{e&&o(e),t&&s(t)},[n,t,e,o,s])}const No=z.CircleDashedIcon;function kt({name:e,className:t}){const n=(()=>{switch(e){case"Check":return z.CheckIcon;case"CheckCheck":return z.CheckCheckIcon;case"CircleCheck":return z.CircleCheckIcon;case"CircleCheckBig":return z.CircleCheckBigIcon;case"CircleX":return z.CircleXIcon;case"Expand":return z.ExpandIcon;case"Maximize":return z.MaximizeIcon;case"Maximize2":return z.Maximize2Icon;case"Minimize":return z.MinimizeIcon;case"Minimize2":return z.Minimize2Icon;case"Shrink":return z.ShrinkIcon;case"SquareCheck":return z.SquareCheckIcon;case"SquareCheckBig":return z.SquareCheckBigIcon;case"SquareX":return z.SquareXIcon;case"X":return z.XIcon;case"AtSign":return z.AtSignIcon;case"Bot":return z.BotIcon;case"Book":return z.BookIcon;case"BookOpen":return z.BookOpenIcon;case"Building2":return z.Building2Icon;case"Calendar":return z.CalendarIcon;case"CreditCard":return z.CreditCardIcon;case"Database":return z.DatabaseIcon;case"FileText":return z.FileTextIcon;case"Folder":return z.FolderIcon;case"Globe":return z.GlobeIcon;case"Link":return z.LinkIcon;case"Mail":return z.MailIcon;case"Package":return z.PackageIcon;case"Plug":return z.PlugIcon;case"Settings":return z.SettingsIcon;case"ShoppingCart":return z.ShoppingCartIcon;case"Tag":return z.TagIcon;case"Ticket":return z.TicketIcon;case"User":return z.UserIcon;case"Users":return z.UsersIcon;case"Workflow":return z.WorkflowIcon;case"Zap":return z.ZapIcon;case void 0:return No;default:return Q.isExhaustive(e,kt.name),No}})();return r.jsx(n,{className:T("size-4",t)})}function Er(e){const{t}=ee(),{session:n}=C.usePrimitiveState(e.ctx.sessionCtx.sessionState),{messages:o}=C.usePrimitiveState(e.ctx.messageCtx.state),s=C.usePrimitiveState(e.ctx.messageCtx.draftState),i=e.title||(n==null?void 0:n.title)||t("companion_chat_number",{count:e.id});let a=(n==null?void 0:n.lastMessage)??s.text??"";for(let d=o.length-1;d>=0;d--){const p=o[d],m=p.type==="USER"?p.content:p.type==="SYSTEM"?"":p.data.message;if(m.trim()){a=m;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"):i,preview:a.replace(/\s+/g," ").trim(),status:c}}function Tr(){const e=gn(),[t,n]=u.useState(null),[o,s]=u.useState(!1),[i,a]=u.useState(!1),[c,l]=u.useState(!1),d=u.useRef(!1),p=u.useRef(void 0),m=u.useCallback(()=>clearTimeout(p.current),[]);u.useEffect(()=>m,[m]);const h=u.useCallback((f=!1)=>{m(),d.current=!1,f&&a(!1),s(!1)},[m]);return{anchor:t,open:o,animate:i,autoFocus:c,close:h,toggle(f,y=!1){if(m(),o&&d.current){h(!y);return}d.current=!0,n(f),a(y),l(!0),s(!0)},hover(f){m(),!(!e||o)&&(p.current=setTimeout(()=>{d.current=!1,n(f),a(!0),l(!1),s(!0)},100))},enter:m,leave(){m(),d.current||(p.current=setTimeout(()=>h(),200))}}}function Ar(){return r.jsx("style",{children:`
49
+ [data-companion-action] {
50
+ transition: transform 150ms ease-out, background-color 150ms ease-out, color 150ms ease-out, opacity 100ms ease-out;
51
+ }
52
+ @media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
53
+ [data-companion-action] { transform: translate(var(--wobble-x, 0px), var(--wobble-y, 0px)); }
54
+ [data-companion-action]:hover { transform: translate(var(--wobble-x, 0px), var(--wobble-y, 0px)) scale(var(--scale, .98)); }
55
+ [data-companion-action]:hover:active { transform: translate(var(--wobble-x, 0px), var(--wobble-y, 0px)) scale(calc(var(--scale, .98) - .02)); }
56
+ }
57
+ @media (prefers-reduced-motion: reduce), (pointer: coarse) {
58
+ [data-companion-action] { transform: none !important; transition: none; }
59
+ }
60
+ `})}function yd({picker:e,...t}){return r.jsxs(r.Fragment,{children:[r.jsx(Ar,{}),r.jsx(G,{...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 vd({chat:e,selected:t,onSelect:n,onClose:o}){const{t:s}=ee(),{title:i,preview:a,status:c}=Er(e);return r.jsx(Ie,{children:r.jsxs("div",{"data-chat-row":"","data-companion-action":"","data-selected":t||void 0,children:[r.jsx(ke.RadioItem,{asChild:!0,value:String(e.id),textValue:i,onSelect:l=>{l.preventDefault(),n()},children:r.jsxs("button",{className:Xn({size:"selfless",className:"bg-transparent"}),type:"button","data-companion-action":"","aria-description":a||void 0,"aria-label":`${i} — ${c}${t?` — ${s("companion_viewing")}`:""}`,"data-chat-select":e.id,children:[r.jsx("span",{"data-chat-indicator":"","aria-hidden":!0,children:r.jsx(ke.ItemIndicator,{children:r.jsx(z.CheckIcon,{size:14})})}),r.jsx("span",{"data-chat-title":"",children:i}),e.working&&r.jsx(z.LoaderCircleIcon,{size:14,"data-working":"","aria-hidden":!0})]})}),r.jsx(ke.Item,{asChild:!0,textValue:s("companion_close_chat",{title:i}),onSelect:l=>{l.preventDefault(),o()},children:r.jsx("button",{className:Xn({size:"selfless",className:"bg-transparent"}),type:"button","data-companion-action":"","aria-label":s("companion_close_chat",{title:i}),"data-chat-close":e.id,children:r.jsx(z.XIcon,{size:14,"aria-hidden":!0})})})]})})}function zr(e){const{picker:t,portalTarget:n}=e;return t.anchor&&n?r.jsx(kd,{...e,anchor:t.anchor,portalTarget:n}):null}function kd({picker:e,anchor:t,portalTarget:n,placement:o,onSelected:s}){const{open:i,animate:a,autoFocus:c,close:l,enter:d,leave:p}=e,{chats:m,activeId:h,selectChat:f,newChat:y,closeChat:w}=C.useCompanionChats(),{canCreateNewSession:k}=C.useSessions(),{t:x,dir:S}=ee(),{cssVars:b,theme:N}=fe(),j=u.useRef(null),g=u.useRef(t.ownerDocument.activeElement),_=u.useCallback(E=>{E&&!j.current&&(g.current=t.ownerDocument.activeElement),j.current=E},[t]),A=u.useRef(!1),R=u.useRef({onClose:l,onSelected:s});R.current={onClose:l,onSelected:s};const P=u.useMemo(()=>({current:{getBoundingClientRect(){let E=t.getBoundingClientRect(),M=t.ownerDocument.defaultView;const W=n.ownerDocument.defaultView;for(;M&&M!==W;){const $=M.frameElement;if(!$)break;const q=$.getBoundingClientRect(),V=q.width/$.offsetWidth||1,U=q.height/$.offsetHeight||1;E=new DOMRect(q.left+E.left*V,q.top+E.top*U,E.width*V,E.height*U),M=$.ownerDocument.defaultView}return E}}}),[t,n]),O=m.filter(E=>E.working).length;u.useEffect(()=>{if(!i||t.ownerDocument===n.ownerDocument)return;const E=W=>{W.composedPath().includes(t)||W.type==="focusin"&&!c&&W.target===g.current||R.current.onClose(W.type==="focusin")},M=t.ownerDocument;return M.addEventListener("pointerdown",E,!0),M.addEventListener("focusin",E),()=>{M.removeEventListener("pointerdown",E,!0),M.removeEventListener("focusin",E)}},[t,n,i,c]),u.useLayoutEffect(()=>{var E,M,W;(E=j.current)==null||E.toggleAttribute("inert",!i),i&&c&&((W=(M=j.current)==null?void 0:M.querySelector('[aria-checked="true"]'))==null||W.focus({preventScroll:!0}))},[i,c]);function I(E){var M,W;t.focus({preventScroll:!0}),E===void 0?y():f(E),R.current.onClose(!0),(W=(M=R.current).onSelected)==null||W.call(M)}function B(E){var $,q,V,U;const M=m.findIndex(D=>D.id===E),W=m[M+1]??m[M-1];E===h?(t.focus({preventScroll:!0}),R.current.onClose(!0)):(q=($=j.current)==null?void 0:$.querySelector(W?`[data-chat-select="${W.id}"]`:"[data-new-chat]"))==null||q.focus({preventScroll:!0}),w(E),E===h&&((U=(V=R.current).onSelected)==null||U.call(V))}return Dt.createPortal(r.jsxs(ke.Root,{open:i,onOpenChange:E=>{!E&&!A.current&&R.current.onClose()},modal:!1,dir:S==="rtl"?"rtl":"ltr",children:[r.jsx(ke.Anchor,{virtualRef:P}),r.jsxs(ke.Content,{ref:_,loop:!0,side:o==="above"?"top":"bottom",align:o==="below"?"start":"center",sideOffset:6,collisionPadding:12,updatePositionStrategy:"always","aria-label":x("companion_chats"),"data-companion-chat-picker":"","data-motion":a?"pointer":"instant",onEntryFocus:E=>{var M,W,$;E.preventDefault(),c?(W=(M=j.current)==null?void 0:M.querySelector('[aria-checked="true"]'))==null||W.focus({preventScroll:!0}):(A.current=!0,($=g.current)==null||$.focus({preventScroll:!0}),A.current=!1)},onCloseAutoFocus:E=>{E.preventDefault()},onEscapeKeyDown:E=>{E.preventDefault(),t.focus({preventScroll:!0}),R.current.onClose(!0)},onFocusOutside:E=>{var M,W;((M=j.current)!=null&&M.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===g.current)&&E.preventDefault()},onInteractOutside:E=>{E.detail.originalEvent.composedPath().includes(t)&&E.preventDefault()},onPointerEnter:d,onPointerLeave:p,onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>E.stopPropagation(),onKeyDown:E=>{E.key==="Tab"&&(E.preventDefault(),t.focus({preventScroll:!0}),R.current.onClose(!0))},style:{...b,zIndex:N.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(Ar,{}),r.jsx("style",{children:`
61
+ [data-companion-chat-picker] {
62
+ transform-origin: var(--radix-popper-transform-origin);
63
+ animation: opencx-menu-in ${xe.duration*1e3}ms ${$l};
64
+ }
65
+ [data-companion-chat-picker][data-state="closed"] { animation-name: opencx-menu-out; pointer-events: none; }
66
+ [data-companion-chat-picker][data-motion="instant"] { animation: none; }
67
+ @media (prefers-reduced-motion: reduce) {
68
+ [data-companion-chat-picker] { animation: none !important; }
69
+ }
70
+ @keyframes opencx-menu-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
71
+ @keyframes opencx-menu-out { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(.96); } }
72
+ [data-companion-chat-picker] button {
73
+ display: flex; align-items: center; justify-content: flex-start; gap: 8px; width: 100%; min-height: 34px;
74
+ padding: 7px 8px; border: 0; border-radius: 7px; background: transparent;
75
+ color: inherit; font: inherit; text-align: start; cursor: pointer; box-sizing: border-box;
76
+ }
77
+ [data-companion-chat-picker] [data-chat-row] { display: flex; align-items: center; border-radius: 7px; }
78
+ [data-companion-chat-picker] [data-chat-row] + [data-chat-row] { margin-top: 4px; }
79
+ [data-companion-chat-picker] [data-chat-select] { flex: 1; min-width: 0; min-height: 36px; color: hsl(var(--opencx-foreground) / .8); }
80
+ [data-companion-chat-picker] [data-selected] [data-chat-select] { color: hsl(var(--opencx-foreground)); }
81
+ [data-companion-chat-picker] [data-chat-indicator] { width: 14px; height: 14px; display: flex; align-items: center; flex-shrink: 0; color: hsl(var(--opencx-muted-foreground)); }
82
+ [data-companion-chat-picker] [data-selected] [data-chat-indicator],
83
+ [data-companion-chat-picker] [data-working] { color: hsl(var(--opencx-foreground)); }
84
+ [data-companion-chat-picker] [data-chat-title] { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; line-height: 20px; }
85
+ [data-companion-chat-picker] [data-chat-close] { width: 28px; min-height: 28px; padding: 0; margin-inline-end: 4px; flex-shrink: 0; justify-content: center; color: hsl(var(--opencx-muted-foreground)); }
86
+ [data-companion-chat-picker] [data-chat-row]:focus-within { background: hsl(var(--opencx-secondary)); }
87
+ @media (hover: hover) and (pointer: fine) {
88
+ [data-companion-chat-picker] [data-chat-row]:hover,
89
+ [data-companion-chat-picker] [data-new-chat][data-highlighted] { background: hsl(var(--opencx-secondary)); }
90
+ [data-companion-chat-picker] [data-chat-close]:hover { color: hsl(var(--opencx-foreground)); }
91
+ }
92
+ [data-companion-chat-picker] [data-chat-row] button {
93
+ background: transparent; transform: none;
94
+ }
95
+ [data-companion-chat-picker] [data-chat-close][data-highlighted] { color: hsl(var(--opencx-foreground)); }
96
+ [data-companion-chat-picker] button:active { background: hsl(var(--opencx-foreground) / .065); }
97
+ [data-companion-chat-picker] button:focus { outline: none; }
98
+ [data-companion-chat-picker] button:disabled { opacity: .45; cursor: default; }
99
+ @media (pointer: coarse) {
100
+ [data-companion-chat-picker] button, [data-companion-chat-picker] [data-chat-select] { min-height: 48px; }
101
+ [data-companion-chat-picker] [data-chat-close] { width: 48px; min-height: 48px; }
102
+ [data-companion-chat-picker] [data-chat-title], [data-companion-chat-picker] [data-new-chat] { font-size: 16px; }
103
+ }
104
+ [data-companion-chat-picker] svg { flex-shrink: 0; }
105
+ [data-companion-chat-picker] [data-working] { animation: opencx-picker-spin 1.2s linear infinite; }
106
+ @keyframes opencx-picker-spin { to { transform: rotate(360deg); } }
107
+ @media (prefers-reduced-motion: reduce) { [data-companion-chat-picker] [data-working] { animation: none; } }
108
+ `}),r.jsxs(ke.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:x("companion_chats")}),O>0&&r.jsx("span",{role:"status",children:x("companion_working_chats",{count:O})})]}),r.jsx(ke.RadioGroup,{value:String(h),children:m.map(E=>r.jsx(vd,{chat:E,selected:E.id===h,onSelect:()=>I(E.id),onClose:()=>B(E.id)},E.id))}),r.jsx(ke.Separator,{style:{height:1,background:"hsl(var(--opencx-border) / .4)",margin:"5px 4px"}}),r.jsx(ke.Group,{children:r.jsx(ke.Item,{asChild:!0,disabled:!k,onSelect:E=>{E.preventDefault(),I()},children:r.jsxs(G,{variant:"ghost",size:"selfless",type:"button","data-companion-action":"","data-new-chat":"",disabled:!k,children:[r.jsx(z.PlusIcon,{size:14,"aria-hidden":!0}),x("new_conversation")]})})})]})]}),n)}function vn(){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)}},[]),e}function jd(){const{chats:e,openChats:t,activeId:n}=C.useCompanionChats(),o=e.find(f=>f.id===n),s=Er(o),{t:i}=ee(),a=Tr(),c=vn(),l=s.title,d=t.filter(f=>f.id!==n),p=d.filter(f=>f.working).length,m=`${i("companion_other_sessions",{count:d.length})}${p?` · ${i("companion_working_chats",{count:p})}`:""}`,h=`${i("companion_switch_chat")}: ${l}${d.length?` · ${m}`:""}`;return r.jsxs(r.Fragment,{children:[r.jsxs(yd,{picker:a,"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(z.LoaderCircleIcon,{"aria-label":i("companion_working"),className:"size-3.5 shrink-0 animate-spin motion-reduce:animate-none"}),r.jsx("span",{className:"truncate font-medium",children:l}),d.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:m}),p>0&&r.jsx(z.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:["+",d.length]})]}),r.jsx(z.ChevronsUpDownIcon,{"aria-hidden":!0,className:"size-3 shrink-0 text-muted-foreground"})]}),a.anchor&&c&&r.jsx(zr,{picker:a,portalTarget:c,placement:"below"})]})}function Cd(){var n;const e=De(),t=(n=e.config.customComponents)==null?void 0:n.headerBottom;return t?r.jsx(t,{...e}):null}function Sd({fallback:e}){var o;const t=De(),n=(o=t.config.customComponents)==null?void 0:o.headerTitle;return n?r.jsx(n,{...t}):e}function fa(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":return n;default:return Q.isExhaustive(e,fa.name),n}}function ga(){const{widgetCtx:{org:e}}=C.useWidget(),{routerState:{screen:t}}=C.useWidgetRouter(),{textContent:n}=C.useConfig();return fa(t,n,e.name)}function Nd(e){switch(e){case"chat":return F("chat/header");case"sessions":return F("sessions/header");case"welcome":return;default:Q.isExhaustive(e,ga.name);return}}function _d(){const{router:e}=C.useConfig(),{routerState:{screen:t},toSessionsScreen:n}=C.useWidgetRouter();return t!=="chat"||e!=null&&e.chatScreenOnly?null:r.jsx(G,{variant:"ghost",size:"fit",className:"rounded-full",onClick:n,children:r.jsx(z.ChevronLeftIcon,{className:"size-4 rtl:-scale-100"})})}function Ed({button:e}){const{setIsOpen:t}=C.useWidgetTrigger(),{isSmallScreen:n}=Ae(),o=De();if(n&&e.hideOnSmallScreen||!n&&e.hideOnLargeScreen)return null;const s=()=>{var i;e.handleClick?e.handleClick():t(!1),(i=e.onClicked)==null||i.call(e,o)};return r.jsx(G,{variant:"ghost",size:"fit",className:"rounded-full",onClick:s,children:r.jsx(kt,{name:e.icon})})}function Zn({button:e}){const[t,n]=u.useState(!1),{routerState:{screen:o}}=C.useWidgetRouter(),{isSmallScreen:s}=Ae(),{theme:i}=fe(),{setWidth:a,setHeight:c}=ha(),l=De();if(o!=="chat"&&o!=="sessions")return null;const d=(()=>{switch(o){case"chat":return i.screens.chat.height;case"sessions":return i.screens.sessions.height;default:return Q.isExhaustive(o,Zn.name),i.screens.chat.height}})(),p=(()=>{switch(o){case"chat":return i.screens.chat.width;case"sessions":return i.screens.sessions.width;default:return Q.isExhaustive(o,Zn.name),i.screens.chat.width}})(),m=()=>{var h;n(f=>{const y=!f;return c(y?"100vh":d),a(y?`max(40vw, ${p})`:p),y}),(h=e.onClicked)==null||h.call(e,l)};return s&&e.hideOnSmallScreen||!s&&e.hideOnLargeScreen?null:r.jsx(G,{variant:"ghost",size:"fit",className:"rounded-full",onClick:m,children:r.jsx(kt,{name:e.icon||(t?e.shrinkIcon:e.expandIcon)})})}function xa({button:e}){var x,S;const{close:t}=xn(),{widgetCtx:n}=C.useWidget(),{setIsOpen:o}=C.useWidgetTrigger(),{resolveSession:s,sessionState:i}=C.useSessions(),{isSmallScreen:a}=Ae(),c=De(),{t:l}=ee(),d=!i.session,p=((x=i.session)==null?void 0:x.isOpened)===!1,m=e.onResolved||"stay-in-chat",h=e.behaviorBeforeSessionCreation||"disabled",f=e.behaviorIfSessionIsResolved||"disabled",y=!!(i.isResolvingSession||d&&h==="disabled"||p&&f==="disabled"),w=async()=>{const{success:b,error:N}=await s();if(t(),!b)return Q.log.error("failed to resolve session",N),!1;switch(m){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:Q.isExhaustive(m,xa.name);break}return!0},k=()=>{if(d)switch(h){case"disabled":return;case"close-widget":o(!1);break;default:Q.isExhaustive(h,k.name)}if(p)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:Q.isExhaustive(f,k.name)}};return a&&e.hideOnSmallScreen||!a&&e.hideOnLargeScreen?null:((S=e.confirmation)==null?void 0:S.type)==="modal"&&!p&&!d?r.jsx(wn,{trigger:r.jsx(G,{variant:"ghost",size:"fit",className:"rounded-full",disabled:y,onClick:()=>{var b;return(b=e.onClicked)==null?void 0:b.call(e,c)},children:r.jsx(kt,{name:e.icon})}),children:r.jsxs(bn,{children:[r.jsx(br,{children:r.jsx(yr,{children:e.confirmation.title||l("close_conversation_title")})}),r.jsx(wr,{children:r.jsx(vr,{children:e.confirmation.description||l("close_conversation_description")})}),r.jsxs(oa,{children:[r.jsx(G,{variant:"secondary",onClick:t,disabled:i.isResolvingSession,children:e.confirmation.cancelButtonText||l("close_conversation_cancel")}),r.jsx(G,{variant:"destructive",onClick:async()=>{var N,j;await w()&&((j=(N=e.confirmation)==null?void 0:N.onResolved)==null||j.call(N,c))},disabled:i.isResolvingSession,children:e.confirmation.confirmButtonText||l("close_conversation_confirm")})]})]})}):r.jsx(G,{variant:"ghost",size:"fit",className:"rounded-full",onClick:()=>{var b;p||d?k():w(),(b=e.onClicked)==null||b.call(e,c)},disabled:y,children:r.jsx(kt,{name:e.icon})})}function Jn({button:e}){switch(e.functionality){case"close-widget":return r.jsx(Ed,{button:e});case"expand-shrink":return r.jsx(Zn,{button:e});case"resolve-session":return r.jsx(xa,{button:e});default:return Q.isExhaustive(e,Jn.name),null}}const Td={functionality:"close-widget",hideOnLargeScreen:!0,icon:"X"};function Ad(){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(Jn,{button:Td}):r.jsx(r.Fragment,{children:n.map(o=>r.jsx(Jn,{button:o},`${o.functionality}-${o.icon}`))})}function ba(){const e=C.useConfig(),t=e.displayMode==="companion"&&!e.inline,{routerState:{screen:n}}=C.useWidgetRouter(),o=Nd(n),s=ga();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(_d,{}),r.jsx("div",{className:T("min-w-0 flex-1 h-8 flex items-center",n==="sessions"&&"ps-2"),children:r.jsx(Sd,{fallback:t&&n!=="sessions"?r.jsx(jd,{}):r.jsx("h2",{className:"font-semibold",children:s})})}),r.jsx(Ad,{})]}),r.jsx(Cd,{})]})}function wa({className:e}){return r.jsx(z.LoaderIcon,{className:T("size-4 animate-spin",e)})}function zd(){const{messagesState:{isInitialFetchLoading:e}}=C.useMessages(),{isSmallScreen:t}=Ae(),{activeMode:n,Component:o}=C.useModes();return{isCanvasOpen:!e&&!t&&!!n&&!!o}}function Id({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 a=s.getComponent(o.data.action.name);if(a)return r.jsx(a,{...o,id:o.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}const i=s.getComponent(o.component);return i?r.jsx(i,{...o,id:o.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n}):r.jsx(Gn,{...o,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}function kn({suggestion:e,className:t,...n}){const{sendMessage:o}=C.useMessages(),s=()=>{const i=e.trim();i&&o({content:i})};return r.jsx(G,{...F("chat/suggested_reply_btn"),size:"sm",className:T("rounded-xl w-fit",t),...n,onClick:s,children:e})}function ya({messages:e,className:t,containerClassName:n}){var a,c;const{timestamps:o}=C.useConfig();if(!((a=o==null?void 0:o.perMessageGroup)!=null&&a.enabled))return null;const s=(c=e[e.length-1])==null?void 0:c.timestamp;if(!s)return null;const i=(()=>{try{return new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}catch(l){return Q.log.error("failed to format timestamp",l),null}})();return i?r.jsx("div",{className:n,children:r.jsx("span",{className:T("text-xs text-muted-foreground",t),children:i})}):null}const Md=2e3;function Rd(e){return e.map(t=>ca(t.data.message).trim()).filter(t=>t.length>0).join(`
109
+
110
+ `)}function va(){const{messageActions:e}=C.useConfig(),t=C.useDisplayMode();return(e==null?void 0:e.copy)??t==="companion"}function ka({messages:e}){const{t}=ee(),{messageActions:n}=C.useConfig(),o=(n==null?void 0:n.display)==="always",[s,i]=u.useState(!1),a=u.useRef(null);u.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]);const c=Rd(e),l=typeof navigator<"u"?navigator.clipboard:void 0;if(!l||c.length===0)return null;const d=()=>{l.writeText(c).then(()=>{i(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),Md)},m=>Q.log.warn("copying the reply failed",m))},p=t(s?"copied":"copy_reply");return r.jsx("div",{...F("chat/agent_msg_group/actions"),className:T("flex items-center gap-1 -mt-0.5 transition-opacity duration-150",o?"opacity-100":T("opacity-0 group-hover:opacity-100 focus-within:opacity-100","[@media(hover:none)]:opacity-100")),children:r.jsx(_e,{content:p,side:"bottom",align:"start",children:r.jsx("button",{...F("chat/agent_msg_group/actions/copy"),type:"button","aria-label":p,"aria-live":"polite",onClick:d,className:T("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(z.CheckIcon,{className:"size-3.5"}):r.jsx(z.CopyIcon,{className:"size-3.5"})})})})}function Pd(e){return e.type==="AI"&&e.data.variant!=="error"}function dn({messages:e,agent:t,suggestedReplies:n,actions:o=!0}){const s=va(),i=e.filter(Pd);return r.jsxs("div",{...F("chat/agent_msg_group/root"),className:T("group flex items-end gap-2"),children:[r.jsx(_e,{content:t==null?void 0:t.name,side:"right",align:"end",children:r.jsx(Kn,{...F("chat/agent_msg_group/root/avatar"),agent:t,className:"hidden"})}),r.jsxs("div",{className:T("flex-1 flex flex-col gap-1"),children:[r.jsxs("div",{...F("chat/agent_msg_group/avatar_and_msgs/root"),className:T("flex items-end gap-2"),children:[r.jsx(_e,{content:t==null?void 0:t.name,side:"right",align:"end",children:r.jsx(Kn,{...F("chat/agent_msg_group/avatar_and_msgs/avatar"),agent:t})}),r.jsxs("div",{...F("chat/agent_msg_group/avatar_and_msgs/msgs"),className:T("flex-1 flex flex-col gap-1"),children:[e.map((a,c,l)=>r.jsx(Id,{isFirstInGroup:c===0,isLastInGroup:c===l.length-1,isAloneInGroup:l.length===1,...a},a.id)),r.jsx(ya,{messages:e}),o&&s&&i.length>0&&r.jsx(ka,{messages:i})]})]}),n&&n.length>0&&r.jsx("div",{...F("chat/agent_msg_group/suggestions"),className:T("flex flex-col gap-1 ps-8"),children:n==null?void 0:n.map((a,c)=>r.jsx(kn,{suggestion:a},`${a}-${c}`))})]})]})}const _o=["⠏","⠗","⠧","⠷","⠾","⠽","⠻","⠟"];function Ir({className:e}){const t=H.useReducedMotion(),[n,o]=u.useState(0);return u.useEffect(()=>{if(t)return;const s=setInterval(()=>o(i=>(i+1)%_o.length),80);return()=>clearInterval(s)},[t]),r.jsx("span",{className:T("select-none",e),"aria-hidden":!0,children:_o[n]})}function Eo({turn:e,agent:t,timestamp:n}){const{componentStore:o,config:s,widgetCtx:i}=C.useWidget(),a=va(),c=o.getComponent("agent_chat_steps"),l=o.getComponent("agent_chat_spec"),d=o.getComponent("loading"),[p]=u.useState(()=>new Date().toISOString()),m=n??p,h=Q.resolveClientPresentation(i.agent.presentation,s.presentation),f=C.applyPresentation(e.items,h),y=e.active&&(h==null?void 0:h.streaming)===!1&&!f.some(w=>w.kind==="questions");return r.jsxs("div",{...F("chat/streaming_turn/root"),className:"group flex flex-col gap-2",children:[f.map((w,k)=>w.kind==="text"?r.jsx(dn,{messages:[{id:`streaming-${k}`,type:"AI",component:"bot_message",timestamp:m,data:{message:w.text},agent:t}],agent:t,actions:!1},`text-${k}`):w.kind==="spec"?l&&r.jsx(l,{parts:w.parts,active:e.active},`spec-${k}`):w.kind==="questions"||w.kind==="plan"||w.kind==="connection"?null:c&&r.jsx(c,{active:e.active,steps:w.steps},`steps-${k}`)),y&&d?r.jsx(d,{agent:t}):e.active&&!Od(f)&&r.jsx("div",{...F("chat/streaming_turn/working"),className:"flex h-5 items-center ps-1",children:r.jsx(Ir,{className:"text-[14px] leading-none text-primary/70"})}),!e.active&&a&&r.jsx(ka,{messages:f.flatMap(w=>w.kind==="text"?[{data:{message:w.text}}]:[])})]})}function Od(e){const t=e.at(-1);return(t==null?void 0:t.kind)==="steps"&&t.steps.some(n=>!n.done)}function $d({parts:e,active:t=!1}){const n=u.useMemo(()=>Rl(e),[e]);return r.jsx(Qs,{spec:n,active:t})}function Ld({plan:e,active:t}){const[n,o]=u.useState(!1),s=u.useId(),i=H.useReducedMotion(),a=e.filter(p=>p.status==="completed").length,c=e.find(p=>p.status==="in_progress")??e.find(p=>p.status==="pending")??e[0],l=2*Math.PI*8,d=l*(1-(e.length>0?a/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(p=>!p),"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(H.motion.circle,{cx:"10",cy:"10",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeDasharray:l,initial:!1,animate:{strokeDashoffset:d},transition:i?{duration:0}:Ee,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:[a,"/",e.length]}),r.jsx(H.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:i?{duration:0}:xe,children:r.jsx(z.ChevronUp,{className:"size-3.5"})})]}),r.jsx("div",{id:s,"aria-hidden":!n,children:r.jsx(H.AnimatePresence,{initial:!1,children:n&&r.jsx(H.motion.div,{initial:{height:i?"auto":0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:i?"auto":0,opacity:0,transition:xe},transition:i?xe:Ee,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((p,m)=>r.jsxs("li",{className:"flex items-start gap-2.5 py-1.5 text-sm","data-plan-status":p.status,children:[r.jsx("span",{"aria-hidden":"true",className:T("relative mt-0.5 size-4 shrink-0",!t&&"[&_.animate-spin]:animate-none"),children:r.jsx(H.AnimatePresence,{initial:!1,children:r.jsx(H.motion.span,{className:"absolute inset-0 flex items-center justify-center",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:xe,children:p.status==="completed"?r.jsx("span",{className:"flex size-4 items-center justify-center rounded-full bg-emerald-500/10",children:r.jsx(z.Check,{className:"size-2.5 text-emerald-600 dark:text-emerald-400"})}):p.status==="in_progress"?t?r.jsx(z.Loader2,{className:"size-4 animate-spin text-primary/60 motion-reduce:animate-none"}):r.jsx(z.CircleDashed,{className:"size-4 text-primary/40"}):r.jsx("span",{className:"size-1.5 rounded-full bg-primary/25"})},p.status)})}),r.jsx("span",{className:T(p.status==="completed"?"text-primary/50 line-through":p.status==="in_progress"?"font-medium text-primary":"text-primary/60"),children:p.step})]},m))})},"plan-steps")})})]})}function ja(){var n,o;const e=De();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 Ca(){var n;const e=De(),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 Sa(e){const t=[];let n=null;return e.forEach(o=>{var s,i,a,c,l,d;(((s=n==null?void 0:n[0])==null?void 0:s.type)!==o.type||((i=n[0])==null?void 0:i.type)==="AGENT"&&o.type==="AGENT"&&(((a=o.agent)==null?void 0:a.id)!==((c=n[0].agent)==null?void 0:c.id)||((l=o.agent)==null?void 0:l.name)!==((d=n[0].agent)==null?void 0:d.name)))&&(n=[],t.push(n)),n.push(o)}),t}function Qn(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="USER"}function Dd(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="AI"}function Fd(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="AGENT"}function Na(){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(kr,{children:n})},`${n}-${s}`))})}const Wd=10*1024,To=new Map;function Hd(e){const t=To.get(e);if(t!==void 0)return t;const n=Bd(e);return To.set(e,n),n}function Bd(e){const t=e.trim();if(!t||t.length>Wd||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 Ud=ms.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 qd({className:e,variant:t,...n}){return r.jsx("div",{className:T(Ud({variant:t}),e),...n})}function _a({customStatus:e,className:t,dotClassName:n}){const o=e.icon?Hd(e.icon):null,s=e.color||"currentColor";return o?r.jsx("span",{"aria-hidden":!0,className:T("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:T("size-2 shrink-0 rounded-full",n),style:{backgroundColor:s}})}function Ea({customStatus:e,className:t}){return r.jsxs(qd,{variant:"secondary",className:T("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(_a,{customStatus:e}),r.jsx("span",{className:"truncate",children:e.name})]})}function Ta(){const{sessionState:{session:e}}=C.useSessions(),t=e==null?void 0:e.customStatus;return r.jsx(H.AnimatePresence,{mode:"wait",children:t&&r.jsx(te,{className:"sticky top-2 z-10 self-center max-w-full",snapExit:!0,children:r.jsx(wn,{trigger:r.jsx(G,{variant:"ghost",size:"selfless",className:"rounded-full",children:r.jsx(Ea,{customStatus:t})}),children:r.jsxs(bn,{withClose:!0,children:[r.jsxs(br,{children:[r.jsx(_a,{customStatus:t,className:"size-8 mx-auto",dotClassName:"size-3 mx-auto"}),r.jsx(yr,{children:t.name})]}),t.description&&r.jsx(wr,{children:r.jsx(vr,{children:t.description})})]})})},t.id)})}function Aa(){var c;const{messagesState:{messages:e}}=C.useMessages(),t=C.useConfig(),n=C.useBot(),{advancedInitialMessages:o=[],initialQuestions:s,initialQuestionsPosition:i}=t;if(e.length>0)return null;const a=o.length?o.map(l=>l.message):(c=t.initialMessages)!=null&&c.length?t.initialMessages:["Hello, how can I help you?"];return r.jsx(dn,{messages:a.map((l,d)=>({component:"bot_message",data:{message:l},id:`${d}-${l}`,type:"AI",timestamp:null})),suggestedReplies:i==="below-initial-messages"?s:void 0,agent:n})}function za({src:e,alt:t,title:n,note:o,shape:s="strip",className:i,children:a,...c}){const l=s==="tile";return r.jsxs("div",{...c,className:T("relative overflow-hidden bg-background ring-1 ring-border",l?"size-12 shrink-0 rounded-2xl":"max-w-full rounded-xl",i),children:[r.jsx("img",{src:e,alt:t,title:n,draggable:!1,className:T("block object-cover object-left-top",l?"size-full":"h-10 w-auto max-w-40")}),o&&r.jsx("div",{className:T("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}),a]})}const Mr=["#opencx-root","[data-opencx-root]","[data-opencx-overlay]"],at='input,textarea,select,[contenteditable]:not([contenteditable="false"]),[role="textbox"],[role="searchbox"],[role="combobox"]',Vd=[...Mr,"[data-opencx-private]",'[aria-hidden="true"]',"[hidden]","script","style","noscript"].join(",");function Ia(e){var n;if(e.matches(Vd))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 Te(e){for(let t=e;t;t=t.parentElement)if(Ia(t))return!0;return!1}function Ma(e){if(Te(e)||e.closest(at))return"";const t=[],n=o=>{if(o instanceof Element){if(o!==e&&Ia(o)||o.matches(at))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 Rr(e){try{const t=new URL(e,window.location.href);return t.protocol==="http:"||t.protocol==="https:"?`${t.origin}${t.pathname}`:""}catch{return""}}function Pt(e){return e.getRootNode()===document&&!Te(e)&&!e.closest(at)&&!e.matches("canvas,iframe,video,object,embed")&&!Array.from(e.querySelectorAll("*")).some(t=>Te(t)||t.matches(`${at},canvas,iframe,video,object,embed`))}const Yd=480,Xd=3e3,Ot=new WeakMap,er=new WeakMap;async function Gd(e){if(!Pt(e))return null;const t=e.getBoundingClientRect();if(t.width<1||t.height<1)return null;const n=Math.min(2,Math.max(.5,Yd/Math.max(t.width,t.height))),o=Ni.toJpeg(e,{quality:.85,pixelRatio:n,backgroundColor:"#ffffff",filter:i=>!(i instanceof Element)||Pt(i)}),s=new Promise(i=>setTimeout(()=>i(null),Xd));try{return await Promise.race([o,s])}catch{return null}}function Kd(e,t){er.set(e,t),Ot.set(e,Gd(t))}const tr=new WeakMap;function Zd(e,t){if(tr.has(e))return;const n=Ot.get(e);if(!n)return;const o=n.then(s=>{const i=er.get(e);if(!(i!=null&&i.isConnected)||!Pt(i))return null;const a=s?Qd(s,"page-mark.jpg"):null;return a?t(a):null}).catch(()=>null).then(s=>{const i=er.get(e);return!(i!=null&&i.isConnected)||!Pt(i)?null:(s&&(e.snapshotUrl=s),s)});tr.set(e,o)}async function Jd(e,t){if(e.snapshotUrl)return e.snapshotUrl;const n=tr.get(e);if(!n)return null;const o=new Promise(s=>setTimeout(()=>s(null),t));return Promise.race([n,o])}function Qd(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 i=atob(s),a=new Uint8Array(i.length);for(let c=0;c<i.length;c++)a[c]=i.charCodeAt(c);return new File([a],t,{type:o})}catch{return null}}function eu(e){return Ot.get(e)}function tu(e,t){const n=Ot.get(e);n&&Ot.set(t,n)}function Ra(e){const[t,n]=u.useState(null);return u.useEffect(()=>{var s;if(n(null),!e)return;let o=!1;return(s=eu(e))==null||s.then(i=>{!o&&i&&n(i)}),()=>{o=!0}},[e]),t}function nu({element:e}){const t=Ra(e.mark)??e.snapshotUrl??null,n=e.note??e.name;return t?r.jsx(za,{src:t,alt:n,title:e.name,note:e.note}):r.jsxs("span",{className:T("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(z.PenLineIcon,{className:"size-3 shrink-0 text-primary"}),r.jsx("span",{className:"truncate",children:n})]})}const ru=150,ou=40,su=3;function au(e,t){const n=new Map;for(const i of e){const a=n.get(i.type);a?a.push(i):n.set(i.type,[i])}const o=[],s=[];for(const[i,a]of Array.from(n)){const c=t.has(i)?a:a.slice(0,su);o.push({type:i,items:c,hidden:a.length-c.length}),s.push(...c)}return{groups:o,visible:s}}function iu(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 cu(e,t){const n=t.trim().toLowerCase();if(!n)return[...e];const o=s=>{var a;const i=s.title.toLowerCase();return i.startsWith(n)?0:i.includes(n)?1:(a=s.description)!=null&&a.toLowerCase().includes(n)?2:-1};return e.map((s,i)=>({item:s,index:i,rank:o(s)})).filter(s=>s.rank>=0).sort((s,i)=>s.rank-i.rank||s.index-i.index).map(s=>s.item)}const Rt=e=>`@${e.title}`;function Ao(e,t){const n=[];for(const o of t){const s=Rt(o);let i=0;for(;;){const a=e.indexOf(s,i);if(a===-1)break;n.push({start:a,end:a+s.length}),i=a+s.length}}return n}function lu({text:e,setText:t,inputRef:n}){const{mentions:o}=C.useConfig(),{widgetCtx:s}=C.useWidget(),i=o==null?void 0:o.items,a=o==null?void 0:o.search,c=u.useMemo(()=>{if(a)return a;if(i)return M=>cu(i,M)},[a,i]),l=!!c&&s.features.pageContext,{mentions:d,setMentions:p}=C.useComposerDraft(),[m,h]=u.useState(null),[f,y]=u.useState([]),[w,k]=u.useState(()=>new Set),[x,S]=u.useState(0),[b,N]=u.useState(!1),{groups:j,visible:g}=u.useMemo(()=>au(f,w),[w,f]);u.useEffect(()=>{p(M=>{const W=M.filter($=>e.includes(Rt($)));return W.length===M.length?M:W})},[e,p]);const _=u.useCallback((M="nearest")=>{if(!l)return;const W=n.current;let $=(W==null?void 0:W.selectionStart)??e.length;if(W&&W.selectionStart===W.selectionEnd){const U=Ao(e,d).find(D=>$>D.start&&$<D.end);U&&($=M==="forward"?U.end:M==="backward"||$-U.start<U.end-$?U.start:U.end,W.setSelectionRange($,$))}const q=iu(e,$),V=q&&d.some(U=>e.startsWith(Rt(U),q.start))?null:q;h(U=>(U==null?void 0:U.start)===(V==null?void 0:V.start)&&(U==null?void 0:U.query)===(V==null?void 0:V.query)?U:V)},[l,n,d,e]);u.useEffect(()=>_(),[_]);const A=u.useRef(0);u.useEffect(()=>{if(!m||!c){y([]),N(!1);return}const M=++A.current;N(!0);const W=setTimeout(()=>{Promise.resolve().then(()=>c(m.query)).then($=>{M===A.current&&(y($.slice(0,ou)),k(new Set),S(0),N(!1))},$=>{M===A.current&&(Q.log.warn("mentions search failed",$),y([]),N(!1))})},ru);return()=>clearTimeout(W)},[m,c]);const R=u.useCallback(()=>{A.current+=1,h(null),y([]),N(!1)},[]),P=u.useCallback(M=>{if(!m)return;const W=m.start+1+m.query.length,$=`${Rt(M)} `,q=e.slice(0,m.start)+$+e.slice(W);t(q),p(U=>U.some(D=>D.type===M.type&&D.id===M.id)?U:[...U,M]),R();const V=m.start+$.length;requestAnimationFrame(()=>{const U=n.current;U&&(U.focus(),U.setSelectionRange(V,V))})},[m,R,n,t,p,e]),O=u.useCallback(M=>{k(W=>new Set(W).add(M))},[]),I=l&&m!==null,B=u.useCallback(M=>{const W=n.current;if(l&&W&&W.selectionStart===W.selectionEnd&&(M.key==="Backspace"||M.key==="Delete")){const $=W.selectionStart,q=Ao(e,d).find(V=>M.key==="Backspace"?V.end===$:V.start===$);if(q){M.preventDefault();const V=e[q.end]===" "?q.end+1:q.end;return t(e.slice(0,q.start)+e.slice(V)),requestAnimationFrame(()=>W.setSelectionRange(q.start,q.start)),!0}}if(!I)return!1;if(M.key==="Escape")return M.preventDefault(),R(),!0;if(g.length===0)return!1;if(M.key==="ArrowDown")return M.preventDefault(),S($=>($+1)%g.length),!0;if(M.key==="ArrowUp")return M.preventDefault(),S($=>($-1+g.length)%g.length),!0;if(M.key==="Enter"||M.key==="Tab"){M.preventDefault();const $=g[x];return $&&P($),!0}return!1},[R,l,x,n,I,P,d,t,e,g]),E=u.useCallback(()=>{p([]),R()},[R,p]);return u.useMemo(()=>({picked:d,isOpen:I,anchorIndex:(m==null?void 0:m.start)??null,preview:(o==null?void 0:o.preview)!==!1,groups:j,visible:g,expandGroup:O,searching:b,highlighted:x,setHighlighted:S,pick:P,onKeyDown:B,onCaretMove:_,reset:E}),[d,I,m,o==null?void 0:o.preview,j,g,O,b,x,P,B,_,E])}function Pa({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(Rt))).sort((c,l)=>l.length-c.length),s=[];let i=e,a=0;for(;i.length>0;){let c=-1,l="";for(const d of o){const p=i.indexOf(d);p!==-1&&(c===-1||p<c)&&(c=p,l=d)}if(c===-1){s.push(i);break}c>0&&s.push(i.slice(0,c)),s.push(u.createElement("span",{...F("chat/mention"),key:a++,className:T("rounded-sm px-0.5 -mx-0.5",n)},l)),i=i.slice(c+l.length)}return r.jsx(r.Fragment,{children:s})}function du({message:e,isFirstInGroup:t,isLastInGroup:n,isAloneInGroup:o}){var s;return r.jsxs("div",{...F("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",{...F("chat/user_msg/marked_elements"),className:"w-full flex gap-1 flex-wrap justify-end",children:e.markedElements.map((i,a)=>r.jsx(nu,{element:i},`${i.name}-${a}`))}),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(i=>r.jsx(aa,{attachment:i},i.id))}),e.content.length>0&&r.jsx("div",{...F("chat/user_msg/msg"),"data-first":t,"data-last":n,"data-alone":o,"data-pending":e.pending===!0,className:T("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(Pa,{text:e.content,mentions:e.mentions,tokenClassName:"bg-primary-foreground/20 font-medium"})})]})}function uu({messages:e}){return r.jsxs("div",{...F("chat/user_msg_group/root"),className:T("group","flex flex-col gap-1 justify-end items-end"),children:[e.map((t,n,o)=>r.jsx(du,{message:t,isFirstInGroup:n===0,isLastInGroup:n===o.length-1,isAloneInGroup:o.length===1},t.id)),r.jsx(ya,{messages:e,containerClassName:"ms-auto"})]})}function nr({groups:e,pendingReply:t=!1}){const{humanAgent:n}=C.useConfig(),o=C.useBot();return r.jsx(r.Fragment,{children:e.map((s,i)=>{var c,l;const a=(c=s[0])==null?void 0:c.id;if(!a)return null;if(Qn(s))return r.jsx(uu,{messages:s},a);if(Dd(s))return r.jsx(dn,{messages:s,agent:o,actions:!t||i!==e.length-1},a);if(Fd(s)){const d=(l=s[0])==null?void 0:l.agent;return r.jsx(dn,{messages:s,agent:d?{...d,name:(n==null?void 0:n.name)||d.name||"",avatarUrl:(n==null?void 0:n.avatarUrl)||d.avatarUrl||null}:n?{isAi:!1,id:null,name:n.name||"",avatarUrl:n.avatarUrl||null}:void 0},a)}return null})})}const pu=150;function mu({scrollHeight:e,scrollTop:t,clientHeight:n},o=pu){return e-t-n<o}function hu(e){const t=u.useRef(null),n=u.useRef(!0),[o,s]=u.useState(!1),i=u.useRef(null),[a]=u.useState(()=>new Set),c=u.useCallback(()=>{const d=t.current,p=d?mu(d):!0;n.current=p,s(!p)},[]),l=u.useCallback(()=>{const d=t.current;d&&(d.scrollTo({top:d.scrollHeight,behavior:"smooth"}),n.current=!0,s(!1))},[]);return u.useEffect(()=>{if(!n.current)return;const d=setTimeout(()=>{const p=t.current;p&&(p.scrollTop=p.scrollHeight)},0);return()=>clearTimeout(d)},e),u.useEffect(()=>{const d=t.current;if(!d)return;const p=new ResizeObserver(()=>{n.current&&(d.scrollTop=d.scrollHeight)});return i.current=p,()=>{p.disconnect(),i.current=null,a.clear()}},[a]),u.useEffect(()=>{const d=t.current,p=i.current;!d||!p||(a.forEach(m=>{m.isConnected||(p.unobserve(m),a.delete(m))}),Array.from(d.children).forEach(m=>{a.has(m)||(p.observe(m),a.add(m))}))}),{containerRef:t,handleScroll:c,showScrollDown:o,scrollToBottom:l}}function fu(){const{messagesState:{messages:e}}=C.useMessages(),{isStreaming:t,liveItems:n,turnSources:o,liveTurnKey:s,turnFailed:i,retryFailedTurn:a}=C.useAgentChatUi(),{componentStore:c}=C.useWidget(),{t:l}=ee(),d=C.useBot(),{sessionState:{session:p}}=C.useSessions(),m=u.useMemo(()=>C.sessionPlan({liveItems:n,turnSources:o}),[n,o]),h=u.useMemo(()=>Sa(e),[e]),f=u.useMemo(()=>{const A=new Map;for(const R of o)for(const P of R.rowIds)A.set(P,R);return A},[o]),y=u.useMemo(()=>{for(let A=h.length-1;A>=0;A-=1){const R=h[A];if(R&&Qn(R))return A}return-1},[h]),w=n.length>0,{nodes:k,renderedSourceKeys:x}=u.useMemo(()=>{const A=[],R=new Set;return h.forEach((P,O)=>{var M;const I=(M=P[0])==null?void 0:M.id;if(!I)return;if(Qn(P)){A.push(r.jsx(nr,{groups:[P]},I));return}let B=[];const E=()=>{var $;const W=($=B[0])==null?void 0:$.id;W&&A.push(r.jsx(nr,{groups:[B]},W)),B=[]};for(const W of P){const $=f.get(W.id);$?(E(),R.has($.key)||(R.add($.key),A.push(r.jsx(Eo,{turn:{active:!1,items:$.items},agent:d,timestamp:W.timestamp},$.key)))):w&&O>y||B.push(W)}E()}),{nodes:A,renderedSourceKeys:R}},[h,f,w,y,d]),S=s!==null&&n.length>0&&!x.has(s),b=c.getComponent("loading"),{containerRef:N,handleScroll:j,showScrollDown:g,scrollToBottom:_}=hu([e,n]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{...F("chat/msgs/wrapper"),className:"relative flex flex-1 flex-col min-h-0",children:[r.jsxs("div",{...F("chat/msgs/root"),ref:N,onScroll:j,className:"max-h-full relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[r.jsx(Ta,{}),r.jsx(Na,{}),r.jsx(Aa,{}),[...k,...S?[r.jsx(Eo,{turn:{active:t,items:n},agent:d},s)]:[]],t&&n.length===0&&b&&r.jsx(b,{agent:d}),i&&!t&&r.jsxs("div",{...F("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:l("turn_failed_message")}),r.jsx("button",{...F("chat/turn_failed/retry"),type:"button",onClick:a,className:"font-medium underline underline-offset-2 hover:opacity-80",children:l("turn_failed_retry")})]}),r.jsx(Ca,{}),r.jsx(ja,{})]}),r.jsx(H.AnimatePresence,{children:g&&u.createElement(H.motion.button,{...F("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:_,"aria-label":l("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(z.ArrowDown,{className:"size-4"}))})]}),m&&m.length>0&&r.jsx("div",{...F("chat/session-plan"),className:"shrink-0 px-4 pb-2",children:r.jsx(Ld,{plan:m,active:t},(p==null?void 0:p.id)??"new-session")})]})}function gu(){const e=De(),{activeMode:t,Component:n}=C.useModes(),{sendMessage:o}=C.useMessages(),{createStateCheckpoint:s}=C.useSessions(),[i,a]=u.useState(!1),c=async l=>{try{a(!0),await o(l)}catch(d){Q.log.error("mode component send failed",d)}finally{a(!1)}};return!t||!n?null:r.jsx(n,{...e,mode:t,createStateCheckpoint:s,sendMessage:c,isSendingMessage:i})}function Oa(){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 ve=u.forwardRef((e,t)=>{var n,o,s;return r.jsx(te,{...e,ref:t,className:T("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}}})});ve.displayName="MotionDiv__VerticalReveal";const xu=[{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 bu(){const{isSmallScreen:e}=Ae(),{t}=ee(),{submitCsat:n,isCsatRequested:o,isCsatSubmitted:s,submittedScore:i,submittedFeedback:a}=C.useCsat(),[c,l]=u.useState(null),[d,p]=u.useState(null),m=f=>{l(y=>y===f?null:f)},h=()=>{c&&n({score:c,feedback:d||void 0})};return!o&&!s?null:r.jsxs("div",{className:"w-1/2 min-w-80 max-w-96 mx-auto overflow-hidden",children:[r.jsx(H.AnimatePresence,{mode:"wait",children:o&&!c?r.jsx(ve,{children:r.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:t("csat_title")})},"csat-requested-title"):s?r.jsx(ve,{children:r.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:t("csat_submitted_title")})},"csat-submitted-title"):null}),r.jsx("div",{dir:"ltr",className:T("flex gap-4 justify-between pt-2 px-2 pb-2","transition-all",s&&"gap-0 justify-center"),children:xu.map(f=>r.jsx(G,{variant:f.value===c?"secondary":"ghost",size:"selfless",className:T("transition-all overflow-hidden","text-2xl size-8 rounded-full","opacity-35","hover:opacity-100",!c&&"opacity-100",f.value===c&&"opacity-100",s&&f.value!==i&&"opacity-0 size-0",s&&f.value===i&&"opacity-100 size-fit text-4xl"),onClick:o?()=>m(f.value):void 0,children:f.emoji},f.value))}),r.jsx(H.AnimatePresence,{mode:"wait",children:(c||i)&&r.jsx(ve,{children:r.jsxs("div",{className:"pb-2 px-2 flex items-end",children:[r.jsx("textarea",{rows:3,className:T("transition-all","max-h-40 [field-sizing:content]","w-full resize-none","bg-transparent outline-none","placeholder:text-muted-foreground",e?"text-[16px]":"text-sm",s&&"text-center"),value:s?a||"":d||"",onChange:o?f=>p(f.target.value):void 0,readOnly:s,placeholder:o?t("csat_feedback_placeholder"):void 0}),r.jsx(G,{size:"fit",onClick:h,disabled:!c,className:T("transition-all overflow-hidden","rounded-full size-8 flex items-center justify-center p-0",s&&"opacity-0 size-0"),children:r.jsx(z.ArrowUpIcon,{className:"size-4"})})]})},"feedback-box")}),r.jsx("div",{className:T("h-0 transition-[height]",s&&"h-4")})]})}function wu(){const{t:e}=ee(),t=[e("i_need_more_help"),e("this_was_helpful")];return r.jsx("div",{...F("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(kn,{suggestion:n,className:"flex-1"},n))})}function rr(){const{sessionState:e}=C.useSessions(),{chatFooterItems:t}=C.useConfig(),n=!!e.session&&!e.session.isOpened,o=!n;return r.jsx(H.AnimatePresence,{mode:"wait",children:t==null?void 0:t.map((s,i)=>s.showWhenSessionIsOpen===!1&&o||s.showWhenSessionIsResolved===!1&&n?null:r.jsx(ve,{children:r.jsx("div",{className:"pb-2 text-center text-xs",children:r.jsx(id,{children:s.message})})},`${s.message}-${i}`))})}function un(){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 yu({sessionId:e,active:t}){var a;const{widgetCtx:n,config:o}=C.useWidget(),[s,i]=u.useState(null);return u.useEffect(()=>{var p;if(i(null),!t||((p=o.capabilities)==null?void 0:p.connections)!==!0)return;const c=new AbortController;let l;const d=async()=>{try{const m=await n.api.listElicitations(e,c.signal);c.signal.aborted||i(m[0]??null)}catch{i(m=>m&&m.expiresAt>Date.now()?m:null)}c.signal.aborted||(l=setTimeout(d,1500))};return d(),()=>{c.abort(),clearTimeout(l)}},[n,e,t,(a=o.capabilities)==null?void 0:a.connections]),r.jsxs(r.Fragment,{children:[" ",s&&s.expiresAt>Date.now()?r.jsx(vu,{request:s,onAnswer:async c=>{await n.api.answerElicitation(e,s.id,c),i(null)}},s.id):null]})}function vu({request:e,onAnswer:t}){var p,m;const[n,o]=u.useState(!1),[s,i]=u.useState(""),a=async h=>{if(!n){o(!0),i("");try{await t(h)}catch(f){i(f instanceof Error?f.message:"Could not submit. Try again.")}finally{o(!1)}}},c=e.form.requestedSchema.properties,l=Object.keys(c).length===1&&((p=c.approve)==null?void 0:p.type)==="boolean"&&((m=e.form.requestedSchema.required)==null?void 0:m.includes("approve")),d="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 ${l?"overflow-visible":"max-h-[50vh] overflow-y-auto"}`,onSubmit:h=>{if(h.preventDefault(),l){a({action:"accept",content:{approve:!0}});return}const f=new FormData(h.currentTarget),y={};for(const[w,k]of Object.entries(c)){const x=f.get(w);if(k.type==="boolean")y[w]=x==="on";else if(k.type==="array"){const S=f.getAll(w).filter(b=>typeof b=="string");if(k.minItems!==void 0&&S.length<k.minItems){i(`${k.title??w}: select at least ${k.minItems} options.`);return}if(k.maxItems!==void 0&&S.length>k.maxItems){i(`${k.title??w}: select no more than ${k.maxItems} options.`);return}y[w]=S}else typeof x=="string"&&x!==""&&(y[w]=k.type==="number"||k.type==="integer"?Number(x):x)}a({action:"accept",content:y})},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(un,{})}),r.jsx("p",{className:"min-w-0 flex-1 text-sm leading-5 break-words",children:e.form.message}),r.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-foreground/50",wobble:!1,"aria-label":"Cancel request",disabled:n,onClick:()=>void a({action:"cancel"}),children:r.jsx(z.X,{className:"size-3.5"})})]}),!l&&r.jsx("fieldset",{disabled:n,className:"space-y-3",children:Object.entries(c).map(([h,f])=>{var x,S,b,N,j;const y=`${e.id}-${h}`,w=f.oneOf??((x=f.enum)==null?void 0:x.map(g=>({const:g,title:g})))??((S=f.items)==null?void 0:S.anyOf)??((N=(b=f.items)==null?void 0:b.enum)==null?void 0:N.map(g=>({const:g,title:g}))),k=(j=e.form.requestedSchema.required)==null?void 0:j.includes(h);return r.jsxs("div",{children:[r.jsxs("label",{htmlFor:y,className:"block text-sm font-medium mb-1",children:[f.title??h,k?" *":""]}),f.description&&r.jsx("p",{className:"text-sm text-foreground/60 mb-1",children:f.description}),f.type==="boolean"?r.jsx("input",{id:y,name:h,type:"checkbox",defaultChecked:f.default===!0,className:"size-5 accent-current"}):w?r.jsxs("select",{id:y,name:h,multiple:f.type==="array",required:k,className:d,defaultValue:typeof f.default=="string"||Array.isArray(f.default)?f.default:f.type==="array"?[]:"",children:[f.type!=="array"&&r.jsx("option",{value:"",children:"Choose…"}),w.map(g=>r.jsx("option",{value:g.const,children:g.title??g.const},g.const))]}):r.jsx("input",{id:y,name:h,className:d,type:f.type==="number"||f.type==="integer"?"number":f.format==="email"?"email":f.format==="uri"?"url":f.format==="date"?"date":"text",required:k,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(G,{type:"submit",size:"sm",className:"h-7 rounded-lg px-2.5 py-0 text-xs",wobble:!1,disabled:n,children:n?"Submitting…":l?"Approve once":"Submit"}),l&&e.approvalKey&&r.jsx(G,{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 a({action:"accept",content:{approve:!0},remember:!0}),children:"Always allow"}),r.jsx(G,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-lg px-2.5 py-0 text-xs",wobble:!1,disabled:n,onClick:()=>void a({action:"decline"}),children:"Decline"})]})]})}function ku({request:e}){const t=C.useConnection(e),{phase:n,authorization:o,continuation:s,error:i}=t,c=n==="loading"||n==="waiting"||s!==null,l=n==="connected"||n==="external",d=(i==null?void 0:i.toLowerCase().includes("expired"))??!1,p=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",m=s?s==="renew"?"Requesting…":"Continuing…":n==="loading"?"Preparing…":n==="waiting"?"Waiting…":d?"Reconnect":i?"Try again":l?"Continue":"Connect",h=()=>i||l?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(un,{})}),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,": ",p]}),n==="ready"&&o&&!s?r.jsx(G,{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(G,{type:"button",wobble:!1,size:"sm",className:"h-7 shrink-0 px-2.5 text-xs order-2",disabled:c,"aria-busy":c,title:d?"Your access expired. Connect again to continue.":void 0,onClick:()=>void h(),children:[c&&r.jsx(Ir,{}),m]}),r.jsx(G,{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"})]}),i&&r.jsx("p",{role:"alert",className:"px-1 pt-2 text-sm text-pretty text-destructive",children:i})]})}const ju=["box","circle","arrow","bracket","underline","highlight","strike-through","crossed-off"];function Cu(e){const t=new Map,n=[];for(const o of e){let s;for(const i of o.elements){const a=i.selector||i.name,c=t.get(a);if(c){s??(s=c);continue}const l={...i};t.set(a,l),n.push(l),s??(s=l)}o.note&&s&&(s.note=s.note?`${s.note}
111
+ ${o.note}`:o.note)}return n}const zo=20,Su=4e3;function or(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 Nu(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 i=null;try{i=gs.annotate(s,{type:t,color:n,strokeWidth:2,wobble:.8}),i.show(),or(s,o)}catch(d){Q.log.warn("page mark: could not be drawn",d)}let a=!1;const c=()=>{if(!a){a=!0;try{i==null||i.remove()}catch{}s.remove()}},l=d=>{if(!a)try{i==null||i.update(d),or(s,o)}catch{}};return{setRect(d){a||(s.style.left=`${d.x}px`,s.style.top=`${d.y}px`,s.style.width=`${d.width}px`,s.style.height=`${d.height}px`,l({}))},setShape(d){l({type:d})},undraw(){if(!a){if(!i)return c();try{i.hide(),i.finished.then(c)}catch{return c()}window.setTimeout(c,Su)}},remove:c}}const _u=60;function Ve(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function $a(e){return Ma(e)}function Eu(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 Tu(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)&&!Eu(o))??null:null}function Au(e){if(Te(e))return"private region";const t=e.tagName.toLowerCase(),n=e.getAttribute("aria-label"),o=$a(e);if(t==="button"||e.getAttribute("role")==="button")return n?`button [${n}]`:o?`button "${Ve(o,30)}"`:"button";if(t==="a"){if(o)return`link "${Ve(o,30)}"`;const i=e.getAttribute("href"),a=i?Rr(i):"",c=i!=null&&i.startsWith("/")&&!i.startsWith("//")&&a?new URL(a).pathname:a;return c?`link to ${Ve(c,40)}`:"link"}if(t==="input"||t==="textarea"||t==="select"){const i=e.getAttribute("placeholder"),a=e.getAttribute("name");return i?`${t} "${Ve(i,30)}"`:n?`${t} [${n}]`:a?`${t} [${a}]`:t==="input"?`${e.getAttribute("type")??"text"} input`:t}if(/^h[1-6]$/.test(t))return o?`${t} "${Ve(o,40)}"`:t;if(t==="img"){const i=e.getAttribute("alt");return i?`image "${Ve(i,30)}"`:"image"}if(t==="svg")return"icon";if(n)return`${t} [${n}]`;if(o&&o.length<=_u)return`${t} "${Ve(o,40)}"`;const s=Tu(e);return s||(t==="div"?"container":t)}function Io(e,t){try{return e.querySelectorAll(t).length===1}catch{return!1}}function zu(e){const t=e.ownerDocument;if(e.id){const s=`#${CSS.escape(e.id)}`;if(Io(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 i=s;const a=o.parentElement;if(a){const l=Array.from(a.children).filter(d=>d.tagName===(o==null?void 0:o.tagName));l.length>1&&(i+=`:nth-of-type(${l.indexOf(o)+1})`)}n.unshift(i);const c=n.join(" > ");if(Io(t,c))return c;o=a}return n.join(" > ")}function Iu(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 Mu=8;function Mo(e,t=Mu){const n=document.documentElement.clientWidth||window.innerWidth,o=document.documentElement.clientHeight||window.innerHeight,s=Math.max(e.x,t),i=Math.max(e.y,t),a=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(i),width:Math.round(Math.max(0,a-s)),height:Math.round(Math.max(0,c-i))}}function La(e){if(Te(e)||e.closest(at))return{name:"private region",selector:"",tag:"div"};const t=$a(e);return{name:Au(e),selector:zu(e),tag:e.tagName.toLowerCase(),text:t?Ve(t,200):void 0}}const Ru=Mr.join(", ");function Ut(e){return e.closest(Ru)!==null}function sr(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 i=n.closest('button, a, input, textarea, select, [role="button"], [role="link"]')??n;for(;i&&!(i instanceof HTMLElement);)i=i.parentElement;if(!(i instanceof HTMLElement)||Te(n)||Te(i)||i.closest(at))return null;const a=i.tagName.toLowerCase();return a==="html"||a==="body"?null:i}const Pr=new WeakMap;function Pu(e,t){Pr.set(e,[...t])}function on(e){const t=Pr.get(e);return t!==void 0&&e.pageUrl===Rr(window.location.href)&&t.every(n=>n.isConnected&&n.getRootNode()===document&&!Te(n)&&!n.closest(at))}function Ou(e){const t=Pr.get(e);if(!t||!on(e))return null;const n=t.map(La),o=t.length>0&&t.every(Pt)&&JSON.stringify(n)===JSON.stringify(e.elements),s={...e,elements:n};return o?tu(e,s):delete s.snapshotUrl,s}const Ro=120,Qe=e=>e.replace(/\s+/g," ").trim(),Ue=e=>e.length>Ro?`${e.slice(0,Ro)}…`:e,pn=Ma;function $u(e){const t=e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.labels:null,n=t?Array.from(t).map(i=>pn(i)).join(" "):"";if(n)return Qe(n);const o=e.closest("fieldset"),s=o==null?void 0:o.querySelector("legend");return s?pn(s):""}function jt(e){if(Te(e))return"";const t=e.getAttribute("aria-labelledby");if(t){const a=t.split(/\s+/).map(c=>e.ownerDocument.getElementById(c)).filter(c=>c!==null).map(c=>pn(c)).filter(Boolean).join(" ");if(a)return Ue(Qe(a))}const n=e.getAttribute("aria-label");if(n!=null&&n.trim())return Ue(Qe(n));const o=e.tagName.toLowerCase();if(o==="img"){const a=e.getAttribute("alt");if(a!=null&&a.trim())return Ue(Qe(a))}if(o==="input"||o==="select"||o==="textarea"){const a=$u(e);if(a)return Ue(a);const c=e.getAttribute("placeholder");if(c!=null&&c.trim())return Ue(Qe(c));const l=e.getAttribute("title");return l!=null&&l.trim()?Ue(Qe(l)):""}const s=pn(e);if(s)return Ue(s);const i=e.getAttribute("title");return i!=null&&i.trim()?Ue(Qe(i)):""}const Lu=["click","fill","select","check","uncheck"],Du=3e3,Da=new Set(["password","file","hidden"]);function Fa(e){const t=new WeakRef(e),n=Po(e).map(o=>{const s=Oo(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=Po(o).map(Oo);return s.length===n.length&&s.every((i,a)=>{var l,d;const c=n[a];return i.allowed&&i.element===c.element.deref()&&i.form===(((l=c.form)==null?void 0:l.deref())??null)&&i.labelControl===(((d=c.labelControl)==null?void 0:d.deref())??null)&&i.semantics===c.semantics})}}function Po(e){const t=[],n=new Set,o=s=>{for(let i=s;i&&!n.has(i);i=i.parentElement)n.add(i),(i===e||i.matches("a[href],area[href],button,input,select,textarea,label"))&&t.push(i),i instanceof HTMLLabelElement&&i.control&&o(i.control)};return o(e),t}function Oo(e){var i;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=(i=e.ownerDocument.querySelector("base[target]"))==null?void 0:i.getAttribute("target");return{element:e,form:o,labelControl:e instanceof HTMLLabelElement?e.control:null,allowed:!(e instanceof HTMLInputElement&&Da.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(a=>e.getAttribute(a)),e instanceof HTMLButtonElement||e instanceof HTMLInputElement?[e.formAction,e.formMethod,e.formTarget,e.formEnctype,e.formNoValidate]:null])}}const Fu=2,gt=[];let Wu=0,$o=new WeakMap,et,Lo,Or=new WeakMap,$r=new WeakMap,mn=new WeakMap;const Hu='tr,li,article,form,fieldset,section,dialog,aside,nav,main,header,footer,[role="row"],[role="listitem"],[role="group"],[role="region"],[role="dialog"],[role="tooltip"]',Lr='tr,li,article,[role="row"],[role="listitem"]',Mn='section,form,fieldset,dialog,[role="group"],[role="region"],[role="dialog"]',Bu=new Set(["class","style","aria-busy"]);function Uu(e){var i,a;const t=e.closest(Lr);if(t)return t;let n=e.closest(Mn);if(n){let c=(i=n.parentElement)==null?void 0:i.closest(Mn);for(;c;)n=c,c=(a=n.parentElement)==null?void 0:a.closest(Mn);return n}const o=e.closest(Hu);if(o)return o;const s=e.parentElement;return s&&s!==e.ownerDocument.body&&s!==e.ownerDocument.documentElement?s:e}function qu(e){return Ut(e)||e.closest('[role="tooltip"]')!==null}function Vu(e){const t=e.target.nodeType===1?e.target:e.target.parentElement;if(t&&Ut(t)||e.type==="attributes"&&Bu.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&&qu(o)))return!1}return!0}function Wa(e){const t=new Set;for(const n of e){for(const s of Array.from(n.removedNodes)){const i=mn.get(s);i&&t.add(i)}if(!Vu(n))continue;if(n.type==="attributes"){const s=mn.get(n.target);s&&t.add(s)}let o=!0;for(let s=n.target;s;s=s.parentNode){const i=Or.get(s);if(i&&t.add(i),o){const a=$r.get(s);a&&t.add(a)}if(s instanceof Element&&(s.matches(Lr)&&(o=!1),s.matches('[role="tooltip"]')&&!(n.type==="attributes"&&n.attributeName==="role")))break}}t.forEach(n=>n.value++)}function Yu(e){const t=[],n=(s,i)=>{let a=i.get(s);a||(a={value:0},i.set(s,a)),t.push({revision:a,value:a.value})},o=Uu(e);n(o,Or);for(let s=e;s;s=s.parentNode)n(s,mn),s!==o&&s instanceof Element&&s.matches(Lr)&&n(s,$r);return()=>t.every(({revision:s,value:i})=>s.value===i)}function ar(){et&&Wa(et.takeRecords())}function Xu(e){if(Lo!==e){et==null||et.disconnect();for(const t of gt)for(const n of Array.from(t.values()))n.valid=!1;Lo=e,Or=new WeakMap,$r=new WeakMap,mn=new WeakMap,et=new MutationObserver(Wa),et.observe(e.documentElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}}function Ha(e,t,n=jt(t)){return e.valid&&(e.valid=t.isConnected&&e.url===t.ownerDocument.location.href&&e.name===n&&e.sameContext()&&e.sameMeaning()),e.valid}function Gu(){ar();const e=new Map;gt.unshift(e),gt.length=Math.min(gt.length,Fu);let t=0;const n=`s${++Wu}`;return(o,s=jt(o))=>{Xu(o.ownerDocument),ar();const i=$o.get(o),a=i?gt.map(d=>d.get(i)).find(d=>d!==void 0):void 0,c=i&&a&&Ha(a,o,s)?i:`${n}c${t+=1}`,l=c===i&&a?a:{element:new WeakRef(o),sameContext:Yu(o),name:s,url:o.ownerDocument.location.href,sameMeaning:Fa(o),valid:!0};return e.set(c,l),$o.set(o,c),c}}function Do(e){const t=Ba(e);return t!=null&&t.isCurrent?t.element:null}function Ba(e){ar();for(const t of gt){const n=t.get(e);if(!n)continue;const o=n.element.deref();if(o&&o.isConnected)return{element:o,isCurrent:Ha(n,o)}}return null}const Ku="data-opencx-private",Zu=new Set(["password","file","hidden"]),Fo=300;function ir(e){if(Ut(e))return"widget-owned";if(e.closest(`[${Ku}]`))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(Zu.has(t))return"credential-field"}return null}const Ju={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."},Wo=["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(","),Qu=["tr","li",'[role="row"]','[role="listitem"]','[role="gridcell"]',"[tabindex]","[onclick]"].join(","),ep=400;function tp(e){var t;try{return((t=e.ownerDocument.defaultView)==null?void 0:t.getComputedStyle(e).cursor)==="pointer"}catch{return!1}}function np(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 rp(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 Ho(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 op(e){return"disabled"in e&&e.disabled===!0?!0:e.getAttribute("aria-disabled")==="true"}function cr(e=document){const t=[],n=new Set;let o=!1;try{const s=Gu(),i=Array.from(e.querySelectorAll(Wo));for(const c of i){if(ir(c)||!Ho(c))continue;const l=jt(c);if(!l)continue;if(t.length>=Fo){o=!0;break}const d={ref:s(c,l),role:np(c),name:l};op(c)&&(d.disabled=!0),t.push(d),n.add(c)}let a=0;if(!o){const c=Array.from(e.querySelectorAll(Qu));for(const l of c){if(t.length>=Fo){o=!0;break}if(a>=ep)break;if(n.has(l)||ir(l)||l.querySelector(Wo)||!Ho(l))continue;const d=jt(l);d&&(a+=1,tp(l)&&(t.push({ref:s(l,d),role:rp(l),name:d}),n.add(l)))}}}catch{return{controls:[],truncated:!1}}return{controls:t,truncated:o}}function Ua({marks:e,readsPage:t}){if(!t)return;const n={},o=e.flatMap(a=>{const c=Ou(a);return c?[c]:[]});o.length>0&&(n.page_marks=o,n.picked_elements=Cu(o));const{controls:s,truncated:i}=cr();return s.length>0&&(n.page_controls=s,i&&(n.page_controls_truncated=!0)),Object.keys(n).length>0?n:void 0}const sp={click:"click",fill:"type into",select:"change",check:"switch on",uncheck:"switch off"};function ap({request:e}){const{resolvePageAction:t}=C.useAgentChatUi(),n=sp[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(G,{size:"sm",className:"flex-1",onClick:()=>t(e.callId,!0),children:"Allow"}),r.jsx(G,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>t(e.callId,!1),children:"No"})]})]})}const sn="rounded-full size-8 flex items-center justify-center p-0 overflow-hidden",qa="bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground",ip=T("rounded-full p-0.5 text-muted-foreground","hover:bg-muted hover:text-foreground","transition-transform active:scale-90");function cp({entity:e,onRemove:t}){const{t:n}=ee();return r.jsxs("div",{...F("chat/input_box/page_context_pill"),className:T("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(z.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:ip,onClick:t,children:r.jsx(z.XIcon,{className:"size-3"})})]})}const lp=v.z.object({type:v.z.string().min(1),id:v.z.string().min(1),title:v.z.string().min(1),meta:v.z.record(v.z.string(),v.z.unknown()).optional()});function dp(){var o;const e=C.useConfig(),{widgetCtx:t}=C.useWidget();if(C.useHostLocation(),!t.features.pageContext)return null;const n=lp.safeParse((o=Q.resolveConfigContext(e))==null?void 0:o.entity);return n.success?n.data:null}function Qt(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 Dr({cssVars:e,primaryColor:t,contentZIndex:n}){return{accent:t,surface:Qt(e,"--opencx-background"),foreground:Qt(e,"--opencx-foreground"),mutedForeground:Qt(e,"--opencx-muted-foreground"),border:Qt(e,"--opencx-border"),inkZIndex:n-2,chromeZIndex:n-1,editorZIndex:n+1}}function up({isActive:e,draft:t,hover:n,onShapeChange:o,onAttach:s,onDiscard:i}){const a=vn(),{theme:c,cssVars:l}=fe(),{t:d}=ee();if(!a||!e)return null;const p=Dr({cssVars:l,primaryColor:c.primaryColor,contentZIndex:c.widgetContentContainer.zIndex}),{accent:m}=p;return Dt.createPortal(r.jsxs("div",{"data-opencx-overlay":"",style:{pointerEvents:"none"},children:[r.jsx("style",{children:`
112
+ @keyframes opencx-mark-hint-in {
113
+ from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
114
+ to { opacity: 1; transform: translateX(-50%) translateY(0); }
115
+ }
116
+ @keyframes opencx-mark-editor-in {
117
+ from { opacity: 0; transform: translateY(4px); }
118
+ to { opacity: 1; transform: translateY(0); }
119
+ }
120
+ @keyframes opencx-mark-frame-in {
121
+ from { opacity: 0; transform: scale(1.015); }
122
+ to { opacity: 1; transform: scale(1); }
123
+ }
124
+ @media (prefers-reduced-motion: reduce) {
125
+ [data-opencx-mark-hint], [data-opencx-mark-editor],
126
+ [data-opencx-mark-frame] { animation: none !important; }
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:p.chromeZIndex,display:"flex",alignItems:"center",gap:8,background:`color-mix(in srgb, ${p.surface} 92%, transparent)`,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",color:p.foreground,font:"500 12px/1.4 system-ui, sans-serif",padding:"7px 12px 7px 10px",borderRadius:999,whiteSpace:"nowrap",boxShadow:`0 0 0 1px ${p.border}, 0 8px 24px color-mix(in srgb, ${p.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(pp,{theme:p,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:p.chromeZIndex,borderRadius:10,boxShadow:`0 0 0 2px ${p.surface}, 0 0 0 3.5px ${m}, 0 12px 32px color-mix(in srgb, ${p.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(([h,f],y)=>r.jsx("div",{style:{position:"fixed",left:h-5,top:f-5,width:10,height:10,borderRadius:999,background:p.surface,boxShadow:`0 0 0 2px ${m}, 0 2px 6px color-mix(in srgb, ${p.foreground} 25%, transparent)`,zIndex:p.chromeZIndex,pointerEvents:"none"}},y)),r.jsx(fp,{draft:t,theme:p,onShapeChange:o,onAttach:s,onDiscard:i},"editor")]})]}),a)}function pp({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 mp={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"})]})},hp={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 fp({draft:e,theme:t,onShapeChange:n,onAttach:o,onDiscard:s}){const{accent:i}=t,{t:a}=ee(),[c,l]=u.useState(""),d=u.useRef(null);u.useEffect(()=>{var x;(x=d.current)==null||x.focus()},[]);const p=320,m=window.innerWidth,h=window.innerHeight,{rect:f}=e,y=Math.max(12,Math.min(f.x+f.width/2-p/2,m-p-12)),w=f.y+f.height+16,k=w+120>h?Math.max(12,f.y-116):w;return r.jsxs("div",{"data-opencx-mark-editor":"",style:{position:"fixed",left:y,top:k,width:p,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:ju.map(x=>{const S=x===e.shape,b=a(hp[x]);return r.jsx("button",{type:"button",title:b,"aria-label":a("page_mark_shape_aria",{shape:b}),"aria-pressed":S,onClick:()=>n(x),style:{border:"none",cursor:"pointer",borderRadius:8,width:32,height:28,display:"flex",alignItems:"center",justifyContent:"center",background:S?i:"transparent",color:S?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:mp[x]})},x)})}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("input",{ref:d,value:c,onChange:x=>l(x.target.value),onKeyDown:x=>{x.key==="Enter"?(x.preventDefault(),o(c)):x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),s())},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",paddingInlineStart:4}}),r.jsx("button",{type:"button","aria-label":a("page_mark_attach"),onClick:()=>o(c),style:{border:"none",borderRadius:999,width:26,height:26,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:i,color:t.surface,font:"600 13px/1 system-ui, sans-serif",cursor:"pointer"},children:"↑"})]})]})}function gp({mark:e,onRemove:t}){var c;const{t:n}=ee(),o=Ra(e),s=e.note??((c=e.elements[0])==null?void 0:c.name)??n("page_mark_region"),i=n("page_mark_remove",{label:s}),a=e.elements.map(l=>l.name).join(", ");return o?r.jsx(za,{...F("chat/input_box/page_mark_pill"),className:"group",shape:"tile",src:o,alt:s,title:a,note:e.note,children:r.jsx("button",{type:"button","aria-label":i,className:T("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(z.XIcon,{className:"size-3"})})}):r.jsxs("div",{...F("chat/input_box/page_mark_pill"),title:a,className:T("group relative size-12 shrink-0 overflow-hidden","flex items-center justify-center","rounded-2xl bg-background ring-1 ring-border"),children:[r.jsx(z.PenLineIcon,{className:"size-4 shrink-0 text-primary"}),r.jsx("span",{className:T("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":i,className:T("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(z.XIcon,{className:"size-3"})})]})}const Me={"close-panel":"Escape","toggle-fullscreen":"Mod+Shift+F",send:"Enter","send-alt":"Mod+Enter","history-prev":"ArrowUp","history-next":"ArrowDown"};function Va(){return typeof navigator>"u"?!1:/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)}function it(e,t,n=Va()){const o=t.split("+"),s=o.at(-1)??"",i=new Set(o.slice(0,-1)),a=i.has("Cmd")||i.has("Mod")&&n,c=i.has("Ctrl")||i.has("Mod")&&!n;return e.metaKey!==a||e.ctrlKey!==c||e.altKey!==i.has("Alt")||e.shiftKey!==i.has("Shift")?!1:e.key.toLowerCase()===s.toLowerCase()}const xp={Mod:"⌘",Cmd:"⌘",Ctrl:"⌃",Alt:"⌥",Shift:"⇧"},bp={Escape:"Esc",Enter:"⏎",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→"};function Fr(e,t=Va()){const n=e.split("+"),o=n.at(-1)??"",s=n.slice(0,-1),i=bp[o]??(o.length===1?o.toUpperCase():o);return t?[...s.map(a=>xp[a]??a),i].join(""):[...s.map(a=>a==="Mod"?"Ctrl":a),i].join("+")}const wp=25*1024*1024,Ya={"application/pdf":[".pdf"],...Pl,...Ol},yp={"text/*":[".txt"],"image/*":[".png",".jpg",".jpeg",".gif"],...Ya},vp={"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"],...Ya};function kp({status:e}){switch(e){case"uploading":return r.jsx(z.Loader2,{className:"size-4 animate-spin"});case"error":return r.jsx(z.AlertCircle,{className:"size-4 text-destructive"});default:return null}}function jp({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(z.FileAudio2Icon,{className:"size-4 text-muted-foreground"}):n==="video"?r.jsx(z.FileVideo2Icon,{className:"size-4 text-muted-foreground"}):e.type==="application/pdf"?r.jsx(z.FileText,{className:"size-4 text-muted-foreground"}):na({type:e.type,name:e.name})?r.jsx(z.FileSpreadsheet,{className:"size-4 text-muted-foreground"}):r.jsx(z.FileIcon,{className:"size-4 text-muted-foreground"})}function Cp({file:{status:e,file:t,error:n},onCancel:o}){const{t:s}=ee(),[i,a]=u.useState(null);return u.useEffect(()=>{if(!t.type.startsWith("image/"))return;const c=new FileReader;return c.onload=()=>a(c.result),c.onerror=()=>Q.log.error("failed to read file for preview"),c.readAsDataURL(t),()=>c.abort()},[t]),r.jsx(_e,{side:"bottom",content:e==="error"?r.jsx("span",{className:"text-destructive",children:s("upload_failed",{error:n??""})}):t.name,children:r.jsxs("div",{className:T(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(kp,{status:e})}),r.jsx("button",{type:"button",className:T("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(z.XIcon,{className:"size-4 text-primary-foreground"})}),r.jsx(jp,{file:t,fileContent:i})]})})}function Sp(){const{queuedUserMessages:e,removeQueued:t,stop:n}=C.useAgentChatUi(),{messagesState:{messages:o}}=C.useMessages(),{t:s}=ee(),i=u.useMemo(()=>e.filter(a=>!o.some(c=>c.id===a.id)),[e,o]);return r.jsx(H.AnimatePresence,{children:i.length>0&&r.jsx(ve,{children:r.jsxs("div",{...F("chat/queued_sends/root"),className:"mb-1 rounded-2xl border border-muted-foreground/15 bg-background shadow-sm",children:[r.jsxs("div",{...F("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:i.length})}),r.jsx("button",{type:"button",...F("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(z.CornerDownLeftIcon,{className:"size-3"})})]}),r.jsx("ul",{...F("chat/queued_sends/list"),className:"flex flex-col pb-1",children:i.map(a=>r.jsxs("li",{...F("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:a.content}),r.jsx("button",{type:"button",...F("chat/queued_sends/remove"),"aria-label":s("remove_queued_message"),onClick:()=>t(a.id),className:"shrink-0 rounded-md p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground hover:bg-muted",children:r.jsx(z.XIcon,{className:"size-3.5"})})]},a.id))})]})},"queued-sends-pill")})}function Np({levelRef:e}){const t=u.useRef(null);return u.useEffect(()=>{let n=0;const o=new Q.DictationLevelSmoother({attack:.2,release:.07}),s=[],i=()=>{var c;const a=(c=t.current)==null?void 0:c.children;if(a){const l=o.next(e.current);for(let d=0;d<a.length;d++){const p=a[d];if(p instanceof HTMLElement){const m=.75+.25*Math.sin(Date.now()/260+d*1.7),h=`scaleY(${Math.max(.25,Math.min(1,l*1.8*m)).toFixed(3)})`;s[d]!==h&&(p.style.transform=h,s[d]=h)}}}n=requestAnimationFrame(i)};return n=requestAnimationFrame(i),()=>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 _p({status:e,levelRef:t,onToggle:n,onPrewarm:o}){const{t:s}=ee(),i=e==="listening",a=e==="connecting",c=s(i||a?"stop_dictation":"dictate");return r.jsx(_e,{side:"top",align:"start",content:c,children:r.jsxs(G,{...F("chat/input_box/dictate_btn"),onClick:n,onPointerDown:l=>l.preventDefault(),onPointerEnter:o,onFocus:o,"aria-pressed":i||a,"aria-label":c,size:"fit",variant:"ghost",className:T("relative",sn,i&&qa),children:[a&&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(H.AnimatePresence,{mode:"wait",children:i?r.jsx(te,{distance:0,children:r.jsx(Np,{levelRef:t})},"bars"):r.jsx(te,{distance:0,children:r.jsx(z.MicIcon,{className:T("size-4",a&&"opacity-60")})},"mic")})]})})}function Ep(e,t){const n=e.ownerDocument;if(!n.defaultView)return null;const s=n.createElement("div");Xa(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 i=n.createElement("span");i.textContent="​",s.appendChild(i),n.body.appendChild(s);const a=i.offsetLeft,c=i.offsetTop-e.scrollTop;return s.remove(),{left:a,top:c}}function Xa(e,t){const n=e.ownerDocument.defaultView;if(!n)return;const o=n.getComputedStyle(e);for(const s of Tp)t.style.setProperty(s,o.getPropertyValue(s))}const Tp=["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"],Ap=300,Ga=260,zp=8,Ka="rounded-xl border border-border bg-background shadow-lg";function Ip({anchorRef:e,inputRef:t,anchorIndex:n,preview:o,groups:s,visible:i,searching:a,highlighted:c,onHighlight:l,onPick:d,onExpand:p}){var S;const{t:m}=ee(),[h,f]=u.useState(null);u.useLayoutEffect(()=>{const b=e.current;if(!b)return;const N=b.ownerDocument.defaultView,j=()=>{const _=b.getBoundingClientRect(),A=(N==null?void 0:N.innerWidth)??_.right,R=Math.min(Ap,Math.max(0,A-16)),P=t.current,O=P&&n!==null?Ep(P,n):null,I=P==null?void 0:P.getBoundingClientRect(),B=O&&I?I.left+O.left:_.left+8,E=Math.max(8,Math.min(B,A-8-R)),M=O&&I?I.top+O.top-4:_.top-4;f({left:E,width:R,top:M,detailBeside:o&&E+R+zp+Ga<=A-8})};j(),N==null||N.addEventListener("resize",j);const g=typeof ResizeObserver>"u"?null:new ResizeObserver(j);return g==null||g.observe(b),()=>{N==null||N.removeEventListener("resize",j),g==null||g.disconnect()}},[n,e,t,o,i.length]);const y=(S=e.current)==null?void 0:S.closest("[data-version]");if(!y||!h||i.length===0&&a)return null;const w=i[c],k=w!=null&&w.description?w:null;let x=-1;return Dt.createPortal(r.jsxs("div",{...F("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:T("flex max-h-72 flex-col overflow-hidden",Ka),children:r.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-1",children:i.length===0?r.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:m("mentions_empty")}):s.map(b=>u.createElement("div",{...F("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(N=>{const j=++x;return u.createElement("button",{...F("chat/input_box/mention_picker/option"),key:`${N.type}:${N.id}`,type:"button",role:"option","aria-selected":j===c,onMouseDown:g=>g.preventDefault(),onMouseEnter:()=>l(j),onClick:()=>d(N),className:T("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-sm",j===c?"bg-muted":"hover:bg-muted/60")},r.jsx(Za,{item:N}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground",children:N.title}))}),b.hidden>0&&r.jsx("button",{...F("chat/input_box/mention_picker/more"),type:"button",onMouseDown:N=>N.preventDefault(),onClick:()=>p(b.type),className:T("w-full rounded-lg px-2 py-1 text-start text-xs","text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:m("json_see_more",{count:String(b.hidden)})})))})}),k&&h.detailBeside&&r.jsx(Mp,{item:k})]}),y)}function Mp({item:e}){return r.jsxs("div",{...F("chat/input_box/mention_picker/detail"),style:{width:Ga},className:T("flex gap-3 p-3",Ka),children:[r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted",children:r.jsx(Za,{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 Za({item:e,className:t}){return e.icon?r.jsx("img",{src:e.icon,alt:"",className:T("size-4 shrink-0 rounded-sm object-contain",t)}):r.jsx(kt,{name:e.iconName??"AtSign",className:T("size-3.5 shrink-0 text-primary",t)})}const Ja=u.createContext(null);function Rp({children:e}){const[t,n]=u.useState([]),[o,s]=u.useState(!1),i=u.useRef(new Map),a=u.useCallback(m=>{s(m)},[]),c=u.useCallback((m,h)=>{i.current.set(m,h),n(f=>[...f,m])},[]),l=u.useCallback(m=>{const h=i.current.get(m);h&&(i.current.delete(m),h.undraw()),n(f=>f.filter(y=>y!==m))},[]),d=u.useCallback(()=>{const m=Array.from(i.current.values());i.current.clear();for(const h of m)h.undraw();n([])},[]);u.useEffect(()=>()=>{i.current.forEach(m=>m.remove()),i.current.clear()},[]);const p=u.useMemo(()=>({marks:t,isArmed:o,setArmed:a,attach:c,detach:l,detachAll:d}),[t,o,a,c,l,d]);return r.jsx(Ja.Provider,{value:p,children:e})}function Wr(){const e=u.useContext(Ja);if(!e)throw new Error("usePageMarks must be used within a PageMarksProvider");return e}const Pp="data-opencx-mark-cursor",Op=5,en=4,tn=6,Rn={width:160,height:100},$p=10,Lp=Mr.map(e=>`:not(${e}):not(${e} *)`).join(""),Dp=e=>e==="nw"||e==="se"?"nwse-resize":"nesw-resize";function Fp({enabled:e,onAttach:t,accentColor:n,zIndex:o}){const{isArmed:s,setArmed:i,attach:a}=Wr(),c=e&&s,[l,d]=u.useState(null),[p,m]=u.useState(null),h=u.useRef(null),f=u.useRef(null);f.current=l;const y=u.useCallback(()=>{var N;(N=h.current)==null||N.undraw(),h.current=null,d(null)},[]),w=u.useCallback(()=>i(!1),[i]),k=u.useCallback(N=>{var j;d(g=>g&&{...g,rect:N}),(j=h.current)==null||j.setRect({x:N.x+window.scrollX,y:N.y+window.scrollY,width:N.width,height:N.height})},[]),x=u.useCallback(N=>{var j;d(g=>g&&{...g,shape:N}),(j=h.current)==null||j.setShape(N)},[]);u.useEffect(()=>{!e&&s&&i(!1)},[e,s,i]),u.useEffect(()=>{if(!c)return;const N=document.createElement("style");N.setAttribute(Pp,"");let j=null;const g=L=>{L!==j&&(j=L,N.textContent=`*${Lp} { cursor: ${L} !important; }`)};g("crosshair"),document.head.appendChild(N);let _=null;const A=L=>L.target instanceof Element&&Ut(L.target),R=L=>A(L)?!1:(L.preventDefault(),L.stopPropagation(),L.stopImmediatePropagation(),!0),P=(L,X,K)=>{const re=[["nw",L.x,L.y],["ne",L.x+L.width,L.y],["sw",L.x,L.y+L.height],["se",L.x+L.width,L.y+L.height]];for(const[oe,pe,se]of re)if(Math.hypot(X-pe,K-se)<=$p)return oe;return null},O=(L,X,K)=>X>=L.x&&X<=L.x+L.width&&K>=L.y&&K<=L.y+L.height,I=(L,X)=>{var pe;const K=sr(L,X),re=Mo(K?(()=>{const se=K.getBoundingClientRect();return{x:se.left-tn,y:se.top-tn,width:se.width+tn*2,height:se.height+tn*2}})():{x:L-Rn.width/2,y:X-Rn.height/2,...Rn}),oe=((pe=f.current)==null?void 0:pe.shape)??"box";m(null),h.current=Nu({x:re.x+window.scrollX,y:re.y+window.scrollY,width:re.width,height:re.height},oe,n,o),d({rect:re,shape:oe})},B=L=>{var re;if(!R(L)||L.button!==0)return;const X=f.current;if(!X){I(L.clientX,L.clientY);return}const K=P(X.rect,L.clientX,L.clientY);if(K){_={kind:"resize",corner:K};return}if(O(X.rect,L.clientX,L.clientY)){_={kind:"move",grabX:L.clientX-X.rect.x,grabY:L.clientY-X.rect.y};return}(re=h.current)==null||re.undraw(),h.current=null,I(L.clientX,L.clientY)};let E=null,M=0;const W=L=>{if(!R(L))return;const X=f.current;if(!X){g("crosshair");const ae=sr(L.clientX,L.clientY);if(!ae){E=null,m(null);return}ae!==E&&(E=ae,M+=1),m({rect:Mo(Iu(ae)),key:M});return}if(!_){const ae=P(X.rect,L.clientX,L.clientY);g(ae?Dp(ae):O(X.rect,L.clientX,L.clientY)?"move":"crosshair");return}const{rect:K}=X;if(_.kind==="move"){k({...K,x:L.clientX-_.grabX,y:L.clientY-_.grabY});return}const re=_.corner.includes("w")?K.x+K.width:K.x,oe=_.corner.includes("n")?K.y+K.height:K.y,pe=Math.min(re,L.clientX),se=Math.max(re,L.clientX),be=Math.min(oe,L.clientY),ze=Math.max(oe,L.clientY);k({x:pe,y:be,width:Math.max(zo,se-pe),height:Math.max(zo,ze-be)})},$=L=>{R(L)&&(_=null)},q=L=>{A(L)||R(L),_=null},V=L=>{R(L)},U=L=>{var X;if(L.key==="Escape"){if(L.preventDefault(),L.stopPropagation(),_=null,f.current){(X=h.current)==null||X.undraw(),h.current=null,d(null),g("crosshair");return}i(!1)}};let D=window.scrollX,Z=window.scrollY;const ne=()=>{m(null);const L=window.scrollX-D,X=window.scrollY-Z;D=window.scrollX,Z=window.scrollY,!(L===0&&X===0)&&d(K=>K&&{...K,rect:{...K.rect,x:K.rect.x-L,y:K.rect.y-X}})};return document.addEventListener("pointerdown",B,!0),document.addEventListener("pointermove",W,!0),document.addEventListener("pointerup",$,!0),document.addEventListener("pointercancel",q,!0),document.addEventListener("click",V,!0),document.addEventListener("keydown",U,!0),document.addEventListener("scroll",ne,!0),()=>{N.remove(),document.removeEventListener("pointerdown",B,!0),document.removeEventListener("pointermove",W,!0),document.removeEventListener("pointerup",$,!0),document.removeEventListener("pointercancel",q,!0),document.removeEventListener("click",V,!0),document.removeEventListener("keydown",U,!0),document.removeEventListener("scroll",ne,!0),m(null)}},[c,n,o,k,i]),u.useEffect(()=>{!c&&f.current&&y()},[c,y]),u.useEffect(()=>()=>{var N;(N=h.current)==null||N.remove(),h.current=null},[]);const S=u.useCallback(N=>{if(!e)return;const j=f.current,g=h.current;if(!j||!g)return;const _=N.trim(),A=Wp(j.rect),R={shape:j.shape,..._?{note:_}:{},pageUrl:Rr(window.location.href),rect:j.rect,elements:A.map(La)};Pu(R,A),A[0]&&Kd(R,A[0]),h.current=null,d(null),i(!1),a(R,g),t==null||t(R)},[a,e,t,i]),b=u.useCallback(()=>{e&&i(!s)},[e,s,i]);return{isActive:c,draft:l,hover:p,setShape:x,attach:S,dropDraft:y,disarm:w,toggle:b}}function Wp(e){const t=new Set,n=(o,s)=>{const i=sr(o,s);i&&t.add(i)};n(e.x+e.width/2,e.y+e.height/2);for(let o=0;o<=en;o++)for(let s=0;s<=en;s++)n(e.x+e.width*o/en,e.y+e.height*s/en);return Array.from(t).slice(0,Op)}function Hp({enabled:e,inputRef:t}){const{widgetCtx:n}=C.useWidget(),{theme:o,cssVars:s}=fe(),i=Dr({cssVars:s,primaryColor:o.primaryColor,contentZIndex:o.widgetContentContainer.zIndex}),{marks:a,detach:c}=Wr(),l=u.useCallback(()=>{var m;(m=t.current)==null||m.focus()},[t]),d=u.useCallback(async m=>{if(!n.features.pageContext)return null;try{const{fileUrl:h}=await n.api.uploadFile({file:m,abortSignal:new AbortController().signal});return h??null}catch(h){return Q.log.warn("page mark snapshot upload failed",h),null}},[n]),p=Fp({enabled:e,onAttach:l,accentColor:i.accent,zIndex:i.inkZIndex});return{marks:a,detach:c,marking:p,uploadSnapshot:d}}function Bp({inputText:e,setInputText:t,inputRef:n,getSentTextHistory:o}){const s=u.useRef(null),i=u.useRef(""),a=()=>{const m=n.current;m&&(m.classList.remove("opencx-input-recall"),m.offsetWidth,m.classList.add("opencx-input-recall"))},c=(m,{animate:h=!0}={})=>{t(m),h&&a(),requestAnimationFrame(()=>{var f;return(f=n.current)==null?void 0:f.setSelectionRange(m.length,m.length)})};return{onKeyDown:m=>{if(it(m,Me["history-prev"])){const h=o();if(h.length===0)return!1;const f=s.current;if(f===null){const y=n.current;if(!((y==null?void 0:y.selectionStart)===0&&(y==null?void 0:y.selectionEnd)===0)&&e!=="")return!1;i.current=e,s.current=h.length-1}else{if(f===0)return!1;s.current=f-1}return m.preventDefault(),c(h[s.current],{animate:!m.repeat}),!0}if(it(m,Me["history-next"])){const h=s.current;if(h===null)return!1;m.preventDefault();const f=o();return h>=f.length-1?(s.current=null,c(i.current,{animate:!m.repeat}),i.current=""):(s.current=h+1,c(f[s.current],{animate:!m.repeat})),!0}return!1},onEdit:()=>{s.current=null},onSent:()=>{s.current=null,i.current=""}}}const Bo="max-h-16 [field-sizing:content] w-full px-2";function Qa({trailingActions:e,placeholder:t,hideAttachTools:n,disabled:o=!1}={}){var Yt;const{isSmallScreen:s}=Ae(),i=u.useRef(null),a=u.useRef(null),c=u.useRef(null),l=u.useRef(!0),{sendMessage:d,rememberSentText:p,getSentTextHistory:m}=C.useMessages(),{widgetCtx:h,componentStore:f}=C.useWidget(),{attachments:y,pageContext:w}=h.features,{isStreaming:k,stop:x,queuedUserMessages:S,pendingClarification:b,pendingConnection:N,pendingPageAction:j}=C.useAgentChatUi(),{sessionState:g}=C.useSessions(),{t:_}=ee(),{text:A,setText:R,clearSubmitted:P}=C.useComposerDraft(),O=dp(),I=lu({text:A,setText:R,inputRef:i}),B=I.picked.length>0;u.useLayoutEffect(()=>{const Y=i.current,me=c.current;!Y||!me||Xa(Y,me)},[B,A]);const[E,M]=u.useState(!1),W=O?`${O.type}:${O.id}`:"";u.useEffect(()=>{M(!1)},[W]);const[$,q]=u.useState(null),V=u.useRef(A);V.current=A;const U=u.useRef(()=>{}),D=C.useDictation({getValue:()=>V.current,setValue:Y=>{V.current=Y,R(Y)},onSend:()=>U.current()}),{stop:Z}=D;u.useEffect(()=>{o&&Z({executeFinalCommand:!1})},[o,Z]),u.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const ne=Bp({inputText:A,setInputText:R,inputRef:i,getSentTextHistory:m}),L=w&&!s,X=!o&&L&&n!==!0,{marks:K,detach:re,marking:oe,uploadSnapshot:pe}=Hp({enabled:X,inputRef:i});u.useEffect(()=>{w||K.forEach(re)},[w,K,re]);const{allFiles:se,handleCancelUpload:be,appendFiles:ze,isUploading:ae,successFiles:Ze}=C.useUploadFiles(),ct=!!((Yt=g.session)!=null&&Yt.isHandedOff),{isAwaitingBotReply:Re}=C.useIsAwaitingBotReply(),Pe=h.messageCtx.blocksSendWhileAwaitingReply&&Re,Fe=Y=>{o||!y||(q(null),ze(Y))},We=O!==null&&!E,He=se.length>0||K.length>0,Oe=!A.trim()&&Ze.length===0&&(!w||!K.some(on)),we=k&&Oe,lt=we&&S.length>0,ge=o||ae||Pe||Oe,le=()=>{if(D.stop({executeFinalCommand:!1}),o||Pe||ae)return;const Y=V.current,me=h.messageCtx.captureConversation(),_t=h.messageCtx.draftState.get(),$e=K.filter(de=>h.features.pageContext&&on(de)?!0:(re(de),!1)),Je=[...Ze];if(!Y.trim()&&Je.length===0&&$e.length===0)return;const Et=se.map(de=>de.id);$e.forEach(de=>Zd(de,pe)),Promise.all($e.map(de=>Jd(de,Up))).then(()=>Nt({isCurrentConversation:me,submittedText:Y,submittedDraft:_t,submittedMarks:$e,submittedFiles:Je,submittedFileIds:Et}))},Nt=({isCurrentConversation:Y,submittedText:me,submittedDraft:_t,submittedMarks:$e,submittedFiles:Je,submittedFileIds:Et})=>{if(!Y())return;const de=h.features.pageContext,Be=$e.filter(he=>de&&on(he)?!0:(re(he),!1));if(!me.trim()&&Je.length===0&&Be.length===0)return;const Xt=me.trim()||(Be.length>0?qp(Be)??_("page_mark_default_message"):"");let ut=!1;const Tt=I.picked;d({content:Xt,withPageEntity:!E,mentions:Tt.length>0?Tt:void 0,attachments:Je.flatMap(he=>he.fileUrl?[{url:he.fileUrl,type:he.file.type,name:he.file.name,id:he.id,size:he.file.size}]:[]),clientContext:Ua({marks:Be,readsPage:de}),onAccepted:()=>{if(ut||!Y())return;ut=!0,p(Xt),$e.forEach(pt=>re(pt)),Et.forEach(pt=>be(pt));const he=P(_t);l.current&&(ne.onSent(),M(!1),he&&I.reset())}}).catch(he=>{Q.log.error("failed to send message",he)})},{getRootProps:jn,getInputProps:dt,open:qt}=_i.useDropzone({onDrop:Fe,noClick:!0,disabled:o||!y,onDropRejected(){q(_("file_rejected"))},maxSize:wp,accept:ct?yp:vp}),Cn=Y=>{const me=Y.clipboardData;me&&me.files.length>0&&Fe(Array.from(me.files))};U.current=le;const Vt=f.getComponent("agent_chat_questions");return!N&&b&&Vt?r.jsx("div",{...F("chat/input_box/root"),className:"p-2 relative space-y-1",children:r.jsx(Vt,{request:b})}):r.jsxs("div",{...F("chat/input_box/root"),className:"p-2 relative space-y-1",...jn({ref:a}),children:[g.session&&r.jsx(yu,{sessionId:g.session.id,active:k||Re},g.session.id),N&&r.jsx(ku,{request:N},N.request_id),j&&r.jsx(ap,{request:j},j.callId),r.jsx("input",{...dt()}),I.isOpen&&r.jsx(Ip,{anchorRef:a,inputRef:i,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}),X&&r.jsx(up,{isActive:oe.isActive,draft:oe.draft,hover:oe.hover,onShapeChange:oe.setShape,onAttach:oe.attach,onDiscard:oe.dropDraft}),r.jsx(Sp,{}),$&&r.jsx("p",{role:"alert",className:"px-2 text-xs text-destructive",children:$}),D.error&&r.jsx("p",{role:"alert",className:"px-2 text-xs text-destructive",children:D.error==="microphone"?_("dictation_mic_blocked"):_("dictation_unavailable")}),r.jsxs("div",{...F("chat/input_box/attached_context_tray"),style:{"--cx-p":"0.25rem"},className:T("flex flex-col","rounded-[calc(var(--opencx-inset-radius)+var(--cx-p))] p-[var(--cx-p)]","transition-colors duration-200 ease-opencx",We?"bg-muted":"bg-transparent"),children:[r.jsx(H.AnimatePresence,{children:We&&r.jsx(ve,{children:r.jsx("div",{...F("chat/input_box/page_context_container"),className:"flex items-center gap-1 flex-wrap ps-3 pe-1 py-1",children:r.jsx(H.AnimatePresence,{mode:"popLayout",children:O&&!E&&r.jsx(te,{snapExit:!0,children:r.jsx(cp,{entity:O,onRemove:()=>M(!0)})},"page-entity")})})},"attached-context")}),r.jsxs("div",{...F("chat/input_box/inner_root"),className:T("transition-colors","bg-background","border border-border","relative rounded-[var(--opencx-inset-radius)] flex flex-col gap-2 p-2"),children:[r.jsxs("div",{...F("chat/input_box/textarea_and_attachments_container"),className:"flex flex-col gap-2",children:[He&&r.jsx("div",{...F("chat/input_box/attachments_container"),className:"flex items-center gap-1 overflow-x-auto",children:r.jsxs(H.AnimatePresence,{mode:"popLayout",children:[se.map(Y=>r.jsx(te,{snapExit:!0,children:r.jsx(Cp,{onCancel:()=>be(Y.id),file:Y})},Y.id)),K.map((Y,me)=>r.jsx(te,{snapExit:!0,children:r.jsx(gp,{mark:Y,onRemove:()=>re(Y)})},`mark-${me}-${Y.note??""}`))]})}),r.jsxs("div",{className:"relative",children:[B&&r.jsx("div",{ref:c,"aria-hidden":!0,className:T(Bo,"pointer-events-none absolute inset-0 overflow-hidden","whitespace-pre-wrap break-words text-foreground",!He&&"pt-1",s?"text-[16px]":"text-sm"),children:r.jsx(Pa,{text:A,mentions:I.picked,tokenClassName:"bg-primary/10 text-primary"})}),r.jsx("textarea",{...F("chat/input_box/textarea"),disabled:o,onPaste:Cn,ref:i,id:"chat-input",value:A,rows:3,className:T(Bo,"relative resize-none",!He&&"pt-1","bg-transparent outline-none","placeholder:text-muted-foreground",B&&"text-transparent caret-foreground",s?"text-[16px]":"text-sm"),onScroll:Y=>{c.current&&(c.current.scrollTop=Y.currentTarget.scrollTop)},onChange:Y=>{ne.onEdit(),R(Y.target.value)},onClick:()=>I.onCaretMove("nearest"),onKeyUp:Y=>{Y.key==="ArrowRight"||Y.key==="ArrowDown"?I.onCaretMove("forward"):Y.key==="ArrowLeft"||Y.key==="ArrowUp"?I.onCaretMove("backward"):(Y.key==="Home"||Y.key==="End")&&I.onCaretMove("nearest")},onKeyDown:Y=>{if(!Y.nativeEvent.isComposing&&!I.onKeyDown(Y)){if(it(Y,Me.send)||it(Y,Me["send-alt"])){Y.preventDefault(),lt?x():le();return}if(Y.key==="Escape"&&oe.isActive){oe.disarm();return}ne.onKeyDown(Y)}},placeholder:t??_("write_a_message_placeholder")})]})]}),r.jsxs("div",{className:"gap-2 flex justify-between",children:[r.jsx("div",{className:"flex items-center gap-1",children:!o&&!n&&r.jsxs(r.Fragment,{children:[y&&r.jsx(_e,{side:"top",align:"start",content:_("attach_files"),children:r.jsx(G,{onClick:qt,"aria-label":_("attach_files"),size:"fit",variant:"ghost",className:sn,children:r.jsx(H.AnimatePresence,{mode:"wait",children:Pe?r.jsx(te,{distance:0,children:r.jsx(z.PaperclipIcon,{className:"size-4 opacity-50"})},"paper-clip-disabled"):r.jsx(te,{distance:0,children:r.jsx(z.PaperclipIcon,{className:"size-4"})},"paper-clip")})})}),D.enabled&&r.jsx(_p,{status:D.status,levelRef:D.levelRef,onToggle:D.toggle,onPrewarm:D.prewarm}),L&&r.jsx(_e,{side:"top",align:"start",content:oe.isActive?_("mark_page_active"):_("mark_page"),children:r.jsx(G,{...F("chat/input_box/page_mark_btn"),onClick:oe.toggle,"aria-label":oe.isActive?_("mark_page_active"):_("mark_page"),size:"fit",variant:"ghost",className:T(sn,oe.isActive&&qa),children:r.jsx(z.MousePointerClickIcon,{className:"size-4"})})})]})}),r.jsxs("div",{className:"flex items-center gap-1",children:[e,r.jsx(_e,{content:_(we?"stop_response":"send_message"),shortcut:we?void 0:Fr(Me.send),side:"top",align:"end",children:r.jsx(G,{size:"fit",onClick:we?x:le,"aria-label":_(we?"stop_response":"send_message"),disabled:o||!we&&ge,className:sn,children:r.jsx(H.AnimatePresence,{mode:"wait",children:we?r.jsx(te,{snapExit:!0,distance:0,children:r.jsx(z.SquareIcon,{className:"size-3 fill-current"})},"stop"):!k&&(Pe||ae)?r.jsx(te,{snapExit:!0,distance:0,children:r.jsx(z.CircleDashed,{className:"size-4 animate-spin animate-iteration-infinite"})},"loading"):r.jsx(te,{snapExit:!0,distance:0,children:r.jsx(z.ArrowUpIcon,{className:"size-4"})},"send")})})})]})]})]})]})]})}const Up=1500;function qp(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 Uo(){const{widgetCtx:e}=C.useWidget(),{router:t}=C.useConfig(),{canCreateNewSession:n}=C.useSessions(),{toSessionsScreen:o}=C.useWidgetRouter(),{t:s}=ee();return r.jsx(r.Fragment,{children:n||t!=null&&t.chatScreenOnly?r.jsx(G,{onClick:e.resetChat,className:"rounded-2xl w-full",children:s("new_conversation")}):r.jsx(G,{onClick:o,className:"rounded-2xl w-full",children:s("back_to_conversations")})})}function Vp(){const{t:e}=ee(),{isCsatRequested:t,isCsatSubmitted:n}=C.useCsat();return r.jsx("div",{className:"p-2",children:r.jsx("div",{className:"p-2 bg-muted rounded-[var(--opencx-inset-radius)]",children:r.jsx(H.AnimatePresence,{mode:"wait",children:t||n?r.jsxs(ve,{children:[r.jsx(bu,{}),r.jsx(H.AnimatePresence,{mode:"wait",children:n&&r.jsx(ve,{children:r.jsx(Uo,{})},"new-conv-or-back-to-convs-button")})]},"csat"):r.jsxs(ve,{children:[r.jsxs("div",{className:"ps-2 flex items-center gap-1 pb-2",children:[r.jsx(z.CircleCheckIcon,{className:"size-4 text-emerald-600"}),r.jsx("h2",{className:"text-sm font-medium",children:e("your_issue_has_been_resolved")})]}),r.jsx(Uo,{})]},"session-closed")})})})}function Yp(){var c;const{initialQuestions:e,initialQuestionsPosition:t,thisWasHelpfulOrNot:n}=C.useConfig(),{sessionState:o}=C.useSessions(),{messagesState:s}=C.useMessages(),i=s.messages.length===0,a=Oa();return r.jsx("footer",{children:r.jsx(H.AnimatePresence,{mode:"wait",children:o.session&&!((c=o.session)!=null&&c.isOpened)?r.jsxs(ve,{children:[r.jsx(Vp,{}),r.jsx(rr,{})]},"session-closed"):r.jsxs(ve,{children:[s.lastAIResMightSolveUserIssue&&(n==null?void 0:n.enabled)!==!1&&r.jsx(wu,{}),i&&e&&t!=="below-initial-messages"&&r.jsx("div",{className:T("flex items-center flex-row justify-end gap-2 flex-wrap px-2",a&&"pb-4"),children:e==null?void 0:e.map((l,d)=>r.jsx(kn,{suggestion:l},`${l}-${d}`))}),!a&&r.jsx(Qa,{}),r.jsx(rr,{})]},"chat-input")})})}function Xp(){const{messagesState:{messages:e}}=C.useMessages(),{isAwaitingBotReply:t}=C.useIsAwaitingBotReply(),{componentStore:n}=C.useWidget(),o=C.useBot(),s=u.useMemo(()=>Sa(e),[e]),i=e.at(-1),a=i==null?void 0:i.id,c=i==null?void 0:i.type,l=u.useRef(a),[d,p]=u.useState(!1),m=t&&!d;u.useEffect(()=>{const w=l.current!==a;if(l.current=a,!t||c!=="AI"){p(!1);return}if(!w)return;p(!0);const k=setTimeout(()=>p(!1),600);return()=>clearTimeout(k)},[t,a,c]);const h=n.getComponent("loading"),f=u.useRef(null);function y(){setTimeout(()=>{const w=f.current;w&&(w.scrollTop=w.scrollHeight)},0)}return u.useEffect(()=>{y()},[e,m]),r.jsxs("div",{...F("chat/msgs/root"),ref:f,className:"max-h-full scroll-smooth relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[r.jsx(Ta,{}),r.jsx(Na,{}),r.jsx(Aa,{}),r.jsx(nr,{groups:s,pendingReply:t}),m&&h&&r.jsx(h,{agent:o}),r.jsx(Ca,{}),r.jsx(ja,{})]})}function Gp(){const{messagesState:{isInitialFetchLoading:e}}=C.useMessages(),{widgetCtx:t}=C.useWidget(),n=t.streaming,{sessionState:{session:o}}=C.useSessions(),{isCanvasOpen:s}=zd(),{theme:i}=fe();_r({width:s?i.screens.chat.withCanvas.width:i.screens.chat.width,height:s?i.screens.chat.withCanvas.height:i.screens.chat.height});const a=u.useRef((o==null?void 0:o.id)||"chat").current;return r.jsx("div",{...F("chat/root"),className:T("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(ba,{}),r.jsx(H.AnimatePresence,{mode:"wait",children:e?r.jsx(te,{className:"flex flex-col items-center justify-center w-full flex-1",children:r.jsx(wa,{})},"loading"):r.jsxs(te,{className:"flex items-start h-full flex-1 overflow-auto",snapExit:!0,children:[r.jsxs("div",{...F("chat/main/root"),className:T("flex flex-col h-full overflow-auto transition-all",s?"w-2/5":"w-full"),style:{transitionTimingFunction:i.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:i.screens.chat.withCanvas.transitionDuration},children:[n?r.jsx(fu,{}):r.jsx(Xp,{}),r.jsx(Yp,{})]}),r.jsx("div",{...F("chat/canvas/root"),className:T("h-full overflow-auto transition-all",s?"w-3/5":"w-0"),style:{transitionTimingFunction:i.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:i.screens.chat.withCanvas.transitionDuration},children:r.jsx(gu,{})})]},a)})]})})}function Kp({children:e}){var S,b,N;const{widgetCtx:t,config:n}=C.useWidget(),[o,s]=u.useState(!1),[i,a]=u.useState(null),[c,l]=u.useState(""),[d,p]=u.useState([]),[m,h]=u.useState([]),[f,y]=u.useState(!1),[w,k]=u.useState("");u.useEffect(()=>{var g;let j=!1;if(((g=n.capabilities)==null?void 0:g.connections)===!0)return Promise.all([t.api.listConnections(),t.api.listApprovalPreferences()]).then(([_,A])=>{j||(p(_.filter(R=>R.status!=="not_connected")),h(A))}).catch(()=>{}),()=>{j=!0}},[t,(S=n.capabilities)==null?void 0:S.connections]);const x=async j=>{y(!0),k("");try{await j()}catch{k("Could not save the change. Try again.")}finally{y(!1)}};return!o||((b=n.capabilities)==null?void 0:b.connections)!==!0?r.jsxs(r.Fragment,{children:[r.jsx(ba,{}),((N=n.capabilities)==null?void 0:N.connections)===!0&&d.length>0&&r.jsxs(G,{variant:"ghost",className:"mx-3 my-1 h-9 justify-start gap-2 text-sm",onClick:()=>s(!0),children:[r.jsx(z.Unplug,{className:"size-4"})," Connections"," ",r.jsx(z.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(G,{variant:"ghost",size:"icon",className:"size-7","aria-label":i?"Back to connections":"Back to sessions",onClick:()=>i?a(null):s(!1),children:r.jsx(z.ArrowLeft,{className:"size-4"})}),r.jsx("h2",{className:"text-sm font-medium",children:"Connections"})]}),!d.length&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"No connected services."}),!i&&r.jsxs(r.Fragment,{children:[r.jsx("input",{type:"search","aria-label":"Search connections",placeholder:"Search connections",value:c,onChange:j=>l(j.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"}),d.filter(j=>j.name.toLowerCase().includes(c.toLowerCase())).map(j=>r.jsxs("button",{type:"button",onClick:()=>a(j.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(un,{})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-sm font-medium",children:j.name}),r.jsx("span",{className:"block text-xs text-muted-foreground",children:j.status==="connected"?"Connected":"Reconnect required"})]}),r.jsx(z.ChevronRight,{className:"size-4 text-muted-foreground"})]},j.server_id)),d.length>0&&!d.some(j=>j.name.toLowerCase().includes(c.toLowerCase()))&&r.jsx("p",{className:"py-3 text-xs text-muted-foreground",children:"No matching connections."})]})]}),d.filter(j=>j.server_id===i).map(j=>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(un,{})}),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:j.name}),r.jsx("p",{className:"text-xs text-muted-foreground",children:j.status==="connected"?"Connected":"Reconnect required"})]}),r.jsx(G,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",disabled:f,onClick:()=>void x(async()=>{await t.api.disconnectConnection(j.server_id),a(null),p(g=>g.filter(_=>_.server_id!==j.server_id)),h(g=>g.filter(_=>_.serverId!==j.server_id))}),children:"Disconnect"})]}),m.some(g=>g.serverId===j.server_id)?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("h3",{className:"text-xs font-medium",children:["Saved approvals (",m.filter(g=>g.serverId===j.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":`${j.name} saved approvals`,children:m.filter(g=>g.serverId===j.server_id).map(g=>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:g.toolName.replace(/[_-]+/g," ")}),r.jsx("p",{className:"text-xs text-muted-foreground break-words",children:g.message})]}),r.jsx(G,{variant:"secondary",size:"sm",className:"h-7 shrink-0 px-2 text-xs",disabled:f,onClick:()=>void x(async()=>{await t.api.revokeApprovalPreference(g.serverId,g.key),h(_=>_.filter(A=>A.serverId!==g.serverId||A.key!==g.key))}),children:"Remove approval"})]},g.key))})]}):r.jsx("p",{className:"text-xs text-muted-foreground",children:"No saved approvals"})]},j.server_id)),w&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:w})]})}function Zp({className:e,...t}){return r.jsx("div",{className:T("animate-pulse rounded-md bg-secondary",e),...t})}function Jp({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:T("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 ei({className:e}){const{token:t}=C.useConfig();return r.jsx("div",{className:T("flex items-center justify-center gap-2 p-2 pt-0",e),children:r.jsx(Ie,{children:r.jsxs("a",{href:`https://open.cx/?ref=${t}`,target:"_blank",rel:"noreferrer",className:T("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(Jp,{className:"size-3 inline-block"})}),r.jsx("span",{className:"font-semibold",children:"open"})]})]})})})}function Qp({children:e}){return r.jsx("p",{className:"ps-4 text-xs text-muted-foreground/75 uppercase font-semibold tracking-tight",children:e})}function qo({session:e,className:t}){const{humanAgent:n}=C.useConfig(),o=C.useBot(),{toChatScreen:s}=C.useWidgetRouter(),i=e.assignee.kind==="human"?(n==null?void 0:n.name)||e.assignee.name||"Support Agent":o.name,a=e.assignee.kind==="human"?(n==null?void 0:n.avatarUrl)||e.assignee.avatarUrl||"":o.avatarUrl||o.avatar||"";return r.jsxs(G,{variant:"ghost",size:"lg",className:T("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(H.AnimatePresence,{mode:"wait",children:r.jsx(te,{snapExit:!0,children:r.jsxs(jr,{className:"size-10",children:[r.jsx(Cr,{src:a,alt:"Agent Icon"}),r.jsx(Sr,{children:r.jsx(z.UserRoundIcon,{className:"size-4"})})]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx(H.AnimatePresence,{mode:"wait",children:r.jsx(te,{snapExit:!0,children:i},i)}),r.jsx(H.AnimatePresence,{mode:"wait",children:e.lastMessage?r.jsx(te,{snapExit:!0,children:r.jsx(ia,{remarkPlugins:[hs],rehypePlugins:[Fn],className:"line-clamp-1 overflow-hidden text-ellipsis text-xs text-muted-foreground",children:e.lastMessage})},e.lastMessage||"content"):r.jsx(te,{className:"w-1/2",snapExit:!0,children:r.jsx(Zp,{className:"h-4 w-full"})},"skeleton")}),r.jsx(H.AnimatePresence,{mode:"wait",children:e.customStatus&&r.jsx(te,{className:"mt-1",snapExit:!0,children:r.jsx(Ea,{customStatus:e.customStatus})},e.customStatus.id)})]})]}),r.jsx(z.ChevronRightIcon,{className:"size-4 text-muted-foreground shrink-0 rtl:-scale-100"})]})}function em(){const{t:e}=ee(),{toChatScreen:t}=C.useWidgetRouter(),{sessionsState:{data:n,isInitialFetchLoading:o},openSessions:s,closedSessions:i,canCreateNewSession:a}=C.useSessions();return r.jsx("div",{...F("sessions/list"),className:"flex-1 flex flex-col overflow-scroll py-2 px-2",children:r.jsx(H.AnimatePresence,{mode:"wait",children:o?r.jsx(te,{className:"flex-1 flex items-center justify-center",children:r.jsx(wa,{})},"loading"):r.jsx(te,{className:"flex-1 flex flex-col gap-2 relative",children:n.length?r.jsxs(r.Fragment,{children:[r.jsxs(H.AnimatePresence,{children:[s.length>0&&r.jsx(te,{fadeIn:"up",delay:.2,className:"space-y-2",snapExit:!0,children:s.map(c=>r.jsx(qo,{session:c},c.id))},"open-sessions"),i.length>0&&r.jsxs(te,{className:"space-y-2",delay:.2,snapExit:!0,children:[r.jsx(Qp,{children:e("closed_conversations")}),i.map(c=>r.jsx(qo,{session:c,className:"opacity-50 hover:opacity-100"},c.id))]},"closed-sessions")]}),a&&r.jsx("div",{className:"mt-auto w-full rounded-3xl sticky bottom-0 outline outline-8 outline-background bg-background",children:u.createElement(G,{...F("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(G,{...F("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full",onClick:()=>t()},e("new_conversation"))]})},"sessions")})})}function tm(){const{theme:e}=fe();return _r({width:e.screens.sessions.width,height:e.screens.sessions.height}),r.jsx("div",{...F("sessions/root"),className:T("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(Kp,{children:r.jsx(em,{})}),r.jsx(ei,{})]})})}const an=Ke.forwardRef(({className:e,type:t,...n},o)=>{const{isSmallScreen:s}=Ae();return r.jsx("input",{ref:o,type:t,className:T(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})});an.displayName="Input";function nm(){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 i;const a=new ResizeObserver(()=>{i=requestAnimationFrame(()=>{const c=s.offsetHeight;o.style.setProperty("--opencx-widget-height",t?"100%":`${c.toFixed(1)}px`)})});return a.observe(s),()=>{cancelAnimationFrame(i),a.unobserve(s)}}},[e,t]),{observedElementRef:n}}const rm=v.z.object({name:v.z.string().min(2),email:v.z.string().email()});function om(){var x,S,b,N,j,g,_,A;const{widgetCtx:{org:e}}=C.useWidget(),{setIsOpen:t}=C.useWidgetTrigger(),{createUnverifiedContact:n}=C.useContact(),{isSmallScreen:o}=Ae(),s=C.useConfig(),{theme:i}=fe(),{t:a}=ee(),{observedElementRef:c}=nm();_r({height:void 0,width:i.screens.welcome.width});const[l,d]=u.useState(((x=s.prefillUserData)==null?void 0:x.name)||""),[p,m]=u.useState(((S=s.prefillUserData)==null?void 0:S.email)||""),h=(s.extraDataCollectionFields||[]).filter(R=>R!=="name"&&R!=="email"&&!!R),[f,y]=u.useState({}),[w,k]=Ei(async R=>{R.preventDefault();const P=rm.safeParse({name:l,email:p});P.success&&await n({email:P.data.email,non_verified_name:P.data.name},Object.values(f).filter(Boolean).length?f:void 0)},[l,p,f]);return r.jsx("div",{style:{width:"100vw",maxWidth:"100vw",minHeight:i.screens.welcome.minHeight,height:"100vh",maxHeight:"100vh",overflowY:"auto"},children:r.jsxs("div",{ref:c,className:T("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:T("flex-1 flex flex-col px-4 py-12 text-start space-y-4 relative z-10","text-primary-foreground"),children:[o&&r.jsx(te,{className:"absolute top-6 end-6",children:r.jsx(G,{size:"selfless",onClick:()=>t(!1),children:r.jsx(z.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:(N=s.assets)==null?void 0:N.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:((g=(j=s.textContent)==null?void 0:j.welcomeScreen)==null?void 0:g.title)||a("welcome_screen_title")}),r.jsx("p",{className:"text-sm",children:((A=(_=s.textContent)==null?void 0:_.welcomeScreen)==null?void 0:A.description)||a("welcome_screen_description")})]})]}),r.jsxs("div",{className:T("z-10 m-2 px-2 pt-2 bp-0 space-y-2","bg-[white]","border shadow","rounded-3xl"),children:[r.jsxs("form",{onSubmit:k,className:"space-y-2",children:[r.jsx(an,{value:l,onChange:R=>d(R.target.value),required:!0,placeholder:a("your_name_placeholder"),name:"name"}),r.jsx(an,{required:!0,value:p,onChange:R=>m(R.target.value),type:"email",placeholder:a("your_email_placeholder"),name:"email"}),h.map(R=>r.jsx(an,{value:f[R],onChange:P=>y(O=>({...O,[R]:P.target.value})),placeholder:`${R} (${a("optional")})`},R)),r.jsxs(G,{disabled:w.loading,className:"w-full",size:"lg",children:[w.loading?a("start_chat_button_loading"):a("start_chat_button"),r.jsx(z.SendHorizontal,{className:"size-4 rtl:-scale-100"})]})]}),r.jsx(ei,{})]})]})})}function Hr(){const{routerState:{screen:e}}=C.useWidgetRouter();return r.jsx("div",{className:"relative bg-background size-full",children:(()=>{switch(e){case"welcome":return r.jsx(te,{fadeIn:"right",className:"size-full",snapExit:!0,children:r.jsx(om,{})},e);case"sessions":return r.jsx(te,{fadeIn:"right",className:"size-full",snapExit:!0,children:r.jsx(tm,{})},e);case"chat":return r.jsx(te,{fadeIn:"right",className:"size-full",snapExit:!0,children:r.jsx(Gp,{})},e);default:return Q.isExhaustive(e,Hr.name),null}})()})}const sm=Nr(),am=()=>{};function ti(){const{isOpen:e}=C.useWidgetTrigger(),{contentIframeRef:t,widgetCtx:n}=C.useWidget(),{inline:o}=C.useConfig(),{theme:s,computed:i}=fe();return u.useEffect(()=>{e||n.dictationCtx.stop({executeFinalCommand:!1})},[e,n]),r.jsx(H.motion.div,{onUpdate:am,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:vt},visible:{opacity:1,scale:1,y:0,display:"block",height:o?"100%":void 0,transition:{...vt,height:{duration:0}}}},children:r.jsx(fs,{ref:t,initialContent:sm,allowFullScreen:!0,title:ma,style:{"--opencx-widget-width":i.minWidth,"--opencx-widget-height":i.minHeight,minWidth:i.minWidth,width:"var(--opencx-widget-width)",maxWidth:i.maxWidth,minHeight:i.minHeight,height:"var(--opencx-widget-height)",maxHeight:i.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.jsx(yn,{style:{zIndex:s.widgetContentContainer.zIndex},children:r.jsx(Hr,{})})})})}function im(){const{theme:e,triggerSide:t}=fe(),{dir:n}=C.useDocumentDir(),{t:o}=ee(),s=(n==="rtl"?t==="left":t==="right")?"end":"start";return r.jsx(Ye.Content,{onInteractOutside:i=>i.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(ti,{})})}function cm({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:T("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 ni(){var t;const{accessibility:e}=C.useConfig();return((t=e==null?void 0:e.widgetTriggerButton)==null?void 0:t.label)??"Chat with us"}function ri(e,t,n){return e({react:u,isOpen:t,setIsOpen:o=>n(o)})}const lm=Nr();function dm(){var a,c;const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger(),{assets:n,customComponents:o}=C.useConfig(),{theme:s}=fe(),i=ni();return o!=null&&o.widgetTrigger?ri(o.widgetTrigger,e,t):r.jsx(fs,{initialContent:lm,title:"OpenCX Live Chat Trigger",style:{height:`calc(${s.widgetTrigger.size.button}px + ${yt.x*2}px)`,width:`calc(${s.widgetTrigger.size.button}px + ${yt.y*2}px)`,fontSize:"16px",position:"fixed",zIndex:s.widgetTrigger.zIndex,right:s.widgetTrigger.offset.right,bottom:s.widgetTrigger.offset.bottom,left:s.widgetTrigger.offset.left,boxSizing:"border-box",borderWidth:"0px",borderRadius:"100%"},children:r.jsx(yn,{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsx(Ye.PopoverTrigger,{"aria-label":i,title:i,className:T("font-sans flex items-center justify-center rounded-full"),style:{height:s.widgetTrigger.size.button,width:s.widgetTrigger.size.button},children:r.jsx(Ie,{children:r.jsx("div",{...F("trigger/btn"),className:T("relative size-full rounded-full","flex items-center justify-center","overflow-hidden","transition-all","bg-primary","text-primary-foreground"),children:r.jsx(H.AnimatePresence,{mode:"wait",children:e?r.jsx(te,{snapExit:!0,fadeIn:"up",overrides:{initial:{rotate:45},animate:{rotate:0}},children:(a=n==null?void 0:n.widgetTrigger)!=null&&a.closeIcon?r.jsx("img",{src:n.widgetTrigger.closeIcon,alt:"Widget trigger close icon",style:{width:s.widgetTrigger.size.icon,height:s.widgetTrigger.size.icon}}):r.jsx(z.ChevronDownIcon,{style:{width:s.widgetTrigger.size.icon,height:s.widgetTrigger.size.icon}})},"x-icon"):r.jsx(te,{snapExit:!0,overrides:{initial:{rotate:45},animate:{rotate:0}},children:(c=n==null?void 0:n.widgetTrigger)!=null&&c.openIcon?r.jsx("img",{src:n.widgetTrigger.openIcon,alt:"Widget trigger open icon",style:{width:s.widgetTrigger.size.icon,height:s.widgetTrigger.size.icon}}):r.jsx(cm,{style:{width:s.widgetTrigger.size.icon,height:s.widgetTrigger.size.icon},className:"mt-0.5 opacity-95"})},"message-icon")})})})})})})}function um(){const{triggerSide:e}=fe();return r.jsx(Ye.Anchor,{style:{position:"fixed",bottom:0,right:e==="right"?0:void 0,left:e==="left"?0:void 0}})}const pm="[data-opencx-escape-scope]";function mm(e){var n;const t=e.target;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,pm))!=null}function hm(e,{state:t,onToggleFullscreen:n}){e.defaultPrevented||t!=="chat"||it(e,Me["toggle-fullscreen"])&&(e.preventDefault(),n())}function oi(e,{state:t,onDismiss:n,onToggleFullscreen:o}){if(!e.defaultPrevented){if(it(e,Me["close-panel"])){mm(e)||n();return}t==="chat"&&it(e,Me["toggle-fullscreen"])&&(e.preventDefault(),o())}}function fm({panelLayout:e,previousLayout:t,defaultLayout:n,allowedLayouts:o}){if(e!=="fullscreen")return{kind:"close"};const s=[t,n];for(const a of s)if(a!=="fullscreen"&&o.includes(a))return{kind:"layout",layout:a};const i=o.find(a=>a!=="fullscreen");return i?{kind:"layout",layout:i}:{kind:"close"}}function gm({onHeightChange:e,maxHeight:t,onDismiss:n,onToggleFullscreen:o}){const s=u.useRef(null);return u.useLayoutEffect(()=>{var d;const i=s.current;if(!i)return;const a=()=>e(i.offsetHeight);a();const c=(d=i.ownerDocument.defaultView)==null?void 0:d.ResizeObserver;if(!c)return;const l=new c(a);return l.observe(i),()=>l.disconnect()},[e,t]),r.jsx(yn,{children:r.jsx("div",{ref:s,onKeyDown:i=>oi(i.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(xm,{})})})}function xm(){const{initialQuestions:e}=C.useConfig(),t=H.useReducedMotion();return r.jsx(r.Fragment,{children:e==null?void 0:e.filter(n=>n.trim().length>0).map((n,o)=>r.jsx(H.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:St},children:r.jsx(kn,{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 si=new WeakSet;function bm(e){return si.has(e)}function Vo(e,t=()=>!0){var m;let n=!1;const o=h=>h?"completed":n?"interrupted":"not-started",s=e.getBoundingClientRect(),i=s.left+s.width/2,a=s.top+s.height/2,c={bubbles:!0,cancelable:!0,composed:!0,clientX:i,clientY:a},l=h=>t()?(n=!0,si.add(h),e.dispatchEvent(h),!0):!1,d=h=>l(new PointerEvent(h,{...c,pointerId:1,pointerType:"mouse",isPrimary:!0})),p=(h,f=0)=>l(new MouseEvent(h,{...c,detail:f,button:0,buttons:1}));return!d("pointerover")||!d("pointerenter")||!p("mouseover")||!p("mousemove")||!d("pointerdown")||!p("mousedown",1)||!t()?o(!1):((m=e.focus)==null||m.call(e),o(d("pointerup")&&p("mouseup",1)&&p("click",1)))}const Br=u.forwardRef(function({label:t,className:n,...o},s){return r.jsx("button",{ref:s,type:"button","aria-label":t,...o,className:T("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 tt(e,t,n){return Math.min(Math.max(e,t),n)}const lr=16,Ne=16,It=32,wm=44,ym=240,vm=440,ai=32,km=280,jm=420,Cm=640,Sm=48,Pn=12,Ur=400,ii=320,Nm=560,_m="#f4f4f5",ci=120,li=ii+ci+Ne*3,Xe={pill:999,input:16,fullscreen:16,sidebar:20,compact:20};function qr(e,t){if(e.width<=li)return Math.max(0,e.width-Ne*2);const n=e.width-ci-Ne*3;return Math.max(0,Math.min(t,n))}function bt(e,t,n=0){return typeof e=="number"&&Number.isFinite(e)?Math.max(n,e):t}function di(e,t={}){const n=Math.max(0,e.width),o=bt(t.maxWidth,vm),s=Math.min(o,bt(t.minWidth,km));return Math.min(n,o,Math.max(s,n-ai))}function Em(e,t,n={}){const o=Math.max(0,e.height),s=bt(n.minHeight,jm),i=bt(n.maxHeight,Cm,s),a=Math.min(1,bt(n.viewportHeightRatio,.65)),c=Math.max(0,o-Math.max(0,t)-Sm);return Math.min(i,c,Math.max(s,o*a))}function Tm(e){const{layout:t,region:n,sidebarWidth:o,bottomOffset:s,compact:i}=e;return t==="fullscreen"?{width:Math.max(0,n.width-lr*2),height:Math.max(0,n.height-lr*2),borderRadius:Xe.fullscreen}:t==="sidebar"?{width:qr(n,o),height:Math.max(0,n.height-Ne*2),borderRadius:Xe.sidebar}:{width:di(n,i),height:Em(n,s,i),borderRadius:bt(i==null?void 0:i.borderRadius,Xe.compact)}}function Am(e){const{isChatOpen:t,layout:n,region:o,sidebarWidth:s,sidebarSide:i,bottomOffset:a}=e,c=t?n:"compact",l=qr(o,s),d=c==="fullscreen"?lr:c==="sidebar"?Ne:a;return{centerX:c==="sidebar"?i==="left"?Ne+l/2:o.width-Ne-l/2:o.width/2,bottom:d}}const ue="[data-companion-root]",zm=`
130
+ ${ue} [data-component="chat/msgs/root"] {
131
+ overflow-x: hidden !important;
132
+ }
133
+ ${ue} [data-component="chat/agent_msg_group/root"],
134
+ ${ue} [data-component="chat/agent_msg_group/avatar_and_msgs/root"],
135
+ ${ue} [data-component="chat/agent_msg_group/avatar_and_msgs/msgs"] {
136
+ min-width: 0 !important;
137
+ max-width: 100% !important;
138
+ }
139
+ ${ue} [data-component="chat/agent_msg/msg"] {
140
+ background: transparent !important;
141
+ padding: 2px 0 !important;
142
+ border-radius: 0 !important;
143
+ max-width: 100% !important;
144
+ min-width: 0 !important;
145
+ overflow-wrap: break-word !important;
146
+ }
147
+ ${ue} [data-component="chat/agent_msg/msg"] table {
148
+ display: block;
149
+ max-width: 100%;
150
+ overflow-x: auto;
151
+ border-collapse: collapse;
152
+ }
153
+ ${ue} [data-component="chat/agent_msg/msg"] th,
154
+ ${ue} [data-component="chat/agent_msg/msg"] td {
155
+ overflow-wrap: normal;
156
+ word-break: normal;
157
+ white-space: normal;
158
+ vertical-align: top;
159
+ text-align: start;
160
+ padding: 4px 10px 4px 0;
161
+ border-bottom: 1px solid hsl(var(--opencx-border));
162
+ }
163
+ ${ue} [data-component="chat/user_msg/msg"] {
164
+ background: hsl(var(--opencx-secondary)) !important;
165
+ color: hsl(var(--opencx-secondary-foreground)) !important;
166
+ padding: 8px 12px !important;
167
+ border-radius: 10px !important;
168
+ }
169
+ `,Im=`
170
+ ${ue} [data-component="chat/agent_msg_group/root/avatar"],
171
+ ${ue} [data-component="chat/agent_msg_group/avatar_and_msgs/avatar"] {
172
+ display: none !important;
173
+ }
174
+ `,Mm=`
175
+ ${ue} [data-component="chat/agent_msg_group/avatar_and_msgs/root"] {
176
+ align-items: flex-start !important;
177
+ }
178
+ ${ue} [data-component="chat/agent_msg_group/avatar_and_msgs/avatar"] {
179
+ width: 20px !important;
180
+ height: 20px !important;
181
+ margin-top: 2px !important;
182
+ }
183
+ /* Steps, rendered blocks, the working spinner and the actions row are siblings
184
+ of the text groups in a streamed turn: indent them by the avatar gutter
185
+ (20px avatar + 8px gap) so everything shares the text's left edge. The
186
+ typing row carries its own avatar, so it keeps the gutter instead — indenting
187
+ it would jump the avatar sideways when the reply replaces it. */
188
+ ${ue} [data-component="chat/streaming_turn/root"] > :not([data-component="chat/agent_msg_group/root"]):not([data-component="chat/bot_loading/root"]) {
189
+ margin-inline-start: 28px !important;
190
+ }
191
+ ${ue} [data-component="chat/bot_loading/root"] {
192
+ align-items: flex-start !important;
193
+ }
194
+ /* Its avatar is the row's first child (LoadingDefaultComponent renders no
195
+ data-component on it), sized to match a reply's. */
196
+ ${ue} [data-component="chat/bot_loading/root"] > :first-child {
197
+ width: 20px !important;
198
+ height: 20px !important;
199
+ margin-top: 2px !important;
200
+ }
201
+ `;function Yo({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 Rm({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 Pm({anchored:e,side:t,onSelectSide:n,docked:o,onToggleDock:s}){const{t:i}=ee();return r.jsx(H.motion.div,{...F("companion/layout_picker/sidebar_options"),initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.18,ease:St},style:e?{left:"50%",x:"-50%"}:void 0,className:T("origin-top",e&&"absolute top-full z-10 pt-3"),children:r.jsxs("div",{className:T("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(Xo,{label:i("companion_sidebar_dock_label"),children:r.jsx(Om,{label:i("companion_sidebar_dock_label"),checked:o,onToggle:s})}),r.jsx(Xo,{label:i("companion_sidebar_side_label"),children:r.jsx($m,{label:i("companion_sidebar_side_label"),side:t,onSelect:n})})]})})}function Xo({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 Om({label:e,checked:t,onToggle:n}){return r.jsx("button",{...F("companion/layout_picker/sidebar_option"),type:"button",role:"switch","aria-checked":t,"aria-label":e,onClick:n,className:T("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(H.motion.span,{"aria-hidden":!0,initial:!1,animate:{x:t?12:0},transition:vt,className:"size-3 rounded-full bg-background shadow-sm"})})}function $m({label:e,side:t,onSelect:n}){const{t:o}=ee(),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:i,labelKey:a})=>{const c=i===t;return r.jsxs("button",{...F("companion/layout_picker/sidebar_option"),type:"button",role:"radio","aria-checked":c,"aria-label":o(a),onClick:()=>n(i),className:T("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(H.motion.span,{"aria-hidden":!0,layoutId:"opencx-sidebar-side-indicator",transition:vt,className:"absolute inset-0 rounded-full bg-background shadow-sm"}),r.jsx("span",{className:"relative",children:r.jsx(Rm,{side:i})})]},i)})})}const Lm={compact:"companion_layout_floating",sidebar:"companion_layout_sidebar",fullscreen:"companion_layout_fullscreen"};function Dm(e){try{return e.matches(":focus-visible")}catch{return!0}}function Fm({current:e,onSelect:t}){const{t:n}=ee(),{allowedLayouts:o,sidebarSide:s,setSidebarSide:i,sidebarMode:a,setSidebarMode:c}=C.useWidgetLayout(),[l,d]=u.useState(!1),p=gn(),m=o.map(x=>({layout:x,label:Lm[x]})),h=m.length>=2,f=o.includes("sidebar");if(!h&&!f)return null;const y=f&&(h?p?l:e==="sidebar":!0),w=x=>{x(),e!=="sidebar"&&t("sidebar")},k=r.jsx(H.AnimatePresence,{initial:!1,children:y&&r.jsx(Pm,{anchored:h,side:s,onSelectSide:x=>w(()=>i(x)),docked:a==="docked",onToggleDock:()=>w(()=>c(a==="docked"?"floating":"docked"))})});return r.jsxs(Ye.Root,{onOpenChange:()=>d(!1),children:[r.jsx(_e,{content:n("companion_layout_label"),side:"bottom",children:r.jsx(Ye.Trigger,{asChild:!0,children:r.jsx(Br,{...F("companion/layout_picker/trigger"),label:n("companion_layout_label"),className:"size-7",children:r.jsx(Yo,{layout:e,sidebarSide:s})})})}),r.jsx(Ye.Content,{...F("companion/layout_picker/menu"),"data-opencx-escape-scope":"",side:"bottom",align:"end",sideOffset:6,collisionPadding:8,onPointerLeave:()=>d(!1),style:{"--pk-r":"16px","--pk-p":"6px"},className:T("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:m.map(({layout:x,label:S})=>{const b=x===e,N=n(S),j=x==="sidebar",g=r.jsx(Ye.Close,{asChild:!0,children:r.jsxs("button",{...F("companion/layout_picker/option"),type:"button","aria-label":N,"aria-pressed":b,"aria-expanded":j?y:void 0,onClick:()=>t(x),onPointerEnter:()=>d(j),onFocus:_=>d(j&&Dm(_.currentTarget)),className:T("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(Yo,{layout:x,sidebarSide:s}),r.jsx("span",{className:"whitespace-nowrap text-[10px] font-medium leading-none",children:N})]})});return j?r.jsxs("div",{className:"relative flex",children:[g,k]},x):x!=="fullscreen"?r.jsx(u.Fragment,{children:g},x):r.jsx(_e,{content:N,shortcut:Fr(Me["toggle-fullscreen"]),side:"bottom",children:g},x)})}):k})]})}function Wm({layout:e,onSelectLayout:t,onClose:n}){const{t:o}=ee();return r.jsxs("div",{...F("companion/controls/root"),className:"absolute top-2 z-10 flex items-center gap-1",style:{insetInlineEnd:8},children:[r.jsx(Fm,{current:e,onSelect:t}),r.jsx(_e,{content:o("companion_close"),shortcut:Fr(Me["close-panel"]),side:"bottom",children:r.jsx(Br,{...F("companion/close_btn"),label:o("companion_close"),onClick:n,className:"size-7",children:r.jsx(z.XIcon,{className:"size-4"})})})]})}const Hm=`
202
+ /* Quick-ask (resting) composer: the stock card is a two-row layout (textarea
203
+ over an attach/send row) wrapped in outer padding. In the companion pill it
204
+ reads as a single quick-ask bar, so drop the outer pad and lay the card out
205
+ on ONE row — textarea flex-fills, attach + send sit inline at the end.
206
+ Scoped to the quick-ask pane only; the full chat panel keeps the stock
207
+ two-row composer. */
208
+ [data-companion-input] [data-component="chat/input_box/root"] {
209
+ padding: 0 !important;
210
+ }
211
+ /* The attached-context tray is a FULL-composer affordance. In the one-row
212
+ quick-ask bar it stacks a second row and paints a second surface inside the
213
+ shell — a grey box with its own padding and radius sitting inside the white
214
+ pill, which is not what the resting bar is. Flatten the tray to a pure
215
+ pass-through here and hide its row; the entity still rides the send, and
216
+ the full chat panel (one rung up) is where you see and remove it. */
217
+ [data-companion-input] [data-component="chat/input_box/attached_context_tray"] {
218
+ padding: 0 !important;
219
+ background: transparent !important;
220
+ /* The root's space-y-1 puts a 4px top margin on the tray (its first sibling
221
+ is the hidden dropzone input); with the outer padding gone that margin
222
+ shows as a strip of shell background above the bar. */
223
+ margin-top: 0 !important;
224
+ }
225
+ [data-companion-input]
226
+ [data-component="chat/input_box/attached_context_tray"]
227
+ > *:not([data-component="chat/input_box/inner_root"]) {
228
+ display: none !important;
229
+ }
230
+ [data-companion-input] [data-component="chat/input_box/inner_root"] {
231
+ flex-direction: row !important;
232
+ align-items: center !important;
233
+ margin-top: 0 !important;
234
+ /* The stock card is rounded-3xl (24px), but the companion shell that frames
235
+ it clips at RADII.input in the resting-input state. A mismatch leaves the
236
+ shell's background token peeking out as a two-tone crescent at each
237
+ corner, so the card takes the shell radius via the custom property set on
238
+ the quick-ask pane — one clean rounded bar. */
239
+ border-radius: var(--opencx-companion-input-radius) !important;
240
+ }
241
+ [data-companion-input] [data-component="chat/input_box/textarea_and_attachments_container"] {
242
+ flex: 1 1 auto !important;
243
+ min-width: 0 !important;
244
+ }
245
+
246
+ /* Fullscreen reading column: the panel is a full-width window, but message
247
+ text across a 1900px panel wraps at ~200 characters. Cap the conversation
248
+ and composer to one centered column; the header and corner controls stay
249
+ full-width window chrome. The messages keep the cap as PADDING on the
250
+ scroll container so the scrollbar stays at the panel edge; the footer gets
251
+ a real max-width (+16px compensates the input card's own p-2) so the
252
+ composer card's edges land exactly on the message column's edges. */
253
+ [data-companion-root][data-layout="fullscreen"] [data-component="chat/msgs/root"] {
254
+ padding-inline: max(16px, calc((100% - var(--opencx-companion-content-max-width)) / 2)) !important;
255
+ }
256
+ [data-companion-root][data-layout="fullscreen"] [data-component="chat/main/root"] > footer {
257
+ width: 100%;
258
+ max-width: calc(var(--opencx-companion-content-max-width) + 16px);
259
+ margin-inline: auto;
260
+ }
261
+
262
+ /* Sessions (conversation history) gets the same reading column: cards and the
263
+ sticky new-conversation button stretch edge-to-edge otherwise. Padding (not
264
+ max-width) for the same reason as the messages — the list IS the scroll
265
+ container, so the scrollbar stays at the panel edge. */
266
+ [data-companion-root][data-layout="fullscreen"] [data-component="sessions/list"] {
267
+ padding-inline: max(16px, calc((100% - var(--opencx-companion-content-max-width)) / 2)) !important;
268
+ }
269
+ `;function Bm({state:e,layout:t,shellRadius:n,onMinimize:o,onDismiss:s,onToggleFullscreen:i,onSelectLayout:a,onExpand:c,canExpand:l,placeholder:d,hideAttachTools:p,onInputHeightChange:m}){const{companion:h}=C.useConfig(),f=Oa(),{t:y}=ee(),w=u.useRef(null),k=u.useRef(null),x=u.useRef(null),S=(h==null?void 0:h.bubbles)===!0,b=(h==null?void 0:h.avatars)??S,N=Hm+(S?"":zm)+(b?"":Im)+(b&&!S?Mm:"");return u.useEffect(()=>{var _;const j=(_=w.current)==null?void 0:_.ownerDocument;if(!j)return;function g(A){oi(A,{state:e,onDismiss:s,onToggleFullscreen:i})}return j.addEventListener("keydown",g),()=>j.removeEventListener("keydown",g)},[s,i,e]),u.useLayoutEffect(()=>{var R;if(e!=="input")return;const j=k.current,g=(R=j==null?void 0:j.ownerDocument.defaultView)==null?void 0:R.ResizeObserver;if(!j||!g)return;const _=()=>m(j.offsetHeight);_();const A=new g(_);return A.observe(j),()=>A.disconnect()},[e,m]),u.useLayoutEffect(()=>{e!=="input"||l||f||On(k.current)},[e,l,f]),u.useLayoutEffect(()=>{var _;if(e!=="chat"||On(x.current))return;const j=(_=x.current)==null?void 0:_.ownerDocument.defaultView;if(!j)return;const g=j.requestAnimationFrame(()=>On(x.current));return()=>j.cancelAnimationFrame(g)},[e]),r.jsx(yn,{overrides:N,rootRef:w,shellRadius:`${n}px`,children:e==="input"?r.jsxs("div",{ref:k,"data-companion-input":!0,style:{position:"absolute",left:0,right:0,bottom:0,"--opencx-companion-input-radius":`${Xe.input}px`},children:[r.jsxs("div",{className:"relative",children:[r.jsx(wd,{children:r.jsx(Qa,{disabled:f,hideAttachTools:p,placeholder:d,trailingActions:f?r.jsx(Br,{label:y("companion_close"),onClick:s,className:"size-8",children:r.jsx(z.XIcon,{className:"size-4"})}):void 0})}),l?r.jsx("button",{type:"button","aria-label":y("companion_expand_chat"),onClick:c,className:"absolute inset-0 z-10 cursor-pointer"}):null]}),r.jsx(rr,{})]}):r.jsxs("div",{ref:x,"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(Hr,{}),r.jsx(Wm,{layout:t,onSelectLayout:a,onClose:o})]})})}function On(e){const t=e==null?void 0:e.querySelector("textarea");return t?(t.focus({preventScroll:!0}),!0):!1}function Go({initialContent:e,title:t=ma,style:n,iframeRef:o,children:s}){const[i,a]=u.useState(null),c=u.useCallback(l=>{if(o&&(o.current=l),!l)return;const d=l.contentDocument;d&&(d.open(),d.write(e),d.close(),a(d.body))},[]);return r.jsxs(r.Fragment,{children:[r.jsx("iframe",{ref:c,title:t,style:n,allowFullScreen:!0}),i&&Dt.createPortal(s,i)]})}function Um({size:e,headColor:t,eyeColor:n}){const o=u.useRef(null),[s,i]=u.useState(!1),[a,c]=u.useState(!1),l=H.useReducedMotion(),d=H.useMotionValue(0),p=H.useMotionValue(0),m=H.useSpring(d,{stiffness:300,damping:30}),h=H.useSpring(p,{stiffness:300,damping:30}),f=H.useTransform(m,b=>8+b*1.2),y=H.useTransform(h,b=>11.5+b*1.2),w=H.useTransform(m,b=>16+b*1.2),k=H.useTransform(h,b=>11.5+b*1.2),x=u.useCallback(b=>{const N=o.current;if(!N)return;const j=N.getBoundingClientRect(),g=j.left+j.width/2,_=j.top+j.height/2,A=(b.clientX-g)/(j.width*2),R=(b.clientY-_)/(j.height*2),P=Math.min(Math.sqrt(A*A+R*R),1),O=Math.atan2(R,A);d.set(Math.cos(O)*P),p.set(Math.sin(O)*P)},[d,p]);u.useEffect(()=>(s&&!l?window.addEventListener("mousemove",x):(d.set(0),p.set(0)),()=>window.removeEventListener("mousemove",x)),[s,x,d,p,l]),u.useEffect(()=>{if(l)return;let b,N;function j(){clearTimeout(b),clearTimeout(N)}function g(){b=setTimeout(()=>{c(!0),N=setTimeout(()=>c(!1),150),g()},1200+Math.random()*1800)}function _(){j(),document.visibilityState==="visible"&&g()}return document.visibilityState==="visible"&&g(),document.addEventListener("visibilitychange",_),()=>{j(),document.removeEventListener("visibilitychange",_)}},[l]);const S=a?.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:()=>i(!0),onMouseLeave:()=>i(!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(H.motion.circle,{cx:f,cy:y,r:1.4,fill:t,animate:{scaleY:S},style:{originX:"8px",originY:"11.5px"},transition:{duration:.08}}),r.jsx(H.motion.circle,{cx:w,cy:k,r:1.4,fill:t,animate:{scaleY:S},style:{originX:"16px",originY:"11.5px"},transition:{duration:.08}})]})}function qm({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(Um,{size:n,headColor:t,eyeColor:"hsl(var(--opencx-primary-foreground))"})}function Vm(e){return{initial:!1,animate:{opacity:e?1:0},transition:{...xe,delay:e?.25:0}}}function Ym({visible:e,docked:t,label:n,icon:o,pillBackground:s,dir:i,measureRef:a,activeCount:c=0,countLabel:l,onOpenChats:d,pickerOpen:p=!1,working:m=!1,sessions:h}){const f=H.useReducedMotion();return r.jsxs(H.motion.div,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",borderRadius:"inherit",overflow:"hidden",pointerEvents:"none",userSelect:"none",background:"hsl(var(--opencx-background))"},...Vm(e),children:[e&&!t&&c>0&&r.jsx("button",{type:"button","data-companion-count-trigger":"","aria-label":l,"aria-haspopup":"menu","aria-expanded":p,onClick:y=>{y.stopPropagation(),d==null||d(y.currentTarget,y.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,m&&r.jsx(H.motion.span,{style:{position:"absolute",inset:-2,display:"flex"},animate:f?void 0:{rotate:360},transition:{duration:1.2,repeat:1/0,ease:"linear"},children:r.jsx(z.LoaderCircleIcon,{size:18})})]})}),r.jsxs("div",{ref:a,dir:i,style:{display:"flex",alignItems:"center",gap:8,height:"100%",width:"max-content",paddingInlineEnd:12,fontFamily:"ui-sans-serif, system-ui, sans-serif"},children:[r.jsx(qm,{icon:o,pillBackground:s,size:It}),r.jsx(H.motion.span,{initial:!1,animate:{opacity:t?1:0},transition:{duration:.12,ease:St},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 Xm({chat:e,number:t,selected:n,interactive:o,onSelect:s,onClose:i,portalTarget:a}){const{t:c}=ee(),{cssVars:l,theme:d}=fe(),[p,m]=u.useState(!1);u.useEffect(()=>{o||m(!1)},[o]);const{title:h}=Er(e),f=`${h}${e.working?` — ${c("thinking")}`:""}`;function y(k){return a&&r.jsx(Se.Portal,{container:a,children:r.jsxs(Se.Content,{side:"top",sideOffset:8,collisionPadding:12,"data-companion-session-tooltip":"",style:{...l,zIndex:d.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:[k,r.jsx(Se.Arrow,{width:8,height:4,style:{fill:"hsl(var(--opencx-foreground))"}})]})})}const w=c("companion_close_chat",{title:h});return r.jsxs("div",{"data-session-item":"",children:[r.jsxs(Se.Root,{open:o&&p,onOpenChange:m,children:[r.jsx(Se.Trigger,{asChild:!0,children:r.jsxs(G,{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:k=>{k.stopPropagation(),s()},children:[e.working&&r.jsx(z.LoaderCircleIcon,{size:28,"aria-hidden":!0,"data-session-working":""}),r.jsx("span",{"aria-hidden":!0,children:t})]})}),y(f)]}),r.jsx(G,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","data-session-close":e.id,"aria-label":w,tabIndex:o?0:-1,onClick:k=>{k.stopPropagation(),m(!1),i(k.currentTarget)},children:r.jsx(z.XIcon,{size:10,"aria-hidden":!0})})]})}function Gm({onSelected:e=()=>{},onLastClosed:t=()=>{},interactive:n=!0}){const{openChats:o,activeId:s,selectChat:i,newChat:a,closeChat:c}=C.useCompanionChats(),{canCreateNewSession:l}=C.useSessions(),{isSmallScreen:d}=Ae(),{t:p,dir:m}=ee(),h=Tr(),f=vn(),y=d?2:3,w=o.slice(0,o.length>y?y-1:y),k=o.find(g=>g.id===s);k&&!w.includes(k)&&(w[w.length-1]=k);const x=o.length-w.length,S=o.some(g=>g.working&&!w.includes(g)),b=u.useRef(h.close);b.current=h.close,u.useEffect(()=>{n||b.current(!0)},[n]);function N(g){h.close(!0),g===void 0?a():i(g),e()}function j(g,_){var P,O;h.close(!0);const A=w.findIndex(I=>I.id===g),R=w[A+1]??w[A-1];(O=(P=_.closest("[data-companion-session-circles]"))==null?void 0:P.querySelector(R?`[data-session-circle="${R.id}"]`:"[data-new-session]"))==null||O.focus({preventScroll:!0}),c(g),o.length===1&&t()}return r.jsx(Se.Provider,{delayDuration:150,skipDelayDuration:300,children:r.jsxs("div",{role:"group","aria-label":p("companion_active_chats",{count:o.length}),"aria-hidden":!n||void 0,"data-companion-session-circles":"",dir:m,onPointerDown:g=>g.stopPropagation(),style:{position:"relative",zIndex:0,display:"flex",alignItems:"center",gap:4,flexShrink:0,pointerEvents:n?"auto":"none"},children:[r.jsx(Ar,{}),r.jsx("style",{children:`
270
+ [data-companion-session-tooltip][data-state="delayed-open"] { animation: opencx-session-tooltip-in 120ms ease-out; }
271
+ @keyframes opencx-session-tooltip-in { from { opacity: 0; } to { opacity: 1; } }
272
+ @media (prefers-reduced-motion: reduce) { [data-companion-session-tooltip] { animation: none !important; } }
273
+ [data-companion-session-circles] > button,
274
+ [data-companion-session-circles] [data-session-circle] {
275
+ position: relative; display: grid; place-items: center; flex: 0 0 28px;
276
+ width: 28px; height: 28px; padding: 0; border-radius: 50%;
277
+ border: 1px solid hsl(var(--opencx-border));
278
+ background: transparent; color: hsl(var(--opencx-muted-foreground));
279
+ font: 11px ui-sans-serif, system-ui, sans-serif; font-variant-numeric: tabular-nums;
280
+ cursor: pointer;
281
+ }
282
+ [data-companion-session-circles] [data-session-circle][aria-pressed="true"] {
283
+ border-color: hsl(var(--opencx-primary) / .45);
284
+ background: hsl(var(--opencx-primary) / .08);
285
+ color: hsl(var(--opencx-foreground));
286
+ }
287
+ @media (hover: hover) and (pointer: fine) {
288
+ [data-companion-session-circles] > button:hover,
289
+ [data-companion-session-circles] [data-session-item]:hover [data-session-circle] { background: hsl(var(--opencx-muted)); color: hsl(var(--opencx-foreground)); }
290
+ }
291
+ [data-companion-session-circles] button:focus-visible { outline: 2px solid hsl(var(--opencx-ring)); outline-offset: 2px; }
292
+ [data-companion-session-circles] > button:disabled { opacity: .4; cursor: default; }
293
+ [data-companion-session-circles] [data-session-item] { position: relative; display: flex; align-items: center; width: 36px; height: 32px; flex-shrink: 0; }
294
+ [data-companion-session-circles] [data-session-close] {
295
+ position: absolute; inset-inline-end: 0; top: -1px; z-index: 1;
296
+ width: 16px; height: 16px; display: grid; place-items: center; padding: 0;
297
+ border: 1px solid hsl(var(--opencx-border) / .7); border-radius: 50%;
298
+ background: hsl(var(--opencx-background)); color: hsl(var(--opencx-muted-foreground)); cursor: pointer;
299
+ }
300
+ @media (hover: hover) and (pointer: fine) {
301
+ [data-companion-session-circles] [data-session-close] { opacity: 0; pointer-events: none; }
302
+ [data-companion-session-circles] [data-session-item]:hover [data-session-close],
303
+ [data-companion-session-circles] [data-session-item]:focus-within [data-session-close] { opacity: 1; pointer-events: auto; }
304
+ [data-companion-session-circles] [data-session-close]:hover { color: hsl(var(--opencx-foreground)); }
305
+ }
306
+ @media (pointer: coarse) {
307
+ [data-companion-session-circles] [data-session-item] { width: 42px; }
308
+ [data-companion-session-circles] [data-session-close] { width: 24px; height: 24px; top: -3px; }
309
+ [data-companion-session-circles] [data-session-close] svg { width: 12px; height: 12px; }
310
+ }
311
+ [data-companion-session-circles] > button[data-new-session] { border-style: dashed; }
312
+ [data-companion-session-circles] [data-session-working] {
313
+ position: absolute; inset: -1px; color: hsl(var(--opencx-primary));
314
+ animation: opencx-session-spin 1.2s linear infinite;
315
+ }
316
+ @keyframes opencx-session-spin { to { transform: rotate(360deg); } }
317
+ @media (prefers-reduced-motion: reduce) { [data-companion-session-circles] [data-session-working] { animation: none; } }
318
+ `}),w.map(g=>r.jsx(Xm,{chat:g,number:g.id,selected:g.id===s,interactive:n,portalTarget:f,onSelect:()=>N(g.id),onClose:_=>j(g.id,_)},g.id)),x>0&&r.jsxs(G,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","aria-label":p("companion_chats"),"aria-haspopup":"menu","aria-expanded":h.open,tabIndex:n?0:-1,onPointerEnter:g=>h.hover(g.currentTarget),onPointerLeave:h.leave,onClick:g=>{g.stopPropagation(),h.toggle(g.currentTarget,g.detail>0)},children:[S&&r.jsx(z.LoaderCircleIcon,{size:28,"aria-hidden":!0,"data-session-working":""}),r.jsxs("span",{"aria-hidden":!0,children:["+",x]})]}),r.jsx(G,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","data-new-session":"","aria-label":p("new_conversation"),disabled:!l,tabIndex:n?0:-1,onClick:g=>{g.stopPropagation(),N()},children:r.jsx(z.PlusIcon,{size:14,"aria-hidden":!0})}),h.anchor&&f&&r.jsx(zr,{picker:h,portalTarget:f,placement:"above",onSelected:e})]})})}function Km({panelOpen:e,isOpen:t,setIsOpen:n,onOpen:o,onClose:s}){const i=u.useRef(t),a=u.useRef({onOpen:o,onClose:s});a.current={onOpen:o,onClose:s},u.useEffect(()=>{i.current=e,n(e)},[e,n]),u.useEffect(()=>{t!==i.current&&(i.current=t,t?a.current.onOpen():a.current.onClose())},[t])}const rt="data-opencx-app-frame",Zm="data-opencx-app-frame-style",$t="data-opencx-sidebar-open",hn="data-opencx-frame-no-anim",Lt="data-opencx-fixed-fit",Vr="--opencx-sidebar-w",ft=Dl;let Ge=null,xt=null,Ko=0;const Mt=new Map,Zo={setOpen:()=>{},setWidth:()=>{},setAnimated:()=>{},release:()=>{}};function Jm(){let e,t;return Mt.forEach(n=>{(!e||n.order>e.order)&&(e=n),n.open&&(!t||n.order>t.order)&&(t=n)}),t??e}function $n(){const e=Jm();if(!e||!Ge)return;Ge.textContent=Qm(e.canvas,e.side,e.pageBackground);const t=document.documentElement;e.open?t.setAttribute($t,""):t.removeAttribute($t),e.animated?t.removeAttribute(hn):t.setAttribute(hn,""),t.style.setProperty(Vr,`${e.width}px`)}function Jo(e){getComputedStyle(e).position==="fixed"&&e.setAttribute(Lt,"");for(const t of Array.from(e.querySelectorAll("*")))getComputedStyle(t).position==="fixed"&&t.setAttribute(Lt,"")}function Qm(e,t,n){const[o,s]=t==="left"?["right","left"]:["left","right"];return`
319
+ html[${rt}] {
320
+ overflow: hidden !important;
321
+ background: ${e} !important;
322
+ }
323
+ html[${rt}] body {
324
+ position: fixed !important;
325
+ inset: 0 !important;
326
+ margin: 0 !important;
327
+ width: auto !important;
328
+ height: auto !important;
329
+ min-width: 0 !important;
330
+ min-height: 0 !important;
331
+ max-width: none !important;
332
+ max-height: none !important;
333
+ overflow: auto !important;
334
+ contain: strict !important;
335
+ background: ${n} !important;
336
+ border-radius: 0 !important;
337
+ /* Transparent ring+shadow, NOT none — none can't interpolate */
338
+ box-shadow: 0 0 0 1px rgba(0,0,0,0), 0 10px 24px -6px rgba(0,0,0,0) !important;
339
+ }
340
+ @media (prefers-reduced-motion: no-preference) {
341
+ html[${rt}] body {
342
+ transition:
343
+ top 0.3s ${ft}, bottom 0.3s ${ft},
344
+ left 0.3s ${ft}, right 0.3s ${ft},
345
+ border-radius 0.3s ${ft}, box-shadow 0.3s ${ft} !important;
346
+ }
347
+ }
348
+ html[${hn}] body { transition: none !important; }
349
+ html[${rt}] body [${Lt}] {
350
+ max-width: 100% !important;
351
+ max-height: 100% !important;
352
+ }
353
+ html[${$t}] body {
354
+ top: ${Ne}px !important;
355
+ bottom: ${Ne}px !important;
356
+ ${o}: ${Ne}px !important;
357
+ ${s}: calc(var(${Vr}, ${Ur}px) + ${Ne*2}px) !important;
358
+ border-radius: ${Xe.sidebar}px !important;
359
+ box-shadow: 0 0 0 1px rgba(0,0,0,0.06), 0 10px 24px -6px rgba(0,0,0,0.10) !important;
360
+ }
361
+ @media (max-width: ${li}px) {
362
+ html[${$t}] body {
363
+ inset: 0 !important;
364
+ border-radius: 0 !important;
365
+ box-shadow: 0 0 0 1px rgba(0,0,0,0), 0 10px 24px -6px rgba(0,0,0,0) !important;
366
+ }
367
+ }
368
+ `}function eh({canvas:e,side:t,pageBackground:n}){if(typeof document>"u")return Zo;const o=document.documentElement;if(!Ge&&o.hasAttribute(rt))return Zo;if(!Ge){const l=document.createElement("style");l.setAttribute(Zm,""),document.head.appendChild(l);const d=window.scrollY;o.setAttribute(rt,""),document.body.scrollTop=d,Jo(document.body),xt=new MutationObserver(p=>{for(const m of p)for(const h of Array.from(m.addedNodes))h instanceof Element&&Jo(h)}),xt.observe(document.body,{childList:!0,subtree:!0}),Ge=l}const s=Symbol("opencx-app-frame-owner"),i={canvas:e,side:t,pageBackground:n,open:!1,width:Ur,animated:!0,order:++Ko};Mt.set(s,i),$n();let a=!1;const c=l=>{if(a)return;const d=Mt.get(s);d&&(l(d),$n())};return{setOpen(l){c(d=>{d.open=l,l&&(d.order=++Ko)})},setWidth(l){c(d=>{d.width=l})},setAnimated(l){c(d=>{d.animated=l})},release(){a||(a=!0,Mt.delete(s),Mt.size===0?th():$n())}}}function th(){if(!Ge)return;const e=document.body.scrollTop,t=document.documentElement;t.removeAttribute(rt),t.removeAttribute($t),t.removeAttribute(hn),t.style.removeProperty(Vr),xt==null||xt.disconnect(),xt=null;for(const n of Array.from(document.querySelectorAll(`[${Lt}]`)))n.removeAttribute(Lt);Ge.remove(),Ge=null,window.scrollTo({top:e})}let zt=0,Ln="";function nh(){if(typeof document>"u")return()=>{};zt===0&&(Ln=document.body.style.overflow,document.body.style.overflow="hidden"),zt+=1;let e=!1;return()=>{e||(e=!0,zt=Math.max(0,zt-1),zt===0&&(document.body.style.overflow=Ln,Ln=""))}}function rh(e,t){return e[t]??""}function oh({companion:e,layout:t,state:n,region:o,sidebarSide:s,sidebarMode:i,cssVars:a,storage:c,resizeLabel:l}){var M,W,$,q,V,U;const d=Math.max(0,((M=e==null?void 0:e.sidebar)==null?void 0:M.minWidth)??ii),p=Math.max(d,((W=e==null?void 0:e.sidebar)==null?void 0:W.maxWidth)??Nm),[m,h]=u.useState(()=>{var D;return tt(((D=e==null?void 0:e.sidebar)==null?void 0:D.width)??Ur,d,p)}),[f,y]=u.useState(!1),w=u.useRef(null);u.useEffect(()=>{h(D=>{var Z;return tt(((Z=e==null?void 0:e.sidebar)==null?void 0:Z.width)??D,d,p)})},[($=e==null?void 0:e.sidebar)==null?void 0:$.width,p,d]),u.useEffect(()=>{var Z;let D=!1;if(!(!c||((Z=e==null?void 0:e.sidebar)==null?void 0:Z.width)!==void 0))return c.getCompanionSidebarWidth().then(ne=>{D||ne===null||h(tt(ne,d,p))}).catch(()=>{}),()=>{D=!0}},[(q=e==null?void 0:e.sidebar)==null?void 0:q.width,p,d,c]);const k=u.useCallback(D=>tt(s==="left"?D:window.innerWidth-D,d,p),[p,d,s]),x=u.useCallback(D=>{var Z;D.currentTarget.setPointerCapture(D.pointerId),y(!0),(Z=w.current)==null||Z.setAnimated(!1)},[]),S=u.useCallback(D=>{D.currentTarget.hasPointerCapture(D.pointerId)&&h(k(D.clientX))},[k]),b=u.useCallback(D=>{var ne;const Z=k(D.clientX);D.currentTarget.hasPointerCapture(D.pointerId)&&D.currentTarget.releasePointerCapture(D.pointerId),h(Z),y(!1),(ne=w.current)==null||ne.setAnimated(!0),c==null||c.setCompanionSidebarWidth(Z).catch(()=>{})},[c,k]),N=u.useCallback(D=>{var Z;D.currentTarget.hasPointerCapture(D.pointerId)&&D.currentTarget.releasePointerCapture(D.pointerId),y(!1),(Z=w.current)==null||Z.setAnimated(!0)},[]),j=u.useCallback(D=>{let Z=null;if(D.key==="Home"&&(Z=d),D.key==="End"&&(Z=p),D.key==="ArrowLeft"||D.key==="ArrowRight"){const ne=D.key===(s==="left"?"ArrowRight":"ArrowLeft");Z=tt(m+(ne?16:-16),d,p)}Z!==null&&(D.preventDefault(),h(Z),c==null||c.setCompanionSidebarWidth(Z).catch(()=>{}))},[p,d,s,m,c]),g=t==="sidebar",_=i==="docked",A=qr(o,m),R=((V=e==null?void 0:e.sidebar)==null?void 0:V.canvasColor)??_m,P=`hsl(${rh(a,"--opencx-background")})`,O=u.useRef({open:n!=="pill",width:A});O.current={open:n!=="pill",width:A},u.useEffect(()=>{if(!g||!_)return;const D=eh({canvas:R,side:s,pageBackground:P});return w.current=D,D.setWidth(O.current.width),D.setOpen(O.current.open),()=>{w.current===D&&(w.current=null),D.release()}},[R,_,g,P,s]),u.useEffect(()=>{var D;g&&_&&((D=w.current)==null||D.setWidth(A))},[A,_,g]),u.useEffect(()=>{var D;g&&_&&((D=w.current)==null||D.setOpen(n!=="pill"))},[_,g,n]);const I=n==="chat"&&t==="fullscreen",B=((U=e==null?void 0:e.fullscreen)==null?void 0:U.lockScroll)!==!1;u.useEffect(()=>{if(!(!I||!B))return nh()},[I,B]);const E=u.useMemo(()=>({role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":l,"aria-valuemin":d,"aria-valuemax":p,"aria-valuenow":m,onPointerDown:x,onPointerMove:S,onPointerUp:b,onPointerCancel:N,onKeyDown:j}),[p,d,j,x,S,N,b,l,m]);return{sidebarWidth:m,sidebarResizing:f,resizeHandleProps:E}}const sh={width:1440,height:900};function Qo(){return typeof window>"u"?sh:{width:window.innerWidth,height:window.innerHeight}}function ah(){const[e,t]=u.useState(Qo),[n,o]=u.useState(null),s=u.useRef(null),i=u.useCallback(c=>{var d;if((d=s.current)==null||d.disconnect(),s.current=null,!c)return;const l=new ResizeObserver(()=>{o(c.offsetWidth)});l.observe(c),s.current=l},[]);u.useEffect(()=>{function c(){t(Qo())}return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]),u.useEffect(()=>()=>{var c;(c=s.current)==null||c.disconnect(),s.current=null},[]);const a=Math.min(n??ym,Math.max(0,e.width-ai));return{region:e,dockWidth:a,dockContentRef:i}}function ih({storage:e,state:t,layout:n,viewportWidth:o,currentWidth:s,restingWidth:i,shouldReduceMotion:a}){const[c,l]=u.useState(0),d=H.useMotionValue(0),p=u.useRef(!1);u.useEffect(()=>{let k=!1;if(e)return e.getCompanionPillOffsetX().then(x=>{k||x===null||l(x)}).catch(()=>{}),()=>{k=!0}},[d,e]),u.useEffect(()=>{const k=a?xe:vt;if(t==="pill"){const S=Math.max(0,o/2-i/2-Pn),b=tt(c,-S,S);Math.abs(d.get())>S?d.set(b):H.animate(d,b,k);return}if(t==="chat"&&(n==="fullscreen"||n==="sidebar")){H.animate(d,0,k);return}const x=Math.max(0,o/2-s/2-Pn);H.animate(d,tt(c,-x,x),k)},[s,d,n,c,i,a,t,o]);const m=Math.max(0,o/2-i/2-Pn),h=u.useMemo(()=>({left:-m,right:m,top:0,bottom:0}),[m]),f=u.useCallback(()=>{p.current=!0},[]),y=u.useCallback(()=>{const k=d.get();l(x=>x===k?x:k),e==null||e.setCompanionPillOffsetX(k).catch(()=>{}),requestAnimationFrame(()=>{p.current=!1})},[d,e]),w=u.useCallback(()=>p.current,[]);return{dragX:d,dragConstraints:h,onDragStart:f,onDragEnd:y,shouldIgnoreLaunch:w}}function ch({state:e,layout:t,sidebarMode:n,isPageMarkModeArmed:o}){return e==="pill"||o?!1:!(t==="sidebar"&&n==="docked")}const lh=96,es=Nr({transparent:!0});function dh(){var Zr,Jr,Qr;const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger(),{openChats:n,activeId:o}=C.useCompanionChats(),s=n.length,i=n.filter(J=>J.working).length,{widgetCtx:a,contentIframeRef:c}=C.useWidget(),{companion:l,assets:d,customComponents:p,initialQuestions:m}=C.useConfig(),{theme:h,cssVars:f}=fe(),{t:y,dir:w}=ee(),{sessionState:k}=C.useSessions(),{messagesState:x}=C.useMessages(),{isArmed:S}=Wr(),{region:b,dockWidth:N,dockContentRef:j}=ah(),[g,_]=u.useState(e?"chat":"pill"),{layout:A,setLayout:R,setLayoutPreference:P,allowedLayouts:O,defaultLayout:I,sidebarSide:B,sidebarMode:E}=C.useWidgetLayout(),[M,W]=u.useState(lh),{sidebarWidth:$,sidebarResizing:q,resizeHandleProps:V}=oh({companion:l,layout:A,state:g,region:b,sidebarSide:B,sidebarMode:E,cssVars:f,storage:a.storageCtx,resizeLabel:y("companion_resize_chat")}),U=H.useReducedMotion(),D=q?{duration:0}:U?xe:vt,Z=gn(),ne=u.useRef(null),L=u.useRef(!1),X=g==="pill",K=g==="input"&&x.messages.length===0&&(m==null?void 0:m.some(J=>J.trim().length>0))===!0,[re,oe]=u.useState(0),pe=s>0,se=Tr(),be=u.useRef(se.close);be.current=se.close,u.useEffect(()=>{(!X||!pe)&&be.current(!0)},[X,pe]);const ze=p==null?void 0:p.widgetTrigger,ae=!!ze,Ze=(l==null?void 0:l.pillBackground)??"hsl(var(--opencx-primary))",ct=(l==null?void 0:l.icon)??((Zr=d==null?void 0:d.widgetTrigger)==null?void 0:Zr.openIcon),Re=h.widgetTrigger.offset.bottom,Pe=ni(),Fe=!!((Jr=k.session)!=null&&Jr.id),We=Fe?y("follow_up_placeholder"):void 0,He=(l==null?void 0:l.pillLabel)??(l==null?void 0:l.placeholder)??We??y("write_a_message_placeholder"),Oe=(l==null?void 0:l.pillLabelDisplay)??"always",we=(l==null?void 0:l.placeholder)??We??y("write_a_message_placeholder"),[lt,ge]=u.useState(!1),le=X&&!ae&&Oe!=="never"&&(Oe==="always"||Z&&lt),Nt=di(b,l==null?void 0:l.compact),jn=A==="sidebar",dt=Tm({layout:A,region:b,sidebarWidth:$,bottomOffset:Re,compact:l==null?void 0:l.compact}),qt=g==="chat"?dt.width:Nt,Cn=dt.height,{centerX:Vt,bottom:Yt}=Am({isChatOpen:g==="chat",layout:A,region:b,sidebarWidth:$,sidebarSide:B,bottomOffset:Re}),Y=u.useMemo(()=>g==="pill"?le?{width:N,height:wm,borderRadius:Xe.pill}:{width:It,height:It,borderRadius:Xe.pill}:g==="input"?{width:Nt,height:M,borderRadius:Xe.input}:dt,[g,le,N,Nt,dt,M]),me=g==="pill"&&le&&Oe==="hover"?(w==="rtl"?-1:1)*(N-It)/2:0,{dragX:_t,dragConstraints:$e,onDragStart:Je,onDragEnd:Et,shouldIgnoreLaunch:de}=ih({storage:a.storageCtx,state:g,layout:A,viewportWidth:b.width,currentWidth:Y.width,restingWidth:le?N:It,shouldReduceMotion:U}),Be=u.useCallback(()=>{var At;const J=a.routerCtx.state.get().screen,ce=!!((At=a.sessionCtx.sessionState.get().session)!=null&&At.id);_(J==="welcome"||ce?"chat":"input")},[a]),Xt=u.useCallback(()=>{if(!de()){if(be.current(!0),A==="sidebar"){_("chat");return}Be()}},[Be,A,de]),ut=u.useCallback(()=>{if(A==="fullscreen"&&I!=="fullscreen"){R(I);return}if(A==="sidebar"){_("pill");return}_(J=>{var ce;return J==="chat"&&((ce=a.sessionCtx.sessionState.get().session)!=null&&ce.id)?"input":"pill"})},[I,A,R,a]),Tt=u.useCallback(()=>{const J=fm({panelLayout:A,previousLayout:mt.current,defaultLayout:I,allowedLayouts:O});if(J.kind==="layout"){R(J.layout);return}_("pill")},[O,I,A,R]),he=u.useCallback(()=>{_("pill")},[]);u.useEffect(()=>{g==="chat"&&(L.current=!0)},[g]),u.useEffect(()=>{g!=="chat"&&L.current&&A==="fullscreen"&&I!=="fullscreen"&&R(I)},[I,A,R,g]);const pt=g==="chat"&&A==="fullscreen";Km({panelOpen:g!=="pill",isOpen:e,setIsOpen:t,onOpen:Be,onClose:he}),u.useEffect(()=>{if(!ch({state:g,layout:A,sidebarMode:E,isPageMarkModeArmed:S}))return;function J(ce){if(bm(ce))return;const At=ne.current;At&&(ce.composedPath().includes(At)||ut())}return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[ut,g,A,E,S]);const Sn=((Qr=x.messages.findLast(J=>J.type==="USER"))==null?void 0:Qr.id)??null,Kr=u.useRef(null);u.useEffect(()=>{g==="input"&&(Kr.current=Sn)},[g]),u.useEffect(()=>{g==="input"&&Sn!==Kr.current&&(a.routerCtx.state.get().screen!=="chat"&&a.routerCtx.state.setPartial({screen:"chat"}),_("chat"))},[Sn,g,a]);const fi=u.useCallback(()=>{var J;a.routerCtx.state.get().screen!=="chat"&&((J=a.sessionCtx.sessionState.get().session)!=null&&J.id)&&a.routerCtx.state.setPartial({screen:"chat"}),_("chat")},[a]),Gt=u.useCallback(J=>{var ce;O.includes(J)&&(J==="fullscreen"&&a.routerCtx.state.get().screen==="sessions"&&a.routerCtx.toChatScreen((ce=a.sessionCtx.sessionState.get().session)==null?void 0:ce.id),P(J))},[O,a,P]),Nn=O.find(J=>J!=="fullscreen"),mt=u.useRef(Nn??I);u.useEffect(()=>{A!=="fullscreen"&&O.includes(A)?mt.current=A:(mt.current==="fullscreen"||!O.includes(mt.current))&&(mt.current=Nn??I)},[O,I,Nn,A]);const Kt=u.useCallback(()=>{if(!O.includes("fullscreen"))return;if(A!=="fullscreen"){Gt("fullscreen");return}const J=mt.current;J!=="fullscreen"&&O.includes(J)&&Gt(J)},[O,A,Gt]);u.useEffect(()=>{function J(ce){hm(ce,{state:g,onToggleFullscreen:Kt})}return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[Kt,g]);const _n=vn();return _n?Dt.createPortal(r.jsxs(r.Fragment,{children:[ze&&ri(ze,e,t),X&&se.anchor&&!ae&&r.jsx(zr,{placement:"above",picker:se,portalTarget:_n,onSelected:()=>_("chat")}),r.jsx(H.motion.div,{"aria-hidden":!0,style:{position:"fixed",inset:0,background:"transparent",zIndex:h.widgetContentContainer.zIndex,pointerEvents:pt?"auto":"none"},initial:!1,animate:{opacity:pt?1:0},transition:Ee}),r.jsxs(H.motion.div,{ref:ne,style:{...f,position:"fixed",x:_t,translateX:"-50%",zIndex:h.widgetContentContainer.zIndex,visibility:ae&&X?"hidden":void 0},initial:!1,animate:{left:Vt,bottom:Yt},drag:X&&!ae&&!se.open?"x":!1,dragMomentum:!1,dragElastic:.15,dragConstraints:$e,onDragStart:Je,onDragEnd:Et,transition:D,children:[K&&r.jsx("div",{"data-companion-starters":!0,style:{position:"absolute",bottom:"calc(100% + 12px)",left:"50%",transform:"translateX(-50%)",width:qt,height:re},children:r.jsx(Go,{title:"Suggested questions",initialContent:es,style:{width:"100%",height:"100%",border:0,background:"transparent"},children:r.jsx(gm,{onHeightChange:oe,onDismiss:Tt,onToggleFullscreen:Kt,maxHeight:Math.max(48,b.height-Y.height-Re-32)})})}),r.jsxs(H.motion.div,{onPointerEnter:X&&!ae?J=>{ge(!0);const ce=J.currentTarget.querySelector("[data-companion-count-trigger]");ce&&!de()&&se.hover(ce)}:void 0,onPointerLeave:()=>{ge(!1),se.leave()},style:{position:"relative",overflow:"hidden",transformOrigin:"center bottom",cursor:X&&!ae?le?"pointer":"grab":"default",background:"hsl(var(--opencx-background))"},initial:!1,animate:{x:me,width:Y.width,height:Y.height,borderTopLeftRadius:Y.borderRadius,borderTopRightRadius:Y.borderRadius,borderBottomLeftRadius:Y.borderRadius,borderBottomRightRadius:Y.borderRadius,boxShadow:X?le?Wl:Fl:g==="input"?Hl:Bl},whileHover:X&&!ae&&Z&&!U?{scale:le?1.01:1.12}:void 0,whileTap:X&&!ae?{scale:le?.995:.92}:void 0,transition:D,children:[X&&!ae&&r.jsx("button",{type:"button","data-companion-launcher":"",onClick:Xt,"aria-label":Pe,"aria-expanded":!1,style:{position:"absolute",inset:0,zIndex:1,border:0,padding:0,background:"transparent",cursor:"pointer",borderRadius:"inherit"}}),!ae&&r.jsx(Ym,{visible:X,docked:le,label:He,sessions:s>0?r.jsx(Gm,{interactive:X&&le,onSelected:()=>_("chat"),onLastClosed:()=>{requestAnimationFrame(()=>{var J,ce;(ce=(J=ne.current)==null?void 0:J.querySelector("[data-companion-launcher]"))==null||ce.focus({preventScroll:!0})})}}):void 0,activeCount:s,countLabel:`${y("companion_chats")} · ${y("companion_active_chats",{count:s})}${i?` · ${y("companion_working_chats",{count:i})}`:""}`,pickerOpen:se.open,onOpenChats:(J,ce)=>{de()||se.toggle(J,ce)},working:i>0,icon:ct,pillBackground:Ze,dir:w,measureRef:j}),g!=="pill"&&r.jsx(H.motion.div,{style:{position:"absolute",bottom:0,left:"50%",translateX:"-50%",width:qt,height:Cn},initial:{opacity:0},animate:{opacity:1,transition:{...xe,delay:U?0:.1}},children:r.jsx(Go,{iframeRef:c,initialContent:es,style:{width:"100%",height:"100%",overflow:"hidden",backgroundColor:"transparent",boxSizing:"border-box",borderWidth:"0px"},children:r.jsx(Bm,{state:g==="chat"?"chat":"input",layout:A,shellRadius:Y.borderRadius,onMinimize:ut,onDismiss:Tt,onToggleFullscreen:Kt,onSelectLayout:Gt,onExpand:fi,canExpand:Fe,placeholder:we,hideAttachTools:((l==null?void 0:l.quickAskTools)??"history-only")==="history-only",onInputHeightChange:W},o)})}),jn&&g==="chat"&&r.jsx("div",{...V,style:{position:"absolute",top:0,bottom:0,...B==="left"?{right:0}:{left:0},width:8,cursor:"ew-resize",zIndex:2}})]})]})]}),_n):null}function uh(e){const t=e.getBoundingClientRect(),n=t.left+t.width/2,o=t.top+t.height/2,s=e.ownerDocument,i=s.documentElement.clientWidth||window.innerWidth,a=s.documentElement.clientHeight||window.innerHeight;if(n<0||o<0||n>i||o>a||typeof s.elementFromPoint!="function")return!0;const c=s.elementFromPoint(n,o);return c?c===e||e.contains(c)||c.contains(e):!0}function dr(e){const t=Ba(e);if(!t)return{ok:!1,reason:"gone"};const{element:n}=t,o=ir(n);if(o)return{ok:!1,reason:"off-limits",detail:Ju[o]};const s=typeof n.checkVisibility=="function"?n.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}):n.isConnected,i=n.getBoundingClientRect();return!s||i.width===0||i.height===0?{ok:!1,reason:"hidden"}:uh(n)?t.isCurrent?{ok:!0,element:n}:{ok:!1,reason:"gone"}:{ok:!1,reason:"covered"}}function ts(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 ur(e,t){if(!(e instanceof HTMLSelectElement)||t===void 0)return null;const n=Array.from(e.options),o=n.filter(i=>i.value===t||i.label.trim().toLowerCase()===t.trim().toLowerCase()),[s]=o;return o.length!==1||!s||s.disabled||s.parentElement instanceof HTMLOptGroupElement&&s.parentElement.disabled||n.filter(i=>i.value===s.value).length!==1?null:s}function nn(e,t,n){const o=e.ownerDocument,s=h=>h.contains(e)||e.contains(h)||(e.getAttribute("aria-controls")??"").split(/\s+/).some(f=>{const y=o.getElementById(f);return y!==null&&(h.contains(y)||y.contains(h))}),i=Array.from(o.querySelectorAll('[aria-busy="true"]')).filter(h=>!Te(h)&&!s(h)),a=h=>{for(let f=i.length-1;f>=0;f--)s(i[f])&&i.splice(f,1);return i.some(f=>f.contains(h))};let c=!1,l=performance.now(),d;const p=new MutationObserver(h=>{h.some(y=>{const w=y.target instanceof Element?y.target:y.target.parentElement;return w!==null&&!Ut(w)&&!a(w)})&&(c=!0,l=performance.now())});p.observe(o.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});const m=()=>{clearTimeout(d),p.disconnect()};return{settle:()=>new Promise(h=>{const f=performance.now()+t,y=()=>{if(!n()){m(),h({mutated:c,loading:!1});return}const w=Array.from(o.querySelectorAll('[aria-busy="true"]')).some(x=>!a(x)&&!Te(x)),k=performance.now();k>=f||!w&&k-l>=100?(m(),h({mutated:c,loading:w})):d=setTimeout(y,Math.min(100,f-k))};d=setTimeout(y,Math.min(100,t))}),cancel:m}}function ph(e){if(e.tagName.toLowerCase()==="input"){const t=(e.getAttribute("type")??"text").toLowerCase();if(Da.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 mh(e){try{return await hh(e)}catch{return{outcome:"unsupported",detail:"That could not be done on this page."}}}async function hh({ref:e,action:t,value:n,settleMs:o=Du,consentIsCurrent:s=()=>!0,observationIsCurrent:i=()=>!0}){var y;if(!s())return{outcome:"declined"};const a=dr(e);if(!a.ok)return a.reason==="off-limits"?{outcome:"unsupported",detail:a.detail}:{outcome:a.reason};const c=a.element,l=ph(c);if(l)return{outcome:"unsupported",detail:l};const d=c.ownerDocument,p=d.location.href;let m,h,f=!1;try{switch(t){case"click":{m=nn(c,o,i);const S=Vo(c,s);if(S==="not-started")return m.cancel(),{outcome:"declined"};f=S==="interrupted";break}case"fill":{if(n===void 0)return{outcome:"unsupported",detail:"No value was given to type."};if(m=nn(c,o,i),(y=c.focus)==null||y.call(c),!s()){f=!0;break}if(!ts(c,n))return m.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 S=ur(c,n);if(!S)return{outcome:"no_change",detail:"That option is not in the list or cannot be selected unambiguously."};m=nn(c,o,i),h=S.value,ts(c,S.value);break}case"check":case"uncheck":{const S=t==="check",b=c instanceof HTMLInputElement&&(c.type==="checkbox"||c.type==="radio")?c:null,N=c.getAttribute("aria-checked");if(!b&&N===null)return{outcome:"unsupported",detail:"That control is not a checkbox or switch."};if((b?b.checked:N==="true")===S)return{outcome:"no_change",detail:`It is already ${S?"on":"off"}.`};m=nn(c,o,i);const g=Vo(c,s);if(g==="not-started")return m.cancel(),{outcome:"declined"};f=g==="interrupted";break}}const{mutated:w,loading:k}=await(m==null?void 0:m.settle())??{mutated:!1,loading:!1};if(f)return{outcome:"no_change",detail:(w||d.location.href!==p?"The page changed. ":"")+"The requested action was interrupted after input events were dispatched. Its final result is unknown. Do not repeat it automatically."};const x=k?"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 S=c instanceof HTMLInputElement||c instanceof HTMLTextAreaElement||c instanceof HTMLSelectElement?c.value:null;return t==="fill"&&S!==n?{outcome:"no_change",detail:"The field did not keep what was typed."}:t==="select"&&S!==h?{outcome:"no_change",detail:"The dropdown did not keep the selected option."}:{outcome:"done",...x?{detail:x}:{}}}if(t==="check"||t==="uncheck"){const S=t==="check",b=c instanceof HTMLInputElement&&(c.type==="checkbox"||c.type==="radio")?c:null;return(b?b.checked:c.getAttribute("aria-checked")==="true")===S?{outcome:"done",...x?{detail:x}:{}}:{outcome:"no_change",detail:"It did not change."}}return w||d.location.href!==p?{outcome:"done",...x?{detail:x}:{}}:{outcome:"no_change",detail:x??"The control was clicked and nothing on the page changed during observation. Its final result is unknown. Do not repeat it automatically."}}finally{m==null||m.cancel()}}const fh="cubic-bezier(0.32, 0.72, 0, 1)",Dn=260,gh=1600,xh=180,ns=240,rs=.13,bh=e=>e*e*e*(10-15*e+6*e*e);function wh(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 yh(e,t,n=48){const o=t.x-e.x,s=t.y-e.y,i=Math.hypot(o,s)||1,a={x:e.x+o/2-s/i*i*rs,y:e.y+s/2+o/i*i*rs},c=[];for(let l=0;l<=n;l+=1){const d=wh(e,a,t,bh(l/n));c.push({transform:`translate(${d.x-cn}px, ${d.y-ln}px)`})}return c}const cn=2,ln=1.7,vh="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 Yr(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const os=e=>new Promise(t=>{window.setTimeout(t,Yr()?0:e)});let ot=null,pr;const kh=4e3;function fn(){clearTimeout(pr),ot==null||ot.release(),ot=null,document.querySelectorAll("[data-opencx-cursor]").forEach(e=>e.remove())}function mr(){clearTimeout(pr),pr=setTimeout(fn,kh)}function jh(e){if(ot)return mr(),ot;try{fn();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 ${Dn}ms ease`,willChange:"transform"}),t.appendChild(n),n.innerHTML=`<svg viewBox="0 0 14 14" width="14" height="14" style="display:block">
369
+ <path d="${vh}" fill="currentColor" stroke="currentColor" stroke-width="1.7"
370
+ stroke-linejoin="round" stroke-linecap="round" paint-order="stroke"
371
+ style="transition: transform ${ns}ms ${fh}; transform-origin: ${cn}px ${ln}px"/>
372
+ </svg>`;const o=e??{x:window.innerWidth-40,y:window.innerHeight-40};let s=o;n.style.transform=`translate(${o.x-cn}px, ${o.y-ln}px)`,document.documentElement.appendChild(t);const i=n.querySelector("path");n.offsetWidth,n.style.opacity="1";let a=!1;const c={async moveTo(l,d){if(a)return;const p=`translate(${l-cn}px, ${d-ln}px)`;if(Yr()||typeof n.animate!="function"){n.style.transform=p;return}n.style.transition=`opacity ${Dn}ms ease`;const m=yh(s,{x:l,y:d});await n.animate(m,{duration:gh,easing:"linear",fill:"forwards"}).finished.catch(()=>{}),!a&&(n.style.transform=p,s={x:l,y:d},await os(xh))},async press(){a||!i||(i.style.transform="scale(0.86)",await os(ns),i.style.transform="")},release(){a||(a=!0,n.style.opacity="0",window.setTimeout(()=>t.remove(),Dn+60))}};return ot=c,mr(),c}catch{return null}}function Ch(e){const t=e.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}async function ui(e,{press:t=!1}={}){var o;const n=jh();if(!n)return{done:()=>{}};try{(o=e.scrollIntoView)==null||o.call(e,{behavior:Yr()?"auto":"smooth",block:"center",inline:"nearest"});const{x:s,y:i}=Ch(e);await n.moveTo(s,i),t&&await n.press()}catch{}return{done:mr}}const Sh=v.z.object({ref:v.z.string().min(1),action:v.z.enum(Lu),value:v.z.string().max(500).optional()});function pi(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(i=>i.key===s),[])}const Nh=200;function _h(){const{widgetCtx:e}=C.useWidget(),{pageEffects:t,replyToPageCall:n,requestPageActionConsent:o,isStreaming:s}=C.useAgentChatUi(),i=u.useRef(new Set),a=pi(t,s);return u.useEffect(()=>{const c=i.current;for(const l of t){if(l.type!=="act-on-page"||c.has(l.key))continue;for(c.add(l.key);c.size>Nh;){const f=c.values().next().value;if(f===void 0)break;c.delete(f)}const d=Sh.safeParse(l.input);if(!d.success){Q.log.warn("act_on_page: invalid tool input",{issues:d.error.issues}),n(l.callId,"unsupported");continue}const{ref:p,action:m,value:h}=d.data;(async()=>{let f;try{const y=()=>a(l.key)&&e.features.pageContext&&e.features.clientTools&&e.features.pageActions;if(!y()){n(l.callId,"declined");return}const w=Do(p);if(!w){n(l.callId,"gone",void 0,y()?cr():void 0);return}const k=jt(w)||"this control",x=m==="select"?ur(w,h):null;if(m==="select"&&!x){n(l.callId,"no_change","That option is unavailable or ambiguous.");return}const S=x==null?void 0:x.value,b=x==null?void 0:x.label.trim(),N=Fa(w),j=()=>y()&&Do(p)===w&&N()&&k===(jt(w)||"this control")&&(!x||ur(w,h)===x&&x.value===S&&x.label.trim()===b);if(!await o({callId:l.callId,action:m,controlName:k,...m==="fill"||m==="select"?{value:h}:{},...x?{valueLabel:b||"(empty option)"}:{}})){n(l.callId,"declined");return}if(!j()){n(l.callId,"declined");return}if(f=await ui(w,{press:!0}),!j()){n(l.callId,"declined");return}const _=await mh({ref:p,action:m,value:h,consentIsCurrent:j,observationIsCurrent:y}),A=y()&&_.outcome!=="declined"&&_.outcome!=="unsupported"?cr():null;n(l.callId,_.outcome,_.detail,A?{controls:A.controls,truncated:A.truncated}:void 0)}catch{n(l.callId,"unsupported","The page action could not be completed.")}finally{f==null||f.done()}})()}},[t,n,o,e,a]),null}const Eh=["circle","box","underline","bracket","arrow"],Th=v.z.object({ref:v.z.string().min(1),label:v.z.string().optional(),type:v.z.enum(Eh).optional().catch(void 0)}),Ah=8e3;function zh(e,t,n){return t.display==="inline"&&e.height<=n*2.5?"underline":e.width<=220&&e.height<=80?"circle":"box"}let Le=null;function Ih(){Le==null||Le()}function Mh(e,t,{accentColor:n="hsl(0 0% 9%)",surfaceColor:o="hsl(0 0% 9%)",foregroundColor:s="hsl(0 0% 98%)",zIndex:i=10000002,durationMs:a=Ah,seed:c}={}){if(!e.isConnected)return!1;Le==null||Le();const l=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;e.scrollIntoView({behavior:l?"auto":"smooth",block:"center",inline:"nearest"});const d=e.getBoundingClientRect(),p=getComputedStyle(e),m=parseFloat(p.fontSize)||16,h=d.width<160&&d.height<56,f=gs.annotate(e,{type:t.type??zh(d,p,m),color:n,strokeWidth:Math.min(3,Math.max(1.6,m*.11)),wobble:h?.6:.9,rtl:p.direction==="rtl",seed:c});let y=!1;const w=()=>{if(!y)try{f.show(),or(e,i)}catch(P){Q.log.warn("highlight_element: mark could not be drawn",P)}},k=document.fonts;k!=null&&k.ready&&typeof k.ready.then=="function"?k.ready.then(w):w();const x=document.createElement("div");x.setAttribute("data-opencx-overlay",""),x.style.pointerEvents="none";let S=null,b=null;t.label&&(S=document.createElement("div"),S.setAttribute("data-cx-role","callout"),Object.assign(S.style,{position:"fixed",zIndex:String(i+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:l?"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"}),S.textContent=t.label,b=document.createElement("div"),Object.assign(b.style,{position:"absolute",width:"10px",height:"10px",background:o,transform:"rotate(45deg)"}),S.appendChild(b),x.appendChild(S)),document.documentElement.appendChild(x);let N=0;if(S&&b){const P=S,O=b,I=()=>{const B=e.getBoundingClientRect(),E=window.innerWidth,M=B.top>90?"top":"bottom",W=Math.min(240,P.offsetWidth||240),$=Math.max(12,Math.min(B.left+B.width/2-W/2,E-W-12));P.style.left=`${$}px`,P.style.width=`${W}px`,P.style.top=M==="top"?`${B.top-P.offsetHeight-12}px`:`${B.bottom+12}px`,O.style.left=`${Math.max(10,Math.min(B.left+B.width/2-$-5,W-20))}px`,M==="top"?(O.style.bottom="-4px",O.style.top=""):(O.style.top="-4px",O.style.bottom=""),N=requestAnimationFrame(I)};I()}const j=S?window.setTimeout(()=>{S&&(S.style.opacity="1",S.style.transform="translateY(0)")},350):0,g=()=>{if(!y){y=!0,Le===g&&(Le=null),cancelAnimationFrame(N),window.clearTimeout(R),window.clearTimeout(j),document.removeEventListener("click",_,!0),document.removeEventListener("keydown",A,!0),S&&(S.style.opacity="0",S.style.transform=l?"none":"translateY(4px)");try{f.hide(),f.finished.then(()=>f.remove())}catch{f.remove()}window.setTimeout(()=>x.remove(),300)}},_=()=>g(),A=P=>{P.key==="Escape"&&g()},R=window.setTimeout(g,Math.max(0,a));return document.addEventListener("click",_,!0),document.addEventListener("keydown",A,!0),Le=g,!0}const Rh=200;function Ph(){const{pageMarkHighlightDurationMs:e}=C.useConfig(),{pageEffects:t,replyToPageCall:n,isStreaming:o}=C.useAgentChatUi(),{widgetCtx:s}=C.useWidget(),i=pi(t,o),{theme:a,cssVars:c}=fe(),l=Dr({cssVars:c,primaryColor:a.primaryColor,contentZIndex:a.widgetContentContainer.zIndex}),d=u.useRef(new Set);return u.useEffect(()=>()=>{Ih(),fn()},[]),u.useEffect(()=>{o||fn()},[o]),u.useEffect(()=>{const p=d.current;for(const m of t){if(m.type!=="highlight-element"||p.has(m.key))continue;for(p.add(m.key);p.size>Rh;){const S=p.values().next().value;if(S===void 0)break;p.delete(S)}const h=()=>i(m.key)&&s.features.pageContext&&s.features.clientTools;if(!h()){n(m.callId,"declined");continue}const f=Th.safeParse(m.input);if(!f.success){Q.log.warn("highlight_element: invalid tool input",{issues:f.error.issues}),n(m.callId,"unsupported");continue}const y=dr(f.data.ref);if(!y.ok){Q.log.warn("highlight_element: not drawn",{ref:f.data.ref,reason:y.reason}),y.reason==="off-limits"?n(m.callId,"unsupported",y.detail):n(m.callId,y.reason);continue}const w=y.element,k=m.callId,x=f.data;(async()=>{let S;try{if(S=await ui(w),!h()){n(k,"declined");return}const b=dr(x.ref);if(!b.ok){n(k,b.reason==="off-limits"?"unsupported":b.reason);return}const N=Mh(w,x,{accentColor:l.accent,surfaceColor:l.surface,foregroundColor:l.foreground,zIndex:l.inkZIndex,durationMs:e});n(k,N?"done":"gone"),N||Q.log.warn("highlight_element: the mark could not be drawn",x)}catch{n(k,"unsupported","The page highlight could not be completed.")}finally{S==null||S.done()}})()}},[t,n,e,l.accent,l.surface,l.foreground,l.inkZIndex,i,s]),null}const Oh=/(\*\*\*|\*\*|\*|~~|`+)(?=\S)([\s\S]*?\S)\1/g,$h=/(^|[^\w`])(___|__|_)(?=\S)([\s\S]*?\S)\2(?!\w)/g,Lh=3;function hr(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<Lh;n++){const o=t.replace(Oh,"$2").replace($h,"$1$3");if(o===t)break;t=o}return t.trim()}function mi({className:e}){const[t,n]=u.useState(()=>new Set);return u.useEffect(()=>{const o=Array.from({length:9},(i,a)=>a),s=setInterval(()=>{const i=2+Math.floor(Math.random()*3),a=[...o].sort(()=>Math.random()-.5).slice(0,i);n(new Set(a))},110);return()=>clearInterval(s)},[]),r.jsx("div",{className:T("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 Dh({labels:e,active:t}){const n=u.useRef(e);n.current=e;const[o,s]=u.useState(()=>e[e.length-1]??""),[i,a]=u.useState("in"),c=u.useRef(e.length);return u.useEffect(()=>{const l=n.current.length;if(!t||l<=c.current){c.current=l;return}c.current=l;const d=n.current[l-1]??"";a("out");const p=setTimeout(()=>{s(d),a("in")},180);return()=>clearTimeout(p)},[t,e.length]),r.jsx("span",{className:T("truncate text-[12px] text-muted-foreground/60",t&&(i==="in"?"opencx-placeholder-in":"opencx-placeholder-out")),children:o})}function Xr(e,t){if(e.kind==="tool")return Gr(e.label);const n=e.label.split(`
373
+ `).find(s=>s.trim());if(!n)return t;const o=hr(n);return o?o.length>40?`${o.slice(0,40)}...`:o:t}function Fh(e,t,n=3){const o=e.filter(s=>s.kind==="tool").map(s=>Gr(s.label));if(o.length===0){const s=e.find(i=>i.kind==="reasoning");return s?Xr(s,t):t}return o.length<=n?o.join(" → "):`${o.slice(0,n).join(" → ")} → ...`}const Wh=["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 Hh({step:e,isLive:t,thinkingLabel:n}){const[o,s]=u.useState(!1),i=Xr(e,n),a=i!==hr(e.label),c=t?(()=>{const l=e.label.split(`
374
+ `).filter(p=>p.trim()),d=hr(l[l.length-1]??"");return d?d.length>80?`${d.slice(0,80)}...`:d:n})():i;return r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:T("flex min-w-0 items-center gap-2.5 py-[3px]",a&&"cursor-pointer"),onClick:()=>a&&s(l=>!l),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(Ir,{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:T("min-w-0 truncate text-[13px] italic text-muted-foreground/60",t&&"opencx-text-shimmer"),children:c}),a&&r.jsx(z.ChevronRightIcon,{className:T("size-2.5 shrink-0 text-muted-foreground/40 transition-transform duration-200",o&&"rotate-90")})]}),a&&o&&r.jsx("div",{className:"opencx-fade-up ms-[30px]",children:r.jsx("div",{className:T("max-h-[160px] overflow-y-auto py-1.5 text-[13px] leading-relaxed [overflow-wrap:anywhere]",Wh),children:r.jsx(kr,{children:e.label})})})]})}const ss=4e3;function Bh(e){const t=typeof e=="string"?e:Uh(e)??String(e);return t.length>ss?`${t.slice(0,ss)}…`:t}function Uh(e){try{return JSON.stringify(e,null,2)}catch{return null}}function as({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:Bh(t)})]})}function qh({step:e,showIO:t}){const{t:n}=ee(),[o,s]=u.useState(!1),i=t&&(e.input!==void 0||e.output!==void 0);return r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:T("flex min-w-0 items-center gap-2.5 py-[3px]",i&&"cursor-pointer"),onClick:()=>i&&s(a=>!a),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(mi,{})}),r.jsx("span",{className:T("min-w-0 truncate text-[13px] text-muted-foreground/70",!e.done&&"opencx-text-shimmer"),children:Gr(e.label)}),i&&r.jsx(z.ChevronRightIcon,{className:T("size-2.5 shrink-0 text-muted-foreground/40 transition-transform duration-200",o&&"rotate-90")})]}),i&&o&&r.jsxs("div",{className:"opencx-fade-up ms-[30px] pb-1",children:[e.input!==void 0&&r.jsx(as,{label:n("step_arguments"),value:e.input}),e.output!==void 0&&r.jsx(as,{label:n("step_result"),value:e.output})]})]})}function Vh({steps:e,active:t}){var y;const{t:n}=ee(),{showStepToolIO:o,presentation:s}=C.useConfig(),{widgetCtx:i}=C.useWidget(),a=(y=Q.resolveClientPresentation(i.agent.presentation,s))==null?void 0:y.toolActivity,c=o!==!1&&(a==="details"||a===void 0&&o===!0),l=n("thinking"),d=t?e:e.map(w=>w.done?w:{...w,done:!0}),p=d.some(w=>!w.done),[m,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]),d.length===0?null:r.jsxs("div",{...F("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(w=>!w),children:m?r.jsxs(r.Fragment,{children:[r.jsx(z.ChevronDownIcon,{className:"size-2.5 shrink-0"}),r.jsx("span",{className:"text-[11px] font-medium tabular-nums",children:d.length}),r.jsx("span",{className:T("text-muted-foreground/40",p&&"opencx-text-shimmer"),children:n(p?"running":"steps")})]}):p?r.jsxs(r.Fragment,{children:[r.jsx(mi,{className:"opacity-70"}),r.jsx("span",{className:"text-[11px] font-medium tabular-nums",children:d.length}),r.jsx(Dh,{labels:d.map(w=>Xr(w,l)),active:p})]}):r.jsxs(r.Fragment,{children:[r.jsx(z.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:Fh(d,l)})]})}),m&&r.jsxs("div",{className:"relative pt-1",children:[d.length>1&&r.jsx("div",{className:"absolute bottom-3 start-2 top-3 border-s border-dashed border-muted-foreground/20"}),d.map((w,k)=>r.jsx("div",{className:"opencx-fade-up",style:{animationDelay:`${k*40}ms`},children:w.kind==="reasoning"?r.jsx(Hh,{step:w,isLive:p&&k===d.length-1,thinkingLabel:l}):r.jsx(qh,{step:w,showIO:c})},k))]})]})}function Gr(e){const n=e.replace(/^mcp_[a-f0-9]{16}__/,"").replaceAll(/[_-]+/g," ").trim();return n.charAt(0).toUpperCase()+n.slice(1)}function is(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(i=>i.id===o))==null?void 0:s.label}).filter(o=>typeof o=="string"&&o.length>0);return t.length>0?t.join(", "):void 0}function Yh({request:e}){const{t}=ee(),{sendMessage:n}=C.useMessages(),{widgetCtx:o}=C.useWidget(),s=e.questions,[i,a]=u.useState(0),[c,l]=u.useState(!1),[d,p]=u.useState({}),[m,h]=u.useState({}),[f,y]=u.useState({}),[w,k]=u.useState({}),x=s[i],S=s.length,b=u.useCallback(I=>is({question:I,manual:!!d[I.id],manualText:m[I.id]??"",singleId:f[I.id],multiIds:w[I.id]??new Set})!==void 0,[d,m,w,f]),N=x?b(x):!1,j=u.useMemo(()=>s.every(I=>b(I)),[b,s]),g=u.useCallback((I,B)=>{y(E=>({...E,[I]:B})),p(E=>({...E,[I]:!1}))},[]),_=u.useCallback((I,B)=>{k(E=>{const M=new Set(E[I]??[]);return M.has(B)?M.delete(B):M.add(B),{...E,[I]:M}}),p(E=>({...E,[I]:!1}))},[]),A=u.useCallback(I=>{p(B=>({...B,[I]:!0})),y(B=>({...B,[I]:void 0})),k(B=>({...B,[I]:new Set}))},[]),R=u.useCallback(()=>{N&&a(I=>Math.min(S-1,I+1))},[N,S]),P=u.useCallback(()=>{if(c||!j)return;const I=new Map;for(const E of s){const M=is({question:E,manual:!!d[E.id],manualText:m[E.id]??"",singleId:f[E.id],multiIds:w[E.id]??new Set});M&&I.set(E.id,M)}const B=C.formatAskQuestionsAnswers(e,I);B.trim().length!==0&&(l(!0),n({content:B,clientContext:Ua({marks:[],readsPage:o.features.pageContext})}))},[j,c,d,m,w,s,e,n,f,o]);if(!x)return null;const O=!!d[x.id];return r.jsxs("div",{...F("chat/clarification_questions/root"),className:T("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(z.SparklesIcon,{className:"size-4"})}),r.jsx("p",{...F("chat/clarification_questions/prompt"),className:"min-w-0 flex-1 text-sm font-medium leading-snug text-foreground",children:x.prompt})]}),r.jsx("div",{className:"px-4 pb-3 pt-3",children:O?r.jsx("textarea",{...F("chat/clarification_questions/manual_input"),value:m[x.id]??"",onChange:I=>h(B=>({...B,[x.id]:I.target.value})),placeholder:t("questions_answer_placeholder"),rows:3,className:T("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:I=>{I.key!=="Enter"||I.shiftKey||(I.preventDefault(),i<S-1?R():P())}}):r.jsxs("div",{className:"flex flex-wrap gap-2",children:[x.options.map(I=>{var E;const B=x.selection==="single"?f[x.id]===I.id:((E=w[x.id])==null?void 0:E.has(I.id))??!1;return u.createElement("button",{...F("chat/clarification_questions/option"),key:I.id,type:"button","aria-pressed":B,onClick:()=>x.selection==="single"?g(x.id,I.id):_(x.id,I.id),className:T("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")},I.label)}),r.jsx("button",{...F("chat/clarification_questions/type_it"),type:"button",onClick:()=>A(x.id),className:T("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",{...F("chat/clarification_questions/back"),type:"button",onClick:()=>a(I=>Math.max(0,I-1)),disabled:i===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(z.ChevronLeftIcon,{className:"size-3.5"}),t("questions_back")]}),S>1?r.jsxs("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[i+1," / ",S]}):null,i<S-1?r.jsxs("button",{...F("chat/clarification_questions/next"),type:"button",onClick:R,disabled:!N,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(z.ChevronRightIcon,{className:"size-3.5"})]}):r.jsx("button",{...F("chat/clarification_questions/send"),type:"button",onClick:P,disabled:!j,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:`${(i+1)/Math.max(1,S)*100}%`}})})]})}function Xh({widgetRef:e}){const{contactState:t}=C.useContact(),{setIsOpen:n}=C.useWidgetTrigger(),{toChatScreen:o}=C.useWidgetRouter();return u.useImperativeHandle(e,()=>({newChat:async s=>{var a;if(!((a=t.contact)!=null&&a.token)){Q.log.warn("cannot start a new chat: contact not yet initialized");return}n(!0);const i=o();i&&(s!=null&&s.message)&&await i.messageCtx.sendMessage({content:s.message})}}),[t,n,o]),null}function Gh(){const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger();return r.jsxs(Ye.Root,{open:e,onOpenChange:t,children:[r.jsx(um,{}),r.jsx(dm,{}),r.jsx(im,{})]})}function Kh(){return C.useDisplayMode()==="companion"?r.jsx(C.WidgetLayoutProvider,{children:r.jsx(dh,{})}):r.jsx(Gh,{})}const Zh=[{key:"loading",component:ud},{key:"fallback",component:dd},{key:"bot_message",component:Gn},{key:"agent_message",component:Gn},{key:"agent_chat_steps",component:Vh},{key:"agent_chat_spec",component:$d},{key:"agent_chat_questions",component:Yh}],Jh={get:async e=>localStorage.getItem(e),set:async(e,t)=>{localStorage.setItem(e,t)},remove:async e=>{localStorage.removeItem(e)}},hi=u.forwardRef(function({options:t,components:n=[],loadingComponent:o,errorComponent:s},i){var a,c,l,d;return r.jsx(H.MotionConfig,{reducedMotion:"user",children:r.jsx(C.WidgetProvider,{components:[...Zh,...n],options:{...t,capabilities:{...t.capabilities,richReplies:((a=t.capabilities)==null?void 0:a.richReplies)??!n.some(({key:p})=>["AGENT_CHAT_SPEC","BOT_MESSAGE","AGENT_MESSAGE"].includes(p.toUpperCase())),connections:((c=t.capabilities)==null?void 0:c.connections)===!0,pageEffects:((l=t.capabilities)==null?void 0:l.pageEffects)??!0,structuredQuestions:((d=t.capabilities)==null?void 0:d.structuredQuestions)??!n.some(({key:p})=>p.toUpperCase()==="AGENT_CHAT_QUESTIONS")}},storage:Jh,loadingComponent:o,errorComponent:s,children:r.jsx(C.WidgetTriggerProvider,{children:r.jsxs(Rp,{children:[r.jsx(Ph,{}),r.jsx(_h,{}),r.jsx(Xh,{widgetRef:i}),t.inline?r.jsx(ti,{}):r.jsx(Kh,{})]})})})})});hi.displayName="Widget";exports.HostedSpecRenderer=Tl;exports.Widget=hi;exports.segmentContent=ta;exports.useJsonRenderHost=Bt;
375
+ //# sourceMappingURL=index-rkpSpEfw.cjs.map