@francistinao/formiq-sdk 1.0.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 +39 -0
- package/dist/favicon.ico +0 -0
- package/dist/formiq-sdk.css +1 -0
- package/dist/index.cjs +67 -0
- package/dist/index.js +1485 -0
- package/dist/logo192.png +0 -0
- package/dist/logo512.png +0 -0
- package/dist/manifest.json +25 -0
- package/dist/robots.txt +3 -0
- package/package.json +93 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1485 @@
|
|
|
1
|
+
import Oe, { useRef as K, useCallback as j, useEffect as Q, useState as ne, useMemo as Y } from "react";
|
|
2
|
+
import { useQuery as fe, useQueryClient as Ce, useMutation as pe } from "@tanstack/react-query";
|
|
3
|
+
import De from "axios";
|
|
4
|
+
import { debounce as Ne } from "lodash";
|
|
5
|
+
import { Image as se, Text as ye, Stage as ze, Layer as Fe, Rect as ge, Label as Le, Tag as Ue, Transformer as qe } from "react-konva";
|
|
6
|
+
import ce from "use-image";
|
|
7
|
+
import { create as Be } from "zustand";
|
|
8
|
+
var le = { exports: {} }, oe = {};
|
|
9
|
+
var me;
|
|
10
|
+
function $e() {
|
|
11
|
+
if (me) return oe;
|
|
12
|
+
me = 1;
|
|
13
|
+
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
14
|
+
function n(a, s, o) {
|
|
15
|
+
var c = null;
|
|
16
|
+
if (o !== void 0 && (c = "" + o), s.key !== void 0 && (c = "" + s.key), "key" in s) {
|
|
17
|
+
o = {};
|
|
18
|
+
for (var g in s)
|
|
19
|
+
g !== "key" && (o[g] = s[g]);
|
|
20
|
+
} else o = s;
|
|
21
|
+
return s = o.ref, {
|
|
22
|
+
$$typeof: e,
|
|
23
|
+
type: a,
|
|
24
|
+
key: c,
|
|
25
|
+
ref: s !== void 0 ? s : null,
|
|
26
|
+
props: o
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return oe.Fragment = t, oe.jsx = n, oe.jsxs = n, oe;
|
|
30
|
+
}
|
|
31
|
+
var ae = {};
|
|
32
|
+
var we;
|
|
33
|
+
function We() {
|
|
34
|
+
return we || (we = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
35
|
+
function e(i) {
|
|
36
|
+
if (i == null) return null;
|
|
37
|
+
if (typeof i == "function")
|
|
38
|
+
return i.$$typeof === L ? null : i.displayName || i.name || null;
|
|
39
|
+
if (typeof i == "string") return i;
|
|
40
|
+
switch (i) {
|
|
41
|
+
case y:
|
|
42
|
+
return "Fragment";
|
|
43
|
+
case P:
|
|
44
|
+
return "Profiler";
|
|
45
|
+
case d:
|
|
46
|
+
return "StrictMode";
|
|
47
|
+
case u:
|
|
48
|
+
return "Suspense";
|
|
49
|
+
case b:
|
|
50
|
+
return "SuspenseList";
|
|
51
|
+
case C:
|
|
52
|
+
return "Activity";
|
|
53
|
+
}
|
|
54
|
+
if (typeof i == "object")
|
|
55
|
+
switch (typeof i.tag == "number" && console.error(
|
|
56
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
57
|
+
), i.$$typeof) {
|
|
58
|
+
case S:
|
|
59
|
+
return "Portal";
|
|
60
|
+
case k:
|
|
61
|
+
return i.displayName || "Context";
|
|
62
|
+
case z:
|
|
63
|
+
return (i._context.displayName || "Context") + ".Consumer";
|
|
64
|
+
case Z:
|
|
65
|
+
var r = i.render;
|
|
66
|
+
return i = i.displayName, i || (i = r.displayName || r.name || "", i = i !== "" ? "ForwardRef(" + i + ")" : "ForwardRef"), i;
|
|
67
|
+
case A:
|
|
68
|
+
return r = i.displayName || null, r !== null ? r : e(i.type) || "Memo";
|
|
69
|
+
case T:
|
|
70
|
+
r = i._payload, i = i._init;
|
|
71
|
+
try {
|
|
72
|
+
return e(i(r));
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
function t(i) {
|
|
79
|
+
return "" + i;
|
|
80
|
+
}
|
|
81
|
+
function n(i) {
|
|
82
|
+
try {
|
|
83
|
+
t(i);
|
|
84
|
+
var r = !1;
|
|
85
|
+
} catch {
|
|
86
|
+
r = !0;
|
|
87
|
+
}
|
|
88
|
+
if (r) {
|
|
89
|
+
r = console;
|
|
90
|
+
var f = r.error, h = typeof Symbol == "function" && Symbol.toStringTag && i[Symbol.toStringTag] || i.constructor.name || "Object";
|
|
91
|
+
return f.call(
|
|
92
|
+
r,
|
|
93
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
94
|
+
h
|
|
95
|
+
), t(i);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function a(i) {
|
|
99
|
+
if (i === y) return "<>";
|
|
100
|
+
if (typeof i == "object" && i !== null && i.$$typeof === T)
|
|
101
|
+
return "<...>";
|
|
102
|
+
try {
|
|
103
|
+
var r = e(i);
|
|
104
|
+
return r ? "<" + r + ">" : "<...>";
|
|
105
|
+
} catch {
|
|
106
|
+
return "<...>";
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function s() {
|
|
110
|
+
var i = q.A;
|
|
111
|
+
return i === null ? null : i.getOwner();
|
|
112
|
+
}
|
|
113
|
+
function o() {
|
|
114
|
+
return Error("react-stack-top-frame");
|
|
115
|
+
}
|
|
116
|
+
function c(i) {
|
|
117
|
+
if (B.call(i, "key")) {
|
|
118
|
+
var r = Object.getOwnPropertyDescriptor(i, "key").get;
|
|
119
|
+
if (r && r.isReactWarning) return !1;
|
|
120
|
+
}
|
|
121
|
+
return i.key !== void 0;
|
|
122
|
+
}
|
|
123
|
+
function g(i, r) {
|
|
124
|
+
function f() {
|
|
125
|
+
G || (G = !0, console.error(
|
|
126
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
127
|
+
r
|
|
128
|
+
));
|
|
129
|
+
}
|
|
130
|
+
f.isReactWarning = !0, Object.defineProperty(i, "key", {
|
|
131
|
+
get: f,
|
|
132
|
+
configurable: !0
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function m() {
|
|
136
|
+
var i = e(this.type);
|
|
137
|
+
return J[i] || (J[i] = !0, console.error(
|
|
138
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
139
|
+
)), i = this.props.ref, i !== void 0 ? i : null;
|
|
140
|
+
}
|
|
141
|
+
function _(i, r, f, h, $, U) {
|
|
142
|
+
var E = f.ref;
|
|
143
|
+
return i = {
|
|
144
|
+
$$typeof: p,
|
|
145
|
+
type: i,
|
|
146
|
+
key: r,
|
|
147
|
+
props: f,
|
|
148
|
+
_owner: h
|
|
149
|
+
}, (E !== void 0 ? E : null) !== null ? Object.defineProperty(i, "ref", {
|
|
150
|
+
enumerable: !1,
|
|
151
|
+
get: m
|
|
152
|
+
}) : Object.defineProperty(i, "ref", { enumerable: !1, value: null }), i._store = {}, Object.defineProperty(i._store, "validated", {
|
|
153
|
+
configurable: !1,
|
|
154
|
+
enumerable: !1,
|
|
155
|
+
writable: !0,
|
|
156
|
+
value: 0
|
|
157
|
+
}), Object.defineProperty(i, "_debugInfo", {
|
|
158
|
+
configurable: !1,
|
|
159
|
+
enumerable: !1,
|
|
160
|
+
writable: !0,
|
|
161
|
+
value: null
|
|
162
|
+
}), Object.defineProperty(i, "_debugStack", {
|
|
163
|
+
configurable: !1,
|
|
164
|
+
enumerable: !1,
|
|
165
|
+
writable: !0,
|
|
166
|
+
value: $
|
|
167
|
+
}), Object.defineProperty(i, "_debugTask", {
|
|
168
|
+
configurable: !1,
|
|
169
|
+
enumerable: !1,
|
|
170
|
+
writable: !0,
|
|
171
|
+
value: U
|
|
172
|
+
}), Object.freeze && (Object.freeze(i.props), Object.freeze(i)), i;
|
|
173
|
+
}
|
|
174
|
+
function M(i, r, f, h, $, U) {
|
|
175
|
+
var E = r.children;
|
|
176
|
+
if (E !== void 0)
|
|
177
|
+
if (h)
|
|
178
|
+
if (D(E)) {
|
|
179
|
+
for (h = 0; h < E.length; h++)
|
|
180
|
+
R(E[h]);
|
|
181
|
+
Object.freeze && Object.freeze(E);
|
|
182
|
+
} else
|
|
183
|
+
console.error(
|
|
184
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
185
|
+
);
|
|
186
|
+
else R(E);
|
|
187
|
+
if (B.call(r, "key")) {
|
|
188
|
+
E = e(i);
|
|
189
|
+
var H = Object.keys(r).filter(function(v) {
|
|
190
|
+
return v !== "key";
|
|
191
|
+
});
|
|
192
|
+
h = 0 < H.length ? "{key: someKey, " + H.join(": ..., ") + ": ...}" : "{key: someKey}", ie[E + h] || (H = 0 < H.length ? "{" + H.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
193
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
194
|
+
let props = %s;
|
|
195
|
+
<%s {...props} />
|
|
196
|
+
React keys must be passed directly to JSX without using spread:
|
|
197
|
+
let props = %s;
|
|
198
|
+
<%s key={someKey} {...props} />`,
|
|
199
|
+
h,
|
|
200
|
+
E,
|
|
201
|
+
H,
|
|
202
|
+
E
|
|
203
|
+
), ie[E + h] = !0);
|
|
204
|
+
}
|
|
205
|
+
if (E = null, f !== void 0 && (n(f), E = "" + f), c(r) && (n(r.key), E = "" + r.key), "key" in r) {
|
|
206
|
+
f = {};
|
|
207
|
+
for (var N in r)
|
|
208
|
+
N !== "key" && (f[N] = r[N]);
|
|
209
|
+
} else f = r;
|
|
210
|
+
return E && g(
|
|
211
|
+
f,
|
|
212
|
+
typeof i == "function" ? i.displayName || i.name || "Unknown" : i
|
|
213
|
+
), _(
|
|
214
|
+
i,
|
|
215
|
+
E,
|
|
216
|
+
f,
|
|
217
|
+
s(),
|
|
218
|
+
$,
|
|
219
|
+
U
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
function R(i) {
|
|
223
|
+
I(i) ? i._store && (i._store.validated = 1) : typeof i == "object" && i !== null && i.$$typeof === T && (i._payload.status === "fulfilled" ? I(i._payload.value) && i._payload.value._store && (i._payload.value._store.validated = 1) : i._store && (i._store.validated = 1));
|
|
224
|
+
}
|
|
225
|
+
function I(i) {
|
|
226
|
+
return typeof i == "object" && i !== null && i.$$typeof === p;
|
|
227
|
+
}
|
|
228
|
+
var l = Oe, p = /* @__PURE__ */ Symbol.for("react.transitional.element"), S = /* @__PURE__ */ Symbol.for("react.portal"), y = /* @__PURE__ */ Symbol.for("react.fragment"), d = /* @__PURE__ */ Symbol.for("react.strict_mode"), P = /* @__PURE__ */ Symbol.for("react.profiler"), z = /* @__PURE__ */ Symbol.for("react.consumer"), k = /* @__PURE__ */ Symbol.for("react.context"), Z = /* @__PURE__ */ Symbol.for("react.forward_ref"), u = /* @__PURE__ */ Symbol.for("react.suspense"), b = /* @__PURE__ */ Symbol.for("react.suspense_list"), A = /* @__PURE__ */ Symbol.for("react.memo"), T = /* @__PURE__ */ Symbol.for("react.lazy"), C = /* @__PURE__ */ Symbol.for("react.activity"), L = /* @__PURE__ */ Symbol.for("react.client.reference"), q = l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, B = Object.prototype.hasOwnProperty, D = Array.isArray, x = console.createTask ? console.createTask : function() {
|
|
229
|
+
return null;
|
|
230
|
+
};
|
|
231
|
+
l = {
|
|
232
|
+
react_stack_bottom_frame: function(i) {
|
|
233
|
+
return i();
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
var G, J = {}, ee = l.react_stack_bottom_frame.bind(
|
|
237
|
+
l,
|
|
238
|
+
o
|
|
239
|
+
)(), V = x(a(o)), ie = {};
|
|
240
|
+
ae.Fragment = y, ae.jsx = function(i, r, f) {
|
|
241
|
+
var h = 1e4 > q.recentlyCreatedOwnerStacks++;
|
|
242
|
+
return M(
|
|
243
|
+
i,
|
|
244
|
+
r,
|
|
245
|
+
f,
|
|
246
|
+
!1,
|
|
247
|
+
h ? Error("react-stack-top-frame") : ee,
|
|
248
|
+
h ? x(a(i)) : V
|
|
249
|
+
);
|
|
250
|
+
}, ae.jsxs = function(i, r, f) {
|
|
251
|
+
var h = 1e4 > q.recentlyCreatedOwnerStacks++;
|
|
252
|
+
return M(
|
|
253
|
+
i,
|
|
254
|
+
r,
|
|
255
|
+
f,
|
|
256
|
+
!0,
|
|
257
|
+
h ? Error("react-stack-top-frame") : ee,
|
|
258
|
+
h ? x(a(i)) : V
|
|
259
|
+
);
|
|
260
|
+
};
|
|
261
|
+
})()), ae;
|
|
262
|
+
}
|
|
263
|
+
var xe;
|
|
264
|
+
function Ye() {
|
|
265
|
+
return xe || (xe = 1, process.env.NODE_ENV === "production" ? le.exports = $e() : le.exports = We()), le.exports;
|
|
266
|
+
}
|
|
267
|
+
var w = Ye();
|
|
268
|
+
let Ae = null;
|
|
269
|
+
function Me() {
|
|
270
|
+
return Ae;
|
|
271
|
+
}
|
|
272
|
+
function Ie(e) {
|
|
273
|
+
Ae = e;
|
|
274
|
+
}
|
|
275
|
+
function It() {
|
|
276
|
+
Ie(null);
|
|
277
|
+
}
|
|
278
|
+
function He(e) {
|
|
279
|
+
const t = De.create({
|
|
280
|
+
baseURL: "http://localhost:3000/api/external",
|
|
281
|
+
headers: {
|
|
282
|
+
"Content-Type": "application/json"
|
|
283
|
+
},
|
|
284
|
+
withCredentials: !1
|
|
285
|
+
});
|
|
286
|
+
return t.interceptors.request.use((n) => {
|
|
287
|
+
const a = e?.();
|
|
288
|
+
return a && (n.headers.Authorization = `Bearer ${a}`), n;
|
|
289
|
+
}), t;
|
|
290
|
+
}
|
|
291
|
+
const X = He(Me), Ke = async (e) => {
|
|
292
|
+
if (!e)
|
|
293
|
+
throw new Error("token must be provided");
|
|
294
|
+
return (await X.get("/integrations/validate-pat", {
|
|
295
|
+
headers: {
|
|
296
|
+
Authorization: `Bearer ${e}`
|
|
297
|
+
}
|
|
298
|
+
})).data;
|
|
299
|
+
}, Ge = async (e) => {
|
|
300
|
+
if (!e)
|
|
301
|
+
throw new Error("boardId must be provided");
|
|
302
|
+
return (await X.get(`/boards/${e}`)).data;
|
|
303
|
+
}, Je = async (e) => {
|
|
304
|
+
if (!e)
|
|
305
|
+
throw new Error("boardId must be provided");
|
|
306
|
+
return (await X.get(`/canvas-elements/${e}`)).data.canvasElements;
|
|
307
|
+
}, Ve = async (e) => (await X.post("/canvas-elements", e)).data.canvasElement, Qe = async (e) => {
|
|
308
|
+
await X.delete(`/canvas-elements/${e}`);
|
|
309
|
+
}, Xe = async (e) => {
|
|
310
|
+
if (!e)
|
|
311
|
+
throw new Error("boardId must be provided");
|
|
312
|
+
return (await X.post(`/boards/${e}/produce`)).data;
|
|
313
|
+
}, Ze = async (e, t) => {
|
|
314
|
+
if (!e || !t)
|
|
315
|
+
throw new Error("boardId and jobId must be provided");
|
|
316
|
+
return (await X.get(
|
|
317
|
+
`/boards/${e}/produce/jobs/${t}`
|
|
318
|
+
)).data;
|
|
319
|
+
};
|
|
320
|
+
function et(e, t) {
|
|
321
|
+
const n = t?.enabled ?? !0;
|
|
322
|
+
return fe({
|
|
323
|
+
queryKey: ["board-editor", e],
|
|
324
|
+
queryFn: async () => {
|
|
325
|
+
if (!e)
|
|
326
|
+
throw new Error("Missing board id");
|
|
327
|
+
return Ge(e);
|
|
328
|
+
},
|
|
329
|
+
enabled: !!e && n,
|
|
330
|
+
retry: (a, s) => {
|
|
331
|
+
const o = s.response?.status;
|
|
332
|
+
return o === 401 || o === 403 ? !1 : o === 404 ? a < 3 : a < 2;
|
|
333
|
+
},
|
|
334
|
+
retryDelay: (a, s) => s.response?.status === 404 ? Math.min(300 * 2 ** a, 2e3) : Math.min(1e3 * 2 ** a, 8e3),
|
|
335
|
+
refetchOnWindowFocus: !1,
|
|
336
|
+
refetchOnReconnect: !1,
|
|
337
|
+
staleTime: 3e4
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
const tt = 250;
|
|
341
|
+
function rt(e) {
|
|
342
|
+
return typeof e.id == "number" ? `id:${e.id}` : e.clientId ? `client:${e.clientId}` : typeof e.canvasElementConfigId == "number" ? `cfg:${e.canvasElementConfigId}` : `fallback:${e.type}:${e.variableName ?? ""}`;
|
|
343
|
+
}
|
|
344
|
+
function ke(e, t) {
|
|
345
|
+
const n = t?.canEdit ?? !0, a = t?.enabled ?? !0, s = Ce(), o = K(/* @__PURE__ */ new Map()), c = K(/* @__PURE__ */ new Map()), { data: g } = fe({
|
|
346
|
+
queryKey: ["canvas-elements", e],
|
|
347
|
+
queryFn: async () => Je(e),
|
|
348
|
+
enabled: !!e && a,
|
|
349
|
+
retry: (l, p) => {
|
|
350
|
+
const S = p.response?.status;
|
|
351
|
+
return S === 401 || S === 403 || S === 404 ? !1 : l < 1;
|
|
352
|
+
},
|
|
353
|
+
refetchOnWindowFocus: !1,
|
|
354
|
+
refetchOnReconnect: !1
|
|
355
|
+
}), { mutate: m } = pe({
|
|
356
|
+
mutationFn: Ve,
|
|
357
|
+
onSuccess: (l) => {
|
|
358
|
+
l.id && s.setQueryData(["canvas-elements", e], (p = []) => p.some((y) => y.id === l.id) ? p.map((y) => y.id === l.id ? l : y) : [...p, l]);
|
|
359
|
+
}
|
|
360
|
+
}), _ = j(
|
|
361
|
+
(l) => {
|
|
362
|
+
if (!n) {
|
|
363
|
+
o.current.delete(l);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const p = o.current.get(l);
|
|
367
|
+
p && (o.current.delete(l), m(p.element, {
|
|
368
|
+
onSuccess: (S) => {
|
|
369
|
+
p.element.id || p.onCreated?.(S.id, S.canvasElementConfigId);
|
|
370
|
+
}
|
|
371
|
+
}));
|
|
372
|
+
},
|
|
373
|
+
[n, m]
|
|
374
|
+
), M = j(
|
|
375
|
+
(l, p, S) => {
|
|
376
|
+
if (!n)
|
|
377
|
+
return;
|
|
378
|
+
const y = rt(l);
|
|
379
|
+
o.current.set(y, { element: l, onCreated: p });
|
|
380
|
+
let d = c.current.get(y);
|
|
381
|
+
if (d || (d = Ne(() => _(y), tt), c.current.set(y, d)), S?.immediate) {
|
|
382
|
+
d.cancel(), _(y);
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
d();
|
|
386
|
+
},
|
|
387
|
+
[n, _]
|
|
388
|
+
);
|
|
389
|
+
Q(() => {
|
|
390
|
+
const l = c.current, p = o.current;
|
|
391
|
+
return () => {
|
|
392
|
+
for (const S of l.values())
|
|
393
|
+
S.cancel();
|
|
394
|
+
l.clear(), p.clear();
|
|
395
|
+
};
|
|
396
|
+
}, []);
|
|
397
|
+
const { mutate: R } = pe({
|
|
398
|
+
mutationFn: Qe,
|
|
399
|
+
onSuccess: () => {
|
|
400
|
+
s.invalidateQueries({ queryKey: ["canvas-elements", e] });
|
|
401
|
+
}
|
|
402
|
+
}), I = j(
|
|
403
|
+
(l, p) => {
|
|
404
|
+
n && R(l, p);
|
|
405
|
+
},
|
|
406
|
+
[n, R]
|
|
407
|
+
);
|
|
408
|
+
return { canvasElements: g, upsertCanvasElement: M, deleteCanvasElement: I };
|
|
409
|
+
}
|
|
410
|
+
const nt = 2e3, it = 2;
|
|
411
|
+
function be(e) {
|
|
412
|
+
return `produce-active-job:${e}`;
|
|
413
|
+
}
|
|
414
|
+
function ve(e) {
|
|
415
|
+
return e === "QUEUED" || e === "PROCESSING";
|
|
416
|
+
}
|
|
417
|
+
function Ee(e) {
|
|
418
|
+
const t = e.response?.data.error;
|
|
419
|
+
return t && t.length > 0 ? t : e.message || "Failed to process PDF generation";
|
|
420
|
+
}
|
|
421
|
+
function ot(e) {
|
|
422
|
+
const t = Ce(), [n, a] = ne({}), s = j((d, P) => {
|
|
423
|
+
if (typeof window > "u") return;
|
|
424
|
+
const z = be(d);
|
|
425
|
+
if (P) {
|
|
426
|
+
window.localStorage.setItem(z, P);
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
window.localStorage.removeItem(z);
|
|
430
|
+
}, []), o = j(
|
|
431
|
+
(d, P = e) => {
|
|
432
|
+
P && (a((z) => {
|
|
433
|
+
const k = { ...z };
|
|
434
|
+
return d ? k[P] = d : delete k[P], k;
|
|
435
|
+
}), s(P, d));
|
|
436
|
+
},
|
|
437
|
+
[e, s]
|
|
438
|
+
), c = e ? n[e] ?? (typeof window > "u" ? null : window.localStorage.getItem(be(e))) : null, g = pe({
|
|
439
|
+
onMutate: () => {
|
|
440
|
+
o(null);
|
|
441
|
+
},
|
|
442
|
+
mutationFn: async () => {
|
|
443
|
+
if (!e)
|
|
444
|
+
throw new Error("Missing board id");
|
|
445
|
+
return Xe(e);
|
|
446
|
+
},
|
|
447
|
+
onSuccess: (d) => {
|
|
448
|
+
o(d.jobId);
|
|
449
|
+
},
|
|
450
|
+
onSettled: async () => {
|
|
451
|
+
await t.invalidateQueries({ queryKey: ["billing", "summary"] });
|
|
452
|
+
}
|
|
453
|
+
}), m = fe({
|
|
454
|
+
queryKey: ["produce-status", e, c],
|
|
455
|
+
queryFn: async () => {
|
|
456
|
+
if (!e || !c)
|
|
457
|
+
throw new Error("Missing board or job id");
|
|
458
|
+
const d = await Ze(e, c);
|
|
459
|
+
return d.jobId && d.jobId !== c && o(d.jobId), d;
|
|
460
|
+
},
|
|
461
|
+
enabled: !!(e && c),
|
|
462
|
+
refetchInterval: (d) => {
|
|
463
|
+
const P = d.state.data?.status;
|
|
464
|
+
return P && ve(P) ? nt : !1;
|
|
465
|
+
},
|
|
466
|
+
retry: (d, P) => {
|
|
467
|
+
if (P.response?.status === 404) {
|
|
468
|
+
const z = d < it;
|
|
469
|
+
return z || o(null), z;
|
|
470
|
+
}
|
|
471
|
+
return d < 3;
|
|
472
|
+
},
|
|
473
|
+
retryDelay: (d, P) => P.response?.status === 404 ? Math.min(500 * 2 ** d, 4e3) : Math.min(1e3 * 2 ** d, 8e3)
|
|
474
|
+
});
|
|
475
|
+
Q(() => {
|
|
476
|
+
const d = m.data?.status;
|
|
477
|
+
d !== "READY" && d !== "FAILED" || t.invalidateQueries({ queryKey: ["billing", "summary"] });
|
|
478
|
+
}, [m.data?.status, e, c, t]);
|
|
479
|
+
const _ = m.data?.status ?? g.data?.status ?? null, M = (() => {
|
|
480
|
+
const d = g.error;
|
|
481
|
+
return d ? d.response?.status !== 422 ? [] : d.response?.data.missing ?? [] : [];
|
|
482
|
+
})(), R = (() => {
|
|
483
|
+
const d = g.error;
|
|
484
|
+
return !d || d.response?.status !== 409 ? null : d.response?.data.jobId ?? null;
|
|
485
|
+
})(), I = Y(() => m.error ? Ee(m.error) : g.error ? Ee(g.error) : m.data?.errorMessage ?? null, [m.error, m.data, g.error]), l = ve(_), p = m.data?.progress ?? g.data?.progress ?? 0, S = j(
|
|
486
|
+
(d) => {
|
|
487
|
+
o(d);
|
|
488
|
+
},
|
|
489
|
+
[o]
|
|
490
|
+
), y = j(() => {
|
|
491
|
+
o(null);
|
|
492
|
+
}, [o]);
|
|
493
|
+
return {
|
|
494
|
+
activeJobId: c,
|
|
495
|
+
status: _,
|
|
496
|
+
progress: p,
|
|
497
|
+
isGenerating: l,
|
|
498
|
+
isTriggering: g.isPending,
|
|
499
|
+
isPolling: m.isFetching,
|
|
500
|
+
downloadUrl: m.data?.downloadUrl,
|
|
501
|
+
errorMessage: I,
|
|
502
|
+
missingPrerequisites: M,
|
|
503
|
+
conflictJobId: R,
|
|
504
|
+
triggerGeneration: g.mutateAsync,
|
|
505
|
+
refetchStatus: m.refetch,
|
|
506
|
+
resumeFromJobId: S,
|
|
507
|
+
clearActiveJob: y
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
function at(e) {
|
|
511
|
+
const t = {
|
|
512
|
+
id: crypto.randomUUID(),
|
|
513
|
+
x: 220,
|
|
514
|
+
y: 140,
|
|
515
|
+
width: 220,
|
|
516
|
+
height: 40,
|
|
517
|
+
rotation: 0
|
|
518
|
+
}, n = {
|
|
519
|
+
fontFamily: "Poppins",
|
|
520
|
+
fontWeight: "bold",
|
|
521
|
+
italic: !1,
|
|
522
|
+
underline: !1,
|
|
523
|
+
fontSize: 28,
|
|
524
|
+
textAlign: "left",
|
|
525
|
+
color: "#ffffff",
|
|
526
|
+
opacity: 1,
|
|
527
|
+
coordinateSpace: "page"
|
|
528
|
+
};
|
|
529
|
+
switch (e) {
|
|
530
|
+
case "text":
|
|
531
|
+
return {
|
|
532
|
+
...t,
|
|
533
|
+
type: e,
|
|
534
|
+
text: "{{Variable_name}}",
|
|
535
|
+
width: 240,
|
|
536
|
+
height: 36,
|
|
537
|
+
zIndex: 0,
|
|
538
|
+
properties: {
|
|
539
|
+
...n,
|
|
540
|
+
fontWeight: "bold",
|
|
541
|
+
color: "#000000",
|
|
542
|
+
bindingKey: "Variable_name"
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
case "qr_code":
|
|
546
|
+
return {
|
|
547
|
+
...t,
|
|
548
|
+
type: e,
|
|
549
|
+
width: 100,
|
|
550
|
+
height: 100,
|
|
551
|
+
zIndex: 0,
|
|
552
|
+
data: "https://upload.wikimedia.org/wikipedia/commons/d/d0/QR_code_for_mobile_English_Wikipedia.svg",
|
|
553
|
+
properties: {
|
|
554
|
+
...n,
|
|
555
|
+
fontWeight: "normal",
|
|
556
|
+
color: "#000000",
|
|
557
|
+
bindingKey: "qr_data",
|
|
558
|
+
data: "https://upload.wikimedia.org/wikipedia/commons/d/d0/QR_code_for_mobile_English_Wikipedia.svg"
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
case "bar_code":
|
|
562
|
+
return {
|
|
563
|
+
...t,
|
|
564
|
+
type: e,
|
|
565
|
+
width: 240,
|
|
566
|
+
height: 32,
|
|
567
|
+
zIndex: 0,
|
|
568
|
+
data: "BULK-0001",
|
|
569
|
+
properties: {
|
|
570
|
+
...n,
|
|
571
|
+
fontWeight: "normal",
|
|
572
|
+
color: "#000000",
|
|
573
|
+
bindingKey: "barcode_data",
|
|
574
|
+
data: "BULK-0001"
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
case "image":
|
|
578
|
+
return {
|
|
579
|
+
...t,
|
|
580
|
+
type: e,
|
|
581
|
+
width: 190,
|
|
582
|
+
height: 120,
|
|
583
|
+
zIndex: 0,
|
|
584
|
+
src: "/logo.png",
|
|
585
|
+
properties: {
|
|
586
|
+
...n,
|
|
587
|
+
fontWeight: "normal",
|
|
588
|
+
color: "#000000",
|
|
589
|
+
src: "/logo.png"
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
const F = Be((e) => ({
|
|
595
|
+
elements: [],
|
|
596
|
+
selectedId: null,
|
|
597
|
+
dataSourceMeta: null,
|
|
598
|
+
colorEyedropped: null,
|
|
599
|
+
colorEyedropperActive: !1,
|
|
600
|
+
setColorEyedropped: (t) => e({ colorEyedropped: t }),
|
|
601
|
+
setColorEyedropperActive: (t) => e({ colorEyedropperActive: t }),
|
|
602
|
+
addElement: (t) => {
|
|
603
|
+
const n = at(t);
|
|
604
|
+
e((a) => ({
|
|
605
|
+
elements: [...a.elements, n],
|
|
606
|
+
selectedId: n.id
|
|
607
|
+
}));
|
|
608
|
+
},
|
|
609
|
+
updateElement: (t, n) => e((a) => ({
|
|
610
|
+
elements: a.elements.map(
|
|
611
|
+
(s) => s.id === t ? { ...s, ...n } : s
|
|
612
|
+
)
|
|
613
|
+
})),
|
|
614
|
+
updateElementProperties: (t, n) => e((a) => ({
|
|
615
|
+
elements: a.elements.map(
|
|
616
|
+
(s) => s.id === t ? { ...s, properties: { ...s.properties, ...n } } : s
|
|
617
|
+
)
|
|
618
|
+
})),
|
|
619
|
+
updateDimensions: (t, n) => e((a) => ({
|
|
620
|
+
elements: a.elements.map(
|
|
621
|
+
(s) => s.id === t ? { ...s, ...n } : s
|
|
622
|
+
)
|
|
623
|
+
})),
|
|
624
|
+
removeElement: (t) => e((n) => ({
|
|
625
|
+
elements: n.elements.filter((a) => a.id !== t),
|
|
626
|
+
selectedId: n.selectedId === t ? null : n.selectedId
|
|
627
|
+
})),
|
|
628
|
+
bringForward: (t) => e((n) => ({
|
|
629
|
+
elements: n.elements.map(
|
|
630
|
+
(a) => a.id === t ? { ...a, zIndex: a.zIndex + 1 } : a
|
|
631
|
+
)
|
|
632
|
+
})),
|
|
633
|
+
sendBackward: (t) => e((n) => ({
|
|
634
|
+
elements: n.elements.map(
|
|
635
|
+
(a) => a.id === t ? { ...a, zIndex: Math.max(0, a.zIndex - 1) } : a
|
|
636
|
+
)
|
|
637
|
+
})),
|
|
638
|
+
setSelectedId: (t) => e({ selectedId: t }),
|
|
639
|
+
setDataSourceMeta: (t) => e({ dataSourceMeta: t }),
|
|
640
|
+
mergeElements: (t) => e((n) => {
|
|
641
|
+
const a = new Set(
|
|
642
|
+
n.elements.map((o) => o.dbId).filter((o) => o !== void 0)
|
|
643
|
+
), s = t.filter((o) => o.dbId !== void 0 && !a.has(o.dbId));
|
|
644
|
+
return s.length === 0 ? n : { elements: [...n.elements, ...s] };
|
|
645
|
+
}),
|
|
646
|
+
setElements: (t) => e((n) => {
|
|
647
|
+
if (!n.selectedId)
|
|
648
|
+
return { elements: t, selectedId: null };
|
|
649
|
+
const a = t.find((o) => o.id === n.selectedId);
|
|
650
|
+
if (a)
|
|
651
|
+
return { elements: t, selectedId: a.id };
|
|
652
|
+
const s = n.elements.find((o) => o.id === n.selectedId);
|
|
653
|
+
if (s?.dbId) {
|
|
654
|
+
const o = t.find((c) => c.dbId === s.dbId);
|
|
655
|
+
return { elements: t, selectedId: o?.id ?? null };
|
|
656
|
+
}
|
|
657
|
+
return { elements: t, selectedId: null };
|
|
658
|
+
}),
|
|
659
|
+
assetUrl: null,
|
|
660
|
+
setAssetUrl: (t) => e({ assetUrl: t })
|
|
661
|
+
}));
|
|
662
|
+
function st(e, t) {
|
|
663
|
+
const n = t?.canEdit ?? !0, { upsertCanvasElement: a } = ke(e, { canEdit: n }), s = F((u) => u.updateElement), o = K(null), c = K(null), [g, m] = ne({ width: 800, height: 600 }), [_, M] = ne(1), [R, I] = ne({ x: 0, y: 0 }), l = K(!1), p = K(null);
|
|
664
|
+
Q(() => {
|
|
665
|
+
if (!c.current) return;
|
|
666
|
+
const u = new ResizeObserver(() => {
|
|
667
|
+
const b = Math.max(c.current?.clientWidth ?? 0, 400), A = Math.max(c.current?.clientHeight ?? 0, 320), T = typeof window < "u" ? window.innerHeight : 900, C = Math.max(T - 220, 480);
|
|
668
|
+
m({ width: b, height: Math.min(A, C) });
|
|
669
|
+
});
|
|
670
|
+
return u.observe(c.current), () => u.disconnect();
|
|
671
|
+
}, []);
|
|
672
|
+
const S = j(
|
|
673
|
+
(u) => {
|
|
674
|
+
const b = o.current;
|
|
675
|
+
if (!b) return;
|
|
676
|
+
u.evt.preventDefault();
|
|
677
|
+
const A = _, T = b.getPointerPosition();
|
|
678
|
+
if (!T) return;
|
|
679
|
+
const C = 1.08, L = Math.min(
|
|
680
|
+
2.4,
|
|
681
|
+
Math.max(0.5, u.evt.deltaY > 0 ? A / C : A * C)
|
|
682
|
+
), q = {
|
|
683
|
+
x: (T.x - R.x) / A,
|
|
684
|
+
y: (T.y - R.y) / A
|
|
685
|
+
}, B = {
|
|
686
|
+
x: T.x - q.x * L,
|
|
687
|
+
y: T.y - q.y * L
|
|
688
|
+
};
|
|
689
|
+
M(L), I(B);
|
|
690
|
+
},
|
|
691
|
+
[_, R]
|
|
692
|
+
), y = j((u) => {
|
|
693
|
+
u.target === u.target.getStage() && (l.current = !0, p.current = o.current?.getPointerPosition() ?? null);
|
|
694
|
+
}, []), d = j(() => {
|
|
695
|
+
if (!l.current) return;
|
|
696
|
+
const u = o.current?.getPointerPosition();
|
|
697
|
+
if (!u || !p.current) return;
|
|
698
|
+
const b = u.x - p.current.x, A = u.y - p.current.y;
|
|
699
|
+
I((T) => ({ x: T.x + b, y: T.y + A })), p.current = u;
|
|
700
|
+
}, []), P = j(() => {
|
|
701
|
+
l.current = !1, p.current = null;
|
|
702
|
+
}, []), z = j((u) => {
|
|
703
|
+
c.current = u;
|
|
704
|
+
}, []), k = j(
|
|
705
|
+
(u, b, A, T = u.properties) => {
|
|
706
|
+
n && (s(u.id, { x: b, y: A }), a(
|
|
707
|
+
{
|
|
708
|
+
id: u.dbId,
|
|
709
|
+
clientId: u.id,
|
|
710
|
+
canvasElementConfigId: u.configDbId,
|
|
711
|
+
boardId: e,
|
|
712
|
+
type: u.type,
|
|
713
|
+
x: b,
|
|
714
|
+
y: A,
|
|
715
|
+
rotation: u.rotation,
|
|
716
|
+
width: u.width,
|
|
717
|
+
height: u.height,
|
|
718
|
+
zIndex: u.zIndex,
|
|
719
|
+
properties: T
|
|
720
|
+
},
|
|
721
|
+
(C, L) => s(u.id, { dbId: C, configDbId: L }),
|
|
722
|
+
{ immediate: !0 }
|
|
723
|
+
));
|
|
724
|
+
},
|
|
725
|
+
[n, a, s, e]
|
|
726
|
+
), Z = j(
|
|
727
|
+
(u, b, A = u.properties) => {
|
|
728
|
+
if (!n)
|
|
729
|
+
return;
|
|
730
|
+
const { x: T, y: C, width: L, height: q, rotation: B } = b;
|
|
731
|
+
s(u.id, { x: T, y: C, rotation: B, width: L, height: q }), a(
|
|
732
|
+
{
|
|
733
|
+
id: u.dbId,
|
|
734
|
+
clientId: u.id,
|
|
735
|
+
canvasElementConfigId: u.configDbId,
|
|
736
|
+
boardId: e,
|
|
737
|
+
type: u.type,
|
|
738
|
+
x: T,
|
|
739
|
+
y: C,
|
|
740
|
+
rotation: B,
|
|
741
|
+
width: L,
|
|
742
|
+
height: q,
|
|
743
|
+
zIndex: u.zIndex,
|
|
744
|
+
properties: A
|
|
745
|
+
},
|
|
746
|
+
(D, x) => s(u.id, { dbId: D, configDbId: x }),
|
|
747
|
+
{ immediate: !0 }
|
|
748
|
+
);
|
|
749
|
+
},
|
|
750
|
+
[n, a, s, e]
|
|
751
|
+
);
|
|
752
|
+
return {
|
|
753
|
+
stageRef: o,
|
|
754
|
+
registerContainer: z,
|
|
755
|
+
stageSize: g,
|
|
756
|
+
stageScale: _,
|
|
757
|
+
stagePosition: R,
|
|
758
|
+
handleMouseDown: y,
|
|
759
|
+
handleMouseMove: d,
|
|
760
|
+
handleMouseUp: P,
|
|
761
|
+
handleWheel: S,
|
|
762
|
+
setStagePosition: I,
|
|
763
|
+
handleDragEnd: k,
|
|
764
|
+
handleTransformEnd: Z
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
const _e = {
|
|
768
|
+
width: 595.28,
|
|
769
|
+
height: 841.89
|
|
770
|
+
};
|
|
771
|
+
function O(e) {
|
|
772
|
+
return !Number.isFinite(e) || e <= 0 ? 1 : e;
|
|
773
|
+
}
|
|
774
|
+
function Se(e) {
|
|
775
|
+
return e * 72 / 25.4;
|
|
776
|
+
}
|
|
777
|
+
function ct(e) {
|
|
778
|
+
let t;
|
|
779
|
+
if (!e?.paperSize || e.paperSize === "A4")
|
|
780
|
+
t = _e;
|
|
781
|
+
else if (e.paperSize === "Long")
|
|
782
|
+
t = { width: 612, height: 1008 };
|
|
783
|
+
else if (e.paperSize === "Short")
|
|
784
|
+
t = { width: 612, height: 792 };
|
|
785
|
+
else if (e.paperSize === "Custom") {
|
|
786
|
+
const n = e.customWidthMm ?? 210, a = e.customHeightMm ?? 297;
|
|
787
|
+
t = { width: Se(n), height: Se(a) };
|
|
788
|
+
} else
|
|
789
|
+
t = _e;
|
|
790
|
+
return e?.orientation === "LANDSCAPE" ? { width: t.height, height: t.width } : t;
|
|
791
|
+
}
|
|
792
|
+
function dt(e, t) {
|
|
793
|
+
const n = Math.max(1, Math.min(e.width, t.width)), a = Math.max(1, Math.min(e.height, t.height));
|
|
794
|
+
return {
|
|
795
|
+
x: Math.max(0, Math.min(e.x, t.width - n)),
|
|
796
|
+
y: Math.max(0, Math.min(e.y, t.height - a)),
|
|
797
|
+
width: n,
|
|
798
|
+
height: a
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
function Re(e, t, n) {
|
|
802
|
+
const a = O(n.width), s = O(n.height), o = O(t.width), c = O(t.height);
|
|
803
|
+
return {
|
|
804
|
+
x: t.x + e.x / a * o,
|
|
805
|
+
y: t.y + e.y / s * c,
|
|
806
|
+
width: e.width / a * o,
|
|
807
|
+
height: e.height / s * c
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
function he(e, t, n) {
|
|
811
|
+
const a = O(n.width), s = O(n.height), o = O(t.width), c = O(t.height), g = {
|
|
812
|
+
x: (e.x - t.x) / o * a,
|
|
813
|
+
y: (e.y - t.y) / c * s,
|
|
814
|
+
width: e.width / o * a,
|
|
815
|
+
height: e.height / c * s
|
|
816
|
+
};
|
|
817
|
+
return dt(g, n);
|
|
818
|
+
}
|
|
819
|
+
function Te(e, t, n) {
|
|
820
|
+
return he(e, t, n);
|
|
821
|
+
}
|
|
822
|
+
function lt(e, t) {
|
|
823
|
+
const n = e.width * 0.8, a = e.height * 0.75, s = O(t.width) / O(t.height);
|
|
824
|
+
let o = n, c = o / s;
|
|
825
|
+
c > a && (c = a, o = c * s);
|
|
826
|
+
const g = (e.height - c) / 2;
|
|
827
|
+
return {
|
|
828
|
+
x: (e.width - o) / 2,
|
|
829
|
+
y: Math.max(e.height * 0.1, g),
|
|
830
|
+
width: o,
|
|
831
|
+
height: c
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
function ut(e, t) {
|
|
835
|
+
const n = t.width ?? e.width * 0.8, a = t.height ?? e.height * 0.6, s = e.width * 0.8 / O(n), o = e.height * 0.75 / O(a), c = Math.min(s, o, 1), g = n * c, m = a * c, _ = (e.height - m) / 2;
|
|
836
|
+
return {
|
|
837
|
+
x: (e.width - g) / 2,
|
|
838
|
+
y: Math.max(e.height * 0.1, _),
|
|
839
|
+
width: g,
|
|
840
|
+
height: m
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
function ht(e, t) {
|
|
844
|
+
const n = t.width ?? e.width, a = t.height ?? e.height, s = O(e.width), o = O(e.height), c = O(n), g = O(a), m = Math.min(s / c, o / g), _ = c * m, M = g * m;
|
|
845
|
+
return {
|
|
846
|
+
x: e.x + (s - _) / 2,
|
|
847
|
+
y: e.y + (o - M) / 2,
|
|
848
|
+
width: _,
|
|
849
|
+
height: M
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
function ft({
|
|
853
|
+
sharedProps: e,
|
|
854
|
+
src: t,
|
|
855
|
+
placeholder: n,
|
|
856
|
+
width: a,
|
|
857
|
+
height: s,
|
|
858
|
+
opacity: o
|
|
859
|
+
}) {
|
|
860
|
+
const [c] = ce(t ?? "", "anonymous");
|
|
861
|
+
return /* @__PURE__ */ w.jsx(
|
|
862
|
+
se,
|
|
863
|
+
{
|
|
864
|
+
...e,
|
|
865
|
+
image: t ? c : n,
|
|
866
|
+
width: a,
|
|
867
|
+
height: s,
|
|
868
|
+
opacity: o
|
|
869
|
+
}
|
|
870
|
+
);
|
|
871
|
+
}
|
|
872
|
+
const gt = /\.(png|jpe?g|gif|webp|bmp|svg|avif|tiff?)(\?.*)?$/i;
|
|
873
|
+
function pt(e) {
|
|
874
|
+
return /^https?:\/\//i.test(e) ? gt.test(e) : !1;
|
|
875
|
+
}
|
|
876
|
+
const yt = {
|
|
877
|
+
text: "Text",
|
|
878
|
+
qr_code: "QR Code",
|
|
879
|
+
bar_code: "Bar Code",
|
|
880
|
+
image: "Image"
|
|
881
|
+
}, mt = `data:image/svg+xml;utf8,${encodeURIComponent(`
|
|
882
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120">
|
|
883
|
+
<rect width="120" height="120" fill="#ffffff"/>
|
|
884
|
+
<rect x="8" y="8" width="32" height="32" fill="#111827"/>
|
|
885
|
+
<rect x="13" y="13" width="22" height="22" fill="#ffffff"/>
|
|
886
|
+
<rect x="18" y="18" width="12" height="12" fill="#111827"/>
|
|
887
|
+
<rect x="80" y="8" width="32" height="32" fill="#111827"/>
|
|
888
|
+
<rect x="85" y="13" width="22" height="22" fill="#ffffff"/>
|
|
889
|
+
<rect x="90" y="18" width="12" height="12" fill="#111827"/>
|
|
890
|
+
<rect x="8" y="80" width="32" height="32" fill="#111827"/>
|
|
891
|
+
<rect x="13" y="85" width="22" height="22" fill="#ffffff"/>
|
|
892
|
+
<rect x="18" y="90" width="12" height="12" fill="#111827"/>
|
|
893
|
+
<rect x="50" y="50" width="8" height="8" fill="#111827"/>
|
|
894
|
+
<rect x="62" y="50" width="8" height="8" fill="#111827"/>
|
|
895
|
+
<rect x="50" y="62" width="8" height="8" fill="#111827"/>
|
|
896
|
+
<rect x="74" y="62" width="8" height="8" fill="#111827"/>
|
|
897
|
+
<rect x="62" y="74" width="8" height="8" fill="#111827"/>
|
|
898
|
+
<rect x="86" y="50" width="8" height="8" fill="#111827"/>
|
|
899
|
+
<rect x="74" y="86" width="8" height="8" fill="#111827"/>
|
|
900
|
+
<rect x="94" y="74" width="8" height="8" fill="#111827"/>
|
|
901
|
+
</svg>
|
|
902
|
+
`)}`, wt = `data:image/svg+xml;utf8,${encodeURIComponent(`
|
|
903
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 80">
|
|
904
|
+
<rect width="240" height="80" fill="#ffffff"/>
|
|
905
|
+
<g fill="#111827">
|
|
906
|
+
<rect x="18" y="10" width="4" height="52"/>
|
|
907
|
+
<rect x="26" y="10" width="2" height="52"/>
|
|
908
|
+
<rect x="32" y="10" width="6" height="52"/>
|
|
909
|
+
<rect x="42" y="10" width="3" height="52"/>
|
|
910
|
+
<rect x="49" y="10" width="5" height="52"/>
|
|
911
|
+
<rect x="58" y="10" width="2" height="52"/>
|
|
912
|
+
<rect x="64" y="10" width="7" height="52"/>
|
|
913
|
+
<rect x="75" y="10" width="3" height="52"/>
|
|
914
|
+
<rect x="82" y="10" width="6" height="52"/>
|
|
915
|
+
<rect x="92" y="10" width="2" height="52"/>
|
|
916
|
+
<rect x="98" y="10" width="5" height="52"/>
|
|
917
|
+
<rect x="108" y="10" width="4" height="52"/>
|
|
918
|
+
<rect x="116" y="10" width="2" height="52"/>
|
|
919
|
+
<rect x="122" y="10" width="6" height="52"/>
|
|
920
|
+
<rect x="132" y="10" width="3" height="52"/>
|
|
921
|
+
<rect x="139" y="10" width="5" height="52"/>
|
|
922
|
+
<rect x="148" y="10" width="2" height="52"/>
|
|
923
|
+
<rect x="154" y="10" width="7" height="52"/>
|
|
924
|
+
<rect x="165" y="10" width="3" height="52"/>
|
|
925
|
+
<rect x="172" y="10" width="5" height="52"/>
|
|
926
|
+
<rect x="181" y="10" width="2" height="52"/>
|
|
927
|
+
<rect x="187" y="10" width="6" height="52"/>
|
|
928
|
+
<rect x="197" y="10" width="3" height="52"/>
|
|
929
|
+
<rect x="204" y="10" width="5" height="52"/>
|
|
930
|
+
<rect x="213" y="10" width="4" height="52"/>
|
|
931
|
+
</g>
|
|
932
|
+
<text x="120" y="74" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#6b7280">123456789012</text>
|
|
933
|
+
</svg>
|
|
934
|
+
`)}`, xt = `data:image/svg+xml;utf8,${encodeURIComponent(`
|
|
935
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 100">
|
|
936
|
+
<rect width="160" height="100" fill="#f3f4f6"/>
|
|
937
|
+
<rect x="6" y="6" width="148" height="88" rx="8" fill="#ffffff" stroke="#cbd5e1" stroke-width="2"/>
|
|
938
|
+
<circle cx="48" cy="35" r="10" fill="#d1d5db"/>
|
|
939
|
+
<path d="M20 78 L58 50 L78 66 L98 56 L138 78 Z" fill="#cbd5e1"/>
|
|
940
|
+
<path d="M20 78 L44 62 L62 74 L84 58 L118 78 Z" fill="#9ca3af" opacity="0.9"/>
|
|
941
|
+
</svg>
|
|
942
|
+
`)}`;
|
|
943
|
+
function bt({ boardId: e, board: t, canEdit: n = !0 }) {
|
|
944
|
+
const {
|
|
945
|
+
registerContainer: a,
|
|
946
|
+
stageRef: s,
|
|
947
|
+
stageSize: o,
|
|
948
|
+
stageScale: c,
|
|
949
|
+
stagePosition: g,
|
|
950
|
+
handleMouseDown: m,
|
|
951
|
+
handleMouseMove: _,
|
|
952
|
+
handleMouseUp: M,
|
|
953
|
+
handleWheel: R,
|
|
954
|
+
handleDragEnd: I,
|
|
955
|
+
handleTransformEnd: l
|
|
956
|
+
} = st(e, { canEdit: n }), p = F((r) => r.elements), S = F((r) => r.selectedId), y = F((r) => r.setSelectedId), d = F((r) => r.updateElement), P = F((r) => r.assetUrl), z = F((r) => r.dataSourceMeta), k = F((r) => r.colorEyedropperActive), Z = F((r) => r.setColorEyedropped), u = F((r) => r.setColorEyedropperActive), b = Y(
|
|
957
|
+
() => p.find((r) => r.id === S) ?? null,
|
|
958
|
+
[p, S]
|
|
959
|
+
), A = K(0), T = j(
|
|
960
|
+
(r) => {
|
|
961
|
+
y(r);
|
|
962
|
+
},
|
|
963
|
+
[y]
|
|
964
|
+
), [C] = ce(P ?? "", "anonymous"), [L] = ce(mt, "anonymous"), [q] = ce(wt, "anonymous"), [B] = ce(xt, "anonymous"), D = Y(
|
|
965
|
+
() => ct({
|
|
966
|
+
...t?.config,
|
|
967
|
+
orientation: t?.orientation
|
|
968
|
+
}),
|
|
969
|
+
[t?.config, t?.orientation]
|
|
970
|
+
), x = Y(() => lt(o, D), [o, D]), G = Y(() => ut(o, {
|
|
971
|
+
width: C?.width,
|
|
972
|
+
height: C?.height
|
|
973
|
+
}), [o, C]), J = Y(() => C ? ht(x, {
|
|
974
|
+
width: C.width,
|
|
975
|
+
height: C.height
|
|
976
|
+
}) : x, [C, x]), ee = Y(() => {
|
|
977
|
+
if (!b)
|
|
978
|
+
return null;
|
|
979
|
+
const r = b.properties.coordinateSpace === "page" ? {
|
|
980
|
+
x: b.x,
|
|
981
|
+
y: b.y,
|
|
982
|
+
width: b.width,
|
|
983
|
+
height: b.height
|
|
984
|
+
} : Te(
|
|
985
|
+
{
|
|
986
|
+
x: b.x,
|
|
987
|
+
y: b.y,
|
|
988
|
+
width: b.width,
|
|
989
|
+
height: b.height
|
|
990
|
+
},
|
|
991
|
+
G,
|
|
992
|
+
D
|
|
993
|
+
);
|
|
994
|
+
return Re(r, x, D);
|
|
995
|
+
}, [b, G, D, x]), V = Y(
|
|
996
|
+
() => ({
|
|
997
|
+
x: x.x + 10,
|
|
998
|
+
y: x.y + 10,
|
|
999
|
+
width: x.width - 20,
|
|
1000
|
+
height: x.height - 20
|
|
1001
|
+
}),
|
|
1002
|
+
[x]
|
|
1003
|
+
), ie = j(
|
|
1004
|
+
(r) => {
|
|
1005
|
+
if (!k)
|
|
1006
|
+
return !1;
|
|
1007
|
+
const f = s.current, h = f?.getPointerPosition(), U = f?.getLayers()[0]?.getNativeCanvasElement(), E = U?.getContext("2d");
|
|
1008
|
+
if (r.cancelBubble = !0, r.evt.preventDefault(), !f || !h || !U || !E)
|
|
1009
|
+
return !0;
|
|
1010
|
+
const H = Math.max(
|
|
1011
|
+
0,
|
|
1012
|
+
Math.min(U.width - 1, Math.round(h.x / Math.max(1, f.width()) * U.width))
|
|
1013
|
+
), N = Math.max(
|
|
1014
|
+
0,
|
|
1015
|
+
Math.min(U.height - 1, Math.round(h.y / Math.max(1, f.height()) * U.height))
|
|
1016
|
+
), [v, te, W, de] = E.getImageData(H, N, 1, 1).data;
|
|
1017
|
+
return de === 0 || (A.current = Date.now() + 250, Z(
|
|
1018
|
+
`#${[v, te, W].map((je) => je.toString(16).padStart(2, "0")).join("")}`
|
|
1019
|
+
), u(!1)), !0;
|
|
1020
|
+
},
|
|
1021
|
+
[k, Z, u, s]
|
|
1022
|
+
), i = j(
|
|
1023
|
+
(r) => {
|
|
1024
|
+
const f = r.properties.coordinateSpace === "page" ? {
|
|
1025
|
+
x: r.x,
|
|
1026
|
+
y: r.y,
|
|
1027
|
+
width: r.width,
|
|
1028
|
+
height: r.height
|
|
1029
|
+
} : Te(
|
|
1030
|
+
{
|
|
1031
|
+
x: r.x,
|
|
1032
|
+
y: r.y,
|
|
1033
|
+
width: r.width,
|
|
1034
|
+
height: r.height
|
|
1035
|
+
},
|
|
1036
|
+
G,
|
|
1037
|
+
D
|
|
1038
|
+
), h = Re(f, x, D), $ = {
|
|
1039
|
+
id: r.id,
|
|
1040
|
+
x: h.x,
|
|
1041
|
+
y: h.y,
|
|
1042
|
+
width: h.width,
|
|
1043
|
+
height: h.height,
|
|
1044
|
+
draggable: n && !k,
|
|
1045
|
+
onClick: () => {
|
|
1046
|
+
Date.now() < A.current || k || T(r.id);
|
|
1047
|
+
},
|
|
1048
|
+
onTap: () => {
|
|
1049
|
+
Date.now() < A.current || k || T(r.id);
|
|
1050
|
+
},
|
|
1051
|
+
onDragEnd: (N) => {
|
|
1052
|
+
if (!n || k) return;
|
|
1053
|
+
const v = he(
|
|
1054
|
+
{
|
|
1055
|
+
x: N.target.x(),
|
|
1056
|
+
y: N.target.y(),
|
|
1057
|
+
width: h.width,
|
|
1058
|
+
height: h.height
|
|
1059
|
+
},
|
|
1060
|
+
x,
|
|
1061
|
+
D
|
|
1062
|
+
), te = {
|
|
1063
|
+
...r.properties,
|
|
1064
|
+
coordinateSpace: "page"
|
|
1065
|
+
};
|
|
1066
|
+
d(r.id, {
|
|
1067
|
+
x: v.x,
|
|
1068
|
+
y: v.y,
|
|
1069
|
+
width: v.width,
|
|
1070
|
+
height: v.height,
|
|
1071
|
+
properties: te
|
|
1072
|
+
}), I(r, v.x, v.y, te);
|
|
1073
|
+
},
|
|
1074
|
+
onDragMove: (N) => {
|
|
1075
|
+
if (!n || k) return;
|
|
1076
|
+
const v = he(
|
|
1077
|
+
{
|
|
1078
|
+
x: N.target.x(),
|
|
1079
|
+
y: N.target.y(),
|
|
1080
|
+
width: h.width,
|
|
1081
|
+
height: h.height
|
|
1082
|
+
},
|
|
1083
|
+
x,
|
|
1084
|
+
D
|
|
1085
|
+
);
|
|
1086
|
+
d(r.id, {
|
|
1087
|
+
x: v.x,
|
|
1088
|
+
y: v.y,
|
|
1089
|
+
width: v.width,
|
|
1090
|
+
height: v.height,
|
|
1091
|
+
properties: {
|
|
1092
|
+
...r.properties,
|
|
1093
|
+
coordinateSpace: "page"
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
},
|
|
1097
|
+
onTransformEnd: (N) => {
|
|
1098
|
+
if (!n || k) return;
|
|
1099
|
+
const v = N.target, te = {
|
|
1100
|
+
x: v.x(),
|
|
1101
|
+
y: v.y(),
|
|
1102
|
+
width: v.width() * v.scaleX(),
|
|
1103
|
+
height: v.height() * v.scaleY()
|
|
1104
|
+
};
|
|
1105
|
+
v.scaleX(1), v.scaleY(1);
|
|
1106
|
+
const W = he(te, x, D), de = {
|
|
1107
|
+
...r.properties,
|
|
1108
|
+
coordinateSpace: "page"
|
|
1109
|
+
};
|
|
1110
|
+
d(r.id, {
|
|
1111
|
+
x: W.x,
|
|
1112
|
+
y: W.y,
|
|
1113
|
+
width: W.width,
|
|
1114
|
+
height: W.height,
|
|
1115
|
+
properties: de
|
|
1116
|
+
}), l(
|
|
1117
|
+
r,
|
|
1118
|
+
{
|
|
1119
|
+
x: W.x,
|
|
1120
|
+
y: W.y,
|
|
1121
|
+
width: W.width,
|
|
1122
|
+
height: W.height,
|
|
1123
|
+
rotation: v.rotation()
|
|
1124
|
+
},
|
|
1125
|
+
de
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
}, U = typeof r.properties.bindingKey == "string" ? r.properties.bindingKey : null, E = U ? z?.previewRow[U] ?? null : null;
|
|
1129
|
+
if (E ? pt(E) : !1)
|
|
1130
|
+
return /* @__PURE__ */ w.jsx(
|
|
1131
|
+
se,
|
|
1132
|
+
{
|
|
1133
|
+
...$,
|
|
1134
|
+
image: B ?? void 0,
|
|
1135
|
+
width: h.width,
|
|
1136
|
+
height: h.height,
|
|
1137
|
+
opacity: r.properties.opacity
|
|
1138
|
+
},
|
|
1139
|
+
r.id
|
|
1140
|
+
);
|
|
1141
|
+
if (r.type === "text") {
|
|
1142
|
+
const N = [r.properties.fontWeight, r.properties.italic ? "italic" : ""].join(" ").trim(), v = r.properties.underline ? "underline" : "";
|
|
1143
|
+
return /* @__PURE__ */ w.jsx(
|
|
1144
|
+
ye,
|
|
1145
|
+
{
|
|
1146
|
+
...$,
|
|
1147
|
+
text: r.text ?? "{{Text}}",
|
|
1148
|
+
fontSize: r.properties.fontSize,
|
|
1149
|
+
fontFamily: r.properties.fontFamily,
|
|
1150
|
+
fontStyle: N,
|
|
1151
|
+
textDecoration: v,
|
|
1152
|
+
fill: r.properties.color,
|
|
1153
|
+
padding: 8,
|
|
1154
|
+
align: r.properties.textAlign,
|
|
1155
|
+
verticalAlign: "middle",
|
|
1156
|
+
opacity: r.properties.opacity
|
|
1157
|
+
},
|
|
1158
|
+
r.id
|
|
1159
|
+
);
|
|
1160
|
+
}
|
|
1161
|
+
return r.type === "qr_code" ? /* @__PURE__ */ w.jsx(
|
|
1162
|
+
se,
|
|
1163
|
+
{
|
|
1164
|
+
...$,
|
|
1165
|
+
image: L ?? void 0,
|
|
1166
|
+
width: h.width,
|
|
1167
|
+
height: h.height,
|
|
1168
|
+
opacity: r.properties.opacity
|
|
1169
|
+
},
|
|
1170
|
+
r.id
|
|
1171
|
+
) : r.type === "bar_code" ? /* @__PURE__ */ w.jsx(
|
|
1172
|
+
se,
|
|
1173
|
+
{
|
|
1174
|
+
...$,
|
|
1175
|
+
image: q ?? void 0,
|
|
1176
|
+
width: h.width,
|
|
1177
|
+
height: h.height,
|
|
1178
|
+
opacity: r.properties.opacity
|
|
1179
|
+
},
|
|
1180
|
+
r.id
|
|
1181
|
+
) : /* @__PURE__ */ w.jsx(
|
|
1182
|
+
ft,
|
|
1183
|
+
{
|
|
1184
|
+
sharedProps: $,
|
|
1185
|
+
src: r.properties.src ?? r.src,
|
|
1186
|
+
placeholder: B ?? void 0,
|
|
1187
|
+
width: h.width,
|
|
1188
|
+
height: h.height,
|
|
1189
|
+
opacity: r.properties.opacity
|
|
1190
|
+
},
|
|
1191
|
+
r.id
|
|
1192
|
+
);
|
|
1193
|
+
},
|
|
1194
|
+
[
|
|
1195
|
+
T,
|
|
1196
|
+
I,
|
|
1197
|
+
l,
|
|
1198
|
+
d,
|
|
1199
|
+
x,
|
|
1200
|
+
D,
|
|
1201
|
+
G,
|
|
1202
|
+
L,
|
|
1203
|
+
q,
|
|
1204
|
+
B,
|
|
1205
|
+
n,
|
|
1206
|
+
z,
|
|
1207
|
+
k
|
|
1208
|
+
]
|
|
1209
|
+
);
|
|
1210
|
+
return /* @__PURE__ */ w.jsx("div", { className: "formiq-board-canvas", children: /* @__PURE__ */ w.jsx(
|
|
1211
|
+
"div",
|
|
1212
|
+
{
|
|
1213
|
+
id: "formiq-board-canvas",
|
|
1214
|
+
ref: a,
|
|
1215
|
+
className: "formiq-board-canvas__stage",
|
|
1216
|
+
style: {
|
|
1217
|
+
backgroundColor: "#f3f5fb",
|
|
1218
|
+
backgroundImage: "radial-gradient(rgba(15,23,42,0.12) 1.7px, transparent 1px)",
|
|
1219
|
+
backgroundSize: "32px 32px",
|
|
1220
|
+
cursor: k ? "crosshair" : "default"
|
|
1221
|
+
},
|
|
1222
|
+
children: /* @__PURE__ */ w.jsx(
|
|
1223
|
+
ze,
|
|
1224
|
+
{
|
|
1225
|
+
ref: s,
|
|
1226
|
+
width: o.width,
|
|
1227
|
+
height: o.height,
|
|
1228
|
+
x: g.x,
|
|
1229
|
+
y: g.y,
|
|
1230
|
+
scaleX: c,
|
|
1231
|
+
scaleY: c,
|
|
1232
|
+
onWheel: R,
|
|
1233
|
+
onMouseDown: (r) => {
|
|
1234
|
+
ie(r) || m(r);
|
|
1235
|
+
},
|
|
1236
|
+
onMouseMove: _,
|
|
1237
|
+
onMouseUp: M,
|
|
1238
|
+
onTouchStart: ie,
|
|
1239
|
+
onTouchEnd: M,
|
|
1240
|
+
onMouseLeave: M,
|
|
1241
|
+
onTouchMove: _,
|
|
1242
|
+
children: /* @__PURE__ */ w.jsxs(Fe, { children: [
|
|
1243
|
+
/* @__PURE__ */ w.jsx(
|
|
1244
|
+
ge,
|
|
1245
|
+
{
|
|
1246
|
+
x: x.x,
|
|
1247
|
+
y: x.y,
|
|
1248
|
+
width: x.width,
|
|
1249
|
+
height: x.height,
|
|
1250
|
+
cornerRadius: 20,
|
|
1251
|
+
fill: "#ffffff",
|
|
1252
|
+
shadowColor: "#0f172a",
|
|
1253
|
+
shadowBlur: 16,
|
|
1254
|
+
shadowOpacity: 0.12
|
|
1255
|
+
}
|
|
1256
|
+
),
|
|
1257
|
+
C ? /* @__PURE__ */ w.jsx(
|
|
1258
|
+
se,
|
|
1259
|
+
{
|
|
1260
|
+
image: C,
|
|
1261
|
+
x: J.x,
|
|
1262
|
+
y: J.y,
|
|
1263
|
+
width: J.width,
|
|
1264
|
+
height: J.height,
|
|
1265
|
+
cornerRadius: 20
|
|
1266
|
+
}
|
|
1267
|
+
) : /* @__PURE__ */ w.jsx(
|
|
1268
|
+
ge,
|
|
1269
|
+
{
|
|
1270
|
+
x: x.x,
|
|
1271
|
+
y: x.y,
|
|
1272
|
+
width: x.width,
|
|
1273
|
+
height: x.height,
|
|
1274
|
+
cornerRadius: 20,
|
|
1275
|
+
fillLinearGradientColorStops: [0, "#03072b", 0.55, "#0b2b64", 1, "#031a4c"],
|
|
1276
|
+
shadowColor: "#0f172a",
|
|
1277
|
+
shadowBlur: 40
|
|
1278
|
+
}
|
|
1279
|
+
),
|
|
1280
|
+
/* @__PURE__ */ w.jsx(
|
|
1281
|
+
ge,
|
|
1282
|
+
{
|
|
1283
|
+
x: V.x,
|
|
1284
|
+
y: V.y,
|
|
1285
|
+
width: V.width,
|
|
1286
|
+
height: V.height,
|
|
1287
|
+
cornerRadius: 18,
|
|
1288
|
+
stroke: "#7dd3fc",
|
|
1289
|
+
strokeWidth: 2,
|
|
1290
|
+
dash: [10, 6],
|
|
1291
|
+
opacity: 0.5
|
|
1292
|
+
}
|
|
1293
|
+
),
|
|
1294
|
+
p.slice().sort((r, f) => r.zIndex - f.zIndex).map((r) => i(r)),
|
|
1295
|
+
b && ee && /* @__PURE__ */ w.jsxs(
|
|
1296
|
+
Le,
|
|
1297
|
+
{
|
|
1298
|
+
x: Math.max(ee.x, 0),
|
|
1299
|
+
y: Math.max(ee.y - 28, 0),
|
|
1300
|
+
listening: !1,
|
|
1301
|
+
children: [
|
|
1302
|
+
/* @__PURE__ */ w.jsx(Ue, { fill: "#2563eb", cornerRadius: 4 }),
|
|
1303
|
+
/* @__PURE__ */ w.jsx(ye, { text: yt[b.type], fontSize: 12, fill: "#fff", padding: 6 })
|
|
1304
|
+
]
|
|
1305
|
+
}
|
|
1306
|
+
),
|
|
1307
|
+
n && S && /* @__PURE__ */ w.jsx(
|
|
1308
|
+
qe,
|
|
1309
|
+
{
|
|
1310
|
+
ref: (r) => {
|
|
1311
|
+
if (!r) return;
|
|
1312
|
+
const h = r.getStage()?.findOne(`#${S}`);
|
|
1313
|
+
r.nodes(h ? [h] : []);
|
|
1314
|
+
},
|
|
1315
|
+
boundBoxFunc: (r, f) => ({
|
|
1316
|
+
...f,
|
|
1317
|
+
width: Math.max(f.width, 20),
|
|
1318
|
+
height: Math.max(f.height, 20)
|
|
1319
|
+
})
|
|
1320
|
+
}
|
|
1321
|
+
)
|
|
1322
|
+
] })
|
|
1323
|
+
}
|
|
1324
|
+
)
|
|
1325
|
+
}
|
|
1326
|
+
) });
|
|
1327
|
+
}
|
|
1328
|
+
const re = {
|
|
1329
|
+
fontFamily: "Poppins",
|
|
1330
|
+
italic: !1,
|
|
1331
|
+
underline: !1,
|
|
1332
|
+
fontSize: 24,
|
|
1333
|
+
color: "#ffffff",
|
|
1334
|
+
opacity: 1
|
|
1335
|
+
};
|
|
1336
|
+
function vt(e) {
|
|
1337
|
+
return e === "center" || e === "right" ? e : "left";
|
|
1338
|
+
}
|
|
1339
|
+
function Et(e) {
|
|
1340
|
+
return e === "bold" ? "bold" : "normal";
|
|
1341
|
+
}
|
|
1342
|
+
function ue(e, t = !1) {
|
|
1343
|
+
return typeof e == "boolean" ? e : t;
|
|
1344
|
+
}
|
|
1345
|
+
function Pe(e) {
|
|
1346
|
+
const t = e.properties ?? {}, n = {
|
|
1347
|
+
fontFamily: typeof t.fontFamily == "string" ? t.fontFamily : re.fontFamily,
|
|
1348
|
+
fontWeight: Et(t.fontWeight),
|
|
1349
|
+
italic: ue(
|
|
1350
|
+
t.italic,
|
|
1351
|
+
ue(t.isItalicText, re.italic)
|
|
1352
|
+
),
|
|
1353
|
+
underline: ue(
|
|
1354
|
+
t.underline,
|
|
1355
|
+
ue(t.isUnderlineText, re.underline)
|
|
1356
|
+
),
|
|
1357
|
+
fontSize: typeof t.fontSize == "number" ? t.fontSize : re.fontSize,
|
|
1358
|
+
textAlign: vt(t.textAlign),
|
|
1359
|
+
color: typeof t.color == "string" ? t.color : re.color,
|
|
1360
|
+
opacity: typeof t.opacity == "number" ? t.opacity : re.opacity,
|
|
1361
|
+
coordinateSpace: t.coordinateSpace === "page" ? "page" : "stage",
|
|
1362
|
+
bindingKey: typeof t.bindingKey == "string" ? t.bindingKey : typeof t.bindingKey == "number" ? String(t.bindingKey) : void 0,
|
|
1363
|
+
data: typeof t.data == "string" ? t.data : typeof e.data == "string" ? e.data : void 0,
|
|
1364
|
+
src: typeof t.src == "string" ? t.src : typeof e.src == "string" ? e.src : void 0,
|
|
1365
|
+
isIncrementalVariable: typeof t.isIncrementalVariable == "boolean" ? t.isIncrementalVariable : !1,
|
|
1366
|
+
generationType: t.generationType === "alphanumeric" || t.generationType === "integer" ? t.generationType : void 0,
|
|
1367
|
+
incrementCount: typeof t.incrementCount == "number" && Number.isFinite(t.incrementCount) ? t.incrementCount : void 0,
|
|
1368
|
+
incrementStart: typeof t.incrementStart == "number" && Number.isFinite(t.incrementStart) ? t.incrementStart : void 0,
|
|
1369
|
+
incrementPadLength: typeof t.incrementPadLength == "number" && Number.isFinite(t.incrementPadLength) ? t.incrementPadLength : void 0,
|
|
1370
|
+
incrementSeed: typeof t.incrementSeed == "string" ? t.incrementSeed : void 0
|
|
1371
|
+
};
|
|
1372
|
+
return {
|
|
1373
|
+
id: e.id.toString(),
|
|
1374
|
+
dbId: e.id,
|
|
1375
|
+
configDbId: e.canvasElementConfigId,
|
|
1376
|
+
type: e.type,
|
|
1377
|
+
x: e.x,
|
|
1378
|
+
y: e.y,
|
|
1379
|
+
rotation: e.rotation ?? 0,
|
|
1380
|
+
width: e.width,
|
|
1381
|
+
height: e.height,
|
|
1382
|
+
zIndex: e.zIndex,
|
|
1383
|
+
generationType: n.generationType,
|
|
1384
|
+
text: typeof t.text == "string" ? t.text : e.type === "text" && n.bindingKey ? `{{${n.bindingKey}}}` : void 0,
|
|
1385
|
+
data: n.data,
|
|
1386
|
+
src: n.src,
|
|
1387
|
+
properties: n
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
function _t(e) {
|
|
1391
|
+
if (!e) return null;
|
|
1392
|
+
const t = Array.isArray(e.columnHeaders) ? e.columnHeaders : [], n = Array.isArray(e.parsedData) && e.parsedData.length ? e.parsedData[0] : {};
|
|
1393
|
+
return { columnHeaders: t, previewRow: n };
|
|
1394
|
+
}
|
|
1395
|
+
function kt({ boardId: e, canEdit: t = !0 }) {
|
|
1396
|
+
const [n, a] = ne(null), [s, o] = ne(!1), c = F((y) => y.setElements), g = F((y) => y.mergeElements), m = F((y) => y.setDataSourceMeta), _ = F((y) => y.setAssetUrl), M = K(!1);
|
|
1397
|
+
Q(() => {
|
|
1398
|
+
const y = Me();
|
|
1399
|
+
a(y), o(!0);
|
|
1400
|
+
}, []);
|
|
1401
|
+
const R = et(e, { enabled: !!(s && n) }), { canvasElements: I } = ke(e, { enabled: !!(s && n) }), l = ot(e), p = Y(() => R.data ? R.data.board.boardName : "Board", [R.data]);
|
|
1402
|
+
Q(() => {
|
|
1403
|
+
if (!R.data?.board) {
|
|
1404
|
+
c([]), m(null), _(null);
|
|
1405
|
+
return;
|
|
1406
|
+
}
|
|
1407
|
+
const { board: y } = R.data;
|
|
1408
|
+
m(_t(y.dataSource)), _(y.asset?.fileUrl ?? null);
|
|
1409
|
+
}, [R.data, c, m, _]), Q(() => {
|
|
1410
|
+
if (I) {
|
|
1411
|
+
if (!M.current) {
|
|
1412
|
+
c(I.map(Pe)), M.current = !0;
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
g(I.map(Pe));
|
|
1416
|
+
}
|
|
1417
|
+
}, [I, c, g]);
|
|
1418
|
+
async function S() {
|
|
1419
|
+
if (l.status === "READY" && l.downloadUrl) {
|
|
1420
|
+
window.open(l.downloadUrl, "_blank", "noopener,noreferrer");
|
|
1421
|
+
return;
|
|
1422
|
+
}
|
|
1423
|
+
await l.triggerGeneration();
|
|
1424
|
+
}
|
|
1425
|
+
return /* @__PURE__ */ w.jsxs("div", { className: "formiq-board", children: [
|
|
1426
|
+
/* @__PURE__ */ w.jsxs("div", { className: "formiq-board__header", children: [
|
|
1427
|
+
/* @__PURE__ */ w.jsx("div", { className: "formiq-board__title", children: p }),
|
|
1428
|
+
/* @__PURE__ */ w.jsxs("div", { className: "formiq-board__actions", children: [
|
|
1429
|
+
/* @__PURE__ */ w.jsx(
|
|
1430
|
+
"button",
|
|
1431
|
+
{
|
|
1432
|
+
type: "button",
|
|
1433
|
+
className: "formiq-board__button",
|
|
1434
|
+
onClick: S,
|
|
1435
|
+
disabled: l.isTriggering || l.isGenerating || !n,
|
|
1436
|
+
children: l.isGenerating ? `Generating ${l.progress}%` : "Generate PDF"
|
|
1437
|
+
}
|
|
1438
|
+
),
|
|
1439
|
+
l.downloadUrl && l.status === "READY" && /* @__PURE__ */ w.jsx(
|
|
1440
|
+
"button",
|
|
1441
|
+
{
|
|
1442
|
+
type: "button",
|
|
1443
|
+
className: "formiq-board__button formiq-board__button--ghost",
|
|
1444
|
+
onClick: () => window.open(l.downloadUrl, "_blank", "noopener,noreferrer"),
|
|
1445
|
+
children: "Download PDF"
|
|
1446
|
+
}
|
|
1447
|
+
)
|
|
1448
|
+
] })
|
|
1449
|
+
] }),
|
|
1450
|
+
R.isError && /* @__PURE__ */ w.jsx("div", { className: "formiq-board__error", children: "Failed to load board. Check your PAT and board id." }),
|
|
1451
|
+
!n && /* @__PURE__ */ w.jsxs("div", { className: "formiq-board__empty", children: [
|
|
1452
|
+
"No PAT provided. Wrap this component with ",
|
|
1453
|
+
/* @__PURE__ */ w.jsx("code", { children: '<FormiqProvider token="...">' }),
|
|
1454
|
+
"."
|
|
1455
|
+
] }),
|
|
1456
|
+
n && /* @__PURE__ */ w.jsx("div", { className: "formiq-board__canvas", children: /* @__PURE__ */ w.jsx(bt, { boardId: e, board: R.data?.board, canEdit: t }) })
|
|
1457
|
+
] });
|
|
1458
|
+
}
|
|
1459
|
+
function jt({ token: e, children: t }) {
|
|
1460
|
+
const n = Y(() => e.trim(), [e]);
|
|
1461
|
+
return Q(() => {
|
|
1462
|
+
n && Ie(n);
|
|
1463
|
+
}, [n]), /* @__PURE__ */ w.jsx(w.Fragment, { children: t });
|
|
1464
|
+
}
|
|
1465
|
+
function Ot(e) {
|
|
1466
|
+
return fe({
|
|
1467
|
+
queryKey: ["validate-pat", e],
|
|
1468
|
+
queryFn: () => Ke(e ?? ""),
|
|
1469
|
+
enabled: !!e,
|
|
1470
|
+
staleTime: 6e4
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
export {
|
|
1474
|
+
kt as BoardEditor,
|
|
1475
|
+
jt as FormiqProvider,
|
|
1476
|
+
It as clearPersonalAccessToken,
|
|
1477
|
+
Me as getPersonalAccessToken,
|
|
1478
|
+
Ie as setPersonalAccessToken,
|
|
1479
|
+
st as useBoardCanvas,
|
|
1480
|
+
et as useBoardEditor,
|
|
1481
|
+
ke as useCanvasElement,
|
|
1482
|
+
F as useCanvasStore,
|
|
1483
|
+
ot as useProduce,
|
|
1484
|
+
Ot as useValidatePat
|
|
1485
|
+
};
|