@webority/ui-elements 0.53.1 → 0.55.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 (82) hide show
  1. package/dist/WuiAutocomplete-CE7wT-Vc.js +13 -0
  2. package/dist/WuiCarousel-C33Z8FBt.js +1 -0
  3. package/dist/WuiCodeBlock-BcLJhLBJ.js +1 -0
  4. package/dist/WuiCommandPalette-CcmFOWNc.js +2 -0
  5. package/dist/WuiCommentThread-Bww7P_cu.js +1 -0
  6. package/dist/{WuiCountrySelect-GJrl6sUP.js → WuiCountrySelect-D92rrSvW.js} +1 -1
  7. package/dist/WuiDataTable-tR8Lp4XZ.js +1 -0
  8. package/dist/{WuiDatePicker-CI7wLkmd.js → WuiDatePicker-_BzQ2m1e.js} +1 -1
  9. package/dist/WuiDateRange-CrVodISl.js +25 -0
  10. package/dist/WuiDrawer-BuvDLR6M.js +1 -0
  11. package/dist/WuiHoverCard-CNEawHmO.js +1 -0
  12. package/dist/WuiInlineEdit-CI-3C7yP.js +1 -0
  13. package/dist/WuiLightbox-hluak_-q.js +1 -0
  14. package/dist/WuiMentionInput-DW7N1Zne.js +1 -0
  15. package/dist/WuiMenubar-D2tb_3eU.js +1 -0
  16. package/dist/WuiMultiSelect-WUNCdkzW.js +25 -0
  17. package/dist/WuiNavigationMenu-BsLnvz2Y.js +1 -0
  18. package/dist/WuiNotificationCenter-DKdvaSbm.js +1 -0
  19. package/dist/WuiOnboardingChecklist-s2DG6PZ0.js +1 -0
  20. package/dist/WuiOverflow-CB3j6q6n.js +1 -0
  21. package/dist/WuiRating-BzeW6iDC.js +1 -0
  22. package/dist/WuiRecordPager-yXv4g2ZR.js +1 -0
  23. package/dist/WuiRelativeTime-Cfc8TMd8.js +1 -0
  24. package/dist/WuiResizable-m2Ypa-zD.js +1 -0
  25. package/dist/WuiRollingNumber-DBgi_3l7.js +1 -0
  26. package/dist/{WuiSelect-DcbtqI9s.js → WuiSelect-CT8tgsxL.js} +1 -1
  27. package/dist/WuiShortcuts-CMibF1XM.js +1 -0
  28. package/dist/WuiShowMore-Bu7IQcXS.js +1 -0
  29. package/dist/WuiTour-DW3kPaR9.js +488 -0
  30. package/dist/WuiTruncate-BLl2u3b-.js +1 -0
  31. package/dist/WuiWhatsNew-BO78119Z.js +1 -0
  32. package/dist/copyText-DM5HhXjf.js +1 -0
  33. package/dist/elements/autocomplete.js +1 -1
  34. package/dist/elements/carousel.js +1 -0
  35. package/dist/elements/code-block.js +1 -0
  36. package/dist/elements/command-palette.js +1 -1
  37. package/dist/elements/comment-thread.js +1 -0
  38. package/dist/elements/country-select.js +1 -1
  39. package/dist/elements/data-table.js +1 -0
  40. package/dist/elements/date-range.js +1 -1
  41. package/dist/elements/datepicker.js +1 -1
  42. package/dist/elements/drawer.js +1 -0
  43. package/dist/elements/hover-card.js +1 -0
  44. package/dist/elements/inline-edit.js +1 -0
  45. package/dist/elements/lightbox.js +1 -0
  46. package/dist/elements/mention-input.js +1 -0
  47. package/dist/elements/menubar.js +1 -0
  48. package/dist/elements/multiselect.js +1 -1
  49. package/dist/elements/navigation-menu.js +1 -0
  50. package/dist/elements/notification-center.js +1 -0
  51. package/dist/elements/onboarding-checklist.js +1 -0
  52. package/dist/elements/overflow.js +1 -0
  53. package/dist/elements/rating.js +1 -0
  54. package/dist/elements/record-pager.js +1 -0
  55. package/dist/elements/relative-time.js +1 -0
  56. package/dist/elements/resizable.js +1 -0
  57. package/dist/elements/rolling-number.js +1 -0
  58. package/dist/elements/select.js +1 -1
  59. package/dist/elements/shortcuts.js +1 -0
  60. package/dist/elements/show-more.js +1 -0
  61. package/dist/elements/tour.js +1 -1
  62. package/dist/elements/truncate.js +1 -0
  63. package/dist/elements/whats-new.js +1 -0
  64. package/dist/helpers.js +1 -1
  65. package/dist/notificationDays-pYmoU0g6.js +1 -0
  66. package/dist/{optionLabel-DOZb8ERB.js → optionLabel-BBaur8Bs.js} +1 -1
  67. package/dist/shortcutKeys-BQiDpsTJ.js +1 -0
  68. package/dist/themeTransition-C61cbmZ4.js +1 -0
  69. package/dist/types/chatClient.d.ts +4 -4
  70. package/dist/ui-chat-core.js +1 -1
  71. package/dist/ui-chat.global.js +1 -1
  72. package/dist/ui-chat.js +1 -1
  73. package/dist/ui-elements.global.js +462 -143
  74. package/dist/ui-elements.js +1 -1
  75. package/dist/ui-tour.global.js +1 -1
  76. package/package.json +24 -1
  77. package/dist/WuiAutocomplete-DvXHihD6.js +0 -13
  78. package/dist/WuiCommandPalette-CfbMtT6z.js +0 -2
  79. package/dist/WuiDateRange-BFpOjqWn.js +0 -25
  80. package/dist/WuiMultiSelect-BCZE2VHM.js +0 -25
  81. package/dist/WuiTour-CEoudHTq.js +0 -169
  82. package/dist/themeTransition-lkmQm8FR.js +0 -1
