@getuserfeedback/sdk 0.1.0 → 0.3.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
@@ -12,12 +12,12 @@ Secure, performant, and tiny SDK for [getuserfeedback.com](https://getuserfeedba
12
12
  npm install @getuserfeedback/sdk
13
13
  ```
14
14
 
15
- ## Get Started
15
+ ## Get started
16
16
 
17
17
  ### 1. Get an API key
18
18
  Sign up on [getuserfeedback.com](https://getuserfeedback.com) and grab your key in Settings.
19
19
 
20
- ### 2. Wire the client
20
+ ### 2. Add the client
21
21
 
22
22
  ```ts
23
23
  // client.ts
@@ -47,16 +47,16 @@ Our AI-powered theme editor allows a complete overhaul of the widget look and fe
47
47
 
48
48
  ## Advanced use cases
49
49
  ### Feedback form
50
- You can call flows imperatively, e.g., open a feedback form when the user clicks a dedicated button in your UI.
50
+ You can call flows imperatively, e.g., open a support form when the user clicks a help menu item.
51
51
 
52
52
  ```ts
53
- // feedback form you created on getuserfeedback.com
54
- const FEEDBACK_FLOW_ID = "YOUR_FLOW_ID";
53
+ // contact support flow you created on getuserfeedback.com
54
+ const CONTACT_SUPPORT_FLOW_ID = "YOUR_FLOW_ID";
55
55
 
56
- const button = document.querySelector<HTMLButtonElement>("#feedback-button");
56
+ const supportMenuItem = document.querySelector<HTMLButtonElement>("#help-menu-contact-support");
57
57
 
58
- button?.addEventListener("click", () => {
59
- client.open(FEEDBACK_FLOW_ID);
58
+ supportMenuItem?.addEventListener("click", () => {
59
+ client.open(CONTACT_SUPPORT_FLOW_ID);
60
60
  });
61
61
  ```
62
62
 
@@ -69,7 +69,7 @@ For example, if you're using custom dialogs throughout your product, our widgets
69
69
  const flow = await client.flow("YOUR_FLOW_ID");
70
70
 
71
71
  // your custom container, e.g. a dialog
72
- const container = document.querySelector<HTMLDivElement>("#feedback-dialog-body");
72
+ const container = document.querySelector<HTMLDivElement>("#support-dialog-body");
73
73
 
74
74
  if (container) {
75
75
  flow.setContainer(container);
@@ -129,8 +129,27 @@ export const client = createClient({
129
129
  disableAutoLoad: true,
130
130
  });
131
131
 
132
- // later, when ready:
133
- client.load();
132
+ type ConsentResolvedDetail = {
133
+ hasResolvedConsent: boolean;
134
+ };
135
+
136
+ function isConsentResolvedEvent(
137
+ event: Event,
138
+ ): event is CustomEvent<ConsentResolvedDetail> {
139
+ return event instanceof CustomEvent;
140
+ }
141
+
142
+ window.addEventListener("cookie-consent-resolved", (event) => {
143
+ if (!isConsentResolvedEvent(event)) {
144
+ return;
145
+ }
146
+
147
+ if (!event.detail?.hasResolvedConsent) {
148
+ return;
149
+ }
150
+
151
+ client.load();
152
+ });
134
153
  ```
135
154
 
136
155
  ## Identify users
@@ -165,9 +184,15 @@ client.identify({
165
184
  Call this on logout to clear active identity state and auth (if you use auth):
166
185
 
167
186
  ```ts
187
+ import { auth } from "./auth";
168
188
  import { client } from "./client";
169
189
 
170
- client.reset();
190
+ const logoutButton = document.querySelector<HTMLButtonElement>("#logout-button");
191
+
192
+ logoutButton?.addEventListener("click", async () => {
193
+ await auth.signOut();
194
+ await client.reset();
195
+ });
171
196
  ```
172
197
 
173
198
  ## Dark mode
@@ -200,19 +225,29 @@ export const client = createClient({
200
225
  ### Update color scheme at runtime
201
226
 
202
227
  ```ts
203
- client.configure({
204
- colorScheme: "system", // follows user's system preference
205
- });
228
+ type ThemePreference = "light" | "dark" | "system";
229
+
230
+ function onThemePreferenceChanged(themePreference: ThemePreference) {
231
+ client.configure({
232
+ colorScheme: themePreference,
233
+ });
234
+ }
206
235
  ```
207
236
 
208
237
  You can also switch runtime behavior back to host-driven auto-detection:
209
238
 
210
239
  ```ts
211
- client.configure({
212
- colorScheme: {
213
- autoDetectColorScheme: ["class", "data-theme"] // default
240
+ function onUseAppThemeChanged(useAppTheme: boolean) {
241
+ if (!useAppTheme) {
242
+ return;
214
243
  }
215
- });
244
+
245
+ client.configure({
246
+ colorScheme: {
247
+ autoDetectColorScheme: ["class", "data-theme"] // default
248
+ }
249
+ });
250
+ }
216
251
  ```
217
252
 
218
253
  ## Auth (optional)
@@ -221,30 +256,44 @@ You can run the SDK without auth. This is standard industry practice for client-
221
256
 
222
257
  Enable JWT validation in your workspace settings and pass a signed token from your app.
223
258
 
224
- ### Set auth token
259
+ ### Example: set, refresh, and clear auth token
225
260
 
226
261
  ```ts
227
- client.configure({
228
- auth: { jwt: { token: "YOUR_JWT" } },
229
- });
230
- ```
262
+ type AuthAdapter = {
263
+ isSignedIn: () => boolean;
264
+ getToken: () => Promise<string | null>;
265
+ onSessionChanged: (callback: () => void) => () => void;
266
+ };
231
267
 
232
- ### Refresh auth token
268
+ declare const auth: AuthAdapter;
233
269
 
234
- ```ts
235
- client.configure({
236
- auth: { jwt: { token: "YOUR_NEXT_JWT" } },
237
- });
238
- ```
270
+ const AUTH_REFRESH_INTERVAL_MS = 5 * 60 * 1000;
239
271
 
240
- ### Clear auth token
272
+ async function syncAuthToken() {
273
+ if (!auth.isSignedIn()) {
274
+ await client.configure({ auth: { jwt: null } });
275
+ return;
276
+ }
241
277
 
242
- ```ts
243
- client.configure({
244
- auth: { jwt: null },
278
+ const token = await auth.getToken();
279
+ if (!token) {
280
+ await client.configure({ auth: { jwt: null } });
281
+ return;
282
+ }
283
+
284
+ await client.configure({ auth: { jwt: { token } } });
285
+ }
286
+
287
+ syncAuthToken();
288
+ const unsubscribeSessionChanged = auth.onSessionChanged(() => {
289
+ syncAuthToken();
245
290
  });
291
+ const refreshTimer = window.setInterval(syncAuthToken, AUTH_REFRESH_INTERVAL_MS);
246
292
 
247
- // also cleared on client.reset()
293
+ window.addEventListener("beforeunload", () => {
294
+ unsubscribeSessionChanged();
295
+ window.clearInterval(refreshTimer);
296
+ });
248
297
  ```
249
298
 
250
299
  ## Privacy and consent (GDPR, CCPA, etc)
@@ -266,18 +315,64 @@ With `pending` consent set by default, all non-essential data scopes are conside
266
315
 
267
316
  ### Update consent at runtime
268
317
 
318
+ For example, sync consent from your cookie banner or CMP state:
319
+
269
320
  ```ts
270
- client.configure({
271
- consent: "granted",
321
+ function syncConsent(state: CookieConsentState) {
322
+ if (!state.hasAnswered) {
323
+ client.configure({ consent: "pending" });
324
+ return;
325
+ }
326
+
327
+ if (!state.analyticsEnabled) {
328
+ client.configure({ consent: "denied" });
329
+ return;
330
+ }
331
+
332
+ client.configure({
333
+ consent: ["analytics.measurement", "analytics.storage"],
334
+ });
335
+ }
336
+
337
+ window.addEventListener("cookie-consent-changed", (event) => {
338
+ syncConsent(event.detail);
272
339
  });
273
340
  ```
274
341
 
275
- You can also pass explicit granted scopes instead:
342
+ Or, when users save privacy settings, pass explicit granted scopes:
276
343
 
277
344
  ```ts
278
- client.configure({
279
- consent: ["analytics.measurement", "analytics.storage"],
280
- });
345
+ type PrivacySettings = {
346
+ analyticsEnabled: boolean;
347
+ personalizedAdsEnabled: boolean;
348
+ };
349
+
350
+ type GrantScope =
351
+ | "analytics.measurement"
352
+ | "analytics.storage"
353
+ | "ads.storage"
354
+ | "ads.user_data"
355
+ | "ads.personalization";
356
+
357
+ async function savePrivacySettings(settings: PrivacySettings) {
358
+ const grantedScopes: GrantScope[] = [];
359
+
360
+ if (settings.analyticsEnabled) {
361
+ grantedScopes.push("analytics.measurement", "analytics.storage");
362
+ }
363
+
364
+ if (settings.personalizedAdsEnabled) {
365
+ grantedScopes.push(
366
+ "ads.storage",
367
+ "ads.user_data",
368
+ "ads.personalization",
369
+ );
370
+ }
371
+
372
+ await client.configure({
373
+ consent: grantedScopes.length > 0 ? grantedScopes : "denied",
374
+ });
375
+ }
281
376
 
282
377
  ```
283
378
  `defaultConsent` supports:
@@ -296,7 +391,12 @@ client.configure({
296
391
  ### Open a flow
297
392
 
298
393
  ```ts
299
- client.open("YOUR_FLOW_ID");
394
+ const BUG_REPORT_FLOW_ID = "YOUR_FLOW_ID";
395
+ const reportBugButton = document.querySelector<HTMLButtonElement>("#report-bug-button");
396
+
397
+ reportBugButton?.addEventListener("click", () => {
398
+ client.open(BUG_REPORT_FLOW_ID);
399
+ });
300
400
  ```
301
401
 
302
402
  ### Prefetch and prerender
@@ -304,11 +404,20 @@ client.open("YOUR_FLOW_ID");
304
404
  Prefetching loads flow resources over the network, prerendering warms up the UI.
305
405
 
306
406
  ```ts
307
- const flowId = "YOUR_FLOW_ID";
308
- const button = document.querySelector<HTMLButtonElement>("#feedback-button");
407
+ const FEEDBACK_FLOW_ID = "YOUR_FLOW_ID";
408
+ const helpMenuFeedbackItem = document.querySelector<HTMLButtonElement>("#help-menu-feedback");
409
+
410
+ helpMenuFeedbackItem?.addEventListener("mouseenter", () => {
411
+ client.prefetch(FEEDBACK_FLOW_ID);
412
+ client.prerender(FEEDBACK_FLOW_ID);
413
+ });
309
414
 
310
- button?.addEventListener("mouseenter", () => {
311
- client.prerender(flowId);
415
+ helpMenuFeedbackItem?.addEventListener("focus", () => {
416
+ client.prerender(FEEDBACK_FLOW_ID);
417
+ });
418
+
419
+ helpMenuFeedbackItem?.addEventListener("click", () => {
420
+ client.open(FEEDBACK_FLOW_ID);
312
421
  });
313
422
  ```
314
423
 
package/dist/index.d.ts CHANGED
@@ -122,6 +122,18 @@ type OpenFlowOptions = {
122
122
  * - `hostOnly`: wait until a custom per-flow container is registered.
123
123
  */
124
124
  containerRequirement?: "any" | "hostOnly";
125
+ /**
126
+ * When `true`, the flow view does not show a close button.
127
+ * Useful for mobile or embedded contexts where the host handles dismissal (e.g. via a drawer or back gesture).
128
+ */
129
+ hideCloseButton?: boolean;
130
+ };
131
+ /** Options for prerendering a flow run. */
132
+ type PrerenderFlowOptions = {
133
+ /**
134
+ * When `true`, the prerendered view does not show a close button.
135
+ */
136
+ hideCloseButton?: boolean;
125
137
  };
126
138
  /** Options for subscribing to flow state updates. */
127
139
  type SubscribeFlowStateOptions = {
@@ -139,7 +151,7 @@ type FlowRun = {
139
151
  /** Prefetch the flow so it opens faster when you call `open()`. */
140
152
  prefetch: () => Promise<void>;
141
153
  /** Prerender the flow into a container (e.g. for a custom dialog). */
142
- prerender: () => Promise<void>;
154
+ prerender: (options?: PrerenderFlowOptions) => Promise<void>;
143
155
  /** Close this flow. */
144
156
  close: () => Promise<void>;
145
157
  /** Attach the flow UI to a DOM element, or `null` to detach. */
@@ -161,16 +173,8 @@ type Client = {
161
173
  getFlowState: () => FlowState;
162
174
  /** Subscribe to instance-level flow state updates (eg targeting-triggered opens). */
163
175
  subscribeFlowState: (callback: FlowStateCallback, options?: SubscribeFlowStateOptions) => () => void;
164
- /** Return an instance for the given flow (use its `open`, `prefetch`, `close`, `setContainer`, `getFlowState`, `subscribeFlowState`). */
176
+ /** Return a flow instance; call .open(), .prefetch(), .prerender(), .setContainer(), .close() on it. */
165
177
  flow: (flowId: string) => FlowRun;
166
- /** Open the flow and return its instance. */
167
- open: (flowId: string, options?: OpenFlowOptions) => Promise<FlowRun>;
168
- /** Prefetch the flow and return its instance. */
169
- prefetch: (flowId: string) => Promise<FlowRun>;
170
- /** Prerender the flow (e.g. on button hover).
171
- * Prerendering warms up the flow for instant display later.
172
- */
173
- prerender: (flowId: string) => Promise<FlowRun>;
174
178
  /** Close all open flows. */
175
179
  close: () => Promise<void>;
176
180
  /** Reset widget state and user identity. */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var L={INSTANCE_FLOW_STATE_CHANGED:"instance:flow:state-changed",INSTANCE_FLOW_STATE_CHANGED_INSTANCE:"instance:flow:state-changed:instance",INSTANCE_COMMAND_SETTLED:"instance:command:settled",INSTANCE_COMMAND_UNSUPPORTED:"instance:command:unsupported",INSTANCE_READY:"instance:ready",INSTANCE_BRIDGE_MOUNTED:"instance:bridge:mounted",INSTANCE_BRIDGE_UNMOUNTED:"instance:bridge:unmounted",INSTANCE_IFRAME_READY:"instance:iframe:ready",INSTANCE_ERROR:"instance:error",INSTANCE_APP_EVENT:"instance:app-event"},C={configure:"gx.command.configure.v1",open:"gx.command.open.v1",prefetch:"gx.command.prefetch.v1",prerender:"gx.command.prerender.v1",identify:"gx.command.identify.v1",close:"gx.command.close.v1",reset:"gx.command.reset.v1",setContainer:"gx.command.setContainer.v1",setDefaultContainerPolicy:"gx.command.setDefaultContainerPolicy.v1"},Hm=[C.configure,C.open,C.prefetch,C.prerender,C.identify,C.close,C.reset,C.setContainer,C.setDefaultContainerPolicy],$m=["gx.protocol.public.v1",...Hm],jm="__getuserfeedback_runtime",s="v1",H=(T)=>`getuserfeedback:${T}`;var v=()=>{if(typeof globalThis.crypto<"u"&&typeof globalThis.crypto.randomUUID==="function")return globalThis.crypto.randomUUID();return`req_${Date.now()}_${Math.random().toString(36).slice(2)}`};var r=(T)=>typeof T==="string"&&T.trim().length>0;function t(T){if(typeof T!=="object"||T===null)return!1;let O=T;return r(O.instanceId)&&typeof O.isOpen==="boolean"&&typeof O.isLoading==="boolean"&&(typeof O.width>"u"||typeof O.width==="number")&&(typeof O.height>"u"||typeof O.height==="number")&&r(O.flowHandleId)}function n(T){if(typeof T!=="object"||T===null)return!1;let O=T;return r(O.instanceId)&&typeof O.isOpen==="boolean"&&typeof O.isLoading==="boolean"&&(typeof O.width>"u"||typeof O.width==="number")&&(typeof O.height>"u"||typeof O.height==="number")}function zm(T){if(typeof T!=="object"||T===null)return!1;let O=T;if(!r(O.requestId)||typeof O.instanceId!=="string"&&O.instanceId!==null||typeof O.kind!=="string"||typeof O.ok!=="boolean")return!1;if(O.ok===!0)return!0;if(O.ok===!1&&typeof O.error==="object"&&O.error!==null)return typeof O.error.message==="string";return!1}var qm=30000,Um="COMMAND_SETTLEMENT_TIMEOUT";class q extends Error{code=Um;requestId;constructor(T){super(`Timed out waiting for command settlement: ${T}`);this.name="CommandSettlementTimeoutError",this.requestId=T}}var gm=(T)=>{if(typeof CustomEvent<"u")return T instanceof CustomEvent;return typeof T==="object"&&T!==null&&"detail"in T},h=(T)=>{let O=T.requestId.trim();if(!O)return Promise.reject(Error("requestId must be a non-empty string"));let G=T.windowRef??(typeof window>"u"?void 0:window);if(!G)return Promise.reject(Error("Cannot await command settlement without window"));let X=H(L.INSTANCE_COMMAND_SETTLED),M=Math.max(0,T.timeoutMs??qm);return new Promise((Y,x)=>{let K=()=>{if(typeof G.removeEventListener==="function")G.removeEventListener(X,F)},g=setTimeout(()=>{K(),x(new q(O))},M),F=(V)=>{if(!gm(V))return;let y=V.detail;if(!zm(y)||y.requestId!==O)return;let B=y;if(K(),clearTimeout(g),B.ok){Y(B);return}x(Error(B.error.message??`Command ${B.kind} failed without an error payload`))};G.addEventListener(X,F)})};var a=(T)=>{return async(O,G)=>{let X=v(),M=Am(G?.idempotencyKey);T({version:"1",requestId:X,idempotencyKey:M??X,command:O}),await h({requestId:X})}},Am=(T)=>{if(T===void 0)return null;let O=T.trim();if(!O)throw Error("idempotencyKey must be a non-empty string");return O};var Gm="0.1.0".trim(),l=Gm.length>0?Gm:"0.0.0-local";var d={isOpen:!1,isLoading:!1,width:void 0,height:void 0},Jm=new Map,Qm=(T)=>T,wm=()=>{if(typeof globalThis.crypto<"u"&&typeof globalThis.crypto.randomUUID==="function")return Qm(globalThis.crypto.randomUUID());return Qm(`handle_${Date.now()}_${Math.random().toString(36).slice(2)}`)},bm=()=>{if(typeof globalThis.crypto<"u"&&typeof globalThis.crypto.randomUUID==="function")return globalThis.crypto.randomUUID();return`sdk-${Date.now()}-${Math.random().toString(16).slice(2)}`},rm=(T,O)=>{if(typeof T==="string")return{kind:"identify",userId:T,traits:O};return{kind:"identify",traits:T}},pm=120,Xm=120,cm=(T)=>T.apiKey,um=()=>typeof window>"u"?globalThis:window,Im=()=>{let T=um(),O=Jm.get(T);if(O)return O;let G=new Map;return Jm.set(T,G),G},om=({apiKey:T,_cdn:O="https://cdn.getuserfeedback.com",disableAutoLoad:G=!1,colorScheme:X,disableTelemetry:M=!1,enableDebug:Y=!1,defaultConsent:x})=>{let K=cm({apiKey:T,_cdn:O,disableAutoLoad:G,colorScheme:X,disableTelemetry:M,enableDebug:Y,defaultConsent:x}),g=Im(),F=g.get(K);if(F){if(F.updateOptions({apiKey:T,_cdn:O,disableAutoLoad:G,colorScheme:X,disableTelemetry:M,enableDebug:Y,defaultConsent:x}),!G)F.client.load();return F.client}let V=O,y=(m)=>{},B=l,Zm="v1",p=bm(),e={loader:"sdk",clientName:"@getuserfeedback/sdk",clientVersion:B,transport:"snippet"},Cm=[...$m],A=x,Mm=()=>({apiKey:T,clientMeta:e,capabilities:[...Cm],...X!==void 0&&{colorScheme:X},...M!==void 0&&{disableTelemetry:M},...Y!==void 0&&{enableDebug:Y},...A!==void 0&&{defaultConsent:A}}),w=!1,D=null,k=G,c=new Map,mm=d,R=(m)=>({isOpen:m.isOpen,isLoading:m.isLoading,width:m.width,height:m.height}),Em=(m)=>{let E=c.get(m);if(!E)return R(d);return R(E)},Tm=(m,E)=>{c.set(m,R(E))},Om=()=>R(mm),Vm=(m)=>{mm=R(m)},ym=(m)=>{if(!c.has(m))Tm(m,d)},_=()=>w,f=(m)=>{if(typeof window>"u")return;if(!window.__getuserfeedback_queue)window.__getuserfeedback_queue=[];let E={...m,instanceId:m.instanceId??p,clientMeta:m.clientMeta??e};window.__getuserfeedback_queue.push(E)},u=(m)=>{let E=m??v();return f({version:"1",instanceId:p,requestId:E,idempotencyKey:E,command:{kind:"init",opts:Mm()}}),E},Dm=(m,E)=>{let $=v();f({version:"1",requestId:$,idempotencyKey:$,command:{kind:"setContainer",flowHandleId:m,container:E}})},I=(m)=>{let E=v();f({version:"1",requestId:E,idempotencyKey:E,command:{kind:"setDefaultContainerPolicy",policy:m}})},P=(m)=>{return m.catch((E)=>{throw y(E),E})},Pm=()=>{if(typeof window>"u")return;if(!_()){if(k)throw Error("Widget not loaded. Call client.load() first.");o()}},Nm=a((m)=>f(m)),N=async(m)=>{return Pm(),Nm(m)},Sm=(m)=>{if(!_())return;let E=v();f({version:"1",requestId:E,idempotencyKey:E,command:{kind:"configure",opts:m}})},vm=(m)=>{if(k=m.disableAutoLoad??k,A=m.defaultConsent??A,m._cdn!==void 0&&m._cdn!==V)if(_()||D!==null){let E=Error("_cdn cannot be changed after widget init; keeping original");y(E)}else V=m._cdn;if(Ym(m),!k&&!_())o()},Ym=(m)=>{if(!_())return;let E={};if(m.colorScheme!==void 0)E.colorScheme=m.colorScheme;Sm(E)},o=()=>{if(typeof window>"u")return;if(_()||D)return;let m=()=>{let W=V.endsWith("/")?V:`${V}/`,j=`loader/${Zm}/${encodeURIComponent(T)}/loader.js`,J=new URL(j,W).toString();if(!document.querySelector(`link[href="${J}"][rel="preload"]`)){let Q=document.createElement("link");Q.rel="preload",Q.as="script",Q.href=J,document.head.appendChild(Q)}let U=document.createElement("script");if(U.src=J,U.async=!0,U.dataset)U.dataset.disableAutoRegister="true";else if(typeof U.setAttribute==="function")U.setAttribute("data-disable-auto-register","true");document.head.appendChild(U)},E=window[jm];if(E?.alive){let W=E.protocolVersion;if(W!==s)throw Error(`Incompatible loader runtime protocol: expected ${s}, received ${W??"unknown"}`);u(),w=!0;return}if(!Array.isArray(window.__getuserfeedback_queue)){let W=u();m(),w=!0;let j;j=h({requestId:W,timeoutMs:Xm}).then(()=>{}).catch((U)=>{y(U)}).finally(()=>{if(D===j)D=null}),D=j;return}w=!0;let z;z=(async()=>{let W=v();u(W);try{await h({requestId:W,timeoutMs:pm});return}catch(j){if(j instanceof q){m(),await h({requestId:W,timeoutMs:Xm});return}throw j}})().catch((W)=>{y(W)}).finally(()=>{if(D===z)D=null}),D=z},Fm=(m,E)=>{Dm(m,E)},Rm=(m)=>{if(m===null){I({kind:"floating"});return}I({kind:"hostContainer",host:m,sharing:"shared"})},_m=(m,E,$)=>{if($?.emitInitial??!0)E(Em(m));if(typeof window>"u")return()=>{};let z=H(L.INSTANCE_FLOW_STATE_CHANGED),S=(Q)=>{let Z=Q.detail;if(!t(Z)||Z.flowHandleId!==m)return;let Wm={isOpen:Z.isOpen,isLoading:Z.isLoading,width:Z.width,height:Z.height};Tm(m,Wm),E(R(Wm))},W=!1,j=$?.signal,J=null,U=()=>{if(W)return;if(W=!0,window.removeEventListener(z,S),j&&J)j.removeEventListener("abort",J)};if(window.addEventListener(z,S),j){if(J=()=>{U()},j.aborted)return U(),U;j.addEventListener("abort",J,{once:!0})}return U},hm=(m,E)=>{if(E?.emitInitial??!0)m(Om());if(typeof window>"u")return()=>{};let $=H(L.INSTANCE_FLOW_STATE_CHANGED_INSTANCE),z=(U)=>{let Q=U.detail;if(!n(Q)||Q.instanceId!==p)return;let Z={isOpen:Q.isOpen,isLoading:Q.isLoading,width:Q.width,height:Q.height};Vm(Z),m(R(Z))},S=!1,W=E?.signal,j=null,J=()=>{if(S)return;if(S=!0,window.removeEventListener($,z),W&&j)W.removeEventListener("abort",j)};if(window.addEventListener($,z),W){if(j=()=>{J()},W.aborted)return J(),J;W.addEventListener("abort",j,{once:!0})}return J},b=(m)=>{let E=m;if(!E.trim())throw Error("flowId must be a non-empty string");let $=wm();return ym($),{flowId:E,open:(z)=>P(N({kind:"open",flowId:E,flowHandleId:$,...z?.containerRequirement?{containerRequirement:z.containerRequirement}:{}})),prefetch:()=>P(N({kind:"prefetch",flowId:E})),prerender:()=>P(N({kind:"prerender",flowId:E,flowHandleId:$})),close:()=>P(N({kind:"close",flowHandleId:$})),setContainer:(z)=>{Fm($,z)},getFlowState:()=>Em($),subscribeFlowState:(z,S)=>_m($,z,S)}},xm=(m)=>b(m),Bm=async(m,E)=>{let $=b(m);return await $.open(E),$},Km=async(m)=>{let E=b(m);return await E.prefetch(),E},km=()=>{if(typeof window>"u")return Promise.resolve();return P(N({kind:"close"}))},fm=()=>{if(typeof window>"u")return Promise.resolve();return P(N({kind:"reset"}))};function Lm(m,E){if(typeof window>"u")return Promise.resolve();return P(N(rm(m,E)))}let i={load:o,setDefaultContainerPolicy:(m)=>{I(m)},setContainer:(m)=>{Rm(m)},getFlowState:()=>Om(),subscribeFlowState:(m,E)=>hm(m,E),flow:xm,open:Bm,prefetch:Km,prerender:async(m)=>{let E=b(m);return await E.prerender(),E},close:km,reset:fm,configure:(m)=>{if(typeof window>"u")return Promise.resolve();if(!_())return Promise.resolve();return P(N({kind:"configure",opts:m}))},identify:Lm};if(g.set(K,{client:i,updateOptions:vm}),!k)i.load();return i};export{om as createClient,l as SDK_VERSION};
1
+ var w={INSTANCE_FLOW_STATE_CHANGED:"instance:flow:state-changed",INSTANCE_FLOW_STATE_CHANGED_INSTANCE:"instance:flow:state-changed:instance",INSTANCE_COMMAND_SETTLED:"instance:command:settled",INSTANCE_COMMAND_UNSUPPORTED:"instance:command:unsupported",INSTANCE_READY:"instance:ready",INSTANCE_BRIDGE_MOUNTED:"instance:bridge:mounted",INSTANCE_BRIDGE_UNMOUNTED:"instance:bridge:unmounted",INSTANCE_IFRAME_READY:"instance:iframe:ready",INSTANCE_ERROR:"instance:error",INSTANCE_APP_EVENT:"instance:app-event"},C={configure:"gx.command.configure.v1",open:"gx.command.open.v1",prefetch:"gx.command.prefetch.v1",prerender:"gx.command.prerender.v1",identify:"gx.command.identify.v1",close:"gx.command.close.v1",reset:"gx.command.reset.v1",setContainer:"gx.command.setContainer.v1",setDefaultContainerPolicy:"gx.command.setDefaultContainerPolicy.v1"},wm=[C.configure,C.open,C.prefetch,C.prerender,C.identify,C.close,C.reset,C.setContainer,C.setDefaultContainerPolicy],Um=["gx.protocol.public.v1",...wm],$m="__getuserfeedback_runtime",i="v1",q=(E)=>`getuserfeedback:${E}`;function Wm(E){if(typeof globalThis.crypto<"u"&&typeof globalThis.crypto.randomUUID==="function")return globalThis.crypto.randomUUID();let T=`${Date.now()}_${Math.random().toString(36).slice(2)}`;return E?`${E}_${T}`:T}var x=()=>Wm("req");var A=(E)=>typeof E==="string"&&E.trim().length>0;function s(E){if(typeof E!=="object"||E===null)return!1;let T=E;return A(T.instanceId)&&typeof T.isOpen==="boolean"&&typeof T.isLoading==="boolean"&&(typeof T.width>"u"||typeof T.width==="number")&&(typeof T.height>"u"||typeof T.height==="number")&&A(T.flowHandleId)}function t(E){if(typeof E!=="object"||E===null)return!1;let T=E;return A(T.instanceId)&&typeof T.isOpen==="boolean"&&typeof T.isLoading==="boolean"&&(typeof T.width>"u"||typeof T.width==="number")&&(typeof T.height>"u"||typeof T.height==="number")}function jm(E){if(typeof E!=="object"||E===null)return!1;let T=E;if(!A(T.requestId)||typeof T.instanceId!=="string"&&T.instanceId!==null||typeof T.kind!=="string"||typeof T.ok!=="boolean")return!1;if(T.ok===!0)return!0;if(T.ok===!1&&typeof T.error==="object"&&T.error!==null)return typeof T.error.message==="string";return!1}var qm=30000,zm="COMMAND_SETTLEMENT_TIMEOUT";class L extends Error{code=zm;requestId;constructor(E){super(`Timed out waiting for command settlement: ${E}`);this.name="CommandSettlementTimeoutError",this.requestId=E}}var Lm=(E)=>{if(typeof CustomEvent<"u")return E instanceof CustomEvent;return typeof E==="object"&&E!==null&&"detail"in E},h=(E)=>{let T=E.requestId.trim();if(!T)return Promise.reject(Error("requestId must be a non-empty string"));let G=E.windowRef??(typeof window>"u"?void 0:window);if(!G)return Promise.reject(Error("Cannot await command settlement without window"));let X=q(w.INSTANCE_COMMAND_SETTLED),M=Math.max(0,E.timeoutMs??qm);return new Promise((P,Y)=>{let B=()=>{if(typeof G.removeEventListener==="function")G.removeEventListener(X,v)},H=setTimeout(()=>{B(),Y(new L(T))},M),v=(V)=>{if(!Lm(V))return;let y=V.detail;if(!jm(y)||y.requestId!==T)return;let _=y;if(B(),clearTimeout(H),_.ok){P(_);return}Y(Error(_.error.message??`Command ${_.kind} failed without an error payload`))};G.addEventListener(X,v)})};var n=(E)=>{return async(T,G)=>{let X=x(),M=Hm(G?.idempotencyKey);E({version:"1",requestId:X,idempotencyKey:M??X,command:T}),await h({requestId:X})}},Hm=(E)=>{if(E===void 0)return null;let T=E.trim();if(!T)throw Error("idempotencyKey must be a non-empty string");return T};var Gm="0.3.0".trim(),a=Gm.length>0?Gm:"0.0.0-local";var l={isOpen:!1,isLoading:!1,width:void 0,height:void 0},Jm=new Map,Qm=(E)=>E,gm=()=>{if(typeof globalThis.crypto<"u"&&typeof globalThis.crypto.randomUUID==="function")return Qm(globalThis.crypto.randomUUID());return Qm(`handle_${Date.now()}_${Math.random().toString(36).slice(2)}`)},rm=()=>{if(typeof globalThis.crypto<"u"&&typeof globalThis.crypto.randomUUID==="function")return globalThis.crypto.randomUUID();return`sdk-${Date.now()}-${Math.random().toString(16).slice(2)}`},Am=(E,T)=>{if(typeof E==="string")return{kind:"identify",userId:E,traits:T};return{kind:"identify",traits:E}},bm=120,Xm=120,pm=(E)=>E.apiKey,cm=()=>typeof window>"u"?globalThis:window,um=()=>{let E=cm(),T=Jm.get(E);if(T)return T;let G=new Map;return Jm.set(E,G),G},om=({apiKey:E,_cdn:T="https://cdn.getuserfeedback.com",disableAutoLoad:G=!1,colorScheme:X,disableTelemetry:M=!1,enableDebug:P=!1,defaultConsent:Y})=>{let B=pm({apiKey:E,_cdn:T,disableAutoLoad:G,colorScheme:X,disableTelemetry:M,enableDebug:P,defaultConsent:Y}),H=um(),v=H.get(B);if(v){if(v.updateOptions({apiKey:E,_cdn:T,disableAutoLoad:G,colorScheme:X,disableTelemetry:M,enableDebug:P,defaultConsent:Y}),!G)v.client.load();return v.client}let V=T,y=(m)=>{},_=a,Zm="v1",b=rm(),d={loader:"sdk",clientName:"@getuserfeedback/sdk",clientVersion:_,transport:"snippet"},Cm=[...Um],g=Y,Mm=()=>({apiKey:E,clientMeta:d,capabilities:[...Cm],...X!==void 0&&{colorScheme:X},...M!==void 0&&{disableTelemetry:M},...P!==void 0&&{enableDebug:P},...g!==void 0&&{defaultConsent:g}}),r=!1,D=null,k=G,p=new Map,e=l,N=(m)=>({isOpen:m.isOpen,isLoading:m.isLoading,width:m.width,height:m.height}),mm=(m)=>{let O=p.get(m);if(!O)return N(l);return N(O)},Em=(m,O)=>{p.set(m,N(O))},Tm=()=>N(e),Vm=(m)=>{e=N(m)},ym=(m)=>{if(!p.has(m))Em(m,l)},S=()=>r,K=(m)=>{if(typeof window>"u")return;if(!window.__getuserfeedback_queue)window.__getuserfeedback_queue=[];let O={...m,instanceId:m.instanceId??b,clientMeta:m.clientMeta??d};window.__getuserfeedback_queue.push(O)},c=(m)=>{let O=m??x();return K({version:"1",instanceId:b,requestId:O,idempotencyKey:O,command:{kind:"init",opts:Mm()}}),O},Dm=(m,O)=>{let j=x();K({version:"1",requestId:j,idempotencyKey:j,command:{kind:"setContainer",flowHandleId:m,container:O}})},u=(m)=>{let O=x();K({version:"1",requestId:O,idempotencyKey:O,command:{kind:"setDefaultContainerPolicy",policy:m}})},f=(m)=>{return m.catch((O)=>{throw y(O),O})},fm=()=>{if(typeof window>"u")return;if(!S()){if(k)throw Error("Widget not loaded. Call client.load() first.");o()}},Fm=n((m)=>K(m)),F=async(m)=>{return fm(),Fm(m)},Rm=(m)=>{if(!S())return;let O=x();K({version:"1",requestId:O,idempotencyKey:O,command:{kind:"configure",opts:m}})},xm=(m)=>{if(k=m.disableAutoLoad??k,g=m.defaultConsent??g,m._cdn!==void 0&&m._cdn!==V)if(S()||D!==null){let O=Error("_cdn cannot be changed after widget init; keeping original");y(O)}else V=m._cdn;if(Pm(m),!k&&!S())o()},Pm=(m)=>{if(!S())return;let O={};if(m.colorScheme!==void 0)O.colorScheme=m.colorScheme;Rm(O)},o=()=>{if(typeof window>"u")return;if(S()||D)return;let m=()=>{let U=V.endsWith("/")?V:`${V}/`,$=`loader/${Zm}/${encodeURIComponent(E)}/loader.js`,J=new URL($,U).toString();if(!document.querySelector(`link[href="${J}"][rel="preload"]`)){let Q=document.createElement("link");Q.rel="preload",Q.as="script",Q.href=J,document.head.appendChild(Q)}let z=document.createElement("script");if(z.src=J,z.async=!0,z.dataset)z.dataset.disableAutoRegister="true";else if(typeof z.setAttribute==="function")z.setAttribute("data-disable-auto-register","true");document.head.appendChild(z)},O=window[$m];if(O?.alive){let U=O.protocolVersion;if(U!==i)throw Error(`Incompatible loader runtime protocol: expected ${i}, received ${U??"unknown"}`);c(),r=!0;return}if(!Array.isArray(window.__getuserfeedback_queue)){let U=c();m(),r=!0;let $;$=h({requestId:U,timeoutMs:Xm}).then(()=>{}).catch((z)=>{y(z)}).finally(()=>{if(D===$)D=null}),D=$;return}r=!0;let W;W=(async()=>{let U=x();c(U);try{await h({requestId:U,timeoutMs:bm});return}catch($){if($ instanceof L){m(),await h({requestId:U,timeoutMs:Xm});return}throw $}})().catch((U)=>{y(U)}).finally(()=>{if(D===W)D=null}),D=W},vm=(m,O)=>{Dm(m,O)},Nm=(m)=>{if(m===null){u({kind:"floating"});return}u({kind:"hostContainer",host:m,sharing:"shared"})},Sm=(m,O,j)=>{if(j?.emitInitial??!0)O(mm(m));if(typeof window>"u")return()=>{};let W=q(w.INSTANCE_FLOW_STATE_CHANGED),R=(Q)=>{let Z=Q.detail;if(!s(Z)||Z.flowHandleId!==m)return;let Om={isOpen:Z.isOpen,isLoading:Z.isLoading,width:Z.width,height:Z.height};Em(m,Om),O(N(Om))},U=!1,$=j?.signal,J=null,z=()=>{if(U)return;if(U=!0,window.removeEventListener(W,R),$&&J)$.removeEventListener("abort",J)};if(window.addEventListener(W,R),$){if(J=()=>{z()},$.aborted)return z(),z;$.addEventListener("abort",J,{once:!0})}return z},hm=(m,O)=>{if(O?.emitInitial??!0)m(Tm());if(typeof window>"u")return()=>{};let j=q(w.INSTANCE_FLOW_STATE_CHANGED_INSTANCE),W=(z)=>{let Q=z.detail;if(!t(Q)||Q.instanceId!==b)return;let Z={isOpen:Q.isOpen,isLoading:Q.isLoading,width:Q.width,height:Q.height};Vm(Z),m(N(Z))},R=!1,U=O?.signal,$=null,J=()=>{if(R)return;if(R=!0,window.removeEventListener(j,W),U&&$)U.removeEventListener("abort",$)};if(window.addEventListener(j,W),U){if($=()=>{J()},U.aborted)return J(),J;U.addEventListener("abort",$,{once:!0})}return J},Ym=(m)=>{let O=m;if(!O.trim())throw Error("flowId must be a non-empty string");let j=gm();return ym(j),{flowId:O,open:(W)=>{return f(F({kind:"open",flowId:O,flowHandleId:j,containerRequirement:W?.containerRequirement,hideCloseButton:W?.hideCloseButton}))},prefetch:()=>f(F({kind:"prefetch",flowId:O})),prerender:(W)=>f(F({kind:"prerender",flowId:O,flowHandleId:j,hideCloseButton:W?.hideCloseButton})),close:()=>f(F({kind:"close",flowHandleId:j})),setContainer:(W)=>{vm(j,W)},getFlowState:()=>mm(j),subscribeFlowState:(W,R)=>Sm(j,W,R)}},_m=(m)=>Ym(m),Bm=()=>{if(typeof window>"u")return Promise.resolve();return f(F({kind:"close"}))},km=()=>{if(typeof window>"u")return Promise.resolve();return f(F({kind:"reset"}))};function Km(m,O){if(typeof window>"u")return Promise.resolve();return f(F(Am(m,O)))}let I={load:o,setDefaultContainerPolicy:(m)=>{u(m)},setContainer:(m)=>{Nm(m)},getFlowState:()=>Tm(),subscribeFlowState:(m,O)=>hm(m,O),flow:_m,close:Bm,reset:km,configure:(m)=>{if(typeof window>"u")return Promise.resolve();if(!S())return Promise.resolve();return f(F({kind:"configure",opts:m}))},identify:Km};if(H.set(B,{client:I,updateOptions:xm}),!k)I.load();return I};export{om as createClient,a as SDK_VERSION};
2
2
 
3
- //# debugId=5F212816B6682BA864756E2164756E21
3
+ //# debugId=16106A19F80245A064756E2164756E21
4
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../shared/src/constants.ts", "../../shared/src/request-id.ts", "../../shared/src/protocol/host-event-contract.ts", "../../shared/src/protocol/command-settlement.ts", "../../shared/src/protocol/command-dispatch.ts", "../src/version.ts", "../src/client.ts"],
3
+ "sources": ["../../shared/src/constants.ts", "../../shared/src/unique-id.ts", "../../shared/src/request-id.ts", "../../shared/src/protocol/host-event-contract.ts", "../../shared/src/protocol/command-settlement.ts", "../../shared/src/protocol/command-dispatch.ts", "../src/version.ts", "../src/client.ts"],
4
4
  "sourcesContent": [
5
5
  "import type { PublicCommandPayload } from \"./protocol/sdk-types\";\n\n// TODO: review this file and remove unused events\n\nexport const TELEMETRY_EVENTS = {\n\tINSTANCE_READY: \"instance_ready\",\n\tVIEW_DISPLAYED: \"view_displayed\",\n\tVIEW_CLOSED: \"view_closed\",\n\tFLOW_DISPLAYED: \"flow_displayed\",\n\tFLOW_CLOSED: \"flow_closed\",\n} as const;\n\nexport type TelemetryEventName =\n\t(typeof TELEMETRY_EVENTS)[keyof typeof TELEMETRY_EVENTS];\n\n// Data attribute used to anchor widget styles & root element. Shared so build\n// scripts, runtime code and tests stay in sync.\nexport const WIDGET_SELECTOR = \"[data-gx-widget]\" as const;\n\nexport const PARENT_ORIGIN_PARAM = \"gx_parent_origin\" as const;\n\nexport const WIDGET_EVENTS = {\n\tREADY: \"gx:ready\",\n\tBRIDGE_MOUNTED: \"gx:bridge-mounted\",\n\tBRIDGE_UNMOUNTED: \"gx:bridge-unmounted\",\n\tIFRAME_READY: \"gx:iframe-ready\",\n} as const;\n\nexport type WidgetEventName =\n\t(typeof WIDGET_EVENTS)[keyof typeof WIDGET_EVENTS];\n\n// Host event names (DOM events emitted by widget for external consumption)\n// Uses prefix \"getuserfeedback:\" for namespacing\nexport const HOST_EVENT_PREFIX = \"getuserfeedback:\" as const;\n\nexport const HOST_EVENT_KEYS = {\n\tINSTANCE_FLOW_STATE_CHANGED: \"instance:flow:state-changed\",\n\tINSTANCE_FLOW_STATE_CHANGED_INSTANCE: \"instance:flow:state-changed:instance\",\n\tINSTANCE_COMMAND_SETTLED: \"instance:command:settled\",\n\tINSTANCE_COMMAND_UNSUPPORTED: \"instance:command:unsupported\",\n\tINSTANCE_READY: \"instance:ready\",\n\tINSTANCE_BRIDGE_MOUNTED: \"instance:bridge:mounted\",\n\tINSTANCE_BRIDGE_UNMOUNTED: \"instance:bridge:unmounted\",\n\tINSTANCE_IFRAME_READY: \"instance:iframe:ready\",\n\tINSTANCE_ERROR: \"instance:error\",\n\tINSTANCE_APP_EVENT: \"instance:app-event\",\n} as const;\n\ntype SdkCapabilityCommandKind = Exclude<PublicCommandPayload[\"kind\"], \"init\">;\n\nconst SDK_COMMAND_CAPABILITY_BY_KIND = {\n\tconfigure: \"gx.command.configure.v1\",\n\topen: \"gx.command.open.v1\",\n\tprefetch: \"gx.command.prefetch.v1\",\n\tprerender: \"gx.command.prerender.v1\",\n\tidentify: \"gx.command.identify.v1\",\n\tclose: \"gx.command.close.v1\",\n\treset: \"gx.command.reset.v1\",\n\tsetContainer: \"gx.command.setContainer.v1\",\n\tsetDefaultContainerPolicy: \"gx.command.setDefaultContainerPolicy.v1\",\n} as const satisfies Record<\n\tSdkCapabilityCommandKind,\n\t`gx.command.${string}.v${number}`\n>;\n\nconst SDK_COMMAND_CAPABILITIES = [\n\tSDK_COMMAND_CAPABILITY_BY_KIND.configure,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.open,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.prefetch,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.prerender,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.identify,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.close,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.reset,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.setContainer,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.setDefaultContainerPolicy,\n] as const;\n\ntype SdkCommandCapability =\n\t(typeof SDK_COMMAND_CAPABILITY_BY_KIND)[keyof typeof SDK_COMMAND_CAPABILITY_BY_KIND];\ntype _AssertAllCommandCapabilitiesAreAnnounced =\n\tExclude<\n\t\tSdkCommandCapability,\n\t\t(typeof SDK_COMMAND_CAPABILITIES)[number]\n\t> extends never\n\t\t? true\n\t\t: never;\ntype _AssertNoUnknownCommandCapabilities =\n\tExclude<\n\t\t(typeof SDK_COMMAND_CAPABILITIES)[number],\n\t\tSdkCommandCapability\n\t> extends never\n\t\t? true\n\t\t: never;\n\n/**\n * Stable capability tokens announced by the browser SDK during init.\n * These are versioned and namespaced to support forward-compatible negotiation.\n */\nexport const SDK_PROTOCOL_CAPABILITIES = [\n\t\"gx.protocol.public.v1\",\n\t...SDK_COMMAND_CAPABILITIES,\n] as const;\n\nexport type SdkProtocolCapability = (typeof SDK_PROTOCOL_CAPABILITIES)[number];\n\nexport const LOADER_RUNTIME_GLOBAL_KEY = \"__getuserfeedback_runtime\" as const;\nexport const LOADER_RUNTIME_PROTOCOL_VERSION = \"v1\" as const;\n\n// Helper to construct full event name with prefix\nexport const toHostEventName = (key: string): string =>\n\t`${HOST_EVENT_PREFIX}${key}`;\n",
6
- "export const createCommandRequestId = (): string => {\n\tif (\n\t\ttypeof globalThis.crypto !== \"undefined\" &&\n\t\ttypeof globalThis.crypto.randomUUID === \"function\"\n\t) {\n\t\treturn globalThis.crypto.randomUUID();\n\t}\n\treturn `req_${Date.now()}_${Math.random().toString(36).slice(2)}`;\n};\n",
6
+ "/**\n * Generates a unique string ID. Uses crypto.randomUUID when available,\n * otherwise falls back to a timestamp + random string.\n *\n * @param prefix - Optional prefix for the fallback format (e.g. \"req\", \"err\").\n * Only affects fallback; UUIDs have no prefix.\n */\nexport function createUniqueId(prefix?: string): string {\n\tif (\n\t\ttypeof globalThis.crypto !== \"undefined\" &&\n\t\ttypeof globalThis.crypto.randomUUID === \"function\"\n\t) {\n\t\treturn globalThis.crypto.randomUUID();\n\t}\n\tconst fallback = `${Date.now()}_${Math.random().toString(36).slice(2)}`;\n\treturn prefix ? `${prefix}_${fallback}` : fallback;\n}\n",
7
+ "import { createUniqueId } from \"./unique-id\";\n\nexport const createCommandRequestId = (): string => createUniqueId(\"req\");\n",
7
8
  "/**\n * Types and type guards for flow state and lifecycle events.\n */\n\n/** Current state of the flow: whether it is open, loading, and its dimensions (if known). */\nexport interface FlowState {\n\t/** True when the flow is visible. */\n\tisOpen: boolean;\n\t/** True when the flow is loading (e.g. fetching or rendering). */\n\tisLoading: boolean;\n\t/** Flow width in pixels when known. */\n\twidth?: number;\n\t/** Flow height in pixels when known. */\n\theight?: number;\n}\n\nexport interface FlowStateChangedDetail extends FlowState {\n\tinstanceId: string;\n\tflowHandleId: string;\n}\n\nexport interface InstanceFlowStateChangedDetail extends FlowState {\n\tinstanceId: string;\n}\n\nconst isNonEmptyString = (v: unknown): v is string =>\n\ttypeof v === \"string\" && v.trim().length > 0;\n\nexport function isFlowStateChangedDetail(\n\tdetail: unknown,\n): detail is FlowStateChangedDetail {\n\tif (typeof detail !== \"object\" || detail === null) return false;\n\tconst d = detail as Record<string, unknown>;\n\treturn (\n\t\tisNonEmptyString(d.instanceId) &&\n\t\ttypeof d.isOpen === \"boolean\" &&\n\t\ttypeof d.isLoading === \"boolean\" &&\n\t\t(typeof d.width === \"undefined\" || typeof d.width === \"number\") &&\n\t\t(typeof d.height === \"undefined\" || typeof d.height === \"number\") &&\n\t\tisNonEmptyString(d.flowHandleId)\n\t);\n}\n\nexport function isInstanceFlowStateChangedDetail(\n\tdetail: unknown,\n): detail is InstanceFlowStateChangedDetail {\n\tif (typeof detail !== \"object\" || detail === null) return false;\n\tconst d = detail as Record<string, unknown>;\n\treturn (\n\t\tisNonEmptyString(d.instanceId) &&\n\t\ttypeof d.isOpen === \"boolean\" &&\n\t\ttypeof d.isLoading === \"boolean\" &&\n\t\t(typeof d.width === \"undefined\" || typeof d.width === \"number\") &&\n\t\t(typeof d.height === \"undefined\" || typeof d.height === \"number\")\n\t);\n}\n\nexport interface CommandSettledSuccessDetail {\n\trequestId: string;\n\tinstanceId: string | null;\n\tkind: string;\n\tok: true;\n\tresult?: unknown;\n}\n\nexport interface CommandSettledFailureDetail {\n\trequestId: string;\n\tinstanceId: string | null;\n\tkind: string;\n\tok: false;\n\terror: { message: string; code?: string };\n}\n\nexport type CommandSettledDetail =\n\t| CommandSettledSuccessDetail\n\t| CommandSettledFailureDetail;\n\nexport function isCommandSettledDetail(\n\tdetail: unknown,\n): detail is CommandSettledDetail {\n\tif (typeof detail !== \"object\" || detail === null) return false;\n\tconst d = detail as Record<string, unknown>;\n\tif (\n\t\t!isNonEmptyString(d.requestId) ||\n\t\t(typeof d.instanceId !== \"string\" && d.instanceId !== null) ||\n\t\ttypeof d.kind !== \"string\" ||\n\t\ttypeof d.ok !== \"boolean\"\n\t) {\n\t\treturn false;\n\t}\n\tif (d.ok === true) {\n\t\treturn true;\n\t}\n\tif (d.ok === false && typeof d.error === \"object\" && d.error !== null) {\n\t\tconst err = d.error as Record<string, unknown>;\n\t\treturn typeof err.message === \"string\";\n\t}\n\treturn false;\n}\n",
8
9
  "import { HOST_EVENT_KEYS, toHostEventName } from \"../constants\";\nimport {\n\ttype CommandSettledDetail,\n\tisCommandSettledDetail,\n} from \"./host-event-contract\";\n\ntype WaitForCommandSettlementInput = {\n\trequestId: string;\n\twindowRef?: Window;\n\ttimeoutMs?: number;\n};\n\nconst DEFAULT_SETTLEMENT_TIMEOUT_MS = 30_000;\nexport const COMMAND_SETTLEMENT_TIMEOUT_CODE =\n\t\"COMMAND_SETTLEMENT_TIMEOUT\" as const;\n\nexport class CommandSettlementTimeoutError extends Error {\n\treadonly code = COMMAND_SETTLEMENT_TIMEOUT_CODE;\n\treadonly requestId: string;\n\n\tconstructor(requestId: string) {\n\t\tsuper(`Timed out waiting for command settlement: ${requestId}`);\n\t\tthis.name = \"CommandSettlementTimeoutError\";\n\t\tthis.requestId = requestId;\n\t}\n}\n\nconst eventHasDetail = (event: Event): event is Event & { detail: unknown } => {\n\tif (typeof CustomEvent !== \"undefined\") {\n\t\treturn event instanceof CustomEvent;\n\t}\n\treturn typeof event === \"object\" && event !== null && \"detail\" in event;\n};\n\nexport const waitForCommandSettlement = (\n\tinput: WaitForCommandSettlementInput,\n): Promise<CommandSettledDetail> => {\n\tconst requestId = input.requestId.trim();\n\tif (!requestId) {\n\t\treturn Promise.reject(new Error(\"requestId must be a non-empty string\"));\n\t}\n\tconst targetWindow =\n\t\tinput.windowRef ?? (typeof window === \"undefined\" ? undefined : window);\n\tif (!targetWindow) {\n\t\treturn Promise.reject(\n\t\t\tnew Error(\"Cannot await command settlement without window\"),\n\t\t);\n\t}\n\tconst eventName = toHostEventName(HOST_EVENT_KEYS.INSTANCE_COMMAND_SETTLED);\n\tconst timeoutMs = Math.max(\n\t\t0,\n\t\tinput.timeoutMs ?? DEFAULT_SETTLEMENT_TIMEOUT_MS,\n\t);\n\treturn new Promise<CommandSettledDetail>((resolve, reject) => {\n\t\tconst cleanup = (): void => {\n\t\t\tif (typeof targetWindow.removeEventListener === \"function\") {\n\t\t\t\ttargetWindow.removeEventListener(eventName, handleEvent);\n\t\t\t}\n\t\t};\n\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tcleanup();\n\t\t\treject(new CommandSettlementTimeoutError(requestId));\n\t\t}, timeoutMs);\n\n\t\tconst handleEvent = (event: Event): void => {\n\t\t\tif (!eventHasDetail(event)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst raw = event.detail;\n\t\t\tif (!isCommandSettledDetail(raw) || raw.requestId !== requestId) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst detail = raw;\n\t\t\tcleanup();\n\t\t\tclearTimeout(timeoutId);\n\t\t\tif (detail.ok) {\n\t\t\t\tresolve(detail);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treject(\n\t\t\t\tnew Error(\n\t\t\t\t\tdetail.error.message ??\n\t\t\t\t\t\t`Command ${detail.kind} failed without an error payload`,\n\t\t\t\t),\n\t\t\t);\n\t\t};\n\t\ttargetWindow.addEventListener(eventName, handleEvent);\n\t});\n};\n",
9
10
  "import { createCommandRequestId } from \"../request-id\";\nimport { waitForCommandSettlement } from \"./command-settlement\";\nimport type { CommandEnvelope, PublicCommandPayload } from \"./sdk-types\";\n\n/**\n * A command input: the pure payload with `kind` and command-specific fields.\n * Distributes over the PublicCommandPayload union so discriminant\n * narrowing is preserved (e.g. `{ kind: \"open\", flowId }` type-checks).\n */\nexport type CommandInput = PublicCommandPayload extends infer C\n\t? C extends PublicCommandPayload\n\t\t? C\n\t\t: never\n\t: never;\n\ntype DispatchOptions = {\n\tidempotencyKey?: string;\n};\n\n/**\n * Creates a dispatch function that wraps a command payload in an envelope,\n * pushes it into the queue, and returns a promise that settles when the\n * runtime acknowledges it.\n *\n * Request IDs are generated automatically.\n *\n * @example\n * ```ts\n * const dispatch = createCommandDispatch((env) => queue.push(env));\n * await dispatch({ kind: \"open\", flowId: \"f1\", flowHandleId: \"h1\" });\n * ```\n */\nexport const createCommandDispatch = (\n\tpush: (envelope: CommandEnvelope) => void,\n): ((input: CommandInput, options?: DispatchOptions) => Promise<void>) => {\n\treturn async (\n\t\tinput: CommandInput,\n\t\toptions?: DispatchOptions,\n\t): Promise<void> => {\n\t\tconst requestId = createCommandRequestId();\n\t\tconst idempotencyKey = resolveIdempotencyKey(options?.idempotencyKey);\n\t\tconst envelope: CommandEnvelope = {\n\t\t\tversion: \"1\",\n\t\t\trequestId,\n\t\t\tidempotencyKey: idempotencyKey ?? requestId,\n\t\t\tcommand: input,\n\t\t};\n\t\tpush(envelope);\n\t\tawait waitForCommandSettlement({ requestId });\n\t};\n};\n\nconst resolveIdempotencyKey = (value?: string): string | null => {\n\tif (value === undefined) {\n\t\treturn null;\n\t}\n\tconst idempotencyKey = value.trim();\n\tif (!idempotencyKey) {\n\t\tthrow new Error(\"idempotencyKey must be a non-empty string\");\n\t}\n\treturn idempotencyKey;\n};\n",
10
11
  "declare const __GX_SDK_VERSION__: string | undefined;\n\nconst sdkVersion =\n\ttypeof __GX_SDK_VERSION__ === \"string\" ? __GX_SDK_VERSION__.trim() : \"\";\n\n// Build scripts inject __GX_SDK_VERSION__ for published artifacts.\n// Source-linked workspace usage may not inject defines, so keep a safe fallback.\nexport const SDK_VERSION = sdkVersion.length > 0 ? sdkVersion : \"0.0.0-local\";\n",
11
- "import {\n\tHOST_EVENT_KEYS,\n\tLOADER_RUNTIME_GLOBAL_KEY,\n\tLOADER_RUNTIME_PROTOCOL_VERSION,\n\tSDK_PROTOCOL_CAPABILITIES,\n\ttoHostEventName,\n} from \"shared/constants\";\nimport {\n\ttype ClientMeta,\n\ttype ClientOptions,\n\ttype Command,\n\ttype CommandEnvelope,\n\tCommandSettlementTimeoutError,\n\ttype ConfigureOptions,\n\ttype ContainerPolicy,\n\tcreateCommandDispatch,\n\ttype FlowState as HostFlowState,\n\ttype InitOptions,\n\tisFlowStateChangedDetail,\n\tisInstanceFlowStateChangedDetail,\n\twaitForCommandSettlement,\n} from \"shared/protocol/sdk\";\nimport { SDK_VERSION } from \"./version\";\n\nexport type { ClientOptions };\n\nimport { createCommandRequestId } from \"shared/request-id\";\n\n/** @internal */\ndeclare global {\n\tinterface Window {\n\t\t__getuserfeedback_queue?: CommandEnvelope[];\n\t\t[LOADER_RUNTIME_GLOBAL_KEY]?: {\n\t\t\talive?: boolean;\n\t\t\tprotocolVersion?: string;\n\t\t};\n\t}\n}\n\ntype FlowHandleId = string;\n\n/** Current state of a flow run (open/loading + dimensions when known). */\nexport type FlowState = HostFlowState;\n\n/** Callback invoked when flow state changes. */\nexport type FlowStateCallback = (state: FlowState) => void;\ntype IdentifyTraits = Record<string, unknown>;\n\n/** Options for opening a flow run. */\nexport type OpenFlowOptions = {\n\t/**\n\t * Controls where the flow may mount.\n\t * - `any` (default): loader may use default mounting policy.\n\t * - `hostOnly`: wait until a custom per-flow container is registered.\n\t */\n\tcontainerRequirement?: \"any\" | \"hostOnly\";\n};\n\n/** Options for subscribing to flow state updates. */\nexport type SubscribeFlowStateOptions = {\n\t/** Emit the current snapshot immediately. Default `true`. */\n\temitInitial?: boolean;\n\t/** Auto-unsubscribe when the signal is aborted. */\n\tsignal?: AbortSignal;\n};\n\nconst DEFAULT_FLOW_STATE: FlowState = {\n\tisOpen: false,\n\tisLoading: false,\n\twidth: undefined,\n\theight: undefined,\n};\n\n/** Instance for a specific flow: open, prefetch, prerender, close, set container, and subscribe to flow state. */\nexport type FlowRun = {\n\t/** The flow/survey ID this instance refers to. */\n\tflowId: string;\n\t/** Open the flow (show the survey). */\n\topen: (options?: OpenFlowOptions) => Promise<void>;\n\t/** Prefetch the flow so it opens faster when you call `open()`. */\n\tprefetch: () => Promise<void>;\n\t/** Prerender the flow into a container (e.g. for a custom dialog). */\n\tprerender: () => Promise<void>;\n\t/** Close this flow. */\n\tclose: () => Promise<void>;\n\t/** Attach the flow UI to a DOM element, or `null` to detach. */\n\tsetContainer: (element: HTMLElement | null) => void;\n\t/** Return the latest known flow state snapshot. */\n\tgetFlowState: () => FlowState;\n\t/** Subscribe to open/loading/dimensions; returns an unsubscribe function. */\n\tsubscribeFlowState: (\n\t\tcallback: FlowStateCallback,\n\t\toptions?: SubscribeFlowStateOptions,\n\t) => () => void;\n};\n\n/** getuserfeedback client: load the widget, open flows, configure colorScheme/consent/auth, and identify users. */\nexport type Client = {\n\t/** Load the widget script. Call when you created the client with `disableAutoLoad: true`. */\n\tload: () => void;\n\t/** Set how this instance should choose default containers for flows. */\n\tsetDefaultContainerPolicy: (policy: ContainerPolicy) => void;\n\t/** Attach all instance flows to a DOM element, or `null` to restore default host mounting. */\n\tsetContainer: (element: HTMLElement | null) => void;\n\t/** Return the latest known instance-level flow state snapshot. */\n\tgetFlowState: () => FlowState;\n\t/** Subscribe to instance-level flow state updates (eg targeting-triggered opens). */\n\tsubscribeFlowState: (\n\t\tcallback: FlowStateCallback,\n\t\toptions?: SubscribeFlowStateOptions,\n\t) => () => void;\n\t/** Return an instance for the given flow (use its `open`, `prefetch`, `close`, `setContainer`, `getFlowState`, `subscribeFlowState`). */\n\tflow: (flowId: string) => FlowRun;\n\t/** Open the flow and return its instance. */\n\topen: (flowId: string, options?: OpenFlowOptions) => Promise<FlowRun>;\n\t/** Prefetch the flow and return its instance. */\n\tprefetch: (flowId: string) => Promise<FlowRun>;\n\t/** Prerender the flow (e.g. on button hover).\n\t * Prerendering warms up the flow for instant display later.\n\t */\n\tprerender: (flowId: string) => Promise<FlowRun>;\n\t/** Close all open flows. */\n\tclose: () => Promise<void>;\n\t/** Reset widget state and user identity. */\n\treset: () => Promise<void>;\n\t/** Update color scheme, consent, or auth. */\n\tconfigure: (updates: ConfigureOptions) => Promise<void>;\n\t/** Associate the current user via either (userId, optionalTraits) or (traits). */\n\tidentify: {\n\t\t(userId: string, traits?: IdentifyTraits): Promise<void>;\n\t\t(traits: IdentifyTraits): Promise<void>;\n\t};\n};\n\ntype ClientRegistryEntry = {\n\tclient: Client;\n\tupdateOptions: (options: ClientOptions) => void;\n};\n\nconst clientRegistry = new Map<object, Map<string, ClientRegistryEntry>>();\n\nconst asFlowHandleId = (value: string): FlowHandleId => value;\n\nconst createFlowHandleId = (): FlowHandleId => {\n\tif (\n\t\ttypeof globalThis.crypto !== \"undefined\" &&\n\t\ttypeof globalThis.crypto.randomUUID === \"function\"\n\t) {\n\t\treturn asFlowHandleId(globalThis.crypto.randomUUID());\n\t}\n\treturn asFlowHandleId(\n\t\t`handle_${Date.now()}_${Math.random().toString(36).slice(2)}`,\n\t);\n};\n\nconst createClientInstanceId = (): string => {\n\tif (\n\t\ttypeof globalThis.crypto !== \"undefined\" &&\n\t\ttypeof globalThis.crypto.randomUUID === \"function\"\n\t) {\n\t\treturn globalThis.crypto.randomUUID();\n\t}\n\treturn `sdk-${Date.now()}-${Math.random().toString(16).slice(2)}`;\n};\n\nconst toIdentifyCommandPayload = (\n\tidentifyInput: string | IdentifyTraits,\n\ttraits?: IdentifyTraits,\n): Extract<Command, { kind: \"identify\" }> => {\n\tif (typeof identifyInput === \"string\") {\n\t\treturn {\n\t\t\tkind: \"identify\",\n\t\t\tuserId: identifyInput,\n\t\t\ttraits,\n\t\t};\n\t}\n\treturn {\n\t\tkind: \"identify\",\n\t\ttraits: identifyInput,\n\t};\n};\n\nconst LOADER_RUNTIME_PROBE_TIMEOUT_MS = 120;\nconst LOADER_RUNTIME_POST_LOAD_TIMEOUT_MS = 120;\n\nconst resolveRegistryKey = (options: ClientOptions): string => options.apiKey;\n\nconst resolveRegistryScope = (): object =>\n\ttypeof window === \"undefined\" ? globalThis : window;\n\nconst getRegistryForScope = (): Map<string, ClientRegistryEntry> => {\n\tconst scope = resolveRegistryScope();\n\tconst existing = clientRegistry.get(scope);\n\tif (existing) {\n\t\treturn existing;\n\t}\n\tconst created = new Map<string, ClientRegistryEntry>();\n\tclientRegistry.set(scope, created);\n\treturn created;\n};\n\n/**\n * Create a getuserfeedback client. Reuses an existing client when called with the same\n * `apiKey` and equivalent options; otherwise creates a new one.\n */\nexport const createClient = ({\n\tapiKey,\n\t_cdn = \"https://cdn.getuserfeedback.com\",\n\tdisableAutoLoad = false,\n\tcolorScheme,\n\tdisableTelemetry = false,\n\tenableDebug = false,\n\tdefaultConsent,\n}: ClientOptions): Client => {\n\tconst registryKey = resolveRegistryKey({\n\t\tapiKey,\n\t\t_cdn,\n\t\tdisableAutoLoad,\n\t\tcolorScheme,\n\t\tdisableTelemetry,\n\t\tenableDebug,\n\t\tdefaultConsent,\n\t});\n\tconst registry = getRegistryForScope();\n\tconst existing = registry.get(registryKey);\n\tif (existing) {\n\t\texisting.updateOptions({\n\t\t\tapiKey,\n\t\t\t_cdn,\n\t\t\tdisableAutoLoad,\n\t\t\tcolorScheme,\n\t\t\tdisableTelemetry,\n\t\t\tenableDebug,\n\t\t\tdefaultConsent,\n\t\t});\n\t\tif (!disableAutoLoad) {\n\t\t\texisting.client.load();\n\t\t}\n\t\treturn existing.client;\n\t}\n\n\tlet _cdnConfig = _cdn;\n\n\tconst notifyError = (_error: unknown): void => {\n\t\t// No-op: track/use hooks removed from public API.\n\t};\n\n\tconst sdkVersion = SDK_VERSION;\n\tconst loaderVersion = \"v1\";\n\tconst clientInstanceId = createClientInstanceId();\n\tconst clientMeta: ClientMeta = {\n\t\tloader: \"sdk\",\n\t\tclientName: \"@getuserfeedback/sdk\",\n\t\tclientVersion: sdkVersion,\n\t\ttransport: \"snippet\",\n\t};\n\n\tconst capabilities = [...SDK_PROTOCOL_CAPABILITIES];\n\n\tlet defaultConsentConfig = defaultConsent;\n\n\tconst buildInitOpts = (): InitOptions => ({\n\t\tapiKey,\n\t\tclientMeta,\n\t\tcapabilities: [...capabilities],\n\t\t...(colorScheme !== undefined && { colorScheme }),\n\t\t...(disableTelemetry !== undefined && { disableTelemetry }),\n\t\t...(enableDebug !== undefined && { enableDebug }),\n\t\t...(defaultConsentConfig !== undefined && {\n\t\t\tdefaultConsent: defaultConsentConfig,\n\t\t}),\n\t});\n\n\tlet loaderRequested = false;\n\tlet pendingLoad: Promise<void> | null = null;\n\tlet disableAutoLoadConfig = disableAutoLoad;\n\tconst flowStateByHandle = new Map<FlowHandleId, FlowState>();\n\tlet instanceFlowState: FlowState = DEFAULT_FLOW_STATE;\n\n\tconst cloneFlowState = (state: FlowState): FlowState => ({\n\t\tisOpen: state.isOpen,\n\t\tisLoading: state.isLoading,\n\t\twidth: state.width,\n\t\theight: state.height,\n\t});\n\n\tconst getFlowStateForHandle = (flowHandleId: FlowHandleId): FlowState => {\n\t\tconst existing = flowStateByHandle.get(flowHandleId);\n\t\tif (!existing) {\n\t\t\treturn cloneFlowState(DEFAULT_FLOW_STATE);\n\t\t}\n\t\treturn cloneFlowState(existing);\n\t};\n\n\tconst setFlowStateForHandle = (\n\t\tflowHandleId: FlowHandleId,\n\t\tstate: FlowState,\n\t): void => {\n\t\tflowStateByHandle.set(flowHandleId, cloneFlowState(state));\n\t};\n\n\tconst getInstanceFlowState = (): FlowState =>\n\t\tcloneFlowState(instanceFlowState);\n\n\tconst setInstanceFlowState = (state: FlowState): void => {\n\t\tinstanceFlowState = cloneFlowState(state);\n\t};\n\n\tconst ensureFlowStateForHandle = (flowHandleId: FlowHandleId): void => {\n\t\tif (!flowStateByHandle.has(flowHandleId)) {\n\t\t\tsetFlowStateForHandle(flowHandleId, DEFAULT_FLOW_STATE);\n\t\t}\n\t};\n\n\tconst isLoaderRequested = (): boolean => loaderRequested;\n\n\tconst enqueue = (envelope: CommandEnvelope): void => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tif (!window.__getuserfeedback_queue) {\n\t\t\twindow.__getuserfeedback_queue = [];\n\t\t}\n\t\t// Stamp instanceId and clientMeta so the loader can route commands.\n\t\tconst stamped: CommandEnvelope = {\n\t\t\t...envelope,\n\t\t\tinstanceId: envelope.instanceId ?? clientInstanceId,\n\t\t\tclientMeta: envelope.clientMeta ?? clientMeta,\n\t\t};\n\t\twindow.__getuserfeedback_queue.push(stamped);\n\t};\n\n\tconst enqueueInstanceRegistration = (requestId?: string): string => {\n\t\tconst registrationRequestId = requestId ?? createCommandRequestId();\n\t\tenqueue({\n\t\t\tversion: \"1\",\n\t\t\tinstanceId: clientInstanceId,\n\t\t\trequestId: registrationRequestId,\n\t\t\tidempotencyKey: registrationRequestId,\n\t\t\tcommand: { kind: \"init\", opts: buildInitOpts() },\n\t\t});\n\t\treturn registrationRequestId;\n\t};\n\n\tconst enqueueSetContainer = (\n\t\tflowHandleId: FlowHandleId,\n\t\telement: HTMLElement | null,\n\t): void => {\n\t\tconst requestId = createCommandRequestId();\n\t\tenqueue({\n\t\t\tversion: \"1\",\n\t\t\trequestId,\n\t\t\tidempotencyKey: requestId,\n\t\t\tcommand: { kind: \"setContainer\", flowHandleId, container: element },\n\t\t});\n\t};\n\n\tconst enqueueSetDefaultContainerPolicy = (policy: ContainerPolicy): void => {\n\t\tconst requestId = createCommandRequestId();\n\t\tenqueue({\n\t\t\tversion: \"1\",\n\t\t\trequestId,\n\t\t\tidempotencyKey: requestId,\n\t\t\tcommand: { kind: \"setDefaultContainerPolicy\", policy },\n\t\t});\n\t};\n\n\tconst reportAsyncError = <T>(promise: Promise<T>): Promise<T> => {\n\t\treturn promise.catch((error) => {\n\t\t\tnotifyError(error);\n\t\t\tthrow error;\n\t\t});\n\t};\n\n\tconst ensureCommandsCanRun = (): void => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tif (!isLoaderRequested()) {\n\t\t\tif (disableAutoLoadConfig) {\n\t\t\t\tthrow new Error(\"Widget not loaded. Call client.load() first.\");\n\t\t\t}\n\t\t\tload();\n\t\t}\n\t};\n\n\t/** Enqueue a command and await its settlement.\n\t * The loader resolves instanceId from the instance registry. */\n\tconst rawDispatch = createCommandDispatch((cmd) => enqueue(cmd));\n\tconst dispatch = async (input: Command): Promise<void> => {\n\t\tensureCommandsCanRun();\n\t\treturn rawDispatch(input);\n\t};\n\n\tconst enqueueConfigUpdate = (opts: ConfigureOptions): void => {\n\t\tif (!isLoaderRequested()) {\n\t\t\treturn;\n\t\t}\n\t\tconst requestId = createCommandRequestId();\n\t\tenqueue({\n\t\t\tversion: \"1\",\n\t\t\trequestId,\n\t\t\tidempotencyKey: requestId,\n\t\t\tcommand: { kind: \"configure\", opts },\n\t\t});\n\t};\n\n\tconst updateOptions = (next: ClientOptions): void => {\n\t\tdisableAutoLoadConfig = next.disableAutoLoad ?? disableAutoLoadConfig;\n\t\tdefaultConsentConfig = next.defaultConsent ?? defaultConsentConfig;\n\n\t\tif (next._cdn !== undefined && next._cdn !== _cdnConfig) {\n\t\t\tif (isLoaderRequested() || pendingLoad !== null) {\n\t\t\t\tconst error = new Error(\n\t\t\t\t\t\"_cdn cannot be changed after widget init; keeping original\",\n\t\t\t\t);\n\t\t\t\tnotifyError(error);\n\t\t\t} else {\n\t\t\t\t_cdnConfig = next._cdn;\n\t\t\t}\n\t\t}\n\n\t\tapplyStartupConfig(next);\n\n\t\tif (!disableAutoLoadConfig && !isLoaderRequested()) {\n\t\t\tload();\n\t\t}\n\t};\n\n\tconst applyStartupConfig = (next: ClientOptions): void => {\n\t\t// Send configure payload from next (colorScheme only from ClientOptions).\n\t\tif (!isLoaderRequested()) return;\n\t\tconst opts: ConfigureOptions = {};\n\t\tif (next.colorScheme !== undefined) opts.colorScheme = next.colorScheme;\n\t\tenqueueConfigUpdate(opts);\n\t};\n\n\tconst load = (): void => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tif (isLoaderRequested() || pendingLoad) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst appendLoaderScript = (): void => {\n\t\t\tconst cdnBase = _cdnConfig.endsWith(\"/\") ? _cdnConfig : `${_cdnConfig}/`;\n\t\t\tconst loaderScriptPath = `loader/${loaderVersion}/${encodeURIComponent(\n\t\t\t\tapiKey,\n\t\t\t)}/loader.js`;\n\t\t\tconst scriptUrl = new URL(loaderScriptPath, cdnBase).toString();\n\t\t\tif (!document.querySelector(`link[href=\"${scriptUrl}\"][rel=\"preload\"]`)) {\n\t\t\t\tconst preload = document.createElement(\"link\");\n\t\t\t\tpreload.rel = \"preload\";\n\t\t\t\tpreload.as = \"script\";\n\t\t\t\tpreload.href = scriptUrl;\n\t\t\t\tdocument.head.appendChild(preload);\n\t\t\t}\n\n\t\t\tconst script = document.createElement(\"script\");\n\t\t\tscript.src = scriptUrl;\n\t\t\tscript.async = true;\n\t\t\tif (script.dataset) {\n\t\t\t\tscript.dataset.disableAutoRegister = \"true\";\n\t\t\t} else if (typeof script.setAttribute === \"function\") {\n\t\t\t\tscript.setAttribute(\"data-disable-auto-register\", \"true\");\n\t\t\t}\n\t\t\tdocument.head.appendChild(script);\n\t\t};\n\n\t\tconst runtimeMarker = window[LOADER_RUNTIME_GLOBAL_KEY];\n\t\tif (runtimeMarker?.alive) {\n\t\t\tconst protocolVersion = runtimeMarker.protocolVersion;\n\t\t\tif (protocolVersion !== LOADER_RUNTIME_PROTOCOL_VERSION) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Incompatible loader runtime protocol: expected ${LOADER_RUNTIME_PROTOCOL_VERSION}, received ${protocolVersion ?? \"unknown\"}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tenqueueInstanceRegistration();\n\t\t\tloaderRequested = true;\n\t\t\treturn;\n\t\t}\n\n\t\tconst hasCommandQueue = Array.isArray(window.__getuserfeedback_queue);\n\t\tif (!hasCommandQueue) {\n\t\t\tconst requestId = enqueueInstanceRegistration();\n\t\t\tappendLoaderScript();\n\t\t\tloaderRequested = true;\n\t\t\tlet trackedPending: Promise<void>;\n\t\t\tconst pending = waitForCommandSettlement({\n\t\t\t\trequestId,\n\t\t\t\ttimeoutMs: LOADER_RUNTIME_POST_LOAD_TIMEOUT_MS,\n\t\t\t})\n\t\t\t\t.then(() => {})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tnotifyError(error);\n\t\t\t\t});\n\t\t\ttrackedPending = pending.finally(() => {\n\t\t\t\tif (pendingLoad === trackedPending) {\n\t\t\t\t\tpendingLoad = null;\n\t\t\t\t}\n\t\t\t});\n\t\t\tpendingLoad = trackedPending;\n\t\t\treturn;\n\t\t}\n\n\t\tloaderRequested = true;\n\n\t\tlet trackedPending: Promise<void>;\n\t\tconst pending = (async () => {\n\t\t\tconst requestId = createCommandRequestId();\n\t\t\tenqueueInstanceRegistration(requestId);\n\t\t\ttry {\n\t\t\t\tawait waitForCommandSettlement({\n\t\t\t\t\trequestId,\n\t\t\t\t\ttimeoutMs: LOADER_RUNTIME_PROBE_TIMEOUT_MS,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof CommandSettlementTimeoutError) {\n\t\t\t\t\tappendLoaderScript();\n\t\t\t\t\tawait waitForCommandSettlement({\n\t\t\t\t\t\trequestId,\n\t\t\t\t\t\ttimeoutMs: LOADER_RUNTIME_POST_LOAD_TIMEOUT_MS,\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})().catch((error) => {\n\t\t\tnotifyError(error);\n\t\t});\n\t\ttrackedPending = pending.finally(() => {\n\t\t\tif (pendingLoad === trackedPending) {\n\t\t\t\tpendingLoad = null;\n\t\t\t}\n\t\t});\n\t\tpendingLoad = trackedPending;\n\t};\n\n\tconst setContainerForHandle = (\n\t\tflowHandleId: FlowHandleId,\n\t\telement: HTMLElement | null,\n\t): void => {\n\t\t// Always enqueue — commands sit in the global queue until the\n\t\t// loader processes them. The command-router stores containers in\n\t\t// pendingContainer and applies them when a flow run is allocated.\n\t\tenqueueSetContainer(flowHandleId, element);\n\t};\n\n\tconst setDefaultContainer = (element: HTMLElement | null): void => {\n\t\tif (element === null) {\n\t\t\tenqueueSetDefaultContainerPolicy({ kind: \"floating\" });\n\t\t\treturn;\n\t\t}\n\t\tenqueueSetDefaultContainerPolicy({\n\t\t\tkind: \"hostContainer\",\n\t\t\thost: element,\n\t\t\tsharing: \"shared\",\n\t\t});\n\t};\n\n\tconst subscribeFlowStateForHandle = (\n\t\tflowHandleId: FlowHandleId,\n\t\tcallback: FlowStateCallback,\n\t\toptions?: SubscribeFlowStateOptions,\n\t): (() => void) => {\n\t\tif (options?.emitInitial ?? true) {\n\t\t\tcallback(getFlowStateForHandle(flowHandleId));\n\t\t}\n\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst eventName = toHostEventName(\n\t\t\tHOST_EVENT_KEYS.INSTANCE_FLOW_STATE_CHANGED,\n\t\t);\n\n\t\tconst handleFlowStateEvent = (event: Event): void => {\n\t\t\tconst detail = (event as CustomEvent<unknown>).detail;\n\t\t\tif (\n\t\t\t\t!isFlowStateChangedDetail(detail) ||\n\t\t\t\tdetail.flowHandleId !== flowHandleId\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextState: FlowState = {\n\t\t\t\tisOpen: detail.isOpen,\n\t\t\t\tisLoading: detail.isLoading,\n\t\t\t\twidth: detail.width,\n\t\t\t\theight: detail.height,\n\t\t\t};\n\t\t\tsetFlowStateForHandle(flowHandleId, nextState);\n\t\t\tcallback(cloneFlowState(nextState));\n\t\t};\n\n\t\tlet isUnsubscribed = false;\n\t\tconst signal = options?.signal;\n\t\tlet handleAbort: (() => void) | null = null;\n\n\t\tconst unsubscribe = (): void => {\n\t\t\tif (isUnsubscribed) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tisUnsubscribed = true;\n\t\t\twindow.removeEventListener(eventName, handleFlowStateEvent);\n\t\t\tif (signal && handleAbort) {\n\t\t\t\tsignal.removeEventListener(\"abort\", handleAbort);\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(eventName, handleFlowStateEvent);\n\n\t\tif (signal) {\n\t\t\thandleAbort = () => {\n\t\t\t\tunsubscribe();\n\t\t\t};\n\t\t\tif (signal.aborted) {\n\t\t\t\tunsubscribe();\n\t\t\t\treturn unsubscribe;\n\t\t\t}\n\t\t\tsignal.addEventListener(\"abort\", handleAbort, { once: true });\n\t\t}\n\n\t\treturn unsubscribe;\n\t};\n\n\tconst subscribeFlowStateForInstance = (\n\t\tcallback: FlowStateCallback,\n\t\toptions?: SubscribeFlowStateOptions,\n\t): (() => void) => {\n\t\tif (options?.emitInitial ?? true) {\n\t\t\tcallback(getInstanceFlowState());\n\t\t}\n\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst eventName = toHostEventName(\n\t\t\tHOST_EVENT_KEYS.INSTANCE_FLOW_STATE_CHANGED_INSTANCE,\n\t\t);\n\n\t\tconst handleFlowStateEvent = (event: Event): void => {\n\t\t\tconst detail = (event as CustomEvent<unknown>).detail;\n\t\t\tif (\n\t\t\t\t!isInstanceFlowStateChangedDetail(detail) ||\n\t\t\t\tdetail.instanceId !== clientInstanceId\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst nextState: FlowState = {\n\t\t\t\tisOpen: detail.isOpen,\n\t\t\t\tisLoading: detail.isLoading,\n\t\t\t\twidth: detail.width,\n\t\t\t\theight: detail.height,\n\t\t\t};\n\t\t\tsetInstanceFlowState(nextState);\n\t\t\tcallback(cloneFlowState(nextState));\n\t\t};\n\n\t\tlet isUnsubscribed = false;\n\t\tconst signal = options?.signal;\n\t\tlet handleAbort: (() => void) | null = null;\n\n\t\tconst unsubscribe = (): void => {\n\t\t\tif (isUnsubscribed) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tisUnsubscribed = true;\n\t\t\twindow.removeEventListener(eventName, handleFlowStateEvent);\n\t\t\tif (signal && handleAbort) {\n\t\t\t\tsignal.removeEventListener(\"abort\", handleAbort);\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(eventName, handleFlowStateEvent);\n\n\t\tif (signal) {\n\t\t\thandleAbort = () => {\n\t\t\t\tunsubscribe();\n\t\t\t};\n\t\t\tif (signal.aborted) {\n\t\t\t\tunsubscribe();\n\t\t\t\treturn unsubscribe;\n\t\t\t}\n\t\t\tsignal.addEventListener(\"abort\", handleAbort, { once: true });\n\t\t}\n\n\t\treturn unsubscribe;\n\t};\n\n\tconst createFlowRun = (flowIdInput: string): FlowRun => {\n\t\tconst flowId = flowIdInput;\n\t\tif (!flowId.trim()) {\n\t\t\tthrow new Error(\"flowId must be a non-empty string\");\n\t\t}\n\t\tconst flowHandleId = createFlowHandleId();\n\t\tensureFlowStateForHandle(flowHandleId);\n\n\t\treturn {\n\t\t\tflowId,\n\t\t\topen: (options?: OpenFlowOptions) =>\n\t\t\t\treportAsyncError(\n\t\t\t\t\tdispatch({\n\t\t\t\t\t\tkind: \"open\",\n\t\t\t\t\t\tflowId,\n\t\t\t\t\t\tflowHandleId,\n\t\t\t\t\t\t...(options?.containerRequirement\n\t\t\t\t\t\t\t? { containerRequirement: options.containerRequirement }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\tprefetch: () => reportAsyncError(dispatch({ kind: \"prefetch\", flowId })),\n\t\t\tprerender: () =>\n\t\t\t\treportAsyncError(dispatch({ kind: \"prerender\", flowId, flowHandleId })),\n\t\t\tclose: () => reportAsyncError(dispatch({ kind: \"close\", flowHandleId })),\n\t\t\tsetContainer: (element: HTMLElement | null) => {\n\t\t\t\tsetContainerForHandle(flowHandleId, element);\n\t\t\t},\n\t\t\tgetFlowState: () => getFlowStateForHandle(flowHandleId),\n\t\t\tsubscribeFlowState: (\n\t\t\t\tcallback: FlowStateCallback,\n\t\t\t\toptions?: SubscribeFlowStateOptions,\n\t\t\t) => subscribeFlowStateForHandle(flowHandleId, callback, options),\n\t\t};\n\t};\n\n\tconst flow = (flowIdInput: string): FlowRun => createFlowRun(flowIdInput);\n\n\tconst open = async (\n\t\tflowIdInput: string,\n\t\toptions?: OpenFlowOptions,\n\t): Promise<FlowRun> => {\n\t\tconst nextFlowRun = createFlowRun(flowIdInput);\n\t\tawait nextFlowRun.open(options);\n\t\treturn nextFlowRun;\n\t};\n\n\tconst prefetch = async (flowIdInput: string): Promise<FlowRun> => {\n\t\tconst nextFlowRun = createFlowRun(flowIdInput);\n\t\tawait nextFlowRun.prefetch();\n\t\treturn nextFlowRun;\n\t};\n\n\tconst close = (): Promise<void> => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn reportAsyncError(dispatch({ kind: \"close\" }));\n\t};\n\n\tconst reset = (): Promise<void> => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn reportAsyncError(dispatch({ kind: \"reset\" }));\n\t};\n\n\tfunction identify(userId: string, traits?: IdentifyTraits): Promise<void>;\n\tfunction identify(traits: IdentifyTraits): Promise<void>;\n\tfunction identify(\n\t\tidentifyInput: string | IdentifyTraits,\n\t\ttraits?: IdentifyTraits,\n\t): Promise<void> {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn reportAsyncError(\n\t\t\tdispatch(toIdentifyCommandPayload(identifyInput, traits)),\n\t\t);\n\t}\n\n\tconst configure = (updates: ConfigureOptions): Promise<void> => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tif (!isLoaderRequested()) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\t// Send updates as-is; loader merges and forwards deltas to core.\n\t\treturn reportAsyncError(dispatch({ kind: \"configure\", opts: updates }));\n\t};\n\n\tconst prerender = async (flowIdInput: string): Promise<FlowRun> => {\n\t\tconst nextFlowRun = createFlowRun(flowIdInput);\n\t\tawait nextFlowRun.prerender();\n\t\treturn nextFlowRun;\n\t};\n\n\tconst client: Client = {\n\t\tload,\n\t\tsetDefaultContainerPolicy: (policy: ContainerPolicy) => {\n\t\t\tenqueueSetDefaultContainerPolicy(policy);\n\t\t},\n\t\tsetContainer: (element: HTMLElement | null) => {\n\t\t\tsetDefaultContainer(element);\n\t\t},\n\t\tgetFlowState: () => getInstanceFlowState(),\n\t\tsubscribeFlowState: (\n\t\t\tcallback: FlowStateCallback,\n\t\t\toptions?: SubscribeFlowStateOptions,\n\t\t) => subscribeFlowStateForInstance(callback, options),\n\t\tflow,\n\t\topen,\n\t\tprefetch,\n\t\tprerender,\n\t\tclose,\n\t\treset,\n\t\tconfigure,\n\t\tidentify,\n\t};\n\n\tregistry.set(registryKey, {\n\t\tclient,\n\t\tupdateOptions,\n\t});\n\n\tif (!disableAutoLoadConfig) {\n\t\tclient.load();\n\t}\n\n\treturn client;\n};\n\nexport default createClient;\n"
12
+ "import {\n\tHOST_EVENT_KEYS,\n\tLOADER_RUNTIME_GLOBAL_KEY,\n\tLOADER_RUNTIME_PROTOCOL_VERSION,\n\tSDK_PROTOCOL_CAPABILITIES,\n\ttoHostEventName,\n} from \"shared/constants\";\nimport {\n\ttype ClientMeta,\n\ttype ClientOptions,\n\ttype Command,\n\ttype CommandEnvelope,\n\tCommandSettlementTimeoutError,\n\ttype ConfigureOptions,\n\ttype ContainerPolicy,\n\tcreateCommandDispatch,\n\ttype FlowState as HostFlowState,\n\ttype InitOptions,\n\tisFlowStateChangedDetail,\n\tisInstanceFlowStateChangedDetail,\n\twaitForCommandSettlement,\n} from \"shared/protocol/sdk\";\nimport { SDK_VERSION } from \"./version\";\n\nexport type { ClientOptions };\n\nimport { createCommandRequestId } from \"shared/request-id\";\n\n/** @internal */\ndeclare global {\n\tinterface Window {\n\t\t__getuserfeedback_queue?: CommandEnvelope[];\n\t\t[LOADER_RUNTIME_GLOBAL_KEY]?: {\n\t\t\talive?: boolean;\n\t\t\tprotocolVersion?: string;\n\t\t};\n\t}\n}\n\ntype FlowHandleId = string;\n\n/** Current state of a flow run (open/loading + dimensions when known). */\nexport type FlowState = HostFlowState;\n\n/** Callback invoked when flow state changes. */\nexport type FlowStateCallback = (state: FlowState) => void;\ntype IdentifyTraits = Record<string, unknown>;\n\n/** Options for opening a flow run. */\nexport type OpenFlowOptions = {\n\t/**\n\t * Controls where the flow may mount.\n\t * - `any` (default): loader may use default mounting policy.\n\t * - `hostOnly`: wait until a custom per-flow container is registered.\n\t */\n\tcontainerRequirement?: \"any\" | \"hostOnly\";\n\t/**\n\t * When `true`, the flow view does not show a close button.\n\t * Useful for mobile or embedded contexts where the host handles dismissal (e.g. via a drawer or back gesture).\n\t */\n\thideCloseButton?: boolean;\n};\n\n/** Options for prerendering a flow run. */\nexport type PrerenderFlowOptions = {\n\t/**\n\t * When `true`, the prerendered view does not show a close button.\n\t */\n\thideCloseButton?: boolean;\n};\n\n/** Options for subscribing to flow state updates. */\nexport type SubscribeFlowStateOptions = {\n\t/** Emit the current snapshot immediately. Default `true`. */\n\temitInitial?: boolean;\n\t/** Auto-unsubscribe when the signal is aborted. */\n\tsignal?: AbortSignal;\n};\n\nconst DEFAULT_FLOW_STATE: FlowState = {\n\tisOpen: false,\n\tisLoading: false,\n\twidth: undefined,\n\theight: undefined,\n};\n\n/** Instance for a specific flow: open, prefetch, prerender, close, set container, and subscribe to flow state. */\nexport type FlowRun = {\n\t/** The flow/survey ID this instance refers to. */\n\tflowId: string;\n\t/** Open the flow (show the survey). */\n\topen: (options?: OpenFlowOptions) => Promise<void>;\n\t/** Prefetch the flow so it opens faster when you call `open()`. */\n\tprefetch: () => Promise<void>;\n\t/** Prerender the flow into a container (e.g. for a custom dialog). */\n\tprerender: (options?: PrerenderFlowOptions) => Promise<void>;\n\t/** Close this flow. */\n\tclose: () => Promise<void>;\n\t/** Attach the flow UI to a DOM element, or `null` to detach. */\n\tsetContainer: (element: HTMLElement | null) => void;\n\t/** Return the latest known flow state snapshot. */\n\tgetFlowState: () => FlowState;\n\t/** Subscribe to open/loading/dimensions; returns an unsubscribe function. */\n\tsubscribeFlowState: (\n\t\tcallback: FlowStateCallback,\n\t\toptions?: SubscribeFlowStateOptions,\n\t) => () => void;\n};\n\n/** getuserfeedback client: load the widget, open flows, configure colorScheme/consent/auth, and identify users. */\nexport type Client = {\n\t/** Load the widget script. Call when you created the client with `disableAutoLoad: true`. */\n\tload: () => void;\n\t/** Set how this instance should choose default containers for flows. */\n\tsetDefaultContainerPolicy: (policy: ContainerPolicy) => void;\n\t/** Attach all instance flows to a DOM element, or `null` to restore default host mounting. */\n\tsetContainer: (element: HTMLElement | null) => void;\n\t/** Return the latest known instance-level flow state snapshot. */\n\tgetFlowState: () => FlowState;\n\t/** Subscribe to instance-level flow state updates (eg targeting-triggered opens). */\n\tsubscribeFlowState: (\n\t\tcallback: FlowStateCallback,\n\t\toptions?: SubscribeFlowStateOptions,\n\t) => () => void;\n\t/** Return a flow instance; call .open(), .prefetch(), .prerender(), .setContainer(), .close() on it. */\n\tflow: (flowId: string) => FlowRun;\n\t/** Close all open flows. */\n\tclose: () => Promise<void>;\n\t/** Reset widget state and user identity. */\n\treset: () => Promise<void>;\n\t/** Update color scheme, consent, or auth. */\n\tconfigure: (updates: ConfigureOptions) => Promise<void>;\n\t/** Associate the current user via either (userId, optionalTraits) or (traits). */\n\tidentify: {\n\t\t(userId: string, traits?: IdentifyTraits): Promise<void>;\n\t\t(traits: IdentifyTraits): Promise<void>;\n\t};\n};\n\ntype ClientRegistryEntry = {\n\tclient: Client;\n\tupdateOptions: (options: ClientOptions) => void;\n};\n\nconst clientRegistry = new Map<object, Map<string, ClientRegistryEntry>>();\n\nconst asFlowHandleId = (value: string): FlowHandleId => value;\n\nconst createFlowHandleId = (): FlowHandleId => {\n\tif (\n\t\ttypeof globalThis.crypto !== \"undefined\" &&\n\t\ttypeof globalThis.crypto.randomUUID === \"function\"\n\t) {\n\t\treturn asFlowHandleId(globalThis.crypto.randomUUID());\n\t}\n\treturn asFlowHandleId(\n\t\t`handle_${Date.now()}_${Math.random().toString(36).slice(2)}`,\n\t);\n};\n\nconst createClientInstanceId = (): string => {\n\tif (\n\t\ttypeof globalThis.crypto !== \"undefined\" &&\n\t\ttypeof globalThis.crypto.randomUUID === \"function\"\n\t) {\n\t\treturn globalThis.crypto.randomUUID();\n\t}\n\treturn `sdk-${Date.now()}-${Math.random().toString(16).slice(2)}`;\n};\n\nconst toIdentifyCommandPayload = (\n\tidentifyInput: string | IdentifyTraits,\n\ttraits?: IdentifyTraits,\n): Extract<Command, { kind: \"identify\" }> => {\n\tif (typeof identifyInput === \"string\") {\n\t\treturn {\n\t\t\tkind: \"identify\",\n\t\t\tuserId: identifyInput,\n\t\t\ttraits,\n\t\t};\n\t}\n\treturn {\n\t\tkind: \"identify\",\n\t\ttraits: identifyInput,\n\t};\n};\n\nconst LOADER_RUNTIME_PROBE_TIMEOUT_MS = 120;\nconst LOADER_RUNTIME_POST_LOAD_TIMEOUT_MS = 120;\n\nconst resolveRegistryKey = (options: ClientOptions): string => options.apiKey;\n\nconst resolveRegistryScope = (): object =>\n\ttypeof window === \"undefined\" ? globalThis : window;\n\nconst getRegistryForScope = (): Map<string, ClientRegistryEntry> => {\n\tconst scope = resolveRegistryScope();\n\tconst existing = clientRegistry.get(scope);\n\tif (existing) {\n\t\treturn existing;\n\t}\n\tconst created = new Map<string, ClientRegistryEntry>();\n\tclientRegistry.set(scope, created);\n\treturn created;\n};\n\n/**\n * Create a getuserfeedback client. Reuses an existing client when called with the same\n * `apiKey` and equivalent options; otherwise creates a new one.\n */\nexport const createClient = ({\n\tapiKey,\n\t_cdn = \"https://cdn.getuserfeedback.com\",\n\tdisableAutoLoad = false,\n\tcolorScheme,\n\tdisableTelemetry = false,\n\tenableDebug = false,\n\tdefaultConsent,\n}: ClientOptions): Client => {\n\tconst registryKey = resolveRegistryKey({\n\t\tapiKey,\n\t\t_cdn,\n\t\tdisableAutoLoad,\n\t\tcolorScheme,\n\t\tdisableTelemetry,\n\t\tenableDebug,\n\t\tdefaultConsent,\n\t});\n\tconst registry = getRegistryForScope();\n\tconst existing = registry.get(registryKey);\n\tif (existing) {\n\t\texisting.updateOptions({\n\t\t\tapiKey,\n\t\t\t_cdn,\n\t\t\tdisableAutoLoad,\n\t\t\tcolorScheme,\n\t\t\tdisableTelemetry,\n\t\t\tenableDebug,\n\t\t\tdefaultConsent,\n\t\t});\n\t\tif (!disableAutoLoad) {\n\t\t\texisting.client.load();\n\t\t}\n\t\treturn existing.client;\n\t}\n\n\tlet _cdnConfig = _cdn;\n\n\tconst notifyError = (_error: unknown): void => {\n\t\t// No-op: track/use hooks removed from public API.\n\t};\n\n\tconst sdkVersion = SDK_VERSION;\n\tconst loaderVersion = \"v1\";\n\tconst clientInstanceId = createClientInstanceId();\n\tconst clientMeta: ClientMeta = {\n\t\tloader: \"sdk\",\n\t\tclientName: \"@getuserfeedback/sdk\",\n\t\tclientVersion: sdkVersion,\n\t\ttransport: \"snippet\",\n\t};\n\n\tconst capabilities = [...SDK_PROTOCOL_CAPABILITIES];\n\n\tlet defaultConsentConfig = defaultConsent;\n\n\tconst buildInitOpts = (): InitOptions => ({\n\t\tapiKey,\n\t\tclientMeta,\n\t\tcapabilities: [...capabilities],\n\t\t...(colorScheme !== undefined && { colorScheme }),\n\t\t...(disableTelemetry !== undefined && { disableTelemetry }),\n\t\t...(enableDebug !== undefined && { enableDebug }),\n\t\t...(defaultConsentConfig !== undefined && {\n\t\t\tdefaultConsent: defaultConsentConfig,\n\t\t}),\n\t});\n\n\tlet loaderRequested = false;\n\tlet pendingLoad: Promise<void> | null = null;\n\tlet disableAutoLoadConfig = disableAutoLoad;\n\tconst flowStateByHandle = new Map<FlowHandleId, FlowState>();\n\tlet instanceFlowState: FlowState = DEFAULT_FLOW_STATE;\n\n\tconst cloneFlowState = (state: FlowState): FlowState => ({\n\t\tisOpen: state.isOpen,\n\t\tisLoading: state.isLoading,\n\t\twidth: state.width,\n\t\theight: state.height,\n\t});\n\n\tconst getFlowStateForHandle = (flowHandleId: FlowHandleId): FlowState => {\n\t\tconst existing = flowStateByHandle.get(flowHandleId);\n\t\tif (!existing) {\n\t\t\treturn cloneFlowState(DEFAULT_FLOW_STATE);\n\t\t}\n\t\treturn cloneFlowState(existing);\n\t};\n\n\tconst setFlowStateForHandle = (\n\t\tflowHandleId: FlowHandleId,\n\t\tstate: FlowState,\n\t): void => {\n\t\tflowStateByHandle.set(flowHandleId, cloneFlowState(state));\n\t};\n\n\tconst getInstanceFlowState = (): FlowState =>\n\t\tcloneFlowState(instanceFlowState);\n\n\tconst setInstanceFlowState = (state: FlowState): void => {\n\t\tinstanceFlowState = cloneFlowState(state);\n\t};\n\n\tconst ensureFlowStateForHandle = (flowHandleId: FlowHandleId): void => {\n\t\tif (!flowStateByHandle.has(flowHandleId)) {\n\t\t\tsetFlowStateForHandle(flowHandleId, DEFAULT_FLOW_STATE);\n\t\t}\n\t};\n\n\tconst isLoaderRequested = (): boolean => loaderRequested;\n\n\tconst enqueue = (envelope: CommandEnvelope): void => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tif (!window.__getuserfeedback_queue) {\n\t\t\twindow.__getuserfeedback_queue = [];\n\t\t}\n\t\t// Stamp instanceId and clientMeta so the loader can route commands.\n\t\tconst stamped: CommandEnvelope = {\n\t\t\t...envelope,\n\t\t\tinstanceId: envelope.instanceId ?? clientInstanceId,\n\t\t\tclientMeta: envelope.clientMeta ?? clientMeta,\n\t\t};\n\t\twindow.__getuserfeedback_queue.push(stamped);\n\t};\n\n\tconst enqueueInstanceRegistration = (requestId?: string): string => {\n\t\tconst registrationRequestId = requestId ?? createCommandRequestId();\n\t\tenqueue({\n\t\t\tversion: \"1\",\n\t\t\tinstanceId: clientInstanceId,\n\t\t\trequestId: registrationRequestId,\n\t\t\tidempotencyKey: registrationRequestId,\n\t\t\tcommand: { kind: \"init\", opts: buildInitOpts() },\n\t\t});\n\t\treturn registrationRequestId;\n\t};\n\n\tconst enqueueSetContainer = (\n\t\tflowHandleId: FlowHandleId,\n\t\telement: HTMLElement | null,\n\t): void => {\n\t\tconst requestId = createCommandRequestId();\n\t\tenqueue({\n\t\t\tversion: \"1\",\n\t\t\trequestId,\n\t\t\tidempotencyKey: requestId,\n\t\t\tcommand: { kind: \"setContainer\", flowHandleId, container: element },\n\t\t});\n\t};\n\n\tconst enqueueSetDefaultContainerPolicy = (policy: ContainerPolicy): void => {\n\t\tconst requestId = createCommandRequestId();\n\t\tenqueue({\n\t\t\tversion: \"1\",\n\t\t\trequestId,\n\t\t\tidempotencyKey: requestId,\n\t\t\tcommand: { kind: \"setDefaultContainerPolicy\", policy },\n\t\t});\n\t};\n\n\tconst reportAsyncError = <T>(promise: Promise<T>): Promise<T> => {\n\t\treturn promise.catch((error) => {\n\t\t\tnotifyError(error);\n\t\t\tthrow error;\n\t\t});\n\t};\n\n\tconst ensureCommandsCanRun = (): void => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tif (!isLoaderRequested()) {\n\t\t\tif (disableAutoLoadConfig) {\n\t\t\t\tthrow new Error(\"Widget not loaded. Call client.load() first.\");\n\t\t\t}\n\t\t\tload();\n\t\t}\n\t};\n\n\t/** Enqueue a command and await its settlement.\n\t * The loader resolves instanceId from the instance registry. */\n\tconst rawDispatch = createCommandDispatch((cmd) => enqueue(cmd));\n\tconst dispatch = async (input: Command): Promise<void> => {\n\t\tensureCommandsCanRun();\n\t\treturn rawDispatch(input);\n\t};\n\n\tconst enqueueConfigUpdate = (opts: ConfigureOptions): void => {\n\t\tif (!isLoaderRequested()) {\n\t\t\treturn;\n\t\t}\n\t\tconst requestId = createCommandRequestId();\n\t\tenqueue({\n\t\t\tversion: \"1\",\n\t\t\trequestId,\n\t\t\tidempotencyKey: requestId,\n\t\t\tcommand: { kind: \"configure\", opts },\n\t\t});\n\t};\n\n\tconst updateOptions = (next: ClientOptions): void => {\n\t\tdisableAutoLoadConfig = next.disableAutoLoad ?? disableAutoLoadConfig;\n\t\tdefaultConsentConfig = next.defaultConsent ?? defaultConsentConfig;\n\n\t\tif (next._cdn !== undefined && next._cdn !== _cdnConfig) {\n\t\t\tif (isLoaderRequested() || pendingLoad !== null) {\n\t\t\t\tconst error = new Error(\n\t\t\t\t\t\"_cdn cannot be changed after widget init; keeping original\",\n\t\t\t\t);\n\t\t\t\tnotifyError(error);\n\t\t\t} else {\n\t\t\t\t_cdnConfig = next._cdn;\n\t\t\t}\n\t\t}\n\n\t\tapplyStartupConfig(next);\n\n\t\tif (!disableAutoLoadConfig && !isLoaderRequested()) {\n\t\t\tload();\n\t\t}\n\t};\n\n\tconst applyStartupConfig = (next: ClientOptions): void => {\n\t\t// Send configure payload from next (colorScheme only from ClientOptions).\n\t\tif (!isLoaderRequested()) return;\n\t\tconst opts: ConfigureOptions = {};\n\t\tif (next.colorScheme !== undefined) opts.colorScheme = next.colorScheme;\n\t\tenqueueConfigUpdate(opts);\n\t};\n\n\tconst load = (): void => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tif (isLoaderRequested() || pendingLoad) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst appendLoaderScript = (): void => {\n\t\t\tconst cdnBase = _cdnConfig.endsWith(\"/\") ? _cdnConfig : `${_cdnConfig}/`;\n\t\t\tconst loaderScriptPath = `loader/${loaderVersion}/${encodeURIComponent(\n\t\t\t\tapiKey,\n\t\t\t)}/loader.js`;\n\t\t\tconst scriptUrl = new URL(loaderScriptPath, cdnBase).toString();\n\t\t\tif (!document.querySelector(`link[href=\"${scriptUrl}\"][rel=\"preload\"]`)) {\n\t\t\t\tconst preload = document.createElement(\"link\");\n\t\t\t\tpreload.rel = \"preload\";\n\t\t\t\tpreload.as = \"script\";\n\t\t\t\tpreload.href = scriptUrl;\n\t\t\t\tdocument.head.appendChild(preload);\n\t\t\t}\n\n\t\t\tconst script = document.createElement(\"script\");\n\t\t\tscript.src = scriptUrl;\n\t\t\tscript.async = true;\n\t\t\tif (script.dataset) {\n\t\t\t\tscript.dataset.disableAutoRegister = \"true\";\n\t\t\t} else if (typeof script.setAttribute === \"function\") {\n\t\t\t\tscript.setAttribute(\"data-disable-auto-register\", \"true\");\n\t\t\t}\n\t\t\tdocument.head.appendChild(script);\n\t\t};\n\n\t\tconst runtimeMarker = window[LOADER_RUNTIME_GLOBAL_KEY];\n\t\tif (runtimeMarker?.alive) {\n\t\t\tconst protocolVersion = runtimeMarker.protocolVersion;\n\t\t\tif (protocolVersion !== LOADER_RUNTIME_PROTOCOL_VERSION) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Incompatible loader runtime protocol: expected ${LOADER_RUNTIME_PROTOCOL_VERSION}, received ${protocolVersion ?? \"unknown\"}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tenqueueInstanceRegistration();\n\t\t\tloaderRequested = true;\n\t\t\treturn;\n\t\t}\n\n\t\tconst hasCommandQueue = Array.isArray(window.__getuserfeedback_queue);\n\t\tif (!hasCommandQueue) {\n\t\t\tconst requestId = enqueueInstanceRegistration();\n\t\t\tappendLoaderScript();\n\t\t\tloaderRequested = true;\n\t\t\tlet trackedPending: Promise<void>;\n\t\t\tconst pending = waitForCommandSettlement({\n\t\t\t\trequestId,\n\t\t\t\ttimeoutMs: LOADER_RUNTIME_POST_LOAD_TIMEOUT_MS,\n\t\t\t})\n\t\t\t\t.then(() => {})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tnotifyError(error);\n\t\t\t\t});\n\t\t\ttrackedPending = pending.finally(() => {\n\t\t\t\tif (pendingLoad === trackedPending) {\n\t\t\t\t\tpendingLoad = null;\n\t\t\t\t}\n\t\t\t});\n\t\t\tpendingLoad = trackedPending;\n\t\t\treturn;\n\t\t}\n\n\t\tloaderRequested = true;\n\n\t\tlet trackedPending: Promise<void>;\n\t\tconst pending = (async () => {\n\t\t\tconst requestId = createCommandRequestId();\n\t\t\tenqueueInstanceRegistration(requestId);\n\t\t\ttry {\n\t\t\t\tawait waitForCommandSettlement({\n\t\t\t\t\trequestId,\n\t\t\t\t\ttimeoutMs: LOADER_RUNTIME_PROBE_TIMEOUT_MS,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof CommandSettlementTimeoutError) {\n\t\t\t\t\tappendLoaderScript();\n\t\t\t\t\tawait waitForCommandSettlement({\n\t\t\t\t\t\trequestId,\n\t\t\t\t\t\ttimeoutMs: LOADER_RUNTIME_POST_LOAD_TIMEOUT_MS,\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})().catch((error) => {\n\t\t\tnotifyError(error);\n\t\t});\n\t\ttrackedPending = pending.finally(() => {\n\t\t\tif (pendingLoad === trackedPending) {\n\t\t\t\tpendingLoad = null;\n\t\t\t}\n\t\t});\n\t\tpendingLoad = trackedPending;\n\t};\n\n\tconst setContainerForHandle = (\n\t\tflowHandleId: FlowHandleId,\n\t\telement: HTMLElement | null,\n\t): void => {\n\t\t// Always enqueue — commands sit in the global queue until the\n\t\t// loader processes them. The command-router stores containers in\n\t\t// pendingContainer and applies them when a flow run is allocated.\n\t\tenqueueSetContainer(flowHandleId, element);\n\t};\n\n\tconst setDefaultContainer = (element: HTMLElement | null): void => {\n\t\tif (element === null) {\n\t\t\tenqueueSetDefaultContainerPolicy({ kind: \"floating\" });\n\t\t\treturn;\n\t\t}\n\t\tenqueueSetDefaultContainerPolicy({\n\t\t\tkind: \"hostContainer\",\n\t\t\thost: element,\n\t\t\tsharing: \"shared\",\n\t\t});\n\t};\n\n\tconst subscribeFlowStateForHandle = (\n\t\tflowHandleId: FlowHandleId,\n\t\tcallback: FlowStateCallback,\n\t\toptions?: SubscribeFlowStateOptions,\n\t): (() => void) => {\n\t\tif (options?.emitInitial ?? true) {\n\t\t\tcallback(getFlowStateForHandle(flowHandleId));\n\t\t}\n\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst eventName = toHostEventName(\n\t\t\tHOST_EVENT_KEYS.INSTANCE_FLOW_STATE_CHANGED,\n\t\t);\n\n\t\tconst handleFlowStateEvent = (event: Event): void => {\n\t\t\tconst detail = (event as CustomEvent<unknown>).detail;\n\t\t\tif (\n\t\t\t\t!isFlowStateChangedDetail(detail) ||\n\t\t\t\tdetail.flowHandleId !== flowHandleId\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextState: FlowState = {\n\t\t\t\tisOpen: detail.isOpen,\n\t\t\t\tisLoading: detail.isLoading,\n\t\t\t\twidth: detail.width,\n\t\t\t\theight: detail.height,\n\t\t\t};\n\t\t\tsetFlowStateForHandle(flowHandleId, nextState);\n\t\t\tcallback(cloneFlowState(nextState));\n\t\t};\n\n\t\tlet isUnsubscribed = false;\n\t\tconst signal = options?.signal;\n\t\tlet handleAbort: (() => void) | null = null;\n\n\t\tconst unsubscribe = (): void => {\n\t\t\tif (isUnsubscribed) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tisUnsubscribed = true;\n\t\t\twindow.removeEventListener(eventName, handleFlowStateEvent);\n\t\t\tif (signal && handleAbort) {\n\t\t\t\tsignal.removeEventListener(\"abort\", handleAbort);\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(eventName, handleFlowStateEvent);\n\n\t\tif (signal) {\n\t\t\thandleAbort = () => {\n\t\t\t\tunsubscribe();\n\t\t\t};\n\t\t\tif (signal.aborted) {\n\t\t\t\tunsubscribe();\n\t\t\t\treturn unsubscribe;\n\t\t\t}\n\t\t\tsignal.addEventListener(\"abort\", handleAbort, { once: true });\n\t\t}\n\n\t\treturn unsubscribe;\n\t};\n\n\tconst subscribeFlowStateForInstance = (\n\t\tcallback: FlowStateCallback,\n\t\toptions?: SubscribeFlowStateOptions,\n\t): (() => void) => {\n\t\tif (options?.emitInitial ?? true) {\n\t\t\tcallback(getInstanceFlowState());\n\t\t}\n\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst eventName = toHostEventName(\n\t\t\tHOST_EVENT_KEYS.INSTANCE_FLOW_STATE_CHANGED_INSTANCE,\n\t\t);\n\n\t\tconst handleFlowStateEvent = (event: Event): void => {\n\t\t\tconst detail = (event as CustomEvent<unknown>).detail;\n\t\t\tif (\n\t\t\t\t!isInstanceFlowStateChangedDetail(detail) ||\n\t\t\t\tdetail.instanceId !== clientInstanceId\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst nextState: FlowState = {\n\t\t\t\tisOpen: detail.isOpen,\n\t\t\t\tisLoading: detail.isLoading,\n\t\t\t\twidth: detail.width,\n\t\t\t\theight: detail.height,\n\t\t\t};\n\t\t\tsetInstanceFlowState(nextState);\n\t\t\tcallback(cloneFlowState(nextState));\n\t\t};\n\n\t\tlet isUnsubscribed = false;\n\t\tconst signal = options?.signal;\n\t\tlet handleAbort: (() => void) | null = null;\n\n\t\tconst unsubscribe = (): void => {\n\t\t\tif (isUnsubscribed) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tisUnsubscribed = true;\n\t\t\twindow.removeEventListener(eventName, handleFlowStateEvent);\n\t\t\tif (signal && handleAbort) {\n\t\t\t\tsignal.removeEventListener(\"abort\", handleAbort);\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(eventName, handleFlowStateEvent);\n\n\t\tif (signal) {\n\t\t\thandleAbort = () => {\n\t\t\t\tunsubscribe();\n\t\t\t};\n\t\t\tif (signal.aborted) {\n\t\t\t\tunsubscribe();\n\t\t\t\treturn unsubscribe;\n\t\t\t}\n\t\t\tsignal.addEventListener(\"abort\", handleAbort, { once: true });\n\t\t}\n\n\t\treturn unsubscribe;\n\t};\n\n\tconst createFlowRun = (flowIdInput: string): FlowRun => {\n\t\tconst flowId = flowIdInput;\n\t\tif (!flowId.trim()) {\n\t\t\tthrow new Error(\"flowId must be a non-empty string\");\n\t\t}\n\t\tconst flowHandleId = createFlowHandleId();\n\t\tensureFlowStateForHandle(flowHandleId);\n\n\t\treturn {\n\t\t\tflowId,\n\t\t\topen: (options?: OpenFlowOptions) => {\n\t\t\t\treturn reportAsyncError(\n\t\t\t\t\tdispatch({\n\t\t\t\t\t\tkind: \"open\",\n\t\t\t\t\t\tflowId,\n\t\t\t\t\t\tflowHandleId,\n\t\t\t\t\t\tcontainerRequirement: options?.containerRequirement,\n\t\t\t\t\t\thideCloseButton: options?.hideCloseButton,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t},\n\t\t\tprefetch: () => reportAsyncError(dispatch({ kind: \"prefetch\", flowId })),\n\t\t\tprerender: (options?: PrerenderFlowOptions) =>\n\t\t\t\treportAsyncError(\n\t\t\t\t\tdispatch({\n\t\t\t\t\t\tkind: \"prerender\",\n\t\t\t\t\t\tflowId,\n\t\t\t\t\t\tflowHandleId,\n\t\t\t\t\t\thideCloseButton: options?.hideCloseButton,\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\tclose: () => reportAsyncError(dispatch({ kind: \"close\", flowHandleId })),\n\t\t\tsetContainer: (element: HTMLElement | null) => {\n\t\t\t\tsetContainerForHandle(flowHandleId, element);\n\t\t\t},\n\t\t\tgetFlowState: () => getFlowStateForHandle(flowHandleId),\n\t\t\tsubscribeFlowState: (\n\t\t\t\tcallback: FlowStateCallback,\n\t\t\t\toptions?: SubscribeFlowStateOptions,\n\t\t\t) => subscribeFlowStateForHandle(flowHandleId, callback, options),\n\t\t};\n\t};\n\n\tconst flow = (flowIdInput: string): FlowRun => createFlowRun(flowIdInput);\n\n\tconst close = (): Promise<void> => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn reportAsyncError(dispatch({ kind: \"close\" }));\n\t};\n\n\tconst reset = (): Promise<void> => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn reportAsyncError(dispatch({ kind: \"reset\" }));\n\t};\n\n\tfunction identify(userId: string, traits?: IdentifyTraits): Promise<void>;\n\tfunction identify(traits: IdentifyTraits): Promise<void>;\n\tfunction identify(\n\t\tidentifyInput: string | IdentifyTraits,\n\t\ttraits?: IdentifyTraits,\n\t): Promise<void> {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn reportAsyncError(\n\t\t\tdispatch(toIdentifyCommandPayload(identifyInput, traits)),\n\t\t);\n\t}\n\n\tconst configure = (updates: ConfigureOptions): Promise<void> => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tif (!isLoaderRequested()) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\t// Send updates as-is; loader merges and forwards deltas to core.\n\t\treturn reportAsyncError(dispatch({ kind: \"configure\", opts: updates }));\n\t};\n\n\tconst client: Client = {\n\t\tload,\n\t\tsetDefaultContainerPolicy: (policy: ContainerPolicy) => {\n\t\t\tenqueueSetDefaultContainerPolicy(policy);\n\t\t},\n\t\tsetContainer: (element: HTMLElement | null) => {\n\t\t\tsetDefaultContainer(element);\n\t\t},\n\t\tgetFlowState: () => getInstanceFlowState(),\n\t\tsubscribeFlowState: (\n\t\t\tcallback: FlowStateCallback,\n\t\t\toptions?: SubscribeFlowStateOptions,\n\t\t) => subscribeFlowStateForInstance(callback, options),\n\t\tflow,\n\t\tclose,\n\t\treset,\n\t\tconfigure,\n\t\tidentify,\n\t};\n\n\tregistry.set(registryKey, {\n\t\tclient,\n\t\tupdateOptions,\n\t});\n\n\tif (!disableAutoLoadConfig) {\n\t\tclient.load();\n\t}\n\n\treturn client;\n};\n\nexport default createClient;\n"
12
13
  ],
13
- "mappings": "AAmCO,IAAM,EAAkB,CAC9B,4BAA6B,8BAC7B,qCAAsC,uCACtC,yBAA0B,2BAC1B,6BAA8B,+BAC9B,eAAgB,iBAChB,wBAAyB,0BACzB,0BAA2B,4BAC3B,sBAAuB,wBACvB,eAAgB,iBAChB,mBAAoB,oBACrB,EAIM,EAAiC,CACtC,UAAW,0BACX,KAAM,qBACN,SAAU,yBACV,UAAW,0BACX,SAAU,yBACV,MAAO,sBACP,MAAO,sBACP,aAAc,6BACd,0BAA2B,yCAC5B,EAKM,GAA2B,CAChC,E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Aa,KAAM,CAAQ,CAAC,CAAC,GAoBtE,WACD,EAOA,GALA,EAAS,IAAI,EAAa,CACzB,SACA,gBACD,CAAC,EAEG,CAAC,EACJ,EAAO,KAAK,EAGb,OAAO",
15
+ "debugId": "16106A19F80245A064756E2164756E21",
15
16
  "names": []
16
17
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@getuserfeedback/sdk",
3
- "version": "0.1.0",
4
- "description": "GetUserFeedback widget SDK for the browser",
3
+ "version": "0.3.0",
4
+ "description": "getuserfeedback Typescript SDK",
5
5
  "keywords": [
6
6
  "getuserfeedback",
7
7
  "feedback",
@@ -32,6 +32,9 @@
32
32
  "scripts": {
33
33
  "prepack": "node scripts/prepack.cjs",
34
34
  "postpack": "node scripts/postpack.cjs",
35
+ "pack:verify": "node ../../scripts/pack-and-verify.cjs",
36
+ "publish:dry-run": "node ../../scripts/publish-package.cjs . -- --dry-run",
37
+ "publish:npm": "node ../../scripts/publish-package.cjs .",
35
38
  "build": "bun x rimraf dist tsconfig.tsbuildinfo && bun run scripts/build.ts && bun x rollup -c rollup.dts.config.mjs",
36
39
  "typecheck": "tsc -b tsconfig.json",
37
40
  "test": "bun test"