UNPKG

widget-chatbot

Version:

- [![React][react.js]][react-url] - [![Socket-io][socket-io-img]][socket-io-url] - [![Chart.js][chart.js-img]][chart.js-url]

1,579 lines (1,577 loc) 161 kB
import bn, { version as Wt, createContext as Te, useContext as ye, useState as D, useRef as K, useMemo as R, useEffect as X, memo as O, Children as Vt, isValidElement as Gt, cloneElement as zt, Fragment as mn, createElement as vn, useCallback as Yt } from "react"; import Oe from "axios"; import ae from "dayjs"; import { version as Kt, Modal as Un, Typography as G, Button as Y, Form as oe, notification as ie, Radio as qt, Divider as Jt, Input as Be, Image as Qt, Skeleton as ue, Avatar as Xn, Upload as Pn, Spin as Zt, Tooltip as Se, Tag as Xt, Badge as Pt, Grid as me, Empty as et, Popover as hn, Mentions as Wn, Select as Vn, DatePicker as es, Result as ns, Tabs as cn } from "antd"; import { io as ts } from "socket.io-client"; import ss from "react-markdown"; import rs from "remark-gfm"; import { Prism as os } from "react-syntax-highlighter"; import cs from "@ant-design/icons"; import { Pie as is } from "@ant-design/charts"; import ke from "crypto-js"; import { Picker as ls } from "emoji-mart"; var Je = { exports: {} }, pe = {}; /* object-assign (c) Sindre Sorhus @license MIT */ var ln, Gn; function nt() { if (Gn) return ln; Gn = 1; var e = Object.getOwnPropertySymbols, t = Object.prototype.hasOwnProperty, r = Object.prototype.propertyIsEnumerable; function s(i) { if (i == null) throw new TypeError("Object.assign cannot be called with null or undefined"); return Object(i); } function l() { try { if (!Object.assign) return !1; var i = new String("abc"); if (i[5] = "de", Object.getOwnPropertyNames(i)[0] === "5") return !1; for (var o = {}, d = 0; d < 10; d++) o["_" + String.fromCharCode(d)] = d; var c = Object.getOwnPropertyNames(o).map(function(f) { return o[f]; }); if (c.join("") !== "0123456789") return !1; var u = {}; return "abcdefghijklmnopqrst".split("").forEach(function(f) { u[f] = f; }), Object.keys(Object.assign({}, u)).join("") === "abcdefghijklmnopqrst"; } catch { return !1; } } return ln = l() ? Object.assign : function(i, o) { for (var d, c = s(i), u, f = 1; f < arguments.length; f++) { d = Object(arguments[f]); for (var x in d) t.call(d, x) && (c[x] = d[x]); if (e) { u = e(d); for (var g = 0; g < u.length; g++) r.call(d, u[g]) && (c[u[g]] = d[u[g]]); } } return c; }, ln; } /** @license React v17.0.2 * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var zn; function as() { if (zn) return pe; zn = 1, nt(); var e = bn, t = 60103; if (pe.Fragment = 60107, typeof Symbol == "function" && Symbol.for) { var r = Symbol.for; t = r("react.element"), pe.Fragment = r("react.fragment"); } var s = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, l = Object.prototype.hasOwnProperty, i = { key: !0, ref: !0, __self: !0, __source: !0 }; function o(d, c, u) { var f, x = {}, g = null, m = null; u !== void 0 && (g = "" + u), c.key !== void 0 && (g = "" + c.key), c.ref !== void 0 && (m = c.ref); for (f in c) l.call(c, f) && !i.hasOwnProperty(f) && (x[f] = c[f]); if (d && d.defaultProps) for (f in c = d.defaultProps, c) x[f] === void 0 && (x[f] = c[f]); return { $$typeof: t, type: d, key: g, ref: m, props: x, _owner: s.current }; } return pe.jsx = o, pe.jsxs = o, pe; } var an = {}; /** @license React v17.0.2 * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var Yn; function ds() { return Yn || (Yn = 1, function(e) { process.env.NODE_ENV !== "production" && function() { var t = bn, r = nt(), s = 60103, l = 60106; e.Fragment = 60107; var i = 60108, o = 60114, d = 60109, c = 60110, u = 60112, f = 60113, x = 60120, g = 60115, m = 60116, T = 60121, w = 60122, _ = 60117, j = 60129, v = 60131; if (typeof Symbol == "function" && Symbol.for) { var h = Symbol.for; s = h("react.element"), l = h("react.portal"), e.Fragment = h("react.fragment"), i = h("react.strict_mode"), o = h("react.profiler"), d = h("react.provider"), c = h("react.context"), u = h("react.forward_ref"), f = h("react.suspense"), x = h("react.suspense_list"), g = h("react.memo"), m = h("react.lazy"), T = h("react.block"), w = h("react.server.block"), _ = h("react.fundamental"), h("react.scope"), h("react.opaque.id"), j = h("react.debug_trace_mode"), h("react.offscreen"), v = h("react.legacy_hidden"); } var b = typeof Symbol == "function" && Symbol.iterator, E = "@@iterator"; function C(a) { if (a === null || typeof a != "object") return null; var y = b && a[b] || a[E]; return typeof y == "function" ? y : null; } var k = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; function S(a) { { for (var y = arguments.length, A = new Array(y > 1 ? y - 1 : 0), N = 1; N < y; N++) A[N - 1] = arguments[N]; F("error", a, A); } } function F(a, y, A) { { var N = k.ReactDebugCurrentFrame, Z = N.getStackAddendum(); Z !== "" && (y += "%s", A = A.concat([Z])); var Q = A.map(function(V) { return "" + V; }); Q.unshift("Warning: " + y), Function.prototype.apply.call(console[a], console, Q); } } var B = !1; function M(a) { return !!(typeof a == "string" || typeof a == "function" || a === e.Fragment || a === o || a === j || a === i || a === f || a === x || a === v || B || typeof a == "object" && a !== null && (a.$$typeof === m || a.$$typeof === g || a.$$typeof === d || a.$$typeof === c || a.$$typeof === u || a.$$typeof === _ || a.$$typeof === T || a[0] === w)); } function L(a, y, A) { var N = y.displayName || y.name || ""; return a.displayName || (N !== "" ? A + "(" + N + ")" : A); } function H(a) { return a.displayName || "Context"; } function $(a) { if (a == null) return null; if (typeof a.tag == "number" && S("Received an unexpected object in getComponentName(). This is likely a bug in React. Please file an issue."), typeof a == "function") return a.displayName || a.name || null; if (typeof a == "string") return a; switch (a) { case e.Fragment: return "Fragment"; case l: return "Portal"; case o: return "Profiler"; case i: return "StrictMode"; case f: return "Suspense"; case x: return "SuspenseList"; } if (typeof a == "object") switch (a.$$typeof) { case c: var y = a; return H(y) + ".Consumer"; case d: var A = a; return H(A._context) + ".Provider"; case u: return L(a, a.render, "ForwardRef"); case g: return $(a.type); case T: return $(a._render); case m: { var N = a, Z = N._payload, Q = N._init; try { return $(Q(Z)); } catch { return null; } } } return null; } var I = 0, J, z, W, te, ee, de, ce; function Ne() { } Ne.__reactDisabledLog = !0; function Ve() { { if (I === 0) { J = console.log, z = console.info, W = console.warn, te = console.error, ee = console.group, de = console.groupCollapsed, ce = console.groupEnd; var a = { configurable: !0, enumerable: !0, value: Ne, writable: !0 }; Object.defineProperties(console, { info: a, log: a, warn: a, error: a, group: a, groupCollapsed: a, groupEnd: a }); } I++; } } function Ge() { { if (I--, I === 0) { var a = { configurable: !0, enumerable: !0, writable: !0 }; Object.defineProperties(console, { log: r({}, a, { value: J }), info: r({}, a, { value: z }), warn: r({}, a, { value: W }), error: r({}, a, { value: te }), group: r({}, a, { value: ee }), groupCollapsed: r({}, a, { value: de }), groupEnd: r({}, a, { value: ce }) }); } I < 0 && S("disabledDepth fell below zero. This is a bug in React. Please file an issue."); } } var Me = k.ReactCurrentDispatcher, Fe; function ze(a, y, A) { { if (Fe === void 0) try { throw Error(); } catch (Z) { var N = Z.stack.trim().match(/\n( *(at )?)/); Fe = N && N[1] || ""; } return ` ` + Fe + a; } } var nn = !1, Ye; { var jt = typeof WeakMap == "function" ? WeakMap : Map; Ye = new jt(); } function _n(a, y) { if (!a || nn) return ""; { var A = Ye.get(a); if (A !== void 0) return A; } var N; nn = !0; var Z = Error.prepareStackTrace; Error.prepareStackTrace = void 0; var Q; Q = Me.current, Me.current = null, Ve(); try { if (y) { var V = function() { throw Error(); }; if (Object.defineProperty(V.prototype, "props", { set: function() { throw Error(); } }), typeof Reflect == "object" && Reflect.construct) { try { Reflect.construct(V, []); } catch (ge) { N = ge; } Reflect.construct(a, [], V); } else { try { V.call(); } catch (ge) { N = ge; } a.call(V.prototype); } } else { try { throw Error(); } catch (ge) { N = ge; } a(); } } catch (ge) { if (ge && N && typeof ge.stack == "string") { for (var U = ge.stack.split(` `), re = N.stack.split(` `), ne = U.length - 1, se = re.length - 1; ne >= 1 && se >= 0 && U[ne] !== re[se]; ) se--; for (; ne >= 1 && se >= 0; ne--, se--) if (U[ne] !== re[se]) { if (ne !== 1 || se !== 1) do if (ne--, se--, se < 0 || U[ne] !== re[se]) { var xe = ` ` + U[ne].replace(" at new ", " at "); return typeof a == "function" && Ye.set(a, xe), xe; } while (ne >= 1 && se >= 0); break; } } } finally { nn = !1, Me.current = Q, Ge(), Error.prepareStackTrace = Z; } var we = a ? a.displayName || a.name : "", Bn = we ? ze(we) : ""; return typeof a == "function" && Ye.set(a, Bn), Bn; } function An(a, y, A) { return _n(a, !1); } function wt(a) { var y = a.prototype; return !!(y && y.isReactComponent); } function Ke(a, y, A) { if (a == null) return ""; if (typeof a == "function") return _n(a, wt(a)); if (typeof a == "string") return ze(a); switch (a) { case f: return ze("Suspense"); case x: return ze("SuspenseList"); } if (typeof a == "object") switch (a.$$typeof) { case u: return An(a.render); case g: return Ke(a.type, y, A); case T: return An(a._render); case m: { var N = a, Z = N._payload, Q = N._init; try { return Ke(Q(Z), y, A); } catch { } } } return ""; } var Sn = {}, Ln = k.ReactDebugCurrentFrame; function qe(a) { if (a) { var y = a._owner, A = Ke(a.type, a._source, y ? y.type : null); Ln.setExtraStackFrame(A); } else Ln.setExtraStackFrame(null); } function kt(a, y, A, N, Z) { { var Q = Function.call.bind(Object.prototype.hasOwnProperty); for (var V in a) if (Q(a, V)) { var U = void 0; try { if (typeof a[V] != "function") { var re = Error((N || "React class") + ": " + A + " type `" + V + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof a[V] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); throw re.name = "Invariant Violation", re; } U = a[V](y, V, N, A, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); } catch (ne) { U = ne; } U && !(U instanceof Error) && (qe(Z), S("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", N || "React class", A, V, typeof U), qe(null)), U instanceof Error && !(U.message in Sn) && (Sn[U.message] = !0, qe(Z), S("Failed %s type: %s", A, U.message), qe(null)); } } } var Rn = k.ReactCurrentOwner, tn = Object.prototype.hasOwnProperty, pt = { key: !0, ref: !0, __self: !0, __source: !0 }, On, Dn; function _t(a) { if (tn.call(a, "ref")) { var y = Object.getOwnPropertyDescriptor(a, "ref").get; if (y && y.isReactWarning) return !1; } return a.ref !== void 0; } function At(a) { if (tn.call(a, "key")) { var y = Object.getOwnPropertyDescriptor(a, "key").get; if (y && y.isReactWarning) return !1; } return a.key !== void 0; } function St(a, y) { typeof a.ref == "string" && Rn.current; } function Lt(a, y) { { var A = function() { On || (On = !0, S("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", y)); }; A.isReactWarning = !0, Object.defineProperty(a, "key", { get: A, configurable: !0 }); } } function Rt(a, y) { { var A = function() { Dn || (Dn = !0, S("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", y)); }; A.isReactWarning = !0, Object.defineProperty(a, "ref", { get: A, configurable: !0 }); } } var Ot = function(a, y, A, N, Z, Q, V) { var U = { // This tag allows us to uniquely identify this as a React Element $$typeof: s, // Built-in properties that belong on the element type: a, key: y, ref: A, props: V, // Record the component responsible for creating this element. _owner: Q }; return U._store = {}, Object.defineProperty(U._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: !1 }), Object.defineProperty(U, "_self", { configurable: !1, enumerable: !1, writable: !1, value: N }), Object.defineProperty(U, "_source", { configurable: !1, enumerable: !1, writable: !1, value: Z }), Object.freeze && (Object.freeze(U.props), Object.freeze(U)), U; }; function Dt(a, y, A, N, Z) { { var Q, V = {}, U = null, re = null; A !== void 0 && (U = "" + A), At(y) && (U = "" + y.key), _t(y) && (re = y.ref, St(y, Z)); for (Q in y) tn.call(y, Q) && !pt.hasOwnProperty(Q) && (V[Q] = y[Q]); if (a && a.defaultProps) { var ne = a.defaultProps; for (Q in ne) V[Q] === void 0 && (V[Q] = ne[Q]); } if (U || re) { var se = typeof a == "function" ? a.displayName || a.name || "Unknown" : a; U && Lt(V, se), re && Rt(V, se); } return Ot(a, U, re, Z, N, Rn.current, V); } } var sn = k.ReactCurrentOwner, Nn = k.ReactDebugCurrentFrame; function je(a) { if (a) { var y = a._owner, A = Ke(a.type, a._source, y ? y.type : null); Nn.setExtraStackFrame(A); } else Nn.setExtraStackFrame(null); } var rn; rn = !1; function on(a) { return typeof a == "object" && a !== null && a.$$typeof === s; } function Mn() { { if (sn.current) { var a = $(sn.current.type); if (a) return ` Check the render method of \`` + a + "`."; } return ""; } } function Nt(a) { return ""; } var Fn = {}; function Mt(a) { { var y = Mn(); if (!y) { var A = typeof a == "string" ? a : a.displayName || a.name; A && (y = ` Check the top-level render call using <` + A + ">."); } return y; } } function Hn(a, y) { { if (!a._store || a._store.validated || a.key != null) return; a._store.validated = !0; var A = Mt(y); if (Fn[A]) return; Fn[A] = !0; var N = ""; a && a._owner && a._owner !== sn.current && (N = " It was passed a child from " + $(a._owner.type) + "."), je(a), S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', A, N), je(null); } } function In(a, y) { { if (typeof a != "object") return; if (Array.isArray(a)) for (var A = 0; A < a.length; A++) { var N = a[A]; on(N) && Hn(N, y); } else if (on(a)) a._store && (a._store.validated = !0); else if (a) { var Z = C(a); if (typeof Z == "function" && Z !== a.entries) for (var Q = Z.call(a), V; !(V = Q.next()).done; ) on(V.value) && Hn(V.value, y); } } } function Ft(a) { { var y = a.type; if (y == null || typeof y == "string") return; var A; if (typeof y == "function") A = y.propTypes; else if (typeof y == "object" && (y.$$typeof === u || // Note: Memo only checks outer props here. // Inner props are checked in the reconciler. y.$$typeof === g)) A = y.propTypes; else return; if (A) { var N = $(y); kt(A, a.props, "prop", N, a); } else if (y.PropTypes !== void 0 && !rn) { rn = !0; var Z = $(y); S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", Z || "Unknown"); } typeof y.getDefaultProps == "function" && !y.getDefaultProps.isReactClassApproved && S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); } } function Ht(a) { { for (var y = Object.keys(a.props), A = 0; A < y.length; A++) { var N = y[A]; if (N !== "children" && N !== "key") { je(a), S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", N), je(null); break; } } a.ref !== null && (je(a), S("Invalid attribute `ref` supplied to `React.Fragment`."), je(null)); } } function $n(a, y, A, N, Z, Q) { { var V = M(a); if (!V) { var U = ""; (a === void 0 || typeof a == "object" && a !== null && Object.keys(a).length === 0) && (U += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); var re = Nt(); re ? U += re : U += Mn(); var ne; a === null ? ne = "null" : Array.isArray(a) ? ne = "array" : a !== void 0 && a.$$typeof === s ? (ne = "<" + ($(a.type) || "Unknown") + " />", U = " Did you accidentally export a JSX literal instead of a component?") : ne = typeof a, S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", ne, U); } var se = Dt(a, y, A, Z, Q); if (se == null) return se; if (V) { var xe = y.children; if (xe !== void 0) if (N) if (Array.isArray(xe)) { for (var we = 0; we < xe.length; we++) In(xe[we], a); Object.freeze && Object.freeze(xe); } else S("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); else In(xe, a); } return a === e.Fragment ? Ht(se) : Ft(se), se; } } function It(a, y, A) { return $n(a, y, A, !0); } function $t(a, y, A) { return $n(a, y, A, !1); } var Bt = $t, Ut = It; e.jsx = Bt, e.jsxs = Ut; }(); }(an)), an; } var Kn; function us() { return Kn || (Kn = 1, process.env.NODE_ENV === "production" ? Je.exports = as() : Je.exports = ds()), Je.exports; } var n = us(); const fs = "2.0.0-alpha.21", tt = "chat_session", xs = "user_uttered", gs = "bot_uttered", ms = "ehelp_bot_uttered", Cs = "https://sfchatbot.dataon.com", bs = [ { label: "Didn’t address my question", value: "Didn’t address my question" }, { label: "Inaccurate Answer", value: "Inaccurate Answer" }, { label: "The response unclear", value: "The response unclear" }, { label: "The information is incomplete", value: "The information is incomplete" }, { label: "I’d like to explain further", value: "another" } ], Le = Kt, Re = Wt, vs = fs, hs = "https://sfchatbot.dataon.com/openai-service-dev/", Ze = "https://res.cloudinary.com/dcvolkyfb/image/upload/v1740135794/svg/bot_profile_hlnyop.png", En = "YYYY-MM-DD", Xe = "HH:mm", qn = "N/A", dn = [ // Raster (bitmap) ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".tif", ".webp", ".heif", ".heic", ".jp2", ".ico", ".dds", ".raw", ".cr2", ".nef", ".arw", ".orf", ".psd", ".xcf" ], un = "w-widget-content-container", fn = "w-ticket-detail-content-container", Es = "w-wrapper-body", Ts = "w-wrapper-body-helpdesk", He = "w-header", xn = { FADE_IN: "w-fade-in-animate" }, ys = "https://placehold.co/600x400?text=No+Image", Ie = 3, js = "GoHRDev2025WorkPlazeDataOnDotCom", _e = "(Helpdesk Widget Chatbot)", ws = (e) => JSON.parse((e == null ? void 0 : e.replaceAll("/get_started", "")) || "{}"), st = (e) => { var t; try { return (t = new URL(e)) == null ? void 0 : t.host; } catch { return st(Cs); } }, le = (e, t) => { var r, s, l; return ((r = Object.keys(e || {})) == null ? void 0 : r.length) > 0 ? (l = (s = Object == null ? void 0 : Object.prototype) == null ? void 0 : s.hasOwnProperty) == null ? void 0 : l.call(e, t) : !1; }, Ae = (e) => { var r; const t = e == null ? void 0 : e.attachment; return { text: ((r = Object.keys(e || {})) == null ? void 0 : r.length) > 0 && (e == null ? void 0 : e.type) === "text", upload: le(e, "attachment") && le(t, "type") && (t == null ? void 0 : t.type) === "fileuploader", password: (t == null ? void 0 : t.type) === "show_password_wp", filedownload: le(t, "type") && (t == null ? void 0 : t.type) === "filedownloader", chart: (t == null ? void 0 : t.type) === "charts" && le(t, "chartType") }; }, rt = (e) => { var t, r, s, l; if (e) { const i = e == null ? void 0 : e.split(".")[1], o = (t = i == null ? void 0 : i.replace(/-/g, "+")) == null ? void 0 : t.replace(/_/g, "/"), d = decodeURIComponent( (l = (s = (r = window == null ? void 0 : window.atob(o)) == null ? void 0 : r.split("")) == null ? void 0 : s.map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2))) == null ? void 0 : l.join("") ); return JSON == null ? void 0 : JSON.parse(d || "{}"); } return {}; }, Tn = ({ downloadURL: e = "", fileName: t = "", isOpenNewTab: r = !1 }) => { var l; const s = document == null ? void 0 : document.createElement("a"); s.href = e, s.download = t || e, r && (s.target = "_blank"), (l = document == null ? void 0 : document.body) == null || l.appendChild(s), s.click(), document.body.removeChild(s); }, ks = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) { const t = crypto.getRandomValues(new Uint8Array(1))[0] % 16; return (e === "x" ? t : t & 3 | 8).toString(16); }), yn = ({ ArrObj: e, key: t, ignoreCaseSensitive: r = !1 }) => (e == null ? void 0 : e.length) > 0 ? [ ...new Map( e.map((s) => { var l; return [ r ? (l = String(s[t])) == null ? void 0 : l.toLowerCase() : s[t], s ]; }) ).values() ] : [], ps = (e = []) => { const t = {}, r = [], s = []; e == null || e.forEach((i) => { var o; le(i, "chats") ? (o = i == null ? void 0 : i.chats) == null || o.forEach((d) => { s == null || s.push(d); }) : s == null || s.push(i); }), s == null || s.forEach((i, o) => { var c, u, f; const d = i == null ? void 0 : i.generated_id; d ? (t[d] || (t[d] = []), (u = t[d]) == null || u.push({ ...i, indexChat: o, ...!(i != null && i.timestamp) && { timestamp: (c = ae()) == null ? void 0 : c.format("hh:mm A") } }), r == null || r.push({ keyItem: d ?? o, type: "text", sender: "response", ...d && { generated_id: d }, chats: t == null ? void 0 : t[d] })) : r == null || r.push({ ...i, keyItem: o, ...!(i != null && i.timestamp) && { timestamp: (f = ae()) == null ? void 0 : f.format("hh:mm A") } }); }); const l = yn({ ArrObj: r, key: "keyItem" }); return l == null || l.forEach((i) => { i == null || delete i.keyItem; }), l; }, Pe = (e = {}) => { const r = { ...ot(), ...e }; localStorage == null || localStorage.setItem(tt, JSON.stringify(r || {})); }, ot = () => { const e = localStorage == null ? void 0 : localStorage.getItem(tt); return JSON.parse(e || "{}"); }, _s = (e = "") => { var t; try { const r = new URL(e); return (t = r == null ? void 0 : r.protocol) != null && t.includes("https") ? "wss" : "ws"; } catch { return "wss"; } }; let Jn = null; const Ce = (e = ".w-wrapper-body") => { const t = document.querySelector(e); clearTimeout(Jn), Jn = setTimeout(() => { t && t.scrollTo({ top: t.scrollHeight, behavior: "smooth" }); }, 0); }, As = (e) => { const t = new Uint8Array(e); let r = ""; for (let s = 0; s < t.byteLength; s++) r += String.fromCharCode(t[s]); return btoa(r); }, Ss = async (e, t) => { var c; const r = typeof e == "object" ? JSON == null ? void 0 : JSON.stringify(e || {}) : e, s = new TextEncoder(), l = s == null ? void 0 : s.encode(r), i = s == null ? void 0 : s.encode(t); if (i.length !== 32) throw new Error("Key length must be 32 bytes for AES-256"); const o = await ((c = crypto == null ? void 0 : crypto.subtle) == null ? void 0 : c.importKey( "raw", i, { name: "AES-CBC" }, !1, ["encrypt"] )), d = await crypto.subtle.encrypt( { name: "AES-CBC", iv: new Uint8Array(16) }, o, l ); return As(d); }, Qe = (e) => { const t = {}, r = ct(e), s = r == null ? void 0 : r.map((l) => { var o; const i = l == null ? void 0 : l.CREATED_DATE; return { ...l, DATE_KEY: (o = ae(i)) == null ? void 0 : o.format("YYYY-MM-DD") }; }); return s == null || s.forEach((l) => { var i; t[l == null ? void 0 : l.DATE_KEY] || (t[l == null ? void 0 : l.DATE_KEY] = []), (i = t[l == null ? void 0 : l.DATE_KEY]) == null || i.push(l); }), t; }, jn = (e) => { var t; return (t = Object.values(e || {})) == null ? void 0 : t.flat(); }, ct = (e) => e == null ? void 0 : e.sort((t, r) => ae(t == null ? void 0 : t.CREATED_DATE) - ae(r == null ? void 0 : r.CREATED_DATE)), it = (e) => { if (e && typeof e == "string") { const t = e == null ? void 0 : e.split("."), r = t[(t == null ? void 0 : t.length) - 1]; return e == null ? void 0 : e.replaceAll(`.${r}`, `_avatar.${r}`); } return e; }, wn = (e) => `https://ui-avatars.com/api/?background=e5e5e5&color=000${e && typeof e == "string" ? `&name=${e.replaceAll(" ", "+")}` : ""}`, Qn = (e) => URL.parse(e) && new URL(e), gn = (e) => { try { return new URL(e); } catch { return {}; } }, lt = Te({}), q = () => ye(lt), Ls = ({ children: e, getStartedPayload: t, socketURL: r, socketPath: s, onPayslipFn: l, title: i, subTitle: o, keyEncrypt: d, history: c, modelName: u, isSF: f }) => { const [x, g] = D(!1), [m, T] = D("va"), [w, _] = D(!1), [j, v] = D({}), [h, b] = D(!1), [E, C] = D(!1), k = K(!1), S = R(() => ({ getStartedPayload: t, socketURL: r, socketPath: s, onPayslipFn: l, title: i, subTitle: o, keyEncrypt: d, history: c, modelName: u, isSF: f }), [ t, r, s, l, i, o, d, c, u, f ]), F = R(() => rt(j == null ? void 0 : j.access_token), [j == null ? void 0 : j.access_token]); return X(() => { v(ws(t)); }, [t]), X(() => { Pe({ chatbot_version: vs }); }, []), /* @__PURE__ */ n.jsx( lt.Provider, { value: { objInitPayload: j, setOpenWidget: g, isOpenWidget: x, activeTab: m, setActiveTab: T, isExpand: w, setExpand: _, setObjInitPayload: v, parsedJWT: F, widgetProps: S, isFirstOpenWidget: h, setFirstOpenWidget: b, isFirstRenderHelpdesk: k, showReadyWSHD: E, setShowReadyWSHD: C }, children: e } ); }, at = Te({}), Rs = () => ye(at), Os = ({ children: e }) => { const { objInitPayload: t } = q(), [r, s] = D({}), l = () => { var o; (o = Oe( `${(t == null ? void 0 : t.uriService) || hs}optional/translations` )) == null || o.then(({ data: d }) => { var c; if (d) { const u = Object.keys((c = Object.values(d)) == null ? void 0 : c[0]), f = {}; u == null || u.forEach((x) => { var g; (g = Object.keys(d)) == null || g.forEach((m) => { var T; f[x == null ? void 0 : x.toLowerCase()] = (T = d == null ? void 0 : d[m]) == null ? void 0 : T[x]; }); }), s(f); } }); }, i = () => { const o = window.indexedDB.open("language"); o.onsuccess = (d) => { var u; const c = d.target.result; try { const x = c.transaction("keyvaluepairs", "readonly").objectStore("keyvaluepairs"), g = x == null ? void 0 : x.get((u = t == null ? void 0 : t.lang) == null ? void 0 : u.toLowerCase()); g.onsuccess = () => { s(g == null ? void 0 : g.result); }, g.onerror = () => { l(); }; } catch { l(); } }, o.onerror = () => { l(); }; }; return X(() => { i(); }, [t == null ? void 0 : t.uriService, t == null ? void 0 : t.lang]), /* @__PURE__ */ n.jsx(at.Provider, { value: { langDatas: r }, children: e }); }, dt = Te({}), fe = () => ye(dt), Ds = ({ children: e }) => { var M; const [t, r] = D([]), [s, l] = D(!1), [i, o] = D(!1), [d, c] = D({}), [u, f] = D(!1), [x, g] = D(!1), { objInitPayload: m, widgetProps: T, setOpenWidget: w, setFirstOpenWidget: _, isFirstRenderHelpdesk: j } = q(), v = K(null), h = K(""), b = K(""), E = (L) => { var $; if (!(($ = L == null ? void 0 : L.metadata) == null ? void 0 : $.stopped)) { const I = le(L, "text_feedback_link") && le(L, "text"); r((J) => { const z = [ ...J, { ...L, ...I && { type: "text" }, sender: "response" } ]; return ps(z); }); } l(!1), o(!1), Ce(); }, C = (L) => { var H, $, I, J; L && k({ msg: T == null ? void 0 : T.getStartedPayload }), (H = v == null ? void 0 : v.current) == null || H.emit("session_request", { session_id: null }), ($ = v == null ? void 0 : v.current) == null || $.on("session_confirm", (z) => { h.current = z, Pe({ session_id: z == null ? void 0 : z.session_id }); }), (I = v == null ? void 0 : v.current) == null || I.on(gs, E), (J = v == null ? void 0 : v.current) == null || J.on(ms, (z) => { const W = JSON.parse(z || "{}"); le(W, "iswidget") && g(W == null ? void 0 : W.iswidget); }), u || f(!0), _(!1); }, k = ({ msg: L, additionalConfig: H = {}, isShowLoadingResponse: $ = !0 }) => { var I; (I = v == null ? void 0 : v.current) == null || I.emit(xs, { customData: { language: m == null ? void 0 : m.lang }, message: L, session_id: h == null ? void 0 : h.current, ...H }), $ ? l(!0) : o(!0); }, S = (L = !1) => { var $, I; v.current && (($ = v == null ? void 0 : v.current) == null || $.off(), (I = v == null ? void 0 : v.current) == null || I.disconnect(), v.current = null), j.current = !1; const H = ts( `${_s(T == null ? void 0 : T.socketURL)}://${st( T == null ? void 0 : T.socketURL )}`, { path: T == null ? void 0 : T.socketPath, transports: ["websocket"], reconnection: !0, reconnectionAttempts: 1 } ); H.on("connect", () => { C(L); }), H.on("connect_error", (J) => { console.error("connect_error widget-chatbot : ", { err: J, socketURL: T == null ? void 0 : T.socketURL, socketPath: T == null ? void 0 : T.widgetProps }), f(!1); }), H.io.on("reconnect", () => { console.error("reconnect widget-chatbot : ", { socketURL: T == null ? void 0 : T.socketURL, socketPath: T == null ? void 0 : T.widgetProps }), f(!1); }), v.current = H; }, F = () => { var L; (!((L = v == null ? void 0 : v.current) != null && L.connected) || !u) && (S(), w(!1)); }, B = () => { f(!1); }; return X(() => (w(!1), S(), window.addEventListener("online", F), window.addEventListener("offline", B), () => { var L, H; v.current && ((L = v.current) == null || L.off("connect", C), (H = v.current) == null || H.disconnect(), v.current = null), window.removeEventListener("online", F), window.removeEventListener("offline", B); }), [ JSON.stringify(m || {}), T == null ? void 0 : T.socketURL, T == null ? void 0 : T.socketPath ]), /* @__PURE__ */ n.jsx( dt.Provider, { value: { setChats: r, chats: t, onSendMsg: k, isWaitResponse: s, socket: v == null ? void 0 : v.current, sessionId: (M = h == null ? void 0 : h.current) == null ? void 0 : M.session_id, loadingRegenerate: i, file: d, setFile: c, connected: u, isHandshakeWidget: x, createSocket: S, currRegenerateId: b }, children: e } ); }, Ns = { 'pre[class*="language-"]': { color: "#d4d4d4", fontSize: "13px", textShadow: "none", fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace', direction: "ltr", textAlign: "left", whiteSpace: "pre", wordSpacing: "normal", wordBreak: "normal", lineHeight: "1.5", MozTabSize: "4", OTabSize: "4", tabSize: "4", WebkitHyphens: "none", MozHyphens: "none", msHyphens: "none", hyphens: "none", padding: "1em", margin: ".5em 0", overflow: "auto", background: "#1e1e1e" }, 'code[class*="language-"]': { color: "#d4d4d4", fontSize: "13px", textShadow: "none", fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace', direction: "ltr", textAlign: "left", whiteSpace: "pre", wordSpacing: "normal", wordBreak: "normal", lineHeight: "1.5", MozTabSize: "4", OTabSize: "4", tabSize: "4", WebkitHyphens: "none", MozHyphens: "none", msHyphens: "none", hyphens: "none" }, 'pre[class*="language-"]::selection': { textShadow: "none", background: "#264F78" }, 'code[class*="language-"]::selection': { textShadow: "none", background: "#264F78" }, 'pre[class*="language-"] *::selection': { textShadow: "none", background: "#264F78" }, 'code[class*="language-"] *::selection': { textShadow: "none", background: "#264F78" }, ':not(pre) > code[class*="language-"]': { padding: ".1em .3em", borderRadius: ".3em", color: "#db4c69", background: "#1e1e1e" }, ".namespace": { Opacity: ".7" }, "doctype.doctype-tag": { color: "#569CD6" }, "doctype.name": { color: "#9cdcfe" }, comment: { color: "#6a9955" }, prolog: { color: "#6a9955" }, punctuation: { color: "#d4d4d4" }, ".language-html .language-css .token.punctuation": { color: "#d4d4d4" }, ".language-html .language-javascript .token.punctuation": { color: "#d4d4d4" }, property: { color: "#9cdcfe" }, tag: { color: "#569cd6" }, boolean: { color: "#569cd6" }, number: { color: "#b5cea8" }, constant: { color: "#9cdcfe" }, symbol: { color: "#b5cea8" }, inserted: { color: "#b5cea8" }, unit: { color: "#b5cea8" }, selector: { color: "#d7ba7d" }, "attr-name": { color: "#9cdcfe" }, string: { color: "#ce9178" }, char: { color: "#ce9178" }, builtin: { color: "#ce9178" }, deleted: { color: "#ce9178" }, ".language-css .token.string.url": { textDecoration: "underline" }, operator: { color: "#d4d4d4" }, entity: { color: "#569cd6" }, "operator.arrow": { color: "#569CD6" }, atrule: { color: "#ce9178" }, "atrule.rule": { color: "#c586c0" }, "atrule.url": { color: "#9cdcfe" }, "atrule.url.function": { color: "#dcdcaa" }, "atrule.url.punctuation": { color: "#d4d4d4" }, keyword: { color: "#569CD6" }, "keyword.module": { color: "#c586c0" }, "keyword.control-flow": { color: "#c586c0" }, function: { color: "#dcdcaa" }, "function.maybe-class-name": { color: "#dcdcaa" }, regex: { color: "#d16969" }, important: { color: "#569cd6" }, italic: { fontStyle: "italic" }, "class-name": { color: "#4ec9b0" }, "maybe-class-name": { color: "#4ec9b0" }, console: { color: "#9cdcfe" }, parameter: { color: "#9cdcfe" }, interpolation: { color: "#9cdcfe" }, "punctuation.interpolation-punctuation": { color: "#569cd6" }, variable: { color: "#9cdcfe" }, "imports.maybe-class-name": { color: "#9cdcfe" }, "exports.maybe-class-name": { color: "#9cdcfe" }, escape: { color: "#d7ba7d" }, "tag.punctuation": { color: "#808080" }, cdata: { color: "#808080" }, "attr-value": { color: "#ce9178" }, "attr-value.punctuation": { color: "#ce9178" }, "attr-value.punctuation.attr-equals": { color: "#d4d4d4" }, namespace: { color: "#4ec9b0" }, 'pre[class*="language-javascript"]': { color: "#9cdcfe" }, 'code[class*="language-javascript"]': { color: "#9cdcfe" }, 'pre[class*="language-jsx"]': { color: "#9cdcfe" }, 'code[class*="language-jsx"]': { color: "#9cdcfe" }, 'pre[class*="language-typescript"]': { color: "#9cdcfe" }, 'code[class*="language-typescript"]': { color: "#9cdcfe" }, 'pre[class*="language-tsx"]': { color: "#9cdcfe" }, 'code[class*="language-tsx"]': { color: "#9cdcfe" }, 'pre[class*="language-css"]': { color: "#ce9178" }, 'code[class*="language-css"]': { color: "#ce9178" }, 'pre[class*="language-html"]': { color: "#d4d4d4" }, 'code[class*="language-html"]': { color: "#d4d4d4" }, ".language-regex .token.anchor": { color: "#dcdcaa" }, ".language-html .token.punctuation": { color: "#808080" }, 'pre[class*="language-"] > code[class*="language-"]': { position: "relative", zIndex: "1" }, ".line-highlight.line-highlight": { background: "#f7ebc6", boxShadow: "inset 5px 0 0 #f7d87c", zIndex: "0" } }, Ms = (e) => e.replace(/[^a-zA-Z0-9_]/g, "").trim(), p = (e = "", t) => { var o; const { langDatas: r } = Rs(), s = localStorage == null ? void 0 : localStorage.getItem("show_text_id"), l = Ms(String(e)), i = (r == null ? void 0 : r[l == null ? void 0 : l.toUpperCase()]) || t; return ((o = Object.keys(r || {})) == null ? void 0 : o.length) > 0 ? s ? `WPUI_${l}` : i : t; }, Fs = ({ isFeedback: e = !1, open: t, ...r }) => { var l; const s = R(() => e ? "w-modal-container-feedback" : "", [e]); return Le != null && Le.startsWith("5") ? /* @__PURE__ */ n.jsx( Un, { rootClassName: s, ...r, open: t, getContainer: "#w-widget-content", maskProps: { style: { backdropFilter: "blur(4px)" } }, width: 300, style: { ...Object.keys((r == null ? void 0 : r.style) || {}).length > 0 && { ...r == null ? void 0 : r.style }, top: 20 } } ) : ( // <div className={rootClassName}> /* @__PURE__ */ n.jsx( Un, { getContainer: "#w-widget-content", width: 300, ...r, ...Re != null && Re.startsWith("18") ? { open: t } : { visible: t }, maskStyle: { backdropFilter: "blur(4x)", ...((l = Object.keys((r == null ? void 0 : r.maskStyle) || {})) == null ? void 0 : l.length) > 0 && { ...r == null ? void 0 : r.maskStyle } }, style: { ...Object.keys((r == null ? void 0 : r.style) || {}).length > 0 && { ...r == null ? void 0 : r.style }, top: 20 } } ) ); }, ut = O(Fs), Zn = ({ props: e, isModal: t = !1 }) => { const r = (s, l) => { var i; return (i = Vt) == null ? void 0 : i.map(s, (o) => { var d, c, u; return !Gt(o) || ((d = Object.keys((o == null ? void 0 : o.props) || {})) == null ? void 0 : d.length) === 0 ? o : zt(o, { ...o == null ? void 0 : o.props, ...(o == null ? void 0 : o.type) === "thead" && { className: "ant-table-thead" }, ...((o == null ? void 0 : o.type) === "th" || (o == null ? void 0 : o.type) === "td") && { className: "ant-table-cell", ...(o == null ? void 0 : o.type) === "th" && { style: { background: "var(--primary-color, #395ebc)", color: "#ffffff", minWidth: 180 } } }, ...o.type === "tr" && l === "tbody" && { className: "ant-table-row" }, ...(o == null ? void 0 : o.type) === "tbody" && { className: "ant-table-tbody" }, children: (c = o == null ? void 0 : o.props) != null && c.children ? r((u = o == null ? void 0 : o.props) == null ? void 0 : u.children, o == null ? void 0 : o.type) : o == null ? void 0 : o.props }); }); }; return /* @__PURE__ */ n.jsx(n.Fragment, { children: /* @__PURE__ */ n.jsx("div", { className: "ant-table", children: /* @__PURE__ */ n.jsx("div", { className: "ant-table-container", children: /* @__PURE__ */ n.jsx( "div", { className: "ant-table-content", style: { overflow: "scroll", maxWidth: t ? "100%" : 330, maxHeight: t ? "100%" : 360 }, children: /* @__PURE__ */ n.jsx("table", { className: "wp-md-table", ...e, children: r(e == null ? void 0 : e.children, "") }) } ) }) }) }); }, Hs = ({ children: e }) => { const t = p( "OpenDetailTable", "Open Detail Table" ), r = p("TableDetail", "Tabel Detail"), { widgetProps: s, objInitPayload: l } = q(), [i, o] = D(!1), d = { table: ({ ...c }) => /* @__PURE__ */ n.jsxs(n.Fragment, { children: [ /* @__PURE__ */ n.jsx(Zn, { props: c }), /* @__PURE__ */ n.jsx( "div", { style: { display: "flex", justifyContent: "center", padding: "5px 0px 10px 0px" }, children: /* @__PURE__ */ n.jsx( Y, { onClick: () => { o(!0); }, children: t } ) } ), /* @__PURE__ */ n.jsx( ut, { getContainer: () => document.body, footer: null, title: r, width: 800, open: i, onCancel: () => { o(!1); }, children: /* @__PURE__ */ n.jsx(Zn, { props: c, isModal: !0 }) } ) ] }), code: ({ ...c }) => { const { children: u, className: f, ...x } = c, g = /language-(\w+)/.exec(f || ""); return g ? /* @__PURE__ */ n.jsx( os, { ...x, PreTag: "div", language: g[1], style: Ns, children: String(u).replace(/\n$/, "") } ) : /* @__PURE__ */ n.jsx(G.Text, { code: !0, children: c == null ? void 0 : c.children }); }, a: ({ ...c }) => { var m, T, w, _; const u = c == null ? void 0 : c.href, f = (m = c == null ? void 0 : c.children) == null ? void 0 : m[0], x = Qn(u), g = Qn(l == null ? void 0 : l.uriBackend); if (x && g) { const j = (T = gn(u)) == null ? void 0 : T.origin, v = (w = gn(l == null ? void 0 : l.uriBackend)) == null ? void 0 : w.origin; if ((j == null ? void 0 : j.toLowerCase()) === (v == null ? void 0 : v.toLowerCase())) { const h = (_ = gn(u)) == null ? void 0 : _.pathname; return /* @__PURE__ */ n.jsx( "span", { ...c, className: "w-link-path", onClick: (b) => { var E, C; b == null || b.stopPropagation(), h && ((E = Object.keys((s == null ? void 0 : s.history) || {})) == null ? void 0 : E.length) > 0 && ((C = s == null ? void 0 : s.history) == null || C.push(h)); }, children: f } ); } } return /* @__PURE__ */ n.jsx("a", { ...c, target: "_blank", className: "w-link-path" }); } }; return /* @__PURE__ */ n.jsx(ss, { remarkPlugins: [rs], components: d, children: e }); }, ft = O(Hs), Is = () => /* @__PURE__ */ n.jsx( "svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ n.jsx( "path", { fillRule: "evenodd", clipRule: "evenodd", d: "M5.25 4.5H18.75C19.5 4.5 19.5 5.44772 19.5 6V18C19.5 18.5523 19.5 19.5 18.75 19.5H5.25C4.5 19.5 4.5 18.5523 4.5 18V6C4.5 5.44772 4.5 4.5 5.25 4.5ZM3 6C3 4.34315 4.34315 3 6 3H18C19.6569 3 21 4.34315 21 6V18C21 19.6569 19.6569 21 18 21H6C4.34315 21 3 19.6569 3 18V6ZM17 17V15.75H7V17H17Z", fill: "white" } ) } ), $s = () => /* @__PURE__ */ n.jsx( "svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", style: { transform: "rotate(0deg)", transition: "300ms" }, children: /* @__PURE__ */ n.jsx( "path", { d: "M11.325 21H5.175C3.97