@@ -0,0 +1 @@
1
+ import{n as e}from"../elementBase-BlsR4tqa.js";import{t}from"../WuiTruncate-BLl2u3b-.js";e(`wui-truncate`,t);export{t as WuiTruncate};
@@ -0,0 +1 @@
1
+ import{n as e}from"../elementBase-BlsR4tqa.js";import{n as t,t as n}from"../WuiWhatsNew-BO78119Z.js";e(`wui-whats-new`,t);export{n as WHATS_NEW_READ_EVENT,t as WuiWhatsNew};
package/dist/helpers.js CHANGED
@@ -1 +1 @@
1
- import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"./formatters-BAE__8ye.js";import{t as h}from"./iconGlyphs.g-CUm_mfze.js";import{i as g}from"./optionLabel-DOZb8ERB.js";import{t as _}from"./textMatch-wdY7XLIc.js";import{$ as v,A as y,B as b,C as x,D as S,E as C,F as w,G as T,H as E,I as D,J as O,K as k,L as A,M as j,N as M,O as N,P,Q as F,R as I,S as L,T as R,U as z,V as B,W as V,X as H,Y as U,Z as W,_ as G,a as K,b as q,c as J,d as Y,et as X,f as Z,g as Q,h as $,i as ee,j as te,k as ne,l as re,m as ie,n as ae,o as oe,p as se,q as ce,s as le,t as ue,tt as de,u as fe,v as pe,w as me,x as he,y as ge,z as _e}from"./themeTransition-lkmQm8FR.js";export{ce as AVATAR_ACCEPT,O as AVATAR_MAX_SIZE_MB,U as AVATAR_OUTPUT_SIZE,H as AVATAR_OUTPUT_TYPE,W as AVATAR_PREVIEW_SIZES,F as AVATAR_TEXT,T as COPY_FEEDBACK_MS,p as CURRENCIES,c as DATE_PATTERNS,A as DEFAULT_IMAGE_ACCEPT,I as DEFAULT_MAX_SIZE_MB,L as DEFAULT_PASSWORD_RULES,x as DEFAULT_REQUIREMENTS_TITLE,ue as DEFAULT_THEME_EFFECT,ae as DEFAULT_THEME_STORAGE_KEY,d as DURATION_UNITS,a as EMPTY_VALUE,e as FORMAT_STYLES,l as IST_TIME_ZONE,S as MASK_INPUT_TYPES,N as MASK_NAMES,f as MONEY_UNITS,ge as SCROLL_EDGE_SELECTOR,ee as THEME_CHANGE_EVENT,K as THEME_EFFECTS,oe as THEME_EFFECT_DURATION,le as THEME_LIVE_NAME,J as THEME_MODES,re as THEME_SWITCHING_CLASS,_e as acceptLabel,fe as applyTheme,ne as attachInputMask,q as attachScrollEdges,v as avatarCropOptions,X as avatarUnreadableMessage,me as buildPasswordRules,k as copyTextToClipboard,R as evaluatePassword,t as formatCompact,o as formatCurrency,m as formatDate,n as formatDuration,y as formatMasked,r as formatNumber,u as formatPercent,s as formatValue,h as glyphSvg,te as initInputMasks,he as initScrollEdges,de as isHeicFile,b as isImageFile,B as isImageOnlyAccept,j as isMaskPattern,E as isPdfFile,M as maskedPostValue,_ as matchSegments,z as matchesAccept,Y as nextTheme,C as passwordSatisfies,P as postedMasked,w as rawMasked,Z as readStoredTheme,D as resolveMask,se as resolveTheme,ie as storeTheme,$ as themeBootScript,Q as themeKeyframes,i as toInstant,G as transitionTheme,V as validateFile,pe as watchSystemTheme,g as withTrustedLabel};
1
+ import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"./formatters-BAE__8ye.js";import{t as h}from"./iconGlyphs.g-CUm_mfze.js";import{o as g}from"./optionLabel-BBaur8Bs.js";import{n as _,t as v}from"./copyText-DM5HhXjf.js";import{t as y}from"./textMatch-wdY7XLIc.js";import{a as b,c as x,i as S,n as C,o as w,r as T,s as E,t as D}from"./notificationDays-pYmoU0g6.js";import{a as O,c as k,d as A,f as j,i as M,l as N,m as P,n as F,o as I,p as L,r as R,s as z,t as B,u as V}from"./shortcutKeys-BQiDpsTJ.js";import{$ as H,A as U,B as W,C as G,D as K,E as q,F as J,G as Y,H as X,I as Z,J as Q,K as $,L as ee,M as te,N as ne,O as re,P as ie,Q as ae,R as oe,S as se,T as ce,U as le,V as ue,W as de,X as fe,Y as pe,Z as me,_ as he,a as ge,b as _e,c as ve,d as ye,f as be,g as xe,h as Se,i as Ce,j as we,k as Te,l as Ee,m as De,n as Oe,o as ke,p as Ae,q as je,s as Me,t as Ne,u as Pe,v as Fe,w as Ie,x as Le,y as Re,z as ze}from"./themeTransition-C61cbmZ4.js";export{Y as AVATAR_ACCEPT,$ as AVATAR_MAX_SIZE_MB,je as AVATAR_OUTPUT_SIZE,Q as AVATAR_OUTPUT_TYPE,pe as AVATAR_PREVIEW_SIZES,fe as AVATAR_TEXT,v as COPY_FEEDBACK_MS,p as CURRENCIES,c as DATE_PATTERNS,ee as DEFAULT_IMAGE_ACCEPT,oe as DEFAULT_MAX_SIZE_MB,se as DEFAULT_PASSWORD_RULES,G as DEFAULT_REQUIREMENTS_TITLE,Ne as DEFAULT_THEME_EFFECT,Oe as DEFAULT_THEME_STORAGE_KEY,d as DURATION_UNITS,a as EMPTY_VALUE,e as FORMAT_STYLES,l as IST_TIME_ZONE,B as LIST_KEYS,K as MASK_INPUT_TYPES,re as MASK_NAMES,f as MONEY_UNITS,D as NOTIFICATION_COUNT_CAP,C as NOTIFICATION_TEXT,Re as SCROLL_EDGE_SELECTOR,F as SELECT_KEY,R as SHORTCUTS_OFF_ATTRIBUTE,M as SHORTCUT_EVENT,O as SHORTCUT_SCOPE_ATTRIBUTE,I as SHORTCUT_TEXT,Ce as THEME_CHANGE_EVENT,ge as THEME_EFFECTS,ke as THEME_EFFECT_DURATION,Me as THEME_LIVE_NAME,ve as THEME_MODES,Ee as THEME_SWITCHING_CLASS,ze as acceptLabel,Pe as applyTheme,z as ariaKeyShortcuts,Te as attachInputMask,_e as attachScrollEdges,me as avatarCropOptions,ae as avatarUnreadableMessage,Ie as buildPasswordRules,_ as copyTextToClipboard,ce as evaluatePassword,t as formatCompact,o as formatCurrency,m as formatDate,n as formatDuration,U as formatMasked,r as formatNumber,u as formatPercent,s as formatValue,h as glyphSvg,T as groupNotificationsByDay,k as inShortcutScope,we as initInputMasks,Le as initScrollEdges,H as isHeicFile,W as isImageFile,ue as isImageOnlyAccept,te as isMaskPattern,X as isPdfFile,N as isTypingTarget,ne as maskedPostValue,y as matchSegments,le as matchesAccept,V as moveFocus,ye as nextTheme,S as notificationCountText,b as notificationDayHeading,w as notificationTime,E as notificationTriggerLabel,x as notificationUnreadAnnouncement,q as passwordSatisfies,ie as postedMasked,J as rawMasked,be as readStoredTheme,Z as resolveMask,Ae as resolveTheme,A as runShortcut,j as shortcutKey,L as shortcutName,P as shortcutsOff,De as storeTheme,Se as themeBootScript,xe as themeKeyframes,i as toInstant,he as transitionTheme,de as validateFile,Fe as watchSystemTheme,g as withTrustedLabel};
@@ -0,0 +1 @@
1
+ import{h as e,u as t}from"./formatters-BAE__8ye.js";var n=99,r=1440*60*1e3,i=Object.freeze({label:`Notifications`,empty:`You are all caught up.`,markAll:`Mark all read`,viewAll:`View all`,unreadPrefix:`Unread: `,today:`Today`,yesterday:`Yesterday`,allRead:`All notifications marked as read.`,noneUnread:`No unread notifications`,failed:Object.freeze({forbidden:`You do not have permission to mark these as read.`,client:`These could not be marked as read. Refresh the page and try again.`,validation:`These could not be marked as read. Refresh the page and try again.`,server:`Something went wrong on our side, so these were not marked as read. Try again in a moment.`,network:`Could not reach the server, so these were not marked as read. Check your connection and try again.`})});function a(e){return e>99?`99+`:String(e)}function o(e,t){return t===0?e:`${e}, ${a(t)} unread`}function s(e){return e===0?i.noneUnread:`${a(e)} unread notifications`}function c(e){return t(e,{pattern:`time`})}function l(n,a=Date.now()){let o=t(n);return o===t(a)?i.today:o===t(e(a)-r)?i.yesterday:o}function u(n,r=Date.now()){let i=new Map;for(let a of n){if(!Number.isFinite(e(a.at)))throw Error(`<AppNotificationCenter> item "${a.id}": at must be an ISO date-time with its zone (or a YYYY-MM-DD day), got ${String(a.at)}.`);let n=t(a.at);i.has(n)||i.set(n,{key:n,heading:l(a.at,r),items:[]}),i.get(n).items.push(a)}return[...i.values()]}export{l as a,s as c,a as i,i as n,c as o,u as r,o as s,n as t};
@@ -1 +1 @@
1
- import{t as e}from"./iconGlyphs.g-CUm_mfze.js";var t=Symbol(`wui.trustedHtml`),n=e=>({...e,[t]:!0}),r=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),i=t=>{if(!t)return``;let n=String(t).toLowerCase().replace(/[^a-z0-9-]/g,``);return n?e(n):``},a=e=>`wui-flag wui-flag-${e}`,o=e=>{let t=String(e??``).toLowerCase();return/^[a-z]{2}$/.test(t)?`<span class="${a(t)}" aria-hidden="true"></span>`:``},s=e=>{if(e==null)return``;let n=e[t]?String(e.label??``):r(e.label),a=o(e.flag)+i(e.icon);return a?`<span class="wui-opt-label">${a}${n}</span>`:n};export{n as i,r as n,s as r,t};
1
+ import{t as e}from"./iconGlyphs.g-CUm_mfze.js";var t=Symbol(`wui.trustedHtml`),n=e=>({...e,[t]:!0}),r=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),i=t=>{if(!t)return``;let n=String(t).toLowerCase().replace(/[^a-z0-9-]/g,``);return n?e(n):``},a=e=>`wui-flag wui-flag-${e}`,o=e=>{let t=String(e??``).toLowerCase();return/^[a-z]{2}$/.test(t)?`<span class="${a(t)}" aria-hidden="true"></span>`:``},s=e=>{if(e==null)return``;let n=e[t]?String(e.label??``):r(e.label),a=o(e.flag)+i(e.icon);return a?`<span class="wui-opt-label">${a}${n}</span>`:n},c=e=>String(e??``).replace(/<[^>]*>/g,``),l=new WeakMap,u=e=>{if(e==null)return``;if(!e[t])return c(e.label);let n=l.get(e);if(n&&n.label===e.label)return n.text;let r=document.createElement(`template`);r.innerHTML=String(e.label??``);let i=r.content.textContent;return l.set(e,{label:e.label,text:i}),i};export{c as a,u as i,r as n,n as o,s as r,t};
@@ -0,0 +1 @@
1
+ var e=`data-wui-shortcuts`,t=`data-shortcut-scope`,n=`wui:shortcut`,r={title:`Keyboard shortcuts`,close:`Close`,help:`Show these shortcuts`},i=[{key:`J`,label:`Next item`},{key:`K`,label:`Previous item`},{key:`Enter`,label:`Open the item`}],a={key:`X`,label:`Select the item`},o={"/":`slash`,"?":`help`,Escape:`esc`,Esc:`esc`,Enter:`enter`},s={esc:`Esc`,escape:`Esc`,enter:`Enter`,slash:`/`,help:`?`},c={esc:`Escape`,ctrl:`Control`,cmd:`Meta`,option:`Alt`,opt:`Alt`},l=new Set([`checkbox`,`radio`,`button`,`submit`,`reset`,`range`,`color`,`file`,`image`]),u=new Set([`textbox`,`searchbox`,`combobox`]),d=`a[href], button, summary, input, select, textarea, [role="button"], [role="link"], [role="menuitem"], [role="option"], [role="tab"], [role="checkbox"], [role="switch"]`;function f(e){if(!e||e.ctrlKey||e.metaKey||e.altKey)return null;let t=e.key;return typeof t!=`string`||!t?null:o[t]?o[t]:t.length===1&&t.trim()?t.toLowerCase():null}function p(e){let t=String(e??``).trim();return t.length===1?t.toUpperCase():s[t.toLowerCase()]??t}function m(e){return String(e??``).trim().split(/\s+/).filter(Boolean).map(e=>c[e.toLowerCase()]??(e.length===1?e.toUpperCase():e)).join(`+`)}function h(e){return!e||e.nodeType!==1?!1:e.isContentEditable||e.closest?.(`[contenteditable=""], [contenteditable="true"], [contenteditable="plaintext-only"]`)||e.tagName===`TEXTAREA`||e.tagName===`SELECT`?!0:e.tagName===`INPUT`?!l.has(String(e.type||`text`).toLowerCase()):u.has(e.getAttribute?.(`role`))}function g(t=typeof document>`u`?null:document){return t?.documentElement?.getAttribute(e)===`off`}function _(e,t){if(!t||e&&t.contains(e))return!0;let n=t.ownerDocument;return(!e||e===n.body||e===n.documentElement)&&n.querySelector(`[data-shortcut-scope]`)===t}function v(e,t,n=null){if(!t||e.defaultPrevented||g(e.target?.ownerDocument??void 0))return!1;let r=f(e);if(!r)return!1;let i=e.target;if(!_(i,n)||h(i))return!1;let a=t[r]??(r.length===1?t[r.toUpperCase()]:void 0);return typeof a!=`function`||r===`enter`&&i?.closest?.(d)?!1:(e.preventDefault(),a(e),!0)}function y(e,t){if(!e.length)return null;let n=e[0].ownerDocument,r=n.activeElement,i=e.findIndex(e=>e===r||e.contains(r));if(i<0&&r&&r!==n.body){let t=r.closest?.(`li, tr`);t&&(i=e.findIndex(e=>t.contains(e)))}i<0&&(i=e.findIndex(e=>e.getAttribute(`aria-current`)===`true`));let a=i<0?t>0?0:e.length-1:Math.min(e.length-1,Math.max(0,i+t));return e[a].focus(),e[a].scrollIntoView?.({block:`nearest`}),e[a]}export{t as a,_ as c,v as d,p as f,n as i,h as l,g as m,a as n,r as o,f as p,e as r,m as s,i as t,y as u};
@@ -0,0 +1 @@
1
+ var e=`image/jpeg,image/png,image/webp,image/heic,image/heif,.heic,.heif`,t=10,n=512,r=`image/webp`,i=[96,48],a={dialogTitle:`Edit photo`,dialogSubtitle:`Drag to position the photo, then zoom or rotate it.`,save:`Save photo`,cancel:`Cancel`,choose:`Upload photo`,change:`Change photo`,camera:`Take photo`,remove:`Remove photo`,unreadable:`That photo could not be opened. Choose a JPG, PNG or WebP image.`,heicUnreadable:`This browser cannot open HEIC photos. Choose a JPG, PNG or WebP image instead.`,cropFailed:`That photo could not be saved. Try again, or choose another one.`};function o(e){if(!e)return!1;let t=String(e.type||``).toLowerCase();return t===`image/heic`||t===`image/heif`||/\.hei[cf]$/i.test(String(e.name||``))}function s(e){return o(e)?a.heicUnreadable:a.unreadable}function c(e,t){let n=Number(t);return{name:e?.name||`photo`,type:r,size:Number.isInteger(n)&&n>0?n:512}}var l=`image/png,image/jpeg,image/webp`,u=5,d={"image/png":[`.png`],"image/jpeg":[`.jpg`,`.jpeg`],"image/webp":[`.webp`],"image/gif":[`.gif`],"image/svg+xml":[`.svg`],"image/heic":[`.heic`],"image/heif":[`.heif`],"application/pdf":[`.pdf`],"text/plain":[`.txt`]},f={"image/png":`PNG`,"image/jpeg":`JPG`,"image/webp":`WEBP`,"image/gif":`GIF`,"image/svg+xml":`SVG`,"image/heic":`HEIC`,"image/heif":`HEIC`,"application/pdf":`PDF`,"text/plain":`text file`,".png":`PNG`,".jpg":`JPG`,".jpeg":`JPG`,".webp":`WEBP`,".gif":`GIF`,".svg":`SVG`,".heic":`HEIC`,".heif":`HEIC`,".pdf":`PDF`,".txt":`text file`},p=e=>String(e||``).split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean),m=[`.png`,`.jpg`,`.jpeg`,`.webp`,`.gif`,`.svg`,`.bmp`,`.avif`,`.heic`,`.heif`];function h(e){if(!e)return!1;let t=typeof e==`object`&&e.type?String(e.type).toLowerCase():``;if(t)return t.startsWith(`image/`);let n=typeof e==`string`?e:e.name||e.url||``,r=String(n).toLowerCase();return m.some(e=>r.endsWith(e))}function g(e){if(!e)return!1;let t=typeof e==`object`&&e.type?String(e.type).toLowerCase():``;if(t)return t===`application/pdf`;let n=typeof e==`string`?e:e.name||e.url||``;return String(n).toLowerCase().split(/[?#]/)[0].endsWith(`.pdf`)}function _(e){let t=p(e);return t.length?t.every(e=>e.startsWith(`.`)?m.includes(e):e===`image/*`||e.startsWith(`image/`)):!1}function v(e){let t=[];for(let n of p(e)){let e=f[n]||(n.startsWith(`.`)?n.slice(1).toUpperCase():n.toUpperCase());t.includes(e)||t.push(e)}return t.length<=1?t[0]||`supported`:`${t.slice(0,-1).join(`, `)} or ${t[t.length-1]}`}function y(e,t){let n=p(t);if(!n.length)return!0;let r=(e.type||``).toLowerCase(),i=(e.name||``).toLowerCase();return n.some(e=>e.startsWith(`.`)?i.endsWith(e):e.endsWith(`/*`)?r.startsWith(e.slice(0,-1)):r&&r===e?!0:!r&&(d[e]||[]).some(e=>i.endsWith(e)))}function b(e,t={}){if(!e)return null;let n=t.accept===void 0?l:t.accept,r=t.maxSizeMb===void 0?5:t.maxSizeMb;if(!y(e,n)){let e=v(n);return`Choose a ${e.endsWith(` file`)?e:`${e} file`}.`}return r>0&&e.size>r*1024*1024?`Keep the file under ${r} MB.`:null}var x=/[0-9]/,S={9:x,A:/[A-Za-z]/,"*":/[0-9A-Za-z]/},C=/[9A*]/,w=new Set([`text`,`tel`,`search`,`url`,`password`]),T=e=>{let t=e.replace(/\D/g,``);return t.length===12&&t.startsWith(`91`)?t.slice(2):t.length===11&&t.startsWith(`0`)?t.slice(1):e},E=e=>{let t=Number(e.slice(0,2)),n=Number(e.slice(2,4)),r=Number(e.slice(4,8));if(r<1)return!1;let i=new Date(Date.UTC(r,n-1,t));return i.getUTCFullYear()===r&&i.getUTCMonth()===n-1&&i.getUTCDate()===t},D=e=>e.length<=3?e:`${e.slice(0,-3).replace(/\B(?=(\d{2})+(?!\d))/g,`,`)},${e.slice(-3)}`,O=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e.trim());return t?`${t[3]}-${t[2]}-${t[1]}`:e};function k(e,{upper:t=!1,normalize:n,valid:r,post:i=e=>e,message:a=`Enter the full value`}={}){let o=[...e].map(e=>S[e]?{re:S[e]}:{lit:e}),s=o.filter(e=>e.re).length;return{inputMode:o.every(e=>!e.re||e.re===x)?`numeric`:`text`,normalize:n,post:i,message:a,extract(e){let n=``,r=0;for(let i of e){for(;r<o.length&&o[r].lit!==void 0&&o[r].lit!==i;)r++;if(r>=o.length)break;let e=o[r];e.lit===void 0?e.re.test(i)&&(n+=t?i.toUpperCase():i,r++):r++}return n},layout(e){let t=``,n=[],r=0;for(let i=0;i<o.length&&r<e.length;i++)o[i].lit===void 0?(t+=e[r++],n.push(!0)):(t+=o[i].lit,n.push(!1));return{text:t,isRaw:n}},isValid:e=>e.length===s&&(!r||r(e))}}function A(){return{inputMode:`decimal`,post:e=>e,message:`Enter a valid amount`,extract(e){let t=``,n=!1,r=0;for(let i of e)x.test(i)?n?r<2&&(t+=i,r++):t+=i:i===`.`&&!n&&(n=!0,t+=i);return t.startsWith(`.`)&&(t=`0${t}`),t.replace(/^0+(?=\d)/,``)},layout(e){let[t,n]=e.split(`.`),r=D(t)+(e.includes(`.`)?`.${n}`:``);return{text:r,isRaw:[...r].map(e=>e!==`,`)}},isValid:e=>/^\d+(\.\d{1,2})?$/.test(e)}}var j={"phone-in":()=>k(`99999 99999`,{normalize:T,valid:e=>/^[6-9]/.test(e),message:`Enter a 10-digit mobile number`}),pan:()=>k(`AAAAA9999A`,{upper:!0,valid:e=>/^[A-Z]{5}\d{4}[A-Z]$/.test(e),message:`Enter a valid PAN`}),gstin:()=>k(`99AAAAA9999A***`,{upper:!0,valid:e=>/^\d{2}[A-Z]{5}\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]$/.test(e),message:`Enter a valid GSTIN`}),aadhaar:()=>k(`9999 9999 9999`,{valid:e=>/^[2-9]/.test(e),message:`Enter a valid 12-digit Aadhaar number`}),ifsc:()=>k(`AAAA*******`,{upper:!0,valid:e=>/^[A-Z]{4}0[A-Z0-9]{6}$/.test(e),message:`Enter a valid IFSC`}),"pin-code":()=>k(`999999`,{valid:e=>/^[1-9]/.test(e),message:`Enter a valid 6-digit PIN code`}),date:()=>k(`99-99-9999`,{normalize:O,valid:E,post:(e,t)=>e.length===8&&E(e)?`${e.slice(4)}-${e.slice(2,4)}-${e.slice(0,2)}`:t,message:`Enter a valid date as DD-MM-YYYY`}),amount:A},M=Object.keys(j),N=e=>{let t=String(e).toLowerCase();return Object.hasOwn(j,t)?t:void 0},ee=e=>C.test(String(e))&&N(e)===void 0,P=new Map;function F(e){if(e==null||e===``)return null;let t=String(e);return P.has(t)||(ee(t)?P.set(t,k(t)):P.set(t,Object.hasOwn(j,t)?j[t]():null)),P.get(t)}var I=(e,t)=>e.normalize?e.normalize(t):t;function te(e,t){let n=F(e);return n?n.extract(I(n,String(t??``))):String(t??``)}function ne(e,t){let n=F(e);if(!n)return String(t??``);let r=n.extract(I(n,String(t??``)));return n.post(r,n.layout(r).text)}function re(e,t){let n=F(e);return n?n.layout(n.extract(I(n,String(t??``)))).text:String(t??``)}var ie=(e,t)=>{if(t<=0)return 0;let n=0;for(let r=0;r<e.length;r++)if(e[r]&&++n===t)return r+1;return e.length},L=new WeakMap,ae=e=>L.get(e)?.(),oe=new WeakMap;function se(e,t,n,r){let i=e.getAll(t),a=oe.get(e);a||oe.set(e,a=new Set);let o=i.findIndex((e,r)=>e===n&&!a.has(`${t}\u0000${r}`));if(!(o<0)){if(a.add(`${t}\u0000${o}`),i[o]=r,i.length===1){e.set(t,r);return}e.delete(t);for(let n of i)e.append(t,n)}}function ce(e){let t=null,n=null,r=!1,i=(t,n)=>n===null?e.removeAttribute(t):e.setAttribute(t,n),a,o,s=()=>{t?.remove(),t=null,n&&(n.hidden=!1),n=null,r&&e.classList.remove(`error`),r=!1,a!==void 0&&i(`aria-invalid`,a),o!==void 0&&i(`aria-describedby`,o),a=void 0,o=void 0};return i=>{if(!i){s();return}let c=e.closest(`.field`),l=c?.querySelector(`.field-error`);l&&l!==t&&l.textContent.trim()||(t||(r=!e.classList.contains(`error`),e.classList.add(`error`),a=e.getAttribute(`aria-invalid`),o=e.getAttribute(`aria-describedby`),c&&(t=document.createElement(`div`),t.className=`field-error`,e.id&&(t.id=`${e.id}-error`),n=c.querySelector(`.field-hint`),n&&(n.hidden=!0),c.insertBefore(t,[...c.children].find(e=>e.classList.contains(`field-count`))??null),t.id&&e.setAttribute(`aria-describedby`,t.id)),e.setAttribute(`aria-invalid`,`true`)),t&&(t.textContent=i))}}function le(e,{mask:t,postFormatted:n=!1,onChange:r,onInvalidChange:i}={}){let a=F(t);if(!a||!w.has(e.type))return()=>{};let o=Object.getPrototypeOf(e),s=Object.getOwnPropertyDescriptor(o,`value`).set,c=!e.hasAttribute(`inputmode`);c&&e.setAttribute(`inputmode`,a.inputMode);let l=i??ce(e),u=null,d=!1,f=!1,p=!1,m=``,h=``,g,_=()=>{let e=p?m:``;e!==h&&(h=e,l(h))},v=(t,n,i)=>{let o=a.extract(t.slice(0,n)).length,c=a.extract(t),{text:l,isRaw:d}=a.layout(c);if(e.value!==l&&(s.call(e,l),document.activeElement===e&&w.has(e.type))){let t=ie(d,o);e.setSelectionRange(t,t)}e.dataset.maskRaw=c,m=c&&!a.isValid(c)?a.message:``,e.setCustomValidity(m),_(),i&&c!==u&&r?.(c,l),u=c},y=Object.getOwnPropertyDescriptor(e,`value`),b=y??Object.getOwnPropertyDescriptor(o,`value`);Object.defineProperty(e,"value",{configurable:!0,enumerable:b.enumerable,get:()=>b.get.call(e),set:t=>{if(b.set.call(e,t),f)return;let n=I(a,e.value);v(n,n.length,!0)}});let x=()=>{d=!0,e.dispatchEvent(new Event(`input`,{bubbles:!0})),d=!1},S=t=>{if(d||f||t.isComposing)return;let n=t.inputType===`insertText`&&(t.data?.length??0)<=1||t.inputType?.startsWith(`delete`)?e.value:I(a,e.value);v(n,e.selectionStart??n.length,!0)},C=()=>{f=!0},T=()=>{f=!1;let t=I(a,e.value);v(t,e.selectionStart??t.length,!0),x()},E=t=>{let n=t.inputType===`deleteContentBackward`;if(!n&&t.inputType!==`deleteContentForward`||t.isComposing)return;let r=e.selectionStart;if(r==null||r!==e.selectionEnd)return;let{isRaw:i}=a.layout(a.extract(e.value)),o=n?r-1:r;for(;o>=0&&o<i.length&&!i[o];)o+=n?-1:1;o!==(n?r-1:r)&&(t.preventDefault(),!(o<0||o>=i.length)&&(v(e.value.slice(0,o)+e.value.slice(o+1),n?o:r,!0),x()))},D=t=>{if(e.readOnly||e.disabled)return;let n=t.clipboardData?.getData(`text`);if(n==null)return;t.preventDefault();let r=I(a,n),i=e.selectionStart??e.value.length,o=e.selectionEnd??i;v(e.value.slice(0,i)+r+e.value.slice(o),i+r.length,!0),x()},O=()=>{let t=a.extract(e.value);return a.post(t,a.layout(t).text)},k=()=>{p=!0,_()};e.addEventListener(`input`,S),e.addEventListener(`beforeinput`,E),e.addEventListener(`paste`,D),e.addEventListener(`compositionstart`,C),e.addEventListener(`compositionend`,T),e.addEventListener(`blur`,k),e.addEventListener(`invalid`,k);let A=e.form,j=t=>{e.name&&!e.disabled&&se(t.formData,e.name,e.value,O())},M=()=>{clearTimeout(g),g=setTimeout(()=>{p=!1,v(I(a,e.value),e.value.length,!0)},0)};n||(A?.addEventListener(`formdata`,j),L.set(e,O)),A?.addEventListener(`reset`,M),A?.addEventListener(`submit`,k);let N=I(a,e.value);return v(N,N.length,!1),()=>{clearTimeout(g),e.removeEventListener(`input`,S),e.removeEventListener(`beforeinput`,E),e.removeEventListener(`paste`,D),e.removeEventListener(`compositionstart`,C),e.removeEventListener(`compositionend`,T),e.removeEventListener(`blur`,k),e.removeEventListener(`invalid`,k),A?.removeEventListener(`formdata`,j),A?.removeEventListener(`reset`,M),A?.removeEventListener(`submit`,k),L.delete(e),y?Object.defineProperty(e,"value",y):delete e.value,p=!1,m=``,_(),e.setCustomValidity(``),delete e.dataset.maskRaw,c&&e.removeAttribute(`inputmode`)}}function ue(){let e=typeof window>`u`?void 0:window.jQuery?.validator?.prototype;if(!e||e.wuiMaskHook)return;let t=e.elementValue;e.elementValue=function(e){let n=ae(e);return n===void 0?t.call(this,e):n},e.wuiMaskHook=!0}var R=new WeakMap,z,de=e=>{R.has(e)||R.set(e,le(e,{mask:e.dataset.appMask,postFormatted:e.hasAttribute(`data-mask-post-formatted`)}))},B=e=>e.nodeType===1?[...e.matches(`input[data-app-mask]`)?[e]:[],...e.querySelectorAll(`input[data-app-mask]`)]:[];function fe(){z||typeof MutationObserver>`u`||(z=new MutationObserver(e=>{for(let t of e){for(let e of t.removedNodes)for(let t of B(e))R.get(t)?.(),R.delete(t);for(let e of t.addedNodes)for(let t of B(e))de(t)}}),z.observe(document.documentElement,{childList:!0,subtree:!0}))}function pe(e=document){ue();for(let t of e.querySelectorAll(`input[data-app-mask]`))de(t);e===document&&fe()}var V={minLength:10,uppercase:!0,lowercase:!0,digit:!0,special:!0,uniqueChars:0,customRules:[]},me=`Password requirements`;function he(e){return e===!0||e==null?{...V}:{...V,...e}}function H(e){let t=he(e),n=[];if(t.minLength>0&&n.push({key:`length`,label:`At least ${t.minLength} characters long`,test:e=>e.length>=t.minLength}),t.uppercase&&n.push({key:`uppercase`,label:`At least one uppercase letter`,test:e=>/[A-Z]/.test(e)}),t.lowercase&&n.push({key:`lowercase`,label:`At least one lowercase letter`,test:e=>/[a-z]/.test(e)}),t.digit&&n.push({key:`digit`,label:`At least one digit`,test:e=>/[0-9]/.test(e)}),t.special&&n.push({key:`special`,label:`At least one special character`,test:e=>/[^A-Za-z0-9]/.test(e)}),t.uniqueChars>0){let e=t.uniqueChars;n.push({key:`unique`,label:`At least ${e} unique character${e>1?`s`:``}`,test:t=>new Set(t).size>=e})}for(let[e,r]of(t.customRules??[]).entries()){let t=new RegExp(r.pattern);n.push({key:`custom-${e}`,label:r.label,test:e=>t.test(e)})}return n}function U(e,t){let n=e==null?``:String(e);return H(t).map(e=>({key:e.key,label:e.label,met:e.test(n)}))}function ge(e,t){return U(e,t).every(e=>e.met)}var W=`.table-wrap, .table-responsive, [class*="table-responsive-"]`,G=1;function _e(e){let t=()=>{let t=e.scrollWidth-e.clientWidth,n=Math.abs(e.scrollLeft);e.toggleAttribute(`data-wui-overflow-start`,t>G&&n>G),e.toggleAttribute(`data-wui-overflow-end`,t>G&&n<t-G),e.toggleAttribute(`data-wui-overflow-top`,e.scrollTop>G)};e.addEventListener(`scroll`,t,{passive:!0});let n=null;if(typeof ResizeObserver<`u`){n=new ResizeObserver(t),n.observe(e);for(let t of e.children)n.observe(t)}return t(),()=>{e.removeEventListener(`scroll`,t),n?.disconnect(),e.removeAttribute(`data-wui-overflow-start`),e.removeAttribute(`data-wui-overflow-end`),e.removeAttribute(`data-wui-overflow-top`)}}var K=new WeakMap,q,ve=e=>{K.has(e)||K.set(e,_e(e))},ye=e=>e.nodeType===1?[...e.matches(`.table-wrap, .table-responsive, [class*="table-responsive-"]`)?[e]:[],...e.querySelectorAll(W)]:[];function be(){q||typeof MutationObserver>`u`||(q=new MutationObserver(e=>{for(let t of e){for(let e of t.removedNodes)for(let t of ye(e))K.get(t)?.(),K.delete(t);for(let e of t.addedNodes)for(let t of ye(e))ve(t)}}),q.observe(document.documentElement,{childList:!0,subtree:!0}))}function xe(e=document){for(let t of e.querySelectorAll(W))ve(t);e===document&&be()}var Se=[`light`,`dark`,`auto`],Ce=[`wave`,`circle`,`slide`,`blinds`,`fade`,`none`],we=`wave`,J=`theme`,Y={wave:1100,circle:700,slide:600,blinds:900,fade:350,none:0},X=`wui-theme-switching`,Te=`wui:theme:change`,Ee=`wui-theme-toggle`,De=`(prefers-color-scheme: dark)`,Oe=e=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(e).matches,ke=e=>Se.includes(e);function Ae(e){return e===`dark`||e===`auto`&&Oe(De)?`dark`:`light`}function je(e=J){let t=null;try{t=window.localStorage.getItem(e)}catch{}return ke(t)?t:`auto`}function Me(e,t=J){try{window.localStorage.setItem(t,e)}catch{}}function Ne(e){let t=document.documentElement,n=Ae(e);t.setAttribute(`data-theme`,e),t.setAttribute(`data-bs-theme`,n),document.dispatchEvent(new CustomEvent(Te,{detail:{mode:n,preference:e}}))}var Pe=`(function(k){var m;try{m=localStorage.getItem(k)}catch{}if(m!=='light'&&m!=='dark')m='auto';var r=document.documentElement,q=window.matchMedia?window.matchMedia('(prefers-color-scheme: dark)'):null;function s(){var t=r.getAttribute('data-theme');r.setAttribute('data-bs-theme',t==='auto'?(q&&q.matches?'dark':'light'):t)}r.setAttribute('data-theme',m);s();if(q&&q.addEventListener)q.addEventListener('change',function(){if(r.getAttribute('data-theme')==='auto')s()})})(`;function Fe(e=J){return`${Pe}${JSON.stringify(String(e)).replace(/</g,`\\u003c`)})`}function Ie(e,{includeAuto:t=!1}={}){return e===`light`?`dark`:e===`dark`&&t?`auto`:`light`}function Le(e){if(typeof window>`u`||typeof window.matchMedia!=`function`)return()=>{};let t=window.matchMedia(De),n=()=>e(t.matches?`dark`:`light`);return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)}var Re=60,ze=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,Z=e=>e.toFixed(1),Q=(e,t)=>`${Z(e)}px ${Z(t)}px`,Be={amplitude:22,segments:36,cycles:1.5,ripples:2},Ve=6,He=(e,t,n,r,i)=>{let{amplitude:a,segments:o,cycles:s}=Be,c=n*(t+2*a),l=i?t+a-c:c-a,u=i?t+2*a:-2*a,d=[Q(0,u)];for(let t=0;t<=o;t++){let n=e*t/o,i=l+a*Math.sin(2*Math.PI*s*t/o+r);d.push(Q(n,i))}return d.push(Q(e,u)),`polygon(${d.join(`, `)})`},Ue=(e,t,n,r)=>{let i=t/Ve,a=[];for(let t=0;t<Ve;t++){let o=t*i,s=i*n,c=r?o+i-s:o,l=r?o+i:o+s;a.push(Q(0,c),Q(e,c),Q(e,l),Q(0,l))}return`polygon(${a.join(`, `)})`};function $(e,{width:t,height:n,to:r=`dark`,origin:i}={}){let a=r===`dark`,o=[];for(let r=0;r<=Re;r++){let s=r/Re,c=ze(s);switch(e){case`circle`:{let e=i?.x??t/2,r=i?.y??n/2,a=Math.hypot(Math.max(e,t-e),Math.max(r,n-r));o.push({clipPath:`circle(${Z(a*c)}px at ${Z(e)}px ${Z(r)}px)`});break}case`slide`:{let e=n*(1-c);o.push({clipPath:a?`inset(${Z(e)}px 0px 0px 0px)`:`inset(0px 0px ${Z(e)}px 0px)`});break}case`blinds`:o.push({clipPath:Ue(t,n,c,a)});break;case`fade`:o.push({clipPath:`none`,opacity:c});break;case`none`:return[];default:o.push({clipPath:He(t,n,c,s*Be.ripples*2*Math.PI,a)})}}return o}function We(e,{effect:t=we,to:n,origin:r,duration:i,live:a}={}){let o=document.documentElement,s=n!==void 0&&o.getAttribute(`data-bs-theme`)===n;if(t===`none`||s||Oe(`(prefers-reduced-motion: reduce)`)||typeof document.startViewTransition!=`function`||typeof o.animate!=`function`)return e(),Promise.resolve(!1);o.classList.add(X);let c=a instanceof Element?a:null;c&&(c.style.viewTransitionName=Ee);let l=document.startViewTransition(e),u=i??Y[t]??Y.wave;return l.ready.then(()=>{let e=$(t,{width:window.innerWidth,height:window.innerHeight,to:n,origin:r});o.animate(e,{duration:u,easing:`linear`,fill:`both`,pseudoElement:`::view-transition-new(root)`})}).catch(()=>{}),l.finished.catch(()=>{}).then(()=>(o.classList.remove(X),c&&(c.style.viewTransitionName=``),!0))}export{o as $,re as A,h as B,me as C,w as D,ge as E,te as F,e as G,g as H,F as I,r as J,t as K,l as L,ee as M,ae as N,M as O,ne as P,s as Q,u as R,V as S,U as T,y as U,_ as V,b as W,a as X,i as Y,c as Z,We as _,Ce as a,_e as b,Se as c,Ie as d,je as f,$ as g,Fe as h,Te as i,pe as j,le as k,X as l,Me as m,J as n,Y as o,Ae as p,n as q,Pe as r,Ee as s,we as t,Ne as u,Le as v,H as w,xe as x,W as y,v as z};
@@ -64,9 +64,9 @@ export type ChatStreamOptions = {
64
64
  /**
65
65
  * Called for each event
66
66
  * before the end of the turn: `delta { text }` to append, `reset {}` to discard what was shown,
67
- * `actions { actions }` for support cards.
67
+ * `tool { toolName }` when the assistant starts a tool (the name only), `actions { actions }` for support cards.
68
68
  */
69
- onEvent?: (name: "delta" | "reset" | "actions", data: any) => void;
69
+ onEvent?: (name: "delta" | "reset" | "tool" | "actions", data: any) => void;
70
70
  };
71
71
  export type ChatTurnResult = {
72
72
  conversationId: string;
@@ -151,9 +151,9 @@ export type ChatClient = {
151
151
  /**
152
152
  * @typedef {object} ChatStreamOptions
153
153
  * @property {AbortSignal} [signal] Cancels the request.
154
- * @property {(name: "delta"|"reset"|"actions", data: any) => void} [onEvent] Called for each event
154
+ * @property {(name: "delta"|"reset"|"tool"|"actions", data: any) => void} [onEvent] Called for each event
155
155
  * before the end of the turn: `delta { text }` to append, `reset {}` to discard what was shown,
156
- * `actions { actions }` for support cards.
156
+ * `tool { toolName }` when the assistant starts a tool (the name only), `actions { actions }` for support cards.
157
157
  */
158
158
  /**
159
159
  * @typedef {object} ChatTurnResult The `done` event: the turn's outcome of record.
@@ -4,7 +4,7 @@ function e(e){let t=``;function n(t){let n=`message`,r=[];for(let e of t.split(`
4
4
  `).replace(/\r(?!$)/g,`
5
5
  `);let r=t.split(`
6
6
 
7
- `);t=r.pop();for(let e of r)n(e)},end(){let e=t.replace(/\r$/,``);t=``,e.trim()&&n(e)}}}var t=`Something went wrong. Please try again.`,n=class extends Error{constructor(e,t,n,r=null){super(t),this.name=`ChatApiError`,this.code=e,this.status=n,this.resetsAtUtc=r}};function r(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return e??null}function i(e,t){return t?.aborted||e?.code===`ERR_CANCELED`||e?.name===`CanceledError`||e?.name===`AbortError`}function a(e,a){if(e instanceof n)return e;if(i(e,a))return new n(`aborted`,`The request was cancelled.`);let o=e?.response;if(!o)return new n(`network`,t);let s=r(o.data),c=typeof s?.code==`string`&&s.code?s.code:`unknown`,l=typeof s?.message==`string`&&s.message?s.message:t,u=typeof s?.resetsAtUtc==`string`?s.resetsAtUtc:null;return new n(c,l,o.status,u)}async function o(e){try{return(await e()).data}catch(e){throw a(e)}}function s(e){let t=e?.event?.target;if(!(!t||typeof t.responseText!=`string`)&&!(typeof t.status==`number`&&(t.status<200||t.status>=300)))return t.responseText}function c(r,{base:i}){if(typeof i!=`string`||i.trim()===``)throw TypeError(`createChatClient needs a base path, e.g. { base: "/api/assistant" }.`);let c=i.replace(/\/+$/,``),l=e=>`${c}/conversations/${encodeURIComponent(e)}`;async function u({message:i,conversationId:o,pageContext:l},{signal:u,onEvent:d}={}){let f=null,p=null,m=e(({name:e,data:t})=>{f||p||(e===`done`?f=t:e===`error`?p=t:(e===`delta`||e===`reset`||e===`actions`)&&d?.(e,t))}),h=0,g=e=>{typeof e!=`string`||e.length<=h||(m.push(e.slice(h)),h=e.length)},_={message:i};o&&(_.conversationId=o),l!=null&&(_.pageContext=l);let v;try{v=await r.post(`${c}/chat`,_,{responseType:`text`,headers:{Accept:`text/event-stream`},signal:u,onDownloadProgress:e=>g(s(e))})}catch(e){throw a(e,u)}if(g(v.data),m.end(),p)throw new n(p.code||`unknown`,p.message||t);if(!f)throw new n(`invalid-response`,t,v.status);return f}return{sendMessage:u,getAllowance:()=>o(()=>r.get(`${c}/allowance`)),listConversations:({skip:e,take:t}={})=>{let n=new URLSearchParams;e!=null&&n.append(`skip`,String(e)),t!=null&&n.append(`take`,String(t));let i=n.toString();return o(()=>r.get(`${c}/conversations${i?`?${i}`:``}`))},getConversation:e=>o(()=>r.get(l(e))),deleteConversation:async e=>{await o(()=>r.delete(l(e)))},rateMessage:async(e,t,{rating:n,note:i})=>{let a=typeof i==`string`?i.trim():``;await o(()=>r.put(`${l(e)}/messages/${encodeURIComponent(t)}/rating`,{rating:n,note:a||null}))}}}var l=Object.freeze({launcher:`Ask the assistant`,panelTitle:`Assistant`,newChat:`New chat`,close:`Close`,thread:`Conversation`,you:`You`,assistant:`Assistant`,thinking:`Thinking`,emptyTitle:`How can I help?`,emptyText:`Ask a question about what you see on this page.`,composer:`Your question`,placeholder:`Ask a question`,send:`Send`,composerHint:`Press Enter to send, Shift and Enter for a new line.`,allowance:e=>e===0?`You have no questions left today.`:e===1?`You have 1 question left today.`:`You have ${e} questions left today.`,disclaimer:`Answers are written by AI and can be wrong. Check anything important.`,loadingConversation:`Loading the conversation`,rateUp:`Helpful`,rateDown:`Not helpful`,rated:`Thanks for the feedback.`,ratingNote:`What was wrong with this answer?`,ratingNoteHint:`Optional.`,ratingNoteSend:`Send`,ratingNoteSkip:`Skip`,ratingFailed:`Your rating did not save. Please try again.`,actionRaiseTicket:`New support ticket`,actionReply:e=>`Reply on ${e}`,actionReopen:e=>`Reopen ${e}`,actionNote:`Nothing is sent until you confirm.`,actionConfirm:`Confirm`,actionDismiss:`Not now`,actionDismissed:`Not sent.`,actionExpired:`This request expired and was not sent. Ask again if you still need it.`,actionFailed:`We could not send this. Please try again.`,actionDoneRaiseTicket:e=>`Ticket ${e} raised.`,actionDoneReply:e=>`Your reply was added to ${e}.`,actionDoneReopen:e=>`${e} is open again.`,viewTicket:`View ticket`,conversations:`Past chats`,conversationsEmptyTitle:`No past chats`,conversationsEmptyText:`Your conversations with the assistant show here.`,untitled:`Untitled chat`,deleteConversation:`Delete chat`,deleteConfirmTitle:`Delete this chat?`,deleteConfirmMessage:`The conversation is removed for good.`,deleteConfirm:`Delete`,deleteFailed:`We could not delete this chat. Please try again.`,cancel:`Cancel`,loadMore:`Show more`,loadFailed:`We could not load your chats. Please try again.`,retry:`Try again`});function u(e){return e?{...l,...e}:l}var d=/^[a-z][a-z0-9+.-]*:[a-z0-9_-]+\/[a-z0-9_.~-]+$/i,f=/^\s*```/,p=/^\s*[-*+]\s+(.*)$/,m=/^\s*(\d{1,9})[.)]\s+(.*)$/,h=/^\s{0,3}#{1,6}\s+(.*?)\s*#*\s*$/,g=/^\s*([-*_])(\s*\1){2,}\s*$/,_=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/,v=e=>e.includes(`|`);function y(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function b(e,t){return v(e[t])&&t+1<e.length&&_.test(e[t+1])}function x(e,t){let n=e[t];return f.test(n)||p.test(n)||m.test(n)||h.test(n)||g.test(n)||b(e,t)}function S(e){let t=String(e??``).replace(/\r\n?/g,`
7
+ `);t=r.pop();for(let e of r)n(e)},end(){let e=t.replace(/\r$/,``);t=``,e.trim()&&n(e)}}}var t=`Something went wrong. Please try again.`,n=class extends Error{constructor(e,t,n,r=null){super(t),this.name=`ChatApiError`,this.code=e,this.status=n,this.resetsAtUtc=r}};function r(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return e??null}function i(e,t){return t?.aborted||e?.code===`ERR_CANCELED`||e?.name===`CanceledError`||e?.name===`AbortError`}function a(e,a){if(e instanceof n)return e;if(i(e,a))return new n(`aborted`,`The request was cancelled.`);let o=e?.response;if(!o)return new n(`network`,t);let s=r(o.data),c=typeof s?.code==`string`&&s.code?s.code:`unknown`,l=typeof s?.message==`string`&&s.message?s.message:t,u=typeof s?.resetsAtUtc==`string`?s.resetsAtUtc:null;return new n(c,l,o.status,u)}async function o(e){try{return(await e()).data}catch(e){throw a(e)}}function s(e){let t=e?.event?.target;if(!(!t||typeof t.responseText!=`string`)&&!(typeof t.status==`number`&&(t.status<200||t.status>=300)))return t.responseText}function c(r,{base:i}){if(typeof i!=`string`||i.trim()===``)throw TypeError(`createChatClient needs a base path, e.g. { base: "/api/assistant" }.`);let c=i.replace(/\/+$/,``),l=e=>`${c}/conversations/${encodeURIComponent(e)}`;async function u({message:i,conversationId:o,pageContext:l},{signal:u,onEvent:d}={}){let f=null,p=null,m=e(({name:e,data:t})=>{f||p||(e===`done`?f=t:e===`error`?p=t:(e===`delta`||e===`reset`||e===`tool`||e===`actions`)&&d?.(e,t))}),h=0,g=e=>{typeof e!=`string`||e.length<=h||(m.push(e.slice(h)),h=e.length)},_={message:i};o&&(_.conversationId=o),l!=null&&(_.pageContext=l);let v;try{v=await r.post(`${c}/chat`,_,{responseType:`text`,headers:{Accept:`text/event-stream`},signal:u,onDownloadProgress:e=>g(s(e))})}catch(e){throw a(e,u)}if(g(v.data),m.end(),p)throw new n(p.code||`unknown`,p.message||t);if(!f)throw new n(`invalid-response`,t,v.status);return f}return{sendMessage:u,getAllowance:()=>o(()=>r.get(`${c}/allowance`)),listConversations:({skip:e,take:t}={})=>{let n=new URLSearchParams;e!=null&&n.append(`skip`,String(e)),t!=null&&n.append(`take`,String(t));let i=n.toString();return o(()=>r.get(`${c}/conversations${i?`?${i}`:``}`))},getConversation:e=>o(()=>r.get(l(e))),deleteConversation:async e=>{await o(()=>r.delete(l(e)))},rateMessage:async(e,t,{rating:n,note:i})=>{let a=typeof i==`string`?i.trim():``;await o(()=>r.put(`${l(e)}/messages/${encodeURIComponent(t)}/rating`,{rating:n,note:a||null}))}}}var l=Object.freeze({launcher:`Ask the assistant`,panelTitle:`Assistant`,newChat:`New chat`,close:`Close`,thread:`Conversation`,you:`You`,assistant:`Assistant`,thinking:`Thinking`,emptyTitle:`How can I help?`,emptyText:`Ask a question about what you see on this page.`,composer:`Your question`,placeholder:`Ask a question`,send:`Send`,composerHint:`Press Enter to send, Shift and Enter for a new line.`,allowance:e=>e===0?`You have no questions left today.`:e===1?`You have 1 question left today.`:`You have ${e} questions left today.`,disclaimer:`Answers are written by AI and can be wrong. Check anything important.`,loadingConversation:`Loading the conversation`,rateUp:`Helpful`,rateDown:`Not helpful`,rated:`Thanks for the feedback.`,ratingNote:`What was wrong with this answer?`,ratingNoteHint:`Optional.`,ratingNoteSend:`Send`,ratingNoteSkip:`Skip`,ratingFailed:`Your rating did not save. Please try again.`,actionRaiseTicket:`New support ticket`,actionReply:e=>`Reply on ${e}`,actionReopen:e=>`Reopen ${e}`,actionNote:`Nothing is sent until you confirm.`,actionConfirm:`Confirm`,actionDismiss:`Not now`,actionDismissed:`Not sent.`,actionExpired:`This request expired and was not sent. Ask again if you still need it.`,actionFailed:`We could not send this. Please try again.`,actionDoneRaiseTicket:e=>`Ticket ${e} raised.`,actionDoneReply:e=>`Your reply was added to ${e}.`,actionDoneReopen:e=>`${e} is open again.`,viewTicket:`View ticket`,conversations:`Past chats`,conversationsEmptyTitle:`No past chats`,conversationsEmptyText:`Your conversations with the assistant show here.`,untitled:`Untitled chat`,deleteConversation:`Delete chat`,deleteConfirmTitle:`Delete this chat?`,deleteConfirmMessage:`The conversation is removed for good.`,deleteConfirm:`Delete`,deleteFailed:`We could not delete this chat. Please try again.`,cancel:`Cancel`,loadMore:`Show more`,loadFailed:`We could not load your chats. Please try again.`,retry:`Try again`});function u(e){return e?{...l,...e}:l}var d=/^[a-z][a-z0-9+.-]*:[a-z0-9_-]+\/[a-z0-9_.~-]+$/i,f=/^\s*```/,p=/^\s*[-*+]\s+(.*)$/,m=/^\s*(\d{1,9})[.)]\s+(.*)$/,h=/^\s{0,3}#{1,6}\s+(.*?)\s*#*\s*$/,g=/^\s*([-*_])(\s*\1){2,}\s*$/,_=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/,v=e=>e.includes(`|`);function y(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function b(e,t){return v(e[t])&&t+1<e.length&&_.test(e[t+1])}function x(e,t){let n=e[t];return f.test(n)||p.test(n)||m.test(n)||h.test(n)||g.test(n)||b(e,t)}function S(e){let t=String(e??``).replace(/\r\n?/g,`
8
8
  `).split(`
9
9
  `),n=[],r=0;for(;r<t.length;){let e=t[r];if(!e.trim()){r+=1;continue}if(f.test(e)){let e=[];for(r+=1;r<t.length&&!f.test(t[r]);)e.push(t[r]),r+=1;r+=1,n.push({type:`code`,text:e.join(`
10
10
  `)});continue}if(b(t,r)){let i=y(e),a=[];for(r+=2;r<t.length&&t[r].trim()&&v(t[r]);)a.push(y(t[r])),r+=1;n.push({type:`table`,header:i,rows:a});continue}if(g.test(e)){n.push({type:`rule`}),r+=1;continue}let i=h.exec(e);if(i){n.push({type:`heading`,text:i[1]}),r+=1;continue}let a=m.exec(e);if(a||p.test(e)){let e=!!a,i=e?m:p,o=[];for(;r<t.length&&t[r].trim();){let n=i.exec(t[r]);if(n)o.push(e?n[2]:n[1]);else if(x(t,r))break;else o[o.length-1]+=` ${t[r].trim()}`;r+=1}n.push({type:`list`,ordered:e,start:e?Number(a[1]):1,items:o});continue}let o=[e];for(r+=1;r<t.length&&t[r].trim()&&!x(t,r);)o.push(t[r]),r+=1;n.push({type:`paragraph`,lines:o})}return n.map((e,t)=>({...e,key:t}))}var C=e=>!!e&&/[\p{L}\p{N}]/u.test(e);function w(e,t,n){let r=e.indexOf(n,t);for(;r!==-1;){let i=e.slice(t,r),a=n.length===1&&(e[r+1]===n||e[r-1]===n),o=n[0]===`_`&&C(e[r+n.length]);if(i.trim()&&!/^\s/.test(i)&&!/\s$/.test(i)&&!a&&!o)return r;r=e.indexOf(n,r+1)}return-1}function T(e){let t=[],n=``,r=()=>{n&&t.push({type:`text`,text:n}),n=``},i=0;for(;i<e.length;){let a=e[i];if(a==="`"){let n=e.indexOf("`",i+1);if(n>i+1){r(),t.push({type:`code`,text:e.slice(i+1,n)}),i=n+1;continue}}if((a===`*`||a===`_`)&&e[i+1]===a){let o=a+a,s=w(e,i+2,o);if(s!==-1&&!(a===`_`&&C(e[i-1]))){r(),t.push({type:`strong`,children:T(e.slice(i+2,s))}),i=s+2;continue}n+=o,i+=2;continue}if(a===`*`||a===`_`){let n=w(e,i+1,a);if(n!==-1&&!(a===`_`&&C(e[i-1]))){r(),t.push({type:`em`,children:T(e.slice(i+1,n))}),i=n+1;continue}}if(a===`[`){let n=/^\[([^\]\n]+)\]\(([^)\s]+)\)/.exec(e.slice(i));if(n){r(),t.push({type:`link`,href:n[2],children:T(n[1])}),i+=n[0].length;continue}}n+=a,i+=1}return r(),t.map((e,t)=>({...e,key:t}))}function E(e,t){if(!t||!d.test(e))return null;let n=t(e);return typeof n==`string`&&n.startsWith(`/`)&&!n.startsWith(`//`)?n:null}export{n as ChatApiError,l as DEFAULT_CHAT_LABELS,c as createChatClient,e as createSseParser,E as linkRoute,u as mergeLabels,S as parseBlocks,T as parseInline};