@foxpixel/react 0.1.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/dist/index.js ADDED
@@ -0,0 +1,495 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ AuthProvider: () => AuthProvider,
34
+ FoxPixelHttpClient: () => FoxPixelHttpClient,
35
+ FoxPixelProvider: () => FoxPixelProvider,
36
+ GuestOnlyRoute: () => GuestOnlyRoute,
37
+ ProtectedRoute: () => ProtectedRoute,
38
+ useAuth: () => useAuth,
39
+ useContactCapture: () => useContactCapture,
40
+ useFoxPixelContext: () => useFoxPixelContext,
41
+ useLeadCapture: () => useLeadCapture,
42
+ useServices: () => useServices,
43
+ withAuth: () => withAuth
44
+ });
45
+ module.exports = __toCommonJS(index_exports);
46
+
47
+ // src/context/FoxPixelContext.tsx
48
+ var import_react = require("react");
49
+
50
+ // src/client/http.ts
51
+ var import_axios = __toESM(require("axios"));
52
+ var FoxPixelHttpClient = class {
53
+ constructor(config) {
54
+ const apiUrl = config.apiUrl || process.env.NEXT_PUBLIC_FOXPIXEL_API_URL || "https://api.foxpixel.com";
55
+ this.client = import_axios.default.create({
56
+ baseURL: apiUrl,
57
+ headers: {
58
+ "Content-Type": "application/json"
59
+ },
60
+ withCredentials: true
61
+ // Important for httpOnly cookies (End User auth)
62
+ });
63
+ this.apiKey = config.apiKey || process.env.FOXPIXEL_API_KEY;
64
+ this.tenantId = config.tenantId;
65
+ this.client.interceptors.request.use(
66
+ (config2) => {
67
+ if (this.endUserToken) {
68
+ } else if (this.apiKey) {
69
+ config2.headers["Authorization"] = `Bearer ${this.apiKey}`;
70
+ }
71
+ return config2;
72
+ },
73
+ (error) => Promise.reject(error)
74
+ );
75
+ this.client.interceptors.response.use(
76
+ (response) => response,
77
+ (error) => {
78
+ const apiError = {
79
+ message: "An error occurred",
80
+ status: error.response?.status
81
+ };
82
+ if (error.response?.data) {
83
+ const data = error.response.data;
84
+ apiError.message = data.message || data.error || apiError.message;
85
+ apiError.code = data.code;
86
+ }
87
+ const requestUrl = error.config?.url || "";
88
+ const isMeEndpoint = requestUrl.includes("/auth/end-user/me");
89
+ const isUnauthorized = error.response?.status === 401;
90
+ if (isMeEndpoint && isUnauthorized) {
91
+ apiError.expected = true;
92
+ }
93
+ return Promise.reject(apiError);
94
+ }
95
+ );
96
+ }
97
+ /**
98
+ * Set API Key (server-side only)
99
+ */
100
+ setApiKey(apiKey) {
101
+ this.apiKey = apiKey;
102
+ }
103
+ /**
104
+ * Set tenant ID
105
+ */
106
+ setTenantId(tenantId) {
107
+ this.tenantId = tenantId;
108
+ }
109
+ /**
110
+ * Set end user token (for client-side auth)
111
+ * Note: In practice, end user auth uses httpOnly cookies
112
+ */
113
+ setEndUserToken(token) {
114
+ this.endUserToken = token;
115
+ }
116
+ /**
117
+ * Clear end user token (logout)
118
+ */
119
+ clearEndUserToken() {
120
+ this.endUserToken = void 0;
121
+ }
122
+ /**
123
+ * Get underlying axios instance
124
+ */
125
+ getInstance() {
126
+ return this.client;
127
+ }
128
+ /**
129
+ * Make GET request
130
+ */
131
+ async get(url, config) {
132
+ const response = await this.client.get(url, config);
133
+ return response.data;
134
+ }
135
+ /**
136
+ * Make POST request
137
+ */
138
+ async post(url, data, config) {
139
+ const response = await this.client.post(url, data, config);
140
+ return response.data;
141
+ }
142
+ /**
143
+ * Make PUT request
144
+ */
145
+ async put(url, data, config) {
146
+ const response = await this.client.put(url, data, config);
147
+ return response.data;
148
+ }
149
+ /**
150
+ * Make DELETE request
151
+ */
152
+ async delete(url, config) {
153
+ const response = await this.client.delete(url, config);
154
+ return response.data;
155
+ }
156
+ };
157
+
158
+ // src/context/FoxPixelContext.tsx
159
+ var import_jsx_runtime = require("react/jsx-runtime");
160
+ var FoxPixelContext = (0, import_react.createContext)(null);
161
+ function FoxPixelProvider({ children, config = {} }) {
162
+ const client = (0, import_react.useMemo)(() => {
163
+ return new FoxPixelHttpClient(config);
164
+ }, [config.apiUrl, config.apiKey, config.tenantId]);
165
+ const value = (0, import_react.useMemo)(() => ({
166
+ client,
167
+ config
168
+ }), [client, config]);
169
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FoxPixelContext.Provider, { value, children });
170
+ }
171
+ function useFoxPixelContext() {
172
+ const context = (0, import_react.useContext)(FoxPixelContext);
173
+ if (!context) {
174
+ throw new Error("useFoxPixelContext must be used within FoxPixelProvider");
175
+ }
176
+ return context;
177
+ }
178
+
179
+ // src/context/AuthContext.tsx
180
+ var import_react2 = require("react");
181
+ var import_jsx_runtime2 = require("react/jsx-runtime");
182
+ var AuthContext = (0, import_react2.createContext)(null);
183
+ function AuthProvider({
184
+ children,
185
+ loginPath = "/login",
186
+ accountPath = "/account"
187
+ }) {
188
+ const { client } = useFoxPixelContext();
189
+ const [user, setUser] = (0, import_react2.useState)(null);
190
+ const [isLoading, setIsLoading] = (0, import_react2.useState)(true);
191
+ const [error, setError] = (0, import_react2.useState)(null);
192
+ const fetchCurrentUser = (0, import_react2.useCallback)(async () => {
193
+ try {
194
+ setIsLoading(true);
195
+ setError(null);
196
+ const response = await client.get("/api/v1/auth/end-user/me");
197
+ setUser(response);
198
+ } catch (err) {
199
+ const apiError = err;
200
+ if (apiError.status !== 401 && !apiError.expected) {
201
+ setError(apiError);
202
+ }
203
+ setUser(null);
204
+ } finally {
205
+ setIsLoading(false);
206
+ }
207
+ }, [client]);
208
+ const login = (0, import_react2.useCallback)(async (credentials) => {
209
+ try {
210
+ setIsLoading(true);
211
+ setError(null);
212
+ const response = await client.post(
213
+ "/api/v1/auth/end-user/login",
214
+ credentials
215
+ );
216
+ setUser(response.user);
217
+ } catch (err) {
218
+ const apiError = err;
219
+ setError(apiError);
220
+ setUser(null);
221
+ throw apiError;
222
+ } finally {
223
+ setIsLoading(false);
224
+ }
225
+ }, [client]);
226
+ const register = (0, import_react2.useCallback)(async (data) => {
227
+ try {
228
+ setIsLoading(true);
229
+ setError(null);
230
+ const response = await client.post(
231
+ "/api/v1/auth/end-user/register",
232
+ data
233
+ );
234
+ setUser(response.user);
235
+ } catch (err) {
236
+ const apiError = err;
237
+ setError(apiError);
238
+ setUser(null);
239
+ throw apiError;
240
+ } finally {
241
+ setIsLoading(false);
242
+ }
243
+ }, [client]);
244
+ const updateProfile = (0, import_react2.useCallback)(async (data) => {
245
+ try {
246
+ setIsLoading(true);
247
+ setError(null);
248
+ const response = await client.put(
249
+ "/api/v1/auth/end-user/me",
250
+ data
251
+ );
252
+ setUser(response);
253
+ } catch (err) {
254
+ const apiError = err;
255
+ setError(apiError);
256
+ throw apiError;
257
+ } finally {
258
+ setIsLoading(false);
259
+ }
260
+ }, [client]);
261
+ const logout = (0, import_react2.useCallback)(async () => {
262
+ try {
263
+ setIsLoading(true);
264
+ setError(null);
265
+ await client.post("/api/v1/auth/end-user/logout", {});
266
+ setUser(null);
267
+ } catch (err) {
268
+ const apiError = err;
269
+ setError(apiError);
270
+ setUser(null);
271
+ } finally {
272
+ setIsLoading(false);
273
+ }
274
+ }, [client]);
275
+ (0, import_react2.useEffect)(() => {
276
+ fetchCurrentUser();
277
+ }, [fetchCurrentUser]);
278
+ const value = {
279
+ user,
280
+ isLoading,
281
+ isAuthenticated: user !== null,
282
+ error,
283
+ login,
284
+ logout,
285
+ register,
286
+ updateProfile,
287
+ refetch: fetchCurrentUser
288
+ };
289
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AuthContext.Provider, { value, children });
290
+ }
291
+ function useAuth() {
292
+ const context = (0, import_react2.useContext)(AuthContext);
293
+ if (!context) {
294
+ throw new Error("useAuth must be used within AuthProvider");
295
+ }
296
+ return context;
297
+ }
298
+
299
+ // src/components/ProtectedRoute.tsx
300
+ var import_react3 = require("react");
301
+ var import_jsx_runtime3 = require("react/jsx-runtime");
302
+ function ProtectedRoute({
303
+ children,
304
+ loginPath = "/login",
305
+ loadingComponent
306
+ }) {
307
+ const { isAuthenticated, isLoading } = useAuth();
308
+ const [isMounted, setIsMounted] = (0, import_react3.useState)(false);
309
+ (0, import_react3.useEffect)(() => {
310
+ setIsMounted(true);
311
+ }, []);
312
+ (0, import_react3.useEffect)(() => {
313
+ if (!isMounted || typeof window === "undefined") return;
314
+ if (!isLoading && !isAuthenticated) {
315
+ const returnUrl = window.location.pathname + window.location.search;
316
+ const url = `${loginPath}?returnUrl=${encodeURIComponent(returnUrl)}`;
317
+ window.location.href = url;
318
+ }
319
+ }, [isMounted, isLoading, isAuthenticated, loginPath]);
320
+ if (!isMounted || isLoading) {
321
+ return loadingComponent || /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "text-gray-500", children: "Carregando..." }) });
322
+ }
323
+ if (!isAuthenticated) {
324
+ return null;
325
+ }
326
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children });
327
+ }
328
+
329
+ // src/components/GuestOnlyRoute.tsx
330
+ var import_react4 = require("react");
331
+ var import_jsx_runtime4 = require("react/jsx-runtime");
332
+ var ACCOUNT_PREFIX = "/account";
333
+ function isSafeRedirect(url) {
334
+ if (!url || url.startsWith("//") || url.includes(":")) return false;
335
+ return url.startsWith("/") && url.startsWith(ACCOUNT_PREFIX);
336
+ }
337
+ function GuestOnlyRoute({
338
+ children,
339
+ redirectTo = "/account",
340
+ loadingComponent
341
+ }) {
342
+ const { isAuthenticated, isLoading } = useAuth();
343
+ const [isMounted, setIsMounted] = (0, import_react4.useState)(false);
344
+ (0, import_react4.useEffect)(() => {
345
+ setIsMounted(true);
346
+ }, []);
347
+ (0, import_react4.useEffect)(() => {
348
+ if (!isMounted || typeof window === "undefined") return;
349
+ if (isLoading) return;
350
+ if (!isAuthenticated) return;
351
+ const params = new URLSearchParams(window.location.search);
352
+ const returnUrl = params.get("returnUrl");
353
+ const destination = returnUrl && isSafeRedirect(returnUrl) ? returnUrl : redirectTo;
354
+ window.location.href = destination;
355
+ }, [isMounted, isLoading, isAuthenticated, redirectTo]);
356
+ if (!isMounted || isLoading) {
357
+ return loadingComponent || /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "text-gray-500", children: "Carregando..." }) });
358
+ }
359
+ if (isAuthenticated) {
360
+ return loadingComponent || /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "text-gray-500", children: "A redirecionar..." }) });
361
+ }
362
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children });
363
+ }
364
+
365
+ // src/components/withAuth.tsx
366
+ var import_react5 = require("react");
367
+ var import_jsx_runtime5 = require("react/jsx-runtime");
368
+ function withAuth(Component, options = {}) {
369
+ const { loginPath = "/login", loadingComponent } = options;
370
+ return function AuthenticatedComponent(props) {
371
+ const { isAuthenticated, isLoading } = useAuth();
372
+ const [isMounted, setIsMounted] = (0, import_react5.useState)(false);
373
+ (0, import_react5.useEffect)(() => {
374
+ setIsMounted(true);
375
+ }, []);
376
+ (0, import_react5.useEffect)(() => {
377
+ if (!isMounted || typeof window === "undefined") return;
378
+ if (!isLoading && !isAuthenticated) {
379
+ const returnUrl = window.location.pathname + window.location.search;
380
+ window.location.href = `${loginPath}?returnUrl=${encodeURIComponent(returnUrl)}`;
381
+ }
382
+ }, [isMounted, isLoading, isAuthenticated, loginPath]);
383
+ if (!isMounted || isLoading) {
384
+ return loadingComponent || /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "text-gray-500", children: "Carregando..." }) });
385
+ }
386
+ if (!isAuthenticated) {
387
+ return null;
388
+ }
389
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Component, { ...props });
390
+ };
391
+ }
392
+
393
+ // src/hooks/useServices.ts
394
+ var import_react6 = require("react");
395
+ function useServices(options = {}) {
396
+ const { client } = useFoxPixelContext();
397
+ const [services, setServices] = (0, import_react6.useState)(null);
398
+ const [isLoading, setIsLoading] = (0, import_react6.useState)(true);
399
+ const [error, setError] = (0, import_react6.useState)(null);
400
+ const fetchServices = async () => {
401
+ try {
402
+ setIsLoading(true);
403
+ setError(null);
404
+ const params = new URLSearchParams();
405
+ if (options.category) params.append("category", options.category);
406
+ if (options.active !== void 0) params.append("active", String(options.active));
407
+ const url = `/api/v1/services${params.toString() ? `?${params.toString()}` : ""}`;
408
+ const data = await client.get(url);
409
+ setServices(data);
410
+ } catch (err) {
411
+ setError(err);
412
+ setServices(null);
413
+ } finally {
414
+ setIsLoading(false);
415
+ }
416
+ };
417
+ (0, import_react6.useEffect)(() => {
418
+ fetchServices();
419
+ }, [options.category, options.active]);
420
+ return {
421
+ services,
422
+ isLoading,
423
+ error,
424
+ refetch: fetchServices
425
+ };
426
+ }
427
+
428
+ // src/hooks/useLeadCapture.ts
429
+ var import_react7 = require("react");
430
+ function useLeadCapture() {
431
+ const { client } = useFoxPixelContext();
432
+ const [isLoading, setIsLoading] = (0, import_react7.useState)(false);
433
+ const [error, setError] = (0, import_react7.useState)(null);
434
+ const captureLead = async (data) => {
435
+ try {
436
+ setIsLoading(true);
437
+ setError(null);
438
+ const lead = await client.post("/api/v1/leads", data);
439
+ return lead;
440
+ } catch (err) {
441
+ const apiError = err;
442
+ setError(apiError);
443
+ throw apiError;
444
+ } finally {
445
+ setIsLoading(false);
446
+ }
447
+ };
448
+ return {
449
+ captureLead,
450
+ isLoading,
451
+ error
452
+ };
453
+ }
454
+
455
+ // src/hooks/useContactCapture.ts
456
+ var import_react8 = require("react");
457
+ function useContactCapture() {
458
+ const { client } = useFoxPixelContext();
459
+ const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
460
+ const [error, setError] = (0, import_react8.useState)(null);
461
+ const captureContact = async (data) => {
462
+ try {
463
+ setIsLoading(true);
464
+ setError(null);
465
+ const contact = await client.post("/api/v1/contacts", data);
466
+ return contact;
467
+ } catch (err) {
468
+ const apiError = err;
469
+ setError(apiError);
470
+ throw apiError;
471
+ } finally {
472
+ setIsLoading(false);
473
+ }
474
+ };
475
+ return {
476
+ captureContact,
477
+ isLoading,
478
+ error
479
+ };
480
+ }
481
+ // Annotate the CommonJS export names for ESM import in node:
482
+ 0 && (module.exports = {
483
+ AuthProvider,
484
+ FoxPixelHttpClient,
485
+ FoxPixelProvider,
486
+ GuestOnlyRoute,
487
+ ProtectedRoute,
488
+ useAuth,
489
+ useContactCapture,
490
+ useFoxPixelContext,
491
+ useLeadCapture,
492
+ useServices,
493
+ withAuth
494
+ });
495
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/context/FoxPixelContext.tsx","../src/client/http.ts","../src/context/AuthContext.tsx","../src/components/ProtectedRoute.tsx","../src/components/GuestOnlyRoute.tsx","../src/components/withAuth.tsx","../src/hooks/useServices.ts","../src/hooks/useLeadCapture.ts","../src/hooks/useContactCapture.ts"],"sourcesContent":["/**\n * @foxpixel/react - React SDK for FoxPixel API\n * \n * Headless integration for custom sites and portals\n */\n\n// Context and Provider\nexport { FoxPixelProvider, useFoxPixelContext } from './context/FoxPixelContext';\nexport { AuthProvider, useAuth } from './context/AuthContext';\n\n// Components\nexport { ProtectedRoute } from './components/ProtectedRoute';\nexport { GuestOnlyRoute } from './components/GuestOnlyRoute';\nexport { withAuth } from './components/withAuth';\n\n// Hooks\nexport { useServices } from './hooks/useServices';\nexport { useLeadCapture } from './hooks/useLeadCapture';\nexport { useContactCapture } from './hooks/useContactCapture';\n\n// Types\nexport type {\n FoxPixelConfig,\n Service,\n ServiceCatalogResponse,\n Lead,\n CreateLeadRequest,\n EndUser,\n EndUserLoginRequest,\n ApiError,\n} from './types';\n\n// HTTP Client (for advanced usage)\nexport { FoxPixelHttpClient } from './client/http';\n","/**\n * React Context for FoxPixel SDK\n * Provides HTTP client and configuration to all hooks\n */\n\nimport React, { createContext, useContext, useMemo, ReactNode } from 'react';\nimport { FoxPixelHttpClient } from '../client/http';\nimport { FoxPixelConfig } from '../types';\n\ninterface FoxPixelContextValue {\n client: FoxPixelHttpClient;\n config: FoxPixelConfig;\n}\n\nconst FoxPixelContext = createContext<FoxPixelContextValue | null>(null);\n\nexport interface FoxPixelProviderProps {\n children: ReactNode;\n config?: FoxPixelConfig;\n}\n\n/**\n * FoxPixelProvider - Wraps your app and provides SDK functionality\n * \n * IMPORTANT: API Key should NEVER be passed from client-side.\n * Use server-side proxy (Next.js API routes) for API Key authentication.\n * \n * @example\n * ```tsx\n * // Client-side (no API Key)\n * <FoxPixelProvider>\n * <App />\n * </FoxPixelProvider>\n * \n * // Server-side proxy (Next.js API route)\n * // pages/api/foxpixel/[...path].ts\n * export default async function handler(req, res) {\n * const apiKey = process.env.FOXPIXEL_API_KEY;\n * // Proxy request with API Key\n * }\n * ```\n */\nexport function FoxPixelProvider({ children, config = {} }: FoxPixelProviderProps) {\n const client = useMemo(() => {\n return new FoxPixelHttpClient(config);\n }, [config.apiUrl, config.apiKey, config.tenantId]);\n\n const value = useMemo(() => ({\n client,\n config,\n }), [client, config]);\n\n return (\n <FoxPixelContext.Provider value={value}>\n {children}\n </FoxPixelContext.Provider>\n );\n}\n\n/**\n * Hook to access FoxPixel context\n * @throws Error if used outside FoxPixelProvider\n */\nexport function useFoxPixelContext(): FoxPixelContextValue {\n const context = useContext(FoxPixelContext);\n \n if (!context) {\n throw new Error('useFoxPixelContext must be used within FoxPixelProvider');\n }\n \n return context;\n}\n","/**\n * HTTP client for FoxPixel API\n * Handles authentication and request/response transformation\n */\n\nimport axios, { AxiosInstance, AxiosRequestConfig, AxiosError } from 'axios';\nimport { FoxPixelConfig, ApiError } from '../types';\n\nexport class FoxPixelHttpClient {\n private client: AxiosInstance;\n private apiKey?: string;\n private tenantId?: string;\n private endUserToken?: string;\n\n constructor(config: FoxPixelConfig) {\n const apiUrl = config.apiUrl || process.env.NEXT_PUBLIC_FOXPIXEL_API_URL || 'https://api.foxpixel.com';\n \n this.client = axios.create({\n baseURL: apiUrl,\n headers: {\n 'Content-Type': 'application/json',\n },\n withCredentials: true, // Important for httpOnly cookies (End User auth)\n });\n\n this.apiKey = config.apiKey || process.env.FOXPIXEL_API_KEY;\n this.tenantId = config.tenantId;\n\n // Setup request interceptor\n this.client.interceptors.request.use(\n (config) => {\n // If end user is logged in, use their token\n // Otherwise, use API Key (server-side only)\n if (this.endUserToken) {\n // End user token is sent via httpOnly cookie automatically\n // No need to set Authorization header\n } else if (this.apiKey) {\n // API Key should only be used server-side\n // In production, this should be proxied through Next.js API routes\n config.headers['Authorization'] = `Bearer ${this.apiKey}`;\n }\n return config;\n },\n (error) => Promise.reject(error)\n );\n\n // Setup response interceptor for error handling\n this.client.interceptors.response.use(\n (response) => response,\n (error: AxiosError) => {\n const apiError: ApiError = {\n message: 'An error occurred',\n status: error.response?.status,\n };\n\n if (error.response?.data) {\n const data = error.response.data as any;\n apiError.message = data.message || data.error || apiError.message;\n apiError.code = data.code;\n }\n\n // Mark 401 on /me endpoint as \"expected\" (not an error)\n // 401 is expected when checking if user is logged in (no cookie = not logged in)\n // The hook (useAuth) will handle this gracefully by ignoring 401\n const requestUrl = error.config?.url || '';\n const isMeEndpoint = requestUrl.includes('/auth/end-user/me');\n const isUnauthorized = error.response?.status === 401;\n\n if (isMeEndpoint && isUnauthorized) {\n // Mark as expected error (hook will handle silently)\n apiError.expected = true;\n }\n\n return Promise.reject(apiError);\n }\n );\n }\n\n /**\n * Set API Key (server-side only)\n */\n setApiKey(apiKey: string) {\n this.apiKey = apiKey;\n }\n\n /**\n * Set tenant ID\n */\n setTenantId(tenantId: string) {\n this.tenantId = tenantId;\n }\n\n /**\n * Set end user token (for client-side auth)\n * Note: In practice, end user auth uses httpOnly cookies\n */\n setEndUserToken(token: string) {\n this.endUserToken = token;\n }\n\n /**\n * Clear end user token (logout)\n */\n clearEndUserToken() {\n this.endUserToken = undefined;\n }\n\n /**\n * Get underlying axios instance\n */\n getInstance(): AxiosInstance {\n return this.client;\n }\n\n /**\n * Make GET request\n */\n async get<T>(url: string, config?: AxiosRequestConfig): Promise<T> {\n const response = await this.client.get<T>(url, config);\n return response.data;\n }\n\n /**\n * Make POST request\n */\n async post<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T> {\n const response = await this.client.post<T>(url, data, config);\n return response.data;\n }\n\n /**\n * Make PUT request\n */\n async put<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T> {\n const response = await this.client.put<T>(url, data, config);\n return response.data;\n }\n\n /**\n * Make DELETE request\n */\n async delete<T>(url: string, config?: AxiosRequestConfig): Promise<T> {\n const response = await this.client.delete<T>(url, config);\n return response.data;\n }\n}\n","/**\n * Global Authentication Context\n * Manages authentication state across the entire application\n * Automatically handles session restoration on page reload\n */\n\nimport React, { createContext, useContext, useEffect, useState, useCallback, ReactNode } from 'react';\nimport { useFoxPixelContext } from './FoxPixelContext';\nimport { EndUser, EndUserLoginRequest, ApiError } from '../types';\n\ninterface AuthContextValue {\n user: EndUser | null;\n isLoading: boolean;\n isAuthenticated: boolean;\n error: ApiError | null;\n login: (credentials: EndUserLoginRequest) => Promise<void>;\n logout: () => Promise<void>;\n register: (data: { email: string; password: string; fullName: string; phone?: string }) => Promise<void>;\n updateProfile: (data: { fullName?: string; phone?: string }) => Promise<void>;\n refetch: () => Promise<void>;\n}\n\nconst AuthContext = createContext<AuthContextValue | null>(null);\n\nexport interface AuthProviderProps {\n children: ReactNode;\n /**\n * Redirect path when user is not authenticated\n * Default: '/login'\n */\n loginPath?: string;\n /**\n * Redirect path after successful login\n * Default: '/account'\n */\n accountPath?: string;\n}\n\n/**\n * AuthProvider - Manages authentication state globally\n * \n * Automatically:\n * - Restores session on mount (checks httpOnly cookie)\n * - Manages user state across the app\n * - Handles login/logout transparently\n * \n * @example\n * ```tsx\n * // In _app.tsx\n * <FoxPixelProvider>\n * <AuthProvider>\n * <Component {...pageProps} />\n * </AuthProvider>\n * </FoxPixelProvider>\n * ```\n */\nexport function AuthProvider({ \n children, \n loginPath = '/login',\n accountPath = '/account'\n}: AuthProviderProps) {\n const { client } = useFoxPixelContext();\n const [user, setUser] = useState<EndUser | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n /**\n * Fetch current user from backend\n * Automatically called on mount to restore session\n */\n const fetchCurrentUser = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n\n const response = await client.get<EndUser>('/api/v1/auth/end-user/me');\n setUser(response);\n } catch (err) {\n const apiError = err as ApiError;\n \n // 401 is expected when not logged in (no cookie)\n // Don't treat it as an error\n if (apiError.status !== 401 && !apiError.expected) {\n setError(apiError);\n }\n \n setUser(null);\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n /**\n * Login with email and password\n * Token is automatically stored in httpOnly cookie by backend\n */\n const login = useCallback(async (credentials: EndUserLoginRequest) => {\n try {\n setIsLoading(true);\n setError(null);\n\n const response = await client.post<{ user: EndUser; message: string }>(\n '/api/v1/auth/end-user/login',\n credentials\n );\n\n setUser(response.user);\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n setUser(null);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n /**\n * Register new user\n * Automatically logs in after registration (backend sets cookie)\n */\n const register = useCallback(async (data: { \n email: string; \n password: string; \n fullName: string; \n phone?: string \n }) => {\n try {\n setIsLoading(true);\n setError(null);\n\n const response = await client.post<{ user: EndUser; message: string }>(\n '/api/v1/auth/end-user/register',\n data\n );\n\n // Backend automatically logs in after registration (cookie is set)\n setUser(response.user);\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n setUser(null);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n /**\n * Update user profile (fullName, phone)\n * Automatically refreshes user data after update\n */\n const updateProfile = useCallback(async (data: { fullName?: string; phone?: string }) => {\n try {\n setIsLoading(true);\n setError(null);\n\n const response = await client.put<EndUser>(\n '/api/v1/auth/end-user/me',\n data\n );\n\n // Update user state with new data\n setUser(response);\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n /**\n * Logout (removes httpOnly cookie)\n */\n const logout = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n\n await client.post('/api/v1/auth/end-user/logout', {});\n setUser(null);\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n // Even if logout fails, clear user state\n setUser(null);\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n // Restore session on mount (check if user is already logged in)\n useEffect(() => {\n fetchCurrentUser();\n }, [fetchCurrentUser]);\n\n const value: AuthContextValue = {\n user,\n isLoading,\n isAuthenticated: user !== null,\n error,\n login,\n logout,\n register,\n updateProfile,\n refetch: fetchCurrentUser,\n };\n\n return (\n <AuthContext.Provider value={value}>\n {children}\n </AuthContext.Provider>\n );\n}\n\n/**\n * Hook to access authentication context\n * @throws Error if used outside AuthProvider\n */\nexport function useAuth(): AuthContextValue {\n const context = useContext(AuthContext);\n \n if (!context) {\n throw new Error('useAuth must be used within AuthProvider');\n }\n \n return context;\n}\n","/**\n * ProtectedRoute - Automatically protects pages/routes\n * Redirects to login if user is not authenticated\n *\n * Does NOT use next/router (useRouter) to avoid \"NextRouter was not mounted\"\n * during SSR. Uses window.location for redirect instead.\n *\n * Usage:\n * ```tsx\n * export default function Dashboard() {\n * return (\n * <ProtectedRoute>\n * <YourContent />\n * </ProtectedRoute>\n * );\n * }\n * ```\n */\n\nimport { ReactNode, useEffect, useState } from 'react';\nimport { useAuth } from '../context/AuthContext';\n\ninterface ProtectedRouteProps {\n children: ReactNode;\n /**\n * Redirect path when not authenticated\n * Default: '/login'\n */\n loginPath?: string;\n /**\n * Show loading spinner while checking auth\n */\n loadingComponent?: ReactNode;\n}\n\nexport function ProtectedRoute({\n children,\n loginPath = '/login',\n loadingComponent,\n}: ProtectedRouteProps) {\n const { isAuthenticated, isLoading } = useAuth();\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n useEffect(() => {\n if (!isMounted || typeof window === 'undefined') return;\n if (!isLoading && !isAuthenticated) {\n const returnUrl = window.location.pathname + window.location.search;\n const url = `${loginPath}?returnUrl=${encodeURIComponent(returnUrl)}`;\n window.location.href = url;\n }\n }, [isMounted, isLoading, isAuthenticated, loginPath]);\n\n // SSR or loading: show placeholder (no useRouter)\n if (!isMounted || isLoading) {\n return (\n loadingComponent || (\n <div className=\"flex items-center justify-center min-h-screen\">\n <div className=\"text-gray-500\">Carregando...</div>\n </div>\n )\n );\n }\n\n if (!isAuthenticated) {\n return null;\n }\n\n return <>{children}</>;\n}\n","/**\n * GuestOnlyRoute - For login/register pages\n * If user is already authenticated, redirects to account (or returnUrl).\n * Otherwise renders children (login/register form).\n *\n * Does NOT use next/router (avoids SSR issues). Uses window.location.\n *\n * Usage:\n * ```tsx\n * export default function Login() {\n * return (\n * <GuestOnlyRoute>\n * <LoginForm />\n * </GuestOnlyRoute>\n * );\n * }\n * ```\n */\n\nimport { ReactNode, useEffect, useState } from 'react';\nimport { useAuth } from '../context/AuthContext';\n\ninterface GuestOnlyRouteProps {\n children: ReactNode;\n /**\n * Where to redirect when already authenticated.\n * Default: '/account'\n */\n redirectTo?: string;\n /**\n * Show this while checking auth or redirecting.\n */\n loadingComponent?: ReactNode;\n}\n\n/** Base path for account area. returnUrl must start with this to be trusted. */\nconst ACCOUNT_PREFIX = '/account';\n\nfunction isSafeRedirect(url: string): boolean {\n if (!url || url.startsWith('//') || url.includes(':')) return false;\n return url.startsWith('/') && url.startsWith(ACCOUNT_PREFIX);\n}\n\nexport function GuestOnlyRoute({\n children,\n redirectTo = '/account',\n loadingComponent,\n}: GuestOnlyRouteProps) {\n const { isAuthenticated, isLoading } = useAuth();\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n useEffect(() => {\n if (!isMounted || typeof window === 'undefined') return;\n if (isLoading) return;\n if (!isAuthenticated) return;\n\n const params = new URLSearchParams(window.location.search);\n const returnUrl = params.get('returnUrl');\n const destination =\n returnUrl && isSafeRedirect(returnUrl) ? returnUrl : redirectTo;\n window.location.href = destination;\n }, [isMounted, isLoading, isAuthenticated, redirectTo]);\n\n if (!isMounted || isLoading) {\n return (\n loadingComponent || (\n <div className=\"flex items-center justify-center min-h-screen\">\n <div className=\"text-gray-500\">Carregando...</div>\n </div>\n )\n );\n }\n\n if (isAuthenticated) {\n return (\n loadingComponent || (\n <div className=\"flex items-center justify-center min-h-screen\">\n <div className=\"text-gray-500\">A redirecionar...</div>\n </div>\n )\n );\n }\n\n return <>{children}</>;\n}\n","/**\n * Higher-Order Component (HOC) to protect components\n * Automatically redirects to login if user is not authenticated\n *\n * Does NOT use next/router to avoid SSR \"NextRouter was not mounted\".\n * Uses window.location for redirect.\n *\n * Usage:\n * ```tsx\n * function MyProtectedPage() {\n * return <div>Protected Content</div>;\n * }\n * export default withAuth(MyProtectedPage);\n * ```\n */\n\nimport { ComponentType, useEffect, useState, ReactNode } from 'react';\nimport { useAuth } from '../context/AuthContext';\n\ninterface WithAuthOptions {\n loginPath?: string;\n loadingComponent?: ReactNode;\n}\n\nexport function withAuth<P extends object>(\n Component: ComponentType<P>,\n options: WithAuthOptions = {}\n) {\n const { loginPath = '/login', loadingComponent } = options;\n\n return function AuthenticatedComponent(props: P) {\n const { isAuthenticated, isLoading } = useAuth();\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n useEffect(() => {\n if (!isMounted || typeof window === 'undefined') return;\n if (!isLoading && !isAuthenticated) {\n const returnUrl = window.location.pathname + window.location.search;\n window.location.href = `${loginPath}?returnUrl=${encodeURIComponent(returnUrl)}`;\n }\n }, [isMounted, isLoading, isAuthenticated, loginPath]);\n\n if (!isMounted || isLoading) {\n return (\n loadingComponent || (\n <div className=\"flex items-center justify-center min-h-screen\">\n <div className=\"text-gray-500\">Carregando...</div>\n </div>\n )\n );\n }\n\n if (!isAuthenticated) {\n return null;\n }\n\n return <Component {...props} />;\n };\n}\n","/**\n * Hook to fetch and manage services (Projects module)\n */\n\nimport { useState, useEffect } from 'react';\nimport { useFoxPixelContext } from '../context/FoxPixelContext';\nimport { ServiceCatalogResponse, ApiError } from '../types';\n\ninterface UseServicesOptions {\n category?: string;\n active?: boolean;\n}\n\ninterface UseServicesReturn {\n services: ServiceCatalogResponse[] | null;\n isLoading: boolean;\n error: ApiError | null;\n refetch: () => Promise<void>;\n}\n\n/**\n * Fetch services from Projects module\n * \n * @example\n * ```tsx\n * function ServicesPage() {\n * const { services, isLoading, error } = useServices({ active: true });\n * \n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * \n * return (\n * <div>\n * {services?.map(service => (\n * <ServiceCard key={service.id} service={service} />\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useServices(options: UseServicesOptions = {}): UseServicesReturn {\n const { client } = useFoxPixelContext();\n const [services, setServices] = useState<ServiceCatalogResponse[] | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<ApiError | null>(null);\n\n const fetchServices = async () => {\n try {\n setIsLoading(true);\n setError(null);\n\n const params = new URLSearchParams();\n if (options.category) params.append('category', options.category);\n if (options.active !== undefined) params.append('active', String(options.active));\n\n const url = `/api/v1/services${params.toString() ? `?${params.toString()}` : ''}`;\n const data = await client.get<ServiceCatalogResponse[]>(url);\n \n setServices(data);\n } catch (err) {\n setError(err as ApiError);\n setServices(null);\n } finally {\n setIsLoading(false);\n }\n };\n\n useEffect(() => {\n fetchServices();\n }, [options.category, options.active]);\n\n return {\n services,\n isLoading,\n error,\n refetch: fetchServices,\n };\n}\n","/**\n * Hook to capture leads (CRM module)\n */\n\nimport { useState } from 'react';\nimport { useFoxPixelContext } from '../context/FoxPixelContext';\nimport { CreateLeadRequest, Lead, ApiError } from '../types';\n\ninterface UseLeadCaptureReturn {\n captureLead: (data: CreateLeadRequest) => Promise<Lead>;\n isLoading: boolean;\n error: ApiError | null;\n}\n\n/**\n * Capture a lead (create lead in CRM)\n * \n * @example\n * ```tsx\n * function ContactForm() {\n * const { captureLead, isLoading, error } = useLeadCapture();\n * \n * const handleSubmit = async (e) => {\n * e.preventDefault();\n * try {\n * const lead = await captureLead({\n * fullName: 'John Doe',\n * email: 'john@example.com',\n * phone: '+1234567890',\n * source: 'website',\n * });\n * alert('Lead created!');\n * } catch (err) {\n * console.error('Error:', err);\n * }\n * };\n * \n * return <form onSubmit={handleSubmit}>...</form>;\n * }\n * ```\n */\nexport function useLeadCapture(): UseLeadCaptureReturn {\n const { client } = useFoxPixelContext();\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<ApiError | null>(null);\n\n const captureLead = async (data: CreateLeadRequest): Promise<Lead> => {\n try {\n setIsLoading(true);\n setError(null);\n\n const lead = await client.post<Lead>('/api/v1/leads', data);\n \n return lead;\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n };\n\n return {\n captureLead,\n isLoading,\n error,\n };\n}\n","/**\n * Hook to capture contacts (CRM module)\n */\n\nimport { useState } from 'react';\nimport { useFoxPixelContext } from '../context/FoxPixelContext';\n\ninterface Contact {\n id: string;\n fullName: string;\n email?: string;\n phone?: string;\n company?: string;\n notes?: string;\n postalCode?: string;\n address?: string;\n city?: string;\n createdAt: string;\n}\n\ninterface CreateContactRequest {\n fullName: string;\n email?: string;\n phone?: string;\n company?: string;\n notes?: string;\n nif?: string;\n address?: string;\n postalCode?: string;\n city?: string;\n}\n\ninterface ApiError {\n message: string;\n status?: number;\n code?: string;\n}\n\ninterface UseContactCaptureReturn {\n captureContact: (data: CreateContactRequest) => Promise<Contact>;\n isLoading: boolean;\n error: ApiError | null;\n}\n\n/**\n * Capture a contact (create contact in CRM)\n * \n * The frontend/SDK decides which fields to fill.\n * This hook accepts any fields from CreateContactRequest.\n * \n * @example\n * ```tsx\n * function ContactForm() {\n * const { captureContact, isLoading, error } = useContactCapture();\n * \n * const handleSubmit = async (e) => {\n * e.preventDefault();\n * try {\n * const contact = await captureContact({\n * fullName: 'John Doe',\n * email: 'john@example.com',\n * phone: '+1234567890',\n * postalCode: '75001',\n * notes: 'Interested in garden maintenance',\n * });\n * alert('Contact created!');\n * } catch (err) {\n * console.error('Error:', err);\n * }\n * };\n * \n * return <form onSubmit={handleSubmit}>...</form>;\n * }\n * ```\n */\nexport function useContactCapture(): UseContactCaptureReturn {\n const { client } = useFoxPixelContext();\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<ApiError | null>(null);\n\n const captureContact = async (data: CreateContactRequest): Promise<Contact> => {\n try {\n setIsLoading(true);\n setError(null);\n\n const contact = await client.post<Contact>('/api/v1/contacts', data);\n \n return contact;\n } catch (err) {\n const apiError = err as ApiError;\n setError(apiError);\n throw apiError;\n } finally {\n setIsLoading(false);\n }\n };\n\n return {\n captureContact,\n isLoading,\n error,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,mBAAqE;;;ACArE,mBAAqE;AAG9D,IAAM,qBAAN,MAAyB;AAAA,EAM9B,YAAY,QAAwB;AAClC,UAAM,SAAS,OAAO,UAAU,QAAQ,IAAI,gCAAgC;AAE5E,SAAK,SAAS,aAAAA,QAAM,OAAO;AAAA,MACzB,SAAS;AAAA,MACT,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,iBAAiB;AAAA;AAAA,IACnB,CAAC;AAED,SAAK,SAAS,OAAO,UAAU,QAAQ,IAAI;AAC3C,SAAK,WAAW,OAAO;AAGvB,SAAK,OAAO,aAAa,QAAQ;AAAA,MAC/B,CAACC,YAAW;AAGV,YAAI,KAAK,cAAc;AAAA,QAGvB,WAAW,KAAK,QAAQ;AAGtB,UAAAA,QAAO,QAAQ,eAAe,IAAI,UAAU,KAAK,MAAM;AAAA,QACzD;AACA,eAAOA;AAAA,MACT;AAAA,MACA,CAAC,UAAU,QAAQ,OAAO,KAAK;AAAA,IACjC;AAGA,SAAK,OAAO,aAAa,SAAS;AAAA,MAChC,CAAC,aAAa;AAAA,MACd,CAAC,UAAsB;AACrB,cAAM,WAAqB;AAAA,UACzB,SAAS;AAAA,UACT,QAAQ,MAAM,UAAU;AAAA,QAC1B;AAEA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ACtC,QAAM,CAAC,WAAW,YAAY,QAAI,wBAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAA0B,IAAI;AAExD,QAAM,iBAAiB,OAAO,SAAiD;AAC7E,QAAI;AACF,mBAAa,IAAI;AACjB,eAAS,IAAI;AAEb,YAAM,UAAU,MAAM,OAAO,KAAc,oBAAoB,IAAI;AAEnE,aAAO;AAAA,IACT,SAAS,KAAK;AACZ,YAAM,WAAW;AACjB,eAAS,QAAQ;AACjB,YAAM;AAAA,IACR,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["axios","config","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_react","import_react"]}