@getnexorai/sdk 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat.cjs +1 -0
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.js +1 -1
- package/dist/{chunk-ZQT7QEXV.js → chunk-YDWD2Q5S.js} +3 -2
- package/dist/chunk-YDWD2Q5S.js.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/nexor.iife.js +5 -5
- package/dist/nexor.iife.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-ZQT7QEXV.js.map +0 -1
package/dist/nexor.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(t){super(t),this.name="NexorError";}},w=class extends P{constructor(t){var n;super(t.message),this.name="NexorAPIError",this.status=t.status,this.code=(n=t.code)!=null?n:we(t.status),this.body=t.body,this.requestId=t.requestId;}},S=class extends w{constructor(t){super({status:401,code:"unauthorized",...t}),this.name="NexorAuthError";}},O=class extends w{constructor(t){super({status:400,code:"validation_error",...t}),this.name="NexorValidationError";}},M=class extends P{constructor(t,n){super(t),this.name="NexorNetworkError",this.cause=n;}};function we(e){return e===400?"validation_error":e===401?"unauthorized":e===403?"forbidden":e===404?"not_found":e===409?"conflict":e===422?"unprocessable_entity":e===429?"rate_limited":e>=500?"server_error":"http_error"}var Ce="https://api.getnexor.ai",ve=3e4,Le=2,Te="0.1.0";function oe(e){var r,o,c,
|
|
1
|
+
var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(t){super(t),this.name="NexorError";}},w=class extends P{constructor(t){var n;super(t.message),this.name="NexorAPIError",this.status=t.status,this.code=(n=t.code)!=null?n:we(t.status),this.body=t.body,this.requestId=t.requestId;}},S=class extends w{constructor(t){super({status:401,code:"unauthorized",...t}),this.name="NexorAuthError";}},O=class extends w{constructor(t){super({status:400,code:"validation_error",...t}),this.name="NexorValidationError";}},M=class extends P{constructor(t,n){super(t),this.name="NexorNetworkError",this.cause=n;}};function we(e){return e===400?"validation_error":e===401?"unauthorized":e===403?"forbidden":e===404?"not_found":e===409?"conflict":e===422?"unprocessable_entity":e===429?"rate_limited":e>=500?"server_error":"http_error"}var Ce="https://api.getnexor.ai",ve=3e4,Le=2,Te="0.1.0";function oe(e){var r,o,c,l;if(!e||typeof e.apiKey!="string"||e.apiKey.trim()==="")throw new Error("Nexor SDK: `apiKey` is required. Get one in the dashboard at https://app.getnexor.ai");let t=(r=e.fetch)!=null?r:typeof globalThis!="undefined"&&typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0;if(!t)throw new Error("Nexor SDK: no global fetch found. Pass a `fetch` implementation via init() or upgrade to Node 18+.");let n=`nexor-sdk-js/${Te}${e.userAgentSuffix?` ${e.userAgentSuffix}`:""}`;return {apiKey:e.apiKey.trim(),baseUrl:Me((o=e.baseUrl)!=null?o:Ce),timeoutMs:(c=e.timeoutMs)!=null?c:ve,maxRetries:(l=e.maxRetries)!=null?l:Le,fetchImpl:t,userAgent:n}}async function g(e,t){var i,a,y,f,C,I,R;let n=Ne(e.baseUrl,t.path,t.query),r={"X-API-Key":e.apiKey,Accept:"application/json","User-Agent":e.userAgent};(i=t.options)!=null&&i.idempotencyKey&&(r["Idempotency-Key"]=t.options.idempotencyKey);let o;t.body!==void 0&&(r["Content-Type"]="application/json",o=JSON.stringify(t.body));let c=(y=(a=t.options)==null?void 0:a.timeoutMs)!=null?y:e.timeoutMs,l;for(let d=0;d<=e.maxRetries;d++){let v=new AbortController,h=(f=t.options)==null?void 0:f.signal,L=()=>v.abort();h&&(h.aborted?v.abort():h.addEventListener("abort",L));let k=setTimeout(()=>v.abort(),c);try{let u=await e.fetchImpl(n,{method:t.method,headers:r,body:o,signal:v.signal});clearTimeout(k),h==null||h.removeEventListener("abort",L);let T=(C=u.headers.get("x-request-id"))!=null?C:void 0;if(u.ok){if(u.status===204)return;let E=await u.text();if(!E)return;try{return JSON.parse(E)}catch(Y){throw new w({status:u.status,message:"Failed to parse JSON response",body:E,requestId:T})}}let A=await Re(u),K=(I=Ee(A))!=null?I:`HTTP ${u.status}`,U=Ie(u.status,K,A,T);if(ke(u.status)&&d<e.maxRetries){await re(ne(d,u)),l=U;continue}throw U}catch(u){if(clearTimeout(k),h==null||h.removeEventListener("abort",L),u instanceof w)throw u;let T=u instanceof Error&&(u.name==="AbortError"||/abort/i.test(u.message));if(T&&(h!=null&&h.aborted))throw u;if(l=u,d<e.maxRetries){await re(ne(d));continue}throw new M(T?`Request timed out after ${c}ms`:`Network error: ${(R=u==null?void 0:u.message)!=null?R:String(u)}`,u)}}throw l!=null?l:new M("Request failed")}function Ie(e,t,n,r){return e===401||e===403?new S({message:t,body:n,requestId:r}):e===400||e===422?new O({message:t,body:n,requestId:r}):new w({status:e,message:t,body:n,requestId:r})}function Ee(e){if(!e||typeof e!="object")return;let t=e;if(typeof t.message=="string")return t.message;if(typeof t.error=="string")return t.error}async function Re(e){try{let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch(n){return t}}catch(t){return null}}function ke(e){return e===429||e>=500&&e<=599}function ne(e,t){if(t){let r=t.headers.get("retry-after");if(r){let o=Number(r);if(!Number.isNaN(o)&&o>0)return Math.min(o*1e3,1e4)}}return 300*2**e+Math.floor(Math.random()*200)}function re(e){return new Promise(t=>setTimeout(t,e))}function Me(e){return e.endsWith("/")?e.slice(0,-1):e}function Ne(e,t,n){let r=t.startsWith("/")?t:`/${t}`,o=Pe(n);return `${e}${r}${o?`?${o}`:""}`}function Pe(e){if(!e)return "";let t=[];for(let[n,r]of Object.entries(e))if(r!=null)if(Array.isArray(r)){if(r.length===0)continue;t.push(`${encodeURIComponent(n)}=${encodeURIComponent(r.join(","))}`);}else t.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(r))}`);return t.join("&")}var b="/api/public",N=class{constructor(t){this.cfg=oe(t);}createLead(t,n){return g(this.cfg,{method:"POST",path:`${b}/leads`,body:t,options:n})}createLeadsBulk(t,n){return g(this.cfg,{method:"POST",path:`${b}/leads`,body:t,options:n})}updateLead(t,n,r){return g(this.cfg,{method:"PUT",path:`${b}/leads/${encodeURIComponent(t)}`,body:n,options:r})}getLead(t,n){return g(this.cfg,{method:"GET",path:`${b}/leads/${encodeURIComponent(t)}`,options:n})}getLeadHistory(t,n={},r){let o=Array.isArray(n.channel)?n.channel:n.channel?[n.channel]:void 0;return g(this.cfg,{method:"GET",path:`${b}/leads/${encodeURIComponent(t)}/history`,query:{channel:o,limit:n.limit,offset:n.offset},options:r})}isLeadPaused(t,n={},r){return g(this.cfg,{method:"GET",path:`${b}/leads/${encodeURIComponent(t)}/is_paused`,query:{workflow_id:n.workflow_id},options:r})}stopAutomation(t,n,r){return g(this.cfg,{method:"POST",path:`${b}/leads/${encodeURIComponent(t)}/automation/stop`,body:n,options:r})}resumeAutomation(t,n,r){return g(this.cfg,{method:"POST",path:`${b}/leads/${encodeURIComponent(t)}/automation/resume`,body:n,options:r})}syncLeadTags(t,n){return g(this.cfg,{method:"POST",path:`${b}/leads/tags`,body:t,options:n})}listLeadMeetings(t,n={},r){let o=Array.isArray(n.status)?n.status.join(","):n.status;return g(this.cfg,{method:"GET",path:`${b}/leads/${encodeURIComponent(t)}/meetings`,query:{status:o},options:r})}listWorkflows(t){return g(this.cfg,{method:"GET",path:`${b}/workflows`,options:t})}listCampaigns(t){return g(this.cfg,{method:"GET",path:`${b}/campaigns`,options:t})}listTemplates(t={},n){return g(this.cfg,{method:"GET",path:`${b}/templates`,query:{status:t.status,category:t.category},options:n})}sendMessage(t,n){return g(this.cfg,{method:"POST",path:`${b}/messages`,body:t,options:n})}createMeeting(t,n){return g(this.cfg,{method:"POST",path:`${b}/meetings`,body:t,options:n})}createMeetingNotes(t,n){return g(this.cfg,{method:"POST",path:`${b}/meeting-notes`,body:t,options:n})}chat(t,n){return g(this.cfg,{method:"POST",path:`${b}/chat`,body:t,options:n})}};function se(e){var t,n,r,o,c,l,i,a,y,f,C,I,R,d,v,h,L,k,u;return {workflowId:e.workflowId,title:(t=e.title)!=null?t:"Chat with us",subtitle:(n=e.subtitle)!=null?n:"We typically reply in a few minutes",greeting:(r=e.greeting)!=null?r:"Hi there! \u{1F44B} How can we help?",errorText:(o=e.errorText)!=null?o:"Sorry, something went wrong. Please try again in a moment.",locale:(c=e.locale)!=null?c:typeof navigator!="undefined"?navigator.language:void 0,accentColor:(l=e.accentColor)!=null?l:"#111827",accentTextColor:(i=e.accentTextColor)!=null?i:"#ffffff",showBranding:(a=e.showBranding)!=null?a:true,position:(y=e.position)!=null?y:"bottom-right",openOnLoad:(f=e.openOnLoad)!=null?f:false,debounceMs:(C=e.debounceMs)!=null?C:700,container:e.container,systemPrompt:e.systemPrompt,clientPrompt:e.clientPrompt,lead:e.lead,capture:{fields:(R=(I=e.capture)==null?void 0:I.fields)!=null?R:["first_name","email"],mode:(v=(d=e.capture)==null?void 0:d.mode)!=null?v:"before",label:(L=(h=e.capture)==null?void 0:h.label)!=null?L:"Tell us a bit about you to get started:",submitLabel:(u=(k=e.capture)==null?void 0:k.submitLabel)!=null?u:"Start chat"},metadata:e.metadata,onOpen:e.onOpen,onClose:e.onClose,onMessage:e.onMessage,onLeadCaptured:e.onLeadCaptured,onError:e.onError}}function F(e){if(e.capture.mode==="skip")return false;if(e.lead){let t=e.lead;return e.capture.fields.some(n=>!t[n])}return true}var ie="nexor.chat.session_id";function ae(){let e=Date.now();try{let n=le();if(n&&e-n.ts<2592e6)return j(n.id,e),n.id}catch(n){}let t=`sess_${Se(16)}`;try{j(t,e);}catch(n){}return t}function de(){try{let e=le();e&&j(e.id,Date.now());}catch(e){}}function le(){let e=window.localStorage.getItem(ie);if(!e)return null;try{let t=JSON.parse(e);if(t&&typeof t.id=="string"&&typeof t.ts=="number")return t}catch(t){}return e.startsWith("sess_")?{id:e,ts:Date.now()}:null}function j(e,t){window.localStorage.setItem(ie,JSON.stringify({id:e,ts:t}));}function Se(e){let t=new Uint8Array(e);if(typeof crypto!="undefined"&&crypto.getRandomValues)crypto.getRandomValues(t);else for(let n=0;n<e;n++)t[n]=Math.floor(Math.random()*256);return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}var ce=(e,t)=>`
|
|
2
2
|
.nexor-chat,
|
|
3
3
|
.nexor-chat * {
|
|
4
4
|
box-sizing: border-box;
|
|
@@ -405,7 +405,7 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
405
405
|
<path d="M4 5.5C4 4.67 4.67 4 5.5 4h13c.83 0 1.5.67 1.5 1.5v9c0 .83-.67 1.5-1.5 1.5H9l-4 4V5.5Z"
|
|
406
406
|
stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/>
|
|
407
407
|
</svg>
|
|
408
|
-
`;let t=document.createElement("span");return t.className="nexor-chat__unread",t.style.display="none",e.appendChild(t),{el:e,badge:t}}function he(e){let t=document.createElement("div");t.className="nexor-chat__panel",t.setAttribute("role","dialog"),t.setAttribute("aria-label",e.title);let{header:n,closeBtn:r}=Oe(e),{body:o,captureForm:c,captureInputs:
|
|
408
|
+
`;let t=document.createElement("span");return t.className="nexor-chat__unread",t.style.display="none",e.appendChild(t),{el:e,badge:t}}function he(e){let t=document.createElement("div");t.className="nexor-chat__panel",t.setAttribute("role","dialog"),t.setAttribute("aria-label",e.title);let{header:n,closeBtn:r}=Oe(e),{body:o,captureForm:c,captureInputs:l}=He(e),{form:i,input:a,send:y}=Ue(),f=e.showBranding?$e():null;return t.appendChild(n),t.appendChild(o),t.appendChild(i),f&&t.appendChild(f),{el:t,closeBtn:r,body:o,form:i,input:a,send:y,captureForm:c,captureInputs:l}}function Oe(e){let t=document.createElement("div");t.className="nexor-chat__header";let n=e.subtitle?`<p class="nexor-chat__subtitle">
|
|
409
409
|
<span class="nexor-chat__status-dot" aria-hidden="true"></span>${pe(e.subtitle)}
|
|
410
410
|
</p>`:"";t.innerHTML=`
|
|
411
411
|
<div>
|
|
@@ -416,11 +416,11 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
416
416
|
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
417
417
|
<path d="M6 6l12 12M6 18L18 6" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
418
418
|
</svg>
|
|
419
|
-
`,t.appendChild(r),{header:t,closeBtn:r}}function He(e){let t=document.createElement("div");t.className="nexor-chat__body";let n={},r=null;return F(e)&&(r=Ae(e,n),t.appendChild(r)),{body:t,captureForm:r,captureInputs:n}}function Ae(e,t){var
|
|
419
|
+
`,t.appendChild(r),{header:t,closeBtn:r}}function He(e){let t=document.createElement("div");t.className="nexor-chat__body";let n={},r=null;return F(e)&&(r=Ae(e,n),t.appendChild(r)),{body:t,captureForm:r,captureInputs:n}}function Ae(e,t){var l,i,a,y;let n=document.createElement("form");n.className="nexor-chat__capture",n.noValidate=true;let r=document.createElement("p");r.className="nexor-chat__capture-label",r.textContent=e.capture.label,n.appendChild(r);let o=e.capture.fields;if(o.includes("first_name")||o.includes("last_name")){let f=document.createElement("div");f.className="nexor-chat__capture-row",o.includes("first_name")&&(t.first_name=z("first_name","First name","text",(l=e.lead)==null?void 0:l.first_name),f.appendChild(t.first_name)),o.includes("last_name")&&(t.last_name=z("last_name","Last name","text",(i=e.lead)==null?void 0:i.last_name),f.appendChild(t.last_name)),f.childElementCount>0&&n.appendChild(f);}o.includes("email")&&(t.email=z("email","Email","email",(a=e.lead)==null?void 0:a.email),n.appendChild(t.email)),o.includes("phone")&&(t.phone=z("phone","Phone","tel",(y=e.lead)==null?void 0:y.phone),n.appendChild(t.phone));let c=document.createElement("button");return c.type="submit",c.className="nexor-chat__capture-submit",c.textContent=e.capture.submitLabel,n.appendChild(c),n}function Ue(){let e=document.createElement("form");e.className="nexor-chat__composer";let t=document.createElement("input");t.type="text",t.className="nexor-chat__input",t.placeholder="Type a message\u2026",t.autocomplete="off";let n=document.createElement("button");return n.type="submit",n.className="nexor-chat__send",n.setAttribute("aria-label","Send message"),n.innerHTML=`
|
|
420
420
|
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
421
421
|
<path d="M3.4 11.2 20.5 4.3c.7-.3 1.4.4 1.1 1.1l-6.9 17.1c-.3.8-1.4.8-1.8 0L10 14l-7.5-3c-.8-.3-.8-1.5 0-1.8Z"
|
|
422
422
|
stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" fill="currentColor"/>
|
|
423
423
|
</svg>
|
|
424
|
-
`,e.appendChild(t),e.appendChild(n),{form:e,input:t,send:n}}function $e(){let e=document.createElement("div");return e.className="nexor-chat__footer",e.innerHTML='Powered by <a href="https://www.getnexor.ai" target="_blank" rel="noopener noreferrer">Nexor</a>',e}function ge(e,t,n,r){let o=document.createElement("div");o.className=`nexor-chat__msg nexor-chat__msg--${e}`;let c=document.createElement("span");if(c.className="nexor-chat__msg-text",c.textContent=t,o.appendChild(c),e!=="system"&&n){let
|
|
425
|
-
`);
|
|
424
|
+
`,e.appendChild(t),e.appendChild(n),{form:e,input:t,send:n}}function $e(){let e=document.createElement("div");return e.className="nexor-chat__footer",e.innerHTML='Powered by <a href="https://www.getnexor.ai" target="_blank" rel="noopener noreferrer">Nexor</a>',e}function ge(e,t,n,r){let o=document.createElement("div");o.className=`nexor-chat__msg nexor-chat__msg--${e}`;let c=document.createElement("span");if(c.className="nexor-chat__msg-text",c.textContent=t,o.appendChild(c),e!=="system"&&n){let l=document.createElement("time");l.className="nexor-chat__msg-time",l.dataset.ts=String(n),l.textContent=G(n,r),o.appendChild(l);}return o}function G(e,t,n=Date.now()){try{let r=Math.max(0,n-e),o=Math.round(r/6e4),c=Math.round(r/36e5),l=Math.round(r/864e5),i=new Intl.RelativeTimeFormat(t,{numeric:"auto"});return r<45e3?i.format(0,"second"):o<60?i.format(-o,"minute"):c<24?i.format(-c,"hour"):l<7?i.format(-l,"day"):new Date(e).toLocaleDateString(t,{day:"numeric",month:"short"})}catch(r){try{return new Date(e).toLocaleTimeString(t,{hour:"2-digit",minute:"2-digit"})}catch(o){return ""}}}function xe(){let e=document.createElement("div");return e.className="nexor-chat__typing",e.innerHTML="<span></span><span></span><span></span>",e}function z(e,t,n,r){let o=document.createElement("input");return o.name=e,o.type=n,o.placeholder=t,r&&(o.value=r),o}function pe(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var qe=220;function be(e,t){var X,Z,Q;if(Be(),!t||!t.workflowId)throw new Error("Nexor SDK: initChat() requires `workflowId`.");let n=se(t);me(n.accentColor,n.accentTextColor);let r=ae(),o=`nexor.chat.history.${r}`,c=Fe(n),l=fe(),i=he(n);c.appendChild(l.el),c.appendChild(i.el),((X=n.container)!=null?X:document.body).appendChild(c);let a={isOpen:false,unread:0,leadId:void 0,captured:!F(n),pendingLead:{...(Z=n.lead)!=null?Z:{}},history:[]};l.el.addEventListener("click",I),i.closeBtn.addEventListener("click",C),i.form.addEventListener("submit",v),(Q=i.captureForm)==null||Q.addEventListener("submit",R),V();let y=K();if(y.length){a.history=y;for(let s of y)E(s.role==="user"?"user":"bot",s.text,s.ts);J();}n.openOnLoad&&f();function f(){var s;a.isOpen||(a.isOpen=true,c.setAttribute("data-open","true"),_e(),a.history.length===0&&n.greeting&&a.captured&&T(n.greeting),i.input.focus(),(s=n.onOpen)==null||s.call(n));}function C(){var s;a.isOpen&&(a.isOpen=false,c.setAttribute("data-open","false"),(s=n.onClose)==null||s.call(n));}function I(){a.isOpen?C():f();}function R(s){var $,D;s.preventDefault();let p=ze(i),_=n.capture.fields;for(let q of _)if(!p[q]){($=i.captureInputs[q])==null||$.focus();return}a.pendingLead={...a.pendingLead,...p},a.captured=true,(D=i.captureForm)==null||D.remove(),V(),i.input.focus(),n.greeting&&a.history.length===0&&T(n.greeting);}let d={pending:[],timer:0,typingTimer:0,inFlight:false,typing:null};function v(s){s.preventDefault();let p=i.input.value.trim();p&&(i.input.value="",h(p));}function h(s){var p;if(!a.captured){(p=i.captureInputs.first_name)==null||p.focus();return}u(s),d.pending.push(s),L();}function L(){d.timer&&window.clearTimeout(d.timer),d.timer=window.setTimeout(()=>{k();},n.debounceMs);}async function k(){var _,$,D,q,ee;if(d.inFlight||d.pending.length===0)return;let p=d.pending.splice(0,d.pending.length).join(`
|
|
425
|
+
`);d.inFlight=true,d.typingTimer=window.setTimeout(()=>{d.typing=W(xe());},qe);try{let B=await e.chat({workflow_id:n.workflowId,session_id:r,message:p,system_prompt:n.systemPrompt,client_prompt:n.clientPrompt,lead:Object.keys(a.pendingLead).length?a.pendingLead:void 0,metadata:n.metadata});B.lead_id&&!a.leadId&&(a.leadId=B.lead_id,(_=n.onLeadCaptured)==null||_.call(n,a.leadId));let te=(($=B.reply)!=null?$:"").trim();te?T(te):(U(n.errorText),(D=n.onError)==null||D.call(n,new Error("Nexor SDK: empty reply from server")));}catch(B){U(n.errorText),(q=n.onError)==null||q.call(n,B);}finally{window.clearTimeout(d.typingTimer),(ee=d.typing)==null||ee.remove(),d.typing=null,d.inFlight=false,i.input.focus(),d.pending.length&&L();}}function u(s){var _;let p=Date.now();E("user",s,p),a.history.push({role:"user",text:s,ts:p}),A(),(_=n.onMessage)==null||_.call(n,{role:"user",text:s});}function T(s){var _;let p=Date.now();E("bot",s,p),a.history.push({role:"bot",text:s,ts:p}),A(),a.isOpen||ye(),(_=n.onMessage)==null||_.call(n,{role:"bot",text:s});}function A(){try{window.localStorage.setItem(o,JSON.stringify({ts:Date.now(),history:a.history})),de();}catch(s){}}function K(){try{let s=window.localStorage.getItem(o);if(!s)return [];let p=JSON.parse(s);return !p||!Array.isArray(p.history)?[]:Date.now()-(p.ts||0)>2592e6?(window.localStorage.removeItem(o),[]):p.history}catch(s){return []}}function U(s){E("system",s);}function E(s,p,_){return W(ge(s,p,_,n.locale))}let Y=window.setInterval(()=>{i.body.querySelectorAll(".nexor-chat__msg-time[data-ts]").forEach(s=>{let p=Number(s.dataset.ts);p&&(s.textContent=G(p,n.locale));});},6e4);function W(s){return i.body.appendChild(s),d.typing&&d.typing!==s&&i.body.appendChild(d.typing),J(),s}function J(){i.body.scrollTop=i.body.scrollHeight;}function ye(){a.unread++,l.badge.textContent=String(a.unread),l.badge.style.display="flex";}function _e(){a.unread=0,l.badge.style.display="none";}function V(){let s=!a.captured;i.input.disabled=s,i.send.disabled=s,i.input.placeholder=s?"Complete the form above to start\u2026":"Type a message\u2026";}return {open:f,close:C,toggle:I,send:s=>(h(s),Promise.resolve()),destroy:()=>{d.timer&&window.clearTimeout(d.timer),d.typingTimer&&window.clearTimeout(d.typingTimer),window.clearInterval(Y),c.remove();},getSessionId:()=>r}}function Be(){if(typeof window=="undefined"||typeof document=="undefined")throw new Error("Nexor SDK: initChat() requires a browser environment.")}function Fe(e){let t=document.createElement("div");return t.className="nexor-chat",t.setAttribute("data-position",e.position),t.setAttribute("data-open","false"),t}function ze(e){let t={},n=e.captureInputs;return n.first_name&&(t.first_name=n.first_name.value.trim()),n.last_name&&(t.last_name=n.last_name.value.trim()),n.email&&(t.email=n.email.value.trim()),n.phone&&(t.phone=n.phone.value.trim()),t}function Ke(e){return new N(e)}var H=null;function x(){if(!H)throw new Error("Nexor SDK: call `nexor.init({ apiKey })` before using the API.");return H}function je(e){return H=new N(e),H}function Ge(){return H!==null}function Ye(){H=null;}var m={init:je,isInitialized:Ge,reset:Ye,createLead:((...e)=>x().createLead(...e)),createLeadsBulk:((...e)=>x().createLeadsBulk(...e)),updateLead:((...e)=>x().updateLead(...e)),getLead:((...e)=>x().getLead(...e)),getLeadHistory:((...e)=>x().getLeadHistory(...e)),isLeadPaused:((...e)=>x().isLeadPaused(...e)),stopAutomation:((...e)=>x().stopAutomation(...e)),resumeAutomation:((...e)=>x().resumeAutomation(...e)),syncLeadTags:((...e)=>x().syncLeadTags(...e)),listLeadMeetings:((...e)=>x().listLeadMeetings(...e)),listWorkflows:((...e)=>x().listWorkflows(...e)),listCampaigns:((...e)=>x().listCampaigns(...e)),listTemplates:((...e)=>x().listTemplates(...e)),sendMessage:((...e)=>x().sendMessage(...e)),createMeeting:((...e)=>x().createMeeting(...e)),createMeetingNotes:((...e)=>x().createMeetingNotes(...e)),initChat:e=>be(x(),e)};var gt=m.init,xt=m.isInitialized,bt=m.reset,yt=m.initChat,_t=m.createLead,wt=m.createLeadsBulk,Ct=m.updateLead,vt=m.getLead,Lt=m.getLeadHistory,Tt=m.isLeadPaused,It=m.stopAutomation,Et=m.resumeAutomation,Rt=m.syncLeadTags,kt=m.listLeadMeetings,Mt=m.listWorkflows,Nt=m.listCampaigns,Pt=m.listTemplates,St=m.sendMessage,Ot=m.createMeeting,Ht=m.createMeetingNotes;exports.NexorAPIError=w;exports.NexorAuthError=S;exports.NexorClient=N;exports.NexorError=P;exports.NexorNetworkError=M;exports.NexorValidationError=O;exports.createClient=Ke;exports.createLead=_t;exports.createLeadsBulk=wt;exports.createMeeting=Ot;exports.createMeetingNotes=Ht;exports.getLead=vt;exports.getLeadHistory=Lt;exports.init=gt;exports.initChat=yt;exports.isInitialized=xt;exports.isLeadPaused=Tt;exports.listCampaigns=Nt;exports.listLeadMeetings=kt;exports.listTemplates=Pt;exports.listWorkflows=Mt;exports.reset=bt;exports.resumeAutomation=Et;exports.sendMessage=St;exports.stopAutomation=It;exports.syncLeadTags=Rt;exports.updateLead=Ct;return exports;})({});//# sourceMappingURL=nexor.iife.js.map
|
|
426
426
|
//# sourceMappingURL=nexor.iife.js.map
|