@upstep/js 0.7.2 → 0.9.0

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 CHANGED
@@ -70,10 +70,28 @@ Every entry point (`Upstep.init`, `<UpstepProvider>`, and the script tag's `data
70
70
  | `apiKey` | `string` | — | **Required.** Your project's API key. |
71
71
  | `userId` | `string` | — | End-user id from your app, used to deduplicate votes per user. Call `identify(userId)` if it's only known after login. |
72
72
  | `baseUrl` | `string` | `https://upstep.dev` | Only needed for self-hosted or staging setups. |
73
- | `accentColor` | `string` | `#D97757` | Any CSS color, used for the launcher button and highlights. |
73
+ | `accentColor` | `string` | `#C9481F` light / `#FF7A50` dark | Any CSS color, used for the launcher button and highlights. |
74
74
  | `theme` | `"light" \| "dark" \| "auto"` | `"auto"` | `"auto"` follows the host page's `prefers-color-scheme`. |
75
75
  | `position` | `"left" \| "right"` | `"right"` | Deprecated. Website launchers and panels stay bottom-right. |
76
76
  | `launcher` | `boolean` | `true` | Set `false` to hide the floating button and trigger the widget yourself via `Upstep.open()`. |
77
+ | `colors` | `object` | — | Brand colors for the panel and support chat: `background`, `surface`, `border`, `text`, `textMuted`, `accentText`, plus `light` / `dark` variants. Unset keys keep the defaults. |
78
+ | `radius` | `number` | `12` | Base corner radius in px. Every corner scales with it; `0` is square. Clamped to 0–32. |
79
+ | `fontFamily` | `string` | system font | CSS font-family for the widget. |
80
+
81
+ ```js
82
+ Upstep.init({
83
+ apiKey: "upstep_xxx",
84
+ accentColor: "#4f46e5",
85
+ colors: {
86
+ border: "#e2e8f0",
87
+ dark: { background: "#0f172a", surface: "#1e293b", text: "#f8fafc" },
88
+ },
89
+ radius: 8,
90
+ fontFamily: "Inter, system-ui, sans-serif",
91
+ });
92
+ ```
93
+
94
+ When `accentText` isn't set, text on the accent is white unless that's hard to read, then near-black. Script tags take `data-colors` (JSON), `data-radius` and `data-font-family`.
77
95
 
78
96
  ## API
79
97
 
@@ -87,7 +105,7 @@ Every entry point (`Upstep.init`, `<UpstepProvider>`, and the script tag's `data
87
105
  ### React (`@upstep/js/react`)
88
106
 
89
107
  - `<UpstepProvider apiKey="..." />` — wraps your app, all `UpstepConfig` options are valid props.
90
- - `<FeedbackWidget position? accentColor? theme? hideLauncher? />` — the launcher button and panel. Renders nothing until it's shown; safe to mount once near the root.
108
+ - `<FeedbackWidget position? accentColor? theme? colors? radius? fontFamily? hideLauncher? />` — the launcher button and panel. Renders nothing until it's shown; safe to mount once near the root.
91
109
  - `useUpstep()` — the same state and actions the widget uses (`feedItems`, `submit`, `vote`, `open`, `close`, `identify`, ...), if you want to build your own UI on top instead of the default widget.
92
110
 
93
111
  ## Links
@@ -1,17 +1,18 @@
1
- const d = "upstep-anonymous-id";
2
- function h() {
3
- const o = typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
4
- if (typeof window > "u") return o;
1
+ import { defaultAccent as h, supportThemeParams as c } from "./theme.js";
2
+ const a = "upstep-anonymous-id";
3
+ function p() {
4
+ const i = typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
5
+ if (typeof window > "u") return i;
5
6
  try {
6
- const e = window.localStorage.getItem(d);
7
- return e || (window.localStorage.setItem(d, o), o);
7
+ const e = window.localStorage.getItem(a);
8
+ return e || (window.localStorage.setItem(a, i), i);
8
9
  } catch {
9
- return o;
10
+ return i;
10
11
  }
11
12
  }
12
- class u {
13
+ class l {
13
14
  constructor(e) {
14
- this.baseUrl = (e.baseUrl ?? "https://upstep.dev").replace(/\/$/, ""), this.apiKey = e.apiKey, this.supportIdentityToken = e.supportIdentityToken, this.chat = e.chat !== !1, e.userId !== void 0 && (this.userId = e.userId), this.anonymousId = h();
15
+ this.baseUrl = (e.baseUrl ?? "https://upstep.dev").replace(/\/$/, ""), this.apiKey = e.apiKey, this.supportIdentityToken = e.supportIdentityToken, this.chat = e.chat !== !1, e.userId !== void 0 && (this.userId = e.userId), this.anonymousId = p();
15
16
  }
16
17
  /** Update the end-user id at runtime (e.g. after the user logs in). */
17
18
  setUserId(e) {
@@ -34,28 +35,62 @@ class u {
34
35
  return !1;
35
36
  }
36
37
  }
37
- supportFrameUrl(e, t = "#D97757") {
38
- return `${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?theme=${encodeURIComponent(e)}&accent=${encodeURIComponent(t)}`;
38
+ /**
39
+ * URL of the hosted support chat. Color, radius and font overrides travel
40
+ * as query parameters; only hex/rgb colors are sent and the server
41
+ * validates every value again.
42
+ */
43
+ supportFrameUrl(e, t, s = {}) {
44
+ const r = new URLSearchParams({
45
+ theme: e,
46
+ accent: t || h(e === "dark" ? "dark" : "light")
47
+ }), d = c({
48
+ mode: e === "dark" ? "dark" : "light",
49
+ ...s
50
+ });
51
+ for (const [o, n] of Object.entries(d)) r.set(o, n);
52
+ return `${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?${r}`;
39
53
  }
40
- connectSupportFrame(e) {
41
- const t = new URL(this.baseUrl).origin, s = () => {
42
- var n;
43
- return (n = e.contentWindow) == null ? void 0 : n.postMessage(
54
+ connectSupportFrame(e, t = {}) {
55
+ const s = new URL(this.baseUrl).origin, r = () => {
56
+ var o;
57
+ return (o = e.contentWindow) == null ? void 0 : o.postMessage(
44
58
  {
45
59
  type: "upstep:support:identity",
46
60
  token: this.supportIdentityToken,
47
- accentColor: getComputedStyle(e).color
61
+ accentColor: getComputedStyle(e).color,
62
+ ...t.isVisible ? { visible: t.isVisible() } : {}
48
63
  },
49
- t
64
+ s
50
65
  );
51
- }, r = (n) => {
52
- var i;
53
- n.origin === t && n.source === e.contentWindow && ((i = n.data) == null ? void 0 : i.type) === "upstep:support:ready" && s();
66
+ }, d = (o) => {
67
+ if (o.origin !== s || o.source !== e.contentWindow)
68
+ return;
69
+ const n = o.data;
70
+ if ((n == null ? void 0 : n.type) === "upstep:support:ready") r();
71
+ else if ((n == null ? void 0 : n.type) === "upstep:support:unread" && t.onUnread) {
72
+ const u = Number(n.count);
73
+ t.onUnread({
74
+ count: Number.isFinite(u) ? Math.max(0, Math.floor(u)) : 0,
75
+ newMessage: n.newMessage === !0,
76
+ author: String(n.author ?? "").slice(0, 80),
77
+ preview: String(n.preview ?? "").slice(0, 200),
78
+ sound: n.sound !== !1
79
+ });
80
+ }
54
81
  };
55
- return e.addEventListener("load", s), window.addEventListener("message", r), () => {
56
- e.removeEventListener("load", s), window.removeEventListener("message", r);
82
+ return e.addEventListener("load", r), window.addEventListener("message", d), () => {
83
+ e.removeEventListener("load", r), window.removeEventListener("message", d);
57
84
  };
58
85
  }
86
+ /** Tell the chat whether it is on screen so it can track unread messages. */
87
+ notifySupportVisibility(e, t) {
88
+ var s;
89
+ (s = e.contentWindow) == null || s.postMessage(
90
+ { type: "upstep:support:visible", visible: t },
91
+ new URL(this.baseUrl).origin
92
+ );
93
+ }
59
94
  async listFeedback(e) {
60
95
  const t = new URLSearchParams();
61
96
  e != null && e.cursor && t.set("cursor", e.cursor), e != null && e.limit && t.set("limit", String(e.limit)), e != null && e.type && t.set("type", e.type), e != null && e.status && t.set("status", e.status), e != null && e.sort && t.set("sort", e.sort), this.userId && t.set("endUserId", this.userId), this.anonymousId && t.set("anonymousId", this.anonymousId);
@@ -120,5 +155,5 @@ class u {
120
155
  }
121
156
  }
122
157
  export {
123
- u as U
158
+ l as U
124
159
  };
@@ -0,0 +1 @@
1
+ "use strict";const a=require("./theme.cjs"),h="upstep-anonymous-id";function c(){const i=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;if(typeof window>"u")return i;try{const e=window.localStorage.getItem(h);return e||(window.localStorage.setItem(h,i),i)}catch{return i}}class p{constructor(e){this.baseUrl=(e.baseUrl??"https://upstep.dev").replace(/\/$/,""),this.apiKey=e.apiKey,this.supportIdentityToken=e.supportIdentityToken,this.chat=e.chat!==!1,e.userId!==void 0&&(this.userId=e.userId),this.anonymousId=c()}setUserId(e){this.userId=e}headers(){return{"Content-Type":"application/json","x-api-key":this.apiKey}}async supportEnabled(){if(!this.chat)return!1;try{const e=await fetch(`${this.baseUrl}/api/sdk/support`,{headers:this.headers()});return e.ok&&(await e.json()).enabled===!0}catch{return!1}}supportFrameUrl(e,t,s={}){const r=new URLSearchParams({theme:e,accent:t||a.defaultAccent(e==="dark"?"dark":"light")}),d=a.supportThemeParams({mode:e==="dark"?"dark":"light",...s});for(const[o,n]of Object.entries(d))r.set(o,n);return`${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?${r}`}connectSupportFrame(e,t={}){const s=new URL(this.baseUrl).origin,r=()=>{var o;return(o=e.contentWindow)==null?void 0:o.postMessage({type:"upstep:support:identity",token:this.supportIdentityToken,accentColor:getComputedStyle(e).color,...t.isVisible?{visible:t.isVisible()}:{}},s)},d=o=>{if(o.origin!==s||o.source!==e.contentWindow)return;const n=o.data;if((n==null?void 0:n.type)==="upstep:support:ready")r();else if((n==null?void 0:n.type)==="upstep:support:unread"&&t.onUnread){const u=Number(n.count);t.onUnread({count:Number.isFinite(u)?Math.max(0,Math.floor(u)):0,newMessage:n.newMessage===!0,author:String(n.author??"").slice(0,80),preview:String(n.preview??"").slice(0,200),sound:n.sound!==!1})}};return e.addEventListener("load",r),window.addEventListener("message",d),()=>{e.removeEventListener("load",r),window.removeEventListener("message",d)}}notifySupportVisibility(e,t){var s;(s=e.contentWindow)==null||s.postMessage({type:"upstep:support:visible",visible:t},new URL(this.baseUrl).origin)}async listFeedback(e){const t=new URLSearchParams;e!=null&&e.cursor&&t.set("cursor",e.cursor),e!=null&&e.limit&&t.set("limit",String(e.limit)),e!=null&&e.type&&t.set("type",e.type),e!=null&&e.status&&t.set("status",e.status),e!=null&&e.sort&&t.set("sort",e.sort),this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const s=await fetch(`${this.baseUrl}/api/sdk/feedback?${t}`,{headers:this.headers()});if(!s.ok)throw new Error(`Upstep: ${s.status}`);return s.json()}async submitFeedback(e){const t=await fetch(`${this.baseUrl}/api/sdk/feedback`,{method:"POST",headers:this.headers(),body:JSON.stringify({...e,endUserId:e.endUserId??this.userId,anonymousId:e.anonymousId??this.anonymousId})});if(!t.ok)throw new Error(`Upstep: ${t.status}`);return t.json()}async vote(e,t){const s=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote`,{method:"POST",headers:this.headers(),body:JSON.stringify({value:t,endUserId:this.userId,anonymousId:this.anonymousId})});if(!s.ok)throw new Error(`Upstep: ${s.status}`)}async getItem(e){const t=new URLSearchParams;this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const s=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}?${t}`,{headers:this.headers()});if(!s.ok)throw new Error(`Upstep: ${s.status}`);return s.json()}async removeVote(e){if(!this.userId&&!this.anonymousId)return;const t=new URLSearchParams;this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const s=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote?${t}`,{method:"DELETE",headers:this.headers()});if(!s.ok)throw new Error(`Upstep: ${s.status}`)}}exports.UpstepApiClient=p;
package/dist/api.d.ts CHANGED
@@ -1,4 +1,14 @@
1
- import { Feedback, FeedbackListResponse, FeedbackWithComments, SubmitFeedbackPayload, VotePayload, UpstepConfig } from '@upstep/types';
1
+ import { Feedback, FeedbackListResponse, FeedbackWithComments, SubmitFeedbackPayload, VotePayload, UpstepColorOverrides, UpstepConfig } from '@upstep/types';
2
+ /** Unread chat messages reported by the support chat while it is closed or scrolled away. */
3
+ export interface SupportUnread {
4
+ count: number;
5
+ /** True when this report was triggered by a message that just arrived. */
6
+ newMessage: boolean;
7
+ author: string;
8
+ preview: string;
9
+ /** Whether the customer wants a sound for new messages. */
10
+ sound: boolean;
11
+ }
2
12
  export declare class UpstepApiClient {
3
13
  readonly baseUrl: string;
4
14
  readonly apiKey: string;
@@ -11,8 +21,23 @@ export declare class UpstepApiClient {
11
21
  setUserId(userId: string | undefined): void;
12
22
  private headers;
13
23
  supportEnabled(): Promise<boolean>;
14
- supportFrameUrl(theme: string, accentColor?: string): string;
15
- connectSupportFrame(frame: HTMLIFrameElement): () => void;
24
+ /**
25
+ * URL of the hosted support chat. Color, radius and font overrides travel
26
+ * as query parameters; only hex/rgb colors are sent and the server
27
+ * validates every value again.
28
+ */
29
+ supportFrameUrl(theme: string, accentColor?: string, appearance?: {
30
+ colors?: UpstepColorOverrides | undefined;
31
+ radius?: number | undefined;
32
+ fontFamily?: string | undefined;
33
+ }): string;
34
+ connectSupportFrame(frame: HTMLIFrameElement, options?: {
35
+ /** Whether the chat is currently on screen. Lets the chat know when messages are unseen. */
36
+ isVisible?: () => boolean;
37
+ onUnread?: (unread: SupportUnread) => void;
38
+ }): () => void;
39
+ /** Tell the chat whether it is on screen so it can track unread messages. */
40
+ notifySupportVisibility(frame: HTMLIFrameElement, visible: boolean): void;
16
41
  listFeedback(params?: {
17
42
  cursor?: string;
18
43
  limit?: number;
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACb,MAAM,eAAe,CAAC;AAyBvB,qBAAa,eAAe;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE7B,MAAM,EAAE,YAAY;IAShC,uEAAuE;IACvE,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IAIpC,OAAO,CAAC,OAAO;IAOT,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAYxC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,SAAY,GAAG,MAAM;IAI/D,mBAAmB,CAAC,KAAK,EAAE,iBAAiB;IA2BtC,YAAY,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACzB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkB3B,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAcjE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBpE,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAc1D,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAcpD"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,oBAAoB,EACpB,YAAY,EACb,MAAM,eAAe,CAAC;AA0BvB,6FAA6F;AAC7F,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,qBAAa,eAAe;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE7B,MAAM,EAAE,YAAY;IAShC,uEAAuE;IACvE,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IAIpC,OAAO,CAAC,OAAO;IAOT,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAYxC;;;;OAIG;IACH,eAAe,CACb,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,GAAE;QACV,MAAM,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;QAC1C,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B,GACL,MAAM;IAaT,mBAAmB,CACjB,KAAK,EAAE,iBAAiB,EACxB,OAAO,GAAE;QACP,4FAA4F;QAC5F,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC;QAC1B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;KACvC;IAqCR,6EAA6E;IAC7E,uBAAuB,CAAC,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO;IAO5D,YAAY,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACzB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkB3B,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAcjE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBpE,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAc1D,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAcpD"}
package/dist/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("./api-ZqVkOuh0.js"),x="#D97757",l={bg:"#ffffff",bgSoft:"#f5f5f5",bgHover:"#ededed",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},c={bg:"#000000",bgSoft:"#171717",bgHover:"#262626",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function u(o){if(o==="light"||o==="dark")return o;if(typeof document<"u"){const t=document.documentElement;return t.classList.contains("dark")||t.getAttribute("data-theme")==="dark"?"dark":"light"}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function m(o,t,e){return`
2
- #upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
3
- #upstep-btn{position:fixed;bottom:24px;right:24px;left:auto;z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${o};color:#fff;border:none;border-radius:9999px;padding:12px 18px;font-size:14px;font-weight:600;cursor:pointer;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("./api-j3GMTEE7.js"),l=require("./theme.cjs");function y(t){const e=t==null?void 0:t.trim();return e&&/^[\w\s,"'.-]{1,200}$/.test(e)?e:""}function f(t){if(t==="light"||t==="dark")return t;if(typeof document<"u"){const e=document.documentElement;return e.classList.contains("dark")||e.getAttribute("data-theme")==="dark"?"dark":"light"}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function v(t,e){const s="right:24px;left:auto",o=t.accent,n=t.accentText,i=r=>`${l.scaleRadius(r,t.radius)}px`;return`
2
+ #upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}${e?`
3
+ #upstep-btn,#upstep-btn *,#upstep-backdrop,#upstep-backdrop *,#upstep-toast,#upstep-toast *{font-family:${e}}`:""}
4
+ #upstep-btn{position:fixed;bottom:24px;${s};z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${o};color:${n};border:none;border-radius:${i(9999)};padding:12px 18px;font-size:14px;font-weight:600;cursor:pointer;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
4
5
  #upstep-btn svg{width:16px;height:16px;flex-shrink:0}
5
6
  #upstep-btn:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(26,25,21,.24)}
6
7
  @media(max-width:639px){#upstep-btn{padding:12px}#upstep-btn span{display:none}}
@@ -8,74 +9,82 @@
8
9
  #upstep-backdrop{position:fixed;inset:0;background:transparent;z-index:9999;display:flex;align-items:flex-end;justify-content:flex-end;padding:0 24px 88px;animation:upstep-fade .2s ease}
9
10
  @keyframes upstep-fade{from{opacity:0}to{opacity:1}}
10
11
  @keyframes upstep-rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:translateY(0)}}
11
- #upstep-modal{background:${e.bg};border:1px solid ${e.border};border-radius:20px;width:100%;max-width:440px;max-height:calc(100dvh - 112px);display:flex;flex-direction:column;overflow:hidden;box-shadow:0 24px 64px rgba(0,0,0,.28);animation:upstep-rise .26s cubic-bezier(.16,1,.3,1)}
12
+ #upstep-modal{background:${t.bg};border:1px solid ${t.border};border-radius:${i(20)};width:100%;max-width:440px;max-height:calc(100dvh - 112px);display:flex;flex-direction:column;overflow:hidden;box-shadow:0 24px 64px rgba(0,0,0,.28);animation:upstep-rise .26s cubic-bezier(.16,1,.3,1)}
12
13
  #upstep-header{display:flex;align-items:flex-start;justify-content:space-between;padding:20px 20px 0}
13
- #upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${e.text};letter-spacing:-.01em}
14
- #upstep-header p{margin:2px 0 0;font-size:14px;color:${e.textFaint}}
15
- #upstep-close{background:${e.bgSoft};border:none;width:28px;height:28px;border-radius:8px;font-size:14px;cursor:pointer;color:${e.textSoft};line-height:1;display:flex;align-items:center;justify-content:center;transition:background .15s}
16
- #upstep-close:hover{background:${e.bgHover};color:${e.text}}
17
- #upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${e.bgSoft};border-radius:11px}
18
- .upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:8px;font-size:14px;font-weight:600;color:${e.textSoft};cursor:pointer;transition:all .15s}
19
- .upstep-mode .upstep-tab.active{background:${e.bgSoft};box-shadow:none}
20
- .upstep-tab.active{background:${e.bg};color:${e.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
14
+ #upstep-header h2{margin:0;font-size:16px;font-weight:700;color:${t.text};letter-spacing:-.01em}
15
+ #upstep-header p{margin:2px 0 0;font-size:14px;color:${t.textFaint}}
16
+ #upstep-close{background:${t.bgSoft};border:none;width:28px;height:28px;border-radius:${i(8)};font-size:14px;cursor:pointer;color:${t.textSoft};line-height:1;display:flex;align-items:center;justify-content:center;transition:background .15s}
17
+ #upstep-close:hover{background:${t.bgHover};color:${t.text}}
18
+ #upstep-tabs{display:flex;gap:4px;margin:16px 20px 0;padding:4px;background:${t.bgSoft};border-radius:${i(11)}}
19
+ .upstep-tab{flex:1;padding:8px;background:none;border:none;border-radius:${i(8)};font-size:14px;font-weight:600;color:${t.textSoft};cursor:pointer;transition:all .15s}
20
+ .upstep-mode .upstep-tab.active{background:${t.bgSoft};box-shadow:none}
21
+ .upstep-tab.active{background:${t.bg};color:${t.text};box-shadow:0 1px 3px rgba(0,0,0,.08)}
21
22
  #upstep-body{flex:1;overflow-y:auto;padding:18px 20px 22px}
22
- .upstep-form textarea{width:100%;min-height:104px;border:1px solid ${e.border};border-radius:12px;padding:12px;font-size:16px;line-height:1.6;resize:vertical;outline:none;background:${e.bgSoft};color:${e.text};transition:border-color .15s}
23
- .upstep-form textarea::placeholder{color:${e.textFaint}}
24
- .upstep-form textarea:focus{border-color:${o};background:${e.bg}}
23
+ .upstep-form textarea{width:100%;min-height:104px;border:1px solid ${t.border};border-radius:${i(12)};padding:12px;font-size:16px;line-height:1.6;resize:vertical;outline:none;background:${t.bgSoft};color:${t.text};transition:border-color .15s}
24
+ .upstep-form textarea::placeholder{color:${t.textFaint}}
25
+ .upstep-form textarea:focus{border-color:${o};background:${t.bg}}
25
26
  .upstep-type-row{display:flex;gap:7px;margin:12px 0 4px}
26
- .upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:9px;border:1px solid ${e.border};background:${e.bg};color:${e.textSoft};font-size:14px;font-weight:600;cursor:pointer;transition:all .15s}
27
+ .upstep-type-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 10px;border-radius:${i(9)};border:1px solid ${t.border};background:${t.bg};color:${t.textSoft};font-size:14px;font-weight:600;cursor:pointer;transition:all .15s}
27
28
  .upstep-type-btn svg{width:12px;height:12px;flex-shrink:0}
28
- .upstep-type-btn:hover{border-color:${e.textFaint}}
29
- .upstep-type-btn.selected{background:${o};color:#fff;border-color:${o}}
30
- .upstep-submit{width:100%;padding:12px;background:${o};color:#fff;border:none;border-radius:11px;font-size:14px;font-weight:600;cursor:pointer;margin-top:14px;transition:filter .15s}
29
+ .upstep-type-btn:hover{border-color:${t.textFaint}}
30
+ .upstep-type-btn.selected{background:${o};color:${n};border-color:${o}}
31
+ .upstep-submit{width:100%;padding:12px;background:${o};color:${n};border:none;border-radius:${i(11)};font-size:14px;font-weight:600;cursor:pointer;margin-top:14px;transition:filter .15s}
31
32
  .upstep-submit:hover{filter:brightness(.94)}
32
33
  .upstep-submit:disabled{opacity:.5;cursor:not-allowed}
33
34
  #upstep-form-msg{font-size:14px;text-align:center;margin-top:12px;color:${o};font-weight:500}
34
- .upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${e.border};border-radius:14px;margin-bottom:10px;background:${e.bg};transition:border-color .15s}
35
- .upstep-feedback-item:hover{border-color:${e.textFaint}}
36
- .upstep-vote{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:46px;padding:7px 0;border-radius:11px;border:1px solid ${e.border};background:${e.bgSoft};cursor:pointer;transition:all .15s}
35
+ .upstep-feedback-item{display:flex;gap:12px;padding:14px;border:1px solid ${t.border};border-radius:${i(14)};margin-bottom:10px;background:${t.bg};transition:border-color .15s}
36
+ .upstep-feedback-item:hover{border-color:${t.textFaint}}
37
+ .upstep-vote{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:46px;padding:7px 0;border-radius:${i(11)};border:1px solid ${t.border};background:${t.bgSoft};cursor:pointer;transition:all .15s}
37
38
  .upstep-vote:hover{border-color:${o}}
38
- .upstep-vote.voted{border-color:${o};background:${o}1a}
39
+ .upstep-vote.voted{border-color:${o};background:${t.accentTint}}
39
40
  .upstep-vote-arrow{font-size:11px;line-height:1;color:${o}}
40
- .upstep-vote-count{font-size:14px;font-weight:700;color:${e.text};line-height:1.1}
41
+ .upstep-vote-count{font-size:14px;font-weight:700;color:${t.text};line-height:1.1}
41
42
  .upstep-feedback-main{flex:1;min-width:0}
42
- .upstep-feedback-content{font-size:16px;line-height:1.5;color:${e.text};margin:0 0 8px;word-break:break-word}
43
+ .upstep-feedback-content{font-size:16px;line-height:1.5;color:${t.text};margin:0 0 8px;word-break:break-word}
43
44
  .upstep-feedback-meta{display:flex;align-items:center;gap:7px}
44
- .upstep-badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:9999px;font-size:10.5px;font-weight:700;letter-spacing:.02em}
45
+ .upstep-badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:${i(9999)};font-size:10.5px;font-weight:700;letter-spacing:.02em}
45
46
  .upstep-badge-bug{background:#fdecec;color:#d6453d}
46
47
  .upstep-badge-feature{background:#e9f0fd;color:#3b76d6}
47
- .upstep-badge-general{background:${e.bgSoft};color:${e.textSoft}}
48
- .upstep-feedback-date{font-size:11px;color:${e.textFaint}}
49
- .upstep-empty{text-align:center;color:${e.textFaint};font-size:14px;padding:40px 0}
50
- .upstep-empty strong{display:block;color:${e.textSoft};font-size:15px;margin-bottom:4px}
51
- `}const g='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';class y{constructor(t,e={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.hasSupport=!1,this.disconnectSupport=null,this.client=t,this.accent=e.accentColor??x,this.position="right",this.showLauncher=e.launcher!==!1,this.themeMode=e.theme??"auto",this.palette=u(this.themeMode)==="dark"?c:l}mount(){this.injectStyles(),this.showLauncher&&this.renderButton(),this.client.supportEnabled().then(t=>{if(this.hasSupport=t,t){const e=document.querySelector("#upstep-btn span");e&&(e.textContent="Help & feedback"),this.isOpen&&this.renderModal()}})}openWidget(){this.openModal()}closeWidget(){this.closeModal()}injectStyles(){var e;(e=document.getElementById("upstep-styles"))==null||e.remove();const t=document.createElement("style");t.id="upstep-styles",t.textContent=m(this.accent,this.position,this.palette),document.head.appendChild(t)}renderButton(){const t=document.createElement("button");t.id="upstep-btn",t.setAttribute("aria-label","Open help and feedback"),t.innerHTML=`${g}<span>Feedback</span>`,t.addEventListener("click",()=>{this.openModal()}),document.body.appendChild(t)}openModal(){!this.isOpen&&this.hasSupport&&(this.tab="support"),this.isOpen=!0,this.palette=u(this.themeMode)==="dark"?c:l,this.injectStyles(),this.fetchFeed(),this.renderModal()}closeModal(){var t,e;(t=this.disconnectSupport)==null||t.call(this),this.disconnectSupport=null,this.isOpen=!1,(e=document.getElementById("upstep-backdrop"))==null||e.remove()}async fetchFeed(){try{const t=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=t.items,this.renderFeedList()}catch{}}renderModal(){var i,s,n;(i=this.disconnectSupport)==null||i.call(this),this.disconnectSupport=null;const t=document.createElement("div");t.id="upstep-backdrop",t.addEventListener("click",d=>{d.target===t&&this.closeModal()}),t.innerHTML=`
48
+ .upstep-badge-general{background:${t.bgSoft};color:${t.textSoft}}
49
+ .upstep-feedback-date{font-size:11px;color:${t.textFaint}}
50
+ #upstep-btn{position:fixed}
51
+ .upstep-unread{position:absolute;top:-7px;right:-5px;min-width:22px;height:22px;padding:0 6px;border-radius:11px;background:${t.text};color:${t.bg};border:2px solid ${t.bg};font-size:12px;font-weight:700;line-height:18px;text-align:center;font-variant-numeric:tabular-nums;animation:upstep-pop .45s cubic-bezier(.3,1.6,.5,1)}
52
+ @keyframes upstep-pop{from{transform:scale(.4)}to{transform:scale(1)}}
53
+ #upstep-toast{position:fixed;bottom:84px;right:24px;z-index:9998;max-width:min(300px,calc(100vw - 48px));display:grid;gap:2px;text-align:left;background:${t.bg};color:${t.text};border:1px solid ${t.border};border-radius:${i(14)} ${i(14)} ${i(4)} ${i(14)};padding:10px 12px;box-shadow:0 10px 32px rgba(0,0,0,.2);cursor:pointer;animation:upstep-rise .26s cubic-bezier(.16,1,.3,1)}
54
+ #upstep-toast b{font-size:12px}
55
+ #upstep-toast span{font-size:14px;line-height:1.4;color:${t.textSoft};display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
56
+ #upstep-toast em{font-style:normal;font-size:11px;font-weight:600;color:${o}}
57
+ @media(prefers-reduced-motion:reduce){.upstep-unread,#upstep-toast{animation:none}}
58
+ .upstep-empty{text-align:center;color:${t.textFaint};font-size:14px;padding:40px 0}
59
+ .upstep-empty strong{display:block;color:${t.textSoft};font-size:15px;margin-bottom:4px}
60
+ `}const k='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';class ${constructor(e,s={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.hasSupport=!1,this.disconnectSupport=null,this.unread=0,this.audio=null,this.frameTheme=null,this.unreadListeners=new Set,this.client=e,this.options=s,this.position="right",this.showLauncher=s.launcher!==!1,this.themeMode=s.theme??"auto",this.palette=this.buildPalette(f(this.themeMode))}buildPalette(e){return l.buildWidgetPalette({mode:e,accentColor:this.options.accentColor,colors:this.options.colors,radius:this.options.radius})}get accent(){return this.palette.accent}supportFrameSrc(){return this.client.supportFrameUrl(this.palette.dark?"dark":"light",this.accent,{colors:this.options.colors,radius:this.options.radius,fontFamily:this.options.fontFamily})}mount(){this.injectStyles(),this.showLauncher&&this.renderButton(),this.client.supportEnabled().then(e=>{if(this.hasSupport=e,e){const s=document.querySelector("#upstep-btn span");s&&(s.textContent="Help & feedback"),this.isOpen?this.renderModal():this.hasOpenedSupport()&&this.preloadSupport()}})}openWidget(){this.openModal()}closeWidget(){this.closeModal()}isChatVisible(){return this.isOpen}onUnread(e){return this.unreadListeners.add(e),e(this.unread),()=>{this.unreadListeners.delete(e)}}injectStyles(){var s;(s=document.getElementById("upstep-styles"))==null||s.remove();const e=document.createElement("style");e.id="upstep-styles",e.textContent=v(this.palette,y(this.options.fontFamily)),document.head.appendChild(e)}renderButton(){const e=document.createElement("button");e.id="upstep-btn",e.setAttribute("aria-label","Open help and feedback"),e.innerHTML=`${k}<span>Feedback</span>`,e.addEventListener("click",()=>{this.openModal()}),document.body.appendChild(e)}supportFrame(){return document.querySelector("#upstep-support-frame")}get usedKey(){return`upstep:support-opened:${this.client.baseUrl}`}hasOpenedSupport(){try{return localStorage.getItem(this.usedKey)==="1"}catch{return!1}}preloadSupport(){this.tab="support",this.renderModal(!0)}openModal(){if(this.unlockAudio(),!this.isOpen&&this.hasSupport){this.tab="support";try{localStorage.setItem(this.usedKey,"1")}catch{}}const e=f(this.themeMode),s=document.getElementById("upstep-backdrop"),o=this.supportFrame();if(!this.isOpen&&s&&o&&s.style.display==="none"&&this.frameTheme===e){this.isOpen=!0,s.style.display="",this.client.notifySupportVisibility(o,!0),this.setUnread(0),this.fetchFeed();return}this.isOpen=!0,this.palette=this.buildPalette(e),this.injectStyles(),this.fetchFeed(),this.renderModal(),this.setUnread(0)}closeModal(){var e,s;if(this.isOpen=!1,this.hasSupport){const o=this.supportFrame(),n=document.getElementById("upstep-backdrop");o&&n?(n.style.display="none",this.client.notifySupportVisibility(o,!1)):this.preloadSupport();return}(e=this.disconnectSupport)==null||e.call(this),this.disconnectSupport=null,(s=document.getElementById("upstep-backdrop"))==null||s.remove()}setUnread(e){this.unread=e;const s=document.getElementById("upstep-btn"),o=s==null?void 0:s.querySelector(".upstep-unread");if(s){if(e>0){const i=o??document.createElement("span");i.className="upstep-unread",i.textContent=e>9?"9+":String(e),o||s.appendChild(i)}else o==null||o.remove();s.setAttribute("aria-label",e>0?`Open help and feedback, ${e} unread ${e===1?"message":"messages"}`:"Open help and feedback")}const n=document.title.replace(/^\(\d+\)\s/,"");document.title=e>0?`(${e}) ${n}`:n,e===0&&this.hideToast(),this.unreadListeners.forEach(i=>i(e))}onSupportUnread(e){if(this.isOpen)return this.setUnread(0);this.setUnread(e.count),e.newMessage&&e.count>0&&(this.showToast(e),e.sound&&this.chime())}showToast(e){this.hideToast();const s=document.createElement("button");s.id="upstep-toast",s.type="button",s.setAttribute("role","status");const o=document.createElement("b");o.textContent=e.author||"New message";const n=document.createElement("span");n.textContent=e.preview;const i=document.createElement("em");i.textContent=e.count>1?`${e.count} new messages`:"Tap to reply",s.append(o,n,i),s.addEventListener("click",()=>this.openModal()),document.body.appendChild(s),this.toastTimer=setTimeout(()=>this.hideToast(),9e3)}hideToast(){var e;clearTimeout(this.toastTimer),(e=document.getElementById("upstep-toast"))==null||e.remove()}unlockAudio(){try{const e=window.AudioContext||window.webkitAudioContext;if(!e)return;this.audio=this.audio??new e,this.audio.state==="suspended"&&this.audio.resume()}catch{}}chime(){const e=this.audio;if(!e||e.state!=="running")return;const s=e.currentTime;for(const[o,n]of[[880,0],[1318,.12]]){const i=e.createOscillator(),r=e.createGain();i.type="sine",i.frequency.value=o,r.gain.setValueAtTime(1e-4,s+n),r.gain.exponentialRampToValueAtTime(.14,s+n+.02),r.gain.exponentialRampToValueAtTime(1e-4,s+n+.5),i.connect(r),r.connect(e.destination),i.start(s+n),i.stop(s+n+.55)}}async fetchFeed(){try{const e=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=e.items,this.renderFeedList()}catch{}}renderModal(e=!1){var n,i,r;(n=this.disconnectSupport)==null||n.call(this),this.disconnectSupport=null;const s=document.createElement("div");s.id="upstep-backdrop",s.addEventListener("click",a=>{a.target===s&&this.closeModal()}),s.innerHTML=`
52
61
  <div id="upstep-modal" style="max-width:${this.hasSupport?"460px":"440px"}">
53
62
  ${this.hasSupport?`<div class="upstep-mode" style="display:flex;align-items:center;gap:14px;padding:10px 14px;border-bottom:1px solid ${this.palette.border}"><div id="upstep-tabs" style="margin:0;padding:0;background:transparent;flex:1"><button class="upstep-tab ${this.tab==="support"?"active":""}" data-tab="support">Support</button><button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Feedback</button><button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Ideas</button></div><button id="upstep-close" aria-label="Close" style="flex-shrink:0;background:transparent">✕</button></div>`:`<div id="upstep-header"><div><h2>Share your feedback</h2><p>Tell us what to build next, or vote on ideas.</p></div><button id="upstep-close" aria-label="Close">✕</button></div><div id="upstep-tabs"><button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Give feedback</button><button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Vote on ideas</button></div>`}
54
63
  <div id="upstep-body" style="${this.tab==="support"?"padding:0;overflow:hidden":""}">
55
- ${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg==="#000000"?"dark":"light",this.accent)}" style="width:100%;height:min(560px,calc(100dvh - 168px));min-height:300px;border:0;display:block"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
64
+ ${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${h(this.supportFrameSrc())}" style="width:100%;height:min(560px,calc(100dvh - 168px));min-height:300px;border:0;display:block"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
56
65
  </div>
57
66
  </div>
58
- `,(s=document.getElementById("upstep-backdrop"))==null||s.remove(),document.body.appendChild(t),(n=t.querySelector("#upstep-close"))==null||n.addEventListener("click",()=>this.closeModal()),t.querySelectorAll(".upstep-tab").forEach(d=>{d.addEventListener("click",()=>{this.tab=d.dataset.tab,this.renderModal()})});const e=t.querySelector("#upstep-support-frame");e&&(e.style.color=this.accent,this.disconnectSupport=this.client.connectSupportFrame(e)),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const t=["BUG","FEATURE","GENERAL"],e={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},i={BUG:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="8" cy="10" rx="3.5" ry="4.5"/><path d="M8 5.5V4M5.5 6.5 3.5 5M10.5 6.5 12.5 5M4.5 10.5 2.5 10M11.5 10.5 13.5 10"/></svg>',FEATURE:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.1 4.1l1 1M10.9 10.9l1 1M11.9 4.1l-1 1M5.1 10.9l-1 1"/><circle cx="8" cy="8" r="2.5"/></svg>',GENERAL:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z"/></svg>'};return`
67
+ `,(i=document.getElementById("upstep-backdrop"))==null||i.remove(),e&&(s.style.display="none"),document.body.appendChild(s),(r=s.querySelector("#upstep-close"))==null||r.addEventListener("click",()=>this.closeModal()),s.querySelectorAll(".upstep-tab").forEach(a=>{a.addEventListener("click",()=>{this.tab=a.dataset.tab,this.renderModal()})});const o=s.querySelector("#upstep-support-frame");o&&(o.style.color=this.accent,this.frameTheme=this.palette.dark?"dark":"light",this.disconnectSupport=this.client.connectSupportFrame(o,{isVisible:()=>this.isOpen,onUnread:a=>this.onSupportUnread(a)})),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const e=["BUG","FEATURE","GENERAL"],s={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},o={BUG:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="8" cy="10" rx="3.5" ry="4.5"/><path d="M8 5.5V4M5.5 6.5 3.5 5M10.5 6.5 12.5 5M4.5 10.5 2.5 10M11.5 10.5 13.5 10"/></svg>',FEATURE:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.1 4.1l1 1M10.9 10.9l1 1M11.9 4.1l-1 1M5.1 10.9l-1 1"/><circle cx="8" cy="8" r="2.5"/></svg>',GENERAL:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z"/></svg>'};return`
59
68
  <div class="upstep-form">
60
69
  <textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
61
70
  <div class="upstep-type-row">
62
- ${t.map(s=>`<button class="upstep-type-btn${this.selectedType===s?" selected":""}" data-type="${s}">${i[s]}${e[s]}</button>`).join("")}
71
+ ${e.map(n=>`<button class="upstep-type-btn${this.selectedType===n?" selected":""}" data-type="${n}">${o[n]}${s[n]}</button>`).join("")}
63
72
  </div>
64
73
  <button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
65
74
  <div id="upstep-form-msg"></div>
66
75
  </div>
67
- `}renderFeed(){return this.feedItems.length?this.feedItems.map(t=>{var e;return`
68
- <div class="upstep-feedback-item" data-id="${t.id}">
69
- <button class="upstep-vote${t.userVote==="UP"?" voted":""}" data-vote="UP" data-feedback="${t.id}">
76
+ `}renderFeed(){return this.feedItems.length?this.feedItems.map(e=>{var s;return`
77
+ <div class="upstep-feedback-item" data-id="${e.id}">
78
+ <button class="upstep-vote${e.userVote==="UP"?" voted":""}" data-vote="UP" data-feedback="${e.id}">
70
79
  <span class="upstep-vote-arrow">▲</span>
71
- <span class="upstep-vote-count">${t.upvotes}</span>
80
+ <span class="upstep-vote-count">${e.upvotes}</span>
72
81
  </button>
73
82
  <div class="upstep-feedback-main">
74
- <p class="upstep-feedback-content">${b(t.content)}</p>
83
+ <p class="upstep-feedback-content">${h(e.content)}</p>
75
84
  <div class="upstep-feedback-meta">
76
- <span class="upstep-badge upstep-badge-${t.type.toLowerCase()}">${t.type}</span>
77
- <span class="upstep-badge upstep-badge-general">${b(((e=t.boardStatus)==null?void 0:e.name)??t.status.replace("_"," "))}</span>
78
- <span class="upstep-feedback-date">${new Date(t.createdAt).toLocaleDateString()}</span>
85
+ <span class="upstep-badge upstep-badge-${e.type.toLowerCase()}">${e.type}</span>
86
+ <span class="upstep-badge upstep-badge-general">${h(((s=e.boardStatus)==null?void 0:s.name)??e.status.replace("_"," "))}</span>
87
+ <span class="upstep-feedback-date">${new Date(e.createdAt).toLocaleDateString()}</span>
79
88
  </div>
80
89
  </div>
81
- </div>`}).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const t=document.getElementById("upstep-body");!t||this.tab!=="feed"||(t.innerHTML=this.renderFeed(),this.bindVoteButtons())}bindSubmitForm(){var t;document.querySelectorAll(".upstep-type-btn").forEach(e=>{e.addEventListener("click",()=>{this.selectedType=e.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(i=>i.classList.remove("selected")),e.classList.add("selected")})}),(t=document.getElementById("upstep-submit-btn"))==null||t.addEventListener("click",async()=>{const e=document.getElementById("upstep-textarea"),i=document.getElementById("upstep-form-msg"),s=document.getElementById("upstep-submit-btn");if(!e||this.loading)return;const n=e.value.trim();if(n){this.loading=!0,s&&(s.disabled=!0,s.textContent="Sending…");try{await this.client.submitFeedback({content:n,type:this.selectedType}),e.value="",i&&(i.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{i&&(i.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,s&&(s.disabled=!1,s.textContent="Send feedback")}}})}bindVoteButtons(){document.querySelectorAll(".upstep-vote").forEach(t=>{t.addEventListener("click",async()=>{const e=t.dataset.feedback;try{await this.client.vote(e,"UP"),await this.fetchFeed()}catch{}})})}}function b(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let a=null,r=null;const f={init(o){if(a=new h.UpstepApiClient(o),typeof window<"u"){const t={};o.accentColor!==void 0&&(t.accentColor=o.accentColor),o.position!==void 0&&(t.position=o.position),o.theme!==void 0&&(t.theme=o.theme),o.launcher!==void 0&&(t.launcher=o.launcher);const e=()=>{r=new y(a,t),r.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}return a},open(){r==null||r.openWidget()},close(){r==null||r.closeWidget()},identify(o){a==null||a.setUserId(o)},identifySupport(o){var e;a&&(a.supportIdentityToken=o);const t=document.querySelector("#upstep-support-frame");t&&a&&((e=t.contentWindow)==null||e.postMessage({type:"upstep:support:identity",token:o},new URL(a.baseUrl).origin))},get client(){if(!a)throw new Error("Upstep.init() must be called first");return a}};if(typeof document<"u"){const o=document.currentScript,t=o==null?void 0:o.dataset.apiKey,e=o==null?void 0:o.dataset.userId,i=o==null?void 0:o.dataset.baseUrl,s=o==null?void 0:o.dataset.accentColor,n=o==null?void 0:o.dataset.position,d=o==null?void 0:o.dataset.theme;if(t){const p={apiKey:t};e&&(p.userId=e),(o==null?void 0:o.dataset.chat)!==void 0&&(p.chat=o.dataset.chat!=="false"),i&&(p.baseUrl=i),s&&(p.accentColor=s),(n==="left"||n==="right")&&(p.position=n),(d==="light"||d==="dark"||d==="auto")&&(p.theme=d),f.init(p)}}exports.UpstepApiClient=h.UpstepApiClient;exports.default=f;
90
+ </div>`}).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const e=document.getElementById("upstep-body");!e||this.tab!=="feed"||(e.innerHTML=this.renderFeed(),this.bindVoteButtons())}bindSubmitForm(){var e;document.querySelectorAll(".upstep-type-btn").forEach(s=>{s.addEventListener("click",()=>{this.selectedType=s.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(o=>o.classList.remove("selected")),s.classList.add("selected")})}),(e=document.getElementById("upstep-submit-btn"))==null||e.addEventListener("click",async()=>{const s=document.getElementById("upstep-textarea"),o=document.getElementById("upstep-form-msg"),n=document.getElementById("upstep-submit-btn");if(!s||this.loading)return;const i=s.value.trim();if(i){this.loading=!0,n&&(n.disabled=!0,n.textContent="Sending…");try{await this.client.submitFeedback({content:i,type:this.selectedType}),s.value="",o&&(o.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{o&&(o.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,n&&(n.disabled=!1,n.textContent="Send feedback")}}})}bindVoteButtons(){document.querySelectorAll(".upstep-vote").forEach(e=>{e.addEventListener("click",async()=>{const s=e.dataset.feedback;try{await this.client.vote(s,"UP"),await this.fetchFeed()}catch{}})})}}function h(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let d=null,p=null;const g={init(t){if(d=new x.UpstepApiClient(t),typeof window<"u"){const e={};t.accentColor!==void 0&&(e.accentColor=t.accentColor),t.position!==void 0&&(e.position=t.position),t.theme!==void 0&&(e.theme=t.theme),t.launcher!==void 0&&(e.launcher=t.launcher),t.colors!==void 0&&(e.colors=t.colors),t.radius!==void 0&&(e.radius=t.radius),t.fontFamily!==void 0&&(e.fontFamily=t.fontFamily);const s=()=>{p=new $(d,e),p.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",s):s()}return d},open(){p==null||p.openWidget()},close(){p==null||p.closeWidget()},identify(t){d==null||d.setUserId(t)},identifySupport(t){var s;d&&(d.supportIdentityToken=t);const e=document.querySelector("#upstep-support-frame");e&&d&&((s=e.contentWindow)==null||s.postMessage({type:"upstep:support:identity",token:t,visible:(p==null?void 0:p.isChatVisible())??!0},new URL(d.baseUrl).origin))},onUnread(t){return(p==null?void 0:p.onUnread(t))??(()=>{})},get client(){if(!d)throw new Error("Upstep.init() must be called first");return d}};if(typeof document<"u"){const t=document.currentScript,e=t==null?void 0:t.dataset.apiKey,s=t==null?void 0:t.dataset.userId,o=t==null?void 0:t.dataset.baseUrl,n=t==null?void 0:t.dataset.accentColor,i=t==null?void 0:t.dataset.position,r=t==null?void 0:t.dataset.theme;if(e){const a={apiKey:e};s&&(a.userId=s),(t==null?void 0:t.dataset.chat)!==void 0&&(a.chat=t.dataset.chat!=="false"),o&&(a.baseUrl=o),n&&(a.accentColor=n),(i==="left"||i==="right")&&(a.position=i),(r==="light"||r==="dark"||r==="auto")&&(a.theme=r);const b=t==null?void 0:t.dataset.colors;if(b)try{const c=JSON.parse(b);c&&typeof c=="object"&&(a.colors=c)}catch{console.warn("Upstep: data-colors must be JSON")}const u=t==null?void 0:t.dataset.radius;u&&Number.isFinite(Number(u))&&(a.radius=Number(u));const m=t==null?void 0:t.dataset.fontFamily;m&&(a.fontFamily=m),g.init(a)}}exports.UpstepApiClient=x.UpstepApiClient;exports.buildWidgetPalette=l.buildWidgetPalette;exports.readableTextOn=l.readableTextOn;exports.default=g;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { UpstepConfig } from '@upstep/types';
2
2
  import { UpstepApiClient } from './api';
3
- export type { UpstepConfig };
3
+ export type { UpstepConfig, UpstepColorOverrides, UpstepThemeColors, } from '@upstep/types';
4
4
  export { UpstepApiClient };
5
+ export { readableTextOn, buildWidgetPalette } from './theme';
5
6
  declare const Upstep: {
6
7
  init(config: UpstepConfig): UpstepApiClient;
7
8
  /** Open the feedback widget — use this to trigger it from your own UI. */
@@ -12,6 +13,8 @@ declare const Upstep: {
12
13
  identify(userId: string | undefined): void;
13
14
  /** Change or clear verified support identity after login/logout. */
14
15
  identifySupport(token: string | undefined): void;
16
+ /** Subscribe to the number of unread support messages, e.g. to drive your own launcher badge. */
17
+ onUnread(listener: (count: number) => void): () => void;
15
18
  readonly client: UpstepApiClient;
16
19
  };
17
20
  export default Upstep;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAGxC,YAAY,EAAE,YAAY,EAAE,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,CAAC;AAK3B,QAAA,MAAM,MAAM;iBACG,YAAY;IAqBzB,0EAA0E;;IAK1E,iCAAiC;;IAKjC,6EAA6E;qBAC5D,MAAM,GAAG,SAAS;IAInC,oEAAoE;2BAC7C,MAAM,GAAG,SAAS;qBAM3B,eAAe;CAI9B,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAGxC,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAK7D,QAAA,MAAM,MAAM;iBACG,YAAY;IAwBzB,0EAA0E;;IAK1E,iCAAiC;;IAKjC,6EAA6E;qBAC5D,MAAM,GAAG,SAAS;IAInC,oEAAoE;2BAC7C,MAAM,GAAG,SAAS;IAMzC,iGAAiG;uBAC9E,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;qBAI5B,eAAe;CAI9B,CAAC;AAEF,eAAe,MAAM,CAAC"}