@livechat/customer-sdk 2.0.4 → 3.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/README.md +227 -121
- package/dist/customer-sdk.cjs.js +457 -277
- package/dist/customer-sdk.cjs.native.js +459 -279
- package/dist/customer-sdk.esm.js +427 -259
- package/dist/customer-sdk.js +760 -6442
- package/dist/customer-sdk.min.js +1 -1
- package/package.json +31 -26
package/dist/customer-sdk.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.CustomerSDK={})}(this,function(e){"use strict";function S(){return(S=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function m(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])<0&&(o[n]=e[n]);return o}function n(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"==typeof t?t:t+""}var r="__test_storage_support__",o="@@test",t=function(){var n=Object.create(null);return{getItem:function(e){var t=n[e];return"string"==typeof t?t:null},setItem:function(e,t){n[e]=t},removeItem:function(e){delete n[e]},clear:function(){n=Object.create(null)}}}(),i=function(e){void 0===e&&(e="local");try{var t="session"===e?window.sessionStorage:window.localStorage;return t.setItem(r,o),t.getItem(r)===o&&(t.removeItem(r),!0)}catch(e){return!1}}()?window.localStorage:t,c=function(t,n){return new Promise(function(e){return e(i.setItem(t,n))})},u=function(t){return new Promise(function(e){return e(i.getItem(t))})},l=function(t){return new Promise(function(e){return e(i.removeItem(t))})},a={}.hasOwnProperty;function s(e,t){return a.call(t,e)}var d=Array.isArray;function T(n,r){return Object.keys(r).reduce(function(e,t){return e[t]=n(r[t]),e},{})}function E(e){return e}function I(){return Math.random().toString(36).substring(2)}function p(e){var t=I();return s(t,e)?p(e):t}function x(){}function O(t,e){var n,r="function"==typeof t?t:function(e){return function(e,t){for(var n="string"==typeof e?e.split("."):e,r=0,o=t;o&&r<n.length;)o=o[n[r++]];return o}(t,e)};return(d(e)?[].concat(e):(n=e,Object.keys(n).map(function(e){return n[e]}))).sort(function(e,t){return r(e)-r(t)})}function y(e,n){return e.reduce(function(e,t){return s(t,n)&&(e[t]=n[t]),e},{})}var f=function(t){return Object.keys(t).map(function(e){return[e,t[e]]})},j=function(e,t){return e===t?0:e<t?-1:1};var k=function(e){return f(e).map(function(e){return e.map(encodeURIComponent).join("=")}).join("&")},h=/[^:]+:\/\/[^(/|?)\s]+/,v=function(e){return e.replace(/\w/g,"$&[\\r\\n\\t]*")},g=(RegExp("^[\0-]*("+v("javascript")+"|"+v("data")+"):","i"),"https://accounts.livechatinc.com"),_="@livechat/customer-auth",b="https://accounts.livechatinc.com",w=function(e,t,n){var r,o,i;return""+("production"===n?b:b.replace("accounts.","accounts."+n+"."))+(((r=e).uniqueGroups?"/licence/g"+r.licenseId+"_"+r.groupId:"")+"/customer")+"?"+k({license_id:(o=e).licenseId+"",flow:"button",response_type:"token",client_id:o.clientId,redirect_uri:i=t,post_message_uri:i,state:_})},C=function(e){var t=e.code,n=Error(e.message);return n.code=t,n},N=function(e,t){var n,r,o=document.createElement("iframe");return o.style.display="none",o.setAttribute("src",w(e,(n=window.location+"",((r=n.match(h))&&r[0])+window.location.pathname),t)),o},P=function(e,t){var n,c=e.licenseId,u="production"===(n=t)?g:g.replace("accounts.","accounts."+n+".");return new Promise(function(r,o){var n=N(e,t),i=function(){var e,t;(t=(e=n).parentNode)&&t.removeChild(e),window.removeEventListener("message",s,!1)},a=setTimeout(function(){i(),o(C({message:"Request timed out.",code:"REQUEST_TIMEOUT"}))},15e3),s=function(e){var t=e.data;if(e.origin===u&&(n=t)&&n.state===_){var n;clearTimeout(a),i();try{r(function(e,t){if("identity_exception"in e)throw C({code:"SSO_IDENTITY_EXCEPTION",message:e.identity_exception});if("oauth_exception"in e)throw C({code:"SSO_OAUTH_EXCEPTION",message:e.oauth_exception});return{accessToken:e.access_token,entityId:e.entity_id,expiresIn:1e3*e.expires_in,tokenType:e.token_type,creationDate:Date.now(),licenseId:t}}(t,c))}catch(e){o(e)}}};window.addEventListener("message",s,!1),new Promise(function(t){!function e(){document.body?t(document.body):setTimeout(e,100)}()}).then(function(e){e.appendChild(n)})})},A=function(e){if("number"!=typeof e.licenseId||"string"!=typeof e.clientId)throw Error("You need to pass valid configuration object: { licenseId, clientId }.")},q=function(e,t){A(e);var n="@@lc_auth_token:"+e.licenseId+(e.uniqueGroups?":"+e.groupId:""),o=null,i=null,a=u(n).then(function(e){null!==a&&(a=null,e&&(i=JSON.parse(e)))}),s=function(){return o=P(e,t).then(function(e){return o=null,c(n,JSON.stringify(e)),i=e},function(e){throw o=null,e})};return{getFreshToken:s,getToken:function e(){return o||(i&&(n=(t=i).creationDate,r=t.expiresIn,Date.now()<n+r)?Promise.resolve(i):a?a.then(e):s());var t,n,r},hasToken:function e(){return a?a.then(e):Promise.resolve(!!i)},invalidate:function(){return a=i=null,l(n)}}};var L,M=function(r){return r=r||Object.create(null),{on:function(e,t){(r[e]||(r[e]=[])).push(t)},off:function(e,t){r[e]&&r[e].splice(r[e].indexOf(t)>>>0,1)},emit:function(t,n){(r[t]||[]).slice().map(function(e){e(n)}),(r["*"]||[]).slice().map(function(e){e(t,n)})}}},R=function(){var n=Object.create(null),i=M(n);return S({},i,{off:function(e,t){e?i.off(e,t):Object.keys(n).forEach(function(e){delete n[e]})},once:function(r,o){i.on(r,function e(t,n){i.off(r,e),o(t,n)})}})},U="change_region",D="check_goals",F="destroy",H="fail_all_requests",J="login_success",W="pause_connection",G="prefetch_token",B="push_received",z="push_response_received",X="reconnect",Y="request_failed",Z="response_received",$="send_request",K="set_chat_active",Q="set_self_id",V="socket_connected",ee="socket_disconnected",te="socket_recovered",ne="socket_unstable",re="start_connection",oe="update_customer_page",ie="CONNECTION_LOST",ae="IDENTITY_MISMATCH",se="MISDIRECTED_CONNECTION",ce="MISSING_CHAT_THREAD",ue="accept_greeting",le="activate_chat",de="cancel_greeting",pe="deactivate_chat",fe="delete_chat_properties",he="delete_event_properties",ve="delete_thread_properties",me="get_chat",ye="get_customer",ge="get_form",_e="get_predicted_agent",be="get_url_info",we="list_chats",Ee="list_group_statuses",Ie="list_threads",Te="mark_events_as_seen",xe="send_event",Oe="send_rich_message_postback",Se="send_sneak_peek",je="set_customer_session_fields",ke="start_chat",Ce="update_chat_properties",Ne="update_customer",Pe="update_customer_page",Ae="update_event_properties",qe="update_thread_properties";L="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")();var Le,Me,Re=("function"==typeof(Me=L.Symbol)?Me.observable?Le=Me.observable:(Le=Me("observable"),Me.observable=Le):Le="@@observable",Le),Ue=function(){return Math.random().toString(36).substring(7).split("").join(".")},De={INIT:"@@redux/INIT"+Ue(),REPLACE:"@@redux/REPLACE"+Ue(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+Ue()}};function Fe(e,t,n){var r;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw Error("Expected the enhancer to be a function.");return n(Fe)(e,t)}if("function"!=typeof e)throw Error("Expected the reducer to be a function.");var o=e,i=t,a=[],s=a,c=!1;function u(){s===a&&(s=a.slice())}function l(){if(c)throw Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function d(t){if("function"!=typeof t)throw Error("Expected the listener to be a function.");if(c)throw Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");var n=!0;return u(),s.push(t),function(){if(n){if(c)throw Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");n=!1,u();var e=s.indexOf(t);s.splice(e,1)}}}function p(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(c)throw Error("Reducers may not dispatch actions.");try{c=!0,i=o(i,e)}finally{c=!1}for(var t=a=s,n=0;n<t.length;n++){(0,t[n])()}return e}return p({type:De.INIT}),(r={dispatch:p,subscribe:d,getState:l,replaceReducer:function(e){if("function"!=typeof e)throw Error("Expected the nextReducer to be a function.");o=e,p({type:De.REPLACE})}})[Re]=function(){var e,n=d;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function t(){e.next&&e.next(l())}return t(),{unsubscribe:n(t)}}})[Re]=function(){return this},e},r}function He(t,e){var n=Object.keys(t);return Object.getOwnPropertySymbols&&n.push.apply(n,Object.getOwnPropertySymbols(t)),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n}function Je(){for(var e=arguments.length,i=Array(e),t=0;t<e;t++)i[t]=arguments[t];return function(o){return function(){var e=o.apply(void 0,arguments),t=function(){throw Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},n={getState:e.getState,dispatch:function(){return t.apply(void 0,arguments)}},r=i.map(function(e){return e(n)});return function(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?He(i,!0).forEach(function(e){var t,n,r;r=i[n=e],n in(t=o)?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):He(i).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}({},e,{dispatch:t=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce(function(e,t){return function(){return e(t.apply(void 0,arguments))}})}.apply(void 0,r)(e.dispatch)})}}}function We(){var n={};return n.promise=new Promise(function(e,t){n.resolve=e,n.reject=t}),n}var Ge="connected",Be="destroyed",ze="disconnected",Xe="customer",Ye=function(e){return e.connection.status},Ze=function(e,t){return e.requests[t]},$e=function(e){return e.users.self.id},Ke=function(e,t){var n=e.chats[t];return!!n&&n.active},Qe=function(e){return Ye(e)===Ge},Ve=function(e){var t,n,r=e.region;return"https://api"+(r?"-"+r:"")+(n=(t=e).env,1520===t.licenseId?".staging":"production"===n?"":"."+n)+".livechatinc.com"},et=function(e){return Ve(e)+"/v3.2/customer"},tt=function(e,t){return S({},e,{requests:m(e.requests,[t.id].map(n))})},nt=function(e,t){return S({},t,{connection:S({},t.connection,{status:e})})},rt=function(e){var t,n,r;return n=e,(t={})[U]=function(e,t){return S({},e,{region:t.region})},t[F]=function(e){return nt(Be,e)},t[J]=function(e){return nt(Ge,e)},t[W]=function(e){return nt("paused",e)},t[Y]=tt,t[Z]=tt,t[$]=function(e,t){var n,r=t.id;return S({},e,{requests:S({},e.requests,(n={},n[r]={id:r,promise:t.promise,resolve:t.resolve,reject:t.reject,request:t.request},n))})},t[K]=function(e,t){var n,r=t.id;return S({},e,{chats:S({},e.chats,(n={},n[r]=S({},e.chats[r],{active:t.active}),n))})},t[Q]=function(e,t){return S({},e,{users:S({},e.users,{self:S({},e.users.self,{id:t.id})})})},t[ee]=function(e){var t=Ye(e);return S({},nt(t===ze?ze:"reconnecting",e),{requests:{}})},t[oe]=function(e,t){return S({},e,{page:S({},e.page,t)})},(r=t)[void 0]&&console.warn("Reducer contains an 'undefined' action type.\nHave you misspelled a constant?"),function(e,t){return void 0===e&&(e=n),s(t.type,r)?r[t.type](e,t.payload):e}};function ot(e){var o,t,n,r,i,a,s,c,u,l,d,p,f,h,v,m,y,g,_=E,b=(o=[],(t=function(r){return function(n){return function(t){var e=n(t);return o.forEach(function(e){e(t,r)}),e}}}).add=function(e){o.push(e)},t),w=Fe(rt((i=(n=e).licenseId,s=void 0===(a=n.groupId)?null:a,c=n.env,l=void 0===(u=n.page)?null:u,p=void 0===(d=n.region)?null:d,h=void 0===(f=n.referrer)?null:f,m=void 0!==(v=n.uniqueGroups)&&v,g=void 0!==(y=n.mobile)&&y,{application:S({},void 0===(r=n.application)?{}:r,{name:"customer_sdk",version:"2.0.4"}),licenseId:i,env:c,groupId:s,chats:{},connection:{status:ze},page:l,region:p,referrer:h,requests:{},users:{self:{id:null,type:Xe},others:{}},uniqueGroups:m,mobile:g})),_(Je(b)));return w.addSideEffectsHandler=b.add,w}function it(e){var t=e.code,n=Error(e.message);return n.code=t,n}var at="chat_deactivated",st="customer_disconnected",ct="customer_side_storage_updated",ut="incoming_chat",lt="incoming_event",dt="incoming_multicast",pt="incoming_typing_indicator",ft="queue_position_updated",ht="thread_properties_updated",vt="user_added_to_chat",mt="user_removed_from_chat",yt="file",gt="filled_form",_t="message",bt="rich_message",wt="system_message",Et=function(e){var t,n={};return"string"==typeof e.customId&&(n.custom_id=e.customId),"object"!=typeof(t=e.properties)||null===t||d(t)||(n.properties=e.properties),n},It=function(e){switch(e.type){case _t:var t=S({},Et(e),{type:e.type,text:e.text});return e.postback&&(t.postback={id:e.postback.id,thread_id:e.postback.threadId,event_id:e.postback.eventId,type:e.postback.type,value:e.postback.value}),t;case yt:return S({},Et(e),{type:e.type,url:e.url});case gt:return S({},Et(e),{type:e.type,form_id:e.formId,fields:e.fields.map(function(e){switch(e.type){case"group_chooser":if(!e.answer)return e;var t=e.answer,n=t.groupId;return S({},e,{answer:S({},m(t,["groupId"]),{group_id:n})});default:return e}})});case wt:var n=S({},Et(e),{type:e.type,text:e.text,system_message_type:e.systemMessageType});return e.recipients&&(n.recipients=e.recipients),n}},Tt=function(e){var t=e.chat,n=e.continuous,r={chat:{}};if("boolean"==typeof n&&(r.continuous=n),!t)return r;var o,i,a,s,c=t.access,u=t.thread,l=t.properties;return c&&c.groupIds&&(r.chat.access={group_ids:c.groupIds}),l&&(r.chat.properties=l),u&&(r.chat.thread=(i={},s=(o=u).properties,(a=o.events)&&(i.events=a.map(It)),s&&(i.properties=s),i)),r},xt=function(e){return f(e).map(function(e){var t;return(t={})[e[0]]=e[1],t})},Ot=function(e){var t=y(["avatar","name","email"],e);return e.sessionFields&&(t.session_fields=xt(e.sessionFields)),t},St=function(e){return{type:F,payload:{reason:e}}},jt=function(e){return void 0===e&&(e=!1),{type:G,payload:{fresh:e}}},kt=function(e){return{type:X,payload:{delay:e}}},Ct=function(e,t,n){return{type:$,payload:S({request:{action:e,payload:t}},n&&{source:n})}},Nt=function(e,t){return{type:K,payload:{id:e,active:t}}},Pt=function(e){return{type:Q,payload:{id:e}}},At=function(e,t){t.payload.id=p(e.getState().requests);var n=We(),r=n.resolve,o=n.reject,i=n.promise;return t.payload.promise=i,t.payload.resolve=r,t.payload.reject=o,e.dispatch(t),i},qt=Lt;function Lt(e){this.ms=(e=e||{}).min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=0<e.jitter&&e.jitter<=1?e.jitter:0,this.attempts=0}Lt.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},Lt.prototype.reset=function(){this.attempts=0},Lt.prototype.setMin=function(e){this.ms=e},Lt.prototype.setMax=function(e){this.max=e},Lt.prototype.setJitter=function(e){this.jitter=e};var Mt=function(e){var t=e.getState();return"side_storage_"+t.licenseId+(t.uniqueGroups?":"+t.groupId:"")},Rt=function(e,o,i){var a=e.slice(0),s=!1;return function t(e){var n,r=a.shift();(n=function(){return r(e)},new Promise(function(e){e(n())})).then(function(e){s||(a.length?t(e):o(e))},function(e){s||i(e)})}(),{cancel:function(){s=!0}}},Ut=function(e,t,n){return At(e,Ct(t,n,"login"))};function Dt(t,f){var h,n,v=null,r=new qt({min:300,max:6e4,jitter:.3}),o=function(e){return h.dispatch(St(e))},i=function(){return h.dispatch(kt(r.duration()))},a=function(){return Promise.all([t.getToken(),(e=h,u(Mt(e)).catch(x).then(function(e){return JSON.parse(e||"{}")}).catch(function(){return{}}))]);var e},s=function(e){var t=e[0],n=e[1],r=$e(h.getState());if(null===r)h.dispatch(Pt(t.entityId));else if(r!==t.entityId){var o=Error("Identity has changed.");throw o.code=ae,o}return[t,n]},c=function(e){var t,n,r,o=e[0],i=e[1],a=h.getState(),s=a.application,c=a.groupId,u=a.page,l=a.referrer,d=a.mobile,p={token:o.tokenType+" "+o.accessToken,customer:"function"==typeof f?Ot(f()):{},customer_side_storage:i,is_mobile:d,application:(t=["name","version"],n=s,t.reduce(function(e,t){return e[t]=n[t],e},{}))};return"number"==typeof c&&(p.group_id=c),s.channelType&&(p.application.channel_type=s.channelType),null!==u&&(p.customer_page=v=u),null!==l&&(p.referrer=l),Promise.race([Ut(h,"login",p),(r=15e3,new Promise(function(e){setTimeout(e,r)})).then(function(){return Promise.reject(it({message:"Request timed out.",code:"REQUEST_TIMEOUT"}))})])};return function(e){h=e,n&&n.cancel(),n=Rt([a,s,c],function(e){var t;n=null,r.reset(),t=h.getState().page,v!==t&&Ut(h,Pe,t).catch(x),v=null,h.dispatch({type:J,payload:e})},function(e){switch(e.code){case"AUTHENTICATION":return t.getFreshToken(),void i();case ie:case se:return;case"SSO_IDENTITY_EXCEPTION":case"SSO_OAUTH_EXCEPTION":return"server_error"===e.message||"temporarily_unavailable"===e.message?void i():void o(e.message);case ae:case"CUSTOMER_BANNED":case"USERS_LIMIT_REACHED":case"WRONG_PRODUCT_VERSION":return void o(e.code.toLowerCase());default:return void i()}})}}var Ft,Ht="function"==typeof fetch?fetch:function(o,i){return i=i||{},new Promise(function(e,t){var n=new XMLHttpRequest;for(var r in n.open(i.method||"get",o),i.headers)n.setRequestHeader(r,i.headers[r]);function s(){var r,o=[],i=[],a={};return n.getAllResponseHeaders().replace(/^(.*?):\s*([\s\S]*?)$/gm,function(e,t,n){o.push(t=t.toLowerCase()),i.push([t,n]),a[t]=(r=a[t])?r+","+n:n}),{ok:1==(n.status/200|0),status:n.status,statusText:n.statusText,url:n.responseURL,clone:s,text:function(){return Promise.resolve(n.responseText)},json:function(){return Promise.resolve(n.responseText).then(JSON.parse)},xml:function(){return Promise.resolve(n.responseXML)},blob:function(){return Promise.resolve(new Blob([n.response]))},headers:{keys:function(){return o},entries:function(){return i},get:function(e){return a[e.toLowerCase()]},has:function(e){return e.toLowerCase()in a}}}}n.withCredentials="include"==i.credentials,n.onload=function(){e(s())},n.onerror=t,n.send(i.body)})},Jt=function(e,t){var n=e.dispatch,r=(0,e.getState)(),o=r.requests;n({type:H,payload:{rejects:Object.keys(o).map(function(e){return o[e].reject}),reason:t}})},Wt=function(e,t,n){var r=t.payload.id;(0,e.dispatch)({type:Y,payload:{id:r,reject:(0,e.getState)().requests[r].reject,error:n}})},Gt=Object.freeze({success:!0}),Bt=function(e,t){var n={id:t.id,authorId:t.author_id,createdAt:t.created_at,threadId:e,properties:t.properties||{}};return void 0!==t.custom_id&&(n.customId=t.custom_id),n},zt=function(e,t){var n,r,o,i,a;a=t.width<t.height?(r="height",o="width",i=t.height,t.width):(r="width",o="height",i=t.width,t.height);var s=e/i;return(n={})[r]=Math.ceil(Math.min(i,e)),n[o]=Math.ceil(Math.min(s*a,a)),n},Xt=function(e,t){return void 0!==t.width&&void 0!==t.height?S({},Bt(e,n=t),{type:yt,contentType:n.content_type,url:n.url,name:n.name,width:n.width,height:n.height,thumbnails:{default:S({url:n.thumbnail_url},zt(300,n)),high:S({url:n.thumbnail2x_url},zt(600,n))}}):S({},Bt(e,t),{type:yt,contentType:t.content_type,url:t.url,name:t.name});var n},Yt=function(e,t){return S({},Bt(e,t),{type:gt,formId:t.form_id,fields:t.fields.map(function(e){switch(e.type){case"group_chooser":if(!e.answer)return e;var t=e.answer,n=t.group_id;return S({},e,{answer:S({},m(t,["group_id"]),{groupId:n})});default:return e}})})},Zt=function(e,t){return S({},Bt(e,t),{type:_t,text:t.text})},$t=function(e){var t={};if("string"==typeof e.title&&(t.title=e.title),"string"==typeof e.subtitle&&(t.subtitle=e.subtitle),e.image){var n=e.image;t.image={url:n.url,name:n.name}}return e.buttons&&(t.buttons=e.buttons.map(function(e){switch(e.type){case"message":case"phone":return{type:e.type,text:e.text,postbackId:e.postback_id,userIds:e.user_ids,value:e.value,role:e.role||"default"};case"url":var t={type:e.type,text:e.text,postbackId:e.postback_id,userIds:e.user_ids,value:e.value,role:e.role||"default"};return e.target&&(t.target=e.target),t;case"webview":var n={type:e.type,text:e.text,postbackId:e.postback_id,userIds:e.user_ids,value:e.value,role:e.role||"default"};return"string"==typeof e.webview_height&&(n.webviewHeight=e.webview_height),n;default:return{text:e.text,postbackId:e.postback_id,userIds:e.user_ids,role:e.role||"default"}}})),t},Kt=function(e,t){switch(t.template_id){case"cards":case"quick_replies":case"sticker":return S({},Bt(e,t),{type:bt,template:t.template_id,elements:t.elements.map($t)});default:return null}},Qt=function(e,t){var n=S({},Bt(e,S({},t,{author_id:"system"})),{type:wt,text:t.text,systemMessageType:t.system_message_type});return t.text_vars&&(n.textVars=t.text_vars),n},Vt=function(e,t){switch(t.type){case yt:return Xt(e,t);case gt:return Yt(e,t);case _t:return Zt(e,t);case bt:return Kt(e,t);case wt:return Qt(e,t);default:return null}},en=function(e){return{id:e.id,addon:e.addon||null,uniqueId:e.unique_id,displayedFirstTime:e.displayed_first_time,accepted:e.accepted||!1,event:Vt(null,e.event),agent:{id:e.agent.id,name:e.agent.name,avatar:e.agent.avatar,jobTitle:e.agent.job_title,isBot:e.agent.is_bot||!1}}},tn=function(e){return void 0===e&&(e={}),e.group_ids?{groupIds:e.group_ids}:{}},nn=function(e){return T(function(e){return e.events_seen_up_to?e.events_seen_up_to:null},(n="id",e.reduce(function(e,t){return e[t[n]]=t,e},{})));var n},rn=function(e,t){var n=t.properties||{};return{id:t.id,chatId:e,active:t.active,access:tn(t.access),createdAt:t.created_at,userIds:t.user_ids,events:t.events.map(function(e){return Vt(t.id,e)}).filter(Boolean),properties:n,previousThreadId:t.previous_thread_id||null,nextThreadId:t.next_thread_id||null,queue:t.queue?ln(t.queue):null}},on=function(e){return{id:e.id,access:tn(e.access),users:e.users.map(dn),properties:e.properties||{},thread:rn(e.id,e.thread),eventsSeenUpToMap:nn(e.users)}},an=function(e){var t=y(["avatar","email","name"],e);return e.session_fields&&(t.sessionFields=e.session_fields.reduce(function(e,t){var n=Object.keys(t)[0];return e[n]=t[n],e},{})),t},sn=function(e){var t=an(e);return S({id:e.id,type:Xe},t,{sessionFields:t.sessionFields||{}})},cn=function(e){var t=e.statistics;return S({},sn(e),{statistics:{chatsCount:t.chats_count,threadsCount:t.threads_count,visitsCount:t.visits_count,pageViewsCount:t.page_views_count,greetingsShownCount:t.greetings_shown_count,greetingsAcceptedCount:t.greetings_accepted_count}})},un=function(e){return{position:e.position,waitTime:e.wait_time}},ln=function(e){return S({},un(e),{queuedAt:e.queued_at})},dn=function(e){return e.type===Xe?S({},sn(n=e),{present:n.present}):{id:(t=e).id,type:"agent",name:t.name,avatar:t.avatar,jobTitle:t.job_title,present:t.present};var t,n},pn=((Ft={})[ie]="Connection lost.",Ft[se]="Connected to wrong region.",Ft),fn=function(t,e){var n=t.getState();switch(e.type){case z:case B:switch(e.payload.action){case at:return void t.dispatch(Nt(e.payload.payload.chatId,!1));case ut:return void t.dispatch(Nt(e.payload.payload.chat.id,!0));default:return}case Z:switch(e.payload.action){case we:return void e.payload.payload.chatsSummary.filter(function(e){var t=e.active;return Ke(n,e.id)!==t}).forEach(function(e){t.dispatch(Nt(e.id,e.active))});default:return}}},hn=function(r,e){e.forEach(function(e){if("present"in e){var t=m(e,["present"]);r("user_data",t)}else if(e.type!==Xe)r("user_data",e);else{var n=m(e,["statistics"]);r("user_data",n)}})},vn=function(e,t){var n,r=t.content;"lc2"===t.type&&("groups_update"===r.name&&"groups"in r&&0!==(d(n=r.groups)?n:Object.keys(n)).length&&e("availability_updated",{availability:"offline"===r.groups[0].status?"offline":"online"}))},mn=function(e,t){var n,r=e.emit,o=e.store,i=t.payload;switch(i.action){case ht:return i.payload.properties.lc2&&"queue_pos"in i.payload.properties.lc2&&r(ft,{chatId:i.payload.chatId,threadId:i.payload.threadId,queue:{position:i.payload.properties.lc2.queue_pos,waitTime:i.payload.properties.lc2.queue_waiting_time}}),void r("thread_properties_updated",i.payload);case ct:return n=i.payload.customer_side_storage,void c(Mt(o),JSON.stringify(n)).catch(x);case st:switch(i.payload.reason){case"access_token_expired":o.dispatch(jt(!0)),o.dispatch(kt(100)),r("disconnected",i.payload);break;case"customer_banned":case"customer_temporarily_blocked":case"license_not_found":case"product_version_changed":case"too_many_connections":case"unsupported_version":o.dispatch(St(i.payload.reason));break;case"misdirected_connection":Jt(o,se),o.dispatch({type:U,payload:i.payload.data});break;case"too_many_unauthorized_connections":Jt(o,"TOO_MANY_UNAUTHORIZED_CONNECTIONS");break;default:o.dispatch(kt(100)),r("disconnected",i.payload)}return;case ut:return hn(r,i.payload.chat.users),void r(i.action,i.payload);case lt:if(null===i.payload.event)return;return void r(i.action,i.payload);case pt:return void r(i.action,i.payload);case dt:return vn(r,i.payload),void r(i.action,i.payload);case vt:return hn(r,[i.payload.user]),void r(i.action,i.payload);default:return void r(i.action,i.payload)}},yn=function(e,t){var n=e.emit,r=t.payload;switch(r.action){case at:return void r.resolve(Gt);case me:return hn(n,r.payload.users),void r.resolve(r.payload);case ut:return hn(n,r.payload.chat.users),void r.resolve(r.payload);case lt:return void r.resolve(r.payload.event);case we:return hn(n,r.payload.users),void r.resolve(r.payload);default:return void r.resolve(r.payload)}},gn=function(e){var _=e.auth,b=e.emitter,w=e.socket,E=b.emit,I=Dt(_,e.customerDataProvider);return function(e,t){switch(e.type){case U:return void w.reinitialize();case D:return void(m=t,y=_,g=e.payload.sessionFields,y.getToken().then(function(e){var t=m.getState();null===$e(t)&&m.dispatch(Pt(e.entityId));var n=t.page;if(n&&n.url){var r=k({license_id:t.licenseId}),o={customer_fields:g||{},session_fields:xt(g||{}),group_id:t.groupId||0,page_url:n.url};return Ht(et(t)+"/action/check_goals?"+r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:e.tokenType+" "+e.accessToken},body:JSON.stringify(o)}).then(function(){})}})).catch(x);case F:var n=e.payload;return w.destroy(),"manual"!==n.reason&&E("disconnected",n),void b.off();case H:var r=e.payload,o=r.reason,i={message:pn[o],code:o};return void r.rejects.forEach(function(e){e(it(i))});case J:var a=e.payload,s=a.dynamicConfig,c=a.chats,u=a.greeting,l=S({customer:a.customer,availability:a.availability},u&&{greeting:u});return Object.defineProperty(l,"__unsafeDynamicConfig",{value:s}),Object.defineProperty(l,"__unsafeChats",{value:c}),void E("connected",l);case W:return void w.disconnect();case G:return e.payload.fresh?void _.getFreshToken().catch(x):void _.hasToken().then(function(e){return e?_.getToken().then(function(e){if(e.creationDate+e.expiresIn-Date.now()<=36e5)return _.invalidate().then(_.getFreshToken)}):_.getToken()}).catch(x);case B:return e.payload.action===st||fn(t,e),void mn({emit:E,store:t},e);case z:return fn(t,e),void yn({emit:E},e);case X:return void w.reconnect(e.payload.delay);case Y:var d=e.payload;return void(0,d.reject)(it(d.error));case Z:return fn(t,e),void yn({emit:E},e);case $:var p=t.getState();return Ye(p)===Be?void Wt(t,e,{code:"SDK_DESTROYED",message:"SDK destroyed."}):Qe(p)||"login"===e.payload.source?(f=w,v=S({request_id:(h=e.payload).id},h.request),void f.emit(v)):void Wt(t,e,{code:"NO_CONNECTION",message:"No connection."});case Q:return void E("customer_id",e.payload.id);case ee:return void E("disconnected",{reason:"connection_lost"});case V:return void I(t);case te:if(!Qe(t.getState()))return;return void E("connection_recovered");case ne:if(!Qe(t.getState()))return;return void E("connection_unstable");case re:return w.connect(),void t.dispatch(jt());case oe:if(!Qe(t.getState()))return;return void At(t,Ct(Pe,e.payload)).catch(x);default:return}var f,h,v,m,y,g}},_n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function bn(e,t){return e(t={exports:{}},t.exports),t.exports}var wn=bn(function(e){e.exports.randomBytes=_n.crypto&&_n.crypto.getRandomValues?function(e){var t=new Uint8Array(e);return _n.crypto.getRandomValues(t),t}:function(e){for(var t=Array(e),n=0;n<e;n++)t[n]=Math.floor(256*Math.random());return t}}),En="abcdefghijklmnopqrstuvwxyz012345",In={string:function(e){for(var t=wn.randomBytes(e),n=[],r=0;r<e;r++)n.push(En.substr(t[r]%32,1));return n.join("")},number:function(e){return Math.floor(Math.random()*e)},numberString:function(e){var t=(""+(e-1)).length;return(Array(t+1).join("0")+this.number(e)).slice(-t)}},Tn=bn(function(e){var n={},r=!1,o=_n.chrome&&_n.chrome.app&&_n.chrome.app.runtime;e.exports={attachEvent:function(e,t){void 0!==_n.addEventListener?_n.addEventListener(e,t,!1):_n.document&&_n.attachEvent&&(_n.document.attachEvent("on"+e,t),_n.attachEvent("on"+e,t))},detachEvent:function(e,t){void 0!==_n.addEventListener?_n.removeEventListener(e,t,!1):_n.document&&_n.detachEvent&&(_n.document.detachEvent("on"+e,t),_n.detachEvent("on"+e,t))},unloadAdd:function(e){if(o)return null;var t=In.string(8);return n[t]=e,r&&setTimeout(this.triggerUnloadCallbacks,0),t},unloadDel:function(e){e in n&&delete n[e]},triggerUnloadCallbacks:function(){for(var e in n)n[e](),delete n[e]}};o||e.exports.attachEvent("unload",function(){r||(r=!0,e.exports.triggerUnloadCallbacks())})}),xn=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e},On=Object.prototype.hasOwnProperty;function Sn(e){return decodeURIComponent(e.replace(/\+/g," "))}var jn={stringify:function(e,t){t=t||"";var n,r,o=[];for(r in"string"!=typeof t&&(t="?"),e)On.call(e,r)&&((n=e[r])||null!=n&&!isNaN(n)||(n=""),o.push(encodeURIComponent(r)+"="+encodeURIComponent(n)));return o.length?t+o.join("&"):""},parse:function(e){for(var t,n=/([^=?&]+)=?([^&]*)/g,r={};t=n.exec(e);){var o=Sn(t[1]),i=Sn(t[2]);o in r||(r[o]=i)}return r}},kn=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,Cn=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,Nn=[["#","hash"],["?","query"],function(e){return e.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],Pn={hash:1,query:1};function An(e){var t;t="undefined"!=typeof window?window:void 0!==_n?_n:"undefined"!=typeof self?self:{};var n,r={},o=typeof(e=e||(t.location||{}));if("blob:"===e.protocol)r=new Ln(unescape(e.pathname),{});else if("string"===o)for(n in r=new Ln(e,{}),Pn)delete r[n];else if("object"===o){for(n in e)n in Pn||(r[n]=e[n]);void 0===r.slashes&&(r.slashes=Cn.test(e.href))}return r}function qn(e){var t=kn.exec(e);return{protocol:t[1]?t[1].toLowerCase():"",slashes:!!t[2],rest:t[3]}}function Ln(e,t,n){if(!(this instanceof Ln))return new Ln(e,t,n);var r,o,i,a,s,c,u=Nn.slice(),l=typeof t,d=this,p=0;for("object"!==l&&"string"!==l&&(n=t,t=null),n&&"function"!=typeof n&&(n=jn.parse),t=An(t),r=!(o=qn(e||"")).protocol&&!o.slashes,d.slashes=o.slashes||r&&t.slashes,d.protocol=o.protocol||t.protocol||"",e=o.rest,o.slashes||(u[3]=[/(.*)/,"pathname"]);p<u.length;p++)"function"!=typeof(a=u[p])?(c=a[1],(i=a[0])!=i?d[c]=e:"string"==typeof i?~(s=e.indexOf(i))&&(e="number"==typeof a[2]?(d[c]=e.slice(0,s),e.slice(s+a[2])):(d[c]=e.slice(s),e.slice(0,s))):(s=i.exec(e))&&(d[c]=s[1],e=e.slice(0,s.index)),d[c]=d[c]||r&&a[3]&&t[c]||"",a[4]&&(d[c]=d[c].toLowerCase())):e=a(e);n&&(d.query=n(d.query)),r&&t.slashes&&"/"!==d.pathname.charAt(0)&&(""!==d.pathname||""!==t.pathname)&&(d.pathname=function(e,t){for(var n=(t||"/").split("/").slice(0,-1).concat(e.split("/")),r=n.length,o=n[r-1],i=!1,a=0;r--;)"."===n[r]?n.splice(r,1):".."===n[r]?(n.splice(r,1),a++):a&&(0===r&&(i=!0),n.splice(r,1),a--);return i&&n.unshift(""),"."!==o&&".."!==o||n.push(""),n.join("/")}(d.pathname,t.pathname)),xn(d.port,d.protocol)||(d.host=d.hostname,d.port=""),d.username=d.password="",d.auth&&(a=d.auth.split(":"),d.username=a[0]||"",d.password=a[1]||""),d.origin=d.protocol&&d.host&&"file:"!==d.protocol?d.protocol+"//"+d.host:"null",d.href=""+d}Ln.prototype={set:function(e,t,n){var r=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(n||jn.parse)(t)),r[e]=t;break;case"port":xn(r[e]=t,r.protocol)?t&&(r.host=r.hostname+":"+t):(r.host=r.hostname,r[e]="");break;case"hostname":r[e]=t,r.port&&(t+=":"+r.port),r.host=t;break;case"host":/:\d+$/.test(r[e]=t)?(t=t.split(":"),r.port=t.pop(),r.hostname=t.join(":")):(r.hostname=t,r.port="");break;case"protocol":r.protocol=t.toLowerCase(),r.slashes=!n;break;case"pathname":case"hash":if(t){var o="pathname"===e?"/":"#";r[e]=t.charAt(0)!==o?o+t:t}else r[e]=t;break;default:r[e]=t}for(var i=0;i<Nn.length;i++){var a=Nn[i];a[4]&&(r[a[1]]=r[a[1]].toLowerCase())}return r.origin=r.protocol&&r.host&&"file:"!==r.protocol?r.protocol+"//"+r.host:"null",r.href=""+r,r},toString:function(e){e&&"function"==typeof e||(e=jn.stringify);var t,n=this,r=n.protocol;r&&":"!==r.charAt(r.length-1)&&(r+=":");var o=r+(n.slashes?"//":"");return n.username&&(o+=n.username,n.password&&(o+=":"+n.password),o+="@"),o+=n.host+n.pathname,(t="object"==typeof n.query?e(n.query):n.query)&&(o+="?"!==t.charAt(0)?"?"+t:t),n.hash&&(o+=n.hash),o}},Ln.extractProtocol=qn,Ln.location=An,Ln.qs=jn;var Mn=Ln,Rn={getOrigin:function(e){if(!e)return null;var t=new Mn(e);if("file:"===t.protocol)return null;var n=t.port;return n||(n="https:"===t.protocol?"443":"80"),t.protocol+"//"+t.hostname+":"+n},isOriginEqual:function(e,t){var n=this.getOrigin(e)===this.getOrigin(t);return n},isSchemeEqual:function(e,t){return e.split(":")[0]===t.split(":")[0]},addPath:function(e,t){var n=e.split("?");return n[0]+t+(n[1]?"?"+n[1]:"")},addQuery:function(e,t){return e+(-1==e.indexOf("?")?"?"+t:"&"+t)}},Un=bn(function(e){e.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){var n=function(){};n.prototype=(e.super_=t).prototype,e.prototype=new n,e.prototype.constructor=e}});function Dn(){this._listeners={}}Dn.prototype.addEventListener=function(e,t){e in this._listeners||(this._listeners[e]=[]);var n=this._listeners[e];-1==n.indexOf(t)&&(n=n.concat([t])),this._listeners[e]=n},Dn.prototype.removeEventListener=function(e,t){var n=this._listeners[e];if(n){var r=n.indexOf(t);-1===r||(1<n.length?this._listeners[e]=n.slice(0,r).concat(n.slice(r+1)):delete this._listeners[e])}},Dn.prototype.dispatchEvent=function(){var e=arguments[0],t=e.type,n=1===arguments.length?[e]:Array.apply(null,arguments);if(this["on"+t]&&this["on"+t].apply(this,n),t in this._listeners)for(var r=this._listeners[t],o=0;o<r.length;o++)r[o].apply(this,n)};var Fn=Dn;function Hn(){Fn.call(this)}Un(Hn,Fn),Hn.prototype.removeAllListeners=function(e){e?delete this._listeners[e]:this._listeners={}},Hn.prototype.once=function(t,n){var r=this,o=!1;this.on(t,function e(){r.removeListener(t,e),o||(o=!0,n.apply(this,arguments))})},Hn.prototype.emit=function(){var e=this._listeners[arguments[0]];if(e){for(var t=arguments.length,n=Array(t-1),r=1;r<t;r++)n[r-1]=arguments[r];for(var o=0;o<e.length;o++)e[o].apply(this,n)}},Hn.prototype.on=Hn.prototype.addListener=Fn.prototype.addEventListener,Hn.prototype.removeListener=Fn.prototype.removeEventListener;var Jn={EventEmitter:Hn},Wn=bn(function(e){var t=_n.WebSocket||_n.MozWebSocket;e.exports=t?function(e){return new t(e)}:void 0}),Gn=Jn.EventEmitter,Bn=function(){};function zn(e,t,n){if(!zn.enabled())throw Error("Transport created when disabled");Gn.call(this),Bn("constructor",e);var r=this,o=Rn.addPath(e,"/websocket");o="https"===o.slice(0,5)?"wss"+o.slice(5):"ws"+o.slice(4),this.url=o,this.ws=new Wn(this.url,[],n),this.ws.onmessage=function(e){Bn("message event",e.data),r.emit("message",e.data)},this.unloadRef=Tn.unloadAdd(function(){Bn("unload"),r.ws.close()}),this.ws.onclose=function(e){Bn("close event",e.code,e.reason),r.emit("close",e.code,e.reason),r._cleanup()},this.ws.onerror=function(e){Bn("error event",e),r.emit("close",1006,"WebSocket connection broken"),r._cleanup()}}Un(zn,Gn),zn.prototype.send=function(e){var t="["+e+"]";Bn("send",t),this.ws.send(t)},zn.prototype.close=function(){Bn("close");var e=this.ws;this._cleanup(),e&&e.close()},zn.prototype._cleanup=function(){Bn("_cleanup");var e=this.ws;e&&(e.onmessage=e.onclose=e.onerror=null),Tn.unloadDel(this.unloadRef),this.unloadRef=this.ws=null,this.removeAllListeners()},zn.enabled=function(){return Bn("enabled"),!!Wn},zn.transportName="websocket",zn.roundTrips=2;var Xn=zn,Yn=Jn.EventEmitter;function Zn(e,t){Yn.call(this),this.sendBuffer=[],this.sender=t,this.url=e}Un(Zn,Yn),Zn.prototype.send=function(e){this.sendBuffer.push(e),this.sendStop||this.sendSchedule()},Zn.prototype.sendScheduleWait=function(){var e,t=this;this.sendStop=function(){t.sendStop=null,clearTimeout(e)},e=setTimeout(function(){t.sendStop=null,t.sendSchedule()},25)},Zn.prototype.sendSchedule=function(){var t=this;if(0<this.sendBuffer.length){var e="["+this.sendBuffer.join(",")+"]";this.sendStop=this.sender(this.url,e,function(e){t.sendStop=null,e?(t.emit("close",e.code||1006,"Sending error: "+e),t.close()):t.sendScheduleWait()}),this.sendBuffer=[]}},Zn.prototype._cleanup=function(){this.removeAllListeners()},Zn.prototype.close=function(){this._cleanup(),this.sendStop&&(this.sendStop(),this.sendStop=null)};var $n=Zn,Kn=Jn.EventEmitter;function Qn(e,t,n){Kn.call(this),this.Receiver=e,this.receiveUrl=t,this.AjaxObject=n,this._scheduleReceiver()}Un(Qn,Kn),Qn.prototype._scheduleReceiver=function(){var n=this,r=this.poll=new this.Receiver(this.receiveUrl,this.AjaxObject);r.on("message",function(e){n.emit("message",e)}),r.once("close",function(e,t){n.poll=r=null,n.pollIsClosing||("network"===t?n._scheduleReceiver():(n.emit("close",e||1006,t),n.removeAllListeners()))})},Qn.prototype.abort=function(){this.removeAllListeners(),this.pollIsClosing=!0,this.poll&&this.poll.abort()};var Vn=Qn;function er(e,t,n,r,o){var i=Rn.addPath(e,t),a=this;$n.call(this,e,n),this.poll=new Vn(r,i,o),this.poll.on("message",function(e){a.emit("message",e)}),this.poll.once("close",function(e,t){a.poll=null,a.emit("close",e,t),a.close()})}Un(er,$n),er.prototype.close=function(){$n.prototype.close.call(this),this.removeAllListeners(),this.poll&&(this.poll.abort(),this.poll=null)};var tr=er,nr=function(){};function rr(e,t,n,r){var a;tr.call(this,e,t,(a=r,function(e,t,n){nr("create ajax sender",e,t);var r={};"string"==typeof t&&(r.headers={"Content-type":"text/plain"});var o=Rn.addPath(e,"/xhr_send"),i=new a("POST",o,t,r);return i.once("finish",function(e){if(nr("finish",e),i=null,200!==e&&204!==e)return n(Error("http status "+e));n()}),function(){nr("abort"),i.close(),i=null;var e=Error("Aborted");e.code=1e3,n(e)}}),n,r)}Un(rr,tr);var or=rr,ir=Jn.EventEmitter;function ar(e,t){ir.call(this);var r=this;this.bufferPosition=0,this.xo=new t("POST",e,null),this.xo.on("chunk",this._chunkHandler.bind(this)),this.xo.once("finish",function(e,t){r._chunkHandler(e,t),r.xo=null;var n=200===e?"network":"permanent";r.emit("close",null,n),r._cleanup()})}Un(ar,ir),ar.prototype._chunkHandler=function(e,t){if(200===e&&t)for(var n=-1;;this.bufferPosition+=n+1){var r=t.slice(this.bufferPosition);if(-1===(n=r.indexOf("\n")))break;var o=r.slice(0,n);o&&this.emit("message",o)}},ar.prototype._cleanup=function(){this.removeAllListeners()},ar.prototype.abort=function(){this.xo&&(this.xo.close(),this.emit("close",null,"user"),this.xo=null),this._cleanup()};var sr=ar,cr=Jn.EventEmitter,ur=_n.XMLHttpRequest;function lr(e,t,n,r){var o=this;cr.call(this),setTimeout(function(){o._start(e,t,n,r)},0)}Un(lr,cr),lr.prototype._start=function(e,t,n,r){var o=this;try{this.xhr=new ur}catch(e){}if(!this.xhr)return this.emit("finish",0,"no xhr support"),void this._cleanup();t=Rn.addQuery(t,"t="+ +new Date),this.unloadRef=Tn.unloadAdd(function(){o._cleanup(!0)});try{this.xhr.open(e,t,!0),this.timeout&&"timeout"in this.xhr&&(this.xhr.timeout=this.timeout,this.xhr.ontimeout=function(){o.emit("finish",0,""),o._cleanup(!1)})}catch(e){return this.emit("finish",0,""),void this._cleanup(!1)}if(r&&r.noCredentials||!lr.supportsCORS||(this.xhr.withCredentials=!0),r&&r.headers)for(var i in r.headers)this.xhr.setRequestHeader(i,r.headers[i]);this.xhr.onreadystatechange=function(){if(o.xhr){var e,t,n=o.xhr;switch(n.readyState){case 3:try{t=n.status,e=n.responseText}catch(e){}1223===t&&(t=204),200===t&&e&&0<e.length&&o.emit("chunk",t,e);break;case 4:1223===(t=n.status)&&(t=204),12005!==t&&12029!==t||(t=0),o.emit("finish",t,n.responseText),o._cleanup(!1)}}};try{o.xhr.send(n)}catch(e){o.emit("finish",0,""),o._cleanup(!1)}},lr.prototype._cleanup=function(e){if(this.xhr){if(this.removeAllListeners(),Tn.unloadDel(this.unloadRef),this.xhr.onreadystatechange=function(){},this.xhr.ontimeout&&(this.xhr.ontimeout=null),e)try{this.xhr.abort()}catch(e){}this.unloadRef=this.xhr=null}},lr.prototype.close=function(){this._cleanup(!0)},lr.enabled=!!ur;var dr=["Active"].concat("Object").join("X");!lr.enabled&&dr in _n&&(lr.enabled=!!new(ur=function(){try{return new _n[dr]("Microsoft.XMLHTTP")}catch(e){return null}}));var pr=!1;try{pr="withCredentials"in new ur}catch(e){}lr.supportsCORS=pr;var fr=lr;function hr(e,t,n,r){fr.call(this,e,t,n,r)}Un(hr,fr),hr.enabled=fr.enabled&&fr.supportsCORS;var vr=hr;function mr(e,t,n){fr.call(this,e,t,n,{noCredentials:!0})}Un(mr,fr),mr.enabled=fr.enabled;var yr=mr,gr={isOpera:function(){return _n.navigator&&/opera/i.test(_n.navigator.userAgent)},isKonqueror:function(){return _n.navigator&&/konqueror/i.test(_n.navigator.userAgent)},hasDomain:function(){if(!_n.document)return!0;try{return!!_n.document.domain}catch(e){return!1}}};function _r(e){if(!yr.enabled&&!vr.enabled)throw Error("Transport created when disabled");or.call(this,e,"/xhr_streaming",sr,vr)}Un(_r,or),_r.enabled=function(e){return!e.nullOrigin&&(!gr.isOpera()&&vr.enabled)},_r.transportName="xhr-streaming",_r.roundTrips=2,_r.needBody=!!_n.document;var br=_r,wr=Jn.EventEmitter;function Er(e,t,n){var r=this;wr.call(this),setTimeout(function(){r._start(e,t,n)},0)}Un(Er,wr),Er.prototype._start=function(e,t,n){var r=this,o=new _n.XDomainRequest;t=Rn.addQuery(t,"t="+ +new Date),o.onerror=function(){r._error()},o.ontimeout=function(){r._error()},o.onprogress=function(){r.emit("chunk",200,o.responseText)},o.onload=function(){r.emit("finish",200,o.responseText),r._cleanup(!1)},this.xdr=o,this.unloadRef=Tn.unloadAdd(function(){r._cleanup(!0)});try{this.xdr.open(e,t),this.timeout&&(this.xdr.timeout=this.timeout),this.xdr.send(n)}catch(e){this._error()}},Er.prototype._error=function(){this.emit("finish",0,""),this._cleanup(!1)},Er.prototype._cleanup=function(e){if(this.xdr){if(this.removeAllListeners(),Tn.unloadDel(this.unloadRef),this.xdr.ontimeout=this.xdr.onerror=this.xdr.onprogress=this.xdr.onload=null,e)try{this.xdr.abort()}catch(e){}this.unloadRef=this.xdr=null}},Er.prototype.close=function(){this._cleanup(!0)},Er.enabled=!(!_n.XDomainRequest||!gr.hasDomain());var Ir=Er;function Tr(e){if(!Ir.enabled)throw Error("Transport created when disabled");or.call(this,e,"/xhr_streaming",sr,Ir)}Un(Tr,or),Tr.enabled=function(e){return!e.cookie_needed&&!e.nullOrigin&&(Ir.enabled&&e.sameScheme)},Tr.transportName="xdr-streaming",Tr.roundTrips=2;var xr=Tr,Or=_n.EventSource,Sr=Jn.EventEmitter;function jr(e){Sr.call(this);var n=this,r=this.es=new Or(e);r.onmessage=function(e){n.emit("message",decodeURI(e.data))},r.onerror=function(e){var t=2!==r.readyState?"network":"permanent";n._cleanup(),n._close(t)}}Un(jr,Sr),jr.prototype.abort=function(){this._cleanup(),this._close("user")},jr.prototype._cleanup=function(){var e=this.es;e&&(e.onmessage=e.onerror=null,e.close(),this.es=null)},jr.prototype._close=function(e){var t=this;setTimeout(function(){t.emit("close",null,e),t.removeAllListeners()},200)};var kr=jr;function Cr(e){if(!Cr.enabled())throw Error("Transport created when disabled");or.call(this,e,"/eventsource",kr,vr)}Un(Cr,or),Cr.enabled=function(){return!!Or},Cr.transportName="eventsource",Cr.roundTrips=2;var Nr=Cr,Pr=bn(function(a,s){(function(){var U={function:!0,object:!0},e=s&&!s.nodeType&&s,D=U[typeof window]&&window||this,t=e&&U.object&&a&&!a.nodeType&&"object"==typeof _n&&_n;function F(e,c){e||(e=D.Object()),c||(c=D.Object());var u=e.Number||D.Number,l=e.String||D.String,t=e.Object||D.Object,d=e.Date||D.Date,n=e.SyntaxError||D.SyntaxError,I=e.TypeError||D.TypeError,r=e.Math||D.Math,o=e.JSON||D.JSON;"object"==typeof o&&o&&(c.stringify=o.stringify,c.parse=o.parse);var T,x,O,i=t.prototype,S=i.toString,p=new d(-0xc782b5b800cec);try{p=-109252==p.getUTCFullYear()&&0==p.getUTCMonth()&&1==p.getUTCDate()&&10==p.getUTCHours()&&37==p.getUTCMinutes()&&6==p.getUTCSeconds()&&708==p.getUTCMilliseconds()}catch(e){}function f(e){if(f[e]!==O)return f[e];var t;if("bug-string-char-index"==e)t=!1;else if("json"==e)t=f("json-stringify")&&f("json-parse");else{var n,r='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if("json-stringify"==e){var o=c.stringify,i="function"==typeof o&&p;if(i){(n=function(){return 1}).toJSON=n;try{i="0"===o(0)&&"0"===o(new u)&&'""'==o(new l)&&o(S)===O&&o(O)===O&&o()===O&&"1"===o(n)&&"[1]"==o([n])&&"[null]"==o([O])&&"null"==o(null)&&"[null,null,null]"==o([O,S,null])&&o({a:[n,!0,!1,null,"\0\b\n\f\r\t"]})==r&&"1"===o(null,n)&&"[\n 1,\n 2\n]"==o([1,2],null,1)&&'"-271821-04-20T00:00:00.000Z"'==o(new d(-864e13))&&'"+275760-09-13T00:00:00.000Z"'==o(new d(864e13))&&'"-000001-01-01T00:00:00.000Z"'==o(new d(-621987552e5))&&'"1969-12-31T23:59:59.999Z"'==o(new d(-1))}catch(e){i=!1}}t=i}if("json-parse"==e){var a=c.parse;if("function"==typeof a)try{if(0===a("0")&&!a(!1)){var s=5==(n=a(r)).a.length&&1===n.a[0];if(s){try{s=!a('"\t"')}catch(e){}if(s)try{s=1!==a("01")}catch(e){}if(s)try{s=1!==a("1.")}catch(e){}}}}catch(e){s=!1}t=s}}return f[e]=!!t}if(!f("json")){var h="[object Function]",j="[object Number]",k="[object String]",C="[object Array]",s=f("bug-string-char-index");if(!p)var N=r.floor,a=[0,31,59,90,120,151,181,212,243,273,304,334],P=function(e,t){return a[t]+365*(e-1970)+N((e-1969+(t=+(1<t)))/4)-N((e-1901+t)/100)+N((e-1601+t)/400)};if((T=i.hasOwnProperty)||(T=function(e){var n,t={};return T=(t.__proto__=null,t.__proto__={toString:1},t).toString!=S?function(e){var t=this.__proto__,n=e in(this.__proto__=null,this);return this.__proto__=t,n}:(n=t.constructor,function(e){var t=(this.constructor||n).prototype;return e in this&&!(e in t&&this[e]===t[e])}),t=null,T.call(this,e)}),x=function(e,t){var n,a,r,o=0;for(r in(n=function(){this.valueOf=0}).prototype.valueOf=0,a=new n)T.call(a,r)&&o++;return n=a=null,(x=o?2==o?function(e,t){var n,r={},o=S.call(e)==h;for(n in e)o&&"prototype"==n||T.call(r,n)||!(r[n]=1)||!T.call(e,n)||t(n)}:function(e,t){var n,r,o=S.call(e)==h;for(n in e)o&&"prototype"==n||!T.call(e,n)||(r="constructor"===n)||t(n);(r||T.call(e,n="constructor"))&&t(n)}:(a=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],function(e,t){var n,r,o=S.call(e)==h,i=!o&&"function"!=typeof e.constructor&&U[typeof e.hasOwnProperty]&&e.hasOwnProperty||T;for(n in e)o&&"prototype"==n||!i.call(e,n)||t(n);for(r=a.length;n=a[--r];i.call(e,n)&&t(n));}))(e,t)},!f("json-stringify")){var v={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},A=function(e,t){return("000000"+(t||0)).slice(-e)},q=function(e){for(var t='"',n=0,r=e.length,o=!s||10<r,i=o&&(s?e.split(""):e);n<r;n++){var a=e.charCodeAt(n);switch(a){case 8:case 9:case 10:case 12:case 13:case 34:case 92:t+=v[a];break;default:if(a<32){t+="\\u00"+A(2,a.toString(16));break}t+=o?i[n]:e.charAt(n)}}return t+'"'},L=function(e,t,n,r,o,i,a){var s,c,u,l,d,p,f,h,v,m,y,g,_,b,w,E;try{s=t[e]}catch(e){}if("object"==typeof s&&s)if("[object Date]"!=(c=S.call(s))||T.call(s,"toJSON"))"function"==typeof s.toJSON&&(c!=j&&c!=k&&c!=C||T.call(s,"toJSON"))&&(s=s.toJSON(e));else if(-1/0<s&&s<1/0){if(P){for(d=N(s/864e5),u=N(d/365.2425)+1970-1;P(u+1,0)<=d;u++);for(l=N((d-P(u,0))/30.42);P(u,l+1)<=d;l++);d=1+d-P(u,l),f=N((p=(s%864e5+864e5)%864e5)/36e5)%24,h=N(p/6e4)%60,v=N(p/1e3)%60,m=p%1e3}else u=s.getUTCFullYear(),l=s.getUTCMonth(),d=s.getUTCDate(),f=s.getUTCHours(),h=s.getUTCMinutes(),v=s.getUTCSeconds(),m=s.getUTCMilliseconds();s=(0<u&&u<1e4?A(4,u):(u<0?"-":"+")+A(6,u<0?-u:u))+"-"+A(2,l+1)+"-"+A(2,d)+"T"+A(2,f)+":"+A(2,h)+":"+A(2,v)+"."+A(3,m)+"Z"}else s=null;if(n&&(s=n.call(t,e,s)),null===s)return"null";if("[object Boolean]"==(c=S.call(s)))return""+s;if(c==j)return-1/0<s&&s<1/0?""+s:"null";if(c==k)return q(""+s);if("object"==typeof s){for(b=a.length;b--;)if(a[b]===s)throw I();if(a.push(s),y=[],w=i,i+=o,c==C){for(_=0,b=s.length;_<b;_++)g=L(_,s,n,r,o,i,a),y.push(g===O?"null":g);E=y.length?o?"[\n"+i+y.join(",\n"+i)+"\n"+w+"]":"["+y.join(",")+"]":"[]"}else x(r||s,function(e){var t=L(e,s,n,r,o,i,a);t!==O&&y.push(q(e)+":"+(o?" ":"")+t)}),E=y.length?o?"{\n"+i+y.join(",\n"+i)+"\n"+w+"}":"{"+y.join(",")+"}":"{}";return a.pop(),E}};c.stringify=function(e,t,n){var r,o,i,a;if(U[typeof t]&&t)if((a=S.call(t))==h)o=t;else if(a==C){i={};for(var s,c=0,u=t.length;c<u;s=t[c++],((a=S.call(s))==k||a==j)&&(i[s]=1));}if(n)if((a=S.call(n))==j){if(0<(n-=n%1))for(r="",10<n&&(n=10);r.length<n;r+=" ");}else a==k&&(r=10<n.length?n.slice(0,10):n);return L("",((s={})[""]=e,s),o,i,r,"",[])}}if(!f("json-parse")){var m,y,g=l.fromCharCode,_={92:"\\",34:'"',47:"/",98:"\b",116:"\t",110:"\n",102:"\f",114:"\r"},b=function(){throw m=y=null,n()},w=function(){for(var e,t,n,r,o,i=y,a=i.length;m<a;)switch(o=i.charCodeAt(m)){case 9:case 10:case 13:case 32:m++;break;case 123:case 125:case 91:case 93:case 58:case 44:return e=s?i.charAt(m):i[m],m++,e;case 34:for(e="@",m++;m<a;)if((o=i.charCodeAt(m))<32)b();else if(92==o)switch(o=i.charCodeAt(++m)){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:e+=_[o],m++;break;case 117:for(t=++m,n=m+4;m<n;m++)((o=i.charCodeAt(m))<48||57<o)&&(o<97||102<o)&&(o<65||70<o)&&b();e+=g("0x"+i.slice(t,m));break;default:b()}else{if(34==o)break;for(o=i.charCodeAt(m),t=m;32<=o&&92!=o&&34!=o;)o=i.charCodeAt(++m);e+=i.slice(t,m)}if(34==i.charCodeAt(m))return m++,e;b();default:if(t=m,45==o&&(r=!0,o=i.charCodeAt(++m)),48<=o&&o<=57){for(48!=o||((o=i.charCodeAt(m+1))<48||57<o)||b(),r=!1;m<a&&(48<=(o=i.charCodeAt(m))&&o<=57);m++);if(46==i.charCodeAt(m)){for(n=++m;n<a&&(48<=(o=i.charCodeAt(n))&&o<=57);n++);n==m&&b(),m=n}if(101==(o=i.charCodeAt(m))||69==o){for(43!=(o=i.charCodeAt(++m))&&45!=o||m++,n=m;n<a&&(48<=(o=i.charCodeAt(n))&&o<=57);n++);n==m&&b(),m=n}return+i.slice(t,m)}if(r&&b(),"true"==i.slice(m,m+4))return m+=4,!0;if("false"==i.slice(m,m+5))return m+=5,!1;if("null"==i.slice(m,m+4))return m+=4,null;b()}return"$"},E=function(e){var t,n;if("$"==e&&b(),"string"==typeof e){if("@"==(s?e.charAt(0):e[0]))return e.slice(1);if("["==e){for(t=[];"]"!=(e=w());n||(n=!0))n&&(","==e?"]"==(e=w())&&b():b()),","==e&&b(),t.push(E(e));return t}if("{"==e){for(t={};"}"!=(e=w());n||(n=!0))n&&(","==e?"}"==(e=w())&&b():b()),","!=e&&"string"==typeof e&&"@"==(s?e.charAt(0):e[0])&&":"==w()||b(),t[e.slice(1)]=E(w());return t}b()}return e},M=function(e,t,n){var r=R(e,t,n);r===O?delete e[t]:e[t]=r},R=function(e,t,n){var r,o=e[t];if("object"==typeof o&&o)if(S.call(o)==C)for(r=o.length;r--;)M(o,r,n);else x(o,function(e){M(o,e,n)});return n.call(e,t,o)};c.parse=function(e,t){var n,r;return m=0,y=""+e,n=E(w()),"$"!=w()&&b(),m=y=null,t&&S.call(t)==h?R(((r={})[""]=n,r),"",t):n}}}return c.runInContext=F,c}if(!t||t.global!==t&&t.window!==t&&t.self!==t||(D=t),e)F(D,e);else{var n=D.JSON,r=D.JSON3,o=!1,i=F(D,D.JSON3={noConflict:function(){return o||(o=!0,D.JSON=n,D.JSON3=r,n=r=null),i}});D.JSON={parse:i.parse,stringify:i.stringify}}}).call(_n)}),Ar=bn(function(d){d.exports={WPrefix:"_jp",currentWindowId:null,polluteGlobalNamespace:function(){d.exports.WPrefix in _n||(_n[d.exports.WPrefix]={})},postMessage:function(e,t){_n.parent!==_n&&_n.parent.postMessage(Pr.stringify({windowId:d.exports.currentWindowId,type:e,data:t||""}),"*")},createIframe:function(e,t){var n,r,o=_n.document.createElement("iframe"),i=function(){clearTimeout(n);try{o.onload=null}catch(e){}o.onerror=null},a=function(){o&&(i(),setTimeout(function(){o&&o.parentNode.removeChild(o),o=null},0),Tn.unloadDel(r))},s=function(e){o&&(a(),t(e))};return o.src=e,o.style.display="none",o.style.position="absolute",o.onerror=function(){s("onerror")},o.onload=function(){clearTimeout(n),n=setTimeout(function(){s("onload timeout")},2e3)},_n.document.body.appendChild(o),n=setTimeout(function(){s("timeout")},15e3),r=Tn.unloadAdd(a),{post:function(e,t){setTimeout(function(){try{o&&o.contentWindow&&o.contentWindow.postMessage(e,t)}catch(e){}},0)},cleanup:a,loaded:i}},createHtmlfile:function(e,t){var n,r,o,i=["Active"].concat("Object").join("X"),a=new _n[i]("htmlfile"),s=function(){clearTimeout(n),o.onerror=null},c=function(){a&&(s(),Tn.unloadDel(r),o.parentNode.removeChild(o),o=a=null,CollectGarbage())},u=function(e){a&&(c(),t(e))};a.open(),a.write('<html><script>document.domain="'+_n.document.domain+'";<\/script></html>'),a.close(),a.parentWindow[d.exports.WPrefix]=_n[d.exports.WPrefix];var l=a.createElement("div");return a.body.appendChild(l),o=a.createElement("iframe"),l.appendChild(o),o.src=e,o.onerror=function(){u("onerror")},n=setTimeout(function(){u("timeout")},15e3),r=Tn.unloadAdd(c),{post:function(e,t){try{setTimeout(function(){o&&o.contentWindow&&o.contentWindow.postMessage(e,t)},0)}catch(e){}},cleanup:c,loaded:s}}},d.exports.iframeEnabled=!1,_n.document&&(d.exports.iframeEnabled=("function"==typeof _n.postMessage||"object"==typeof _n.postMessage)&&!gr.isKonqueror())}),qr=Jn.EventEmitter,Lr=function(){};function Mr(e,t,n){if(!Mr.enabled())throw Error("Transport created when disabled");qr.call(this);var r=this;this.origin=Rn.getOrigin(n),this.baseUrl=n,this.transUrl=t,this.transport=e,this.windowId=In.string(8);var o=Rn.addPath(n,"/iframe.html")+"#"+this.windowId;Lr(e,t,o),this.iframeObj=Ar.createIframe(o,function(e){Lr("err callback"),r.emit("close",1006,"Unable to load an iframe ("+e+")"),r.close()}),this.onmessageCallback=this._message.bind(this),Tn.attachEvent("message",this.onmessageCallback)}Un(Mr,qr),Mr.prototype.close=function(){if(Lr("close"),this.removeAllListeners(),this.iframeObj){Tn.detachEvent("message",this.onmessageCallback);try{this.postMessage("c")}catch(e){}this.iframeObj.cleanup(),this.iframeObj=null,this.onmessageCallback=this.iframeObj=null}},Mr.prototype._message=function(t){if(Lr("message",t.data),Rn.isOriginEqual(t.origin,this.origin)){var n;try{n=Pr.parse(t.data)}catch(e){return void Lr("bad json",t.data)}if(n.windowId===this.windowId)switch(n.type){case"s":this.iframeObj.loaded(),this.postMessage("s",Pr.stringify(["1.3.0",this.transport,this.transUrl,this.baseUrl]));break;case"t":this.emit("message",n.data);break;case"c":var e;try{e=Pr.parse(n.data)}catch(e){return void Lr("bad json",n.data)}this.emit("close",e[0],e[1]),this.close()}else Lr("mismatched window id",n.windowId,this.windowId)}else Lr("not same origin",t.origin,this.origin)},Mr.prototype.postMessage=function(e,t){Lr("postMessage",e,t),this.iframeObj.post(Pr.stringify({windowId:this.windowId,type:e,data:t||""}),this.origin)},Mr.prototype.send=function(e){Lr("send",e),this.postMessage("m",e)},Mr.enabled=function(){return Ar.iframeEnabled},Mr.transportName="iframe",Mr.roundTrips=2;var Rr=Mr,Ur={isObject:function(e){var t=typeof e;return"function"===t||"object"===t&&!!e},extend:function(e){if(!this.isObject(e))return e;for(var t,n,r=1,o=arguments.length;r<o;r++)for(n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}},Dr=function(r){function e(e,t){Rr.call(this,r.transportName,e,t)}return Un(e,Rr),e.enabled=function(e,t){if(!_n.document)return!1;var n=Ur.extend({},t);return n.sameOrigin=!0,r.enabled(n)&&Rr.enabled()},e.transportName="iframe-"+r.transportName,e.needBody=!0,e.roundTrips=Rr.roundTrips+r.roundTrips-1,e.facadeTransport=r,e},Fr=Jn.EventEmitter,Hr=function(){};function Jr(e){Hr(e),Fr.call(this);var t=this;Ar.polluteGlobalNamespace(),this.id="a"+In.string(6),e=Rn.addQuery(e,"c="+decodeURIComponent(Ar.WPrefix+"."+this.id)),Hr("using htmlfile",Jr.htmlfileEnabled);var n=Jr.htmlfileEnabled?Ar.createHtmlfile:Ar.createIframe;_n[Ar.WPrefix][this.id]={start:function(){Hr("start"),t.iframeObj.loaded()},message:function(e){Hr("message",e),t.emit("message",e)},stop:function(){Hr("stop"),t._cleanup(),t._close("network")}},this.iframeObj=n(e,function(){Hr("callback"),t._cleanup(),t._close("permanent")})}Un(Jr,Fr),Jr.prototype.abort=function(){Hr("abort"),this._cleanup(),this._close("user")},Jr.prototype._cleanup=function(){Hr("_cleanup"),this.iframeObj&&(this.iframeObj.cleanup(),this.iframeObj=null),delete _n[Ar.WPrefix][this.id]},Jr.prototype._close=function(e){Hr("_close",e),this.emit("close",null,e),this.removeAllListeners()},Jr.htmlfileEnabled=!1;var Wr=["Active"].concat("Object").join("X");if(Wr in _n)try{Jr.htmlfileEnabled=!!new _n[Wr]("htmlfile")}catch(e){}Jr.enabled=Jr.htmlfileEnabled||Ar.iframeEnabled;var Gr=Jr;function Br(e){if(!Gr.enabled)throw Error("Transport created when disabled");or.call(this,e,"/htmlfile",Gr,yr)}Un(Br,or),Br.enabled=function(e){return Gr.enabled&&e.sameOrigin},Br.transportName="htmlfile",Br.roundTrips=2;var zr=Br;function Xr(e){if(!yr.enabled&&!vr.enabled)throw Error("Transport created when disabled");or.call(this,e,"/xhr",sr,vr)}Un(Xr,or),Xr.enabled=function(e){return!e.nullOrigin&&(!(!yr.enabled||!e.sameOrigin)||vr.enabled)},Xr.transportName="xhr-polling",Xr.roundTrips=2;var Yr=Xr;function Zr(e){if(!Ir.enabled)throw Error("Transport created when disabled");or.call(this,e,"/xhr",sr,Ir)}Un(Zr,or),Zr.enabled=xr.enabled,Zr.transportName="xdr-polling",Zr.roundTrips=2;var $r=Zr,Kr=Jn.EventEmitter,Qr=function(){};function Vr(e){Qr(e);var t=this;Kr.call(this),Ar.polluteGlobalNamespace(),this.id="a"+In.string(6);var n=Rn.addQuery(e,"c="+encodeURIComponent(Ar.WPrefix+"."+this.id));_n[Ar.WPrefix][this.id]=this._callback.bind(this),this._createScript(n),this.timeoutId=setTimeout(function(){Qr("timeout"),t._abort(Error("JSONP script loaded abnormally (timeout)"))},Vr.timeout)}Un(Vr,Kr),Vr.prototype.abort=function(){if(Qr("abort"),_n[Ar.WPrefix][this.id]){var e=Error("JSONP user aborted read");e.code=1e3,this._abort(e)}},Vr.timeout=35e3,Vr.scriptErrorTimeout=1e3,Vr.prototype._callback=function(e){Qr("_callback",e),this._cleanup(),this.aborting||(e&&(Qr("message",e),this.emit("message",e)),this.emit("close",null,"network"),this.removeAllListeners())},Vr.prototype._abort=function(e){Qr("_abort",e),this._cleanup(),this.aborting=!0,this.emit("close",e.code,e.message),this.removeAllListeners()},Vr.prototype._cleanup=function(){if(Qr("_cleanup"),clearTimeout(this.timeoutId),this.script2&&(this.script2.parentNode.removeChild(this.script2),this.script2=null),this.script){var e=this.script;e.parentNode.removeChild(e),e.onreadystatechange=e.onerror=e.onload=e.onclick=null,this.script=null}delete _n[Ar.WPrefix][this.id]},Vr.prototype._scriptError=function(){Qr("_scriptError");var e=this;this.errorTimer||(this.errorTimer=setTimeout(function(){e.loadedOkay||e._abort(Error("JSONP script loaded abnormally (onerror)"))},Vr.scriptErrorTimeout))},Vr.prototype._createScript=function(e){Qr("_createScript",e);var t,n=this,r=this.script=_n.document.createElement("script");if(r.id="a"+In.string(8),r.src=e,r.type="text/javascript",r.charset="UTF-8",r.onerror=this._scriptError.bind(this),r.onload=function(){Qr("onload"),n._abort(Error("JSONP script loaded abnormally (onload)"))},r.onreadystatechange=function(){if(Qr("onreadystatechange",r.readyState),/loaded|closed/.test(r.readyState)){if(r&&r.htmlFor&&r.onclick){n.loadedOkay=!0;try{r.onclick()}catch(e){}}r&&n._abort(Error("JSONP script loaded abnormally (onreadystatechange)"))}},void 0===r.async&&_n.document.attachEvent)if(gr.isOpera())(t=this.script2=_n.document.createElement("script")).text="try{var a = document.getElementById('"+r.id+"'); if(a)a.onerror();}catch(x){};",r.async=t.async=!1;else{try{r.htmlFor=r.id,r.event="onclick"}catch(e){}r.async=!0}void 0!==r.async&&(r.async=!0);var o=_n.document.getElementsByTagName("head")[0];o.insertBefore(r,o.firstChild),t&&o.insertBefore(t,o.firstChild)};var eo,to,no=Vr;var ro=function(e,t,n){eo||((eo=_n.document.createElement("form")).style.display="none",eo.style.position="absolute",eo.method="POST",eo.enctype="application/x-www-form-urlencoded",eo.acceptCharset="UTF-8",(to=_n.document.createElement("textarea")).name="d",eo.appendChild(to),_n.document.body.appendChild(eo));var r="a"+In.string(8);eo.target=r,eo.action=Rn.addQuery(Rn.addPath(e,"/jsonp_send"),"i="+r);var o=function(t){try{return _n.document.createElement('<iframe name="'+t+'">')}catch(e){var n=_n.document.createElement("iframe");return n.name=t,n}}(r);o.id=r,o.style.display="none",eo.appendChild(o);try{to.value=t}catch(e){}eo.submit();var i=function(e){o.onerror&&(o.onreadystatechange=o.onerror=o.onload=null,setTimeout(function(){o.parentNode.removeChild(o),o=null},500),to.value="",n(e))};return o.onerror=function(){i()},o.onload=function(){i()},o.onreadystatechange=function(e){"complete"===o.readyState&&i()},function(){i(Error("Aborted"))}};function oo(e){if(!oo.enabled())throw Error("Transport created when disabled");tr.call(this,e,"/jsonp",ro,no)}Un(oo,tr),oo.enabled=function(){return!!_n.document},oo.transportName="jsonp-polling",oo.roundTrips=1,oo.needBody=!0;var io,ao=oo,so=[Xn,br,xr,Nr,Dr(Nr),zr,Dr(zr),Yr,$r,Dr(Yr),ao],co=Array.prototype,uo=Object.prototype,lo=Function.prototype,po=String.prototype,fo=co.slice,ho=uo.toString,vo=function(e){return"[object Function]"===uo.toString.call(e)},mo=function(e){return"[object String]"===ho.call(e)},yo=Object.defineProperty&&function(){try{return Object.defineProperty({},"x",{}),!0}catch(e){return!1}}();io=yo?function(e,t,n,r){!r&&t in e||Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:!0,value:n})}:function(e,t,n,r){!r&&t in e||(e[t]=n)};var go=function(e,t,n){for(var r in t)uo.hasOwnProperty.call(t,r)&&io(e,r,t[r],n)},_o=function(e){if(null==e)throw new TypeError("can't convert "+e+" to object");return Object(e)};function bo(){}go(lo,{bind:function(t){var n=this;if(!vo(n))throw new TypeError("Function.prototype.bind called on incompatible "+n);for(var r=fo.call(arguments,1),e=Math.max(0,n.length-r.length),o=[],i=0;i<e;i++)o.push("$"+i);var a=Function("binder","return function ("+o.join(",")+"){ return binder.apply(this, arguments); }")(function(){if(this instanceof a){var e=n.apply(this,r.concat(fo.call(arguments)));return Object(e)===e?e:this}return n.apply(t,r.concat(fo.call(arguments)))});return n.prototype&&(bo.prototype=n.prototype,a.prototype=new bo,bo.prototype=null),a}}),go(Array,{isArray:function(e){return"[object Array]"===ho.call(e)}});var wo,Eo,Io,To=Object("a"),xo="a"!==To[0]||!(0 in To);go(co,{forEach:function(e){var t=_o(this),n=xo&&mo(this)?this.split(""):t,r=arguments[1],o=-1,i=n.length>>>0;if(!vo(e))throw new TypeError;for(;++o<i;)o in n&&e.call(r,n[o],o,t)}},(Io=Eo=!0,(wo=co.forEach)&&(wo.call("foo",function(e,t,n){"object"!=typeof n&&(Eo=!1)}),wo.call([1],function(){Io="string"==typeof this},"x")),!(wo&&Eo&&Io))),go(co,{indexOf:function(e){var t=xo&&mo(this)?this.split(""):_o(this),n=t.length>>>0;if(!n)return-1;var r,o=0;for(1<arguments.length&&((r=+arguments[1])!=r?r=0:0!==r&&r!==1/0&&r!==-1/0&&(r=(0<r||-1)*Math.floor(Math.abs(r))),o=r),o=o<0?Math.max(0,n+o):o;o<n;o++)if(o in t&&t[o]===e)return o;return-1}},Array.prototype.indexOf&&!1);var Oo,So=po.split;"".split(/.?/).length&&(Oo=void 0===/()??/.exec("")[1],po.split=function(e,t){var n=this;if(void 0===e&&0===t)return[];if("[object RegExp]"!==ho.call(e))return So.call(this,e,t);var r,o,i,a,s=[],c=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.extended?"x":"")+(e.sticky?"y":""),u=0;for(e=RegExp(e.source,c+"g"),n+="",Oo||(r=RegExp("^"+e.source+"$(?!\\s)",c)),t=void 0===t?-1>>>0:t>>>0;(o=e.exec(n))&&(u>=(i=o.index+o[0].length)||(s.push(n.slice(u,o.index)),!Oo&&1<o.length&&o[0].replace(r,function(){for(var e=1;e<arguments.length-2;e++)void 0===arguments[e]&&(o[e]=void 0)}),1<o.length&&o.index<n.length&&co.push.apply(s,o.slice(1)),a=o[0].length,u=i,s.length<t));)e.lastIndex===o.index&&e.lastIndex++;return u===n.length?!a&&e.test("")||s.push(""):s.push(n.slice(u)),t<s.length?s.slice(0,t):s});var jo=po.substr;go(po,{substr:function(e,t){return jo.call(this,e<0&&(e=this.length+e)<0?0:e,t)}},"".substr&&!1);var ko,Co=/[\x00-\x1f\ud800-\udfff\ufffe\uffff\u0300-\u0333\u033d-\u0346\u034a-\u034c\u0350-\u0352\u0357-\u0358\u035c-\u0362\u0374\u037e\u0387\u0591-\u05af\u05c4\u0610-\u0617\u0653-\u0654\u0657-\u065b\u065d-\u065e\u06df-\u06e2\u06eb-\u06ec\u0730\u0732-\u0733\u0735-\u0736\u073a\u073d\u073f-\u0741\u0743\u0745\u0747\u07eb-\u07f1\u0951\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0e38-\u0e39\u0f43\u0f4d\u0f52\u0f57\u0f5c\u0f69\u0f72-\u0f76\u0f78\u0f80-\u0f83\u0f93\u0f9d\u0fa2\u0fa7\u0fac\u0fb9\u1939-\u193a\u1a17\u1b6b\u1cda-\u1cdb\u1dc0-\u1dcf\u1dfc\u1dfe\u1f71\u1f73\u1f75\u1f77\u1f79\u1f7b\u1f7d\u1fbb\u1fbe\u1fc9\u1fcb\u1fd3\u1fdb\u1fe3\u1feb\u1fee-\u1fef\u1ff9\u1ffb\u1ffd\u2000-\u2001\u20d0-\u20d1\u20d4-\u20d7\u20e7-\u20e9\u2126\u212a-\u212b\u2329-\u232a\u2adc\u302b-\u302c\uaab2-\uaab3\uf900-\ufa0d\ufa10\ufa12\ufa15-\ufa1e\ufa20\ufa22\ufa25-\ufa26\ufa2a-\ufa2d\ufa30-\ufa6d\ufa70-\ufad9\ufb1d\ufb1f\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4e\ufff0-\uffff]/g,No=function(e){var t,n=Pr.stringify(e);return Co.lastIndex=0,Co.test(n)?(ko||((t=Co).lastIndex=0,t.lastIndex=0,ko={}),n.replace(Co,function(e){return ko[e]})):n},Po={};["log","debug","warn"].forEach(function(e){var t;try{t=_n.console&&_n.console[e]&&_n.console[e].apply}catch(e){}Po[e]=t?function(){return _n.console[e].apply(_n.console,arguments)}:"log"===e?function(){}:Po.log});var Ao=Po;function qo(e){this.type=e}qo.prototype.initEvent=function(e,t,n){return this.type=e,this.bubbles=t,this.cancelable=n,this.timeStamp=+new Date,this},qo.prototype.stopPropagation=function(){},qo.prototype.preventDefault=function(){},qo.CAPTURING_PHASE=1,qo.AT_TARGET=2,qo.BUBBLING_PHASE=3;var Lo=qo,Mo=_n.location||{origin:"http://localhost:80",protocol:"http:",host:"localhost",port:80,href:"http://localhost/",hash:""};function Ro(){Lo.call(this),this.initEvent("close",!1,!1),this.wasClean=!1,this.code=0,this.reason=""}Un(Ro,Lo);var Uo=Ro;function Do(e){Lo.call(this),this.initEvent("message",!1,!1),this.data=e}Un(Do,Lo);var Fo=Do,Ho=Jn.EventEmitter;function Jo(){var e=this;Ho.call(this),this.to=setTimeout(function(){e.emit("finish",200,"{}")},Jo.timeout)}Un(Jo,Ho),Jo.prototype.close=function(){clearTimeout(this.to)},Jo.timeout=2e3;var Wo=Jo,Go=Jn.EventEmitter;function Bo(e,t){Go.call(this);var o=this,i=+new Date;this.xo=new t("GET",e),this.xo.once("finish",function(e,t){var n,r;if(200===e){if(r=+new Date-i,t)try{n=Pr.parse(t)}catch(e){}Ur.isObject(n)||(n={})}o.emit("finish",n,r),o.removeAllListeners()})}Un(Bo,Go),Bo.prototype.close=function(){this.removeAllListeners(),this.xo.close()};var zo=Bo,Xo=Jn.EventEmitter;function Yo(e){var n=this;Xo.call(this),this.ir=new zo(e,yr),this.ir.once("finish",function(e,t){n.ir=null,n.emit("message",Pr.stringify([e,t]))})}Un(Yo,Xo),Yo.transportName="iframe-info-receiver",Yo.prototype.close=function(){this.ir&&(this.ir.close(),this.ir=null),this.removeAllListeners()};var Zo=Yo,$o=Jn.EventEmitter;function Ko(t,n){var r=this;$o.call(this);var e=function(){var e=r.ifr=new Rr(Zo.transportName,n,t);e.once("message",function(e){if(e){var t;try{t=Pr.parse(e)}catch(e){return r.emit("finish"),void r.close()}r.emit("finish",t[0],t[1])}r.close()}),e.once("close",function(){r.emit("finish"),r.close()})};_n.document.body?e():Tn.attachEvent("load",e)}Un(Ko,$o),Ko.enabled=function(){return Rr.enabled()},Ko.prototype.close=function(){this.ifr&&this.ifr.close(),this.removeAllListeners(),this.ifr=null};var Qo=Ko,Vo=Jn.EventEmitter;function ei(e,t){var n=this;Vo.call(this),setTimeout(function(){n.doXhr(e,t)},0)}Un(ei,Vo),ei._getReceiver=function(e,t,n){return n.sameOrigin?new zo(t,yr):vr.enabled?new zo(t,vr):Ir.enabled&&n.sameScheme?new zo(t,Ir):Qo.enabled()?new Qo(e,t):new zo(t,Wo)},ei.prototype.doXhr=function(e,t){var n=this,r=Rn.addPath(e,"/info");this.xo=ei._getReceiver(e,r,t),this.timeoutRef=setTimeout(function(){n._cleanup(!1),n.emit("finish")},ei.timeout),this.xo.once("finish",function(e,t){n._cleanup(!0),n.emit("finish",e,t)})},ei.prototype._cleanup=function(e){clearTimeout(this.timeoutRef),this.timeoutRef=null,!e&&this.xo&&this.xo.close(),this.xo=null},ei.prototype.close=function(){this.removeAllListeners(),this._cleanup(!1)},ei.timeout=8e3;var ti=ei;function ni(e){(this._transport=e).on("message",this._transportMessage.bind(this)),e.on("close",this._transportClose.bind(this))}ni.prototype._transportClose=function(e,t){Ar.postMessage("c",Pr.stringify([e,t]))},ni.prototype._transportMessage=function(e){Ar.postMessage("t",e)},ni.prototype._send=function(e){this._transport.send(e)},ni.prototype._close=function(){this._transport.close(),this._transport.removeAllListeners()};var ri,oi=ni,ii=function(){};function ai(e,t,n){if(!(this instanceof ai))return new ai(e,t,n);if(arguments.length<1)throw new TypeError("Failed to construct 'SockJS: 1 argument required, but only 0 present");Fn.call(this),this.readyState=ai.CONNECTING,this.extensions="",this.protocol="",(n=n||{}).protocols_whitelist&&Ao.warn("'protocols_whitelist' is DEPRECATED. Use 'transports' instead."),this._transportsWhitelist=n.transports,this._transportOptions=n.transportOptions||{};var r=n.sessionId||8;if("function"==typeof r)this._generateSessionId=r;else{if("number"!=typeof r)throw new TypeError("If sessionId is used in the options, it needs to be a number or a function.");this._generateSessionId=function(){return In.string(r)}}this._server=n.server||In.numberString(1e3);var o=new Mn(e);if(!o.host||!o.protocol)throw new SyntaxError("The URL '"+e+"' is invalid");if(o.hash)throw new SyntaxError("The URL must not contain a fragment");if("http:"!==o.protocol&&"https:"!==o.protocol)throw new SyntaxError("The URL's scheme must be either 'http:' or 'https:'. '"+o.protocol+"' is not allowed.");if("https:"===Mo.protocol&&!("https:"===o.protocol))throw Error("SecurityError: An insecure SockJS connection may not be initiated from a page loaded over HTTPS");t?Array.isArray(t)||(t=[t]):t=[];var i=t.sort();i.forEach(function(e,t){if(!e)throw new SyntaxError("The protocols entry '"+e+"' is invalid.");if(t<i.length-1&&e===i[t+1])throw new SyntaxError("The protocols entry '"+e+"' is duplicated.")});var a=Rn.getOrigin(Mo.href);this._origin=a?a.toLowerCase():null,o.set("pathname",o.pathname.replace(/\/+$/,"")),this.url=o.href,ii("using url",this.url),this._urlInfo={nullOrigin:!gr.hasDomain(),sameOrigin:Rn.isOriginEqual(this.url,Mo.href),sameScheme:Rn.isSchemeEqual(this.url,Mo.href)},this._ir=new ti(this.url,this._urlInfo),this._ir.once("finish",this._receiveInfo.bind(this))}function si(e){return 1e3===e||3e3<=e&&e<=4999}Un(ai,Fn),ai.prototype.close=function(e,t){if(e&&!si(e))throw Error("InvalidAccessError: Invalid code");if(t&&123<t.length)throw new SyntaxError("reason argument has an invalid length");if(this.readyState!==ai.CLOSING&&this.readyState!==ai.CLOSED){this._close(e||1e3,t||"Normal closure",!0)}},ai.prototype.send=function(e){if("string"!=typeof e&&(e=""+e),this.readyState===ai.CONNECTING)throw Error("InvalidStateError: The connection has not been established yet");this.readyState===ai.OPEN&&this._transport.send(No(e))},ai.version="1.3.0",ai.CONNECTING=0,ai.OPEN=1,ai.CLOSING=2,ai.CLOSED=3,ai.prototype._receiveInfo=function(e,t){if(ii("_receiveInfo",t),this._ir=null,e){this._rto=this.countRTO(t),this._transUrl=e.base_url?e.base_url:this.url,e=Ur.extend(e,this._urlInfo),ii("info",e);var n=ri.filterToEnabled(this._transportsWhitelist,e);this._transports=n.main,ii(this._transports.length+" enabled transports"),this._connect()}else this._close(1002,"Cannot connect to server")},ai.prototype._connect=function(){for(var e=this._transports.shift();e;e=this._transports.shift()){if(ii("attempt",e.transportName),e.needBody&&(!_n.document.body||void 0!==_n.document.readyState&&"complete"!==_n.document.readyState&&"interactive"!==_n.document.readyState))return ii("waiting for body"),this._transports.unshift(e),void Tn.attachEvent("load",this._connect.bind(this));var t=this._rto*e.roundTrips||5e3;this._transportTimeoutId=setTimeout(this._transportTimeout.bind(this),t),ii("using timeout",t);var n=Rn.addPath(this._transUrl,"/"+this._server+"/"+this._generateSessionId()),r=this._transportOptions[e.transportName];ii("transport url",n);var o=new e(n,this._transUrl,r);return o.on("message",this._transportMessage.bind(this)),o.once("close",this._transportClose.bind(this)),o.transportName=e.transportName,void(this._transport=o)}this._close(2e3,"All transports failed",!1)},ai.prototype._transportTimeout=function(){ii("_transportTimeout"),this.readyState===ai.CONNECTING&&(this._transport&&this._transport.close(),this._transportClose(2007,"Transport timed out"))},ai.prototype._transportMessage=function(e){ii("_transportMessage",e);var t,n=this,r=e.slice(0,1),o=e.slice(1);switch(r){case"o":return void this._open();case"h":return this.dispatchEvent(new Lo("heartbeat")),void ii("heartbeat",this.transport)}if(o)try{t=Pr.parse(o)}catch(e){ii("bad json",o)}if(void 0!==t)switch(r){case"a":Array.isArray(t)&&t.forEach(function(e){ii("message",n.transport,e),n.dispatchEvent(new Fo(e))});break;case"m":ii("message",this.transport,t),this.dispatchEvent(new Fo(t));break;case"c":Array.isArray(t)&&2===t.length&&this._close(t[0],t[1],!0)}else ii("empty payload",o)},ai.prototype._transportClose=function(e,t){ii("_transportClose",this.transport,e,t),this._transport&&(this._transport.removeAllListeners(),this._transport=null,this.transport=null),si(e)||2e3===e||this.readyState!==ai.CONNECTING?this._close(e,t):this._connect()},ai.prototype._open=function(){ii("_open",this._transport.transportName,this.readyState),this.readyState===ai.CONNECTING?(this._transportTimeoutId&&(clearTimeout(this._transportTimeoutId),this._transportTimeoutId=null),this.readyState=ai.OPEN,this.transport=this._transport.transportName,this.dispatchEvent(new Lo("open")),ii("connected",this.transport)):this._close(1006,"Server lost session")},ai.prototype._close=function(t,n,r){ii("_close",this.transport,t,n,r,this.readyState);var o=!1;if(this._ir&&(o=!0,this._ir.close(),this._ir=null),this._transport&&(this._transport.close(),this._transport=null,this.transport=null),this.readyState===ai.CLOSED)throw Error("InvalidStateError: SockJS has already been closed");this.readyState=ai.CLOSING,setTimeout(function(){this.readyState=ai.CLOSED,o&&this.dispatchEvent(new Lo("error"));var e=new Uo("close");e.wasClean=r||!1,e.code=t||1e3,e.reason=n,this.dispatchEvent(e),this.onmessage=this.onclose=this.onerror=null,ii("disconnected")}.bind(this),0)},ai.prototype.countRTO=function(e){return 100<e?4*e:300+e};var ci,ui,li,di,pi=(ri={filterToEnabled:function(t,n){var r={main:[],facade:[]};return t?"string"==typeof t&&(t=[t]):t=[],ci.forEach(function(e){e&&("websocket"===e.transportName&&!1===n.websocket||t.length&&-1==t.indexOf(e.transportName)||e.enabled(n)&&(r.main.push(e),e.facadeTransport&&r.facade.push(e.facadeTransport)))}),r}},ui=ai,di={},(ci=so).forEach(function(e){e.facadeTransport&&(di[e.facadeTransport.transportName]=e.facadeTransport)}),di[Zo.transportName]=Zo,ui.bootstrap_iframe=function(){var s;Ar.currentWindowId=Mo.hash.slice(1),Tn.attachEvent("message",function(e){if(e.source===parent&&(void 0===li&&(li=e.origin),e.origin===li)){var t;try{t=Pr.parse(e.data)}catch(e){return}if(t.windowId===Ar.currentWindowId)switch(t.type){case"s":var n;try{n=Pr.parse(t.data)}catch(e){break}var r=n[0],o=n[1],i=n[2],a=n[3];if(r!==ui.version)throw Error('Incompatible SockJS! Main site uses: "'+r+'", the iframe: "'+ui.version+'".');if(!Rn.isOriginEqual(i,Mo.href)||!Rn.isOriginEqual(a,Mo.href))throw Error("Can't connect to different domain from within an iframe. ("+Mo.href+", "+i+", "+a+")");s=new oi(new di[o](i,a));break;case"m":s._send(t.data);break;case"c":s&&s._close(),s=null}}}),Ar.postMessage("s")},ai);"_sockjs_onload"in _n&&setTimeout(_n._sockjs_onload,1);var fi=function(e,t){var n,r,o,i,a,s,c,u,l,d=void 0===t?{}:t,p=d.query,f=d.transports,h=void 0===f?["websocket","xhr-polling"]:f,v=e+(p?"?"+k(p):""),m=R(),y=(o=void 0===(r=(n={min:1e3,max:5e3,jitter:.5}).min)?1e3:r,a=void 0===(i=n.max)?5e3:i,c=void 0===(s=n.jitter)?.5:s,u=0,{duration:function(){var e=o*Math.pow(2,u++);if(c){var t=Math.random(),n=Math.floor(t*c*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,a)},reset:function(){u=0}}),g=3,_=null,b=function(){g=1,y.reset(),m.emit("connect")},w=function(){g=3,_=null,m.emit("disconnect"),O()},E=function(e){m.emit("message",e.data)},I=function(){m.emit("heartbeat")},T=function(){var e;(g=3,_)&&((e=_).removeEventListener("open",b),e.removeEventListener("close",w),e.removeEventListener("message",E),e.removeEventListener("heartbeat",I),_.close(),_=null)},x=function(){var e;_=new pi(v,void(g=0),{transports:h}),(e=_).addEventListener("open",b),e.addEventListener("close",w),e.addEventListener("message",E),e.addEventListener("heartbeat",I)},O=function(e){void 0===e&&(e=y.duration()),clearTimeout(l),0!==e?l=setTimeout(x,e):x()},S={connect:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return""+e},t}(function(){if(3!==g)throw Error("Socket is already open or connecting.");clearTimeout(l),x()}),destroy:function(){S.off(),S.disconnect()},disconnect:function(){g=3,clearTimeout(l),T()},reconnect:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return""+t},e}(function(e){T(),O(e)}),emit:function(e){if(1!==g)throw Error("Socket is not connected.");_.send(e)},getReadyState:function(){return g},on:m.on,off:m.off};return S},hi=function(e,t){var n,r,o,i,a,s=void 0===t?{}:t,c=s.query,u=void 0===c?{}:c,l=s.rescheduleTimeout,d=void 0===l?3e4:l,p=s.transports,f=s.emitter,h=void 0===f?R():f,v=fi(e,{query:S({bh:I()},u),transports:p}),m=(o=x,{cancel:function(){clearTimeout(r),o=x},check:function(){var t=We();return o=t.resolve,r=setTimeout(function(){var e=Error("Timeout.");e.code="TIMEOUT",t.reject(e)},2e3),t.promise},resolve:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return""+e},t}(function(){clearTimeout(r),o()})}),y=function(){return 1===v.getReadyState()},g=function(e){v.emit(JSON.stringify(e)),b()},_=function(){g({action:"ping"})},b=function(){clearTimeout(n),n=setTimeout(_,d)},w=function(){m.cancel(),clearTimeout(n)};return i=v,a=h,["connect","disconnect"].forEach(function(t){i.on(t,function(e){a.emit(t,e)})}),v.on("connect",b),v.on("disconnect",w),v.on("heartbeat",_),v.on("message",function(e){m.resolve();var t=JSON.parse(e);"ping"!==t.action&&h.emit("message",t)}),"undefined"!=typeof window&&void 0!==window.addEventListener&&(window.addEventListener("online",function(){y()&&(m.check().then(function(){m.cancel(),h.emit("connection_recovered")},function(e){if(m.cancel(),"TIMEOUT"!==e.code)throw e;v.reconnect()}),_())}),window.addEventListener("offline",function(){m.cancel(),y()&&h.emit("connection_unstable")})),S({},v,{destroy:function(){w(),v.destroy()},disconnect:function(){w(),v.disconnect()},reconnect:function(e){w(),v.reconnect(e)},emit:g,on:h.on,off:h.off})},vi=function(e,t){var n=e.getState(),r=et(n)+"/rtm/sjs";return hi(r,{query:{license_id:n.licenseId},emitter:t})},mi=function(e){return{uniqueId:e.unique_id}},yi=function(e){return{chatId:e.chat_id,user:dn(e.user),present:e.user.present}},gi=function(e){return{chatId:e.chat_id,userId:e.user_id}},_i=function(e){return e.map(function(e){switch(e.type){case"group_chooser":return S({},e,{options:e.options.map(function(e){var t=e.group_id;return S({},m(e,["group_id"]),{groupId:t})})});case"rating":var t=e.comment_label;return S({},m(e,["comment_label"]),{commentLabel:t});default:return e}})},bi=function(e){return e.enabled?S({},e,{form:"id"in e.form.fields[0]?{id:e.form.id,fields:_i(e.form.fields)}:{id:"ticket",fields:(t=e.form.fields,n=t.map(function(e,t){return S({},e,{id:t+""})}),_i(n))}}):e;var t,n},wi=function(e){switch(e.action){case at:return{action:e.action,payload:{chatId:e.payload.chat_id}};case"chat_properties_deleted":return{action:e.action,payload:(b=e.payload,{chatId:b.chat_id,properties:b.properties})};case"chat_properties_updated":return{action:e.action,payload:(_=e.payload,{chatId:_.chat_id,properties:_.properties})};case"chat_transferred":return{action:e.action,payload:(y=e.payload,g={chatId:y.chat_id,threadId:y.thread_id,transferredTo:S({},y.transferred_to.agent_ids&&{agentIds:y.transferred_to.agent_ids},y.transferred_to.group_ids&&{groupIds:y.transferred_to.group_ids}),queue:y.queue?ln(y.queue):null},S({},g,"manual"===y.reason?{reason:y.reason,requesterId:y.requester_id}:{reason:y.reason}))};case ct:case st:return{action:e.action,payload:e.payload};case"customer_page_updated":return{action:e.action,payload:(m=e.payload,{url:m.url,title:m.title,timestamp:1e3*m.timestamp})};case"customer_updated":return{action:e.action,payload:(v=e.payload,{customer:S({id:v.customer.id},an(v.customer))})};case"event_properties_deleted":return{action:e.action,payload:(h=e.payload,{chatId:h.chat_id,threadId:h.thread_id,eventId:h.event_id,properties:h.properties})};case"event_properties_updated":return{action:e.action,payload:(f=e.payload,{chatId:f.chat_id,threadId:f.thread_id,eventId:f.event_id,properties:f.properties})};case"event_updated":return{action:e.action,payload:(d=e.payload,p=d.thread_id,{chatId:d.chat_id,threadId:p,event:Vt(p,d.event)})};case"events_marked_as_seen":return{action:e.action,payload:(l=e.payload,{chatId:l.chat_id,userId:l.user_id,seenUpTo:l.seen_up_to})};case"greeting_accepted":case"greeting_canceled":return{action:e.action,payload:mi(e.payload)};case ut:return{action:e.action,payload:(u=e.payload,{chat:on(u.chat)})};case lt:return{action:e.action,payload:(c=e.payload,{chatId:c.chat_id,event:Vt(c.thread_id,c.event)})};case"incoming_greeting":return{action:e.action,payload:(s=e.payload,en(s))};case dt:return{action:e.action,payload:e.payload};case"incoming_rich_message_postback":return{action:e.action,payload:(a=e.payload,{userId:a.user_id,chatId:a.chat_id,threadId:a.thread_id,eventId:a.event_id,postback:a.postback})};case pt:return{action:e.action,payload:(o=e.payload,i=o.typing_indicator,{chatId:o.chat_id,typingIndicator:{authorId:i.author_id,isTyping:i.is_typing}})};case ft:return{action:e.action,payload:(r=e.payload,{chatId:r.chat_id,threadId:r.thread_id,queue:un(r.queue)})};case"thread_properties_deleted":return{action:e.action,payload:(n=e.payload,{chatId:n.chat_id,threadId:n.thread_id,properties:n.properties})};case ht:return{action:e.action,payload:(t=e.payload,{chatId:t.chat_id,threadId:t.thread_id,properties:t.properties})};case vt:return{action:e.action,payload:yi(e.payload)};case mt:return{action:e.action,payload:gi(e.payload)};case"chat_user_added":return{action:vt,payload:yi(e.payload)};case"chat_user_removed":return{action:mt,payload:gi(e.payload)}}var t,n,r,o,i,a,s,c,u,l,d,p,f,h,v,m,y,g,_,b},Ei=function(e){var t,n,r,o,i,a,s,c,u,l,d,p,f,h,v,m,y,g,_,b,w,E=e.request,I=e.response;switch(I.action){case ue:case de:case fe:case he:case ve:return{action:I.action,payload:Gt};case me:return{action:I.action,payload:(w=I.payload,on(w))};case ye:return{action:I.action,payload:cn(I.payload)};case ge:return{action:I.action,payload:bi(I.payload)};case _e:return{action:I.action,payload:(b=I.payload,{id:b.id,type:"agent",name:b.name,avatar:b.avatar,jobTitle:b.job_title,isBot:b.is_bot})};case be:return{action:I.action,payload:(g=I.payload,_={url:g.url},g.title&&(_.title=g.title),g.description&&(_.description=g.description),g.image_url&&(_.imageUrl="https://"+g.image_url,g.image_width&&g.image_height&&(_.imageWidth=g.image_width,_.imageHeight=g.image_height)),_)};case we:return{action:I.action,payload:(l=I.payload,y=l.chats_summary.map(function(e){var t=e.last_thread_created_at,n=e.last_thread_id,r=e.last_event_per_type,o=e.properties,i=void 0===o?{}:o,a=e.users,s={id:e.id,active:e.active,access:tn(e.access),properties:i,users:a.map(dn),lastThreadId:n||null,lastThreadCreatedAt:t||null,eventsSeenUpToMap:nn(a)};if(!r)return s;s.lastEventsPerType=T(function(e){return Vt(e.thread_id,e.event)},r);var c,u=r,l=Object.keys(u).map(function(e){return u[e]}),d=0<(c=l.sort(function(e,t){return e.thread_id===t.thread_id?j(e.event.created_at,t.event.created_at):j(e.thread_created_at,t.thread_created_at)})).length?c[c.length-1]:null;return d&&(s.lastEvent=s.lastEventsPerType[d.event.type]),s}),{chatsSummary:O(function(e){var t=e.lastEvent;return-1*(void 0!==t?t.timestamp:e.order)},y),totalChats:l.total_chats,users:(d=function(e){return e.id},h=function(e){return e.users},v=y,p=(m=[]).concat.apply(m,v.map(h)),f=[],p.filter(function(e){var t=d(e);return-1==f.indexOf(t)&&(f.push(t),!0)})),previousPageId:l.previous_page_id||null,nextPageId:l.next_page_id||null})};case Ee:return{action:I.action,payload:(u=I.payload,u.groups_status)};case Ie:return{action:I.action,payload:(s=E,c=I.payload,{threads:c.threads.map(function(e){return rn(s.payload.chat_id,e)}),previousPageId:c.previous_page_id||null,nextPageId:c.next_page_id||null})};case"login":return{action:I.action,payload:(t=I.payload,o=t.__priv_dynamic_config,i=t.chats,a=t.greeting||o.greeting,S({dynamicConfig:o,customer:cn(t.customer),availability:(n=o,r=n.online_groups_ids,r&&-1!=r.indexOf(n.customer_groups.monitoring.id)?"online":"offline"),chats:i.map(function(e){return{id:e.chat_id,active:"has_active_thread"in e?e.has_active_thread:t.has_active_thread,hasUnreadEvents:e.has_unread_events}})},a&&{greeting:en(a)}))};case Te:case Se:case je:case Oe:case Ce:case Ne:case Pe:case Ae:case qe:return{action:I.action,payload:Gt}}},Ii=function(O,e){var t=O.dispatch;return e.on("connect",function(){t({type:V})}),e.on("message",function(e){if("response"===e.type){if(!e.success)return p=(u=O).dispatch,f=(l=e).request_id,h=l.payload,v=Ze((0,u.getState)(),f),void p({type:Y,payload:{id:f,reject:v.reject,error:(d=h.error,{code:d.type.toUpperCase(),message:d.message})}});switch(e.action){case le:case pe:case xe:case ke:return;default:return r=(t=O).dispatch,o=(n=e).request_id,i=Ze((0,t.getState)(),o),a=i.promise,s=i.resolve,c=Ei({request:i.request,response:n}),void r({type:Z,payload:S({id:o,promise:a,resolve:s},c)})}}var t,n,r,o,i,a,s,c,u,l,d,p,f,h,v,m,y,g,_,b,w,E,I,T,x;if("request_id"in e)switch(e.action){case at:case ut:case lt:return g=(m=O).dispatch,_=(y=e).request_id,b=Ze((0,m.getState)(),_),w=b.promise,E=b.resolve,I=wi(y),void g({type:z,payload:S({id:_,promise:w,resolve:E},I)})}T=O,(x=wi(e))&&T.dispatch({type:B,payload:x})}),e.on("disconnect",function(){Jt(O,ie),Ye(O.getState())===Ge&&O.dispatch({type:ee})}),e.on("connection_unstable",function(){t({type:ne})}),e.on("connection_recovered",function(){t({type:te})}),e.off},Ti="incorrect requester structure",xi=function(e,t){return e.length?e+"\n"+t:t},Oi=function(d,e,t){var p=t.filledForm,f=t.groupId,h=t.timeZone;return e.getToken().then(function(e){var t=d.getState();null===$e(t)&&d.dispatch(Pt(e.entityId));var n,r,o,i,a,s,c,u=Ve(t)+"/v2/tickets/new",l=(o=(r={fields:p.fields,customerId:e.entityId,groupId:f,timeZone:h}).fields,c=S({licence_id:(n=t).licenseId,ticket_message:"",offline_message:"",visitor_id:r.customerId,requester:{}},"number"==typeof(a=void 0===(i=r.groupId)?n.groupId:i)&&{group:a},n.page&&{source:{url:n.page.url}},(s=r.timeZone)&&{timezone:s}),o.reduce(function(e,t){switch(t.type){case"subject":var n=t.answer,r=n?t.label+" "+n:t.label;return n&&(e.subject=n),e.offline_message=xi(e.offline_message,r),e;case"name":var o=t.answer,i=o?t.label+" "+o:t.label;return o&&(e.requester.name=o),e.offline_message=xi(e.offline_message,i),e;case"email":var a=t.answer,s=a?t.label+" "+a:t.label;return e.requester.mail=a,e.offline_message=xi(e.offline_message,s),e;case"question":case"textarea":var c=t.answer,u=c?t.label+" "+c:t.label;return e.offline_message=xi(e.offline_message,u),e.ticket_message=xi(e.ticket_message,u),e;case"radio":case"select":var l=t.answer&&t.answer.label,d=l?t.label+" "+l:t.label;return e.offline_message=xi(e.offline_message,d),e.ticket_message=xi(e.ticket_message,d),e;case"checkbox":var p=t.answers&&t.answers.map(function(e){return e.label}).join(", "),f=p?t.label+" "+p:t.label;return e.offline_message=xi(e.offline_message,f),e.ticket_message=xi(e.ticket_message,f),e;default:return e}},c));return Ht(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}).then(function(e){if(e.ok)return e.json().then(function(e){return S({},e,{text:l.ticket_message})});if(400!==e.status&&422!==e.status)throw Error();var t=function(e){if(!e||!e.errors)throw Error();var t=e.errors[0];if(Object.keys(t)[0]===Ti)throw it({message:t[Ti][0],code:"VALIDATION"});throw Error()};return e.json().then(t,t)})})},Si="UPLOAD_FAILED",ji=function(e,i,t){var n=void 0===t?{}:t,a=n.headers,r=n.method,s=void 0===r?"POST":r,c=n.onProgress,o=n.withCredentials,u=void 0!==o&&o,l=new XMLHttpRequest;return{promise:new Promise(function(n,r){var t,o;"function"==typeof c&&(l.upload.onprogress=function(e){c(e.loaded/e.total)}),l.onload=function(){var e;try{e=JSON.parse(l.response)}catch(t){e=l.response}if(l.status<200||300<=l.status){var t=Error("Upload failed.");t.code=Si,t.response=e,r(t)}else n(e)},l.onerror=function(){var e=Error("Upload failed.");e.code=Si,r(e)},l.onabort=function(){var e=Error("Upload canceled.");e.code="UPLOAD_CANCELED",r(e)},l.open(s,e),l.withCredentials=u,a&&Object.keys(a).forEach(function(e){return l.setRequestHeader(e,a[e])}),l.send((t=i,o=new FormData,Object.keys(t).forEach(function(e){return o.append(e,t[e])}),o))}),cancel:function(){l.abort()}}},ki=1048576,Ci=function(e){if(10485760<e.size)throw it({message:"The file is too big (max size is "+function(e,t){if(void 0===t&&(t=2),e<1024)return e+" b";var n=e/1024;if(e<ki)return n.toFixed(t)+" kb";var r=n/1024;return e<1073741824?r.toFixed(t)+" MB":(r/1024).toFixed(t)+" GB"}(10485760)+").",code:"TOO_BIG_FILE"})},Ni=function(e){var t=e.licenseId,n=e.eventName;if("production"!==e.env)return Promise.resolve();var r,o,i={licence_id:t,event_id:"chat_widget_customer_sdk",message:JSON.stringify({event_name:n,severity:"Informational",sdkVersion:"2.0.4"})};return r="https://queue.livechatinc.com/logs",o=k(i),new Promise(function(e){var t=new Image;t.src=r+"?"+o,t.onerror=x,t.onload=function(){return e()}})},Pi="LISTENER_IDENTITY",Ai={},qi=function(e,s){void 0===s&&(s="");var r=Object.keys(e);return r.map(function(i){var a=e[i];return function(){for(var e,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];(e=console).info.apply(e,[s+"."+i+"() ===>"].concat(n));var o=a.apply(void 0,n);return o&&"function"==typeof o.then&&o.then(function(e){console.info(s+"."+i+"() <===",e)}).catch(function(e){console.error(s+"."+i+"() <===",e)}),o}}).reduce(function(e,t,n){return e[r[n]]=t,e},{})},Li=function(t,n,r){if(void 0===r[Pi]&&Object.defineProperty(r,Pi,{value:{}}),r[Pi][n])return Ai[r[Pi][n]];var e=function(e){console.info("."+t+'("'+n+'") <===',e),r(e)},o=p(Ai);return Ai[r[Pi][n]=o]=e};e.init=function(r,o){void 0===o&&(o="production"),A(r);var e,t,n,i=r.autoConnect,a=void 0===i||i,s=r.customerDataProvider,c=m(r,["autoConnect","customerDataProvider"]),p=ot(S({},c,{env:o})),u=R(),l=(e=p,t=R(),n=vi(e,t),S({},Object.keys(n).reduce(function(e,t){return e[t]=function(){var e;return(e=n)[t].apply(e,arguments)},e},{}),{reinitialize:function(){n.disconnect(),(n=vi(e,t)).connect()}})),f=q(c,o);p.addSideEffectsHandler(gn({emitter:u,socket:l,auth:f,customerDataProvider:s})),Ii(p,l);var d=At.bind(null,p),h=function(){p.dispatch({type:re})},v=Object.freeze({acceptGreeting:function(e){return d(Ct(ue,{greeting_id:e.greetingId,unique_id:e.uniqueId}))},activateChat:function(e){return Ni({env:o,licenseId:r.licenseId,eventName:"chat_started"}),d(Ct(le,S({},n=Tt(t=e),{chat:S({},n.chat,{id:t.chat.id})})));var t,n},auth:f,cancelGreeting:function(e){return d(Ct(de,{unique_id:e.uniqueId}))},cancelRate:function(e){var n=e.chatId,t=e.properties,r=void 0===t?["score"]:t;return v.listThreads({chatId:n}).then(function(e){var t=e.threads;if(!t.length)throw it({message:'There is no thread in "'+n+'".',code:ce});return v.deleteThreadProperties({chatId:n,threadId:t[0].id,properties:{rating:r}})})},connect:h,deactivateChat:function(e){return d(Ct(pe,{chat_id:e.chatId}))},deleteChatProperties:function(e){return d(Ct(fe,{chat_id:e.chatId,properties:e.properties}))},deleteEventProperties:function(e){return d(Ct(he,{chat_id:e.chatId,thread_id:e.threadId,event_id:e.eventId,properties:e.properties}))},deleteThreadProperties:function(e){return d(Ct(ve,{chat_id:e.chatId,thread_id:e.threadId,properties:e.properties}))},destroy:function(){p.dispatch(St("manual"))},disconnect:function(){p.dispatch({type:W})},getChat:function(e){return d(Ct(me,{chat_id:e.chatId,thread_id:e.threadId}))},getChatHistory:function(e){var t,i,a,n;return t=v,i=e.chatId,a={status:"idle",queuedTasks:[],nextPageId:null},n=function r(o,n){switch(a.status){case"idle":return a.status="fetching",void t.listThreads({chatId:i,minEventsCount:25,pageId:a.nextPageId||void 0}).then(function(e){var t=e.threads;a.nextPageId=e.nextPageId,a.nextPageId?(a.status="idle",o({value:{threads:[].concat(t).reverse()},done:!1})):(a.status="done",o({value:{threads:[].concat(t).reverse()},done:!0}));var n=a.queuedTasks.shift();n&&r(n.resolve,n.reject)},function(t){var e=a.queuedTasks;a.status="idle",a.queuedTasks=[],n(t),e.forEach(function(e){return e.reject(t)})});case"fetching":return void a.queuedTasks.push({resolve:o,reject:n});case"done":return void o({value:void 0,done:!0})}},{next:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return""+e},t}(function(){return new Promise(n)})}},getCustomer:function(){return d(Ct(ye,{}))},getForm:function(e){return d(Ct(ge,{group_id:e.groupId,type:e.type}))},getPredictedAgent:function(e){void 0===e&&(e={});var t=e.groupId;return d(Ct(_e,"number"==typeof t?{group_id:t}:{}))},getUrlInfo:function(e){return d(Ct(be,{url:e.url}))},listChats:function(e){var t=void 0===e?{}:e,n=t.limit,r=void 0===n?10:n,o=t.pageId;return 25<r?Promise.reject(Error("Specified limit is too high (max 25).")):d(Ct(we,{limit:r,page_id:o}))},listGroupStatuses:function(e){var t=(void 0===e?{}:e).groupIds;return d(Ct(Ee,t?{group_ids:t}:{all:!0}))},listThreads:function(e){var t=e.sortOrder;return d(Ct(Ie,{chat_id:e.chatId,sort_order:void 0===t?"desc":t,limit:e.limit,page_id:e.pageId,min_events_count:e.minEventsCount}))},markEventsAsSeen:function(e){return d(Ct(Te,{chat_id:e.chatId,seen_up_to:e.seenUpTo}))},on:u.on,once:u.once,off:u.off,rateChat:function(e){var n=e.chatId,r=e.rating;return v.listThreads({chatId:n}).then(function(e){var t=e.threads;if(!t.length)throw it({message:'There is no thread in "'+n+'".',code:ce});return v.updateThreadProperties({chatId:n,threadId:t[0].id,properties:{rating:r}})})},sendEvent:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return""+t},e}(function(e){return d((n=(t=e).attachToLastThread,r={chat_id:t.chatId,event:It(t.event)},n&&(r.attach_to_last_thread=!0),Ct(xe,r)));var t,n,r}),sendTicketForm:function(e){return Oi(p,f,e)},sendRichMessagePostback:function(e){return d(Ct(Oe,{chat_id:e.chatId,event_id:e.eventId,thread_id:e.threadId,postback:e.postback}))},setCustomerSessionFields:function(e){return d(Ct(je,{session_fields:xt(e.sessionFields)}))},setSneakPeek:function(e){var t=e.chatId,n=e.sneakPeekText,r=p.getState();Ke(r,t)&&Qe(r)&&d(Ct(Se,{chat_id:t,sneak_peek_text:n})).catch(x)},startChat:function(e){return void 0===e&&(e={}),Ni({env:o,licenseId:r.licenseId,eventName:"chat_started"}),d(Ct(ke,Tt(e)))},updateChatProperties:function(e){return d(Ct(Ce,{chat_id:e.chatId,properties:e.properties}))},updateCustomer:function(e){return d(Ct(Ne,Ot(e)))},updateCustomerPage:function(e){p.dispatch({type:oe,payload:y(["title","url"],e)})},updateEventProperties:function(e){return d(Ct(Ae,{chat_id:e.chatId,event_id:e.eventId,thread_id:e.threadId,properties:e.properties}))},updateThreadProperties:function(e){return d(Ct(qe,{chat_id:e.chatId,thread_id:e.threadId,properties:e.properties}))},uploadFile:function(e){return s=(t={auth:f,store:p}).auth,c=t.store,u=(n=e).file,l=n.onProgress,d=!1,{promise:new Promise(function(t,n){Ci(u);var e=c.getState(),r=k({license_id:e.licenseId}),o=et(e)+"/action/upload_file?"+r,i={file:u};s.getToken().then(function(e){d?n(Error("Upload cancelled.")):(a=ji(o,i,{headers:{Authorization:e.tokenType+" "+e.accessToken},onProgress:l})).promise.then(t,function(e){if(e.response){var t=e.response.error;n(it({message:t.message,code:t.type.toUpperCase()}))}else n(e)})})}),cancel:function(){d||(d=!0,a&&a.cancel())}};var t,n,a,s,c,u,l,d}});return a?h():p.dispatch({type:D,payload:{sessionFields:"function"==typeof s?s().sessionFields:{}}}),v},e.debug=function(e){var t=e;console.warn("You probably do not want to use debug(customerSDK) in your production environment.");var n=t.on,r=t.once,o=t.off,a=t.getChatHistory,i=t.auth,s=m(t,["on","once","off","getChatHistory","auth"]),c=qi(s);return Object.freeze(S({auth:Object.freeze(qi(i,".auth"))},c,{getChatHistory:function(){for(var e,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];(e=console).info.apply(e,[".getChatHistory()"].concat(n));var o=a.apply(void 0,n),i="history.next()";return{next:function(){var e;(e=console).info.apply(e,[i+" ===>"].concat(n));var t=o.next();return t.then(function(e){var t;(t=console).info.apply(t,[i+" <==="].concat(n,[e]))}).catch(function(e){var t;(t=console).error.apply(t,[i+" <==="].concat(n,[e]))}),t}}},off:function(e,t){console.info('.off("'+e+'", '+(t.name||"anonymous")+")");var n=t;void 0!==t[Pi]&&(n=Ai[t[Pi][e]]),o(e,n)},on:function(e,t){n(e,Li("on",e,t))},once:function(e,t){r(e,Li("once",e,t))}}))},e.parseFile=Xt,e.parseFilledForm=Yt,e.parseMessage=Zt,e.parseRichMessage=Kt,e.parseSystemMessage=Qt,e.parseEvent=Vt,e.parseGreeting=en,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CustomerSDK={})}(this,(function(e){"use strict";function t(){return(t=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function n(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;a.length>r;r++)0>t.indexOf(n=a[r])&&(o[n]=e[n]);return o}function r(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}var o="__test_storage_support__",a="@@test",i=function(){var e=Object.create(null);return{getItem:function(t){var n=e[t];return"string"==typeof n?n:null},setItem:function(t,n){e[t]=n},removeItem:function(t){delete e[t]},clear:function(){e=Object.create(null)}}}(),c=function(e){void 0===e&&(e="local");try{var t="session"===e?window.sessionStorage:window.localStorage;return t.setItem(o,a),t.getItem(o)!==a?!1:(t.removeItem(o),!0)}catch(e){return!1}}()?window.localStorage:i,s=function(e,t){return new Promise((function(n){return n(c.setItem(e,t))}))},u=function(e){return new Promise((function(t){return t(c.getItem(e))}))},d=function(e){return new Promise((function(t){return t(c.removeItem(e))}))},p={}.hasOwnProperty;function l(e,t){return p.call(t,e)}function f(e,t){var n;return(n=[]).concat.apply(n,t.map(e))}var h=Array.isArray;function v(e,t){return Object.keys(t).reduce((function(n,r){return n[r]=e(t[r]),n}),{})}function _(e){return e}function y(e){var t=Math.random().toString(36).substring(2);return l(t,e)?y(e):t}function m(e,t){return-1!==t.indexOf(e)}function g(){}function I(e){return Object.keys(e).map((function(t){return e[t]}))}function E(e,t){return e.reduce((function(e,n){return l(n,t)&&(e[n]=t[n]),e}),{})}var b=function(e){return Object.keys(e).map((function(t){return[t,e[t]]}))},T=function(e,t){return e===t?0:t>e?-1:1};var w=function(e){return b(e).map((function(e){return e.map(encodeURIComponent).join("=")})).join("&")},O=/[^:]+:\/\/[^(/|?)\s]+/,S=function(e){var t=e.match(O);return t&&t[0]},k=function(e){return e.replace(/\w/g,"$&[\\r\\n\\t]*")};RegExp("^[\0-]*("+k("javascript")+"|"+k("data")+"):","i");function P(e,t){return t=t||{},new Promise((function(n,r){var o=new XMLHttpRequest,a=[],i=[],c={},s=function(){return{ok:2==(o.status/100|0),statusText:o.statusText,status:o.status,url:o.responseURL,text:function(){return Promise.resolve(o.responseText)},json:function(){return Promise.resolve(o.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([o.response]))},clone:s,headers:{keys:function(){return a},entries:function(){return i},get:function(e){return c[e.toLowerCase()]},has:function(e){return e.toLowerCase()in c}}}};for(var u in o.open(t.method||"get",e,!0),o.onload=function(){o.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(e,t,n){a.push(t=t.toLowerCase()),i.push([t,n]),c[t]=c[t]?c[t]+","+n:n})),n(s())},o.onerror=r,o.withCredentials="include"==t.credentials,t.headers)o.setRequestHeader(u,t.headers[u]);o.send(t.body||null)}))}var C=function(e){var t=e.code,n=Error(e.message);return n.code=t,n},N=function(e,t){if("identity_exception"in e)throw C({code:"SSO_IDENTITY_EXCEPTION",message:e.identity_exception});if("oauth_exception"in e)throw C({code:"SSO_OAUTH_EXCEPTION",message:e.oauth_exception});return{accessToken:e.access_token,entityId:e.entity_id,expiresIn:1e3*e.expires_in,tokenType:e.token_type,creationDate:Date.now(),licenseId:t}},x="https://accounts.livechatinc.com",j=function(e,t){return""+("production"===t?x:x.replace("accounts.","accounts."+t+"."))+function(e){return(e.uniqueGroups?"/licence/g"+e.licenseId+"_"+e.groupId:"")+"/customer"}(e)},D="https://accounts.livechatinc.com",q="@livechat/customer-auth",R=function(e,t){var n=function(e,t){return{license_id:e.licenseId+"",flow:"button",response_type:"token",client_id:e.clientId,redirect_uri:t,post_message_uri:t,state:q}}(e,S(window.location+"")+window.location.pathname),r=document.createElement("iframe");return r.style.display="none",r.setAttribute("src",j(e,t)+"?"+w(n)),r};function A(e,t){var n=e.licenseId,r=function(e){return"production"===e?D:D.replace("accounts.","accounts."+e+".")}(t);return new Promise((function(o,a){var i=R(e,t),c=function(){var e,t;(t=(e=i).parentNode)&&t.removeChild(e),window.removeEventListener("message",u,!1)},s=setTimeout((function(){c(),a(C({message:"Request timed out.",code:"REQUEST_TIMEOUT"}))}),15e3),u=function(e){var t=e.data;if(e.origin===r&&function(e){return e&&e.state===q}(t)){clearTimeout(s),c();try{o(N(t,n))}catch(e){a(e)}}};window.addEventListener("message",u,!1),new Promise((function(e){!function t(){document.body?e(document.body):setTimeout(t,100)}()})).then((function(e){e.appendChild(i)}))}))}var M=function(e){if("number"!=typeof e.licenseId||"string"!=typeof e.clientId)throw Error("You need to pass valid configuration object: { licenseId, clientId }.")},U=function(e,t){M(e);var n="@@lc_auth_token:"+e.licenseId+(e.uniqueGroups?":"+e.groupId:""),r=null,o=null,a=u(n).then((function(e){null!==a&&(a=null,e&&(o=JSON.parse(e)))})),i=function(){return r=function(e,t){return e.uniqueGroups?A(e,t):P(j(e,t)+"/token",{method:"POST",credentials:"include",body:JSON.stringify({response_type:"token",grant_type:"cookie",client_id:e.clientId,license_id:e.licenseId,redirect_uri:S(window.location+"")+window.location.pathname})}).then((function(e){return e.json()})).then((function(t){return N(t,e.licenseId)}))}(e,t).then((function(e){return r=null,s(n,JSON.stringify(e)),o=e,e}),(function(e){throw r=null,e}))};return{getFreshToken:i,getToken:function e(){return r||(o&&!function(e){var t=e.creationDate,n=e.expiresIn;return Date.now()>=t+n}(o)?Promise.resolve(o):a?a.then(e):i())},hasToken:function e(){return a?a.then(e):Promise.resolve(!!o)},invalidate:function(){return o=null,a=null,d(n)}}};var L=function(){var e,r={all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map((function(e){e(n)})),(r=e.get("*"))&&r.slice().map((function(e){e(t,n)}))}},o=r.all,a=n(r,["all"]);return t({},a,{off:function(e,t){e?a.off(e,t):o.clear()},once:function(e,t){a.on(e,(function n(r,o){a.off(e,n),t(r,o)}))}})},H="change_region",F="check_goals",G="destroy",Y="fail_all_requests",V="login_success",z="pause_connection",B="prefetch_token",J="push_received",K="push_response_received",X="reconnect",W="request_failed",Q="response_received",Z="send_request",$="set_chat_active",ee="set_self_id",te="socket_connected",ne="socket_disconnected",re="socket_recovered",oe="socket_unstable",ae="start_connection",ie="update_customer_page",ce="CONNECTION_LOST",se="IDENTITY_MISMATCH",ue="MISDIRECTED_CONNECTION",de="MISSING_CHAT_THREAD",pe="SDK_DESTROYED",le="accept_greeting",fe="cancel_greeting",he="delete_chat_properties",ve="delete_event_properties",_e="delete_thread_properties",ye="get_chat",me="get_customer",ge="get_form",Ie="get_predicted_agent",Ee="get_url_info",be="list_chats",Te="list_group_statuses",we="list_threads",Oe="login",Se="mark_events_as_seen",ke="resume_chat",Pe="send_event",Ce="send_rich_message_postback",Ne="send_sneak_peek",xe="set_customer_session_fields",je="start_chat",De="update_chat_properties",qe="update_customer",Re="update_customer_page",Ae="update_event_properties",Me="update_thread_properties";var Ue=function(e){var t,n=e.Symbol;return"function"==typeof n?n.observable?t=n.observable:(t=n("observable"),n.observable=t):t="@@observable",t}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),Le=function(){return Math.random().toString(36).substring(7).split("").join(".")},He={INIT:"@@redux/INIT"+Le(),REPLACE:"@@redux/REPLACE"+Le(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+Le()}};function Fe(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Ge(e,t,n){var r;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw Error("Expected the enhancer to be a function.");return n(Ge)(e,t)}if("function"!=typeof e)throw Error("Expected the reducer to be a function.");var o=e,a=t,i=[],c=i,s=!1;function u(){c===i&&(c=i.slice())}function d(){if(s)throw Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return a}function p(e){if("function"!=typeof e)throw Error("Expected the listener to be a function.");if(s)throw Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");var t=!0;return u(),c.push(e),function(){if(t){if(s)throw Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");t=!1,u();var n=c.indexOf(e);c.splice(n,1)}}}function l(e){if(!Fe(e))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(s)throw Error("Reducers may not dispatch actions.");try{s=!0,a=o(a,e)}finally{s=!1}for(var t=i=c,n=0;t.length>n;n++){(0,t[n])()}return e}function f(e){if("function"!=typeof e)throw Error("Expected the nextReducer to be a function.");o=e,l({type:He.REPLACE})}function h(){var e,t=p;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function n(){e.next&&e.next(d())}return n(),{unsubscribe:t(n)}}})[Ue]=function(){return this},e}return l({type:He.INIT}),(r={dispatch:l,subscribe:p,getState:d,replaceReducer:f})[Ue]=h,r}function Ye(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ve(e,t){var n=Object.keys(e);return Object.getOwnPropertySymbols&&n.push.apply(n,Object.getOwnPropertySymbols(e)),t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n}function ze(e){for(var t=1;arguments.length>t;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ve(n,!0).forEach((function(t){Ye(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ve(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Be(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}function Je(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return function(e){return function(){var n=e.apply(void 0,arguments),r=function(){throw Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},o={getState:n.getState,dispatch:function(){return r.apply(void 0,arguments)}},a=t.map((function(e){return e(o)}));return ze({},n,{dispatch:r=Be.apply(void 0,a)(n.dispatch)})}}}function Ke(){var e={};return e.promise=new Promise((function(t,n){e.resolve=t,e.reject=n})),e}var Xe="connected",We="destroyed",Qe="disconnected",Ze="agent",$e="customer",et=function(e){return e.connection.status},tt=function(e,t){return e.requests[t]},nt=function(e){return e.users.self.id},rt=function(e,t){var n=e.chats[t];return!!n&&n.active},ot=function(e){return et(e)===Xe},at=function(e){var t=e.region;return"https://api"+(t?"-"+t:"")+function(e){var t=e.env;return 1520===e.licenseId?".staging":"production"===t?"":"."+t}(e)+".livechatinc.com"},it=function(e){return at(e)+"/v3.3/customer"},ct=function(e,o){return t({},e,{requests:n(e.requests,[o.id].map(r))})},st=function(e,n){return t({},n,{connection:t({},n.connection,{status:e})})},ut=function(e){var n,r,o;return r=e,(n={}).change_region=function(e,n){return t({},e,{region:n.region})},n.destroy=function(e){return st(We,e)},n.login_success=function(e){return st(Xe,e)},n.pause_connection=function(e){return st("paused",e)},n.request_failed=ct,n.response_received=ct,n.push_response_received=ct,n.send_request=function(e,n){var r,o=n.id;return t({},e,{requests:t({},e.requests,(r={},r[o]={id:o,promise:n.promise,resolve:n.resolve,reject:n.reject,request:n.request},r))})},n.set_chat_active=function(e,n){var r,o=n.id;return t({},e,{chats:t({},e.chats,(r={},r[o]=t({},e.chats[o],{active:n.active}),r))})},n.set_self_id=function(e,n){return t({},e,{users:t({},e.users,{self:t({},e.users.self,{id:n.id})})})},n.socket_disconnected=function(e){var n=et(e);return t({},st(n===Qe?Qe:"reconnecting",e),{requests:{}})},n.update_customer_page=function(e,n){return t({},e,{page:t({},e.page,n)})},(o=n)[void 0]&&console.warn("Reducer contains an 'undefined' action type.\nHave you misspelled a constant?"),function(e,t){return void 0===e&&(e=r),l(t.type,o)?o[t.type](e,t.payload):e}};function dt(e){var n=_,r=function(){var e=[],t=function(t){return function(n){return function(r){var o=n(r);return e.forEach((function(e){e(r,t)})),o}}};return t.add=function(t){e.push(t)},t}(),o=Ge(ut(function(e){var n=e.application,r=e.licenseId,o=e.groupId,a=void 0===o?null:o,i=e.env,c=e.page,s=void 0===c?null:c,u=e.region,d=void 0===u?null:u,p=e.referrer,l=void 0===p?null:p,f=e.uniqueGroups,h=void 0!==f&&f,v=e.mobile,_=void 0!==v&&v;return{application:t({},void 0===n?{}:n,{name:"customer_sdk",version:"3.1.1"}),licenseId:r,env:i,groupId:a,chats:{},connection:{status:Qe},page:s,region:d,referrer:l,requests:{},users:{self:{id:null,type:$e},others:{}},uniqueGroups:h,mobile:_}}(e)),n(Je(r)));return o.addSideEffectsHandler=r.add,o}function pt(e){var t=e.code,n=Error(e.message);return n.code=t,n}var lt="customer_banned",ft="product_version_changed",ht="chat_deactivated",vt="chat_properties_deleted",_t="chat_properties_updated",yt="chat_transferred",mt="customer_disconnected",gt="customer_page_updated",It="customer_side_storage_updated",Et="customer_updated",bt="event_properties_deleted",Tt="event_properties_updated",wt="event_updated",Ot="events_marked_as_seen",St="greeting_accepted",kt="greeting_canceled",Pt="incoming_chat",Ct="incoming_event",Nt="incoming_greeting",xt="incoming_multicast",jt="incoming_rich_message_postback",Dt="incoming_typing_indicator",qt="queue_position_updated",Rt="thread_properties_deleted",At="thread_properties_updated",Mt="user_added_to_chat",Ut="user_removed_from_chat",Lt=Object.freeze({__proto__:null,CHAT_DEACTIVATED:ht,CHAT_PROPERTIES_DELETED:vt,CHAT_PROPERTIES_UPDATED:_t,CHAT_TRANSFERRED:yt,CUSTOMER_DISCONNECTED:mt,CUSTOMER_PAGE_UPDATED:gt,CUSTOMER_SIDE_STORAGE_UPDATED:It,CUSTOMER_UPDATED:Et,EVENT_PROPERTIES_DELETED:bt,EVENT_PROPERTIES_UPDATED:Tt,EVENT_UPDATED:wt,EVENTS_MARKED_AS_SEEN:Ot,GREETING_ACCEPTED:St,GREETING_CANCELED:kt,INCOMING_CHAT:Pt,INCOMING_EVENT:Ct,INCOMING_GREETING:Nt,INCOMING_MULTICAST:xt,INCOMING_RICH_MESSAGE_POSTBACK:jt,INCOMING_TYPING_INDICATOR:Dt,QUEUE_POSITION_UPDATED:qt,THREAD_PROPERTIES_DELETED:Rt,THREAD_PROPERTIES_UPDATED:At,USER_ADDED_TO_CHAT:Mt,USER_REMOVED_FROM_CHAT:Ut}),Ht="file",Ft="form",Gt="filled_form",Yt="message",Vt="rich_message",zt="system_message",Bt="custom",Jt=function(e){var t,n={};return"string"==typeof e.customId&&(n.custom_id=e.customId),"object"!=typeof(t=e.properties)||null===t||h(t)||(n.properties=e.properties),n},Kt=function(e){switch(e.type){case Yt:var r=t({},Jt(e),{type:e.type,text:e.text});return e.postback&&(r.postback={id:e.postback.id,thread_id:e.postback.threadId,event_id:e.postback.eventId,type:e.postback.type,value:e.postback.value}),r;case Ht:return t({},Jt(e),{type:e.type,url:e.url,alternative_text:e.alternativeText});case Gt:return t({},Jt(e),{type:e.type,form_id:e.formId,fields:e.fields.map((function(e){switch(e.type){case"group_chooser":if(!e.answer)return e;var r=e.answer,o=r.groupId;return t({},e,{answer:t({},n(r,["groupId"]),{group_id:o})});default:return e}}))});case zt:var o=t({},Jt(e),{type:e.type,text:e.text,system_message_type:e.systemMessageType});return e.recipients&&(o.recipients=e.recipients),o;case Bt:var a=t({},Jt(e),{type:e.type});return e.content&&(a.content=e.content),a}},Xt=function(e){var t=e.active,n=e.chat,r=e.continuous,o={active:void 0===t||t,chat:{}};if("boolean"==typeof r&&(o.continuous=r),!n)return o;var a=n.access,i=n.thread,c=n.properties;return a&&a.groupIds&&(o.chat.access={group_ids:a.groupIds}),c&&(o.chat.properties=c),i&&(o.chat.thread=function(e){var t={},n=e.events,r=e.properties;return n&&(t.events=n.map(Kt)),r&&(t.properties=r),t}(i)),o},Wt=function(e){return b(e).map((function(e){var t;return(t={})[e[0]]=e[1],t}))},Qt=function(e){var t=E(["avatar","name","email"],e);return e.sessionFields&&(t.session_fields=Wt(e.sessionFields)),t},Zt=function(e){return{type:G,payload:{reason:e}}},$t=function(e){return{type:z,payload:{reason:e}}},en=function(e){return void 0===e&&(e=!1),{type:B,payload:{fresh:e}}},tn=function(e){return{type:X,payload:{delay:e}}},nn=function(e,n,r){return{type:Z,payload:t({request:{action:e,payload:n}},r&&{source:r})}},rn=function(e,t){return{type:$,payload:{id:e,active:t}}},on=function(e){return{type:ee,payload:{id:e}}},an=function(e,t){t.payload.id=y(e.getState().requests);var n=Ke(),r=n.resolve,o=n.reject,a=n.promise;return t.payload.promise=a,t.payload.resolve=r,t.payload.reject=o,e.dispatch(t),a},cn=function(e){var t=e.min,n=void 0===t?1e3:t,r=e.max,o=void 0===r?5e3:r,a=e.jitter,i=void 0===a?.5:a,c=0;return{duration:function(){var e=n*Math.pow(2,c++);if(i){var t=Math.random(),r=Math.floor(t*i*e);e=0==(1&Math.floor(10*t))?e-r:e+r}return 0|Math.min(e,o)},reset:function(){c=0}}},sn=function(e){var t=e.getState();return"side_storage_"+t.licenseId+(t.uniqueGroups?":"+t.groupId:"")},un=function(e){return u(sn(e)).catch(g).then((function(e){return JSON.parse(e||"{}")})).catch((function(){return{}}))},dn=function(e,t,n){var r=e.slice(0),o=!1;return function e(a){var i,c=r.shift();(i=function(){return c(a)},new Promise((function(e){e(i())}))).then((function(n){o||(r.length?e(n):t(n))}),(function(e){o||n(e)}))}(),{cancel:function(){o=!0}}},pn=function(e,t,n){return an(e,nn(t,n,"login"))};function ln(e,n){var r,o,a=null,i={min:300,max:6e4,jitter:.3},c=cn(i),s=cn(t({},i,{min:1e3})),u=c,d=function(e){return r.dispatch(Zt(e))},p=function(){return r.dispatch(tn(u.duration()))},l=function(){return Promise.all([e.getToken(),un(r)])},f=function(e){var t=e[0],n=e[1],o=nt(r.getState());if(null===o)r.dispatch(on(t.entityId));else if(o!==t.entityId){var a=Error("Identity has changed.");throw a.code=se,a}return[t,n]},h=function(e){var t,o,i,c=e[0],s=e[1],u=r.getState(),d=u.application,p=u.groupId,l=u.page,f=u.referrer,h=u.mobile,v={token:c.tokenType+" "+c.accessToken,customer:"function"==typeof n?Qt(n()):{},customer_side_storage:s,is_mobile:h,application:(t=["name","version"],o=d,t.reduce((function(e,t){return e[t]=o[t],e}),{}))};return"number"==typeof p&&(v.group_id=p),d.channelType&&(v.application.channel_type=d.channelType),null!==l&&(a=l,v.customer_page=l),null!==f&&(v.referrer=f),Promise.race([pn(r,Oe,v),(i=15e3,new Promise((function(e){setTimeout(e,i)}))).then((function(){return Promise.reject(pt({message:"Request timed out.",code:"REQUEST_TIMEOUT"}))}))])};return{sendLogin:function(t){var n;r=t,null==(n=o)||n.cancel(),o=dn([l,f,h],(function(e){var t;o=null,c.reset(),s.reset(),u=c,t=r.getState().page,a!==t&&pn(r,Re,t).catch(g),a=null,r.dispatch({type:V,payload:e})}),(function(t){switch(o=null,t.code){case"AUTHENTICATION":return e.getFreshToken(),void p();case ce:case ue:case pe:return;case"SSO_IDENTITY_EXCEPTION":case"SSO_OAUTH_EXCEPTION":return"server_error"===t.message||"temporarily_unavailable"===t.message?void p():void d(t.message);case"USERS_LIMIT_REACHED":return void r.dispatch($t(t.code.toLowerCase()));case se:case"CUSTOMER_BANNED":case"WRONG_PRODUCT_VERSION":return void d(t.code.toLowerCase());case"SERVICE_TEMPORARILY_UNAVAILABLE":return u=s,void p();default:return void p()}}))},cancel:function(){var e;null==(e=o)||e.cancel()}}}var fn,hn=function(e,t){var n=e.dispatch,r=function(e){return e.requests}((0,e.getState)());n({type:Y,payload:{rejects:Object.keys(r).map((function(e){return r[e].reject})),reason:t}})},vn=function(e,t,n){var r=t.payload.id;(0,e.dispatch)({type:W,payload:{id:r,reject:(0,e.getState)().requests[r].reject,error:n}})},_n=Object.freeze({success:!0}),yn=function(e,t){var n={id:t.id,authorId:t.author_id,createdAt:t.created_at,threadId:e,properties:t.properties||{}};return void 0!==t.custom_id&&(n.customId=t.custom_id),n},mn=function(e,t){var n,r,o,a,i;t.height>t.width?(r="height",o="width",a=t.height,i=t.width):(r="width",o="height",a=t.width,i=t.height);var c=e/a;return(n={})[r]=Math.ceil(Math.min(a,e)),n[o]=Math.ceil(Math.min(c*i,i)),n},gn=function(e,n){return void 0!==n.width&&void 0!==n.height?function(e,n){return t({},yn(e,n),{type:Ht,contentType:n.content_type,url:n.url,name:n.name,width:n.width,height:n.height,thumbnails:{default:t({url:n.thumbnail_url},mn(300,n)),high:t({url:n.thumbnail2x_url},mn(600,n))}},n.alternative_text&&{alternativeText:n.alternative_text})}(e,n):t({},yn(e,n),{type:Ht,contentType:n.content_type,url:n.url,name:n.name})},In=function(e,r){return t({},yn(e,r),{type:Gt,formId:r.form_id,fields:r.fields.map((function(e){switch(e.type){case"group_chooser":if(!e.answer)return e;var r=e.answer,o=r.group_id;return t({},e,{answer:t({},n(r,["group_id"]),{groupId:o})});default:return e}}))})},En=function(e,n){return t({},yn(e,n),{type:Yt,text:n.text})},bn=function(e,n){return t({},yn(e,n),{type:Bt},n.content&&{content:n.content})},Tn=function(e){var n={};if("string"==typeof e.title&&(n.title=e.title),"string"==typeof e.subtitle&&(n.subtitle=e.subtitle),e.image){var r=e.image;n.image=t({url:r.url,name:r.name},r.alternative_text&&{alternativeText:r.alternative_text})}return e.buttons&&(n.buttons=e.buttons.map((function(e){switch(e.type){case"message":case"phone":return{type:e.type,text:e.text,postbackId:e.postback_id,userIds:e.user_ids,value:e.value,role:e.role||"default"};case"cancel":return{type:e.type,text:e.text,postbackId:e.postback_id,userIds:e.user_ids,role:e.role||"default"};case"url":var t={type:e.type,text:e.text,postbackId:e.postback_id,userIds:e.user_ids,value:e.value,role:e.role||"default"};return e.target&&(t.target=e.target),t;case"webview":var n={type:e.type,text:e.text,postbackId:e.postback_id,userIds:e.user_ids,value:e.value,role:e.role||"default"};return"string"==typeof e.webview_height&&(n.webviewHeight=e.webview_height),n;default:return{text:e.text,postbackId:e.postback_id,userIds:e.user_ids,role:e.role||"default"}}}))),n},wn=function(e,n){switch(n.template_id){case"cards":case"quick_replies":case"sticker":return t({},yn(e,n),{type:Vt,template:n.template_id,elements:n.elements.map(Tn)});default:return null}},On=function(e,n){var r=t({},yn(e,t({},n,{author_id:"system"})),{type:zt,text:n.text,systemMessageType:n.system_message_type});return n.text_vars&&(r.textVars=n.text_vars),r},Sn=function(e,n){switch(n.type){case Ht:return gn(e,n);case Ft:return function(e,n){return t({},yn(e,n),{authorId:"system",type:Ft,formId:n.form_id,fields:n.fields})}(e,n);case Gt:return In(e,n);case Yt:return En(e,n);case Vt:return wn(e,n);case zt:return On(e,n);case Bt:return bn(e,n);default:return null}},kn=function(e){return{id:e.id,addon:e.addon||null,uniqueId:e.unique_id,displayedFirstTime:e.displayed_first_time,accepted:e.accepted||!1,subtype:e.subtype||"greeting",event:Sn(null,e.event),agent:{id:e.agent.id,name:e.agent.name,avatar:e.agent.avatar,jobTitle:e.agent.job_title,isBot:e.agent.is_bot||!1}}},Pn=function(e){return void 0===e&&(e={}),e.group_ids?{groupIds:e.group_ids}:{}},Cn=function(e){return v((function(e){return e.events_seen_up_to?e.events_seen_up_to:null}),(t="id",e.reduce((function(e,n){return e[n[t]]=n,e}),{})));var t},Nn=function(e,t){var n=t.properties||{};return{id:t.id,chatId:e,active:t.active,access:Pn(t.access),createdAt:t.created_at,userIds:t.user_ids,events:t.events.map((function(e){return Sn(t.id,e)})).filter(Boolean),properties:n,previousThreadId:t.previous_thread_id||null,nextThreadId:t.next_thread_id||null,queue:t.queue?Mn(t.queue):null}},xn=function(e){return{id:e.id,access:Pn(e.access),users:e.users.map(Un),properties:e.properties||{},eventsSeenUpToMap:Cn(e.users)}},jn=function(e){var t=E(["avatar","email","name"],e);return e.session_fields&&(t.sessionFields=e.session_fields.reduce((function(e,t){var n=Object.keys(t)[0];return e[n]=t[n],e}),{})),t},Dn=function(e){var n=jn(e);return t({id:e.id,type:$e},n,{sessionFields:n.sessionFields||{}})},qn=function(e){var n=e.statistics;return t({},Dn(e),{statistics:{chatsCount:n.chats_count,threadsCount:n.threads_count,visitsCount:n.visits_count,pageViewsCount:n.page_views_count,greetingsShownCount:n.greetings_shown_count,greetingsAcceptedCount:n.greetings_accepted_count}})},Rn=function(e){var t=e.agent;return{agent:{id:t.id,type:Ze,name:t.name,avatar:t.avatar,jobTitle:t.job_title,isBot:t.is_bot},queue:e.queue}},An=function(e){return{position:e.position,waitTime:e.wait_time}},Mn=function(e){return t({},An(e),{queuedAt:e.queued_at})},Un=function(e){return e.type===$e?t({},Dn(r=e),{present:r.present}):{id:(n=e).id,type:Ze,name:n.name,avatar:n.avatar,jobTitle:n.job_title,present:n.present};var n,r},Ln=((fn={}).CONNECTION_LOST="Connection lost.",fn.MISDIRECTED_CONNECTION="Connected to wrong region.",fn),Hn=function(e,t){var n=e.getState();switch(t.type){case K:case J:switch(t.payload.action){case ht:return void e.dispatch(rn(t.payload.payload.chatId,!1));case Pt:return void e.dispatch(rn(t.payload.payload.chat.id,!0));default:return}case Q:switch(t.payload.action){case be:return void t.payload.payload.chatsSummary.filter((function(e){var t=e.active;return rt(n,e.id)!==t})).forEach((function(t){e.dispatch(rn(t.id,t.active))}));default:return}}},Fn=function(e,t){t.forEach((function(t){if("present"in t){var r=n(t,["present"]);e("user_data",r)}else if(t.type!==$e)e("user_data",t);else{var o=n(t,["statistics"]);e("user_data",o)}}))},Gn=function(e,t){var n,r=t.content;"lc2"===t.type&&("groups_update"===r.name&&"groups"in r&&0!==(h(n=r.groups)?n:Object.keys(n)).length&&e("availability_updated",{availability:"offline"===r.groups[0].status?"offline":"online"}))},Yn=function(e,t){var n=e.emit,r=e.store,o=t.payload;switch(o.action){case At:return o.payload.properties.lc2&&"queue_pos"in o.payload.properties.lc2&&n(qt,{chatId:o.payload.chatId,threadId:o.payload.threadId,queue:{position:o.payload.properties.lc2.queue_pos,waitTime:o.payload.properties.lc2.queue_waiting_time}}),void n("thread_properties_updated",o.payload);case It:return void function(e,t){s(sn(e),JSON.stringify(t)).catch(g)}(r,o.payload.customer_side_storage);case mt:switch(o.payload.reason){case"access_token_expired":r.dispatch(en(!0)),r.dispatch(tn(100)),n("disconnected",o.payload);break;case lt:case"customer_temporarily_blocked":case"license_not_found":case ft:case"too_many_connections":case"unsupported_version":r.dispatch(Zt(o.payload.reason));break;case"misdirected_connection":hn(r,ue),r.dispatch({type:H,payload:o.payload.data});break;case"service_temporarily_unavailable":case"too_many_unauthorized_connections":hn(r,o.payload.reason.toUpperCase());break;default:r.dispatch(tn(100)),n("disconnected",o.payload)}return;case Pt:return Fn(n,o.payload.chat.users),void n(o.action,o.payload);case Ct:if(null===o.payload.event)return;return void n(o.action,o.payload);case Dt:return void n(o.action,o.payload);case xt:return Gn(n,o.payload),void n(o.action,o.payload);case Mt:return Fn(n,[o.payload.user]),void n(o.action,o.payload);default:return void n(o.action,o.payload)}},Vn=function(e,t){var n=e.emit,r=t.payload;switch(r.action){case ht:return void r.resolve(_n);case ye:return Fn(n,r.payload.users),void r.resolve(r.payload);case Pt:return Fn(n,r.payload.chat.users),void r.resolve(r.payload);case Ct:return void r.resolve(r.payload.event);case be:return Fn(n,r.payload.users),void r.resolve(r.payload);default:return void r.resolve(r.payload)}},zn=function(e){var n=e.auth,r=e.emitter,o=e.socket,a=r.emit,i=ln(n,e.customerDataProvider);return function(e,c){switch(e.type){case H:return void o.reinitialize();case F:return void function(e,t,n){return t.getToken().then((function(t){var r=e.getState();null===nt(r)&&e.dispatch(on(t.entityId));var o=r.page;if(o&&o.url){var a=w({license_id:r.licenseId}),i={session_fields:Wt(n||{}),group_id:r.groupId||0,page_url:o.url};return P(it(r)+"/action/check_goals?"+a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:t.tokenType+" "+t.accessToken},body:JSON.stringify(i)}).then((function(){}))}}))}(c,n,e.payload.sessionFields).catch(g);case G:var s=e.payload;switch(i.cancel(),o.destroy(),s.reason){case"manual":hn(c,pe);break;case lt:case"license_expired":case ft:hn(c,ce),a("disconnected",s);break;default:a("disconnected",s)}return void r.off();case Y:var u=e.payload,d=u.reason,p={message:Ln[d],code:d};return void u.rejects.forEach((function(e){e(pt(p))}));case V:var l=e.payload,f=l.dynamicConfig,h=l.chats,v=l.greeting,_=t({customer:l.customer,availability:l.availability},v&&{greeting:v});return Object.defineProperty(_,"__unsafeDynamicConfig",{value:f}),Object.defineProperty(_,"__unsafeChats",{value:h}),void a("connected",_);case z:var y=e.payload;return o.disconnect(),void("manual"!==y.reason&&a("disconnected",y));case B:return e.payload.fresh?void n.getFreshToken().catch(g):void n.hasToken().then((function(e){return e?n.getToken().then((function(e){if(36e5>=e.creationDate+e.expiresIn-Date.now())return n.invalidate().then(n.getFreshToken)})):n.getToken()})).catch(g);case J:return e.payload.action===mt||Hn(c,e),void Yn({emit:a,store:c},e);case K:return Hn(c,e),void Vn({emit:a},e);case X:return hn(c,ce),void o.reconnect(e.payload.delay);case W:var E=e.payload;return void(0,E.reject)(pt(E.error));case Q:return Hn(c,e),void Vn({emit:a},e);case Z:var b=c.getState();return function(e){return et(e)===We}(b)?void vn(c,e,{code:pe,message:"SDK destroyed."}):ot(b)||"login"===e.payload.source?void function(e,n){var r=n.payload,o=t({request_id:r.id},r.request);switch(o.action){case Oe:var a=[];return void e.emit(t({},o,{version:"3.3",payload:t({},o.payload,{pushes:{3.3:I(Lt).filter((function(e){return e!==mt&&!m(e,a)}))}})}));default:e.emit(o)}}(o,e):void vn(c,e,{code:"NO_CONNECTION",message:"No connection."});case ee:return void a("customer_id",e.payload.id);case ne:return void a("disconnected",{reason:"connection_lost"});case te:return void i.sendLogin(c);case re:if(!ot(c.getState()))return;return void a("connection_recovered");case oe:if(!ot(c.getState()))return;return void a("connection_unstable");case ae:return o.connect(),void c.dispatch(en());case ie:if(!ot(c.getState()))return;return void an(c,nn(Re,e.payload)).catch(g);default:return}}},Bn=function(e,t){var n,r=(void 0===t?{}:t).query,o=w(void 0===r?{}:r),a=o?e+"?"+o:e,i=L(),c=cn({min:1e3,max:5e3,jitter:.5}),s=3,u=null,d=function(){s=1,c.reset(),i.emit("connect")},p=function(){f(),v(),i.emit("disconnect")},l=function(e){i.emit("message",e.data)},f=function(){var e;(clearTimeout(n),s=3,u)&&((e=u).removeEventListener("open",d),e.removeEventListener("close",p),e.removeEventListener("message",l),u.close(),u=null)},h=function(){var e;s=0,u=new WebSocket(a),(e=u).addEventListener("open",d),e.addEventListener("close",p),e.addEventListener("message",l)},v=function(e){void 0===e&&(e=c.duration()),f(),0!==e?n=setTimeout(h,e):h()};return{connect:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return""+e},t}((function(){if(3!==s)throw Error("Socket is already open or connecting.");clearTimeout(n),h()})),destroy:function(){i.off(),f()},disconnect:f,reconnect:v,emit:function(e){if(1!==s)throw Error("Socket is not connected.");u.send(e)},getReadyState:function(){return s},on:i.on,off:i.off}},Jn=function(e,n){var r,o,a,i,c=void 0===n?{}:n,s=c.query,u=void 0===s?{}:s,d=c.emitter,p=void 0===d?L():d,l=Bn(e,{query:u}),f=(o=g,{cancel:function(){clearTimeout(r),o=g},check:function(){var e=Ke();return o=e.resolve,r=setTimeout((function(){var t=Error("Timeout.");t.code="TIMEOUT",e.reject(t)}),2e3),e.promise},resolve:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return""+e},t}((function(){clearTimeout(r),o()}))}),h=function(){return 1===l.getReadyState()},v=function(){f.cancel()};return a=l,i=p,["connect","disconnect"].forEach((function(e){a.on(e,(function(t){i.emit(e,t)}))})),l.on("disconnect",v),l.on("message",(function(e){f.resolve();var t=JSON.parse(e);p.emit("message",t)})),"undefined"!=typeof window&&void 0!==window.addEventListener&&(window.addEventListener("online",(function(){h()&&f.check().then((function(){f.cancel(),p.emit("connection_recovered")}),(function(e){if(f.cancel(),"TIMEOUT"!==e.code)throw e;l.reconnect()}))})),window.addEventListener("offline",(function(){f.cancel(),h()&&p.emit("connection_unstable")}))),t({},l,{destroy:function(){v(),l.destroy()},disconnect:function(){v(),l.disconnect()},reconnect:function(e){v(),l.reconnect(e)},emit:function(e){l.emit(JSON.stringify(e))},on:p.on,off:p.off})},Kn=function(e,t){var n=e.getState(),r=(it(n)+"/rtm/ws").replace(/^https/,"wss");return Jn(r,{query:{license_id:n.licenseId},emitter:t})},Xn=function(e){return{chatId:e.chat_id,properties:e.properties}},Wn=function(e){var n={chatId:e.chat_id,threadId:e.thread_id,transferredTo:t({},e.transferred_to.agent_ids&&{agentIds:e.transferred_to.agent_ids},e.transferred_to.group_ids&&{groupIds:e.transferred_to.group_ids}),queue:e.queue?Mn(e.queue):null};return t({},n,"manual"===e.reason?{reason:e.reason,requesterId:e.requester_id}:{reason:e.reason})},Qn=function(e){return{url:e.url,title:e.title,openedAt:e.opened_at}},Zn=function(e){return t({id:e.id},jn(e))},$n=function(e){return{chatId:e.chat_id,threadId:e.thread_id,eventId:e.event_id,properties:e.properties}},er=function(e){return{chatId:e.chat_id,threadId:e.thread_id,eventId:e.event_id,properties:e.properties}},tr=function(e){var t=e.thread_id;return{chatId:e.chat_id,threadId:t,event:Sn(t,e.event)}},nr=function(e){return{chatId:e.chat_id,userId:e.user_id,seenUpTo:e.seen_up_to}},rr=function(e){return{uniqueId:e.unique_id}},or=function(e){var n=e.chat;return{chat:t({},xn(n),{thread:Nn(n.id,n.thread)})}},ar=function(e){return{chatId:e.chat_id,event:Sn(e.thread_id,e.event)}},ir=function(e){return kn(e)},cr=function(e){return{userId:e.user_id,chatId:e.chat_id,threadId:e.thread_id,eventId:e.event_id,postback:e.postback}},sr=function(e){var t=e.typing_indicator;return{chatId:e.chat_id,typingIndicator:{authorId:t.author_id,isTyping:t.is_typing}}},ur=function(e){return{chatId:e.chat_id,threadId:e.thread_id,queue:An(e.queue)}},dr=function(e){return{chatId:e.chat_id,threadId:e.thread_id,properties:e.properties}},pr=function(e){return{chatId:e.chat_id,threadId:e.thread_id,properties:e.properties}},lr=function(e){return{chatId:e.chat_id,user:Un(e.user),present:e.user.present}},fr=function(e){return{chatId:e.chat_id,userId:e.user_id}},hr=function(e){return e.map((function(e){switch(e.type){case"group_chooser":return t({},e,{options:e.options.map((function(e){var r=e.group_id;return t({},n(e,["group_id"]),{groupId:r})}))});case"rating":var r=e.comment_label;return t({},n(e,["comment_label"]),{commentLabel:r});default:return e}}))},vr=function(e){var n,r;return{id:e.id,fields:!("id"in e.fields[0])?(n=e.fields,r=n.map((function(e,n){return t({},e,{id:n+""})})),hr(r)):hr(e.fields)}},_r=function(e){return e.enabled?t({},e,{form:vr(e.form)}):e},yr=function(e){var t={url:e.url};return e.title&&(t.title=e.title),e.description&&(t.description=e.description),e.image_url&&(t.imageUrl="https://"+e.image_url,e.image_width&&e.image_height&&(t.imageWidth=e.image_width,t.imageHeight=e.image_height)),t},mr=function(e){var t,n,r,o,a,i,c=e.chats_summary.map((function(e){var t=e.last_thread_created_at,n=e.last_thread_id,r=e.last_event_per_type,o=e.properties,a=void 0===o?{}:o,i=e.users,c={id:e.id,active:e.active,access:Pn(e.access),properties:a,users:i.map(Un),lastThreadId:n||null,lastThreadCreatedAt:t||null,eventsSeenUpToMap:Cn(i)};if(!r)return c;c.lastEventsPerType=v((function(e){return Sn(e.thread_id,e.event)}),r);var s,u=r,d=Object.keys(u).map((function(e){return u[e]})),p=(s=d.sort((function(e,t){return e.thread_id===t.thread_id?T(e.event.created_at,t.event.created_at):T(e.thread_created_at,t.thread_created_at)}))).length>0?s[s.length-1]:null;return p&&(c.lastEvent=c.lastEventsPerType[p.event.type]),c}));return{chatsSummary:(o=function(e){var t=e.lastEvent;return-1*(void 0!==t?t.timestamp:e.order)},a=c,i="function"==typeof o?o:function(e){return function(e,t){for(var n="string"==typeof e?e.split("."):e,r=0,o=t;o&&n.length>r;)o=o[n[r++]];return o}(o,e)},(h(a)?[].concat(a):I(a)).sort((function(e,t){return i(e)-i(t)}))),totalChats:e.total_chats,users:(t=function(e){return e.id},n=f((function(e){return e.users}),c),r=[],n.filter((function(e){var n=t(e);return-1===r.indexOf(n)&&(r.push(n),!0)}))),previousPageId:e.previous_page_id||null,nextPageId:e.next_page_id||null}},gr=function(e){return e.groups_status},Ir=function(e,t){return{threads:t.threads.map((function(t){return Nn(e.payload.chat_id,t)})),previousPageId:t.previous_page_id||null,nextPageId:t.next_page_id||null}},Er=function(e){var n,r,o=e.__priv_dynamic_config,a=e.chats,i=e.greeting;return t({dynamicConfig:o,customer:qn(e.customer),availability:(n=o,r=n.online_groups_ids,r&&m(n.customer_groups.monitoring.id,r)?"online":"offline"),chats:a.map((function(t){return{id:t.chat_id,active:"has_active_thread"in t?t.has_active_thread:e.has_active_thread,hasUnreadEvents:t.has_unread_events}}))},i&&{greeting:kn(i)})},br=function(e){switch(e.action){case ht:return{action:e.action,payload:{chatId:e.payload.chat_id}};case vt:return{action:e.action,payload:(t=e.payload,{chatId:t.chat_id,properties:t.properties})};case _t:return{action:e.action,payload:Xn(e.payload)};case yt:return{action:e.action,payload:Wn(e.payload)};case It:case mt:return{action:e.action,payload:e.payload};case gt:return{action:e.action,payload:Qn(e.payload)};case Et:return{action:e.action,payload:Zn(e.payload)};case bt:return{action:e.action,payload:$n(e.payload)};case Tt:return{action:e.action,payload:er(e.payload)};case wt:return{action:e.action,payload:tr(e.payload)};case Ot:return{action:e.action,payload:nr(e.payload)};case St:case kt:return{action:e.action,payload:rr(e.payload)};case Pt:return{action:e.action,payload:or(e.payload)};case Ct:return{action:e.action,payload:ar(e.payload)};case Nt:return{action:e.action,payload:ir(e.payload)};case xt:return{action:e.action,payload:e.payload};case jt:return{action:e.action,payload:cr(e.payload)};case Dt:return{action:e.action,payload:sr(e.payload)};case qt:return{action:e.action,payload:ur(e.payload)};case Rt:return{action:e.action,payload:dr(e.payload)};case At:return{action:e.action,payload:pr(e.payload)};case Mt:return{action:e.action,payload:lr(e.payload)};case Ut:return{action:e.action,payload:fr(e.payload)}}var t},Tr=function(e,n){var r=e.dispatch,o=n.request_id,a=tt((0,e.getState)(),o),i=a.promise,c=a.resolve,s=function(e){var n,r=e.request,o=e.response;switch(o.action){case le:case fe:case he:case ve:case _e:return{action:o.action,payload:_n};case ye:return{action:o.action,payload:(n=o.payload,t({},xn(n),{thread:n.thread?Nn(n.id,n.thread):null}))};case me:return{action:o.action,payload:qn(o.payload)};case ge:return{action:o.action,payload:_r(o.payload)};case Ie:return{action:o.action,payload:Rn(o.payload)};case Ee:return{action:o.action,payload:yr(o.payload)};case be:return{action:o.action,payload:mr(o.payload)};case Te:return{action:o.action,payload:gr(o.payload)};case we:return{action:o.action,payload:Ir(r,o.payload)};case Oe:return{action:o.action,payload:Er(o.payload)};case Se:case Ne:case xe:case Ce:case De:case qe:case Re:case Ae:case Me:return{action:o.action,payload:_n}}}({request:a.request,response:n});r({type:Q,payload:t({id:o,promise:i,resolve:c},s)})},wr=function(e,n){var r=e.dispatch;return n.on("connect",(function(){r({type:te})})),n.on("message",(function(n){if("response"===n.type){if(!n.success)return void function(e,t){var n,r=e.dispatch,o=t.request_id,a=t.payload,i=tt((0,e.getState)(),o);r({type:W,payload:{id:o,reject:i.reject,error:(n=a.error,{code:n.type.toUpperCase(),message:n.message})}})}(e,n);switch(n.action){case ke:case Pe:case je:return;default:return void Tr(e,n)}}if("request_id"in n)switch(n.action){case Pt:case Ct:return void function(e,n){var r=e.dispatch,o=n.request_id,a=tt((0,e.getState)(),o),i=a.promise,c=a.resolve,s=br(n);r({type:K,payload:t({id:o,promise:i,resolve:c},s)})}(e,n)}!function(e,t){var n=br(t);n&&e.dispatch({type:J,payload:n})}(e,n)})),n.on("disconnect",(function(){hn(e,ce),et(e.getState())===Xe&&e.dispatch({type:ne})})),n.on("connection_unstable",(function(){r({type:oe})})),n.on("connection_recovered",(function(){r({type:re})})),n.off},Or="incorrect requester structure",Sr=function(e,t){return e.length?e+"\n"+t:t},kr=function(e,n,r){var o=r.filledForm,a=r.groupId,i=r.timeZone;return n.getToken().then((function(n){var r=e.getState();null===nt(r)&&e.dispatch(on(n.entityId));var c=at(r)+"/v2/tickets/new",s=function(e,n){var r=n.fields,o=n.groupId,a=void 0===o?e.groupId:o,i=n.timeZone,c=t({licence_id:e.licenseId,ticket_message:"",offline_message:"",visitor_id:n.customerId,requester:{}},"number"==typeof a&&{group:a},e.page&&{source:{url:e.page.url}},i&&{timezone:i});return r.reduce((function(e,t){switch(t.type){case"subject":var n=t.answer,r=n?t.label+" "+n:t.label;return n&&(e.subject=n),e.offline_message=Sr(e.offline_message,r),e;case"name":var o=t.answer,a=o?t.label+" "+o:t.label;return o&&(e.requester.name=o),e.offline_message=Sr(e.offline_message,a),e;case"email":var i=t.answer,c=i?t.label+" "+i:t.label;return e.requester.mail=i,e.offline_message=Sr(e.offline_message,c),e;case"question":case"textarea":var s=t.answer,u=s?t.label+" "+s:t.label;return e.offline_message=Sr(e.offline_message,u),e.ticket_message=Sr(e.ticket_message,u),e;case"radio":case"select":var d=t.answer&&t.answer.label,p=d?t.label+" "+d:t.label;return e.offline_message=Sr(e.offline_message,p),e.ticket_message=Sr(e.ticket_message,p),e;case"checkbox":var l=t.answers&&t.answers.map((function(e){return e.label})).join(", "),f=l?t.label+" "+l:t.label;return e.offline_message=Sr(e.offline_message,f),e.ticket_message=Sr(e.ticket_message,f),e;default:return e}}),c)}(r,{fields:o.fields,customerId:n.entityId,groupId:a,timeZone:i});return P(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}).then((function(e){if(e.ok)return e.json().then((function(e){return t({},e,{text:s.ticket_message})}));if(400===e.status||422===e.status){var n=function(e){if(!e||!e.errors)throw Error();var t=e.errors[0];if(Object.keys(t)[0]===Or)throw pt({message:t[Or][0],code:"VALIDATION"});throw Error()};return e.json().then(n,n)}throw Error()}))}))},Pr="UPLOAD_FAILED",Cr=function(e,t,n){var r=void 0===n?{}:n,o=r.headers,a=r.method,i=void 0===a?"POST":a,c=r.onProgress,s=r.withCredentials,u=void 0!==s&&s,d=new XMLHttpRequest;return{promise:new Promise((function(n,r){var a,s;"function"==typeof c&&(d.upload.onprogress=function(e){c(e.loaded/e.total)}),d.onload=function(){var e;try{e=JSON.parse(d.response)}catch(t){e=d.response}if(200>d.status||d.status>=300){var t=Error("Upload failed.");t.code=Pr,t.response=e,r(t)}else n(e)},d.onerror=function(){var e=Error("Upload failed.");e.code=Pr,r(e)},d.onabort=function(){var e=Error("Upload canceled.");e.code="UPLOAD_CANCELED",r(e)},d.open(i,e),d.withCredentials=u,o&&Object.keys(o).forEach((function(e){return d.setRequestHeader(e,o[e])})),d.send((a=t,s=new FormData,Object.keys(a).forEach((function(e){return s.append(e,a[e])})),s))})),cancel:function(){d.abort()}}},Nr=1048576,xr=10485760,jr=function(e,t){if(void 0===t&&(t=2),1024>e)return e+" b";var n=e/1024;if(Nr>e)return n.toFixed(t)+" kb";var r=n/1024;return 1073741824>e?r.toFixed(t)+" MB":(r/1024).toFixed(t)+" GB"},Dr=function(e,t){var n,r=e.auth,o=e.store,a=t.file,i=t.onProgress,c=!1;return{promise:new Promise((function(e,t){!function(e){if(e.size>xr)throw pt({message:"The file is too big (max size is "+jr(xr)+").",code:"TOO_BIG_FILE"})}(a);var s=o.getState(),u=w({license_id:s.licenseId}),d=it(s)+"/action/upload_file?"+u,p={file:a};r.getToken().then((function(r){c?t(Error("Upload cancelled.")):(n=Cr(d,p,{headers:{Authorization:r.tokenType+" "+r.accessToken},onProgress:i})).promise.then(e,(function(e){if(e.response){var n=e.response.error;t(pt({message:n.message,code:n.type.toUpperCase()}))}else t(e)}))}))})),cancel:function(){c||(c=!0,n&&n.cancel())}}},qr=function(e){var t=e.licenseId,n=e.eventName;if("production"!==e.env)return Promise.resolve();var r={licence_id:t,event_id:"chat_widget_customer_sdk",message:JSON.stringify({event_name:n,severity:"Informational",sdkVersion:"3.1.1"})};return function(e,t){return new Promise((function(n){var r=new Image;r.src=e+"?"+t,r.onerror=g,r.onload=function(){return n()}}))}("https://queue.livechatinc.com/logs",w(r))},Rr="LISTENER_IDENTITY",Ar={},Mr=function(e,t){void 0===t&&(t="");var n=Object.keys(e);return n.map((function(n){var r=e[n];return function(){for(var e,o=arguments.length,a=Array(o),i=0;o>i;i++)a[i]=arguments[i];(e=console).info.apply(e,[t+"."+n+"() ===>"].concat(a));var c=r.apply(void 0,a);return"function"==typeof(null==c?void 0:c.then)?c.then((function(e){return console.info(t+"."+n+"() <===",e),e}),(function(e){throw console.error(t+"."+n+"() <===",e),e})):c}})).reduce((function(e,t,r){return e[n[r]]=t,e}),{})},Ur=function(e,t,n){if(void 0===n.LISTENER_IDENTITY&&Object.defineProperty(n,Rr,{value:{}}),n.LISTENER_IDENTITY[t])return Ar[n.LISTENER_IDENTITY[t]];var r=function(r){console.info("."+e+'("'+t+'") <===',r),n(r)},o=y(Ar);return n.LISTENER_IDENTITY[t]=o,Ar[o]=r,r};e.debug=function(e){var r=e;console.warn("You probably do not want to use debug(customerSDK) in your production environment.");var o=r.on,a=r.once,i=r.off,c=r.getChatHistory,s=r.auth,u=n(r,["on","once","off","getChatHistory","auth"]),d=Mr(u);return Object.freeze(t({auth:Object.freeze(Mr(s,".auth"))},d,{getChatHistory:function(){for(var e,t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];(e=console).info.apply(e,[".getChatHistory()"].concat(n));var o=c.apply(void 0,n),a="history.next()";return{next:function(){var e;return(e=console).info.apply(e,[a+" ===>"].concat(n)),o.next().then((function(e){var t;return(t=console).info.apply(t,[a+" <==="].concat(n,[e])),e}),(function(e){var t;throw(t=console).error.apply(t,[a+" <==="].concat(n,[e])),e}))}}},off:function(e,t){console.info('.off("'+e+'", '+(t.name||"anonymous")+")");var n=t;void 0!==t.LISTENER_IDENTITY&&(n=Ar[t.LISTENER_IDENTITY[e]]);i(e,n)},on:function(e,t){o(e,Ur("on",e,t))},once:function(e,t){a(e,Ur("once",e,t))}}))},e.init=function(e,r){void 0===r&&(r="production"),M(e);var o=e.autoConnect,a=void 0===o||o,i=e.customerDataProvider,c=e.identityProvider,s=n(e,["autoConnect","customerDataProvider","identityProvider"]),u=dt(t({},s,{env:r})),d=L(),p=function(e){var n=L(),r=Kn(e,n);return t({},Object.keys(r).reduce((function(e,t){return e[t]=function(){var e;return(e=r)[t].apply(e,arguments)},e}),{}),{reinitialize:function(){r.disconnect(),(r=Kn(e,n)).connect()}})}(u),l="function"==typeof c?c():U(s,r);u.addSideEffectsHandler(zn({emitter:d,socket:p,auth:l,customerDataProvider:i})),wr(u,p);var f=an.bind(null,u),h=function(){u.dispatch({type:ae})},v=Object.freeze({acceptGreeting:function(e){return f(nn(le,{greeting_id:e.greetingId,unique_id:e.uniqueId}))},auth:l,cancelGreeting:function(e){return f(nn(fe,{unique_id:e.uniqueId}))},cancelRate:function(e){var t=e.chatId,n=e.properties,r=void 0===n?["score"]:n;return v.listThreads({chatId:t}).then((function(e){var n=e.threads;if(!n.length)throw pt({message:'There is no thread in "'+t+'".',code:de});return v.deleteThreadProperties({chatId:t,threadId:n[0].id,properties:{rating:r}})}))},connect:h,deactivateChat:function(e){return f(nn("deactivate_chat",{id:e.id}))},deleteChatProperties:function(e){return f(nn(he,{id:e.id,properties:e.properties}))},deleteEventProperties:function(e){return f(nn(ve,{chat_id:e.chatId,thread_id:e.threadId,event_id:e.eventId,properties:e.properties}))},deleteThreadProperties:function(e){return f(nn(_e,{chat_id:e.chatId,thread_id:e.threadId,properties:e.properties}))},destroy:function(){u.dispatch(Zt("manual"))},disconnect:function(){u.dispatch($t("manual"))},getChat:function(e){return f(nn(ye,{chat_id:e.chatId,thread_id:e.threadId}))},getChatHistory:function(e){return function(e,t){var n={status:"idle",queuedTasks:[],nextPageId:null},r=function r(o,a){switch(n.status){case"idle":return n.status="fetching",void e.listThreads(n.nextPageId?{chatId:t,pageId:n.nextPageId}:{chatId:t,minEventsCount:25}).then((function(e){var t=e.threads;n.nextPageId=e.nextPageId,n.nextPageId?(n.status="idle",o({value:{threads:[].concat(t).reverse()},done:!1})):(n.status="done",o({value:{threads:[].concat(t).reverse()},done:!0}));var a=n.queuedTasks.shift();a&&r(a.resolve,a.reject)}),(function(e){var t=n.queuedTasks;n.status="idle",n.queuedTasks=[],a(e),t.forEach((function(t){return t.reject(e)}))}));case"fetching":return void n.queuedTasks.push({resolve:o,reject:a});case"done":return void o({value:void 0,done:!0})}};return{next:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return""+e},t}((function(){return new Promise(r)}))}}(v,e.chatId)},getCustomer:function(){return f(nn(me,{}))},getForm:function(e){return f(nn(ge,{group_id:e.groupId,type:e.type}))},getPredictedAgent:function(e){void 0===e&&(e={});var t=e.groupId;return f(nn(Ie,"number"==typeof t?{group_id:t}:{}))},getUrlInfo:function(e){return f(nn(Ee,{url:e.url}))},listChats:function(e){return void 0===e&&(e={}),"limit"in e&&"number"==typeof e.limit&&e.limit>25?Promise.reject(Error("Specified limit is too high (max 25).")):f(nn(be,void 0===e.pageId?{limit:e.limit||10}:{page_id:e.pageId}))},listGroupStatuses:function(e){var t=(void 0===e?{}:e).groupIds;return f(nn(Te,t?{group_ids:t}:{all:!0}))},listThreads:function(e){return f(nn(we,void 0===e.pageId?{chat_id:e.chatId,sort_order:e.sortOrder,limit:e.limit,min_events_count:e.minEventsCount}:{chat_id:e.chatId,page_id:e.pageId}))},markEventsAsSeen:function(e){return f(nn(Se,{chat_id:e.chatId,seen_up_to:e.seenUpTo}))},on:d.on,once:d.once,off:d.off,rateChat:function(e){var t=e.chatId,n=e.rating;return v.listThreads({chatId:t}).then((function(e){var r=e.threads;if(!r.length)throw pt({message:'There is no thread in "'+t+'".',code:de});return v.updateThreadProperties({chatId:t,threadId:r[0].id,properties:{rating:n}})}))},resumeChat:function(n){return qr({env:r,licenseId:e.licenseId,eventName:"chat_started"}),f(nn(ke,function(e){var n=Xt(e);return t({},n,{chat:t({},n.chat,{id:e.chat.id})})}(n)))},sendEvent:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return""+e},t}((function(e){return f(function(e){var t=e.attachToLastThread,n={chat_id:e.chatId,event:Kt(e.event)};return t&&(n.attach_to_last_thread=!0),nn(Pe,n)}(e))})),sendTicketForm:function(e){return kr(u,l,e)},sendRichMessagePostback:function(e){return f(nn(Ce,{chat_id:e.chatId,event_id:e.eventId,thread_id:e.threadId,postback:e.postback}))},setCustomerSessionFields:function(e){return f(nn(xe,{session_fields:Wt(e.sessionFields)}))},setSneakPeek:function(e){var t=e.chatId,n=e.sneakPeekText,r=u.getState();rt(r,t)&&ot(r)&&f(nn(Ne,{chat_id:t,sneak_peek_text:n})).catch(g)},startChat:function(t){return void 0===t&&(t={}),qr({env:r,licenseId:e.licenseId,eventName:"chat_started"}),f(nn(je,Xt(t)))},updateChatProperties:function(e){return f(nn(De,{id:e.id,properties:e.properties}))},updateCustomer:function(e){return f(nn(qe,Qt(e)))},updateCustomerPage:function(e){u.dispatch({type:ie,payload:E(["title","url"],e)})},updateEventProperties:function(e){return f(nn(Ae,{chat_id:e.chatId,event_id:e.eventId,thread_id:e.threadId,properties:e.properties}))},updateThreadProperties:function(e){return f(nn(Me,{chat_id:e.chatId,thread_id:e.threadId,properties:e.properties}))},uploadFile:function(e){return Dr({auth:l,store:u},e)}});return a?h():u.dispatch({type:F,payload:{sessionFields:"function"==typeof i?i().sessionFields:{}}}),v},e.parseCustomEvent=bn,e.parseEvent=Sn,e.parseFile=gn,e.parseFilledForm=In,e.parseForm=vr,e.parseGreeting=kn,e.parseMessage=En,e.parseRichMessage=wn,e.parseSystemMessage=On,Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livechat/customer-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "SDK for connecting to LiveChat as a customer",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Konrad Kruk <k.kruk@livechatinc.com>",
|
|
@@ -13,45 +13,50 @@
|
|
|
13
13
|
"unpkg": "dist/customer-sdk.js",
|
|
14
14
|
"react-native": "dist/customer-sdk.cjs.native.js",
|
|
15
15
|
"types": "./types",
|
|
16
|
-
"files": [
|
|
17
|
-
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"livechat"
|
|
21
|
+
],
|
|
18
22
|
"dependencies": {
|
|
19
|
-
"@livechat/
|
|
20
|
-
"@livechat/
|
|
23
|
+
"@livechat/backoff": "^0.1.0",
|
|
24
|
+
"@livechat/customer-auth": "^0.4.0-alpha.7",
|
|
25
|
+
"@livechat/data-utils": "^0.2.16",
|
|
21
26
|
"@livechat/deferred": "^1.1.0",
|
|
22
27
|
"@livechat/file-upload": "^0.3.0",
|
|
23
28
|
"@livechat/isomorphic-storage": "^0.1.0",
|
|
24
29
|
"@livechat/mitt": "^0.1.2",
|
|
25
|
-
"@livechat/platform-client": "^0.
|
|
30
|
+
"@livechat/platform-client": "^0.3.1",
|
|
26
31
|
"@livechat/promise-try": "^0.1.0",
|
|
27
32
|
"@livechat/side-effects-middleware": "^0.2.0",
|
|
28
|
-
"@livechat/url-utils": "^0.
|
|
29
|
-
"backo2": "^1.0.2",
|
|
33
|
+
"@livechat/url-utils": "^0.2.0",
|
|
30
34
|
"redux": "^4.0.4",
|
|
31
35
|
"ts-toolbelt": "^6.7.5",
|
|
32
|
-
"unfetch": "^2.
|
|
36
|
+
"unfetch": "^4.2.0"
|
|
33
37
|
},
|
|
34
38
|
"devDependencies": {
|
|
35
|
-
"@babel/core": "^7.
|
|
36
|
-
"@babel/plugin-proposal-class-properties": "^7.4
|
|
37
|
-
"@babel/plugin-syntax-dynamic-import": "^7.
|
|
38
|
-
"@babel/preset-env": "^7.4
|
|
39
|
-
"@babel/preset-typescript": "^7.
|
|
40
|
-
"
|
|
39
|
+
"@babel/core": "^7.10.5",
|
|
40
|
+
"@babel/plugin-proposal-class-properties": "^7.10.4",
|
|
41
|
+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
42
|
+
"@babel/preset-env": "^7.10.4",
|
|
43
|
+
"@babel/preset-typescript": "^7.10.4",
|
|
44
|
+
"@livechat/customer-api-fake": "*",
|
|
45
|
+
"@rollup/plugin-alias": "^3.1.1",
|
|
46
|
+
"@rollup/plugin-babel": "^5.2.1",
|
|
47
|
+
"@rollup/plugin-commonjs": "^15.0.0",
|
|
48
|
+
"@rollup/plugin-node-resolve": "^9.0.0",
|
|
49
|
+
"@rollup/plugin-replace": "^2.3.3",
|
|
50
|
+
"babel-jest": "^26.6.0",
|
|
41
51
|
"cross-env": "^5.0.0",
|
|
42
52
|
"front-matter": "^2.2.0",
|
|
43
|
-
"jest": "
|
|
53
|
+
"jest": "26.6.0",
|
|
44
54
|
"lerna-alias": "3.0.3-0",
|
|
45
55
|
"lodash": "^4.17.4",
|
|
46
56
|
"rimraf": "^2.6.1",
|
|
47
|
-
"rollup": "^
|
|
48
|
-
"rollup-plugin-
|
|
49
|
-
"rollup-plugin-
|
|
50
|
-
"rollup-plugin-commonjs": "^9.2.0",
|
|
51
|
-
"rollup-plugin-dotenv": "^0.1.0",
|
|
52
|
-
"rollup-plugin-node-resolve": "^3.0.0",
|
|
53
|
-
"rollup-plugin-replace": "^1.1.1",
|
|
54
|
-
"rollup-plugin-uglify": "^2.0.1"
|
|
57
|
+
"rollup": "^2.27.1",
|
|
58
|
+
"rollup-plugin-dotenv": "^0.3.0",
|
|
59
|
+
"rollup-plugin-terser": "^7.0.2"
|
|
55
60
|
},
|
|
56
61
|
"scripts": {
|
|
57
62
|
"docs:concat": "node scripts/concatDocs.js",
|
|
@@ -59,8 +64,8 @@
|
|
|
59
64
|
"build": "rollup -c",
|
|
60
65
|
"test": "jest",
|
|
61
66
|
"example": "npm run start --prefix example",
|
|
62
|
-
"
|
|
67
|
+
"prepare": "npm run build",
|
|
63
68
|
"precommit": "npm run docs:concat && git --git-dir ../../.git --work-tree ../../ add README.md",
|
|
64
|
-
"prepublish": "
|
|
69
|
+
"//prepublish": "echo 'The code in this package connects to the very latest dev Customer API (unstable). It should not be published to npm. If you want to publish a new version you should checkout on the commit that has been used to publish the latest version of this package, apply your changes there and publish from there.' && exit 1 && npm test"
|
|
65
70
|
}
|
|
66
71
|
}
|