@opencx/widget 3.0.80 → 3.0.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/designs.cjs +1 -1
- package/dist/designs.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +2 -2
- package/dist/src/headless/core/types/widget-config.d.ts +5 -0
- package/dist/{useWidgetTrigger-BMUbLNnW.cjs → useWidgetTrigger-DL9e5ISu.cjs} +3 -3
- package/dist/{useWidgetTrigger-BMUbLNnW.cjs.map → useWidgetTrigger-DL9e5ISu.cjs.map} +1 -1
- package/dist/{useWidgetTrigger-CY_10B--.js → useWidgetTrigger-ims5I4zH.js} +106 -100
- package/dist/{useWidgetTrigger-CY_10B--.js.map → useWidgetTrigger-ims5I4zH.js.map} +1 -1
- package/dist-embed/script.js +2 -2
- package/dist-embed/script.js.map +1 -1
- package/package.json +1 -1
package/dist/designs.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),uu=require("@radix-ui/react-popover"),X=require("react"),q=require("./useWidgetTrigger-BMUbLNnW.cjs"),lu=require("@radix-ui/react-dialog"),le=require("lucide-react"),va=require("clsx"),fr=require("react-dom"),cu=require("@radix-ui/react-slot"),be=require("framer-motion"),du=require("@radix-ui/react-avatar"),hu=require("@radix-ui/react-tooltip"),hi=require("tinycolor2"),fu=require("react-dropzone"),pu=require("@radix-ui/react-dropdown-menu"),Gn=require("zod");function It(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Dn=It(uu),ye=It(X),ze=It(lu),St=It(du),sn=It(hu),me=It(pu);function fi(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}const Ne=st(/[A-Za-z]/),Ae=st(/[\dA-Za-z]/),mu=st(/[#-'*+\--9=?A-Z^-~]/);function Cn(e){return e!==null&&(e<32||e===127)}const pr=st(/\d/),gu=st(/[\dA-Fa-f]/),bu=st(/[!-/:-@[-`{-~]/);function W(e){return e!==null&&e<-2}function se(e){return e!==null&&(e<0||e===32)}function J(e){return e===-2||e===-1||e===32}const vn=st(new RegExp("\\p{P}|\\p{S}","u")),pt=st(/\s/);function st(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Eu(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const Pn=function(e){if(e==null)return yu;if(typeof e=="function")return Mn(e);if(typeof e=="object")return Array.isArray(e)?Tu(e):xu(e);if(typeof e=="string")return wu(e);throw new Error("Expected function, string, or object as test")};function Tu(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Pn(e[n]);return Mn(r);function r(...i){let a=-1;for(;++a<t.length;)if(t[a].apply(this,i))return!0;return!1}}function xu(e){const t=e;return Mn(n);function n(r){const i=r;let a;for(a in e)if(i[a]!==t[a])return!1;return!0}}function wu(e){return Mn(t);function t(n){return n&&n.type===e}}function Mn(e){return t;function t(n,r,i){return!!(_u(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function yu(){return!0}function _u(e){return e!==null&&typeof e=="object"&&"type"in e}const Pa=[],Au=!0,mr=!1,Cu="skip";function Ma(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const a=Pn(i),s=r?-1:1;u(e,void 0,[])();function u(l,c,d){const h=l&&typeof l=="object"?l:{};if(typeof h.type=="string"){const f=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(l.type+(f?"<"+f+">":""))+")"})}return g;function g(){let f=Pa,E,y,k;if((!t||a(l,c,d[d.length-1]||void 0))&&(f=ku(n(l,d)),f[0]===mr))return f;if("children"in l&&l.children){const _=l;if(_.children&&f[0]!==Cu)for(y=(r?_.children.length:-1)+s,k=d.concat(_);y>-1&&y<_.children.length;){const S=_.children[y];if(E=u(S,y,k)(),E[0]===mr)return E;y=typeof E[1]=="number"?E[1]:y+s}}return f}}}function ku(e){return Array.isArray(e)?e:typeof e=="number"?[Au,e]:e==null?Pa:[e]}function Nu(e,t,n){const i=Pn((n||{}).ignore||[]),a=Iu(t);let s=-1;for(;++s<a.length;)Ma(e,"text",u);function u(c,d){let h=-1,g;for(;++h<d.length;){const f=d[h],E=g?g.children:void 0;if(i(f,E?E.indexOf(f):void 0,g))return;g=f}if(g)return l(c,d)}function l(c,d){const h=d[d.length-1],g=a[s][0],f=a[s][1];let E=0;const k=h.children.indexOf(c);let _=!1,S=[];g.lastIndex=0;let L=g.exec(c.value);for(;L;){const M=L.index,F={index:L.index,input:L.input,stack:[...d,c]};let I=f(...L,F);if(typeof I=="string"&&(I=I.length>0?{type:"text",value:I}:void 0),I===!1?g.lastIndex=M+1:(E!==M&&S.push({type:"text",value:c.value.slice(E,M)}),Array.isArray(I)?S.push(...I):I&&S.push(I),E=M+L[0].length,_=!0),!g.global)break;L=g.exec(c.value)}return _?(E<c.value.length&&S.push({type:"text",value:c.value.slice(E)}),h.children.splice(k,1,...S)):S=[c],k+S.length}}function Iu(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([Su(i[0]),Ou(i[1])])}return t}function Su(e){return typeof e=="string"?new RegExp(Eu(e),"g"):e}function Ou(e){return typeof e=="function"?e:function(){return e}}const Qn="phrasing",Xn=["autolink","link","image","label"];function Lu(){return{transforms:[Fu],enter:{literalAutolink:Du,literalAutolinkEmail:Kn,literalAutolinkHttp:Kn,literalAutolinkWww:Kn},exit:{literalAutolink:Bu,literalAutolinkEmail:Mu,literalAutolinkHttp:vu,literalAutolinkWww:Pu}}}function Ru(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Qn,notInConstruct:Xn},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Qn,notInConstruct:Xn},{character:":",before:"[ps]",after:"\\/",inConstruct:Qn,notInConstruct:Xn}]}}function Du(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Kn(e){this.config.enter.autolinkProtocol.call(this,e)}function vu(e){this.config.exit.autolinkProtocol.call(this,e)}function Pu(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function Mu(e){this.config.exit.autolinkEmail.call(this,e)}function Bu(e){this.exit(e)}function Fu(e){Nu(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Hu],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Uu]],{ignore:["link","linkReference"]})}function Hu(e,t,n,r,i){let a="";if(!Ba(i)||(/^w/i.test(t)&&(n=t+n,t="",a="http://"),!zu(n)))return!1;const s=ju(n+r);if(!s[0])return!1;const u={type:"link",title:null,url:a+t+s[0],children:[{type:"text",value:t+s[0]}]};return s[1]?[u,{type:"text",value:s[1]}]:u}function Uu(e,t,n,r){return!Ba(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function zu(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function ju(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=fi(e,"(");let a=fi(e,")");for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),a++;return[e,n]}function Ba(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||pt(n)||vn(n))&&(!t||n!==47)}function Ue(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}Fa.peek=Zu;function Yu(){return{enter:{gfmFootnoteDefinition:qu,gfmFootnoteDefinitionLabelString:Vu,gfmFootnoteCall:Xu,gfmFootnoteCallString:Ku},exit:{gfmFootnoteDefinition:Qu,gfmFootnoteDefinitionLabelString:Gu,gfmFootnoteCall:Ju,gfmFootnoteCallString:$u}}}function Wu(){return{unsafe:[{character:"[",inConstruct:["phrasing","label","reference"]}],handlers:{footnoteDefinition:el,footnoteReference:Fa}}}function qu(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Vu(){this.buffer()}function Gu(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=t,n.identifier=Ue(this.sliceSerialize(e)).toLowerCase()}function Qu(e){this.exit(e)}function Xu(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Ku(){this.buffer()}function $u(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=t,n.identifier=Ue(this.sliceSerialize(e)).toLowerCase()}function Ju(e){this.exit(e)}function Fa(e,t,n,r){const i=n.createTracker(r);let a=i.move("[^");const s=n.enter("footnoteReference"),u=n.enter("reference");return a+=i.move(n.safe(n.associationId(e),{...i.current(),before:a,after:"]"})),u(),s(),a+=i.move("]"),a}function Zu(){return"["}function el(e,t,n,r){const i=n.createTracker(r);let a=i.move("[^");const s=n.enter("footnoteDefinition"),u=n.enter("label");return a+=i.move(n.safe(n.associationId(e),{...i.current(),before:a,after:"]"})),u(),a+=i.move("]:"+(e.children&&e.children.length>0?" ":"")),i.shift(4),a+=i.move(n.indentLines(n.containerFlow(e,i.current()),tl)),s(),a}function tl(e,t,n){return t===0?e:(n?"":" ")+e}const nl=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Ha.peek=ol;function rl(){return{canContainEols:["delete"],enter:{strikethrough:al},exit:{strikethrough:sl}}}function il(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:nl}],handlers:{delete:Ha}}}function al(e){this.enter({type:"delete",children:[]},e)}function sl(e){this.exit(e)}function Ha(e,t,n,r){const i=n.createTracker(r),a=n.enter("strikethrough");let s=i.move("~~");return s+=n.containerPhrasing(e,{...i.current(),before:s,after:"~"}),s+=i.move("~~"),a(),s}function ol(){return"~"}function ul(e,t={}){const n=(t.align||[]).concat(),r=t.stringLength||cl,i=[],a=[],s=[],u=[];let l=0,c=-1;for(;++c<e.length;){const E=[],y=[];let k=-1;for(e[c].length>l&&(l=e[c].length);++k<e[c].length;){const _=ll(e[c][k]);if(t.alignDelimiters!==!1){const S=r(_);y[k]=S,(u[k]===void 0||S>u[k])&&(u[k]=S)}E.push(_)}a[c]=E,s[c]=y}let d=-1;if(typeof n=="object"&&"length"in n)for(;++d<l;)i[d]=pi(n[d]);else{const E=pi(n);for(;++d<l;)i[d]=E}d=-1;const h=[],g=[];for(;++d<l;){const E=i[d];let y="",k="";E===99?(y=":",k=":"):E===108?y=":":E===114&&(k=":");let _=t.alignDelimiters===!1?1:Math.max(1,u[d]-y.length-k.length);const S=y+"-".repeat(_)+k;t.alignDelimiters!==!1&&(_=y.length+_+k.length,_>u[d]&&(u[d]=_),g[d]=_),h[d]=S}a.splice(1,0,h),s.splice(1,0,g),c=-1;const f=[];for(;++c<a.length;){const E=a[c],y=s[c];d=-1;const k=[];for(;++d<l;){const _=E[d]||"";let S="",L="";if(t.alignDelimiters!==!1){const M=u[d]-(y[d]||0),F=i[d];F===114?S=" ".repeat(M):F===99?M%2?(S=" ".repeat(M/2+.5),L=" ".repeat(M/2-.5)):(S=" ".repeat(M/2),L=S):L=" ".repeat(M)}t.delimiterStart!==!1&&!d&&k.push("|"),t.padding!==!1&&!(t.alignDelimiters===!1&&_==="")&&(t.delimiterStart!==!1||d)&&k.push(" "),t.alignDelimiters!==!1&&k.push(S),k.push(_),t.alignDelimiters!==!1&&k.push(L),t.padding!==!1&&k.push(" "),(t.delimiterEnd!==!1||d!==l-1)&&k.push("|")}f.push(t.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return f.join(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),uu=require("@radix-ui/react-popover"),X=require("react"),q=require("./useWidgetTrigger-DL9e5ISu.cjs"),lu=require("@radix-ui/react-dialog"),le=require("lucide-react"),va=require("clsx"),fr=require("react-dom"),cu=require("@radix-ui/react-slot"),be=require("framer-motion"),du=require("@radix-ui/react-avatar"),hu=require("@radix-ui/react-tooltip"),hi=require("tinycolor2"),fu=require("react-dropzone"),pu=require("@radix-ui/react-dropdown-menu"),Gn=require("zod");function It(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Dn=It(uu),ye=It(X),ze=It(lu),St=It(du),sn=It(hu),me=It(pu);function fi(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}const Ne=st(/[A-Za-z]/),Ae=st(/[\dA-Za-z]/),mu=st(/[#-'*+\--9=?A-Z^-~]/);function Cn(e){return e!==null&&(e<32||e===127)}const pr=st(/\d/),gu=st(/[\dA-Fa-f]/),bu=st(/[!-/:-@[-`{-~]/);function W(e){return e!==null&&e<-2}function se(e){return e!==null&&(e<0||e===32)}function J(e){return e===-2||e===-1||e===32}const vn=st(new RegExp("\\p{P}|\\p{S}","u")),pt=st(/\s/);function st(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Eu(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const Pn=function(e){if(e==null)return yu;if(typeof e=="function")return Mn(e);if(typeof e=="object")return Array.isArray(e)?Tu(e):xu(e);if(typeof e=="string")return wu(e);throw new Error("Expected function, string, or object as test")};function Tu(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Pn(e[n]);return Mn(r);function r(...i){let a=-1;for(;++a<t.length;)if(t[a].apply(this,i))return!0;return!1}}function xu(e){const t=e;return Mn(n);function n(r){const i=r;let a;for(a in e)if(i[a]!==t[a])return!1;return!0}}function wu(e){return Mn(t);function t(n){return n&&n.type===e}}function Mn(e){return t;function t(n,r,i){return!!(_u(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function yu(){return!0}function _u(e){return e!==null&&typeof e=="object"&&"type"in e}const Pa=[],Au=!0,mr=!1,Cu="skip";function Ma(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const a=Pn(i),s=r?-1:1;u(e,void 0,[])();function u(l,c,d){const h=l&&typeof l=="object"?l:{};if(typeof h.type=="string"){const f=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(l.type+(f?"<"+f+">":""))+")"})}return g;function g(){let f=Pa,E,y,k;if((!t||a(l,c,d[d.length-1]||void 0))&&(f=ku(n(l,d)),f[0]===mr))return f;if("children"in l&&l.children){const _=l;if(_.children&&f[0]!==Cu)for(y=(r?_.children.length:-1)+s,k=d.concat(_);y>-1&&y<_.children.length;){const S=_.children[y];if(E=u(S,y,k)(),E[0]===mr)return E;y=typeof E[1]=="number"?E[1]:y+s}}return f}}}function ku(e){return Array.isArray(e)?e:typeof e=="number"?[Au,e]:e==null?Pa:[e]}function Nu(e,t,n){const i=Pn((n||{}).ignore||[]),a=Iu(t);let s=-1;for(;++s<a.length;)Ma(e,"text",u);function u(c,d){let h=-1,g;for(;++h<d.length;){const f=d[h],E=g?g.children:void 0;if(i(f,E?E.indexOf(f):void 0,g))return;g=f}if(g)return l(c,d)}function l(c,d){const h=d[d.length-1],g=a[s][0],f=a[s][1];let E=0;const k=h.children.indexOf(c);let _=!1,S=[];g.lastIndex=0;let L=g.exec(c.value);for(;L;){const M=L.index,F={index:L.index,input:L.input,stack:[...d,c]};let I=f(...L,F);if(typeof I=="string"&&(I=I.length>0?{type:"text",value:I}:void 0),I===!1?g.lastIndex=M+1:(E!==M&&S.push({type:"text",value:c.value.slice(E,M)}),Array.isArray(I)?S.push(...I):I&&S.push(I),E=M+L[0].length,_=!0),!g.global)break;L=g.exec(c.value)}return _?(E<c.value.length&&S.push({type:"text",value:c.value.slice(E)}),h.children.splice(k,1,...S)):S=[c],k+S.length}}function Iu(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([Su(i[0]),Ou(i[1])])}return t}function Su(e){return typeof e=="string"?new RegExp(Eu(e),"g"):e}function Ou(e){return typeof e=="function"?e:function(){return e}}const Qn="phrasing",Xn=["autolink","link","image","label"];function Lu(){return{transforms:[Fu],enter:{literalAutolink:Du,literalAutolinkEmail:Kn,literalAutolinkHttp:Kn,literalAutolinkWww:Kn},exit:{literalAutolink:Bu,literalAutolinkEmail:Mu,literalAutolinkHttp:vu,literalAutolinkWww:Pu}}}function Ru(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Qn,notInConstruct:Xn},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Qn,notInConstruct:Xn},{character:":",before:"[ps]",after:"\\/",inConstruct:Qn,notInConstruct:Xn}]}}function Du(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Kn(e){this.config.enter.autolinkProtocol.call(this,e)}function vu(e){this.config.exit.autolinkProtocol.call(this,e)}function Pu(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function Mu(e){this.config.exit.autolinkEmail.call(this,e)}function Bu(e){this.exit(e)}function Fu(e){Nu(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Hu],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Uu]],{ignore:["link","linkReference"]})}function Hu(e,t,n,r,i){let a="";if(!Ba(i)||(/^w/i.test(t)&&(n=t+n,t="",a="http://"),!zu(n)))return!1;const s=ju(n+r);if(!s[0])return!1;const u={type:"link",title:null,url:a+t+s[0],children:[{type:"text",value:t+s[0]}]};return s[1]?[u,{type:"text",value:s[1]}]:u}function Uu(e,t,n,r){return!Ba(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function zu(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function ju(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=fi(e,"(");let a=fi(e,")");for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),a++;return[e,n]}function Ba(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||pt(n)||vn(n))&&(!t||n!==47)}function Ue(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}Fa.peek=Zu;function Yu(){return{enter:{gfmFootnoteDefinition:qu,gfmFootnoteDefinitionLabelString:Vu,gfmFootnoteCall:Xu,gfmFootnoteCallString:Ku},exit:{gfmFootnoteDefinition:Qu,gfmFootnoteDefinitionLabelString:Gu,gfmFootnoteCall:Ju,gfmFootnoteCallString:$u}}}function Wu(){return{unsafe:[{character:"[",inConstruct:["phrasing","label","reference"]}],handlers:{footnoteDefinition:el,footnoteReference:Fa}}}function qu(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Vu(){this.buffer()}function Gu(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=t,n.identifier=Ue(this.sliceSerialize(e)).toLowerCase()}function Qu(e){this.exit(e)}function Xu(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Ku(){this.buffer()}function $u(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=t,n.identifier=Ue(this.sliceSerialize(e)).toLowerCase()}function Ju(e){this.exit(e)}function Fa(e,t,n,r){const i=n.createTracker(r);let a=i.move("[^");const s=n.enter("footnoteReference"),u=n.enter("reference");return a+=i.move(n.safe(n.associationId(e),{...i.current(),before:a,after:"]"})),u(),s(),a+=i.move("]"),a}function Zu(){return"["}function el(e,t,n,r){const i=n.createTracker(r);let a=i.move("[^");const s=n.enter("footnoteDefinition"),u=n.enter("label");return a+=i.move(n.safe(n.associationId(e),{...i.current(),before:a,after:"]"})),u(),a+=i.move("]:"+(e.children&&e.children.length>0?" ":"")),i.shift(4),a+=i.move(n.indentLines(n.containerFlow(e,i.current()),tl)),s(),a}function tl(e,t,n){return t===0?e:(n?"":" ")+e}const nl=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Ha.peek=ol;function rl(){return{canContainEols:["delete"],enter:{strikethrough:al},exit:{strikethrough:sl}}}function il(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:nl}],handlers:{delete:Ha}}}function al(e){this.enter({type:"delete",children:[]},e)}function sl(e){this.exit(e)}function Ha(e,t,n,r){const i=n.createTracker(r),a=n.enter("strikethrough");let s=i.move("~~");return s+=n.containerPhrasing(e,{...i.current(),before:s,after:"~"}),s+=i.move("~~"),a(),s}function ol(){return"~"}function ul(e,t={}){const n=(t.align||[]).concat(),r=t.stringLength||cl,i=[],a=[],s=[],u=[];let l=0,c=-1;for(;++c<e.length;){const E=[],y=[];let k=-1;for(e[c].length>l&&(l=e[c].length);++k<e[c].length;){const _=ll(e[c][k]);if(t.alignDelimiters!==!1){const S=r(_);y[k]=S,(u[k]===void 0||S>u[k])&&(u[k]=S)}E.push(_)}a[c]=E,s[c]=y}let d=-1;if(typeof n=="object"&&"length"in n)for(;++d<l;)i[d]=pi(n[d]);else{const E=pi(n);for(;++d<l;)i[d]=E}d=-1;const h=[],g=[];for(;++d<l;){const E=i[d];let y="",k="";E===99?(y=":",k=":"):E===108?y=":":E===114&&(k=":");let _=t.alignDelimiters===!1?1:Math.max(1,u[d]-y.length-k.length);const S=y+"-".repeat(_)+k;t.alignDelimiters!==!1&&(_=y.length+_+k.length,_>u[d]&&(u[d]=_),g[d]=_),h[d]=S}a.splice(1,0,h),s.splice(1,0,g),c=-1;const f=[];for(;++c<a.length;){const E=a[c],y=s[c];d=-1;const k=[];for(;++d<l;){const _=E[d]||"";let S="",L="";if(t.alignDelimiters!==!1){const M=u[d]-(y[d]||0),F=i[d];F===114?S=" ".repeat(M):F===99?M%2?(S=" ".repeat(M/2+.5),L=" ".repeat(M/2-.5)):(S=" ".repeat(M/2),L=S):L=" ".repeat(M)}t.delimiterStart!==!1&&!d&&k.push("|"),t.padding!==!1&&!(t.alignDelimiters===!1&&_==="")&&(t.delimiterStart!==!1||d)&&k.push(" "),t.alignDelimiters!==!1&&k.push(S),k.push(_),t.alignDelimiters!==!1&&k.push(L),t.padding!==!1&&k.push(" "),(t.delimiterEnd!==!1||d!==l-1)&&k.push("|")}f.push(t.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return f.join(`
|
|
2
2
|
`)}function ll(e){return e==null?"":String(e)}function cl(e){return e.length}function pi(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}const mi={}.hasOwnProperty;function Ua(e,t){const n=t||{};function r(i,...a){let s=r.invalid;const u=r.handlers;if(i&&mi.call(i,e)){const l=String(i[e]);s=mi.call(u,l)?u[l]:r.unknown}if(s)return s.call(this,i,...a)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}function dl(e,t,n,r){const i=n.enter("blockquote"),a=n.createTracker(r);a.move("> "),a.shift(2);const s=n.indentLines(n.containerFlow(e,a.current()),hl);return i(),s}function hl(e,t,n){return">"+(n?"":" ")+e}function fl(e,t){return gi(e,t.inConstruct,!0)&&!gi(e,t.notInConstruct,!1)}function gi(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function bi(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
3
3
|
`&&fl(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
4
4
|
`}function pl(e,t){const n=String(e);let r=n.indexOf(t),i=r,a=0,s=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++a>s&&(s=a):a=1,i=r+t.length,r=n.indexOf(t,i);return s}function ml(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function gl(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function bl(e,t,n,r){const i=gl(n),a=e.value||"",s=i==="`"?"GraveAccent":"Tilde";if(ml(e,n)){const h=n.enter("codeIndented"),g=n.indentLines(a,El);return h(),g}const u=n.createTracker(r),l=i.repeat(Math.max(pl(a,i)+1,3)),c=n.enter("codeFenced");let d=u.move(l);if(e.lang){const h=n.enter(`codeFencedLang${s}`);d+=u.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...u.current()})),h()}if(e.lang&&e.meta){const h=n.enter(`codeFencedMeta${s}`);d+=u.move(" "),d+=u.move(n.safe(e.meta,{before:d,after:`
|
package/dist/designs.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Fragment as Qa, jsx as b, jsxs as U } from "react/jsx-runtime";
|
|
|
2
2
|
import * as Un from "@radix-ui/react-popover";
|
|
3
3
|
import * as Te from "react";
|
|
4
4
|
import an, { forwardRef as zr, useState as Fe, useImperativeHandle as Au, useRef as cn, useCallback as Cu, useMemo as Yr, useEffect as Ot, memo as ku, cloneElement as Nu, createElement as Ai } from "react";
|
|
5
|
-
import { l as Ci, m as Iu, a as We, u as mt, d as dn, g as zn, i as Su, c as Xa, h as Lt, e as Yn, j as hn, b as Ou, _ as Lu, W as Ru, k as Du } from "./useWidgetTrigger-
|
|
5
|
+
import { l as Ci, m as Iu, a as We, u as mt, d as dn, g as zn, i as Su, c as Xa, h as Lt, e as Yn, j as hn, b as Ou, _ as Lu, W as Ru, k as Du } from "./useWidgetTrigger-ims5I4zH.js";
|
|
6
6
|
import * as Ue from "@radix-ui/react-dialog";
|
|
7
7
|
import { X as vu, PaperclipIcon as Pu, ImageIcon as Mu, CircleDashed as Bu, ArrowUpIcon as Fu, CircleCheckIcon as Hu, XIcon as jr, AlertCircle as Uu, Loader2 as zu, FileAudio2Icon as Yu, FileVideo2Icon as ju, FileIcon as Wu, ChevronRight as qu, Check as Vu, Circle as Gu, ChevronLeftIcon as Qu, EllipsisVerticalIcon as Xu, MessageCirclePlusIcon as Ku, LoaderIcon as $u, SendHorizontal as Ju, UserRoundIcon as Zu, ChevronRightIcon as el, ChevronDownIcon as tl } from "lucide-react";
|
|
8
8
|
import { clsx as Ka } from "clsx";
|
package/dist/react.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useWidgetTrigger-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useWidgetTrigger-DL9e5ISu.cjs");function g(t,i,s){const{widgetCtx:{api:u}}=e.useWidget();return e._default(async r=>u.vote({action:r==="up"?"upvote":"downvote",messagePublicId:t,sessionId:i}).then(s),[u,t,i,s])}exports.WidgetProvider=e.WidgetProvider;exports.WidgetTriggerProvider=e.WidgetTriggerProvider;exports.useConfig=e.useConfig;exports.useContact=e.useContact;exports.useIsAwaitingBotReply=e.useIsAwaitingBotReply;exports.useMessages=e.useMessages;exports.usePreludeData=e.usePreludeData;exports.usePrimitiveState=e.usePrimitiveState;exports.useSessions=e.useSessions;exports.useUploadFiles=e.useUploadFiles;exports.useWidget=e.useWidget;exports.useWidgetRouter=e.useWidgetRouter;exports.useWidgetTrigger=e.useWidgetTrigger;exports.useVote=g;
|
|
2
2
|
//# sourceMappingURL=react.cjs.map
|
package/dist/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { u, _ as r } from "./useWidgetTrigger-
|
|
2
|
-
import { W as p, k as f, a as l, b as v, c as W, d as c, e as m, f as P, g as w, i as x, h as C, j as b } from "./useWidgetTrigger-
|
|
1
|
+
import { u, _ as r } from "./useWidgetTrigger-ims5I4zH.js";
|
|
2
|
+
import { W as p, k as f, a as l, b as v, c as W, d as c, e as m, f as P, g as w, i as x, h as C, j as b } from "./useWidgetTrigger-ims5I4zH.js";
|
|
3
3
|
function g(e, s, t) {
|
|
4
4
|
const {
|
|
5
5
|
widgetCtx: { api: a }
|
|
@@ -110,6 +110,11 @@ export interface WidgetConfig {
|
|
|
110
110
|
* @default false
|
|
111
111
|
*/
|
|
112
112
|
isOpen?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Automatically open the widget after N seconds.
|
|
115
|
+
* @default undefined
|
|
116
|
+
*/
|
|
117
|
+
openAfterNSeconds?: number;
|
|
113
118
|
/**
|
|
114
119
|
* A custom vanilla stylesheet to override the default styles. See {@link OpenCxComponentNameU} for available component names.
|
|
115
120
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const y=require("react"),Ht=require("uuid"),Ze=require("react/jsx-runtime"),Kt=require("./widget.ctx-sL-dW2kY.cjs"),zt="3.0.
|
|
1
|
+
"use strict";const y=require("react"),Ht=require("uuid"),Ze=require("react/jsx-runtime"),Kt=require("./widget.ctx-sL-dW2kY.cjs"),zt="3.0.81";class kt{constructor(t){this.components=[];const{components:n}=t;if(n&&n.forEach(r=>this.register(r)),this.components.length===0)throw new Error("No components registered");if(!this.get("fallback"))throw new Error("No fallback component registered")}register(t){const n=this.components.findIndex(r=>r.key===t.key);return n!==-1?this.components[n]=t:this.components.push(t),this}get(t){const n=this.components.find(r=>r.key.toUpperCase()===t.toUpperCase());return n||null}getComponent(t){var n;return(n=this.get(t))==null?void 0:n.component}}const et=y.createContext(null);function Yt({options:e,children:t,components:n,storage:r,loadingComponent:o}){const s=y.useRef(null),i=y.useRef(!1),[d,h]=y.useState(null),c=y.useMemo(()=>new kt({components:n}),[n]);return y.useEffect(()=>{i.current||(i.current=!0,Kt.WidgetCtx.initialize({config:e,storage:r}).then(h))},[]),d?Ze.jsx(et.Provider,{value:{widgetCtx:d,config:e,components:n,componentStore:c,version:zt,contentIframeRef:s},children:t}):o||null}function K(){const e=y.useContext(et);if(!e)throw new Error("useWidget must be used within a WidgetProvider");return e}function tt(){const{config:e}=K();return e}function ee(e){return y.useSyncExternalStore(e.subscribe,e.get,e.get)}function Jt(){const{widgetCtx:e}=K();return{contactState:ee(e.contactCtx.state),createUnverifiedContact:e.contactCtx.createUnverifiedContact}}function nt(){const{widgetCtx:e}=K();return{messagesState:ee(e.messageCtx.state),sendMessage:e.messageCtx.sendMessage}}function rt(){const{widgetCtx:e}=K(),t=ee(e.sessionCtx.sessionState),n=ee(e.sessionCtx.sessionsState);return{sessionState:t,sessionsState:n,loadMoreSessions:e.sessionCtx.loadMoreSessions}}function Xt(){var i;const{sessionState:e}=rt(),{messagesState:t}=nt(),n=((i=e.session)==null?void 0:i.assignee.kind)==="ai",r=t.messages.length>0?t.messages[t.messages.length-1]:null,o=(r==null?void 0:r.type)==="FROM_USER";return{isAwaitingBotReply:(n||e.isCreatingSession)&&(t.isSendingMessage||o)}}var Qt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Zt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function en(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var n=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}),n}var Re={exports:{}},_e={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* use-sync-external-store-shim.production.min.js
|
|
4
4
|
*
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var ze;function nn(){return ze||(ze=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=y,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(R){{for(var v=arguments.length,w=new Array(v>1?v-1:0),S=1;S<v;S++)w[S-1]=arguments[S];r("error",R,w)}}function r(R,v,w){{var S=t.ReactDebugCurrentFrame,I=S.getStackAddendum();I!==""&&(v+="%s",w=w.concat([I]));var m=w.map(function(D){return String(D)});m.unshift("Warning: "+v),Function.prototype.apply.call(console[R],console,m)}}function o(R,v){return R===v&&(R!==0||1/R===1/v)||R!==R&&v!==v}var s=typeof Object.is=="function"?Object.is:o,i=e.useState,d=e.useEffect,h=e.useLayoutEffect,c=e.useDebugValue,a=!1,u=!1;function l(R,v,w){a||e.startTransition!==void 0&&(a=!0,n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var S=v();if(!u){var I=v();s(S,I)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}var m=i({inst:{value:S,getSnapshot:v}}),D=m[0].inst,j=m[1];return h(function(){D.value=S,D.getSnapshot=v,f(D)&&j({inst:D})},[R,S,v]),d(function(){f(D)&&j({inst:D});var B=function(){f(D)&&j({inst:D})};return R(B)},[R]),c(S),S}function f(R){var v=R.getSnapshot,w=R.value;try{var S=v();return!s(w,S)}catch{return!0}}function _(R,v,w){return v()}var g=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",C=!g,p=C?_:l,k=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p;Ee.useSyncExternalStore=k,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Ee}process.env.NODE_ENV==="production"?Re.exports=tn():Re.exports=nn();var rn=Re.exports;const G=()=>{},L=G(),ve=Object,E=e=>e===L,N=e=>typeof e=="function",H=(e,t)=>({...e,...t}),on=e=>N(e.then),ue=new WeakMap;let sn=0;const oe=e=>{const t=typeof e,n=e&&e.constructor,r=n==Date;let o,s;if(ve(e)===e&&!r&&n!=RegExp){if(o=ue.get(e),o)return o;if(o=++sn+"~",ue.set(e,o),n==Array){for(o="@",s=0;s<e.length;s++)o+=oe(e[s])+",";ue.set(e,o)}if(n==ve){o="#";const i=ve.keys(e).sort();for(;!E(s=i.pop());)E(e[s])||(o+=s+":"+oe(e[s])+",");ue.set(e,o)}}else o=r?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return o},q=new WeakMap,Se={},ce={},Le="undefined",pe=typeof window!=Le,Te=typeof document!=Le,an=()=>pe&&typeof window.requestAnimationFrame!=Le,ot=(e,t)=>{const n=q.get(e);return[()=>!E(t)&&e.get(t)||Se,r=>{if(!E(t)){const o=e.get(t);t in ce||(ce[t]=o),n[5](t,H(o,r),o||Se)}},n[6],()=>!E(t)&&t in ce?ce[t]:!E(t)&&e.get(t)||Se]};let Ce=!0;const un=()=>Ce,[De,Ae]=pe&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[G,G],cn=()=>{const e=Te&&document.visibilityState;return E(e)||e!=="hidden"},fn=e=>(Te&&document.addEventListener("visibilitychange",e),De("focus",e),()=>{Te&&document.removeEventListener("visibilitychange",e),Ae("focus",e)}),ln=e=>{const t=()=>{Ce=!0,e()},n=()=>{Ce=!1};return De("online",t),De("offline",n),()=>{Ae("online",t),Ae("offline",n)}},dn={isOnline:un,isVisible:cn},pn={initFocus:fn,initReconnect:ln},ke=!y.useId,se=!pe||"Deno"in window,hn=e=>an()?window.requestAnimationFrame(e):setTimeout(e,1),we=se?y.useEffect:y.useLayoutEffect,me=typeof navigator<"u"&&navigator.connection,Ye=!se&&me&&(["slow-2g","2g"].includes(me.effectiveType)||me.saveData),Ie=e=>{if(N(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?oe(e):"",[e,t]};let gn=0;const xe=()=>++gn,st=0,it=1,at=2,yn=3;var re={__proto__:null,ERROR_REVALIDATE_EVENT:yn,FOCUS_EVENT:st,MUTATE_EVENT:at,RECONNECT_EVENT:it};async function ut(...e){const[t,n,r,o]=e,s=H({populateCache:!0,throwOnError:!0},typeof o=="boolean"?{revalidate:o}:o||{});let i=s.populateCache;const d=s.rollbackOnError;let h=s.optimisticData;const c=l=>typeof d=="function"?d(l):d!==!1,a=s.throwOnError;if(N(n)){const l=n,f=[],_=t.keys();for(const g of _)!/^\$(inf|sub)\$/.test(g)&&l(t.get(g)._k)&&f.push(g);return Promise.all(f.map(u))}return u(n);async function u(l){const[f]=Ie(l);if(!f)return;const[_,g]=ot(t,f),[C,p,k,R]=q.get(t),v=()=>{const M=C[f];return(N(s.revalidate)?s.revalidate(_().data,l):s.revalidate!==!1)&&(delete k[f],delete R[f],M&&M[0])?M[0](at).then(()=>_().data):_().data};if(e.length<3)return v();let w=r,S;const I=xe();p[f]=[I,0];const m=!E(h),D=_(),j=D.data,B=D._c,z=E(B)?j:B;if(m&&(h=N(h)?h(z,j):h,g({data:h,_c:z})),N(w))try{w=w(z)}catch(M){S=M}if(w&&on(w))if(w=await w.catch(M=>{S=M}),I!==p[f][0]){if(S)throw S;return w}else S&&m&&c(S)&&(i=!0,g({data:z,_c:L}));if(i&&!S)if(N(i)){const M=i(w,z);g({data:M,error:L,_c:L})}else g({data:w,error:L,_c:L});if(p[f][1]=xe(),Promise.resolve(v()).then(()=>{g({_c:L})}),S){if(a)throw S;return}return w}}const Je=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},_n=(e,t)=>{if(!q.has(e)){const n=H(pn,t),r={},o=ut.bind(L,e);let s=G;const i={},d=(a,u)=>{const l=i[a]||[];return i[a]=l,l.push(u),()=>l.splice(l.indexOf(u),1)},h=(a,u,l)=>{e.set(a,u);const f=i[a];if(f)for(const _ of f)_(u,l)},c=()=>{if(!q.has(e)&&(q.set(e,[r,{},{},{},o,h,d]),!se)){const a=n.initFocus(setTimeout.bind(L,Je.bind(L,r,st))),u=n.initReconnect(setTimeout.bind(L,Je.bind(L,r,it)));s=()=>{a&&a(),u&&u(),q.delete(e)}}};return c(),[e,o,c,s]}return[e,q.get(e)[4]]},En=(e,t,n,r,o)=>{const s=n.errorRetryCount,i=o.retryCount,d=~~((Math.random()+.5)*(1<<(i<8?i:8)))*n.errorRetryInterval;!E(s)&&i>s||setTimeout(r,d,o)},vn=(e,t)=>oe(e)==oe(t),[ct,Sn]=_n(new Map),wn=H({onLoadingSlow:G,onSuccess:G,onError:G,onErrorRetry:En,onDiscarded:G,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ye?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ye?5e3:3e3,compare:vn,isPaused:()=>!1,cache:ct,mutate:Sn,fallback:{}},dn),mn=(e,t)=>{const n=H(e,t);if(t){const{use:r,fallback:o}=e,{use:s,fallback:i}=t;r&&s&&(n.use=r.concat(s)),o&&i&&(n.fallback=H(o,i))}return n},bn=y.createContext({}),On="$inf$",ft=pe&&window.__SWR_DEVTOOLS_USE__,Rn=ft?window.__SWR_DEVTOOLS_USE__:[],Tn=()=>{ft&&(window.__SWR_DEVTOOLS_REACT__=y)},Cn=e=>N(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],Dn=()=>H(wn,y.useContext(bn)),An=e=>(t,n,r)=>e(t,n&&((...s)=>{const[i]=Ie(t),[,,,d]=q.get(ct);if(i.startsWith(On))return n(...s);const h=d[i];return E(h)?n(...s):(delete d[i],h)}),r),xn=Rn.concat(An),Pn=e=>function(...n){const r=Dn(),[o,s,i]=Cn(n),d=mn(r,i);let h=e;const{use:c}=d,a=(c||[]).concat(xn);for(let u=a.length;u--;)h=a[u](h);return h(o,s||d.fetcher||null,d)},jn=(e,t,n)=>{const r=t[e]||(t[e]=[]);return r.push(n),()=>{const o=r.indexOf(n);o>=0&&(r[o]=r[r.length-1],r.pop())}};Tn();const Xe=y.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),be={dedupe:!0},Ln=(e,t,n)=>{const{cache:r,compare:o,suspense:s,fallbackData:i,revalidateOnMount:d,revalidateIfStale:h,refreshInterval:c,refreshWhenHidden:a,refreshWhenOffline:u,keepPreviousData:l}=n,[f,_,g,C]=q.get(r),[p,k]=Ie(e),R=y.useRef(!1),v=y.useRef(!1),w=y.useRef(p),S=y.useRef(t),I=y.useRef(n),m=()=>I.current,D=()=>m().isVisible()&&m().isOnline(),[j,B,z,M]=ot(r,p),Y=y.useRef({}).current,Wt=E(i)?n.fallback[p]:i,Me=(b,O)=>{for(const x in Y){const T=x;if(T==="data"){if(!o(b[T],O[T])&&(!E(b[T])||!o(ae,O[T])))return!1}else if(O[T]!==b[T])return!1}return!0},Fe=y.useMemo(()=>{const b=!p||!t?!1:E(d)?m().isPaused()||s?!1:E(h)?!0:h:d,O=P=>{const U=H(P);return delete U._k,b?{isValidating:!0,isLoading:!0,...U}:U},x=j(),T=M(),F=O(x),Z=x===T?F:O(T);let A=F;return[()=>{const P=O(j());return Me(P,A)?(A.data=P.data,A.isLoading=P.isLoading,A.isValidating=P.isValidating,A.error=P.error,A):(A=P,P)},()=>Z]},[r,p]),J=rn.useSyncExternalStore(y.useCallback(b=>z(p,(O,x)=>{Me(x,O)||b()}),[r,p]),Fe[0],Fe[1]),Ne=!R.current,qt=f[p]&&f[p].length>0,X=J.data,Q=E(X)?Wt:X,ie=J.error,Ue=y.useRef(Q),ae=l?E(X)?Ue.current:X:Q,We=qt&&!E(ie)?!1:Ne&&!E(d)?d:m().isPaused()?!1:s?E(Q)?!1:h:E(Q)||h,qe=!!(p&&t&&Ne&&We),Bt=E(J.isValidating)?qe:J.isValidating,$t=E(J.isLoading)?qe:J.isLoading,ne=y.useCallback(async b=>{const O=S.current;if(!p||!O||v.current||m().isPaused())return!1;let x,T,F=!0;const Z=b||{},A=!g[p]||!Z.dedupe,P=()=>ke?!v.current&&p===w.current&&R.current:p===w.current,U={isValidating:!1,isLoading:!1},$e=()=>{B(U)},Ge=()=>{const V=g[p];V&&V[1]===T&&delete g[p]},He={isValidating:!0};E(j().data)&&(He.isLoading=!0);try{if(A&&(B(He),n.loadingTimeout&&E(j().data)&&setTimeout(()=>{F&&P()&&m().onLoadingSlow(p,n)},n.loadingTimeout),g[p]=[O(k),xe()]),[x,T]=g[p],x=await x,A&&setTimeout(Ge,n.dedupingInterval),!g[p]||g[p][1]!==T)return A&&P()&&m().onDiscarded(p),!1;U.error=L;const V=_[p];if(!E(V)&&(T<=V[0]||T<=V[1]||V[1]===0))return $e(),A&&P()&&m().onDiscarded(p),!1;const W=j().data;U.data=o(W,x)?W:x,A&&P()&&m().onSuccess(x,p,n)}catch(V){Ge();const W=m(),{shouldRetryOnError:ge}=W;W.isPaused()||(U.error=V,A&&P()&&(W.onError(V,p,W),(ge===!0||N(ge)&&ge(V))&&(!m().revalidateOnFocus||!m().revalidateOnReconnect||D())&&W.onErrorRetry(V,p,W,Gt=>{const ye=f[p];ye&&ye[0]&&ye[0](re.ERROR_REVALIDATE_EVENT,Gt)},{retryCount:(Z.retryCount||0)+1,dedupe:!0})))}return F=!1,$e(),!0},[p,r]),Be=y.useCallback((...b)=>ut(r,w.current,...b),[]);if(we(()=>{S.current=t,I.current=n,E(X)||(Ue.current=X)}),we(()=>{if(!p)return;const b=ne.bind(L,be);let O=0;const T=jn(p,f,(F,Z={})=>{if(F==re.FOCUS_EVENT){const A=Date.now();m().revalidateOnFocus&&A>O&&D()&&(O=A+m().focusThrottleInterval,b())}else if(F==re.RECONNECT_EVENT)m().revalidateOnReconnect&&D()&&b();else{if(F==re.MUTATE_EVENT)return ne();if(F==re.ERROR_REVALIDATE_EVENT)return ne(Z)}});return v.current=!1,w.current=p,R.current=!0,B({_k:k}),We&&(E(Q)||se?b():hn(b)),()=>{v.current=!0,T()}},[p]),we(()=>{let b;function O(){const T=N(c)?c(j().data):c;T&&b!==-1&&(b=setTimeout(x,T))}function x(){!j().error&&(a||m().isVisible())&&(u||m().isOnline())?ne(be).then(O):O()}return O(),()=>{b&&(clearTimeout(b),b=-1)}},[c,a,u,p]),y.useDebugValue(ae),s&&E(Q)&&p){if(!ke&&se)throw new Error("Fallback data is required when using suspense in SSR.");S.current=t,I.current=n,v.current=!1;const b=C[p];if(!E(b)){const O=Be(b);Xe(O)}if(E(ie)){const O=ne(be);E(ae)||(O.status="fulfilled",O.value=!0),Xe(O)}else throw ie}return{mutate:Be,get data(){return Y.data=!0,ae},get error(){return Y.error=!0,ie},get isValidating(){return Y.isValidating=!0,Bt},get isLoading(){return Y.isLoading=!0,$t}}},In=Pn(Ln);function Vn(){const{widgetCtx:e}=K();return In([e.config.token],e.api.widgetPrelude,{revalidateOnFocus:!1})}function Mn(){const{widgetCtx:e}=K();return{routerState:ee(e.routerCtx.state),toSessionsScreen:e.routerCtx.toSessionsScreen,toChatScreen:e.routerCtx.toChatScreen}}var lt={},Pe=function(e,t){return Pe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},Pe(e,t)};function dt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Pe(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var le=function(){return le=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},le.apply(this,arguments)};function pt(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function ht(e,t,n,r){var o=arguments.length,s=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(e,t,n,r);else for(var d=e.length-1;d>=0;d--)(i=e[d])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s}function gt(e,t){return function(n,r){t(n,r,e)}}function yt(e,t,n,r,o,s){function i(p){if(p!==void 0&&typeof p!="function")throw new TypeError("Function expected");return p}for(var d=r.kind,h=d==="getter"?"get":d==="setter"?"set":"value",c=!t&&e?r.static?e:e.prototype:null,a=t||(c?Object.getOwnPropertyDescriptor(c,r.name):{}),u,l=!1,f=n.length-1;f>=0;f--){var _={};for(var g in r)_[g]=g==="access"?{}:r[g];for(var g in r.access)_.access[g]=r.access[g];_.addInitializer=function(p){if(l)throw new TypeError("Cannot add initializers after decoration has completed");s.push(i(p||null))};var C=(0,n[f])(d==="accessor"?{get:a.get,set:a.set}:a[h],_);if(d==="accessor"){if(C===void 0)continue;if(C===null||typeof C!="object")throw new TypeError("Object expected");(u=i(C.get))&&(a.get=u),(u=i(C.set))&&(a.set=u),(u=i(C.init))&&o.unshift(u)}else(u=i(C))&&(d==="field"?o.unshift(u):a[h]=u)}c&&Object.defineProperty(c,r.name,a),l=!0}function _t(e,t,n){for(var r=arguments.length>2,o=0;o<t.length;o++)n=r?t[o].call(e,n):t[o].call(e);return r?n:void 0}function Et(e){return typeof e=="symbol"?e:"".concat(e)}function vt(e,t,n){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})}function St(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function wt(e,t,n,r){function o(s){return s instanceof n?s:new n(function(i){i(s)})}return new(n||(n=Promise))(function(s,i){function d(a){try{c(r.next(a))}catch(u){i(u)}}function h(a){try{c(r.throw(a))}catch(u){i(u)}}function c(a){a.done?s(a.value):o(a.value).then(d,h)}c((r=r.apply(e,t||[])).next())})}function mt(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,o,s,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=d(0),i.throw=d(1),i.return=d(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function d(c){return function(a){return h([c,a])}}function h(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(s=c[0]&2?o.return:c[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,c[1])).done)return s;switch(o=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(a){c=[6,a],o=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}var he=Object.create?function(e,t,n,r){r===void 0&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]};function bt(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&he(t,e,n)}function de(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ve(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,s=[],i;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(d){i={error:d}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function Ot(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ve(arguments[t]));return e}function Rt(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),o=0,t=0;t<n;t++)for(var s=arguments[t],i=0,d=s.length;i<d;i++,o++)r[o]=s[i];return r}function Tt(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function te(e){return this instanceof te?(this.v=e,this):new te(e)}function Ct(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),d("next"),d("throw"),d("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(f){return function(_){return Promise.resolve(_).then(f,u)}}function d(f,_){r[f]&&(o[f]=function(g){return new Promise(function(C,p){s.push([f,g,C,p])>1||h(f,g)})},_&&(o[f]=_(o[f])))}function h(f,_){try{c(r[f](_))}catch(g){l(s[0][3],g)}}function c(f){f.value instanceof te?Promise.resolve(f.value.v).then(a,u):l(s[0][2],f)}function a(f){h("next",f)}function u(f){h("throw",f)}function l(f,_){f(_),s.shift(),s.length&&h(s[0][0],s[0][1])}}function Dt(e){var t,n;return t={},r("next"),r("throw",function(o){throw o}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(o,s){t[o]=e[o]?function(i){return(n=!n)?{value:te(e[o](i)),done:!1}:s?s(i):i}:s}}function At(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof de=="function"?de(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(i){return new Promise(function(d,h){i=e[s](i),o(d,h,i.done,i.value)})}}function o(s,i,d,h){Promise.resolve(h).then(function(c){s({value:c,done:d})},i)}}function xt(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var Fn=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function Pt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&he(t,e,n);return Fn(t,e),t}function jt(e){return e&&e.__esModule?e:{default:e}}function Lt(e,t,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)}function It(e,t,n,r,o){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?o.call(e,n):o?o.value=n:t.set(e,n),n}function Vt(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function Mt(e,t,n){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var r,o;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose],n&&(o=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");o&&(r=function(){try{o.call(this)}catch(s){return Promise.reject(s)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}var Nn=typeof SuppressedError=="function"?SuppressedError:function(e,t,n){var r=new Error(n);return r.name="SuppressedError",r.error=e,r.suppressed=t,r};function Ft(e){function t(s){e.error=e.hasError?new Nn(s,e.error,"An error was suppressed during disposal."):s,e.hasError=!0}var n,r=0;function o(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(o);if(n.dispose){var s=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(s).then(o,function(i){return t(i),o()})}else r|=1}catch(i){t(i)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return o()}function Nt(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(n,r,o,s,i){return r?t?".jsx":".js":o&&(!s||!i)?n:o+s+"."+i.toLowerCase()+"js"}):e}const Un={__extends:dt,__assign:le,__rest:pt,__decorate:ht,__param:gt,__esDecorate:yt,__runInitializers:_t,__propKey:Et,__setFunctionName:vt,__metadata:St,__awaiter:wt,__generator:mt,__createBinding:he,__exportStar:bt,__values:de,__read:Ve,__spread:Ot,__spreadArrays:Rt,__spreadArray:Tt,__await:te,__asyncGenerator:Ct,__asyncDelegator:Dt,__asyncValues:At,__makeTemplateObject:xt,__importStar:Pt,__importDefault:jt,__classPrivateFieldGet:Lt,__classPrivateFieldSet:It,__classPrivateFieldIn:Vt,__addDisposableResource:Mt,__disposeResources:Ft,__rewriteRelativeImportExtension:Nt},Wn=Object.freeze(Object.defineProperty({__proto__:null,__addDisposableResource:Mt,get __assign(){return le},__asyncDelegator:Dt,__asyncGenerator:Ct,__asyncValues:At,__await:te,__awaiter:wt,__classPrivateFieldGet:Lt,__classPrivateFieldIn:Vt,__classPrivateFieldSet:It,__createBinding:he,__decorate:ht,__disposeResources:Ft,__esDecorate:yt,__exportStar:bt,__extends:dt,__generator:mt,__importDefault:jt,__importStar:Pt,__makeTemplateObject:xt,__metadata:St,__param:gt,__propKey:Et,__read:Ve,__rest:pt,__rewriteRelativeImportExtension:Nt,__runInitializers:_t,__setFunctionName:vt,__spread:Ot,__spreadArray:Tt,__spreadArrays:Rt,__values:de,default:Un},Symbol.toStringTag,{value:"Module"})),qn=en(Wn);var fe={},Qe;function Bn(){if(Qe)return fe;Qe=1,Object.defineProperty(fe,"__esModule",{value:!0});var e=y;function t(){var n=e.useRef(!1),r=e.useCallback(function(){return n.current},[]);return e.useEffect(function(){return n.current=!0,function(){n.current=!1}},[]),r}return fe.default=t,fe}Object.defineProperty(lt,"__esModule",{value:!0});var je=qn,Oe=y,$n=je.__importDefault(Bn());function Gn(e,t,n){t===void 0&&(t=[]),n===void 0&&(n={loading:!1});var r=Oe.useRef(0),o=$n.default(),s=Oe.useState(n),i=s[0],d=s[1],h=Oe.useCallback(function(){for(var c=[],a=0;a<arguments.length;a++)c[a]=arguments[a];var u=++r.current;return i.loading||d(function(l){return je.__assign(je.__assign({},l),{loading:!0})}),e.apply(void 0,c).then(function(l){return o()&&u===r.current&&d({value:l,loading:!1}),l},function(l){return o()&&u===r.current&&d({error:l,loading:!1}),l})},t);return[i,h]}var Hn=lt.default=Gn;const $=new Map;function Kn(){const[e,t]=y.useState([]),{widgetCtx:{api:n}}=K();function r(a){const u=a.map(l=>({file:l,id:Ht.v4(),status:"pending",progress:0}));t(l=>[...l,...u]),u.forEach(i)}function o(a,u){t(l=>l.map(f=>f.id===a?{...f,...u}:f))}function s(a){t(u=>u.filter(l=>l.id!==a))}const i=async a=>{const u=new AbortController;$.set(a.id,u);try{t(f=>f.map(_=>_.id===a.id?{..._,status:"uploading",progress:0}:_));const l=await n.uploadFile({file:a.file,abortSignal:u.signal,onProgress:f=>{o(a.id,{progress:f})}});o(a.id,{status:"success",fileUrl:l.fileUrl,progress:100})}catch(l){u.signal.aborted||o(a.id,{status:"error",error:l instanceof Error?l.message:"Upload failed",progress:0})}finally{$.delete(a.id)}},d=a=>{const u=$.get(a);u&&(u.abort(),$.delete(a)),s(a)},h=y.useMemo(()=>e.filter(a=>a.status==="success"&&a.fileUrl),[e]);function c(){$.forEach(a=>a.abort()),$.clear(),t([])}return y.useEffect(()=>()=>{$.forEach(a=>a.abort()),$.clear()},[]),{allFiles:e,appendFiles:r,handleCancelUpload:d,successFiles:h,emptyTheFiles:c,getFileById:a=>e.find(u=>u.id===a),getUploadProgress:a=>{var u;return((u=e.find(l=>l.id===a))==null?void 0:u.progress)??0},getUploadStatus:a=>{var u;return(u=e.find(l=>l.id===a))==null?void 0:u.status},hasErrors:e.some(a=>a.status==="error"),isUploading:e.some(a=>a.status==="uploading")}}const Ut=y.createContext(null);function zn({children:e}){const t=tt(),[n,r]=y.useState(t.isOpen??!1);return y.useEffect(()=>{r(o=>t.isOpen??o)},[t.isOpen]),Ze.jsx(Ut.Provider,{value:{isOpen:n,setIsOpen:r},children:e})}function kn(){const e=y.useContext(Ut);if(!e)throw new Error("useWidgetTrigger must be used within a WidgetTriggerProvider");return e}exports.WidgetProvider=Yt;exports.WidgetTriggerProvider=zn;exports._default=Hn;exports.commonjsGlobal=Qt;exports.getDefaultExportFromCjs=Zt;exports.useConfig=tt;exports.useContact=Jt;exports.useIsAwaitingBotReply=Xt;exports.useMessages=nt;exports.usePreludeData=Vn;exports.usePrimitiveState=ee;exports.useSessions=rt;exports.useUploadFiles=Kn;exports.useWidget=K;exports.useWidgetRouter=Mn;exports.useWidgetTrigger=kn;
|
|
18
|
-
//# sourceMappingURL=useWidgetTrigger-
|
|
17
|
+
*/var ze;function nn(){return ze||(ze=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=y,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(R){{for(var v=arguments.length,w=new Array(v>1?v-1:0),S=1;S<v;S++)w[S-1]=arguments[S];r("error",R,w)}}function r(R,v,w){{var S=t.ReactDebugCurrentFrame,I=S.getStackAddendum();I!==""&&(v+="%s",w=w.concat([I]));var m=w.map(function(D){return String(D)});m.unshift("Warning: "+v),Function.prototype.apply.call(console[R],console,m)}}function o(R,v){return R===v&&(R!==0||1/R===1/v)||R!==R&&v!==v}var s=typeof Object.is=="function"?Object.is:o,i=e.useState,d=e.useEffect,h=e.useLayoutEffect,c=e.useDebugValue,a=!1,u=!1;function l(R,v,w){a||e.startTransition!==void 0&&(a=!0,n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var S=v();if(!u){var I=v();s(S,I)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}var m=i({inst:{value:S,getSnapshot:v}}),D=m[0].inst,j=m[1];return h(function(){D.value=S,D.getSnapshot=v,f(D)&&j({inst:D})},[R,S,v]),d(function(){f(D)&&j({inst:D});var B=function(){f(D)&&j({inst:D})};return R(B)},[R]),c(S),S}function f(R){var v=R.getSnapshot,w=R.value;try{var S=v();return!s(w,S)}catch{return!0}}function _(R,v,w){return v()}var g=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",C=!g,p=C?_:l,k=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p;Ee.useSyncExternalStore=k,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Ee}process.env.NODE_ENV==="production"?Re.exports=tn():Re.exports=nn();var rn=Re.exports;const G=()=>{},L=G(),ve=Object,E=e=>e===L,F=e=>typeof e=="function",H=(e,t)=>({...e,...t}),on=e=>F(e.then),ue=new WeakMap;let sn=0;const oe=e=>{const t=typeof e,n=e&&e.constructor,r=n==Date;let o,s;if(ve(e)===e&&!r&&n!=RegExp){if(o=ue.get(e),o)return o;if(o=++sn+"~",ue.set(e,o),n==Array){for(o="@",s=0;s<e.length;s++)o+=oe(e[s])+",";ue.set(e,o)}if(n==ve){o="#";const i=ve.keys(e).sort();for(;!E(s=i.pop());)E(e[s])||(o+=s+":"+oe(e[s])+",");ue.set(e,o)}}else o=r?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return o},q=new WeakMap,Se={},ce={},Le="undefined",pe=typeof window!=Le,Te=typeof document!=Le,an=()=>pe&&typeof window.requestAnimationFrame!=Le,ot=(e,t)=>{const n=q.get(e);return[()=>!E(t)&&e.get(t)||Se,r=>{if(!E(t)){const o=e.get(t);t in ce||(ce[t]=o),n[5](t,H(o,r),o||Se)}},n[6],()=>!E(t)&&t in ce?ce[t]:!E(t)&&e.get(t)||Se]};let Ce=!0;const un=()=>Ce,[De,Ae]=pe&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[G,G],cn=()=>{const e=Te&&document.visibilityState;return E(e)||e!=="hidden"},fn=e=>(Te&&document.addEventListener("visibilitychange",e),De("focus",e),()=>{Te&&document.removeEventListener("visibilitychange",e),Ae("focus",e)}),ln=e=>{const t=()=>{Ce=!0,e()},n=()=>{Ce=!1};return De("online",t),De("offline",n),()=>{Ae("online",t),Ae("offline",n)}},dn={isOnline:un,isVisible:cn},pn={initFocus:fn,initReconnect:ln},ke=!y.useId,se=!pe||"Deno"in window,hn=e=>an()?window.requestAnimationFrame(e):setTimeout(e,1),we=se?y.useEffect:y.useLayoutEffect,me=typeof navigator<"u"&&navigator.connection,Ye=!se&&me&&(["slow-2g","2g"].includes(me.effectiveType)||me.saveData),Ie=e=>{if(F(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?oe(e):"",[e,t]};let gn=0;const xe=()=>++gn,st=0,it=1,at=2,yn=3;var re={__proto__:null,ERROR_REVALIDATE_EVENT:yn,FOCUS_EVENT:st,MUTATE_EVENT:at,RECONNECT_EVENT:it};async function ut(...e){const[t,n,r,o]=e,s=H({populateCache:!0,throwOnError:!0},typeof o=="boolean"?{revalidate:o}:o||{});let i=s.populateCache;const d=s.rollbackOnError;let h=s.optimisticData;const c=l=>typeof d=="function"?d(l):d!==!1,a=s.throwOnError;if(F(n)){const l=n,f=[],_=t.keys();for(const g of _)!/^\$(inf|sub)\$/.test(g)&&l(t.get(g)._k)&&f.push(g);return Promise.all(f.map(u))}return u(n);async function u(l){const[f]=Ie(l);if(!f)return;const[_,g]=ot(t,f),[C,p,k,R]=q.get(t),v=()=>{const M=C[f];return(F(s.revalidate)?s.revalidate(_().data,l):s.revalidate!==!1)&&(delete k[f],delete R[f],M&&M[0])?M[0](at).then(()=>_().data):_().data};if(e.length<3)return v();let w=r,S;const I=xe();p[f]=[I,0];const m=!E(h),D=_(),j=D.data,B=D._c,z=E(B)?j:B;if(m&&(h=F(h)?h(z,j):h,g({data:h,_c:z})),F(w))try{w=w(z)}catch(M){S=M}if(w&&on(w))if(w=await w.catch(M=>{S=M}),I!==p[f][0]){if(S)throw S;return w}else S&&m&&c(S)&&(i=!0,g({data:z,_c:L}));if(i&&!S)if(F(i)){const M=i(w,z);g({data:M,error:L,_c:L})}else g({data:w,error:L,_c:L});if(p[f][1]=xe(),Promise.resolve(v()).then(()=>{g({_c:L})}),S){if(a)throw S;return}return w}}const Je=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},_n=(e,t)=>{if(!q.has(e)){const n=H(pn,t),r={},o=ut.bind(L,e);let s=G;const i={},d=(a,u)=>{const l=i[a]||[];return i[a]=l,l.push(u),()=>l.splice(l.indexOf(u),1)},h=(a,u,l)=>{e.set(a,u);const f=i[a];if(f)for(const _ of f)_(u,l)},c=()=>{if(!q.has(e)&&(q.set(e,[r,{},{},{},o,h,d]),!se)){const a=n.initFocus(setTimeout.bind(L,Je.bind(L,r,st))),u=n.initReconnect(setTimeout.bind(L,Je.bind(L,r,it)));s=()=>{a&&a(),u&&u(),q.delete(e)}}};return c(),[e,o,c,s]}return[e,q.get(e)[4]]},En=(e,t,n,r,o)=>{const s=n.errorRetryCount,i=o.retryCount,d=~~((Math.random()+.5)*(1<<(i<8?i:8)))*n.errorRetryInterval;!E(s)&&i>s||setTimeout(r,d,o)},vn=(e,t)=>oe(e)==oe(t),[ct,Sn]=_n(new Map),wn=H({onLoadingSlow:G,onSuccess:G,onError:G,onErrorRetry:En,onDiscarded:G,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ye?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ye?5e3:3e3,compare:vn,isPaused:()=>!1,cache:ct,mutate:Sn,fallback:{}},dn),mn=(e,t)=>{const n=H(e,t);if(t){const{use:r,fallback:o}=e,{use:s,fallback:i}=t;r&&s&&(n.use=r.concat(s)),o&&i&&(n.fallback=H(o,i))}return n},bn=y.createContext({}),On="$inf$",ft=pe&&window.__SWR_DEVTOOLS_USE__,Rn=ft?window.__SWR_DEVTOOLS_USE__:[],Tn=()=>{ft&&(window.__SWR_DEVTOOLS_REACT__=y)},Cn=e=>F(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],Dn=()=>H(wn,y.useContext(bn)),An=e=>(t,n,r)=>e(t,n&&((...s)=>{const[i]=Ie(t),[,,,d]=q.get(ct);if(i.startsWith(On))return n(...s);const h=d[i];return E(h)?n(...s):(delete d[i],h)}),r),xn=Rn.concat(An),Pn=e=>function(...n){const r=Dn(),[o,s,i]=Cn(n),d=mn(r,i);let h=e;const{use:c}=d,a=(c||[]).concat(xn);for(let u=a.length;u--;)h=a[u](h);return h(o,s||d.fetcher||null,d)},jn=(e,t,n)=>{const r=t[e]||(t[e]=[]);return r.push(n),()=>{const o=r.indexOf(n);o>=0&&(r[o]=r[r.length-1],r.pop())}};Tn();const Xe=y.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),be={dedupe:!0},Ln=(e,t,n)=>{const{cache:r,compare:o,suspense:s,fallbackData:i,revalidateOnMount:d,revalidateIfStale:h,refreshInterval:c,refreshWhenHidden:a,refreshWhenOffline:u,keepPreviousData:l}=n,[f,_,g,C]=q.get(r),[p,k]=Ie(e),R=y.useRef(!1),v=y.useRef(!1),w=y.useRef(p),S=y.useRef(t),I=y.useRef(n),m=()=>I.current,D=()=>m().isVisible()&&m().isOnline(),[j,B,z,M]=ot(r,p),Y=y.useRef({}).current,Wt=E(i)?n.fallback[p]:i,Me=(b,O)=>{for(const x in Y){const T=x;if(T==="data"){if(!o(b[T],O[T])&&(!E(b[T])||!o(ae,O[T])))return!1}else if(O[T]!==b[T])return!1}return!0},Ne=y.useMemo(()=>{const b=!p||!t?!1:E(d)?m().isPaused()||s?!1:E(h)?!0:h:d,O=P=>{const U=H(P);return delete U._k,b?{isValidating:!0,isLoading:!0,...U}:U},x=j(),T=M(),N=O(x),Z=x===T?N:O(T);let A=N;return[()=>{const P=O(j());return Me(P,A)?(A.data=P.data,A.isLoading=P.isLoading,A.isValidating=P.isValidating,A.error=P.error,A):(A=P,P)},()=>Z]},[r,p]),J=rn.useSyncExternalStore(y.useCallback(b=>z(p,(O,x)=>{Me(x,O)||b()}),[r,p]),Ne[0],Ne[1]),Fe=!R.current,qt=f[p]&&f[p].length>0,X=J.data,Q=E(X)?Wt:X,ie=J.error,Ue=y.useRef(Q),ae=l?E(X)?Ue.current:X:Q,We=qt&&!E(ie)?!1:Fe&&!E(d)?d:m().isPaused()?!1:s?E(Q)?!1:h:E(Q)||h,qe=!!(p&&t&&Fe&&We),Bt=E(J.isValidating)?qe:J.isValidating,$t=E(J.isLoading)?qe:J.isLoading,ne=y.useCallback(async b=>{const O=S.current;if(!p||!O||v.current||m().isPaused())return!1;let x,T,N=!0;const Z=b||{},A=!g[p]||!Z.dedupe,P=()=>ke?!v.current&&p===w.current&&R.current:p===w.current,U={isValidating:!1,isLoading:!1},$e=()=>{B(U)},Ge=()=>{const V=g[p];V&&V[1]===T&&delete g[p]},He={isValidating:!0};E(j().data)&&(He.isLoading=!0);try{if(A&&(B(He),n.loadingTimeout&&E(j().data)&&setTimeout(()=>{N&&P()&&m().onLoadingSlow(p,n)},n.loadingTimeout),g[p]=[O(k),xe()]),[x,T]=g[p],x=await x,A&&setTimeout(Ge,n.dedupingInterval),!g[p]||g[p][1]!==T)return A&&P()&&m().onDiscarded(p),!1;U.error=L;const V=_[p];if(!E(V)&&(T<=V[0]||T<=V[1]||V[1]===0))return $e(),A&&P()&&m().onDiscarded(p),!1;const W=j().data;U.data=o(W,x)?W:x,A&&P()&&m().onSuccess(x,p,n)}catch(V){Ge();const W=m(),{shouldRetryOnError:ge}=W;W.isPaused()||(U.error=V,A&&P()&&(W.onError(V,p,W),(ge===!0||F(ge)&&ge(V))&&(!m().revalidateOnFocus||!m().revalidateOnReconnect||D())&&W.onErrorRetry(V,p,W,Gt=>{const ye=f[p];ye&&ye[0]&&ye[0](re.ERROR_REVALIDATE_EVENT,Gt)},{retryCount:(Z.retryCount||0)+1,dedupe:!0})))}return N=!1,$e(),!0},[p,r]),Be=y.useCallback((...b)=>ut(r,w.current,...b),[]);if(we(()=>{S.current=t,I.current=n,E(X)||(Ue.current=X)}),we(()=>{if(!p)return;const b=ne.bind(L,be);let O=0;const T=jn(p,f,(N,Z={})=>{if(N==re.FOCUS_EVENT){const A=Date.now();m().revalidateOnFocus&&A>O&&D()&&(O=A+m().focusThrottleInterval,b())}else if(N==re.RECONNECT_EVENT)m().revalidateOnReconnect&&D()&&b();else{if(N==re.MUTATE_EVENT)return ne();if(N==re.ERROR_REVALIDATE_EVENT)return ne(Z)}});return v.current=!1,w.current=p,R.current=!0,B({_k:k}),We&&(E(Q)||se?b():hn(b)),()=>{v.current=!0,T()}},[p]),we(()=>{let b;function O(){const T=F(c)?c(j().data):c;T&&b!==-1&&(b=setTimeout(x,T))}function x(){!j().error&&(a||m().isVisible())&&(u||m().isOnline())?ne(be).then(O):O()}return O(),()=>{b&&(clearTimeout(b),b=-1)}},[c,a,u,p]),y.useDebugValue(ae),s&&E(Q)&&p){if(!ke&&se)throw new Error("Fallback data is required when using suspense in SSR.");S.current=t,I.current=n,v.current=!1;const b=C[p];if(!E(b)){const O=Be(b);Xe(O)}if(E(ie)){const O=ne(be);E(ae)||(O.status="fulfilled",O.value=!0),Xe(O)}else throw ie}return{mutate:Be,get data(){return Y.data=!0,ae},get error(){return Y.error=!0,ie},get isValidating(){return Y.isValidating=!0,Bt},get isLoading(){return Y.isLoading=!0,$t}}},In=Pn(Ln);function Vn(){const{widgetCtx:e}=K();return In([e.config.token],e.api.widgetPrelude,{revalidateOnFocus:!1})}function Mn(){const{widgetCtx:e}=K();return{routerState:ee(e.routerCtx.state),toSessionsScreen:e.routerCtx.toSessionsScreen,toChatScreen:e.routerCtx.toChatScreen}}var lt={},Pe=function(e,t){return Pe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},Pe(e,t)};function dt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Pe(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var le=function(){return le=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},le.apply(this,arguments)};function pt(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function ht(e,t,n,r){var o=arguments.length,s=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(e,t,n,r);else for(var d=e.length-1;d>=0;d--)(i=e[d])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s}function gt(e,t){return function(n,r){t(n,r,e)}}function yt(e,t,n,r,o,s){function i(p){if(p!==void 0&&typeof p!="function")throw new TypeError("Function expected");return p}for(var d=r.kind,h=d==="getter"?"get":d==="setter"?"set":"value",c=!t&&e?r.static?e:e.prototype:null,a=t||(c?Object.getOwnPropertyDescriptor(c,r.name):{}),u,l=!1,f=n.length-1;f>=0;f--){var _={};for(var g in r)_[g]=g==="access"?{}:r[g];for(var g in r.access)_.access[g]=r.access[g];_.addInitializer=function(p){if(l)throw new TypeError("Cannot add initializers after decoration has completed");s.push(i(p||null))};var C=(0,n[f])(d==="accessor"?{get:a.get,set:a.set}:a[h],_);if(d==="accessor"){if(C===void 0)continue;if(C===null||typeof C!="object")throw new TypeError("Object expected");(u=i(C.get))&&(a.get=u),(u=i(C.set))&&(a.set=u),(u=i(C.init))&&o.unshift(u)}else(u=i(C))&&(d==="field"?o.unshift(u):a[h]=u)}c&&Object.defineProperty(c,r.name,a),l=!0}function _t(e,t,n){for(var r=arguments.length>2,o=0;o<t.length;o++)n=r?t[o].call(e,n):t[o].call(e);return r?n:void 0}function Et(e){return typeof e=="symbol"?e:"".concat(e)}function vt(e,t,n){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})}function St(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function wt(e,t,n,r){function o(s){return s instanceof n?s:new n(function(i){i(s)})}return new(n||(n=Promise))(function(s,i){function d(a){try{c(r.next(a))}catch(u){i(u)}}function h(a){try{c(r.throw(a))}catch(u){i(u)}}function c(a){a.done?s(a.value):o(a.value).then(d,h)}c((r=r.apply(e,t||[])).next())})}function mt(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,o,s,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=d(0),i.throw=d(1),i.return=d(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function d(c){return function(a){return h([c,a])}}function h(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(s=c[0]&2?o.return:c[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,c[1])).done)return s;switch(o=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(a){c=[6,a],o=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}var he=Object.create?function(e,t,n,r){r===void 0&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]};function bt(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&he(t,e,n)}function de(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ve(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,s=[],i;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(d){i={error:d}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function Ot(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ve(arguments[t]));return e}function Rt(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),o=0,t=0;t<n;t++)for(var s=arguments[t],i=0,d=s.length;i<d;i++,o++)r[o]=s[i];return r}function Tt(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function te(e){return this instanceof te?(this.v=e,this):new te(e)}function Ct(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),d("next"),d("throw"),d("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(f){return function(_){return Promise.resolve(_).then(f,u)}}function d(f,_){r[f]&&(o[f]=function(g){return new Promise(function(C,p){s.push([f,g,C,p])>1||h(f,g)})},_&&(o[f]=_(o[f])))}function h(f,_){try{c(r[f](_))}catch(g){l(s[0][3],g)}}function c(f){f.value instanceof te?Promise.resolve(f.value.v).then(a,u):l(s[0][2],f)}function a(f){h("next",f)}function u(f){h("throw",f)}function l(f,_){f(_),s.shift(),s.length&&h(s[0][0],s[0][1])}}function Dt(e){var t,n;return t={},r("next"),r("throw",function(o){throw o}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(o,s){t[o]=e[o]?function(i){return(n=!n)?{value:te(e[o](i)),done:!1}:s?s(i):i}:s}}function At(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof de=="function"?de(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(i){return new Promise(function(d,h){i=e[s](i),o(d,h,i.done,i.value)})}}function o(s,i,d,h){Promise.resolve(h).then(function(c){s({value:c,done:d})},i)}}function xt(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var Nn=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function Pt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&he(t,e,n);return Nn(t,e),t}function jt(e){return e&&e.__esModule?e:{default:e}}function Lt(e,t,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)}function It(e,t,n,r,o){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?o.call(e,n):o?o.value=n:t.set(e,n),n}function Vt(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function Mt(e,t,n){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var r,o;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose],n&&(o=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");o&&(r=function(){try{o.call(this)}catch(s){return Promise.reject(s)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}var Fn=typeof SuppressedError=="function"?SuppressedError:function(e,t,n){var r=new Error(n);return r.name="SuppressedError",r.error=e,r.suppressed=t,r};function Nt(e){function t(s){e.error=e.hasError?new Fn(s,e.error,"An error was suppressed during disposal."):s,e.hasError=!0}var n,r=0;function o(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(o);if(n.dispose){var s=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(s).then(o,function(i){return t(i),o()})}else r|=1}catch(i){t(i)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return o()}function Ft(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(n,r,o,s,i){return r?t?".jsx":".js":o&&(!s||!i)?n:o+s+"."+i.toLowerCase()+"js"}):e}const Un={__extends:dt,__assign:le,__rest:pt,__decorate:ht,__param:gt,__esDecorate:yt,__runInitializers:_t,__propKey:Et,__setFunctionName:vt,__metadata:St,__awaiter:wt,__generator:mt,__createBinding:he,__exportStar:bt,__values:de,__read:Ve,__spread:Ot,__spreadArrays:Rt,__spreadArray:Tt,__await:te,__asyncGenerator:Ct,__asyncDelegator:Dt,__asyncValues:At,__makeTemplateObject:xt,__importStar:Pt,__importDefault:jt,__classPrivateFieldGet:Lt,__classPrivateFieldSet:It,__classPrivateFieldIn:Vt,__addDisposableResource:Mt,__disposeResources:Nt,__rewriteRelativeImportExtension:Ft},Wn=Object.freeze(Object.defineProperty({__proto__:null,__addDisposableResource:Mt,get __assign(){return le},__asyncDelegator:Dt,__asyncGenerator:Ct,__asyncValues:At,__await:te,__awaiter:wt,__classPrivateFieldGet:Lt,__classPrivateFieldIn:Vt,__classPrivateFieldSet:It,__createBinding:he,__decorate:ht,__disposeResources:Nt,__esDecorate:yt,__exportStar:bt,__extends:dt,__generator:mt,__importDefault:jt,__importStar:Pt,__makeTemplateObject:xt,__metadata:St,__param:gt,__propKey:Et,__read:Ve,__rest:pt,__rewriteRelativeImportExtension:Ft,__runInitializers:_t,__setFunctionName:vt,__spread:Ot,__spreadArray:Tt,__spreadArrays:Rt,__values:de,default:Un},Symbol.toStringTag,{value:"Module"})),qn=en(Wn);var fe={},Qe;function Bn(){if(Qe)return fe;Qe=1,Object.defineProperty(fe,"__esModule",{value:!0});var e=y;function t(){var n=e.useRef(!1),r=e.useCallback(function(){return n.current},[]);return e.useEffect(function(){return n.current=!0,function(){n.current=!1}},[]),r}return fe.default=t,fe}Object.defineProperty(lt,"__esModule",{value:!0});var je=qn,Oe=y,$n=je.__importDefault(Bn());function Gn(e,t,n){t===void 0&&(t=[]),n===void 0&&(n={loading:!1});var r=Oe.useRef(0),o=$n.default(),s=Oe.useState(n),i=s[0],d=s[1],h=Oe.useCallback(function(){for(var c=[],a=0;a<arguments.length;a++)c[a]=arguments[a];var u=++r.current;return i.loading||d(function(l){return je.__assign(je.__assign({},l),{loading:!0})}),e.apply(void 0,c).then(function(l){return o()&&u===r.current&&d({value:l,loading:!1}),l},function(l){return o()&&u===r.current&&d({error:l,loading:!1}),l})},t);return[i,h]}var Hn=lt.default=Gn;const $=new Map;function Kn(){const[e,t]=y.useState([]),{widgetCtx:{api:n}}=K();function r(a){const u=a.map(l=>({file:l,id:Ht.v4(),status:"pending",progress:0}));t(l=>[...l,...u]),u.forEach(i)}function o(a,u){t(l=>l.map(f=>f.id===a?{...f,...u}:f))}function s(a){t(u=>u.filter(l=>l.id!==a))}const i=async a=>{const u=new AbortController;$.set(a.id,u);try{t(f=>f.map(_=>_.id===a.id?{..._,status:"uploading",progress:0}:_));const l=await n.uploadFile({file:a.file,abortSignal:u.signal,onProgress:f=>{o(a.id,{progress:f})}});o(a.id,{status:"success",fileUrl:l.fileUrl,progress:100})}catch(l){u.signal.aborted||o(a.id,{status:"error",error:l instanceof Error?l.message:"Upload failed",progress:0})}finally{$.delete(a.id)}},d=a=>{const u=$.get(a);u&&(u.abort(),$.delete(a)),s(a)},h=y.useMemo(()=>e.filter(a=>a.status==="success"&&a.fileUrl),[e]);function c(){$.forEach(a=>a.abort()),$.clear(),t([])}return y.useEffect(()=>()=>{$.forEach(a=>a.abort()),$.clear()},[]),{allFiles:e,appendFiles:r,handleCancelUpload:d,successFiles:h,emptyTheFiles:c,getFileById:a=>e.find(u=>u.id===a),getUploadProgress:a=>{var u;return((u=e.find(l=>l.id===a))==null?void 0:u.progress)??0},getUploadStatus:a=>{var u;return(u=e.find(l=>l.id===a))==null?void 0:u.status},hasErrors:e.some(a=>a.status==="error"),isUploading:e.some(a=>a.status==="uploading")}}const Ut=y.createContext(null);function zn({children:e}){const t=tt(),[n,r]=y.useState(t.isOpen??!1);return y.useEffect(()=>{r(o=>t.isOpen??o)},[t.isOpen]),y.useEffect(()=>{const o=t.openAfterNSeconds;if(typeof o!="number"||isNaN(o))return;const s=setTimeout(()=>r(!0),o*1e3);return()=>clearTimeout(s)},[t.openAfterNSeconds]),Ze.jsx(Ut.Provider,{value:{isOpen:n,setIsOpen:r},children:e})}function kn(){const e=y.useContext(Ut);if(!e)throw new Error("useWidgetTrigger must be used within a WidgetTriggerProvider");return e}exports.WidgetProvider=Yt;exports.WidgetTriggerProvider=zn;exports._default=Hn;exports.commonjsGlobal=Qt;exports.getDefaultExportFromCjs=Zt;exports.useConfig=tt;exports.useContact=Jt;exports.useIsAwaitingBotReply=Xt;exports.useMessages=nt;exports.usePreludeData=Vn;exports.usePrimitiveState=ee;exports.useSessions=rt;exports.useUploadFiles=Kn;exports.useWidget=K;exports.useWidgetRouter=Mn;exports.useWidgetTrigger=kn;
|
|
18
|
+
//# sourceMappingURL=useWidgetTrigger-DL9e5ISu.cjs.map
|