@upstep/js 0.5.11 → 0.6.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
@@ -1,6 +1,6 @@
1
1
  # @upstep/js
2
2
 
3
- A feedback widget for web apps: a floating button, a voting board, and a submit form, backed by your [Upstep](https://upstep.dev) project. Drops into a React app, a vanilla JS app, or a plain HTML page with no build step, in two lines of code.
3
+ A feedback widget for web apps: a floating button, a voting board, and a submit form, backed by your [Upstep](https://upstep.dev) project. Drops into React, Next.js, Vue, Nuxt, SvelteKit, vanilla JS, or a plain HTML page with no build step, in two lines of code.
4
4
 
5
5
  ## Install
6
6
 
@@ -36,17 +36,30 @@ import Upstep from "@upstep/js";
36
36
  Upstep.init({ apiKey: "upstep_xxx" });
37
37
  ```
38
38
 
39
+ ### Vue / Nuxt / SvelteKit
40
+
41
+ ```ts
42
+ import Upstep from "@upstep/js";
43
+
44
+ Upstep.init({ apiKey: "upstep_xxx" });
45
+ ```
46
+
47
+ Mount that once from the client-side root for your framework:
48
+ - Vue: `onMounted()` in `App.vue`
49
+ - Nuxt: `plugins/upstep.client.ts`
50
+ - SvelteKit: `onMount()` in `src/routes/+layout.svelte`
51
+
39
52
  ### No build step (WordPress, Webflow, Shopify, static HTML)
40
53
 
41
54
  ```html
42
55
  <script
43
56
  type="module"
44
- src="https://unpkg.com/@upstep/js/dist/index.js"
57
+ src="https://unpkg.com/@upstep/js/dist/upstep.global.js"
45
58
  data-api-key="upstep_xxx"
46
59
  ></script>
47
60
  ```
48
61
 
49
- All three report to the same project, so feedback from your React app, a script tag on your marketing site, and (if you add [`@upstep/react-native`](https://www.npmjs.com/package/@upstep/react-native)) your mobile app all land on one board, sorted by votes.
62
+ All of these report to the same project, so feedback from your React app, your Nuxt marketing site, a script tag on a static page, and (if you add [`@upstep/react-native`](https://www.npmjs.com/package/@upstep/react-native) or [`upstep_flutter`](https://pub.dev/packages/upstep_flutter)) your mobile app all land on one board, sorted by votes.
50
63
 
51
64
  ## Configuration
52
65
 
@@ -80,5 +93,42 @@ Every entry point (`Upstep.init`, `<UpstepProvider>`, and the script tag's `data
80
93
  ## Links
81
94
 
82
95
  - [Full documentation](https://upstep.dev/#integrate)
96
+ - [Platform integration guides](https://upstep.dev/integrations)
83
97
  - [Dashboard / sign up](https://upstep.dev/login)
84
98
  - [@upstep/react-native](https://www.npmjs.com/package/@upstep/react-native) for React Native apps
99
+ - [upstep_flutter](https://pub.dev/packages/upstep_flutter) for Flutter apps
100
+
101
+ ### AI and live chat in the existing widget
102
+
103
+ Version 0.6.0 adds a **Support** tab to the same widget that handles feedback and
104
+ voting. Enable customer support for your paid project in the UpStep dashboard,
105
+ learn the business website, and confirm the business details and contact email.
106
+ The project must be enabled on the server; `chat: true` never bypasses plan access.
107
+ Chat is shown automatically by default when the project has enabled support.
108
+
109
+ ```ts
110
+ import Upstep from '@upstep/js';
111
+ Upstep.init({ apiKey: 'YOUR_PROJECT_KEY', chat: true });
112
+ // Use chat: false to keep this embed focused on feedback and voting.
113
+ ```
114
+
115
+ ```tsx
116
+ import { UpstepProvider, FeedbackWidget } from '@upstep/js/react';
117
+ <UpstepProvider apiKey="YOUR_PROJECT_KEY" chat={true}>
118
+ <FeedbackWidget />
119
+ </UpstepProvider>
120
+ // FeedbackWidget also accepts chat={false} to hide chat in that widget.
121
+ ```
122
+
123
+ ```html
124
+ <script defer src="https://unpkg.com/@upstep/js@0.6.0/dist/upstep.global.js"
125
+ data-api-key="YOUR_PROJECT_KEY" data-chat="true"></script>
126
+ ```
127
+
128
+ When no teammate is available, AI continues helping from the business's website
129
+ and confirmed answers. Unresolved issues can become private tickets with stable
130
+ references and the business's confirmed support email. Customer email is optional.
131
+ For private cross-device customer history, pass a backend-signed JWT as
132
+ `supportIdentityToken`, or call `Upstep.identifySupport(token)` after login and
133
+ `Upstep.identifySupport(undefined)` on logout. Never put the identity signing
134
+ secret in browser code. [Integration guide](https://upstep.dev/guides/customer-support).
@@ -0,0 +1 @@
1
+ "use strict";const d="upstep-anonymous-id";function h(){const o=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;if(typeof window>"u")return o;try{const e=window.localStorage.getItem(d);return e||(window.localStorage.setItem(d,o),o)}catch{return o}}class u{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=h()}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){return`${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?theme=${encodeURIComponent(e)}`}connectSupportFrame(e){const t=new URL(this.baseUrl).origin,s=()=>{var n;return(n=e.contentWindow)==null?void 0:n.postMessage({type:"upstep:support:identity",token:this.supportIdentityToken},t)},i=n=>{var r;n.origin===t&&n.source===e.contentWindow&&((r=n.data)==null?void 0:r.type)==="upstep:support:ready"&&s()};return e.addEventListener("load",s),window.addEventListener("message",i),()=>{e.removeEventListener("load",s),window.removeEventListener("message",i)}}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=u;
@@ -1,17 +1,17 @@
1
- const n = "upstep-anonymous-id";
2
- function i() {
1
+ const d = "upstep-anonymous-id";
2
+ function h() {
3
3
  const o = typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
4
4
  if (typeof window > "u") return o;
5
5
  try {
6
- const e = window.localStorage.getItem(n);
7
- return e || (window.localStorage.setItem(n, o), o);
6
+ const e = window.localStorage.getItem(d);
7
+ return e || (window.localStorage.setItem(d, o), o);
8
8
  } catch {
9
9
  return o;
10
10
  }
11
11
  }
12
- class r {
12
+ class u {
13
13
  constructor(e) {
14
- this.baseUrl = (e.baseUrl ?? "https://upstep.dev").replace(/\/$/, ""), this.apiKey = e.apiKey, e.userId !== void 0 && (this.userId = e.userId), this.anonymousId = i();
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
15
  }
16
16
  /** Update the end-user id at runtime (e.g. after the user logs in). */
17
17
  setUserId(e) {
@@ -23,6 +23,30 @@ class r {
23
23
  "x-api-key": this.apiKey
24
24
  };
25
25
  }
26
+ async supportEnabled() {
27
+ if (!this.chat) return !1;
28
+ try {
29
+ const e = await fetch(`${this.baseUrl}/api/sdk/support`, { headers: this.headers() });
30
+ return e.ok && (await e.json()).enabled === !0;
31
+ } catch {
32
+ return !1;
33
+ }
34
+ }
35
+ supportFrameUrl(e) {
36
+ return `${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?theme=${encodeURIComponent(e)}`;
37
+ }
38
+ connectSupportFrame(e) {
39
+ const t = new URL(this.baseUrl).origin, s = () => {
40
+ var n;
41
+ return (n = e.contentWindow) == null ? void 0 : n.postMessage({ type: "upstep:support:identity", token: this.supportIdentityToken }, t);
42
+ }, r = (n) => {
43
+ var i;
44
+ n.origin === t && n.source === e.contentWindow && ((i = n.data) == null ? void 0 : i.type) === "upstep:support:ready" && s();
45
+ };
46
+ return e.addEventListener("load", s), window.addEventListener("message", r), () => {
47
+ e.removeEventListener("load", s), window.removeEventListener("message", r);
48
+ };
49
+ }
26
50
  async listFeedback(e) {
27
51
  const t = new URLSearchParams();
28
52
  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);
@@ -74,5 +98,5 @@ class r {
74
98
  }
75
99
  }
76
100
  export {
77
- r as U
101
+ u as U
78
102
  };
package/dist/api.d.ts CHANGED
@@ -1,13 +1,18 @@
1
1
  import { Feedback, FeedbackListResponse, FeedbackWithComments, SubmitFeedbackPayload, VotePayload, UpstepConfig } from '@upstep/types';
2
2
  export declare class UpstepApiClient {
3
- private readonly baseUrl;
4
- private readonly apiKey;
3
+ readonly baseUrl: string;
4
+ readonly apiKey: string;
5
5
  userId: string | undefined;
6
+ supportIdentityToken: string | undefined;
7
+ chat: boolean;
6
8
  readonly anonymousId: string | undefined;
7
9
  constructor(config: UpstepConfig);
8
10
  /** Update the end-user id at runtime (e.g. after the user logs in). */
9
11
  setUserId(userId: string | undefined): void;
10
12
  private headers;
13
+ supportEnabled(): Promise<boolean>;
14
+ supportFrameUrl(theme: string): string;
15
+ connectSupportFrame(frame: HTMLIFrameElement): () => void;
11
16
  listFeedback(params?: {
12
17
  cursor?: string;
13
18
  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,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE7B,MAAM,EAAE,YAAY;IAOhC,uEAAuE;IACvE,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IAIpC,OAAO,CAAC,OAAO;IAOT,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;IASpE,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAW1D,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWpD"}
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;IAKxC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAItC,mBAAmB,CAAC,KAAK,EAAE,iBAAiB;IAStC,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;IASpE,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAW1D,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWpD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=embed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":""}
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("./api-DLrEC5_l.js"),E="#D97757",x={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},m={bg:"#1c1b19",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function y(o){if(o==="light"||o==="dark")return o;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 L(o,e,t){return`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("./api-BuSqdsZp.js"),S="#D97757",m={bg:"#ffffff",bgSoft:"#f6f5f2",bgHover:"#efede8",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},x={bg:"#000000",bgSoft:"#262522",bgHover:"#302e2a",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function y(o){if(o==="light"||o==="dark")return o;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 L(o,e,t){return`
2
2
  #upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
3
3
  #upstep-btn{position:fixed;bottom:24px;${e==="left"?"left:24px":"right:24px"};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:grab;touch-action:none;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
4
4
  #upstep-btn svg{width:16px;height:16px;flex-shrink:0}
@@ -47,24 +47,25 @@
47
47
  .upstep-feedback-date{font-size:11px;color:${t.textFaint}}
48
48
  .upstep-empty{text-align:center;color:${t.textFaint};font-size:14px;padding:40px 0}
49
49
  .upstep-empty strong{display:block;color:${t.textSoft};font-size:15px;margin-bottom:4px}
50
- `}const S='<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 C{constructor(e,t={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.dragMoved=!1,this.client=e,this.accent=t.accentColor??E,this.position=t.position??"right",this.showLauncher=t.launcher!==!1,this.themeMode=t.theme??"auto",this.palette=y(this.themeMode)==="dark"?m:x}mount(){this.injectStyles(),this.showLauncher&&this.renderButton()}openWidget(){this.openModal()}closeWidget(){this.closeModal()}injectStyles(){var t;(t=document.getElementById("upstep-styles"))==null||t.remove();const e=document.createElement("style");e.id="upstep-styles",e.textContent=L(this.accent,this.position,this.palette),document.head.appendChild(e)}renderButton(){const e=document.createElement("button");e.id="upstep-btn",e.innerHTML=`${S}<span>Feedback</span>`,e.addEventListener("click",()=>{this.dragMoved||this.openModal()}),document.body.appendChild(e),this.makeDraggable(e)}makeDraggable(e){const s="upstep-btn-pos";try{const i=localStorage.getItem(s);if(i){const{side:a,bottom:u}=JSON.parse(i);e.style.left=a==="left"?"24px":"auto",e.style.right=a==="right"?"24px":"auto",e.style.top="auto",e.style.bottom=`${u}px`}}catch{}let r=0,c=0,d=0,h=0,b=!1;const w=()=>{const i=e.getBoundingClientRect(),a=i.left+i.width/2<window.innerWidth/2?"left":"right",u=Math.max(24,Math.min(window.innerHeight-i.height-24,i.top)),g=window.innerHeight-u-i.height;e.style.transition="left .25s cubic-bezier(.16,1,.3,1),right .25s cubic-bezier(.16,1,.3,1),top .25s cubic-bezier(.16,1,.3,1),bottom .25s cubic-bezier(.16,1,.3,1),transform .15s,box-shadow .15s",e.style.left=a==="left"?"24px":"auto",e.style.right=a==="right"?"24px":"auto",e.style.top="auto",e.style.bottom=`${g}px`;try{localStorage.setItem(s,JSON.stringify({side:a,bottom:g}))}catch{}},$=i=>{if(i.pointerType==="mouse"&&i.button!==0)return;this.dragMoved=!1,b=!0;const a=e.getBoundingClientRect();r=i.clientX,c=i.clientY,d=a.left,h=a.top,e.setPointerCapture(i.pointerId),e.style.transition="none"},M=i=>{if(!b)return;const a=i.clientX-r,u=i.clientY-c;!this.dragMoved&&Math.hypot(a,u)<6||(this.dragMoved||e.classList.add("upstep-dragging"),this.dragMoved=!0,e.style.left=`${d+a}px`,e.style.right="auto",e.style.top=`${h+u}px`,e.style.bottom="auto")},f=()=>{b&&(b=!1,e.classList.remove("upstep-dragging"),this.dragMoved&&w())};e.addEventListener("pointerdown",$),e.addEventListener("pointermove",M),e.addEventListener("pointerup",f),e.addEventListener("pointercancel",f)}openModal(){this.isOpen=!0,this.palette=y(this.themeMode)==="dark"?m:x,this.injectStyles(),this.fetchFeed(),this.renderModal()}closeModal(){var e;this.isOpen=!1,(e=document.getElementById("upstep-backdrop"))==null||e.remove()}async fetchFeed(){try{const e=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=e.items,this.renderFeedList()}catch{}}renderModal(){var t,n;const e=document.createElement("div");e.id="upstep-backdrop",e.addEventListener("click",s=>{s.target===e&&this.closeModal()}),e.innerHTML=`
50
+ `}const C='<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 F{constructor(e,t={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.dragMoved=!1,this.hasSupport=!1,this.disconnectSupport=null,this.client=e,this.accent=t.accentColor??S,this.position=t.position??"right",this.showLauncher=t.launcher!==!1,this.themeMode=t.theme??"auto",this.palette=y(this.themeMode)==="dark"?x:m}mount(){this.injectStyles(),this.showLauncher&&this.renderButton(),this.client.supportEnabled().then(e=>{if(this.hasSupport=e,e){const t=document.querySelector("#upstep-btn span");t&&(t.textContent="Help & feedback"),this.isOpen&&this.renderModal()}})}openWidget(){this.openModal()}closeWidget(){this.closeModal()}injectStyles(){var t;(t=document.getElementById("upstep-styles"))==null||t.remove();const e=document.createElement("style");e.id="upstep-styles",e.textContent=L(this.accent,this.position,this.palette),document.head.appendChild(e)}renderButton(){const e=document.createElement("button");e.id="upstep-btn",e.setAttribute("aria-label","Open help and feedback"),e.innerHTML=`${C}<span>Feedback</span>`,e.addEventListener("click",()=>{this.dragMoved||this.openModal()}),document.body.appendChild(e),this.makeDraggable(e)}makeDraggable(e){const s="upstep-btn-pos";try{const i=localStorage.getItem(s);if(i){const{side:d,bottom:u}=JSON.parse(i);e.style.left=d==="left"?"24px":"auto",e.style.right=d==="right"?"24px":"auto",e.style.top="auto",e.style.bottom=`${u}px`}}catch{}let a=0,r=0,l=0,b=0,h=!1;const $=()=>{const i=e.getBoundingClientRect(),d=i.left+i.width/2<window.innerWidth/2?"left":"right",u=Math.max(24,Math.min(window.innerHeight-i.height-24,i.top)),g=window.innerHeight-u-i.height;e.style.transition="left .25s cubic-bezier(.16,1,.3,1),right .25s cubic-bezier(.16,1,.3,1),top .25s cubic-bezier(.16,1,.3,1),bottom .25s cubic-bezier(.16,1,.3,1),transform .15s,box-shadow .15s",e.style.left=d==="left"?"24px":"auto",e.style.right=d==="right"?"24px":"auto",e.style.top="auto",e.style.bottom=`${g}px`;try{localStorage.setItem(s,JSON.stringify({side:d,bottom:g}))}catch{}},M=i=>{if(i.pointerType==="mouse"&&i.button!==0)return;this.dragMoved=!1,h=!0;const d=e.getBoundingClientRect();a=i.clientX,r=i.clientY,l=d.left,b=d.top,e.setPointerCapture(i.pointerId),e.style.transition="none"},E=i=>{if(!h)return;const d=i.clientX-a,u=i.clientY-r;!this.dragMoved&&Math.hypot(d,u)<6||(this.dragMoved||e.classList.add("upstep-dragging"),this.dragMoved=!0,e.style.left=`${l+d}px`,e.style.right="auto",e.style.top=`${b+u}px`,e.style.bottom="auto")},f=()=>{h&&(h=!1,e.classList.remove("upstep-dragging"),this.dragMoved&&$())};e.addEventListener("pointerdown",M),e.addEventListener("pointermove",E),e.addEventListener("pointerup",f),e.addEventListener("pointercancel",f)}openModal(){this.isOpen=!0,this.palette=y(this.themeMode)==="dark"?x:m,this.injectStyles(),this.fetchFeed(),this.renderModal()}closeModal(){var e,t;(e=this.disconnectSupport)==null||e.call(this),this.disconnectSupport=null,this.isOpen=!1,(t=document.getElementById("upstep-backdrop"))==null||t.remove()}async fetchFeed(){try{const e=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=e.items,this.renderFeedList()}catch{}}renderModal(){var n,s,a;(n=this.disconnectSupport)==null||n.call(this),this.disconnectSupport=null;const e=document.createElement("div");e.id="upstep-backdrop",e.addEventListener("click",r=>{r.target===e&&this.closeModal()}),e.innerHTML=`
51
51
  <div id="upstep-modal">
52
52
  <div id="upstep-header">
53
53
  <div>
54
- <h2>Share your feedback</h2>
55
- <p>Tell us what to build next, or vote on ideas.</p>
54
+ <h2>${this.tab==="support"?"Customer support":"Share your feedback"}</h2>
55
+ <p>${this.tab==="support"?"Ask AI, or talk with the team.":"Tell us what to build next, or vote on ideas."}</p>
56
56
  </div>
57
57
  <button id="upstep-close" aria-label="Close">✕</button>
58
58
  </div>
59
59
  <div id="upstep-tabs">
60
+ ${this.hasSupport?`<button class="upstep-tab ${this.tab==="support"?"active":""}" data-tab="support">Support</button>`:""}
60
61
  <button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Give feedback</button>
61
62
  <button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Vote on ideas</button>
62
63
  </div>
63
64
  <div id="upstep-body">
64
- ${this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
65
+ ${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg==="#000000"?"dark":"light")}" style="width:100%;height:480px;border:0;display:block;border-radius:12px"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
65
66
  </div>
66
67
  </div>
67
- `,(t=document.getElementById("upstep-backdrop"))==null||t.remove(),document.body.appendChild(e),(n=e.querySelector("#upstep-close"))==null||n.addEventListener("click",()=>this.closeModal()),e.querySelectorAll(".upstep-tab").forEach(s=>{s.addEventListener("click",()=>{this.tab=s.dataset.tab,this.renderModal()})}),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const e=["BUG","FEATURE","GENERAL"],t={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},n={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`
68
+ `,(s=document.getElementById("upstep-backdrop"))==null||s.remove(),document.body.appendChild(e),(a=e.querySelector("#upstep-close"))==null||a.addEventListener("click",()=>this.closeModal()),e.querySelectorAll(".upstep-tab").forEach(r=>{r.addEventListener("click",()=>{this.tab=r.dataset.tab,this.renderModal()})});const t=e.querySelector("#upstep-support-frame");t&&(this.disconnectSupport=this.client.connectSupportFrame(t)),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const e=["BUG","FEATURE","GENERAL"],t={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},n={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`
68
69
  <div class="upstep-form">
69
70
  <textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
70
71
  <div class="upstep-type-row">
@@ -73,17 +74,18 @@
73
74
  <button class="upstep-submit" id="upstep-submit-btn">Send feedback</button>
74
75
  <div id="upstep-form-msg"></div>
75
76
  </div>
76
- `}renderFeed(){return this.feedItems.length?this.feedItems.map(e=>`
77
+ `}renderFeed(){return this.feedItems.length?this.feedItems.map(e=>{var t;return`
77
78
  <div class="upstep-feedback-item" data-id="${e.id}">
78
79
  <button class="upstep-vote${e.userVote==="UP"?" voted":""}" data-vote="UP" data-feedback="${e.id}">
79
80
  <span class="upstep-vote-arrow">▲</span>
80
81
  <span class="upstep-vote-count">${e.upvotes}</span>
81
82
  </button>
82
83
  <div class="upstep-feedback-main">
83
- <p class="upstep-feedback-content">${F(e.content)}</p>
84
+ <p class="upstep-feedback-content">${v(e.content)}</p>
84
85
  <div class="upstep-feedback-meta">
85
86
  <span class="upstep-badge upstep-badge-${e.type.toLowerCase()}">${e.type}</span>
87
+ <span class="upstep-badge upstep-badge-general">${v(((t=e.boardStatus)==null?void 0:t.name)??e.status.replace("_"," "))}</span>
86
88
  <span class="upstep-feedback-date">${new Date(e.createdAt).toLocaleDateString()}</span>
87
89
  </div>
88
90
  </div>
89
- </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(t=>{t.addEventListener("click",()=>{this.selectedType=t.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(n=>n.classList.remove("selected")),t.classList.add("selected")})}),(e=document.getElementById("upstep-submit-btn"))==null||e.addEventListener("click",async()=>{const t=document.getElementById("upstep-textarea"),n=document.getElementById("upstep-form-msg"),s=document.getElementById("upstep-submit-btn");if(!t||this.loading)return;const r=t.value.trim();if(r){this.loading=!0,s&&(s.disabled=!0,s.textContent="Sending…");try{await this.client.submitFeedback({content:r,type:this.selectedType}),t.value="",n&&(n.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{n&&(n.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(e=>{e.addEventListener("click",async()=>{const t=e.dataset.feedback;try{await this.client.vote(t,"UP"),await this.fetchFeed()}catch{}})})}}function F(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let p=null,l=null;const k={init(o){if(p=new v.UpstepApiClient(o),typeof window<"u"){const e={};o.accentColor!==void 0&&(e.accentColor=o.accentColor),o.position!==void 0&&(e.position=o.position),o.theme!==void 0&&(e.theme=o.theme),o.launcher!==void 0&&(e.launcher=o.launcher);const t=()=>{l=new C(p,e),l.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}return p},open(){l==null||l.openWidget()},close(){l==null||l.closeWidget()},identify(o){p==null||p.setUserId(o)},get client(){if(!p)throw new Error("Upstep.init() must be called first");return p}};if(typeof document<"u"){const o=document.currentScript,e=o==null?void 0:o.dataset.apiKey,t=o==null?void 0:o.dataset.userId,n=o==null?void 0:o.dataset.baseUrl,s=o==null?void 0:o.dataset.accentColor,r=o==null?void 0:o.dataset.position,c=o==null?void 0:o.dataset.theme;if(e){const d={apiKey:e};t&&(d.userId=t),n&&(d.baseUrl=n),s&&(d.accentColor=s),(r==="left"||r==="right")&&(d.position=r),(c==="light"||c==="dark"||c==="auto")&&(d.theme=c),k.init(d)}}exports.UpstepApiClient=v.UpstepApiClient;exports.default=k;
91
+ </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(t=>{t.addEventListener("click",()=>{this.selectedType=t.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(n=>n.classList.remove("selected")),t.classList.add("selected")})}),(e=document.getElementById("upstep-submit-btn"))==null||e.addEventListener("click",async()=>{const t=document.getElementById("upstep-textarea"),n=document.getElementById("upstep-form-msg"),s=document.getElementById("upstep-submit-btn");if(!t||this.loading)return;const a=t.value.trim();if(a){this.loading=!0,s&&(s.disabled=!0,s.textContent="Sending…");try{await this.client.submitFeedback({content:a,type:this.selectedType}),t.value="",n&&(n.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{n&&(n.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(e=>{e.addEventListener("click",async()=>{const t=e.dataset.feedback;try{await this.client.vote(t,"UP"),await this.fetchFeed()}catch{}})})}}function v(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let p=null,c=null;const w={init(o){if(p=new k.UpstepApiClient(o),typeof window<"u"){const e={};o.accentColor!==void 0&&(e.accentColor=o.accentColor),o.position!==void 0&&(e.position=o.position),o.theme!==void 0&&(e.theme=o.theme),o.launcher!==void 0&&(e.launcher=o.launcher);const t=()=>{c=new F(p,e),c.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}return p},open(){c==null||c.openWidget()},close(){c==null||c.closeWidget()},identify(o){p==null||p.setUserId(o)},identifySupport(o){var t;p&&(p.supportIdentityToken=o);const e=document.querySelector("#upstep-support-frame");e&&p&&((t=e.contentWindow)==null||t.postMessage({type:"upstep:support:identity",token:o},new URL(p.baseUrl).origin))},get client(){if(!p)throw new Error("Upstep.init() must be called first");return p}};if(typeof document<"u"){const o=document.currentScript,e=o==null?void 0:o.dataset.apiKey,t=o==null?void 0:o.dataset.userId,n=o==null?void 0:o.dataset.baseUrl,s=o==null?void 0:o.dataset.accentColor,a=o==null?void 0:o.dataset.position,r=o==null?void 0:o.dataset.theme;if(e){const l={apiKey:e};t&&(l.userId=t),(o==null?void 0:o.dataset.chat)!==void 0&&(l.chat=o.dataset.chat!=="false"),n&&(l.baseUrl=n),s&&(l.accentColor=s),(a==="left"||a==="right")&&(l.position=a),(r==="light"||r==="dark"||r==="auto")&&(l.theme=r),w.init(l)}}exports.UpstepApiClient=k.UpstepApiClient;exports.default=w;
package/dist/index.d.ts CHANGED
@@ -10,6 +10,8 @@ declare const Upstep: {
10
10
  close(): void;
11
11
  /** Set / update the end-user id at runtime (e.g. after the user logs in). */
12
12
  identify(userId: string | undefined): void;
13
+ /** Change or clear verified support identity after login/logout. */
14
+ identifySupport(token: string | undefined): void;
13
15
  readonly client: UpstepApiClient;
14
16
  };
15
17
  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;qBAIrB,eAAe;CAI9B,CAAC;AAEF,eAAe,MAAM,CAAC"}
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"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { U as $ } from "./api-DIQt-yuC.mjs";
2
- const M = "#D97757", x = {
1
+ import { U as M } from "./api-C1UV7Szw.mjs";
2
+ const E = "#D97757", m = {
3
3
  bg: "#ffffff",
4
4
  bgSoft: "#f6f5f2",
5
5
  bgHover: "#efede8",
@@ -8,8 +8,8 @@ const M = "#D97757", x = {
8
8
  textFaint: "#9b9890",
9
9
  border: "#e8e6df",
10
10
  overlay: "rgba(26,25,21,.45)"
11
- }, m = {
12
- bg: "#1c1b19",
11
+ }, x = {
12
+ bg: "#000000",
13
13
  bgSoft: "#262522",
14
14
  bgHover: "#302e2a",
15
15
  text: "#f5f4f0",
@@ -26,7 +26,7 @@ function y(o) {
26
26
  }
27
27
  return typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
28
28
  }
29
- function E(o, e, t) {
29
+ function S(o, e, t) {
30
30
  return `
31
31
  #upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
32
32
  #upstep-btn{position:fixed;bottom:24px;${e === "left" ? "left:24px" : "right:24px"};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:grab;touch-action:none;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
@@ -79,12 +79,17 @@ function E(o, e, t) {
79
79
  `;
80
80
  }
81
81
  const L = '<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>';
82
- class S {
82
+ class C {
83
83
  constructor(e, t = {}) {
84
- this.isOpen = !1, this.tab = "submit", this.feedItems = [], this.selectedType = "GENERAL", this.loading = !1, this.dragMoved = !1, this.client = e, this.accent = t.accentColor ?? M, this.position = t.position ?? "right", this.showLauncher = t.launcher !== !1, this.themeMode = t.theme ?? "auto", this.palette = y(this.themeMode) === "dark" ? m : x;
84
+ this.isOpen = !1, this.tab = "submit", this.feedItems = [], this.selectedType = "GENERAL", this.loading = !1, this.dragMoved = !1, this.hasSupport = !1, this.disconnectSupport = null, this.client = e, this.accent = t.accentColor ?? E, this.position = t.position ?? "right", this.showLauncher = t.launcher !== !1, this.themeMode = t.theme ?? "auto", this.palette = y(this.themeMode) === "dark" ? x : m;
85
85
  }
86
86
  mount() {
87
- this.injectStyles(), this.showLauncher && this.renderButton();
87
+ this.injectStyles(), this.showLauncher && this.renderButton(), this.client.supportEnabled().then((e) => {
88
+ if (this.hasSupport = e, e) {
89
+ const t = document.querySelector("#upstep-btn span");
90
+ t && (t.textContent = "Help & feedback"), this.isOpen && this.renderModal();
91
+ }
92
+ });
88
93
  }
89
94
  /** Open the feedback modal programmatically (e.g. from your own button). */
90
95
  openWidget() {
@@ -98,11 +103,11 @@ class S {
98
103
  var t;
99
104
  (t = document.getElementById("upstep-styles")) == null || t.remove();
100
105
  const e = document.createElement("style");
101
- e.id = "upstep-styles", e.textContent = E(this.accent, this.position, this.palette), document.head.appendChild(e);
106
+ e.id = "upstep-styles", e.textContent = S(this.accent, this.position, this.palette), document.head.appendChild(e);
102
107
  }
103
108
  renderButton() {
104
109
  const e = document.createElement("button");
105
- e.id = "upstep-btn", e.innerHTML = `${L}<span>Feedback</span>`, e.addEventListener("click", () => {
110
+ e.id = "upstep-btn", e.setAttribute("aria-label", "Open help and feedback"), e.innerHTML = `${L}<span>Feedback</span>`, e.addEventListener("click", () => {
106
111
  this.dragMoved || this.openModal();
107
112
  }), document.body.appendChild(e), this.makeDraggable(e);
108
113
  }
@@ -111,39 +116,39 @@ class S {
111
116
  try {
112
117
  const i = localStorage.getItem(s);
113
118
  if (i) {
114
- const { side: a, bottom: u } = JSON.parse(i);
115
- e.style.left = a === "left" ? "24px" : "auto", e.style.right = a === "right" ? "24px" : "auto", e.style.top = "auto", e.style.bottom = `${u}px`;
119
+ const { side: d, bottom: u } = JSON.parse(i);
120
+ e.style.left = d === "left" ? "24px" : "auto", e.style.right = d === "right" ? "24px" : "auto", e.style.top = "auto", e.style.bottom = `${u}px`;
116
121
  }
117
122
  } catch {
118
123
  }
119
- let r = 0, c = 0, d = 0, h = 0, b = !1;
120
- const v = () => {
121
- const i = e.getBoundingClientRect(), a = i.left + i.width / 2 < window.innerWidth / 2 ? "left" : "right", u = Math.max(24, Math.min(window.innerHeight - i.height - 24, i.top)), g = window.innerHeight - u - i.height;
122
- e.style.transition = "left .25s cubic-bezier(.16,1,.3,1),right .25s cubic-bezier(.16,1,.3,1),top .25s cubic-bezier(.16,1,.3,1),bottom .25s cubic-bezier(.16,1,.3,1),transform .15s,box-shadow .15s", e.style.left = a === "left" ? "24px" : "auto", e.style.right = a === "right" ? "24px" : "auto", e.style.top = "auto", e.style.bottom = `${g}px`;
124
+ let a = 0, r = 0, l = 0, b = 0, h = !1;
125
+ const k = () => {
126
+ const i = e.getBoundingClientRect(), d = i.left + i.width / 2 < window.innerWidth / 2 ? "left" : "right", u = Math.max(24, Math.min(window.innerHeight - i.height - 24, i.top)), g = window.innerHeight - u - i.height;
127
+ e.style.transition = "left .25s cubic-bezier(.16,1,.3,1),right .25s cubic-bezier(.16,1,.3,1),top .25s cubic-bezier(.16,1,.3,1),bottom .25s cubic-bezier(.16,1,.3,1),transform .15s,box-shadow .15s", e.style.left = d === "left" ? "24px" : "auto", e.style.right = d === "right" ? "24px" : "auto", e.style.top = "auto", e.style.bottom = `${g}px`;
123
128
  try {
124
- localStorage.setItem(s, JSON.stringify({ side: a, bottom: g }));
129
+ localStorage.setItem(s, JSON.stringify({ side: d, bottom: g }));
125
130
  } catch {
126
131
  }
127
- }, k = (i) => {
128
- if (i.pointerType === "mouse" && i.button !== 0) return;
129
- this.dragMoved = !1, b = !0;
130
- const a = e.getBoundingClientRect();
131
- r = i.clientX, c = i.clientY, d = a.left, h = a.top, e.setPointerCapture(i.pointerId), e.style.transition = "none";
132
132
  }, w = (i) => {
133
- if (!b) return;
134
- const a = i.clientX - r, u = i.clientY - c;
135
- !this.dragMoved && Math.hypot(a, u) < 6 || (this.dragMoved || e.classList.add("upstep-dragging"), this.dragMoved = !0, e.style.left = `${d + a}px`, e.style.right = "auto", e.style.top = `${h + u}px`, e.style.bottom = "auto");
133
+ if (i.pointerType === "mouse" && i.button !== 0) return;
134
+ this.dragMoved = !1, h = !0;
135
+ const d = e.getBoundingClientRect();
136
+ a = i.clientX, r = i.clientY, l = d.left, b = d.top, e.setPointerCapture(i.pointerId), e.style.transition = "none";
137
+ }, $ = (i) => {
138
+ if (!h) return;
139
+ const d = i.clientX - a, u = i.clientY - r;
140
+ !this.dragMoved && Math.hypot(d, u) < 6 || (this.dragMoved || e.classList.add("upstep-dragging"), this.dragMoved = !0, e.style.left = `${l + d}px`, e.style.right = "auto", e.style.top = `${b + u}px`, e.style.bottom = "auto");
136
141
  }, f = () => {
137
- b && (b = !1, e.classList.remove("upstep-dragging"), this.dragMoved && v());
142
+ h && (h = !1, e.classList.remove("upstep-dragging"), this.dragMoved && k());
138
143
  };
139
- e.addEventListener("pointerdown", k), e.addEventListener("pointermove", w), e.addEventListener("pointerup", f), e.addEventListener("pointercancel", f);
144
+ e.addEventListener("pointerdown", w), e.addEventListener("pointermove", $), e.addEventListener("pointerup", f), e.addEventListener("pointercancel", f);
140
145
  }
141
146
  openModal() {
142
- this.isOpen = !0, this.palette = y(this.themeMode) === "dark" ? m : x, this.injectStyles(), this.fetchFeed(), this.renderModal();
147
+ this.isOpen = !0, this.palette = y(this.themeMode) === "dark" ? x : m, this.injectStyles(), this.fetchFeed(), this.renderModal();
143
148
  }
144
149
  closeModal() {
145
- var e;
146
- this.isOpen = !1, (e = document.getElementById("upstep-backdrop")) == null || e.remove();
150
+ var e, t;
151
+ (e = this.disconnectSupport) == null || e.call(this), this.disconnectSupport = null, this.isOpen = !1, (t = document.getElementById("upstep-backdrop")) == null || t.remove();
147
152
  }
148
153
  async fetchFeed() {
149
154
  try {
@@ -153,32 +158,36 @@ class S {
153
158
  }
154
159
  }
155
160
  renderModal() {
156
- var t, n;
161
+ var n, s, a;
162
+ (n = this.disconnectSupport) == null || n.call(this), this.disconnectSupport = null;
157
163
  const e = document.createElement("div");
158
- e.id = "upstep-backdrop", e.addEventListener("click", (s) => {
159
- s.target === e && this.closeModal();
164
+ e.id = "upstep-backdrop", e.addEventListener("click", (r) => {
165
+ r.target === e && this.closeModal();
160
166
  }), e.innerHTML = `
161
167
  <div id="upstep-modal">
162
168
  <div id="upstep-header">
163
169
  <div>
164
- <h2>Share your feedback</h2>
165
- <p>Tell us what to build next, or vote on ideas.</p>
170
+ <h2>${this.tab === "support" ? "Customer support" : "Share your feedback"}</h2>
171
+ <p>${this.tab === "support" ? "Ask AI, or talk with the team." : "Tell us what to build next, or vote on ideas."}</p>
166
172
  </div>
167
173
  <button id="upstep-close" aria-label="Close">✕</button>
168
174
  </div>
169
175
  <div id="upstep-tabs">
176
+ ${this.hasSupport ? `<button class="upstep-tab ${this.tab === "support" ? "active" : ""}" data-tab="support">Support</button>` : ""}
170
177
  <button class="upstep-tab ${this.tab === "submit" ? "active" : ""}" data-tab="submit">Give feedback</button>
171
178
  <button class="upstep-tab ${this.tab === "feed" ? "active" : ""}" data-tab="feed">Vote on ideas</button>
172
179
  </div>
173
180
  <div id="upstep-body">
174
- ${this.tab === "submit" ? this.renderSubmitForm() : this.renderFeed()}
181
+ ${this.tab === "support" ? `<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg === "#000000" ? "dark" : "light")}" style="width:100%;height:480px;border:0;display:block;border-radius:12px"></iframe>` : this.tab === "submit" ? this.renderSubmitForm() : this.renderFeed()}
175
182
  </div>
176
183
  </div>
177
- `, (t = document.getElementById("upstep-backdrop")) == null || t.remove(), document.body.appendChild(e), (n = e.querySelector("#upstep-close")) == null || n.addEventListener("click", () => this.closeModal()), e.querySelectorAll(".upstep-tab").forEach((s) => {
178
- s.addEventListener("click", () => {
179
- this.tab = s.dataset.tab, this.renderModal();
184
+ `, (s = document.getElementById("upstep-backdrop")) == null || s.remove(), document.body.appendChild(e), (a = e.querySelector("#upstep-close")) == null || a.addEventListener("click", () => this.closeModal()), e.querySelectorAll(".upstep-tab").forEach((r) => {
185
+ r.addEventListener("click", () => {
186
+ this.tab = r.dataset.tab, this.renderModal();
180
187
  });
181
- }), this.bindSubmitForm(), this.bindVoteButtons();
188
+ });
189
+ const t = e.querySelector("#upstep-support-frame");
190
+ t && (this.disconnectSupport = this.client.connectSupportFrame(t)), this.bindSubmitForm(), this.bindVoteButtons();
182
191
  }
183
192
  renderSubmitForm() {
184
193
  const e = ["BUG", "FEATURE", "GENERAL"], t = { BUG: "Bug", FEATURE: "Feature", GENERAL: "General" }, n = {
@@ -199,20 +208,24 @@ class S {
199
208
  }
200
209
  renderFeed() {
201
210
  return this.feedItems.length ? this.feedItems.map(
202
- (e) => `
211
+ (e) => {
212
+ var t;
213
+ return `
203
214
  <div class="upstep-feedback-item" data-id="${e.id}">
204
215
  <button class="upstep-vote${e.userVote === "UP" ? " voted" : ""}" data-vote="UP" data-feedback="${e.id}">
205
216
  <span class="upstep-vote-arrow">▲</span>
206
217
  <span class="upstep-vote-count">${e.upvotes}</span>
207
218
  </button>
208
219
  <div class="upstep-feedback-main">
209
- <p class="upstep-feedback-content">${F(e.content)}</p>
220
+ <p class="upstep-feedback-content">${v(e.content)}</p>
210
221
  <div class="upstep-feedback-meta">
211
222
  <span class="upstep-badge upstep-badge-${e.type.toLowerCase()}">${e.type}</span>
223
+ <span class="upstep-badge upstep-badge-general">${v(((t = e.boardStatus) == null ? void 0 : t.name) ?? e.status.replace("_", " "))}</span>
212
224
  <span class="upstep-feedback-date">${new Date(e.createdAt).toLocaleDateString()}</span>
213
225
  </div>
214
226
  </div>
215
- </div>`
227
+ </div>`;
228
+ }
216
229
  ).join("") : '<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>';
217
230
  }
218
231
  renderFeedList() {
@@ -228,11 +241,11 @@ class S {
228
241
  }), (e = document.getElementById("upstep-submit-btn")) == null || e.addEventListener("click", async () => {
229
242
  const t = document.getElementById("upstep-textarea"), n = document.getElementById("upstep-form-msg"), s = document.getElementById("upstep-submit-btn");
230
243
  if (!t || this.loading) return;
231
- const r = t.value.trim();
232
- if (r) {
244
+ const a = t.value.trim();
245
+ if (a) {
233
246
  this.loading = !0, s && (s.disabled = !0, s.textContent = "Sending…");
234
247
  try {
235
- await this.client.submitFeedback({ content: r, type: this.selectedType }), t.value = "", n && (n.textContent = "Feedback received. Thank you."), await this.fetchFeed();
248
+ await this.client.submitFeedback({ content: a, type: this.selectedType }), t.value = "", n && (n.textContent = "Feedback received. Thank you."), await this.fetchFeed();
236
249
  } catch {
237
250
  n && (n.textContent = "Something went wrong. Please try again.");
238
251
  } finally {
@@ -253,17 +266,17 @@ class S {
253
266
  });
254
267
  }
255
268
  }
256
- function F(o) {
269
+ function v(o) {
257
270
  return o.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
258
271
  }
259
- let p = null, l = null;
260
- const C = {
272
+ let p = null, c = null;
273
+ const F = {
261
274
  init(o) {
262
- if (p = new $(o), typeof window < "u") {
275
+ if (p = new M(o), typeof window < "u") {
263
276
  const e = {};
264
277
  o.accentColor !== void 0 && (e.accentColor = o.accentColor), o.position !== void 0 && (e.position = o.position), o.theme !== void 0 && (e.theme = o.theme), o.launcher !== void 0 && (e.launcher = o.launcher);
265
278
  const t = () => {
266
- l = new S(p, e), l.mount();
279
+ c = new C(p, e), c.mount();
267
280
  };
268
281
  document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : t();
269
282
  }
@@ -271,29 +284,36 @@ const C = {
271
284
  },
272
285
  /** Open the feedback widget — use this to trigger it from your own UI. */
273
286
  open() {
274
- l == null || l.openWidget();
287
+ c == null || c.openWidget();
275
288
  },
276
289
  /** Close the feedback widget. */
277
290
  close() {
278
- l == null || l.closeWidget();
291
+ c == null || c.closeWidget();
279
292
  },
280
293
  /** Set / update the end-user id at runtime (e.g. after the user logs in). */
281
294
  identify(o) {
282
295
  p == null || p.setUserId(o);
283
296
  },
297
+ /** Change or clear verified support identity after login/logout. */
298
+ identifySupport(o) {
299
+ var t;
300
+ p && (p.supportIdentityToken = o);
301
+ const e = document.querySelector("#upstep-support-frame");
302
+ e && p && ((t = e.contentWindow) == null || t.postMessage({ type: "upstep:support:identity", token: o }, new URL(p.baseUrl).origin));
303
+ },
284
304
  get client() {
285
305
  if (!p) throw new Error("Upstep.init() must be called first");
286
306
  return p;
287
307
  }
288
308
  };
289
309
  if (typeof document < "u") {
290
- const o = document.currentScript, e = o == null ? void 0 : o.dataset.apiKey, t = o == null ? void 0 : o.dataset.userId, n = o == null ? void 0 : o.dataset.baseUrl, s = o == null ? void 0 : o.dataset.accentColor, r = o == null ? void 0 : o.dataset.position, c = o == null ? void 0 : o.dataset.theme;
310
+ const o = document.currentScript, e = o == null ? void 0 : o.dataset.apiKey, t = o == null ? void 0 : o.dataset.userId, n = o == null ? void 0 : o.dataset.baseUrl, s = o == null ? void 0 : o.dataset.accentColor, a = o == null ? void 0 : o.dataset.position, r = o == null ? void 0 : o.dataset.theme;
291
311
  if (e) {
292
- const d = { apiKey: e };
293
- t && (d.userId = t), n && (d.baseUrl = n), s && (d.accentColor = s), (r === "left" || r === "right") && (d.position = r), (c === "light" || c === "dark" || c === "auto") && (d.theme = c), C.init(d);
312
+ const l = { apiKey: e };
313
+ t && (l.userId = t), (o == null ? void 0 : o.dataset.chat) !== void 0 && (l.chat = o.dataset.chat !== "false"), n && (l.baseUrl = n), s && (l.accentColor = s), (a === "left" || a === "right") && (l.position = a), (r === "light" || r === "dark" || r === "auto") && (l.theme = r), F.init(l);
294
314
  }
295
315
  }
296
316
  export {
297
- $ as UpstepApiClient,
298
- C as default
317
+ M as UpstepApiClient,
318
+ F as default
299
319
  };