@epam/statgpt-conversation-list 0.1.0-rc.2 → 0.1.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -0
- package/index.js +3 -6
- package/index.mjs +1156 -3941
- package/models/conversation-list.d.ts +1 -1
- package/package.json +4 -4
- package/utils/shared-conversations.d.ts +1 -1
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './models/titles';
|
|
2
2
|
export * from './types/action-menu-item';
|
|
3
|
+
export * from './utils/shared-conversations';
|
|
3
4
|
export { ConversationList } from './components/ConversationList/ConversationList';
|
|
4
5
|
export { ActionMenu } from './components/ActionMenu/ActionMenu';
|
package/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
* tabbable 6.2.0
|
|
3
|
-
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
4
|
-
*/var lo=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],at=lo.join(","),$n=typeof Element>"u",Ve=$n?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,ct=!$n&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e==null?void 0:e.ownerDocument},ut=function e(t,n){var r;n===void 0&&(n=!0);var o=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),i=o===""||o==="true",c=i||n&&t&&e(t.parentNode);return c},ao=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},Un=function(t,n,r){if(ut(t))return[];var o=Array.prototype.slice.apply(t.querySelectorAll(at));return n&&Ve.call(t,at)&&o.unshift(t),o=o.filter(r),o},Vn=function e(t,n,r){for(var o=[],i=Array.from(t);i.length;){var c=i.shift();if(!ut(c,!1))if(c.tagName==="SLOT"){var f=c.assignedElements(),s=f.length?f:c.children,l=e(s,!0,r);r.flatten?o.push.apply(o,l):o.push({scopeParent:c,candidates:l})}else{var a=Ve.call(c,at);a&&r.filter(c)&&(n||!t.includes(c))&&o.push(c);var u=c.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(c),d=!ut(u,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(c));if(u&&d){var h=e(u===!0?c.children:u.children,!0,r);r.flatten?o.push.apply(o,h):o.push({scopeParent:c,candidates:h})}else i.unshift.apply(i,c.children)}}return o},Hn=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Wn=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||ao(t))&&!Hn(t)?0:t.tabIndex},co=function(t,n){var r=Wn(t);return r<0&&n&&!Hn(t)?0:r},uo=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},zn=function(t){return t.tagName==="INPUT"},fo=function(t){return zn(t)&&t.type==="hidden"},ho=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},mo=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},po=function(t){if(!t.name)return!0;var n=t.form||ct(t),r=function(f){return n.querySelectorAll('input[type="radio"][name="'+f+'"]')},o;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")o=r(window.CSS.escape(t.name));else try{o=r(t.name)}catch(c){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",c.message),!1}var i=mo(o,t.form);return!i||i===t},go=function(t){return zn(t)&&t.type==="radio"},bo=function(t){return go(t)&&!po(t)},wo=function(t){var n,r=t&&ct(t),o=(n=r)===null||n===void 0?void 0:n.host,i=!1;if(r&&r!==t){var c,f,s;for(i=!!((c=o)!==null&&c!==void 0&&(f=c.ownerDocument)!==null&&f!==void 0&&f.contains(o)||t!=null&&(s=t.ownerDocument)!==null&&s!==void 0&&s.contains(t));!i&&o;){var l,a,u;r=ct(o),o=(l=r)===null||l===void 0?void 0:l.host,i=!!((a=o)!==null&&a!==void 0&&(u=a.ownerDocument)!==null&&u!==void 0&&u.contains(o))}}return i},rn=function(t){var n=t.getBoundingClientRect(),r=n.width,o=n.height;return r===0&&o===0},xo=function(t,n){var r=n.displayCheck,o=n.getShadowRoot;if(getComputedStyle(t).visibility==="hidden")return!0;var i=Ve.call(t,"details>summary:first-of-type"),c=i?t.parentElement:t;if(Ve.call(c,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="legacy-full"){if(typeof o=="function"){for(var f=t;t;){var s=t.parentElement,l=ct(t);if(s&&!s.shadowRoot&&o(s)===!0)return rn(t);t.assignedSlot?t=t.assignedSlot:!s&&l!==t.ownerDocument?t=l.host:t=s}t=f}if(wo(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return rn(t);return!1},Eo=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var o=n.children.item(r);if(o.tagName==="LEGEND")return Ve.call(n,"fieldset[disabled] *")?!0:!o.contains(t)}return!0}n=n.parentElement}return!1},kt=function(t,n){return!(n.disabled||ut(n)||fo(n)||xo(n,t)||ho(n)||Eo(n))},jt=function(t,n){return!(bo(n)||Wn(n)<0||!kt(t,n))},yo=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Ro=function e(t){var n=[],r=[];return t.forEach(function(o,i){var c=!!o.scopeParent,f=c?o.scopeParent:o,s=co(f,c),l=c?e(o.candidates):f;s===0?c?n.push.apply(n,l):n.push(f):r.push({documentOrder:i,tabIndex:s,item:o,isScope:c,content:l})}),r.sort(uo).reduce(function(o,i){return i.isScope?o.push.apply(o,i.content):o.push(i.content),o},[]).concat(n)},Et=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Vn([t],n.includeContainer,{filter:jt.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:yo}):r=Un(t,n.includeContainer,jt.bind(null,n)),Ro(r)},vo=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Vn([t],n.includeContainer,{filter:kt.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=Un(t,n.includeContainer,kt.bind(null,n)),r},Yn=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return Ve.call(t,at)===!1?!1:jt(n,t)};function Kn(){const e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function Gn(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}function Co(){return/apple/i.test(navigator.vendor)}function Bt(){const e=/android/i;return e.test(Kn())||e.test(Gn())}function Ao(){return Gn().includes("jsdom/")}const on="data-floating-ui-focusable",Mo="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function je(e){let t=e.activeElement;for(;((n=t)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;t=t.shadowRoot.activeElement}return t}function ae(e,t){if(!e||!t)return!1;const n=t.getRootNode==null?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&Dt(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function ve(e){return"composedPath"in e?e.composedPath()[0]:e.target}function At(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function So(e){return e.matches("html,body")}function he(e){return(e==null?void 0:e.ownerDocument)||document}function Xn(e){return Q(e)&&e.matches(Mo)}function sn(e){return e?e.getAttribute("role")==="combobox"&&Xn(e):!1}function _t(e){return e?e.hasAttribute(on)?e:e.querySelector("["+on+"]")||e:null}function _e(e,t,n){return n===void 0&&(n=!0),e.filter(o=>{var i;return o.parentId===t&&(!n||((i=o.context)==null?void 0:i.open))}).flatMap(o=>[o,..._e(e,o.id,n)])}function ln(e,t){var n;let r=[],o=(n=e.find(i=>i.id===t))==null?void 0:n.parentId;for(;o;){const i=e.find(c=>c.id===o);o=i==null?void 0:i.parentId,i&&(r=r.concat(i))}return r}function Mt(e){e.preventDefault(),e.stopPropagation()}function To(e){return"nativeEvent"in e}function No(e){return e.mozInputSource===0&&e.isTrusted?!0:Bt()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Io(e){return Ao()?!1:!Bt()&&e.width===0&&e.height===0||Bt()&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function an(e,t){return["mouse","pen"].includes(e)}var Oo=typeof document<"u",Po=function(){},ce=Oo?S.useLayoutEffect:Po;const Do={...y};function St(e){const t=y.useRef(e);return ce(()=>{t.current=e}),t}const Lo=Do.useInsertionEffect,Fo=Lo||(e=>e());function me(e){const t=y.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return Fo(()=>{t.current=e}),y.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}const Xe=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function qn(e,t){const n=Et(e,Xe()),r=n.length;if(r===0)return;const o=je(he(e)),i=n.indexOf(o),c=i===-1?t===1?0:r-1:i+t;return n[c]}function Qn(e){return qn(he(e).body,1)||e}function Zn(e){return qn(he(e).body,-1)||e}function We(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!ae(n,r)}function ko(e){Et(e,Xe()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function cn(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function un(e,t,n){let{reference:r,floating:o}=e;const i=Ce(t),c=_n(t),f=Bn(c),s=Pe(t),l=i==="y",a=r.x+r.width/2-o.width/2,u=r.y+r.height/2-o.height/2,d=r[f]/2-o[f]/2;let h;switch(s){case"top":h={x:a,y:r.y-o.height};break;case"bottom":h={x:a,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:u};break;case"left":h={x:r.x-o.width,y:u};break;default:h={x:r.x,y:r.y}}switch(xt(t)){case"start":h[c]-=d*(n&&l?-1:1);break;case"end":h[c]+=d*(n&&l?-1:1);break}return h}const jo=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:c}=n,f=i.filter(Boolean),s=await(c.isRTL==null?void 0:c.isRTL(t));let l=await c.getElementRects({reference:e,floating:t,strategy:o}),{x:a,y:u}=un(l,r,s),d=r,h={},m=0;for(let p=0;p<f.length;p++){const{name:g,fn:E}=f[p],{x,y:b,data:A,reset:M}=await E({x:a,y:u,initialPlacement:r,placement:d,strategy:o,middlewareData:h,rects:l,platform:c,elements:{reference:e,floating:t}});a=x??a,u=b??u,h={...h,[g]:{...h[g],...A}},M&&m<=50&&(m++,typeof M=="object"&&(M.placement&&(d=M.placement),M.rects&&(l=M.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:o}):M.rects),{x:a,y:u}=un(l,d,s)),p=-1)}return{x:a,y:u,placement:d,strategy:o,middlewareData:h}};async function Jn(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:c,elements:f,strategy:s}=e,{boundary:l="clippingAncestors",rootBoundary:a="viewport",elementContext:u="floating",altBoundary:d=!1,padding:h=0}=wt(t,e),m=io(h),g=f[d?u==="floating"?"reference":"floating":u],E=lt(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(g)))==null||n?g:g.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(f.floating)),boundary:l,rootBoundary:a,strategy:s})),x=u==="floating"?{x:r,y:o,width:c.floating.width,height:c.floating.height}:c.reference,b=await(i.getOffsetParent==null?void 0:i.getOffsetParent(f.floating)),A=await(i.isElement==null?void 0:i.isElement(b))?await(i.getScale==null?void 0:i.getScale(b))||{x:1,y:1}:{x:1,y:1},M=lt(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:f,rect:x,offsetParent:b,strategy:s}):x);return{top:(E.top-M.top+m.top)/A.y,bottom:(M.bottom-E.bottom+m.bottom)/A.y,left:(E.left-M.left+m.left)/A.x,right:(M.right-E.right+m.right)/A.x}}const Bo=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:c,initialPlacement:f,platform:s,elements:l}=t,{mainAxis:a=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:p=!0,...g}=wt(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const E=Pe(o),x=Ce(f),b=Pe(f)===f,A=await(s.isRTL==null?void 0:s.isRTL(l.floating)),M=d||(b||!p?[it(f)]:eo(f)),O=m!=="none";!d&&O&&M.push(...oo(f,p,m,A));const N=[f,...M],D=await Jn(t,g),V=[];let _=((r=i.flip)==null?void 0:r.overflows)||[];if(a&&V.push(D[E]),u){const C=Jr(o,c,A);V.push(D[C[0]],D[C[1]])}if(_=[..._,{placement:o,overflows:V}],!V.every(C=>C<=0)){var P,z;const C=(((P=i.flip)==null?void 0:P.index)||0)+1,R=N[C];if(R&&(!(u==="alignment"?x!==Ce(R):!1)||_.every(v=>Ce(v.placement)===x?v.overflows[0]>0:!0)))return{data:{index:C,overflows:_},reset:{placement:R}};let T=(z=_.filter(I=>I.overflows[0]<=0).sort((I,v)=>I.overflows[1]-v.overflows[1])[0])==null?void 0:z.placement;if(!T)switch(h){case"bestFit":{var H;const I=(H=_.filter(v=>{if(O){const L=Ce(v.placement);return L===x||L==="y"}return!0}).map(v=>[v.placement,v.overflows.filter(L=>L>0).reduce((L,$)=>L+$,0)]).sort((v,L)=>v[1]-L[1])[0])==null?void 0:H[0];I&&(T=I);break}case"initialPlacement":T=f;break}if(o!==T)return{reset:{placement:T}}}return{}}}},_o=new Set(["left","top"]);async function $o(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),c=Pe(n),f=xt(n),s=Ce(n)==="y",l=_o.has(c)?-1:1,a=i&&s?-1:1,u=wt(t,e);let{mainAxis:d,crossAxis:h,alignmentAxis:m}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return f&&typeof m=="number"&&(h=f==="end"?m*-1:m),s?{x:h*a,y:d*l}:{x:d*l,y:h*a}}const Uo=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:c,middlewareData:f}=t,s=await $o(t,e);return c===((n=f.offset)==null?void 0:n.placement)&&(r=f.arrow)!=null&&r.alignmentOffset?{}:{x:o+s.x,y:i+s.y,data:{...s,placement:c}}}}},Vo=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:c=!1,limiter:f={fn:g=>{let{x:E,y:x}=g;return{x:E,y:x}}},...s}=wt(e,t),l={x:n,y:r},a=await Jn(t,s),u=Ce(Pe(o)),d=jn(u);let h=l[d],m=l[u];if(i){const g=d==="y"?"top":"left",E=d==="y"?"bottom":"right",x=h+a[g],b=h-a[E];h=en(x,h,b)}if(c){const g=u==="y"?"top":"left",E=u==="y"?"bottom":"right",x=m+a[g],b=m-a[E];m=en(x,m,b)}const p=f.fn({...t,[d]:h,[u]:m});return{...p,data:{x:p.x-n,y:p.y-r,enabled:{[d]:i,[u]:c}}}}}};function er(e){const t=de(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Q(e),i=o?e.offsetWidth:n,c=o?e.offsetHeight:r,f=st(n)!==i||st(r)!==c;return f&&(n=i,r=c),{width:n,height:r,$:f}}function Kt(e){return G(e)?e:e.contextElement}function $e(e){const t=Kt(e);if(!Q(t))return pe(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=er(t);let c=(i?st(n.width):n.width)/r,f=(i?st(n.height):n.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!f||!Number.isFinite(f))&&(f=1),{x:c,y:f}}const Ho=pe(0);function tr(e){const t=ue(e);return!gt()||!t.visualViewport?Ho:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Wo(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ue(e)?!1:t}function De(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Kt(e);let c=pe(1);t&&(r?G(r)&&(c=$e(r)):c=$e(e));const f=Wo(i,n,r)?tr(i):pe(0);let s=(o.left+f.x)/c.x,l=(o.top+f.y)/c.y,a=o.width/c.x,u=o.height/c.y;if(i){const d=ue(i),h=r&&G(r)?ue(r):r;let m=d,p=Lt(m);for(;p&&r&&h!==m;){const g=$e(p),E=p.getBoundingClientRect(),x=de(p),b=E.left+(p.clientLeft+parseFloat(x.paddingLeft))*g.x,A=E.top+(p.clientTop+parseFloat(x.paddingTop))*g.y;s*=g.x,l*=g.y,a*=g.x,u*=g.y,s+=b,l+=A,m=ue(p),p=Lt(m)}}return lt({width:a,height:u,x:s,y:l})}function yt(e,t){const n=bt(e).scrollLeft;return t?t.left+n:De(ge(e)).left+n}function nr(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-yt(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function zo(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",c=ge(r),f=t?pt(t.floating):!1;if(r===c||f&&i)return n;let s={scrollLeft:0,scrollTop:0},l=pe(1);const a=pe(0),u=Q(r);if((u||!u&&!i)&&((Se(r)!=="body"||Ge(c))&&(s=bt(r)),Q(r))){const h=De(r);l=$e(r),a.x=h.x+r.clientLeft,a.y=h.y+r.clientTop}const d=c&&!u&&!i?nr(c,s):pe(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-s.scrollLeft*l.x+a.x+d.x,y:n.y*l.y-s.scrollTop*l.y+a.y+d.y}}function Yo(e){return Array.from(e.getClientRects())}function Ko(e){const t=ge(e),n=bt(e),r=e.ownerDocument.body,o=Ne(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Ne(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let c=-n.scrollLeft+yt(e);const f=-n.scrollTop;return de(r).direction==="rtl"&&(c+=Ne(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:c,y:f}}const fn=25;function Go(e,t){const n=ue(e),r=ge(e),o=n.visualViewport;let i=r.clientWidth,c=r.clientHeight,f=0,s=0;if(o){i=o.width,c=o.height;const a=gt();(!a||a&&t==="fixed")&&(f=o.offsetLeft,s=o.offsetTop)}const l=yt(r);if(l<=0){const a=r.ownerDocument,u=a.body,d=getComputedStyle(u),h=a.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,m=Math.abs(r.clientWidth-u.clientWidth-h);m<=fn&&(i-=m)}else l<=fn&&(i+=l);return{width:i,height:c,x:f,y:s}}const Xo=new Set(["absolute","fixed"]);function qo(e,t){const n=De(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Q(e)?$e(e):pe(1),c=e.clientWidth*i.x,f=e.clientHeight*i.y,s=o*i.x,l=r*i.y;return{width:c,height:f,x:s,y:l}}function dn(e,t,n){let r;if(t==="viewport")r=Go(e,n);else if(t==="document")r=Ko(ge(e));else if(G(t))r=qo(t,n);else{const o=tr(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return lt(r)}function rr(e,t){const n=Ee(e);return n===t||!G(n)||xe(n)?!1:de(n).position==="fixed"||rr(n,t)}function Qo(e,t){const n=t.get(e);if(n)return n;let r=Me(e,[],!1).filter(f=>G(f)&&Se(f)!=="body"),o=null;const i=de(e).position==="fixed";let c=i?Ee(e):e;for(;G(c)&&!xe(c);){const f=de(c),s=Yt(c);!s&&f.position==="fixed"&&(o=null),(i?!s&&!o:!s&&f.position==="static"&&!!o&&Xo.has(o.position)||Ge(c)&&!s&&rr(e,c))?r=r.filter(a=>a!==c):o=f,c=Ee(c)}return t.set(e,r),r}function Zo(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const c=[...n==="clippingAncestors"?pt(t)?[]:Qo(t,this._c):[].concat(n),r],f=c[0],s=c.reduce((l,a)=>{const u=dn(t,a,o);return l.top=Ne(u.top,l.top),l.right=ot(u.right,l.right),l.bottom=ot(u.bottom,l.bottom),l.left=Ne(u.left,l.left),l},dn(t,f,o));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}}function Jo(e){const{width:t,height:n}=er(e);return{width:t,height:n}}function es(e,t,n){const r=Q(t),o=ge(t),i=n==="fixed",c=De(e,!0,i,t);let f={scrollLeft:0,scrollTop:0};const s=pe(0);function l(){s.x=yt(o)}if(r||!r&&!i)if((Se(t)!=="body"||Ge(o))&&(f=bt(t)),r){const h=De(t,!0,i,t);s.x=h.x+t.clientLeft,s.y=h.y+t.clientTop}else o&&l();i&&!r&&o&&l();const a=o&&!r&&!i?nr(o,f):pe(0),u=c.left+f.scrollLeft-s.x-a.x,d=c.top+f.scrollTop-s.y-a.y;return{x:u,y:d,width:c.width,height:c.height}}function Tt(e){return de(e).position==="static"}function hn(e,t){if(!Q(e)||de(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ge(e)===n&&(n=n.ownerDocument.body),n}function or(e,t){const n=ue(e);if(pt(e))return n;if(!Q(e)){let o=Ee(e);for(;o&&!xe(o);){if(G(o)&&!Tt(o))return o;o=Ee(o)}return n}let r=hn(e,t);for(;r&&Hr(r)&&Tt(r);)r=hn(r,t);return r&&xe(r)&&Tt(r)&&!Yt(r)?n:r||Gr(e)||n}const ts=async function(e){const t=this.getOffsetParent||or,n=this.getDimensions,r=await n(e.floating);return{reference:es(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ns(e){return de(e).direction==="rtl"}const rs={convertOffsetParentRelativeRectToViewportRelativeRect:zo,getDocumentElement:ge,getClippingRect:Zo,getOffsetParent:or,getElementRects:ts,getClientRects:Yo,getDimensions:Jo,getScale:$e,isElement:G,isRTL:ns};function sr(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function os(e,t){let n=null,r;const o=ge(e);function i(){var f;clearTimeout(r),(f=n)==null||f.disconnect(),n=null}function c(f,s){f===void 0&&(f=!1),s===void 0&&(s=1),i();const l=e.getBoundingClientRect(),{left:a,top:u,width:d,height:h}=l;if(f||t(),!d||!h)return;const m=Ze(u),p=Ze(o.clientWidth-(a+d)),g=Ze(o.clientHeight-(u+h)),E=Ze(a),b={rootMargin:-m+"px "+-p+"px "+-g+"px "+-E+"px",threshold:Ne(0,ot(1,s))||1};let A=!0;function M(O){const N=O[0].intersectionRatio;if(N!==s){if(!A)return c();N?c(!1,N):r=setTimeout(()=>{c(!1,1e-7)},1e3)}N===1&&!sr(l,e.getBoundingClientRect())&&c(),A=!1}try{n=new IntersectionObserver(M,{...b,root:o.ownerDocument})}catch{n=new IntersectionObserver(M,b)}n.observe(e)}return c(!0),i}function ss(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:f=typeof IntersectionObserver=="function",animationFrame:s=!1}=r,l=Kt(e),a=o||i?[...l?Me(l):[],...Me(t)]:[];a.forEach(E=>{o&&E.addEventListener("scroll",n,{passive:!0}),i&&E.addEventListener("resize",n)});const u=l&&f?os(l,n):null;let d=-1,h=null;c&&(h=new ResizeObserver(E=>{let[x]=E;x&&x.target===l&&h&&(h.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var b;(b=h)==null||b.observe(t)})),n()}),l&&!s&&h.observe(l),h.observe(t));let m,p=s?De(e):null;s&&g();function g(){const E=De(e);p&&!sr(p,E)&&n(),p=E,m=requestAnimationFrame(g)}return n(),()=>{var E;a.forEach(x=>{o&&x.removeEventListener("scroll",n),i&&x.removeEventListener("resize",n)}),u==null||u(),(E=h)==null||E.disconnect(),h=null,s&&cancelAnimationFrame(m)}}const is=Uo,ls=Vo,as=Bo,cs=(e,t,n)=>{const r=new Map,o={platform:rs,...n},i={...o.platform,_c:r};return jo(e,t,{...o,platform:i})};var us=typeof document<"u",fs=function(){},nt=us?S.useLayoutEffect:fs;function ft(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ft(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!ft(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function ir(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function mn(e,t){const n=ir(e);return Math.round(t*n)/n}function Nt(e){const t=y.useRef(e);return nt(()=>{t.current=e}),t}function ds(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:c}={},transform:f=!0,whileElementsMounted:s,open:l}=e,[a,u]=y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[d,h]=y.useState(r);ft(d,r)||h(r);const[m,p]=y.useState(null),[g,E]=y.useState(null),x=y.useCallback(v=>{v!==O.current&&(O.current=v,p(v))},[]),b=y.useCallback(v=>{v!==N.current&&(N.current=v,E(v))},[]),A=i||m,M=c||g,O=y.useRef(null),N=y.useRef(null),D=y.useRef(a),V=s!=null,_=Nt(s),P=Nt(o),z=Nt(l),H=y.useCallback(()=>{if(!O.current||!N.current)return;const v={placement:t,strategy:n,middleware:d};P.current&&(v.platform=P.current),cs(O.current,N.current,v).then(L=>{const $={...L,isPositioned:z.current!==!1};C.current&&!ft(D.current,$)&&(D.current=$,Dn.flushSync(()=>{u($)}))})},[d,t,n,P,z]);nt(()=>{l===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,u(v=>({...v,isPositioned:!1})))},[l]);const C=y.useRef(!1);nt(()=>(C.current=!0,()=>{C.current=!1}),[]),nt(()=>{if(A&&(O.current=A),M&&(N.current=M),A&&M){if(_.current)return _.current(A,M,H);H()}},[A,M,H,_,V]);const R=y.useMemo(()=>({reference:O,floating:N,setReference:x,setFloating:b}),[x,b]),T=y.useMemo(()=>({reference:A,floating:M}),[A,M]),I=y.useMemo(()=>{const v={position:n,left:0,top:0};if(!T.floating)return v;const L=mn(T.floating,a.x),$=mn(T.floating,a.y);return f?{...v,transform:"translate("+L+"px, "+$+"px)",...ir(T.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:L,top:$}},[n,f,T.floating,a.x,a.y]);return y.useMemo(()=>({...a,update:H,refs:R,elements:T,floatingStyles:I}),[a,H,R,T,I])}const hs=(e,t)=>({...is(e),options:[e,t]}),ms=(e,t)=>({...ls(e),options:[e,t]}),ps=(e,t)=>({...as(e),options:[e,t]}),gs="data-floating-ui-focusable",pn="active",gn="selected",bs={...y};let bn=!1,ws=0;const wn=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+ws++;function xs(){const[e,t]=y.useState(()=>bn?wn():void 0);return ce(()=>{e==null&&t(wn())},[]),y.useEffect(()=>{bn=!0},[]),e}const Es=bs.useId,Gt=Es||xs;let $t;process.env.NODE_ENV!=="production"&&($t=new Set);function ys(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const o="Floating UI: "+n.join(" ");if(!((e=$t)!=null&&e.has(o))){var i;(i=$t)==null||i.add(o),console.error(o)}}function Rs(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(o=>o(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){var r;(r=e.get(t))==null||r.delete(n)}}}const vs=y.createContext(null),Cs=y.createContext(null),lr=()=>{var e;return((e=y.useContext(vs))==null?void 0:e.id)||null},Xt=()=>y.useContext(Cs);function Ye(e){return"data-floating-ui-"+e}function As(e){e.current!==-1&&(clearTimeout(e.current),e.current=-1)}let xn=0;function Fe(e,t){t===void 0&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(xn);const i=()=>e==null?void 0:e.focus({preventScroll:n});o?i():xn=requestAnimationFrame(i)}function Ms(e){return(e==null?void 0:e.ownerDocument)||document}const Ue={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function En(e){return e==="inert"?Ue.inert:e==="aria-hidden"?Ue["aria-hidden"]:Ue.none}let Je=new WeakSet,et={},It=0;const Ss=()=>typeof HTMLElement<"u"&&"inert"in HTMLElement.prototype,ar=e=>e&&(e.host||ar(e.parentNode)),Ts=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=ar(n);return e.contains(r)?r:null}).filter(n=>n!=null);function Ns(e,t,n,r){const o="data-floating-ui-inert",i=r?"inert":n?"aria-hidden":null,c=Ts(t,e),f=new Set,s=new Set(c),l=[];et[o]||(et[o]=new WeakMap);const a=et[o];c.forEach(u),d(t),f.clear();function u(h){!h||f.has(h)||(f.add(h),h.parentNode&&u(h.parentNode))}function d(h){!h||s.has(h)||[].forEach.call(h.children,m=>{if(Se(m)!=="script")if(f.has(m))d(m);else{const p=i?m.getAttribute(i):null,g=p!==null&&p!=="false",E=En(i),x=(E.get(m)||0)+1,b=(a.get(m)||0)+1;E.set(m,x),a.set(m,b),l.push(m),x===1&&g&&Je.add(m),b===1&&m.setAttribute(o,""),!g&&i&&m.setAttribute(i,i==="inert"?"":"true")}})}return It++,()=>{l.forEach(h=>{const m=En(i),g=(m.get(h)||0)-1,E=(a.get(h)||0)-1;m.set(h,g),a.set(h,E),g||(!Je.has(h)&&i&&h.removeAttribute(i),Je.delete(h)),E||h.removeAttribute(o)}),It--,It||(Ue.inert=new WeakMap,Ue["aria-hidden"]=new WeakMap,Ue.none=new WeakMap,Je=new WeakSet,et={})}}function yn(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=Ms(e[0]).body;return Ns(e.concat(Array.from(r.querySelectorAll('[aria-live],[role="status"],output'))),r,t,n)}const Rt={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},dt=y.forwardRef(function(t,n){const[r,o]=y.useState();ce(()=>{Co()&&o("button")},[]);const i={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[Ye("focus-guard")]:"",style:Rt};return w.jsx("span",{...t,...i})}),cr=y.createContext(null),Rn=Ye("portal");function Is(e){e===void 0&&(e={});const{id:t,root:n}=e,r=Gt(),o=ur(),[i,c]=y.useState(null),f=y.useRef(null);return ce(()=>()=>{i==null||i.remove(),queueMicrotask(()=>{f.current=null})},[i]),ce(()=>{if(!r||f.current)return;const s=t?document.getElementById(t):null;if(!s)return;const l=document.createElement("div");l.id=r,l.setAttribute(Rn,""),s.appendChild(l),f.current=l,c(l)},[t,r]),ce(()=>{if(n===null||!r||f.current)return;let s=n||(o==null?void 0:o.portalNode);s&&!zt(s)&&(s=s.current),s=s||document.body;let l=null;t&&(l=document.createElement("div"),l.id=t,s.appendChild(l));const a=document.createElement("div");a.id=r,a.setAttribute(Rn,""),s=l||s,s.appendChild(a),f.current=a,c(a)},[t,n,r,o]),i}function Os(e){const{children:t,id:n,root:r,preserveTabOrder:o=!0}=e,i=Is({id:n,root:r}),[c,f]=y.useState(null),s=y.useRef(null),l=y.useRef(null),a=y.useRef(null),u=y.useRef(null),d=c==null?void 0:c.modal,h=c==null?void 0:c.open,m=!!c&&!c.modal&&c.open&&o&&!!(r||i);return y.useEffect(()=>{if(!i||!o||d)return;function p(g){i&&We(g)&&(g.type==="focusin"?cn:ko)(i)}return i.addEventListener("focusin",p,!0),i.addEventListener("focusout",p,!0),()=>{i.removeEventListener("focusin",p,!0),i.removeEventListener("focusout",p,!0)}},[i,o,d]),y.useEffect(()=>{i&&(h||cn(i))},[h,i]),w.jsxs(cr.Provider,{value:y.useMemo(()=>({preserveTabOrder:o,beforeOutsideRef:s,afterOutsideRef:l,beforeInsideRef:a,afterInsideRef:u,portalNode:i,setFocusManagerState:f}),[o,i]),children:[m&&i&&w.jsx(dt,{"data-type":"outside",ref:s,onFocus:p=>{if(We(p,i)){var g;(g=a.current)==null||g.focus()}else{const E=c?c.domReference:null,x=Zn(E);x==null||x.focus()}}}),m&&i&&w.jsx("span",{"aria-owns":i.id,style:Rt}),i&&Dn.createPortal(t,i),m&&i&&w.jsx(dt,{"data-type":"outside",ref:l,onFocus:p=>{if(We(p,i)){var g;(g=u.current)==null||g.focus()}else{const E=c?c.domReference:null,x=Qn(E);x==null||x.focus(),c!=null&&c.closeOnFocusOut&&(c==null||c.onOpenChange(!1,p.nativeEvent,"focus-out"))}}})]})}const ur=()=>y.useContext(cr);function vn(e){return y.useMemo(()=>t=>{e.forEach(n=>{n&&(n.current=t)})},e)}const Ps=20;let Ae=[];function qt(){Ae=Ae.filter(e=>e.isConnected)}function Ds(e){qt(),e&&Se(e)!=="body"&&(Ae.push(e),Ae.length>Ps&&(Ae=Ae.slice(-20)))}function Cn(){return qt(),Ae[Ae.length-1]}function Ls(e){const t=Xe();return Yn(e,t)?e:Et(e,t)[0]||e}function An(e,t){var n;if(!t.current.includes("floating")&&!((n=e.getAttribute("role"))!=null&&n.includes("dialog")))return;const r=Xe(),i=vo(e,r).filter(f=>{const s=f.getAttribute("data-tabindex")||"";return Yn(f,r)||f.hasAttribute("data-tabindex")&&!s.startsWith("-")}),c=e.getAttribute("tabindex");t.current.includes("floating")||i.length===0?c!=="0"&&e.setAttribute("tabindex","0"):(c!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}const Fs=y.forwardRef(function(t,n){return w.jsx("button",{...t,type:"button",ref:n,tabIndex:-1,style:Rt})});function ks(e){const{context:t,children:n,disabled:r=!1,order:o=["content"],guards:i=!0,initialFocus:c=0,returnFocus:f=!0,restoreFocus:s=!1,modal:l=!0,visuallyHiddenDismiss:a=!1,closeOnFocusOut:u=!0,outsideElementsInert:d=!1,getInsideElements:h=()=>[]}=e,{open:m,onOpenChange:p,events:g,dataRef:E,elements:{domReference:x,floating:b}}=t,A=me(()=>{var j;return(j=E.current.floatingContext)==null?void 0:j.nodeId}),M=me(h),O=typeof c=="number"&&c<0,N=sn(x)&&O,D=Ss(),V=D?i:!0,_=!V||D&&d,P=St(o),z=St(c),H=St(f),C=Xt(),R=ur(),T=y.useRef(null),I=y.useRef(null),v=y.useRef(!1),L=y.useRef(!1),$=y.useRef(-1),q=y.useRef(-1),te=R!=null,F=_t(b),re=me(function(j){return j===void 0&&(j=F),j?Et(j,Xe()):[]}),Y=me(j=>{const U=re(j);return P.current.map(B=>x&&B==="reference"?x:F&&B==="floating"?F:U).filter(Boolean).flat()});y.useEffect(()=>{if(r||!l)return;function j(B){if(B.key==="Tab"){ae(F,je(he(F)))&&re().length===0&&!N&&Mt(B);const X=Y(),Z=ve(B);P.current[0]==="reference"&&Z===x&&(Mt(B),B.shiftKey?Fe(X[X.length-1]):Fe(X[1])),P.current[1]==="floating"&&Z===F&&B.shiftKey&&(Mt(B),Fe(X[0]))}}const U=he(F);return U.addEventListener("keydown",j),()=>{U.removeEventListener("keydown",j)}},[r,x,F,l,P,N,re,Y]),y.useEffect(()=>{if(r||!b)return;function j(U){const B=ve(U),Z=re().indexOf(B);Z!==-1&&($.current=Z)}return b.addEventListener("focusin",j),()=>{b.removeEventListener("focusin",j)}},[r,b,re]),y.useEffect(()=>{if(r||!u)return;function j(){L.current=!0,setTimeout(()=>{L.current=!1})}function U(Z){const W=Z.relatedTarget,be=Z.currentTarget,fe=ve(Z);queueMicrotask(()=>{const le=A(),Te=!(ae(x,W)||ae(b,W)||ae(W,b)||ae(R==null?void 0:R.portalNode,W)||W!=null&&W.hasAttribute(Ye("focus-guard"))||C&&(_e(C.nodesRef.current,le).find(ye=>{var we,Re;return ae((we=ye.context)==null?void 0:we.elements.floating,W)||ae((Re=ye.context)==null?void 0:Re.elements.domReference,W)})||ln(C.nodesRef.current,le).find(ye=>{var we,Re,Jt;return[(we=ye.context)==null?void 0:we.elements.floating,_t((Re=ye.context)==null?void 0:Re.elements.floating)].includes(W)||((Jt=ye.context)==null?void 0:Jt.elements.domReference)===W})));if(be===x&&F&&An(F,P),s&&be!==x&&!(fe!=null&&fe.isConnected)&&je(he(F))===he(F).body){Q(F)&&F.focus();const ye=$.current,we=re(),Re=we[ye]||we[we.length-1]||F;Q(Re)&&Re.focus()}if(E.current.insideReactTree){E.current.insideReactTree=!1;return}(N||!l)&&W&&Te&&!L.current&&W!==Cn()&&(v.current=!0,p(!1,Z,"focus-out"))})}const B=!!(!C&&R);function X(){As(q),E.current.insideReactTree=!0,q.current=window.setTimeout(()=>{E.current.insideReactTree=!1})}if(b&&Q(x))return x.addEventListener("focusout",U),x.addEventListener("pointerdown",j),b.addEventListener("focusout",U),B&&b.addEventListener("focusout",X,!0),()=>{x.removeEventListener("focusout",U),x.removeEventListener("pointerdown",j),b.removeEventListener("focusout",U),B&&b.removeEventListener("focusout",X,!0)}},[r,x,b,F,l,C,R,p,u,s,re,N,A,P,E]);const ne=y.useRef(null),ie=y.useRef(null),vt=vn([ne,R==null?void 0:R.beforeInsideRef]),Ct=vn([ie,R==null?void 0:R.afterInsideRef]);y.useEffect(()=>{var j,U;if(r||!b)return;const B=Array.from((R==null||(j=R.portalNode)==null?void 0:j.querySelectorAll("["+Ye("portal")+"]"))||[]),Z=(U=(C?ln(C.nodesRef.current,A()):[]).find(fe=>{var le;return sn(((le=fe.context)==null?void 0:le.elements.domReference)||null)}))==null||(U=U.context)==null?void 0:U.elements.domReference,W=[b,Z,...B,...M(),T.current,I.current,ne.current,ie.current,R==null?void 0:R.beforeOutsideRef.current,R==null?void 0:R.afterOutsideRef.current,P.current.includes("reference")||N?x:null].filter(fe=>fe!=null),be=l||N?yn(W,!_,_):yn(W);return()=>{be()}},[r,x,b,l,P,R,N,V,_,C,A,M]),ce(()=>{if(r||!Q(F))return;const j=he(F),U=je(j);queueMicrotask(()=>{const B=Y(F),X=z.current,Z=(typeof X=="number"?B[X]:X.current)||F,W=ae(F,U);!O&&!W&&m&&Fe(Z,{preventScroll:Z===F})})},[r,m,F,O,Y,z]),ce(()=>{if(r||!F)return;const j=he(F),U=je(j);Ds(U);function B(W){let{reason:be,event:fe,nested:le}=W;if(["hover","safe-polygon"].includes(be)&&fe.type==="mouseleave"&&(v.current=!0),be==="outside-press")if(le)v.current=!1;else if(No(fe)||Io(fe))v.current=!1;else{let Te=!1;document.createElement("div").focus({get preventScroll(){return Te=!0,!1}}),Te?v.current=!1:v.current=!0}}g.on("openchange",B);const X=j.createElement("span");X.setAttribute("tabindex","-1"),X.setAttribute("aria-hidden","true"),Object.assign(X.style,Rt),te&&x&&x.insertAdjacentElement("afterend",X);function Z(){if(typeof H.current=="boolean"){const W=x||Cn();return W&&W.isConnected?W:X}return H.current.current||X}return()=>{g.off("openchange",B);const W=je(j),be=ae(b,W)||C&&_e(C.nodesRef.current,A(),!1).some(le=>{var Te;return ae((Te=le.context)==null?void 0:Te.elements.floating,W)}),fe=Z();queueMicrotask(()=>{const le=Ls(fe);H.current&&!v.current&&Q(le)&&(!(le!==W&&W!==j.body)||be)&&le.focus({preventScroll:!0}),X.remove()})}},[r,b,F,H,E,g,C,te,x,A]),y.useEffect(()=>(queueMicrotask(()=>{v.current=!1}),()=>{queueMicrotask(qt)}),[r]),ce(()=>{if(!r&&R)return R.setFocusManagerState({modal:l,closeOnFocusOut:u,open:m,onOpenChange:p,domReference:x}),()=>{R.setFocusManagerState(null)}},[r,R,l,m,p,u,x]),ce(()=>{r||F&&An(F,P)},[r,F,P]);function qe(j){return r||!a||!l?null:w.jsx(Fs,{ref:j==="start"?T:I,onClick:U=>p(!1,U.nativeEvent),children:typeof a=="string"?a:"Dismiss"})}const Qe=!r&&V&&(l?!N:!0)&&(te||l);return w.jsxs(w.Fragment,{children:[Qe&&w.jsx(dt,{"data-type":"inside",ref:vt,onFocus:j=>{if(l){const B=Y();Fe(o[0]==="reference"?B[0]:B[B.length-1])}else if(R!=null&&R.preserveTabOrder&&R.portalNode)if(v.current=!1,We(j,R.portalNode)){const B=Qn(x);B==null||B.focus()}else{var U;(U=R.beforeOutsideRef.current)==null||U.focus()}}}),!N&&qe("start"),n,qe("end"),Qe&&w.jsx(dt,{"data-type":"inside",ref:Ct,onFocus:j=>{if(l)Fe(Y()[0]);else if(R!=null&&R.preserveTabOrder&&R.portalNode)if(u&&(v.current=!0),We(j,R.portalNode)){const B=Zn(x);B==null||B.focus()}else{var U;(U=R.afterOutsideRef.current)==null||U.focus()}}})]})}let tt=0;const Mn="--floating-ui-scrollbar-width";function js(){const e=Kn(),t=/iP(hone|ad|od)|iOS/.test(e)||e==="MacIntel"&&navigator.maxTouchPoints>1,n=document.body.style,o=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",i=window.innerWidth-document.documentElement.clientWidth,c=n.left?parseFloat(n.left):window.scrollX,f=n.top?parseFloat(n.top):window.scrollY;if(n.overflow="hidden",n.setProperty(Mn,i+"px"),i&&(n[o]=i+"px"),t){var s,l;const a=((s=window.visualViewport)==null?void 0:s.offsetLeft)||0,u=((l=window.visualViewport)==null?void 0:l.offsetTop)||0;Object.assign(n,{position:"fixed",top:-(f-Math.floor(u))+"px",left:-(c-Math.floor(a))+"px",right:"0"})}return()=>{Object.assign(n,{overflow:"",[o]:""}),n.removeProperty(Mn),t&&(Object.assign(n,{position:"",top:"",left:"",right:""}),window.scrollTo(c,f))}}let Sn=()=>{};const Bs=y.forwardRef(function(t,n){const{lockScroll:r=!1,...o}=t;return ce(()=>{if(r)return tt++,tt===1&&(Sn=js()),()=>{tt--,tt===0&&Sn()}},[r]),w.jsx("div",{ref:n,...o,style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...o.style}})});function Tn(e){return Q(e.target)&&e.target.tagName==="BUTTON"}function _s(e){return Q(e.target)&&e.target.tagName==="A"}function Nn(e){return Xn(e)}function $s(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,dataRef:o,elements:{domReference:i}}=e,{enabled:c=!0,event:f="click",toggle:s=!0,ignoreMouse:l=!1,keyboardHandlers:a=!0,stickIfOpen:u=!0}=t,d=y.useRef(),h=y.useRef(!1),m=y.useMemo(()=>({onPointerDown(p){d.current=p.pointerType},onMouseDown(p){const g=d.current;p.button===0&&f!=="click"&&(an(g)&&l||(n&&s&&(!(o.current.openEvent&&u)||o.current.openEvent.type==="mousedown")?r(!1,p.nativeEvent,"click"):(p.preventDefault(),r(!0,p.nativeEvent,"click"))))},onClick(p){const g=d.current;if(f==="mousedown"&&d.current){d.current=void 0;return}an(g)&&l||(n&&s&&(!(o.current.openEvent&&u)||o.current.openEvent.type==="click")?r(!1,p.nativeEvent,"click"):r(!0,p.nativeEvent,"click"))},onKeyDown(p){d.current=void 0,!(p.defaultPrevented||!a||Tn(p))&&(p.key===" "&&!Nn(i)&&(p.preventDefault(),h.current=!0),!_s(p)&&p.key==="Enter"&&r(!(n&&s),p.nativeEvent,"click"))},onKeyUp(p){p.defaultPrevented||!a||Tn(p)||Nn(i)||p.key===" "&&h.current&&(h.current=!1,r(!(n&&s),p.nativeEvent,"click"))}}),[o,i,f,l,a,r,n,u,s]);return y.useMemo(()=>c?{reference:m}:{},[c,m])}const Us={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Vs={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},In=e=>{var t,n;return{escapeKey:typeof e=="boolean"?e:(t=e==null?void 0:e.escapeKey)!=null?t:!1,outsidePress:typeof e=="boolean"?e:(n=e==null?void 0:e.outsidePress)!=null?n:!0}};function fr(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,elements:o,dataRef:i}=e,{enabled:c=!0,escapeKey:f=!0,outsidePress:s=!0,outsidePressEvent:l="pointerdown",referencePress:a=!1,referencePressEvent:u="pointerdown",ancestorScroll:d=!1,bubbles:h,capture:m}=t,p=Xt(),g=me(typeof s=="function"?s:()=>!1),E=typeof s=="function"?g:s,x=y.useRef(!1),{escapeKey:b,outsidePress:A}=In(h),{escapeKey:M,outsidePress:O}=In(m),N=y.useRef(!1),D=me(C=>{var R;if(!n||!c||!f||C.key!=="Escape"||N.current)return;const T=(R=i.current.floatingContext)==null?void 0:R.nodeId,I=p?_e(p.nodesRef.current,T):[];if(!b&&(C.stopPropagation(),I.length>0)){let v=!0;if(I.forEach(L=>{var $;if(($=L.context)!=null&&$.open&&!L.context.dataRef.current.__escapeKeyBubbles){v=!1;return}}),!v)return}r(!1,To(C)?C.nativeEvent:C,"escape-key")}),V=me(C=>{var R;const T=()=>{var I;D(C),(I=ve(C))==null||I.removeEventListener("keydown",T)};(R=ve(C))==null||R.addEventListener("keydown",T)}),_=me(C=>{var R;const T=i.current.insideReactTree;i.current.insideReactTree=!1;const I=x.current;if(x.current=!1,l==="click"&&I||T||typeof E=="function"&&!E(C))return;const v=ve(C),L="["+Ye("inert")+"]",$=he(o.floating).querySelectorAll(L);let q=G(v)?v:null;for(;q&&!xe(q);){const Y=Ee(q);if(xe(Y)||!G(Y))break;q=Y}if($.length&&G(v)&&!So(v)&&!ae(v,o.floating)&&Array.from($).every(Y=>!ae(q,Y)))return;if(Q(v)&&H){const Y=xe(v),ne=de(v),ie=/auto|scroll/,vt=Y||ie.test(ne.overflowX),Ct=Y||ie.test(ne.overflowY),qe=vt&&v.clientWidth>0&&v.scrollWidth>v.clientWidth,Qe=Ct&&v.clientHeight>0&&v.scrollHeight>v.clientHeight,j=ne.direction==="rtl",U=Qe&&(j?C.offsetX<=v.offsetWidth-v.clientWidth:C.offsetX>v.clientWidth),B=qe&&C.offsetY>v.clientHeight;if(U||B)return}const te=(R=i.current.floatingContext)==null?void 0:R.nodeId,F=p&&_e(p.nodesRef.current,te).some(Y=>{var ne;return At(C,(ne=Y.context)==null?void 0:ne.elements.floating)});if(At(C,o.floating)||At(C,o.domReference)||F)return;const re=p?_e(p.nodesRef.current,te):[];if(re.length>0){let Y=!0;if(re.forEach(ne=>{var ie;if((ie=ne.context)!=null&&ie.open&&!ne.context.dataRef.current.__outsidePressBubbles){Y=!1;return}}),!Y)return}r(!1,C,"outside-press")}),P=me(C=>{var R;const T=()=>{var I;_(C),(I=ve(C))==null||I.removeEventListener(l,T)};(R=ve(C))==null||R.addEventListener(l,T)});y.useEffect(()=>{if(!n||!c)return;i.current.__escapeKeyBubbles=b,i.current.__outsidePressBubbles=A;let C=-1;function R($){r(!1,$,"ancestor-scroll")}function T(){window.clearTimeout(C),N.current=!0}function I(){C=window.setTimeout(()=>{N.current=!1},gt()?5:0)}const v=he(o.floating);f&&(v.addEventListener("keydown",M?V:D,M),v.addEventListener("compositionstart",T),v.addEventListener("compositionend",I)),E&&v.addEventListener(l,O?P:_,O);let L=[];return d&&(G(o.domReference)&&(L=Me(o.domReference)),G(o.floating)&&(L=L.concat(Me(o.floating))),!G(o.reference)&&o.reference&&o.reference.contextElement&&(L=L.concat(Me(o.reference.contextElement)))),L=L.filter($=>{var q;return $!==((q=v.defaultView)==null?void 0:q.visualViewport)}),L.forEach($=>{$.addEventListener("scroll",R,{passive:!0})}),()=>{f&&(v.removeEventListener("keydown",M?V:D,M),v.removeEventListener("compositionstart",T),v.removeEventListener("compositionend",I)),E&&v.removeEventListener(l,O?P:_,O),L.forEach($=>{$.removeEventListener("scroll",R)}),window.clearTimeout(C)}},[i,o,f,E,l,n,r,d,c,b,A,D,M,V,_,O,P]),y.useEffect(()=>{i.current.insideReactTree=!1},[i,E,l]);const z=y.useMemo(()=>({onKeyDown:D,...a&&{[Us[u]]:C=>{r(!1,C.nativeEvent,"reference-press")},...u!=="click"&&{onClick(C){r(!1,C.nativeEvent,"reference-press")}}}}),[D,r,a,u]),H=y.useMemo(()=>({onKeyDown:D,onMouseDown(){x.current=!0},onMouseUp(){x.current=!0},[Vs[l]]:()=>{i.current.insideReactTree=!0}}),[D,l,i]);return y.useMemo(()=>c?{reference:z,floating:H}:{},[c,z,H])}function Hs(e){const{open:t=!1,onOpenChange:n,elements:r}=e,o=Gt(),i=y.useRef({}),[c]=y.useState(()=>Rs()),f=lr()!=null;if(process.env.NODE_ENV!=="production"){const h=r.reference;h&&!G(h)&&ys("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[s,l]=y.useState(r.reference),a=me((h,m,p)=>{i.current.openEvent=h?m:void 0,c.emit("openchange",{open:h,event:m,reason:p,nested:f}),n==null||n(h,m,p)}),u=y.useMemo(()=>({setPositionReference:l}),[]),d=y.useMemo(()=>({reference:s||r.reference||null,floating:r.floating||null,domReference:r.reference}),[s,r.reference,r.floating]);return y.useMemo(()=>({dataRef:i,open:t,onOpenChange:a,elements:d,events:c,floatingId:o,refs:u}),[t,a,d,c,o,u])}function dr(e){e===void 0&&(e={});const{nodeId:t}=e,n=Hs({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,o=r.elements,[i,c]=y.useState(null),[f,s]=y.useState(null),a=(o==null?void 0:o.domReference)||i,u=y.useRef(null),d=Xt();ce(()=>{a&&(u.current=a)},[a]);const h=ds({...e,elements:{...o,...f&&{reference:f}}}),m=y.useCallback(b=>{const A=G(b)?{getBoundingClientRect:()=>b.getBoundingClientRect(),getClientRects:()=>b.getClientRects(),contextElement:b}:b;s(A),h.refs.setReference(A)},[h.refs]),p=y.useCallback(b=>{(G(b)||b===null)&&(u.current=b,c(b)),(G(h.refs.reference.current)||h.refs.reference.current===null||b!==null&&!G(b))&&h.refs.setReference(b)},[h.refs]),g=y.useMemo(()=>({...h.refs,setReference:p,setPositionReference:m,domReference:u}),[h.refs,p,m]),E=y.useMemo(()=>({...h.elements,domReference:a}),[h.elements,a]),x=y.useMemo(()=>({...h,...r,refs:g,elements:E,nodeId:t}),[h,g,E,t,r]);return ce(()=>{r.dataRef.current.floatingContext=x;const b=d==null?void 0:d.nodesRef.current.find(A=>A.id===t);b&&(b.context=x)}),y.useMemo(()=>({...h,context:x,refs:g,elements:E}),[h,g,E,x])}function Ot(e,t,n){const r=new Map,o=n==="item";let i=e;if(o&&e){const{[pn]:c,[gn]:f,...s}=e;i=s}return{...n==="floating"&&{tabIndex:-1,[gs]:""},...i,...t.map(c=>{const f=c?c[n]:null;return typeof f=="function"?e?f(e):null:f}).concat(e).reduce((c,f)=>(f&&Object.entries(f).forEach(s=>{let[l,a]=s;if(!(o&&[pn,gn].includes(l)))if(l.indexOf("on")===0){if(r.has(l)||r.set(l,[]),typeof a=="function"){var u;(u=r.get(l))==null||u.push(a),c[l]=function(){for(var d,h=arguments.length,m=new Array(h),p=0;p<h;p++)m[p]=arguments[p];return(d=r.get(l))==null?void 0:d.map(g=>g(...m)).find(g=>g!==void 0)}}}else c[l]=a}),c),{})}}function hr(e){e===void 0&&(e=[]);const t=e.map(f=>f==null?void 0:f.reference),n=e.map(f=>f==null?void 0:f.floating),r=e.map(f=>f==null?void 0:f.item),o=y.useCallback(f=>Ot(f,e,"reference"),t),i=y.useCallback(f=>Ot(f,e,"floating"),n),c=y.useCallback(f=>Ot(f,e,"item"),r);return y.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:c}),[o,i,c])}const Ws=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function zs(e,t){var n,r;t===void 0&&(t={});const{open:o,elements:i,floatingId:c}=e,{enabled:f=!0,role:s="dialog"}=t,l=Gt(),a=((n=i.domReference)==null?void 0:n.id)||l,u=y.useMemo(()=>{var x;return((x=_t(i.floating))==null?void 0:x.id)||c},[i.floating,c]),d=(r=Ws.get(s))!=null?r:s,m=lr()!=null,p=y.useMemo(()=>d==="tooltip"||s==="label"?{["aria-"+(s==="label"?"labelledby":"describedby")]:o?u:void 0}:{"aria-expanded":o?"true":"false","aria-haspopup":d==="alertdialog"?"dialog":d,"aria-controls":o?u:void 0,...d==="listbox"&&{role:"combobox"},...d==="menu"&&{id:a},...d==="menu"&&m&&{role:"menuitem"},...s==="select"&&{"aria-autocomplete":"none"},...s==="combobox"&&{"aria-autocomplete":"list"}},[d,u,m,o,a,s]),g=y.useMemo(()=>{const x={id:u,...d&&{role:d}};return d==="tooltip"||s==="label"?x:{...x,...d==="menu"&&{"aria-labelledby":a}}},[d,u,a,s]),E=y.useCallback(x=>{let{active:b,selected:A}=x;const M={role:"option",...b&&{id:u+"-fui-option"}};switch(s){case"select":case"combobox":return{...M,"aria-selected":A}}return{}},[u,s]);return y.useMemo(()=>f?{reference:p,floating:g,item:E}:{},[f,p,g,E])}var J=(e=>(e.Closed="Closed",e.Opened="Opened",e))(J||{}),He=(e=>(e.LG="Large",e.SM="Small",e))(He||{});const Ys=({title:e,btnClassNames:t,iconWidth:n,iconHeight:r,onClick:o})=>w.jsx("button",{type:"button","aria-label":"button",className:t,title:e,onClick:o,children:w.jsx(Ie.IconX,{height:r||20,width:n||20})}),Ks=({portalId:e,state:t=J.Opened,heading:n,size:r,onClose:o,children:i,overlayClassName:c,containerClassName:f,dividers:s=!0,closeButtonTitle:l})=>{const{refs:a,context:u}=dr({open:t!==J.Closed&&!!t,onOpenChange:o}),d=zs(u,{role:"dialog"}),h=fr(u,{outsidePress:!0}),{getFloatingProps:m}=hr([d,h]),p=S.useCallback(g=>{g==null||g.preventDefault(),g==null||g.stopPropagation(),o()},[o]);return w.jsx(Os,{id:e,children:t!==J.Closed&&w.jsx(Bs,{className:ee("z-[52] flex items-center justify-center bg-blackout p-4",c),children:w.jsx(ks,{context:u,children:w.jsxs("div",{className:ee("relative max-h-full modal rounded bg-white flex flex-col shadow w-full",r===He.LG&&"max-w-[65%]",r===He.SM&&"max-w-[30%]",s&&"divide-neutrals-400 divide-y",f,"sm:w-full sm:max-w-full sm:px-4 sm:py-6"),ref:a.setFloating,...m({onClick(g){g.stopPropagation()}}),children:[w.jsxs("div",{className:"flex flex-row justify-between py-3 px-6 items-center mb-2 modal-heading sm:p-0 sm:pb-2",children:[n&&(typeof n=="string"?w.jsx("h2",{className:"flex-1 min-w-0 mr-3 modal-heading-title sm:h3",children:n}):n),w.jsx(Ys,{title:l,onClick:p,btnClassNames:"sm:h-[24px] sm:w-[24px] sm:top-4"})]}),i.map(g=>g)]})})})})},Qt=e=>e.state===J.Closed?null:w.jsx(Ks,{...e}),Gs=({onCloseModal:e,disableModalDividers:t,deleteConversation:n,isSmallButton:r,titles:o,locale:i})=>w.jsxs(Qt,{heading:(o==null?void 0:o.deleteTitle)??"Delete conversation",portalId:"delete-conversation",containerClassName:"delete-conversation-popup",size:He.SM,dividers:!t,onClose:e,closeButtonTitle:(o==null?void 0:o.close)??"Cancel",children:[w.jsx("div",{className:"py-4 px-6 sm:px-0",lang:i,children:(o==null?void 0:o.deleteMessage)??"Are you sure you want to delete this conversation? This action cannot be undone."}),w.jsxs("div",{className:"flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer",children:[w.jsx(Oe,{buttonClassName:"cancel-button",title:(o==null?void 0:o.cancel)??"Cancel",isSmallButton:r,onClick:c=>{c.stopPropagation(),e()}}),w.jsx(Oe,{buttonClassName:"text-button-primary text-button-primary-error",title:(o==null?void 0:o.delete)??"Delete",isSmallButton:r,onClick:c=>{c.stopPropagation(),n()}})]})]}),Xs=e=>{const t=e.messages.flatMap(r=>{var c,f,s;const o=((c=r.custom_content)==null?void 0:c.attachments)||[],i=((s=(f=r.custom_content)==null?void 0:f.stages)==null?void 0:s.flatMap(({attachments:l})=>l??[]))||[];return[...o,...i]})||[],n=Js(t).map(r=>({...r,relativePath:"",contentLength:0}));return Ht.uniqBy(n,r=>Ke(r.relativePath,r.name))},qs=e=>e.endsWith("/"),Qs=e=>{const t=e.toLowerCase();return["data:","//","http://","https://","file://","ftp://","mailto:","telnet://","api/files"].some(n=>t.startsWith(n))},Zs=e=>{const t=Ke(...e.split("/").map(r=>decodeURIComponent(r))),n=t.lastIndexOf("/");return{absolutePath:t.slice(0,n),name:t.slice(n+1)}},Js=e=>e?e.map(t=>{if(!t.url||Qs(t.url)||qs(t.url))return null;const{absolutePath:n,name:r}=Zs(t.url);return{id:t.url,name:r,contentType:t.type,folderId:n,absolutePath:n}}).filter(Boolean):[];async function ei(e,t){const n=Xs(e),r=new Lr;n.forEach(f=>{const s=encodeURI(Ke(f.absolutePath,f.name)),l=t(`${s}`.replace("files/","")),a=ti(f.folderId),u=Ke("res",a,f.name);r.file(u,l)});const o={version:5,history:[e].map(ni)||[],folders:[]},i=JSON.stringify(o,null,2);return r.file("conversations/conversations_history.json",i),await r.generateAsync({type:"base64"})}const ti=e=>{const t=e.split("/");return t.length>2?Ke(...t.slice(2)):void 0},ni=e=>Ht.omit(e,["publicationInfo"]),Ke=(...e)=>e.filter(Boolean).join("/");function ri(e,t){const n=document.createElement("a");n.download=t,n.href=e,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(e)}var oi=Object.defineProperty,ht=Object.getOwnPropertySymbols,mr=Object.prototype.hasOwnProperty,pr=Object.prototype.propertyIsEnumerable,On=(e,t,n)=>t in e?oi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ut=(e,t)=>{for(var n in t||(t={}))mr.call(t,n)&&On(e,n,t[n]);if(ht)for(var n of ht(t))pr.call(t,n)&&On(e,n,t[n]);return e},Vt=(e,t)=>{var n={};for(var r in e)mr.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ht)for(var r of ht(e))t.indexOf(r)<0&&pr.call(e,r)&&(n[r]=e[r]);return n};/**
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),X=require("classnames"),E=require("react"),H=require("@epam/statgpt-dial-toolkit"),Y=require("@epam/statgpt-shared-toolkit"),x=require("@epam/statgpt-ui-components"),le=require("lodash"),K=require("@tabler/icons-react"),ye=require("jszip");var B=(t=>(t.DELETE="delete",t.EXPORT="export",t.SHARE="share",t.RENAME="rename",t))(B||{}),U=(t=>(t.SHARED="shared",t.TODAY="today",t.YESTERDAY="yesterday",t.WEEK="week",t.EARLIER="earlier",t))(U||{});const te=(t,r)=>{var o,i;return((i=(o=t==null?void 0:t.resources)==null?void 0:o.filter(a=>(a==null?void 0:a.parentPath)===r))==null?void 0:i.map(a=>{var f,e,n;const c=`${a==null?void 0:a.bucket}/${r}`,p=(n=(e=(f=a==null?void 0:a.url)==null?void 0:f.split("/"))==null?void 0:e.slice(1))==null?void 0:n.join("/");return{...a,folderId:c,id:p,isShared:!0}}))||[]},ce=t=>({[U.SHARED]:t}),Se={[U.TODAY]:[],[U.YESTERDAY]:[],[U.WEEK]:[],[U.EARLIER]:[]},ue=(t,r)=>t.toDateString()===r.toDateString(),De=(t,r)=>{const o=new Date(t.getFullYear(),t.getMonth(),t.getDate()-1);return ue(r,o)},je=(t,r)=>{const o=t.getTime()-r.getTime();return Math.floor(o/(1e3*60*60*24))},Te=t=>{const r=new Date,o=le.cloneDeep(Se);for(const i of t)if(i.updatedAt){const a=new Date(i.updatedAt);let c;ue(r,a)?c=o[U.TODAY]:De(r,a)?c=o[U.YESTERDAY]:je(r,a)<=7?c=o[U.WEEK]:c=o[U.EARLIER],c!=null&&c.some(p=>p.id===i.id)||c.push(i)}return o},de=t=>t==null?void 0:t.sort((r,o)=>((o==null?void 0:o.updatedAt)||0)-((r==null?void 0:r.updatedAt)||0)),Oe=(t,r)=>t===U.SHARED?(r==null?void 0:r.shared)||"Shared":t===U.TODAY?(r==null?void 0:r.today)||"Today":t===U.YESTERDAY?(r==null?void 0:r.yesterday)||"Yesterday":t===U.WEEK?(r==null?void 0:r.lastWeek)||"Last week":(r==null?void 0:r.earlier)||"Earlier";var Le=Object.defineProperty,ne=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable,ie=(t,r,o)=>r in t?Le(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,se=(t,r)=>{for(var o in r||(r={}))he.call(r,o)&&ie(t,o,r[o]);if(ne)for(var o of ne(r))fe.call(r,o)&&ie(t,o,r[o]);return t},oe=(t,r)=>{var o={};for(var i in t)he.call(t,i)&&r.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&ne)for(var i of ne(t))r.indexOf(i)<0&&fe.call(t,i)&&(o[i]=t[i]);return o};/**
|
|
5
2
|
* @license QR Code generator library (TypeScript)
|
|
6
3
|
* Copyright (c) Project Nayuki.
|
|
7
4
|
* SPDX-License-Identifier: MIT
|
|
8
|
-
*/var Le;(e=>{const t=class k{constructor(s,l,a,u){if(this.version=s,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],s<k.MIN_VERSION||s>k.MAX_VERSION)throw new RangeError("Version value out of range");if(u<-1||u>7)throw new RangeError("Mask value out of range");this.size=s*4+17;let d=[];for(let m=0;m<this.size;m++)d.push(!1);for(let m=0;m<this.size;m++)this.modules.push(d.slice()),this.isFunction.push(d.slice());this.drawFunctionPatterns();const h=this.addEccAndInterleave(a);if(this.drawCodewords(h),u==-1){let m=1e9;for(let p=0;p<8;p++){this.applyMask(p),this.drawFormatBits(p);const g=this.getPenaltyScore();g<m&&(u=p,m=g),this.applyMask(p)}}o(0<=u&&u<=7),this.mask=u,this.applyMask(u),this.drawFormatBits(u),this.isFunction=[]}static encodeText(s,l){const a=e.QrSegment.makeSegments(s);return k.encodeSegments(a,l)}static encodeBinary(s,l){const a=e.QrSegment.makeBytes(s);return k.encodeSegments([a],l)}static encodeSegments(s,l,a=1,u=40,d=-1,h=!0){if(!(k.MIN_VERSION<=a&&a<=u&&u<=k.MAX_VERSION)||d<-1||d>7)throw new RangeError("Invalid value");let m,p;for(m=a;;m++){const b=k.getNumDataCodewords(m,l)*8,A=c.getTotalBits(s,m);if(A<=b){p=A;break}if(m>=u)throw new RangeError("Data too long")}for(const b of[k.Ecc.MEDIUM,k.Ecc.QUARTILE,k.Ecc.HIGH])h&&p<=k.getNumDataCodewords(m,b)*8&&(l=b);let g=[];for(const b of s){n(b.mode.modeBits,4,g),n(b.numChars,b.mode.numCharCountBits(m),g);for(const A of b.getData())g.push(A)}o(g.length==p);const E=k.getNumDataCodewords(m,l)*8;o(g.length<=E),n(0,Math.min(4,E-g.length),g),n(0,(8-g.length%8)%8,g),o(g.length%8==0);for(let b=236;g.length<E;b^=253)n(b,8,g);let x=[];for(;x.length*8<g.length;)x.push(0);return g.forEach((b,A)=>x[A>>>3]|=b<<7-(A&7)),new k(m,l,x,d)}getModule(s,l){return 0<=s&&s<this.size&&0<=l&&l<this.size&&this.modules[l][s]}getModules(){return this.modules}drawFunctionPatterns(){for(let a=0;a<this.size;a++)this.setFunctionModule(6,a,a%2==0),this.setFunctionModule(a,6,a%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const s=this.getAlignmentPatternPositions(),l=s.length;for(let a=0;a<l;a++)for(let u=0;u<l;u++)a==0&&u==0||a==0&&u==l-1||a==l-1&&u==0||this.drawAlignmentPattern(s[a],s[u]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(s){const l=this.errorCorrectionLevel.formatBits<<3|s;let a=l;for(let d=0;d<10;d++)a=a<<1^(a>>>9)*1335;const u=(l<<10|a)^21522;o(u>>>15==0);for(let d=0;d<=5;d++)this.setFunctionModule(8,d,r(u,d));this.setFunctionModule(8,7,r(u,6)),this.setFunctionModule(8,8,r(u,7)),this.setFunctionModule(7,8,r(u,8));for(let d=9;d<15;d++)this.setFunctionModule(14-d,8,r(u,d));for(let d=0;d<8;d++)this.setFunctionModule(this.size-1-d,8,r(u,d));for(let d=8;d<15;d++)this.setFunctionModule(8,this.size-15+d,r(u,d));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let s=this.version;for(let a=0;a<12;a++)s=s<<1^(s>>>11)*7973;const l=this.version<<12|s;o(l>>>18==0);for(let a=0;a<18;a++){const u=r(l,a),d=this.size-11+a%3,h=Math.floor(a/3);this.setFunctionModule(d,h,u),this.setFunctionModule(h,d,u)}}drawFinderPattern(s,l){for(let a=-4;a<=4;a++)for(let u=-4;u<=4;u++){const d=Math.max(Math.abs(u),Math.abs(a)),h=s+u,m=l+a;0<=h&&h<this.size&&0<=m&&m<this.size&&this.setFunctionModule(h,m,d!=2&&d!=4)}}drawAlignmentPattern(s,l){for(let a=-2;a<=2;a++)for(let u=-2;u<=2;u++)this.setFunctionModule(s+u,l+a,Math.max(Math.abs(u),Math.abs(a))!=1)}setFunctionModule(s,l,a){this.modules[l][s]=a,this.isFunction[l][s]=!0}addEccAndInterleave(s){const l=this.version,a=this.errorCorrectionLevel;if(s.length!=k.getNumDataCodewords(l,a))throw new RangeError("Invalid argument");const u=k.NUM_ERROR_CORRECTION_BLOCKS[a.ordinal][l],d=k.ECC_CODEWORDS_PER_BLOCK[a.ordinal][l],h=Math.floor(k.getNumRawDataModules(l)/8),m=u-h%u,p=Math.floor(h/u);let g=[];const E=k.reedSolomonComputeDivisor(d);for(let b=0,A=0;b<u;b++){let M=s.slice(A,A+p-d+(b<m?0:1));A+=M.length;const O=k.reedSolomonComputeRemainder(M,E);b<m&&M.push(0),g.push(M.concat(O))}let x=[];for(let b=0;b<g[0].length;b++)g.forEach((A,M)=>{(b!=p-d||M>=m)&&x.push(A[b])});return o(x.length==h),x}drawCodewords(s){if(s.length!=Math.floor(k.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let l=0;for(let a=this.size-1;a>=1;a-=2){a==6&&(a=5);for(let u=0;u<this.size;u++)for(let d=0;d<2;d++){const h=a-d,p=(a+1&2)==0?this.size-1-u:u;!this.isFunction[p][h]&&l<s.length*8&&(this.modules[p][h]=r(s[l>>>3],7-(l&7)),l++)}}o(l==s.length*8)}applyMask(s){if(s<0||s>7)throw new RangeError("Mask value out of range");for(let l=0;l<this.size;l++)for(let a=0;a<this.size;a++){let u;switch(s){case 0:u=(a+l)%2==0;break;case 1:u=l%2==0;break;case 2:u=a%3==0;break;case 3:u=(a+l)%3==0;break;case 4:u=(Math.floor(a/3)+Math.floor(l/2))%2==0;break;case 5:u=a*l%2+a*l%3==0;break;case 6:u=(a*l%2+a*l%3)%2==0;break;case 7:u=((a+l)%2+a*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][a]&&u&&(this.modules[l][a]=!this.modules[l][a])}}getPenaltyScore(){let s=0;for(let d=0;d<this.size;d++){let h=!1,m=0,p=[0,0,0,0,0,0,0];for(let g=0;g<this.size;g++)this.modules[d][g]==h?(m++,m==5?s+=k.PENALTY_N1:m>5&&s++):(this.finderPenaltyAddHistory(m,p),h||(s+=this.finderPenaltyCountPatterns(p)*k.PENALTY_N3),h=this.modules[d][g],m=1);s+=this.finderPenaltyTerminateAndCount(h,m,p)*k.PENALTY_N3}for(let d=0;d<this.size;d++){let h=!1,m=0,p=[0,0,0,0,0,0,0];for(let g=0;g<this.size;g++)this.modules[g][d]==h?(m++,m==5?s+=k.PENALTY_N1:m>5&&s++):(this.finderPenaltyAddHistory(m,p),h||(s+=this.finderPenaltyCountPatterns(p)*k.PENALTY_N3),h=this.modules[g][d],m=1);s+=this.finderPenaltyTerminateAndCount(h,m,p)*k.PENALTY_N3}for(let d=0;d<this.size-1;d++)for(let h=0;h<this.size-1;h++){const m=this.modules[d][h];m==this.modules[d][h+1]&&m==this.modules[d+1][h]&&m==this.modules[d+1][h+1]&&(s+=k.PENALTY_N2)}let l=0;for(const d of this.modules)l=d.reduce((h,m)=>h+(m?1:0),l);const a=this.size*this.size,u=Math.ceil(Math.abs(l*20-a*10)/a)-1;return o(0<=u&&u<=9),s+=u*k.PENALTY_N4,o(0<=s&&s<=2568888),s}getAlignmentPatternPositions(){if(this.version==1)return[];{const s=Math.floor(this.version/7)+2,l=this.version==32?26:Math.ceil((this.version*4+4)/(s*2-2))*2;let a=[6];for(let u=this.size-7;a.length<s;u-=l)a.splice(1,0,u);return a}}static getNumRawDataModules(s){if(s<k.MIN_VERSION||s>k.MAX_VERSION)throw new RangeError("Version number out of range");let l=(16*s+128)*s+64;if(s>=2){const a=Math.floor(s/7)+2;l-=(25*a-10)*a-55,s>=7&&(l-=36)}return o(208<=l&&l<=29648),l}static getNumDataCodewords(s,l){return Math.floor(k.getNumRawDataModules(s)/8)-k.ECC_CODEWORDS_PER_BLOCK[l.ordinal][s]*k.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][s]}static reedSolomonComputeDivisor(s){if(s<1||s>255)throw new RangeError("Degree out of range");let l=[];for(let u=0;u<s-1;u++)l.push(0);l.push(1);let a=1;for(let u=0;u<s;u++){for(let d=0;d<l.length;d++)l[d]=k.reedSolomonMultiply(l[d],a),d+1<l.length&&(l[d]^=l[d+1]);a=k.reedSolomonMultiply(a,2)}return l}static reedSolomonComputeRemainder(s,l){let a=l.map(u=>0);for(const u of s){const d=u^a.shift();a.push(0),l.forEach((h,m)=>a[m]^=k.reedSolomonMultiply(h,d))}return a}static reedSolomonMultiply(s,l){if(s>>>8||l>>>8)throw new RangeError("Byte out of range");let a=0;for(let u=7;u>=0;u--)a=a<<1^(a>>>7)*285,a^=(l>>>u&1)*s;return o(a>>>8==0),a}finderPenaltyCountPatterns(s){const l=s[1];o(l<=this.size*3);const a=l>0&&s[2]==l&&s[3]==l*3&&s[4]==l&&s[5]==l;return(a&&s[0]>=l*4&&s[6]>=l?1:0)+(a&&s[6]>=l*4&&s[0]>=l?1:0)}finderPenaltyTerminateAndCount(s,l,a){return s&&(this.finderPenaltyAddHistory(l,a),l=0),l+=this.size,this.finderPenaltyAddHistory(l,a),this.finderPenaltyCountPatterns(a)}finderPenaltyAddHistory(s,l){l[0]==0&&(s+=this.size),l.pop(),l.unshift(s)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(f,s,l){if(s<0||s>31||f>>>s)throw new RangeError("Value out of range");for(let a=s-1;a>=0;a--)l.push(f>>>a&1)}function r(f,s){return(f>>>s&1)!=0}function o(f){if(!f)throw new Error("Assertion error")}const i=class K{constructor(s,l,a){if(this.mode=s,this.numChars=l,this.bitData=a,l<0)throw new RangeError("Invalid argument");this.bitData=a.slice()}static makeBytes(s){let l=[];for(const a of s)n(a,8,l);return new K(K.Mode.BYTE,s.length,l)}static makeNumeric(s){if(!K.isNumeric(s))throw new RangeError("String contains non-numeric characters");let l=[];for(let a=0;a<s.length;){const u=Math.min(s.length-a,3);n(parseInt(s.substring(a,a+u),10),u*3+1,l),a+=u}return new K(K.Mode.NUMERIC,s.length,l)}static makeAlphanumeric(s){if(!K.isAlphanumeric(s))throw new RangeError("String contains unencodable characters in alphanumeric mode");let l=[],a;for(a=0;a+2<=s.length;a+=2){let u=K.ALPHANUMERIC_CHARSET.indexOf(s.charAt(a))*45;u+=K.ALPHANUMERIC_CHARSET.indexOf(s.charAt(a+1)),n(u,11,l)}return a<s.length&&n(K.ALPHANUMERIC_CHARSET.indexOf(s.charAt(a)),6,l),new K(K.Mode.ALPHANUMERIC,s.length,l)}static makeSegments(s){return s==""?[]:K.isNumeric(s)?[K.makeNumeric(s)]:K.isAlphanumeric(s)?[K.makeAlphanumeric(s)]:[K.makeBytes(K.toUtf8ByteArray(s))]}static makeEci(s){let l=[];if(s<0)throw new RangeError("ECI assignment value out of range");if(s<128)n(s,8,l);else if(s<16384)n(2,2,l),n(s,14,l);else if(s<1e6)n(6,3,l),n(s,21,l);else throw new RangeError("ECI assignment value out of range");return new K(K.Mode.ECI,0,l)}static isNumeric(s){return K.NUMERIC_REGEX.test(s)}static isAlphanumeric(s){return K.ALPHANUMERIC_REGEX.test(s)}getData(){return this.bitData.slice()}static getTotalBits(s,l){let a=0;for(const u of s){const d=u.mode.numCharCountBits(l);if(u.numChars>=1<<d)return 1/0;a+=4+d+u.bitData.length}return a}static toUtf8ByteArray(s){s=encodeURI(s);let l=[];for(let a=0;a<s.length;a++)s.charAt(a)!="%"?l.push(s.charCodeAt(a)):(l.push(parseInt(s.substring(a+1,a+3),16)),a+=2);return l}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let c=i;e.QrSegment=i})(Le||(Le={}));(e=>{(t=>{const n=class{constructor(o,i){this.ordinal=o,this.formatBits=i}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),t.Ecc=n})(e.QrCode||(e.QrCode={}))})(Le||(Le={}));(e=>{(t=>{const n=class{constructor(o,i){this.modeBits=o,this.numBitsCharCount=i}numCharCountBits(o){return this.numBitsCharCount[Math.floor((o+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),t.Mode=n})(e.QrSegment||(e.QrSegment={}))})(Le||(Le={}));var Be=Le;/**
|
|
5
|
+
*/var V;(t=>{const r=class R{constructor(e,n,s,l){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<R.MIN_VERSION||e>R.MAX_VERSION)throw new RangeError("Version value out of range");if(l<-1||l>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let u=[];for(let h=0;h<this.size;h++)u.push(!1);for(let h=0;h<this.size;h++)this.modules.push(u.slice()),this.isFunction.push(u.slice());this.drawFunctionPatterns();const m=this.addEccAndInterleave(s);if(this.drawCodewords(m),l==-1){let h=1e9;for(let w=0;w<8;w++){this.applyMask(w),this.drawFormatBits(w);const g=this.getPenaltyScore();g<h&&(l=w,h=g),this.applyMask(w)}}a(0<=l&&l<=7),this.mask=l,this.applyMask(l),this.drawFormatBits(l),this.isFunction=[]}static encodeText(e,n){const s=t.QrSegment.makeSegments(e);return R.encodeSegments(s,n)}static encodeBinary(e,n){const s=t.QrSegment.makeBytes(e);return R.encodeSegments([s],n)}static encodeSegments(e,n,s=1,l=40,u=-1,m=!0){if(!(R.MIN_VERSION<=s&&s<=l&&l<=R.MAX_VERSION)||u<-1||u>7)throw new RangeError("Invalid value");let h,w;for(h=s;;h++){const C=R.getNumDataCodewords(h,n)*8,I=p.getTotalBits(e,h);if(I<=C){w=I;break}if(h>=l)throw new RangeError("Data too long")}for(const C of[R.Ecc.MEDIUM,R.Ecc.QUARTILE,R.Ecc.HIGH])m&&w<=R.getNumDataCodewords(h,C)*8&&(n=C);let g=[];for(const C of e){o(C.mode.modeBits,4,g),o(C.numChars,C.mode.numCharCountBits(h),g);for(const I of C.getData())g.push(I)}a(g.length==w);const A=R.getNumDataCodewords(h,n)*8;a(g.length<=A),o(0,Math.min(4,A-g.length),g),o(0,(8-g.length%8)%8,g),a(g.length%8==0);for(let C=236;g.length<A;C^=253)o(C,8,g);let M=[];for(;M.length*8<g.length;)M.push(0);return g.forEach((C,I)=>M[I>>>3]|=C<<7-(I&7)),new R(h,n,M,u)}getModule(e,n){return 0<=e&&e<this.size&&0<=n&&n<this.size&&this.modules[n][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let s=0;s<this.size;s++)this.setFunctionModule(6,s,s%2==0),this.setFunctionModule(s,6,s%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),n=e.length;for(let s=0;s<n;s++)for(let l=0;l<n;l++)s==0&&l==0||s==0&&l==n-1||s==n-1&&l==0||this.drawAlignmentPattern(e[s],e[l]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const n=this.errorCorrectionLevel.formatBits<<3|e;let s=n;for(let u=0;u<10;u++)s=s<<1^(s>>>9)*1335;const l=(n<<10|s)^21522;a(l>>>15==0);for(let u=0;u<=5;u++)this.setFunctionModule(8,u,i(l,u));this.setFunctionModule(8,7,i(l,6)),this.setFunctionModule(8,8,i(l,7)),this.setFunctionModule(7,8,i(l,8));for(let u=9;u<15;u++)this.setFunctionModule(14-u,8,i(l,u));for(let u=0;u<8;u++)this.setFunctionModule(this.size-1-u,8,i(l,u));for(let u=8;u<15;u++)this.setFunctionModule(8,this.size-15+u,i(l,u));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let s=0;s<12;s++)e=e<<1^(e>>>11)*7973;const n=this.version<<12|e;a(n>>>18==0);for(let s=0;s<18;s++){const l=i(n,s),u=this.size-11+s%3,m=Math.floor(s/3);this.setFunctionModule(u,m,l),this.setFunctionModule(m,u,l)}}drawFinderPattern(e,n){for(let s=-4;s<=4;s++)for(let l=-4;l<=4;l++){const u=Math.max(Math.abs(l),Math.abs(s)),m=e+l,h=n+s;0<=m&&m<this.size&&0<=h&&h<this.size&&this.setFunctionModule(m,h,u!=2&&u!=4)}}drawAlignmentPattern(e,n){for(let s=-2;s<=2;s++)for(let l=-2;l<=2;l++)this.setFunctionModule(e+l,n+s,Math.max(Math.abs(l),Math.abs(s))!=1)}setFunctionModule(e,n,s){this.modules[n][e]=s,this.isFunction[n][e]=!0}addEccAndInterleave(e){const n=this.version,s=this.errorCorrectionLevel;if(e.length!=R.getNumDataCodewords(n,s))throw new RangeError("Invalid argument");const l=R.NUM_ERROR_CORRECTION_BLOCKS[s.ordinal][n],u=R.ECC_CODEWORDS_PER_BLOCK[s.ordinal][n],m=Math.floor(R.getNumRawDataModules(n)/8),h=l-m%l,w=Math.floor(m/l);let g=[];const A=R.reedSolomonComputeDivisor(u);for(let C=0,I=0;C<l;C++){let P=e.slice(I,I+w-u+(C<h?0:1));I+=P.length;const S=R.reedSolomonComputeRemainder(P,A);C<h&&P.push(0),g.push(P.concat(S))}let M=[];for(let C=0;C<g[0].length;C++)g.forEach((I,P)=>{(C!=w-u||P>=h)&&M.push(I[C])});return a(M.length==m),M}drawCodewords(e){if(e.length!=Math.floor(R.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let s=this.size-1;s>=1;s-=2){s==6&&(s=5);for(let l=0;l<this.size;l++)for(let u=0;u<2;u++){const m=s-u,w=(s+1&2)==0?this.size-1-l:l;!this.isFunction[w][m]&&n<e.length*8&&(this.modules[w][m]=i(e[n>>>3],7-(n&7)),n++)}}a(n==e.length*8)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let s=0;s<this.size;s++){let l;switch(e){case 0:l=(s+n)%2==0;break;case 1:l=n%2==0;break;case 2:l=s%3==0;break;case 3:l=(s+n)%3==0;break;case 4:l=(Math.floor(s/3)+Math.floor(n/2))%2==0;break;case 5:l=s*n%2+s*n%3==0;break;case 6:l=(s*n%2+s*n%3)%2==0;break;case 7:l=((s+n)%2+s*n%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[n][s]&&l&&(this.modules[n][s]=!this.modules[n][s])}}getPenaltyScore(){let e=0;for(let u=0;u<this.size;u++){let m=!1,h=0,w=[0,0,0,0,0,0,0];for(let g=0;g<this.size;g++)this.modules[u][g]==m?(h++,h==5?e+=R.PENALTY_N1:h>5&&e++):(this.finderPenaltyAddHistory(h,w),m||(e+=this.finderPenaltyCountPatterns(w)*R.PENALTY_N3),m=this.modules[u][g],h=1);e+=this.finderPenaltyTerminateAndCount(m,h,w)*R.PENALTY_N3}for(let u=0;u<this.size;u++){let m=!1,h=0,w=[0,0,0,0,0,0,0];for(let g=0;g<this.size;g++)this.modules[g][u]==m?(h++,h==5?e+=R.PENALTY_N1:h>5&&e++):(this.finderPenaltyAddHistory(h,w),m||(e+=this.finderPenaltyCountPatterns(w)*R.PENALTY_N3),m=this.modules[g][u],h=1);e+=this.finderPenaltyTerminateAndCount(m,h,w)*R.PENALTY_N3}for(let u=0;u<this.size-1;u++)for(let m=0;m<this.size-1;m++){const h=this.modules[u][m];h==this.modules[u][m+1]&&h==this.modules[u+1][m]&&h==this.modules[u+1][m+1]&&(e+=R.PENALTY_N2)}let n=0;for(const u of this.modules)n=u.reduce((m,h)=>m+(h?1:0),n);const s=this.size*this.size,l=Math.ceil(Math.abs(n*20-s*10)/s)-1;return a(0<=l&&l<=9),e+=l*R.PENALTY_N4,a(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{const e=Math.floor(this.version/7)+2,n=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2;let s=[6];for(let l=this.size-7;s.length<e;l-=n)s.splice(1,0,l);return s}}static getNumRawDataModules(e){if(e<R.MIN_VERSION||e>R.MAX_VERSION)throw new RangeError("Version number out of range");let n=(16*e+128)*e+64;if(e>=2){const s=Math.floor(e/7)+2;n-=(25*s-10)*s-55,e>=7&&(n-=36)}return a(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(R.getNumRawDataModules(e)/8)-R.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*R.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let n=[];for(let l=0;l<e-1;l++)n.push(0);n.push(1);let s=1;for(let l=0;l<e;l++){for(let u=0;u<n.length;u++)n[u]=R.reedSolomonMultiply(n[u],s),u+1<n.length&&(n[u]^=n[u+1]);s=R.reedSolomonMultiply(s,2)}return n}static reedSolomonComputeRemainder(e,n){let s=n.map(l=>0);for(const l of e){const u=l^s.shift();s.push(0),n.forEach((m,h)=>s[h]^=R.reedSolomonMultiply(m,u))}return s}static reedSolomonMultiply(e,n){if(e>>>8||n>>>8)throw new RangeError("Byte out of range");let s=0;for(let l=7;l>=0;l--)s=s<<1^(s>>>7)*285,s^=(n>>>l&1)*e;return a(s>>>8==0),s}finderPenaltyCountPatterns(e){const n=e[1];a(n<=this.size*3);const s=n>0&&e[2]==n&&e[3]==n*3&&e[4]==n&&e[5]==n;return(s&&e[0]>=n*4&&e[6]>=n?1:0)+(s&&e[6]>=n*4&&e[0]>=n?1:0)}finderPenaltyTerminateAndCount(e,n,s){return e&&(this.finderPenaltyAddHistory(n,s),n=0),n+=this.size,this.finderPenaltyAddHistory(n,s),this.finderPenaltyCountPatterns(s)}finderPenaltyAddHistory(e,n){n[0]==0&&(e+=this.size),n.pop(),n.unshift(e)}};r.MIN_VERSION=1,r.MAX_VERSION=40,r.PENALTY_N1=3,r.PENALTY_N2=3,r.PENALTY_N3=40,r.PENALTY_N4=10,r.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],r.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=r;function o(f,e,n){if(e<0||e>31||f>>>e)throw new RangeError("Value out of range");for(let s=e-1;s>=0;s--)n.push(f>>>s&1)}function i(f,e){return(f>>>e&1)!=0}function a(f){if(!f)throw new Error("Assertion error")}const c=class y{constructor(e,n,s){if(this.mode=e,this.numChars=n,this.bitData=s,n<0)throw new RangeError("Invalid argument");this.bitData=s.slice()}static makeBytes(e){let n=[];for(const s of e)o(s,8,n);return new y(y.Mode.BYTE,e.length,n)}static makeNumeric(e){if(!y.isNumeric(e))throw new RangeError("String contains non-numeric characters");let n=[];for(let s=0;s<e.length;){const l=Math.min(e.length-s,3);o(parseInt(e.substring(s,s+l),10),l*3+1,n),s+=l}return new y(y.Mode.NUMERIC,e.length,n)}static makeAlphanumeric(e){if(!y.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n=[],s;for(s=0;s+2<=e.length;s+=2){let l=y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(s))*45;l+=y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(s+1)),o(l,11,n)}return s<e.length&&o(y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(s)),6,n),new y(y.Mode.ALPHANUMERIC,e.length,n)}static makeSegments(e){return e==""?[]:y.isNumeric(e)?[y.makeNumeric(e)]:y.isAlphanumeric(e)?[y.makeAlphanumeric(e)]:[y.makeBytes(y.toUtf8ByteArray(e))]}static makeEci(e){let n=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)o(e,8,n);else if(e<16384)o(2,2,n),o(e,14,n);else if(e<1e6)o(6,3,n),o(e,21,n);else throw new RangeError("ECI assignment value out of range");return new y(y.Mode.ECI,0,n)}static isNumeric(e){return y.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return y.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,n){let s=0;for(const l of e){const u=l.mode.numCharCountBits(n);if(l.numChars>=1<<u)return 1/0;s+=4+u+l.bitData.length}return s}static toUtf8ByteArray(e){e=encodeURI(e);let n=[];for(let s=0;s<e.length;s++)e.charAt(s)!="%"?n.push(e.charCodeAt(s)):(n.push(parseInt(e.substring(s+1,s+3),16)),s+=2);return n}};c.NUMERIC_REGEX=/^[0-9]*$/,c.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,c.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let p=c;t.QrSegment=c})(V||(V={}));(t=>{(r=>{const o=class{constructor(a,c){this.ordinal=a,this.formatBits=c}};o.LOW=new o(0,1),o.MEDIUM=new o(1,0),o.QUARTILE=new o(2,3),o.HIGH=new o(3,2),r.Ecc=o})(t.QrCode||(t.QrCode={}))})(V||(V={}));(t=>{(r=>{const o=class{constructor(a,c){this.modeBits=a,this.numBitsCharCount=c}numCharCountBits(a){return this.numBitsCharCount[Math.floor((a+7)/17)]}};o.NUMERIC=new o(1,[10,12,14]),o.ALPHANUMERIC=new o(2,[9,11,13]),o.BYTE=new o(4,[8,16,16]),o.KANJI=new o(8,[8,10,12]),o.ECI=new o(7,[0,0,0]),r.Mode=o})(t.QrSegment||(t.QrSegment={}))})(V||(V={}));var W=V;/**
|
|
9
6
|
* @license qrcode.react
|
|
10
7
|
* Copyright (c) Paul O'Shannessy
|
|
11
8
|
* SPDX-License-Identifier: ISC
|
|
12
|
-
*/var si={L:Be.QrCode.Ecc.LOW,M:Be.QrCode.Ecc.MEDIUM,Q:Be.QrCode.Ecc.QUARTILE,H:Be.QrCode.Ecc.HIGH},gr=128,br="L",wr="#FFFFFF",xr="#000000",Er=!1,yr=1,ii=4,li=0,ai=.1;function Rr(e,t=0){const n=[];return e.forEach(function(r,o){let i=null;r.forEach(function(c,f){if(!c&&i!==null){n.push(`M${i+t} ${o+t}h${f-i}v1H${i+t}z`),i=null;return}if(f===r.length-1){if(!c)return;i===null?n.push(`M${f+t},${o+t} h1v1H${f+t}z`):n.push(`M${i+t},${o+t} h${f+1-i}v1H${i+t}z`);return}c&&i===null&&(i=f)})}),n.join("")}function vr(e,t){return e.slice().map((n,r)=>r<t.y||r>=t.y+t.h?n:n.map((o,i)=>i<t.x||i>=t.x+t.w?o:!1))}function ci(e,t,n,r){if(r==null)return null;const o=e.length+n*2,i=Math.floor(t*ai),c=o/t,f=(r.width||i)*c,s=(r.height||i)*c,l=r.x==null?e.length/2-f/2:r.x*c,a=r.y==null?e.length/2-s/2:r.y*c,u=r.opacity==null?1:r.opacity;let d=null;if(r.excavate){let m=Math.floor(l),p=Math.floor(a),g=Math.ceil(f+l-m),E=Math.ceil(s+a-p);d={x:m,y:p,w:g,h:E}}const h=r.crossOrigin;return{x:l,y:a,h:s,w:f,excavation:d,opacity:u,crossOrigin:h}}function ui(e,t){return t!=null?Math.max(Math.floor(t),0):e?ii:li}function Cr({value:e,level:t,minVersion:n,includeMargin:r,marginSize:o,imageSettings:i,size:c,boostLevel:f}){let s=S.useMemo(()=>{const m=(Array.isArray(e)?e:[e]).reduce((p,g)=>(p.push(...Be.QrSegment.makeSegments(g)),p),[]);return Be.QrCode.encodeSegments(m,si[t],n,void 0,void 0,f)},[e,t,n,f]);const{cells:l,margin:a,numCells:u,calculatedImageSettings:d}=S.useMemo(()=>{let h=s.getModules();const m=ui(r,o),p=h.length+m*2,g=ci(h,c,m,i);return{cells:h,margin:m,numCells:p,calculatedImageSettings:g}},[s,c,i,r,o]);return{qrcode:s,margin:a,cells:l,numCells:u,calculatedImageSettings:d}}var fi=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),di=S.forwardRef(function(t,n){const r=t,{value:o,size:i=gr,level:c=br,bgColor:f=wr,fgColor:s=xr,includeMargin:l=Er,minVersion:a=yr,boostLevel:u,marginSize:d,imageSettings:h}=r,p=Vt(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:g}=p,E=Vt(p,["style"]),x=h==null?void 0:h.src,b=S.useRef(null),A=S.useRef(null),M=S.useCallback(C=>{b.current=C,typeof n=="function"?n(C):n&&(n.current=C)},[n]),[O,N]=S.useState(!1),{margin:D,cells:V,numCells:_,calculatedImageSettings:P}=Cr({value:o,level:c,minVersion:a,boostLevel:u,includeMargin:l,marginSize:d,imageSettings:h,size:i});S.useEffect(()=>{if(b.current!=null){const C=b.current,R=C.getContext("2d");if(!R)return;let T=V;const I=A.current,v=P!=null&&I!==null&&I.complete&&I.naturalHeight!==0&&I.naturalWidth!==0;v&&P.excavation!=null&&(T=vr(V,P.excavation));const L=window.devicePixelRatio||1;C.height=C.width=i*L;const $=i/_*L;R.scale($,$),R.fillStyle=f,R.fillRect(0,0,_,_),R.fillStyle=s,fi?R.fill(new Path2D(Rr(T,D))):V.forEach(function(q,te){q.forEach(function(F,re){F&&R.fillRect(re+D,te+D,1,1)})}),P&&(R.globalAlpha=P.opacity),v&&R.drawImage(I,P.x+D,P.y+D,P.w,P.h)}}),S.useEffect(()=>{N(!1)},[x]);const z=Ut({height:i,width:i},g);let H=null;return x!=null&&(H=S.createElement("img",{src:x,key:x,style:{display:"none"},onLoad:()=>{N(!0)},ref:A,crossOrigin:P==null?void 0:P.crossOrigin})),S.createElement(S.Fragment,null,S.createElement("canvas",Ut({style:z,height:i,width:i,ref:M,role:"img"},E)),H)});di.displayName="QRCodeCanvas";var Ar=S.forwardRef(function(t,n){const r=t,{value:o,size:i=gr,level:c=br,bgColor:f=wr,fgColor:s=xr,includeMargin:l=Er,minVersion:a=yr,boostLevel:u,title:d,marginSize:h,imageSettings:m}=r,p=Vt(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:g,cells:E,numCells:x,calculatedImageSettings:b}=Cr({value:o,level:c,minVersion:a,boostLevel:u,includeMargin:l,marginSize:h,imageSettings:m,size:i});let A=E,M=null;m!=null&&b!=null&&(b.excavation!=null&&(A=vr(E,b.excavation)),M=S.createElement("image",{href:m.src,height:b.h,width:b.w,x:b.x+g,y:b.y+g,preserveAspectRatio:"none",opacity:b.opacity,crossOrigin:b.crossOrigin}));const O=Rr(A,g);return S.createElement("svg",Ut({height:i,width:i,viewBox:`0 0 ${x} ${x}`,ref:n,role:"img"},p),!!d&&S.createElement("title",null,d),S.createElement("path",{fill:f,d:`M0,0 h${x}v${x}H0z`,shapeRendering:"crispEdges"}),S.createElement("path",{fill:s,d:O,shapeRendering:"crispEdges"}),M)});Ar.displayName="QRCodeSVG";var Mr=(e=>(e.LINK="link",e))(Mr||{});const Sr="share",hi="onboarding",mi=(e,t)=>({invitationType:Mr.LINK,resources:[{url:`conversations/${encodeURI(e)}`},...t]}),pi=e=>{var n;const t=((n=e==null?void 0:e.invitationLink)==null?void 0:n.split("/").at(-1))||"";return`/${Sr}/${t}`},gi=(e,t)=>t==null?void 0:t.find(n=>{var i,c,f,s;const r=(c=(i=e==null?void 0:e.id)==null?void 0:i.split("/"))==null?void 0:c.pop(),o=((s=(f=n==null?void 0:n.url)==null?void 0:f.split("/"))==null?void 0:s.pop())||"";return o===r||decodeURI(o)===r}),bi=e=>{var n,r;const t=(n=e==null?void 0:e.messages)==null?void 0:n.filter(o=>{var i;return!!((i=o==null?void 0:o.custom_content)!=null&&i.attachments)});return((r=t==null?void 0:t.flatMap(o=>{var i,c;return((c=(i=o==null?void 0:o.custom_content)==null?void 0:i.attachments)==null?void 0:c.map(f=>({url:(f==null?void 0:f.url)||""})))||[]}))==null?void 0:r.filter(o=>!!(o!=null&&o.url)))||[]},Tr=({value:e,inputId:t,placeholder:n="",cssClass:r="",type:o="text",disabled:i,readonly:c,onChange:f,onKeyDown:s})=>{const l=ee("truncate outline-none shadow-none body-1",r,c?"pointer-events-none":"");return w.jsx("input",{type:o,autoComplete:"off",id:t,placeholder:n,value:e||"",title:e?String(e):"",disabled:i,className:l,onKeyDown:s,onChange:a=>f==null?void 0:f(a.currentTarget.value)})},Nr=({iconBeforeInput:e,iconAfterInput:t,containerClasses:n,cssClass:r,...o})=>w.jsxs("div",{className:ee("input w-full flex flex-row",n),children:[e,w.jsx(Tr,{cssClass:ee("border-0 bg-transparent p-0 h-full shadow-none flex-1 min-w-0 rounded-none",r),...o}),t]});var Ir=(e=>(e.CONVERSATION="CONVERSATION",e))(Ir||{}),ze=(e=>(e.ME="me",e.OTHERS="others",e))(ze||{});const rt=e=>({resourceTypes:[Ir.CONVERSATION],with:e}),wi=({conversation:e,locale:t,onCloseModal:n,modalDividers:r,getConversation:o,generateConversationLink:i,chatExpiration:c,chatExpirationDays:f,close:s,chatWarning:l,shareLink:a,shareCopyLink:u,shareCopiedLink:d,shareDescription:h,shareRemoveAccessToUsers:m,chatName:p,getSharedConversations:g,revokeSharedConversations:E,baseUrl:x,id:b,clientSharedPage:A,clientSharedProp:M})=>{const[O,N]=S.useState(null),[D,V]=S.useState(),[_,P]=S.useState(!1),[z,H]=S.useState(!1),[C,R]=S.useState(),T=S.useMemo(()=>{var te;const q=x||window.location.origin;if(x&&x!==window.location.origin&&A&&M){const F=(te=O==null?void 0:O.split(`/${Sr}/`))==null?void 0:te[1];return`${q}/${A}?${M}=${F}`}return`${q}/${t}${O}`},[x,O,t,A,M]);S.useEffect(()=>{(async()=>{try{const te=decodeURI(e?e==null?void 0:e.id:`${b==null?void 0:b[0]}/${t}/${b==null?void 0:b[1]}`),F=`${decodeURI(te)}`,re=await(o==null?void 0:o(F)),Y=mi(te,bi(re)),ne=await(i==null?void 0:i(Y)),ie=await(g==null?void 0:g(rt(ze.OTHERS)));ne&&ie&&(P(!0),N(pi(ne)),V(gi(e,ie==null?void 0:ie.resources)))}catch(te){P(!1),console.error("Error sharing conversation",te)}})()},[e,i,o,g,b,t]);const I=S.useCallback(()=>{n(),N(null),P(!1),H(!1)},[n]),v=S.useCallback(()=>{H(!0),navigator.clipboard.writeText(T||"")},[T]),L=async()=>{try{R(!0),D&&await(E==null?void 0:E({resources:[D]}))}catch(q){R(!1),console.error("Error revoking shared conversation",q)}},$=S.useCallback(()=>w.jsx(Oe,{buttonClassName:z?"text-button-secondary":"text-button-primary",iconBefore:z?w.jsx(Ie.IconCheck,{width:20,height:20}):w.jsx(Ie.IconCopy,{width:20,height:20}),title:z?d??"Copied":u??"Copy link",disabled:z,onClick:v}),[z,v,d,u]);return w.jsxs(Qt,{heading:a??"Share link",portalId:"share",size:He.SM,dividers:r,onClose:I,closeButtonTitle:s??"Close",children:[_?w.jsxs("div",{className:"share flex flex-col gap-y-4 px-6 pb-6 overflow-auto sm:p-0",children:[e!=null&&e.name?w.jsxs("div",{className:"flex share-info w-full",children:[w.jsx("p",{className:"share-info-title text-neutrals-800 mr-1 body-1",children:p??"Chat name:"}),w.jsx("h3",{className:"flex-1 min-w-0 truncate",title:e==null?void 0:e.name,children:e==null?void 0:e.name})]}):null,w.jsxs("div",{className:"flex share-info",children:[w.jsx("p",{className:"share-info-title text-neutrals-800 mr-1 body-1",children:c??"Link expiration date:"}),w.jsxs("h3",{children:["3 ",f??"days"]})]}),w.jsx(Ar,{className:"self-center border border-neutrals-600 p-2 rounded min-h-[200px]",value:T,size:200}),w.jsx("p",{className:"body-2 text-neutrals-1000",children:h??"Your name, special instructions, and any messages you add after sharing remain confidential."}),w.jsx(Nr,{containerClasses:"share-input-container",cssClass:"share-input",readonly:!0,placeholder:T,value:T,inputId:"conversationLink",iconAfterInput:$()})]}):w.jsx("div",{className:"flex justify-center items-center py-6 px-6",children:w.jsx(Wt,{})}),_?e&&D?w.jsx("div",{className:"remove-access",children:w.jsx(Oe,{title:m??"Remove access to all users",buttonClassName:"remove-access-button py-3 px-4",isSmallButton:!0,disabled:C,onClick:L})}):w.jsx("p",{className:"body-2 text-neutrals-800 share-footer",children:l??"This chat has not been shared with anyone yet."}):w.jsx("div",{})]})},xi=({triggerButton:e,options:t,content:n,selectedOption:r,disabled:o,containerClassName:i,openedClassName:c,onOptionSelect:f})=>{const[s,l]=S.useState(!1),{refs:a,floatingStyles:u,context:d}=dr({open:s,onOpenChange:o?void 0:l,placement:"bottom-end",middleware:[hs(8),ps(),ms()],whileElementsMounted:ss}),h=$s(d),m=fr(d,{outsidePress:!0}),{getReferenceProps:p,getFloatingProps:g}=hr([h,m]);return w.jsxs(w.Fragment,{children:[w.jsx("div",{ref:a.setReference,...p({onClick(E){E.stopPropagation()}}),className:ee(i,s&&c),children:e}),s&&w.jsxs("div",{ref:a.setFloating,style:u,className:"flex flex-col z-10 dropdown-menu-shadow bg-white dropdown-container rounded",...g(),children:[n&&n,t&&t.map(E=>w.jsx("div",{onClick:x=>{x.stopPropagation(),f==null||f(E.key),l(!1)},className:ee("text-neutrals-900 body-3 cursor-pointer dropdown-item min-w-[200px]",r===E.key&&"bg-hues-100"),children:w.jsxs("div",{className:"p-2 hover:bg-hues-100 h-full dropdown-item-text flex items-center gap-x-2",title:E.title,children:[E.icon?E.icon:null,w.jsx("p",{children:E==null?void 0:E.title})]})},E.key))]})]})},Zt=e=>(e==null?void 0:e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").replace(/-/g," "))||"",Ei=({conversation:e,onCloseModal:t,renameCoversation:n,locale:r,disableModalDividers:o,titles:i,isSmallButton:c})=>{const[f,s]=S.useState((e==null?void 0:e.name)||""),l=u=>{s(u)},a=()=>{const u=`${e==null?void 0:e.folderId}/${encodeURIComponent(Zt(f))}-${new Date().getTime()}`;n(`conversations/${e.id}`,`conversations/${u}`)};return w.jsxs(Qt,{heading:(i==null?void 0:i.renameTitle)??"Rename conversation",portalId:"rename-conversation",containerClassName:"rename-conversation-popup",size:He.SM,dividers:!o,onClose:t,closeButtonTitle:(i==null?void 0:i.close)??"Cancel",children:[w.jsx("div",{className:"py-4 px-6 sm:px-0",lang:r,children:w.jsx(Tr,{inputId:"rename",value:f,onChange:l,cssClass:"w-full"})}),w.jsxs("div",{className:"flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer",children:[w.jsx(Oe,{buttonClassName:"cancel-button",title:(i==null?void 0:i.cancel)??"Cancel",isSmallButton:c,onClick:u=>{u.stopPropagation(),t()}}),w.jsx(Oe,{buttonClassName:"text-button-primary text-button-primary",title:(i==null?void 0:i.save)??"Rename",isSmallButton:c,disabled:!f,onClick:u=>{u.stopPropagation(),a()}})]})]})},Or=({conversation:e,conversationStyles:t,shareConversationProps:n,onConversationDelete:r,getConversation:o,getFileBlob:i,renameConversation:c,triggerButton:f,locale:s})=>{var O;const l=S.useMemo(()=>{var D,V,_,P,z,H,C,R,T,I;const N=[{key:oe.DELETE,title:((D=t==null?void 0:t.titles)==null?void 0:D.delete)??"Delete",icon:(V=t.actionsIcons)==null?void 0:V[oe.DELETE]}];return(P=(_=e==null?void 0:e.model)==null?void 0:_.id)!=null&&P.endsWith(hi)?N:[...e.isShared?[]:[{key:oe.SHARE,title:((z=t==null?void 0:t.titles)==null?void 0:z.share)??"Share",icon:(H=t.actionsIcons)==null?void 0:H[oe.SHARE]},{key:oe.RENAME,title:((C=t==null?void 0:t.titles)==null?void 0:C.rename)??"Rename",icon:(R=t.actionsIcons)==null?void 0:R[oe.RENAME]}],{key:oe.EXPORT,title:((T=t==null?void 0:t.titles)==null?void 0:T.export)??"Export",icon:(I=t.actionsIcons)==null?void 0:I[oe.EXPORT]},...N]},[e.isShared,(O=e==null?void 0:e.model)==null?void 0:O.id,t.titles,t.actionsIcons]),[a,u]=S.useState(J.Closed),[d,h]=S.useState(J.Closed),[m,p]=S.useState(J.Closed),g=S.useCallback(()=>{u(J.Closed)},[u]),E=S.useCallback(()=>{h(J.Closed)},[h]),x=S.useCallback(()=>{p(J.Closed)},[p]),b=S.useCallback(()=>{r(e),g()},[e,r,g]),A=S.useCallback((N,D)=>{c(N,D),x()},[c,x]),M=N=>{N===oe.DELETE&&u(J.Opened),N===oe.SHARE&&h(J.Opened),N===oe.RENAME&&p(J.Opened),N===oe.EXPORT&&o(decodeURI(e.id)).then(D=>{ei(D,i).then(V=>{ri(`data:application/zip;base64,${V}`,`chat_with_attachments_${new Date().toLocaleDateString()}.dial`)})})};return w.jsxs(w.Fragment,{children:[w.jsx(xi,{containerClassName:"transition-opacity ml-3 group-hover:opacity-100",triggerButton:f??w.jsx(yi,{}),options:l,openedClassName:"action-menu-opened",onOptionSelect:M}),a===J.Opened&&w.jsx(Gs,{titles:t.titles,locale:s,disableModalDividers:t.disableModalDividers,isSmallButton:t.isSmallModalButton,deleteConversation:b,onCloseModal:g}),d===J.Opened&&w.jsx(wi,{conversation:e,locale:s,onCloseModal:E,...n}),m===J.Opened&&w.jsx(Ei,{conversation:e,locale:s,titles:t.titles,renameCoversation:A,onCloseModal:x,disableModalDividers:t.disableModalDividers,isSmallButton:t.isSmallModalButton})]})},yi=()=>w.jsx("div",{className:"cursor-pointer flex items-center justify-center w-[24px]",children:w.jsx(Ie.IconDotsVertical,{width:20,height:20,stroke:2,className:"text-primary"})}),Pr=({conversation:e,selectedConversationId:t,searchQuery:n,onConversationClick:r,actions:o,locale:i,conversationStyles:c,shareConversationProps:f})=>{const s=S.useRef(null),l=Zt(e==null?void 0:e.name);return S.useEffect(()=>{var a;(e==null?void 0:e.id)===t&&((a=s==null?void 0:s.current)==null||a.scrollIntoView({block:"center",behavior:"smooth"}))},[e,t]),w.jsxs("div",{ref:s,className:ee("flex justify-between items-center py-2 px-3 border-transparent relative group cursor-pointer border hover:border-hues-600","conversation-item",t===(e==null?void 0:e.id)&&"bg-hues-100 conversation-item-active"),onClick:()=>r(e.folderId,e==null?void 0:e.id),title:l,children:[w.jsxs("div",{className:"flex w-full min-w-0 items-center",children:[c.conversationItemIcon?c.conversationItemIcon:null,w.jsx("h3",{className:ee("truncate font-semibold text-neutrals-1000 sm:body-2","conversation-item-text",t===(e==null?void 0:e.id)?"conversation-item-text-active":""),title:l,children:n!=null&&n.length?w.jsx($r,{text:l,highlightText:n}):l})]}),w.jsx(Or,{locale:i,conversationStyles:c,conversation:e,onConversationDelete:o.deleteConversation,getConversation:o.getConversation,getFileBlob:o.getFileBlob,renameConversation:o.renameConversation,shareConversationProps:f})]})},Ri=({handleConversationClick:e,actions:t,selectedConversationId:n,groupLabel:r,conversationStyles:o,groupedConversations:i,shareConversationProps:c,locale:f})=>{const[s,l]=S.useState(!1),a=S.useCallback(()=>{l(u=>!u)},[l]);return w.jsxs("div",{children:[w.jsxs("div",{className:"inline-flex gap-1 items-center text-neutrals-700 mb-3 cursor-pointer conversation-group-items-title",onClick:a,children:[w.jsx(Ie.IconCaretRightFilled,{className:ee("w-3 h-3 conversation-group-items-arrow",s?"rotate-[90deg]":"rotate-0")}),w.jsx("span",{className:"body-3 conversation-group-items-title-text",children:_r(r,o==null?void 0:o.titles)})]}),!s&&w.jsx("div",{className:ee("flex flex-col gap-y-3","conversation-group-items"),children:Fn(i).map(u=>w.jsx(Pr,{locale:f,conversationStyles:o,conversation:u,selectedConversationId:n,onConversationClick:e,actions:t,shareConversationProps:c},u.id||u.name))})]},r)},vi=({icon:e,onClick:t,buttonClassName:n,disabled:r,title:o,isBaseIconStyles:i=!0})=>w.jsx("button",{type:"button",className:ee(i&&"base-icon-button",n),onClick:c=>t==null?void 0:t(c),disabled:r,title:o,"aria-label":"button",children:e}),Ci=({searchQuery:e,isExpandedSearch:t,titles:n,onSearchConversations:r,toggleSearchField:o})=>w.jsx(w.Fragment,{children:t?w.jsx(Nr,{inputId:"conversations-search",placeholder:(n==null?void 0:n.searchPlaceholder)??"Search",containerClasses:"conversation-list-search-input h-[40px] bg-transparent px-4 py-2 rounded-full border-neutrals-400 shadow-none",cssClass:"h-auto",value:e,iconAfterInput:w.jsx(vi,{buttonClassName:"text-button-tertiary items-center p-0 ml-4 border-0 w-5 h-5",onClick:o,icon:w.jsx(Ie.IconX,{})}),onChange:r}):w.jsx(Oe,{buttonClassName:"text-button-tertiary p-0 search-button",iconBefore:w.jsx(Ie.IconSearch,{className:"w-5 h-5"}),onClick:o})}),Ai=({conversations:e,selectedConversationId:t,searchQuery:n,conversationStyles:r,handleConversationClick:o,actions:i,locale:c,shareConversationProps:f})=>{var a;const[s,l]=S.useState([]);return S.useEffect(()=>{l(Fn(e==null?void 0:e.filter(u=>{var d;return(d=Zt(u==null?void 0:u.name))==null?void 0:d.includes(n||"")})))},[e,n]),w.jsx(w.Fragment,{children:s!=null&&s.length?s.map(u=>w.jsx(Pr,{locale:c,conversationStyles:r,conversation:u,searchQuery:n,selectedConversationId:t,onConversationClick:o,actions:i,shareConversationProps:f},u.id)):w.jsx("h3",{className:"text-neutrals-800",children:((a=r==null?void 0:r.titles)==null?void 0:a.noConversation)??"No conversations yet"})})},Mi=({titles:e})=>w.jsxs("div",{className:"p-8 text-center flex flex-col",children:[w.jsx("p",{className:"text-neutrals-800",children:(e==null?void 0:e.noConversation)??"No conversations yet"}),w.jsx("p",{className:"text-sm text-neutrals-800 mt-2",children:(e==null?void 0:e.clickNewChat)??'Click "New Chat" to start a conversation'})]}),ke=e=>e.map(t=>({...t,name:t.name.split(/-\d+$/)[0]})),Pt=(e,t)=>{var n,r;return((r=(n=e==null?void 0:e.resources)==null?void 0:n.filter(o=>(o==null?void 0:o.parentPath)===t))==null?void 0:r.map(o=>{var f,s,l;const i=`${o==null?void 0:o.bucket}/${t}`,c=(l=(s=(f=o==null?void 0:o.url)==null?void 0:f.split("/"))==null?void 0:s.slice(1))==null?void 0:l.join("/");return{...o,folderId:i,id:c,isShared:!0}}))||[]},Si=e=>({[se.SHARED]:e}),Ti=({handleConversationClick:e,selectedConversationId:t,actions:n,children:r,isCollapsed:o,conversationStyles:i,conversations:c,locale:f,sharedConversations:s,setConversations:l,setSharedConversations:a,shareConversationProps:u,handleSelectedConversationRemove:d})=>{var C;const[h,m]=S.useState({}),[p,g]=S.useState(!0),[E,x]=S.useState(""),[b,A]=S.useState(!1),{getConversations:M,getSharedConversations:O,deleteConversation:N,renameConversation:D}=n,V=S.useMemo(()=>!!(E!=null&&E.length),[E]);S.useEffect(()=>{m({...Si(s),...Br(c)})},[c,s]),S.useEffect(()=>{async function R(){try{g(!0);const T=await M(f),I=await O(rt(ze.ME));l(ke(T)),a(ke(Pt(I,f)))}catch(T){console.error("Error loading conversation",T)}finally{g(!1)}}R()},[M,l,f,O,a]);const _=S.useCallback(async R=>{try{await N(R);const T=await M(f),I=await O(rt(ze.ME));l(ke(T)),a(ke(Pt(I,f))),t===(R==null?void 0:R.id)&&d()}catch(T){console.error("Error deleting conversation",T)}},[N,M,f,O,l,a,t,d]),P=S.useCallback(async(R,T)=>{try{g(!0),await D(R,T);const I=await M(f),v=await O(rt(ze.ME));l(ke(I)),a(ke(Pt(v,f)))}catch(I){console.error("Error renaming conversation",I)}finally{g(!1)}},[M,f,O,l,a,D]),z=S.useCallback(R=>{x(R)},[x]),H=S.useCallback(()=>{A(R=>!R),x("")},[A]);return p?w.jsx(Wt,{}):w.jsxs(w.Fragment,{children:[!o&&w.jsxs("div",{className:ee("flex justify-between items-center",b?" pt-4 pb-0 sm:pt-10":" pt-6 pb-2 sm:pt-10"),children:[!b&&w.jsx("h3",{className:"text-neutrals-700 sm:body-2",children:((C=i==null?void 0:i.titles)==null?void 0:C.allChats)??"All Chats"}),w.jsx(Ci,{searchQuery:E,titles:i.titles,isExpandedSearch:b,onSearchConversations:z,toggleSearchField:H})]}),w.jsx("div",{className:ee("overflow-y-auto flex flex-col mt-4 flex-1 min-h-0 pr-2",V?"gap-y-1":"gap-y-6"),children:o?null:w.jsx(w.Fragment,{children:(c==null?void 0:c.length)===0&&(s==null?void 0:s.length)===0?w.jsx(Mi,{titles:i.titles}):V?w.jsx(Ai,{locale:f,conversationStyles:i,conversations:[...s,...c],searchQuery:E,selectedConversationId:t,handleConversationClick:e,shareConversationProps:u,actions:{...n,deleteConversation:_}}):Object.entries(h).map(([R,T])=>(T==null?void 0:T.length)>0&&w.jsx(Ri,{locale:f,groupLabel:R,conversationStyles:i,groupedConversations:T,handleConversationClick:e,actions:{...n,deleteConversation:_,renameConversation:P},shareConversationProps:u,selectedConversationId:t},R))})}),r]})};exports.ActionMenu=Or;exports.ActionMenuItem=oe;exports.ConversationList=Ti;
|
|
9
|
+
*/var Be={L:W.QrCode.Ecc.LOW,M:W.QrCode.Ecc.MEDIUM,Q:W.QrCode.Ecc.QUARTILE,H:W.QrCode.Ecc.HIGH},me=128,pe="L",ge="#FFFFFF",Ee="#000000",Ce=!1,we=1,Ue=4,Fe=0,ke=.1;function Re(t,r=0){const o=[];return t.forEach(function(i,a){let c=null;i.forEach(function(p,f){if(!p&&c!==null){o.push(`M${c+r} ${a+r}h${f-c}v1H${c+r}z`),c=null;return}if(f===i.length-1){if(!p)return;c===null?o.push(`M${f+r},${a+r} h1v1H${f+r}z`):o.push(`M${c+r},${a+r} h${f+1-c}v1H${c+r}z`);return}p&&c===null&&(c=f)})}),o.join("")}function xe(t,r){return t.slice().map((o,i)=>i<r.y||i>=r.y+r.h?o:o.map((a,c)=>c<r.x||c>=r.x+r.w?a:!1))}function ze(t,r,o,i){if(i==null)return null;const a=t.length+o*2,c=Math.floor(r*ke),p=a/r,f=(i.width||c)*p,e=(i.height||c)*p,n=i.x==null?t.length/2-f/2:i.x*p,s=i.y==null?t.length/2-e/2:i.y*p,l=i.opacity==null?1:i.opacity;let u=null;if(i.excavate){let h=Math.floor(n),w=Math.floor(s),g=Math.ceil(f+n-h),A=Math.ceil(e+s-w);u={x:h,y:w,w:g,h:A}}const m=i.crossOrigin;return{x:n,y:s,h:e,w:f,excavation:u,opacity:l,crossOrigin:m}}function _e(t,r){return r!=null?Math.max(Math.floor(r),0):t?Ue:Fe}function Me({value:t,level:r,minVersion:o,includeMargin:i,marginSize:a,imageSettings:c,size:p,boostLevel:f}){let e=E.useMemo(()=>{const h=(Array.isArray(t)?t:[t]).reduce((w,g)=>(w.push(...W.QrSegment.makeSegments(g)),w),[]);return W.QrCode.encodeSegments(h,Be[r],o,void 0,void 0,f)},[t,r,o,f]);const{cells:n,margin:s,numCells:l,calculatedImageSettings:u}=E.useMemo(()=>{let m=e.getModules();const h=_e(i,a),w=m.length+h*2,g=ze(m,p,h,c);return{cells:m,margin:h,numCells:w,calculatedImageSettings:g}},[e,p,c,i,a]);return{qrcode:e,margin:s,cells:n,numCells:l,calculatedImageSettings:u}}var $e=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),He=E.forwardRef(function(r,o){const i=r,{value:a,size:c=me,level:p=pe,bgColor:f=ge,fgColor:e=Ee,includeMargin:n=Ce,minVersion:s=we,boostLevel:l,marginSize:u,imageSettings:m}=i,w=oe(i,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:g}=w,A=oe(w,["style"]),M=m==null?void 0:m.src,C=E.useRef(null),I=E.useRef(null),P=E.useCallback(L=>{C.current=L,typeof o=="function"?o(L):o&&(o.current=L)},[o]),[S,T]=E.useState(!1),{margin:j,cells:F,numCells:k,calculatedImageSettings:D}=Me({value:a,level:p,minVersion:s,boostLevel:l,includeMargin:n,marginSize:u,imageSettings:m,size:c});E.useEffect(()=>{if(C.current!=null){const L=C.current,N=L.getContext("2d");if(!N)return;let b=F;const O=I.current,G=D!=null&&O!==null&&O.complete&&O.naturalHeight!==0&&O.naturalWidth!==0;G&&D.excavation!=null&&(b=xe(F,D.excavation));const J=window.devicePixelRatio||1;L.height=L.width=c*J;const v=c/k*J;N.scale(v,v),N.fillStyle=f,N.fillRect(0,0,k,k),N.fillStyle=e,$e?N.fill(new Path2D(Re(b,j))):F.forEach(function(Q,$){Q.forEach(function(q,re){q&&N.fillRect(re+j,$+j,1,1)})}),D&&(N.globalAlpha=D.opacity),G&&N.drawImage(O,D.x+j,D.y+j,D.w,D.h)}}),E.useEffect(()=>{T(!1)},[M]);const z=se({height:c,width:c},g);let _=null;return M!=null&&(_=E.createElement("img",{src:M,key:M,style:{display:"none"},onLoad:()=>{T(!0)},ref:I,crossOrigin:D==null?void 0:D.crossOrigin})),E.createElement(E.Fragment,null,E.createElement("canvas",se({style:z,height:c,width:c,ref:P,role:"img"},A)),_)});He.displayName="QRCodeCanvas";var Ne=E.forwardRef(function(r,o){const i=r,{value:a,size:c=me,level:p=pe,bgColor:f=ge,fgColor:e=Ee,includeMargin:n=Ce,minVersion:s=we,boostLevel:l,title:u,marginSize:m,imageSettings:h}=i,w=oe(i,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:g,cells:A,numCells:M,calculatedImageSettings:C}=Me({value:a,level:p,minVersion:s,boostLevel:l,includeMargin:n,marginSize:m,imageSettings:h,size:c});let I=A,P=null;h!=null&&C!=null&&(C.excavation!=null&&(I=xe(A,C.excavation)),P=E.createElement("image",{href:h.src,height:C.h,width:C.w,x:C.x+g,y:C.y+g,preserveAspectRatio:"none",opacity:C.opacity,crossOrigin:C.crossOrigin}));const S=Re(I,g);return E.createElement("svg",se({height:c,width:c,viewBox:`0 0 ${M} ${M}`,ref:o,role:"img"},w),!!u&&E.createElement("title",null,u),E.createElement("path",{fill:f,d:`M0,0 h${M}v${M}H0z`,shapeRendering:"crispEdges"}),E.createElement("path",{fill:e,d:S,shapeRendering:"crispEdges"}),P)});Ne.displayName="QRCodeSVG";const Ie="share",Ye="onboarding",Ge=(t,r)=>({invitationType:H.InvitationType.LINK,resources:[{url:`conversations/${encodeURI(t)}`},...r]}),Qe=t=>{var o;const r=((o=t==null?void 0:t.invitationLink)==null?void 0:o.split("/").at(-1))||"";return`/${Ie}/${r}`},Ve=(t,r)=>r==null?void 0:r.find(o=>{var c,p,f,e;const i=(p=(c=t==null?void 0:t.id)==null?void 0:c.split("/"))==null?void 0:p.pop(),a=((e=(f=o==null?void 0:o.url)==null?void 0:f.split("/"))==null?void 0:e.pop())||"";return a===i||decodeURI(a)===i}),We=t=>{var o,i;const r=(o=t==null?void 0:t.messages)==null?void 0:o.filter(a=>{var c;return!!((c=a==null?void 0:a.custom_content)!=null&&c.attachments)});return((i=r==null?void 0:r.flatMap(a=>{var c,p;return((p=(c=a==null?void 0:a.custom_content)==null?void 0:c.attachments)==null?void 0:p.map(f=>({url:(f==null?void 0:f.url)||""})))||[]}))==null?void 0:i.filter(a=>!!(a!=null&&a.url)))||[]},Xe=({conversation:t,locale:r,onCloseModal:o,modalDividers:i,getConversation:a,generateConversationLink:c,chatExpiration:p,chatExpirationDays:f,close:e,chatWarning:n,shareLink:s,shareCopyLink:l,shareCopiedLink:u,shareDescription:m,shareRemoveAccessToUsers:h,chatName:w,getSharedConversations:g,revokeSharedConversations:A,baseUrl:M,id:C,clientSharedPage:I,clientSharedProp:P})=>{const[S,T]=E.useState(null),[j,F]=E.useState(),[k,D]=E.useState(!1),[z,_]=E.useState(!1),[L,N]=E.useState(),b=E.useMemo(()=>{var $;const Q=M||window.location.origin;if(M&&M!==window.location.origin&&I&&P){const q=($=S==null?void 0:S.split(`/${Ie}/`))==null?void 0:$[1];return`${Q}/${I}?${P}=${q}`}return`${Q}/${r}${S}`},[M,S,r,I,P]);E.useEffect(()=>{(async()=>{try{const $=decodeURI(t?t==null?void 0:t.id:`${C==null?void 0:C[0]}/${r}/${C==null?void 0:C[1]}`),q=`${decodeURI($)}`,re=await(a==null?void 0:a(q)),Pe=Ge($,We(re)),ae=await(c==null?void 0:c(Pe)),ee=await(g==null?void 0:g(H.getSharedConversationsRequest(H.ShareTarget.OTHERS)));ae&&ee&&(D(!0),T(Qe(ae)),F(Ve(t,ee==null?void 0:ee.resources)))}catch($){D(!1),console.error("Error sharing conversation",$)}})()},[t,c,a,g,C,r]);const O=E.useCallback(()=>{o(),T(null),D(!1),_(!1)},[o]),G=E.useCallback(()=>{_(!0),navigator.clipboard.writeText(b||"")},[b]),J=async()=>{try{N(!0),j&&await(A==null?void 0:A({resources:[j]}))}catch(Q){N(!1),console.error("Error revoking shared conversation",Q)}},v=E.useCallback(()=>d.jsx(x.Button,{buttonClassName:z?"text-button-secondary":"text-button-primary",iconBefore:z?d.jsx(K.IconCheck,{width:20,height:20}):d.jsx(K.IconCopy,{width:20,height:20}),title:z?u??"Copied":l??"Copy link",disabled:z,onClick:G}),[z,G,u,l]);return d.jsxs(x.Popup,{heading:s??"Share link",portalId:"share",size:x.PopUpSize.SM,dividers:i,onClose:O,closeButtonTitle:e??"Close",children:[k?d.jsxs("div",{className:"share flex flex-col gap-y-4 px-6 pb-6 overflow-auto sm:p-0",children:[t!=null&&t.name?d.jsxs("div",{className:"flex share-info w-full",children:[d.jsx("p",{className:"share-info-title text-neutrals-800 mr-1 body-1",children:w??"Chat name:"}),d.jsx("h3",{className:"flex-1 min-w-0 truncate",title:t==null?void 0:t.name,children:t==null?void 0:t.name})]}):null,d.jsxs("div",{className:"flex share-info",children:[d.jsx("p",{className:"share-info-title text-neutrals-800 mr-1 body-1",children:p??"Link expiration date:"}),d.jsxs("h3",{children:["3 ",f??"days"]})]}),d.jsx(Ne,{className:"self-center border border-neutrals-600 p-2 rounded min-h-[200px]",value:b,size:200}),d.jsx("p",{className:"body-2 text-neutrals-1000",children:m??"Your name, special instructions, and any messages you add after sharing remain confidential."}),d.jsx(x.InputWithIcon,{containerClasses:"share-input-container",cssClass:"share-input",readonly:!0,placeholder:b,value:b,inputId:"conversationLink",iconAfterInput:v()})]}):d.jsx("div",{className:"flex justify-center items-center py-6 px-6",children:d.jsx(x.Loader,{})}),k?t&&j?d.jsx("div",{className:"remove-access",children:d.jsx(x.Button,{title:h??"Remove access to all users",buttonClassName:"remove-access-button py-3 px-4",isSmallButton:!0,disabled:L,onClick:J})}):d.jsx("p",{className:"body-2 text-neutrals-800 share-footer",children:n??"This chat has not been shared with anyone yet."}):d.jsx("div",{})]})},Ke=t=>{const r=t.messages.flatMap(i=>{var p,f,e;const a=((p=i.custom_content)==null?void 0:p.attachments)||[],c=((e=(f=i.custom_content)==null?void 0:f.stages)==null?void 0:e.flatMap(({attachments:n})=>n??[]))||[];return[...a,...c]})||[],o=ve(r).map(i=>({...i,relativePath:"",contentLength:0}));return le.uniqBy(o,i=>Z(i.relativePath,i.name))},qe=t=>t.endsWith("/"),Ze=t=>{const r=t.toLowerCase();return["data:","//","http://","https://","file://","ftp://","mailto:","telnet://","api/files"].some(o=>r.startsWith(o))},Je=t=>{const r=Z(...t.split("/").map(i=>decodeURIComponent(i))),o=r.lastIndexOf("/");return{absolutePath:r.slice(0,o),name:r.slice(o+1)}},ve=t=>t?t.map(r=>{if(!r.url||Ze(r.url)||qe(r.url))return null;const{absolutePath:o,name:i}=Je(r.url);return{id:r.url,name:i,contentType:r.type,folderId:o,absolutePath:o}}).filter(Boolean):[];async function et(t,r){const o=Ke(t),i=new ye;o.forEach(f=>{const e=encodeURI(Z(f.absolutePath,f.name)),n=r(`${e}`.replace("files/","")),s=tt(f.folderId),l=Z("res",s,f.name);i.file(l,n)});const a={version:5,history:[t].map(nt)||[],folders:[]},c=JSON.stringify(a,null,2);return i.file("conversations/conversations_history.json",c),await i.generateAsync({type:"base64"})}const tt=t=>{const r=t.split("/");return r.length>2?Z(...r.slice(2)):void 0},nt=t=>le.omit(t,["publicationInfo"]),Z=(...t)=>t.filter(Boolean).join("/");function rt(t,r){const o=document.createElement("a");o.download=r,o.href=t,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(t)}const st=({onCloseModal:t,disableModalDividers:r,deleteConversation:o,isSmallButton:i,titles:a,locale:c})=>d.jsxs(x.Popup,{heading:(a==null?void 0:a.deleteTitle)??"Delete conversation",portalId:"delete-conversation",containerClassName:"delete-conversation-popup",size:x.PopUpSize.SM,dividers:!r,onClose:t,closeButtonTitle:(a==null?void 0:a.close)??"Cancel",children:[d.jsx("div",{className:"py-4 px-6 sm:px-0",lang:c,children:(a==null?void 0:a.deleteMessage)??"Are you sure you want to delete this conversation? This action cannot be undone."}),d.jsxs("div",{className:"flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer",children:[d.jsx(x.Button,{buttonClassName:"cancel-button",title:(a==null?void 0:a.cancel)??"Cancel",isSmallButton:i,onClick:p=>{p.stopPropagation(),t()}}),d.jsx(x.Button,{buttonClassName:"text-button-primary text-button-primary-error",title:(a==null?void 0:a.delete)??"Delete",isSmallButton:i,onClick:p=>{p.stopPropagation(),o()}})]})]}),ot=({conversation:t,onCloseModal:r,renameCoversation:o,locale:i,disableModalDividers:a,titles:c,isSmallButton:p})=>{const[f,e]=E.useState((t==null?void 0:t.name)||""),n=l=>{e(l)},s=()=>{const l=`${t==null?void 0:t.folderId}/${encodeURIComponent(Y.getClearedConversationName(f))}-${new Date().getTime()}`;o(`conversations/${t.id}`,`conversations/${l}`)};return d.jsxs(x.Popup,{heading:(c==null?void 0:c.renameTitle)??"Rename conversation",portalId:"rename-conversation",containerClassName:"rename-conversation-popup",size:x.PopUpSize.SM,dividers:!a,onClose:r,closeButtonTitle:(c==null?void 0:c.close)??"Cancel",children:[d.jsx("div",{className:"py-4 px-6 sm:px-0",lang:i,children:d.jsx(x.Input,{inputId:"rename",value:f,onChange:n,cssClass:"w-full"})}),d.jsxs("div",{className:"flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer",children:[d.jsx(x.Button,{buttonClassName:"cancel-button",title:(c==null?void 0:c.cancel)??"Cancel",isSmallButton:p,onClick:l=>{l.stopPropagation(),r()}}),d.jsx(x.Button,{buttonClassName:"text-button-primary text-button-primary",title:(c==null?void 0:c.save)??"Rename",isSmallButton:p,disabled:!f,onClick:l=>{l.stopPropagation(),s()}})]})]})},be=({conversation:t,conversationStyles:r,shareConversationProps:o,onConversationDelete:i,getConversation:a,getFileBlob:c,renameConversation:p,triggerButton:f,locale:e})=>{var S;const n=E.useMemo(()=>{var j,F,k,D,z,_,L,N,b,O;const T=[{key:B.DELETE,title:((j=r==null?void 0:r.titles)==null?void 0:j.delete)??"Delete",icon:(F=r.actionsIcons)==null?void 0:F[B.DELETE]}];return(D=(k=t==null?void 0:t.model)==null?void 0:k.id)!=null&&D.endsWith(Ye)?T:[...t.isShared?[]:[{key:B.SHARE,title:((z=r==null?void 0:r.titles)==null?void 0:z.share)??"Share",icon:(_=r.actionsIcons)==null?void 0:_[B.SHARE]},{key:B.RENAME,title:((L=r==null?void 0:r.titles)==null?void 0:L.rename)??"Rename",icon:(N=r.actionsIcons)==null?void 0:N[B.RENAME]}],{key:B.EXPORT,title:((b=r==null?void 0:r.titles)==null?void 0:b.export)??"Export",icon:(O=r.actionsIcons)==null?void 0:O[B.EXPORT]},...T]},[t.isShared,(S=t==null?void 0:t.model)==null?void 0:S.id,r.titles,r.actionsIcons]),[s,l]=E.useState(x.PopUpState.Closed),[u,m]=E.useState(x.PopUpState.Closed),[h,w]=E.useState(x.PopUpState.Closed),g=E.useCallback(()=>{l(x.PopUpState.Closed)},[l]),A=E.useCallback(()=>{m(x.PopUpState.Closed)},[m]),M=E.useCallback(()=>{w(x.PopUpState.Closed)},[w]),C=E.useCallback(()=>{i(t),g()},[t,i,g]),I=E.useCallback((T,j)=>{p(T,j),M()},[p,M]),P=T=>{T===B.DELETE&&l(x.PopUpState.Opened),T===B.SHARE&&m(x.PopUpState.Opened),T===B.RENAME&&w(x.PopUpState.Opened),T===B.EXPORT&&a(decodeURI(t.id)).then(j=>{et(j,c).then(F=>{rt(`data:application/zip;base64,${F}`,`chat_with_attachments_${new Date().toLocaleDateString()}.dial`)})})};return d.jsxs(d.Fragment,{children:[d.jsx(x.Dropdown,{containerClassName:"transition-opacity ml-3 group-hover:opacity-100",triggerButton:f??d.jsx(lt,{}),options:n,openedClassName:"action-menu-opened",onOptionSelect:P}),s===x.PopUpState.Opened&&d.jsx(st,{titles:r.titles,locale:e,disableModalDividers:r.disableModalDividers,isSmallButton:r.isSmallModalButton,deleteConversation:C,onCloseModal:g}),u===x.PopUpState.Opened&&d.jsx(Xe,{conversation:t,locale:e,onCloseModal:A,...o}),h===x.PopUpState.Opened&&d.jsx(ot,{conversation:t,locale:e,titles:r.titles,renameCoversation:I,onCloseModal:M,disableModalDividers:r.disableModalDividers,isSmallButton:r.isSmallModalButton})]})},lt=()=>d.jsx("div",{className:"cursor-pointer flex items-center justify-center w-[24px]",children:d.jsx(K.IconDotsVertical,{width:20,height:20,stroke:2,className:"text-primary"})}),Ae=({conversation:t,selectedConversationId:r,searchQuery:o,onConversationClick:i,actions:a,locale:c,conversationStyles:p,shareConversationProps:f})=>{const e=E.useRef(null),n=Y.getClearedConversationName(t==null?void 0:t.name);return E.useEffect(()=>{var s;(t==null?void 0:t.id)===r&&((s=e==null?void 0:e.current)==null||s.scrollIntoView({block:"center",behavior:"smooth"}))},[t,r]),d.jsxs("div",{ref:e,className:X("flex justify-between items-center py-2 px-3 border-transparent relative group cursor-pointer border hover:border-hues-600","conversation-item",r===(t==null?void 0:t.id)&&"bg-hues-100 conversation-item-active"),onClick:()=>i(t.folderId,t==null?void 0:t.id),title:n,children:[d.jsxs("div",{className:"flex w-full min-w-0 items-center",children:[p.conversationItemIcon?p.conversationItemIcon:null,d.jsx("h3",{className:X("truncate font-semibold text-neutrals-1000 sm:body-2","conversation-item-text",r===(t==null?void 0:t.id)?"conversation-item-text-active":""),title:n,children:o!=null&&o.length?d.jsx(x.HighlightText,{text:n,highlightText:o}):n})]}),d.jsx(be,{locale:c,conversationStyles:p,conversation:t,onConversationDelete:a.deleteConversation,getConversation:a.getConversation,getFileBlob:a.getFileBlob,renameConversation:a.renameConversation,shareConversationProps:f})]})},at=({handleConversationClick:t,actions:r,selectedConversationId:o,groupLabel:i,conversationStyles:a,groupedConversations:c,shareConversationProps:p,locale:f})=>{const[e,n]=E.useState(!1),s=E.useCallback(()=>{n(l=>!l)},[n]);return d.jsxs("div",{children:[d.jsxs("div",{className:"inline-flex gap-1 items-center text-neutrals-700 mb-3 cursor-pointer conversation-group-items-title",onClick:s,children:[d.jsx(K.IconCaretRightFilled,{className:X("w-3 h-3 conversation-group-items-arrow",e?"rotate-[90deg]":"rotate-0")}),d.jsx("span",{className:"body-3 conversation-group-items-title-text",children:Oe(i,a==null?void 0:a.titles)})]}),!e&&d.jsx("div",{className:X("flex flex-col gap-y-3","conversation-group-items"),children:de(c).map(l=>d.jsx(Ae,{locale:f,conversationStyles:a,conversation:l,selectedConversationId:o,onConversationClick:t,actions:r,shareConversationProps:p},l.id||l.name))})]},i)},it=({searchQuery:t,isExpandedSearch:r,titles:o,onSearchConversations:i,toggleSearchField:a})=>d.jsx(d.Fragment,{children:r?d.jsx(x.InputWithIcon,{inputId:"conversations-search",placeholder:(o==null?void 0:o.searchPlaceholder)??"Search",containerClasses:"conversation-list-search-input h-[40px] bg-transparent px-4 py-2 rounded-full border-neutrals-400 shadow-none",cssClass:"h-auto",value:t,iconAfterInput:d.jsx(x.IconButton,{buttonClassName:"text-button-tertiary items-center p-0 ml-4 border-0 w-5 h-5",onClick:a,icon:d.jsx(K.IconX,{})}),onChange:i}):d.jsx(x.Button,{buttonClassName:"text-button-tertiary p-0 search-button",iconBefore:d.jsx(K.IconSearch,{className:"w-5 h-5"}),onClick:a})}),ct=({conversations:t,selectedConversationId:r,searchQuery:o,conversationStyles:i,handleConversationClick:a,actions:c,locale:p,shareConversationProps:f})=>{var s;const[e,n]=E.useState([]);return E.useEffect(()=>{n(de(t==null?void 0:t.filter(l=>{var u;return(u=Y.getClearedConversationName(l==null?void 0:l.name))==null?void 0:u.includes(o||"")})))},[t,o]),d.jsx(d.Fragment,{children:e!=null&&e.length?e.map(l=>d.jsx(Ae,{locale:p,conversationStyles:i,conversation:l,searchQuery:o,selectedConversationId:r,onConversationClick:a,actions:c,shareConversationProps:f},l.id)):d.jsx("h3",{className:"text-neutrals-800",children:((s=i==null?void 0:i.titles)==null?void 0:s.noConversation)??"No conversations yet"})})},ut=({titles:t})=>d.jsxs("div",{className:"p-8 text-center flex flex-col",children:[d.jsx("p",{className:"text-neutrals-800",children:(t==null?void 0:t.noConversation)??"No conversations yet"}),d.jsx("p",{className:"text-sm text-neutrals-800 mt-2",children:(t==null?void 0:t.clickNewChat)??'Click "New Chat" to start a conversation'})]}),dt=({handleConversationClick:t,selectedConversationId:r,actions:o,children:i,isCollapsed:a,conversationStyles:c,conversations:p,locale:f,sharedConversations:e,setConversations:n,setSharedConversations:s,shareConversationProps:l,handleSelectedConversationRemove:u})=>{var L;const[m,h]=E.useState({}),[w,g]=E.useState(!0),[A,M]=E.useState(""),[C,I]=E.useState(!1),{getConversations:P,getSharedConversations:S,deleteConversation:T,renameConversation:j}=o,F=E.useMemo(()=>!!(A!=null&&A.length),[A]);E.useEffect(()=>{h({...ce(e),...Te(p)})},[p,e]),E.useEffect(()=>{async function N(){try{g(!0);const b=await P(f),O=await S(H.getSharedConversationsRequest(H.ShareTarget.ME));n(Y.cleanConversationNames(b)),s(Y.cleanConversationNames(te(O,f)))}catch(b){console.error("Error loading conversation",b)}finally{g(!1)}}N()},[P,n,f,S,s]);const k=E.useCallback(async N=>{try{await T(N);const b=await P(f),O=await S(H.getSharedConversationsRequest(H.ShareTarget.ME));n(Y.cleanConversationNames(b)),s(Y.cleanConversationNames(te(O,f))),r===(N==null?void 0:N.id)&&u()}catch(b){console.error("Error deleting conversation",b)}},[T,P,f,S,n,s,r,u]),D=E.useCallback(async(N,b)=>{try{g(!0),await j(N,b);const O=await P(f),G=await S(H.getSharedConversationsRequest(H.ShareTarget.ME));n(Y.cleanConversationNames(O)),s(Y.cleanConversationNames(te(G,f)))}catch(O){console.error("Error renaming conversation",O)}finally{g(!1)}},[P,f,S,n,s,j]),z=E.useCallback(N=>{M(N)},[M]),_=E.useCallback(()=>{I(N=>!N),M("")},[I]);return w?d.jsx(x.Loader,{}):d.jsxs(d.Fragment,{children:[!a&&d.jsxs("div",{className:X("flex justify-between items-center",C?" pt-4 pb-0 sm:pt-10":" pt-6 pb-2 sm:pt-10"),children:[!C&&d.jsx("h3",{className:"text-neutrals-700 sm:body-2",children:((L=c==null?void 0:c.titles)==null?void 0:L.allChats)??"All Chats"}),d.jsx(it,{searchQuery:A,titles:c.titles,isExpandedSearch:C,onSearchConversations:z,toggleSearchField:_})]}),d.jsx("div",{className:X("overflow-y-auto flex flex-col mt-4 flex-1 min-h-0 pr-2",F?"gap-y-1":"gap-y-6"),children:a?null:d.jsx(d.Fragment,{children:(p==null?void 0:p.length)===0&&(e==null?void 0:e.length)===0?d.jsx(ut,{titles:c.titles}):F?d.jsx(ct,{locale:f,conversationStyles:c,conversations:[...e,...p],searchQuery:A,selectedConversationId:r,handleConversationClick:t,shareConversationProps:l,actions:{...o,deleteConversation:k}}):Object.entries(m).map(([N,b])=>(b==null?void 0:b.length)>0&&d.jsx(at,{locale:f,groupLabel:N,conversationStyles:c,groupedConversations:b,handleConversationClick:t,actions:{...o,deleteConversation:k,renameConversation:D},shareConversationProps:l,selectedConversationId:r},N))})}),i]})};exports.ActionMenu=be;exports.ActionMenuItem=B;exports.ConversationList=dt;exports.getSharedConversationsGroup=ce;exports.transformSharedConversations=te;
|