@gospelfix/qr 0.0.0-stage → 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/react.js ADDED
@@ -0,0 +1,608 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var chunk2YL4VYHX_js = require('./chunk-2YL4VYHX.js');
5
+ var react = require('react');
6
+ var clsx = require('clsx');
7
+ var tailwindMerge = require('tailwind-merge');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+ var button = require('@base-ui/react/button');
10
+ var classVarianceAuthority = require('class-variance-authority');
11
+ var input = require('@base-ui/react/input');
12
+ var select = require('@base-ui/react/select');
13
+ var lucideReact = require('lucide-react');
14
+
15
+ function cn(...inputs) {
16
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
17
+ }
18
+ function Card({
19
+ className,
20
+ size = "default",
21
+ ...props
22
+ }) {
23
+ return /* @__PURE__ */ jsxRuntime.jsx(
24
+ "div",
25
+ {
26
+ "data-slot": "card",
27
+ "data-size": size,
28
+ className: cn(
29
+ "flex flex-col gap-[var(--card-spacing)] overflow-hidden rounded-2xl border border-border bg-card py-[var(--card-spacing)] text-[13px] text-card-foreground [--card-spacing:1rem] data-[size=sm]:[--card-spacing:0.75rem]",
30
+ className
31
+ ),
32
+ ...props
33
+ }
34
+ );
35
+ }
36
+ function CardContent({ className, ...props }) {
37
+ return /* @__PURE__ */ jsxRuntime.jsx(
38
+ "div",
39
+ {
40
+ "data-slot": "card-content",
41
+ className: cn("px-[var(--card-spacing)]", className),
42
+ ...props
43
+ }
44
+ );
45
+ }
46
+ function AccountCard({ bankName, accountNumber, accountHolder }) {
47
+ return /* @__PURE__ */ jsxRuntime.jsx(Card, { className: "gap-0 py-0", children: /* @__PURE__ */ jsxRuntime.jsx(CardContent, { className: "px-0", children: /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "divide-y divide-border", children: [
48
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2 px-4 py-3", children: [
49
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { className: "shrink-0 text-muted-foreground", children: "\uBC1B\uB294 \uC740\uD589" }),
50
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-right font-semibold", children: bankName })
51
+ ] }),
52
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2 px-4 py-3", children: [
53
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { className: "shrink-0 text-muted-foreground", children: "\uACC4\uC88C\uBC88\uD638" }),
54
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { className: "break-all text-right font-mono font-semibold", children: accountNumber })
55
+ ] }),
56
+ accountHolder && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2 px-4 py-3", children: [
57
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { className: "shrink-0 text-muted-foreground", children: "\uC608\uAE08\uC8FC" }),
58
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-right font-semibold", children: accountHolder })
59
+ ] })
60
+ ] }) }) });
61
+ }
62
+ function AmountHero({ amount }) {
63
+ if (amount === null) return null;
64
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { "aria-label": "\uBCF4\uB0BC \uAE08\uC561", className: "space-y-1", children: [
65
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[13px] text-muted-foreground", children: "\uBCF4\uB0BC \uAE08\uC561" }),
66
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-2xl font-semibold", children: [
67
+ amount.toLocaleString("ko-KR"),
68
+ "\uC6D0"
69
+ ] })
70
+ ] });
71
+ }
72
+ var buttonVariants = classVarianceAuthority.cva(
73
+ "inline-flex shrink-0 items-center justify-center rounded-2xl border border-transparent whitespace-nowrap transition-colors outline-none select-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
74
+ {
75
+ variants: {
76
+ variant: {
77
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
78
+ // aria-pressed: 선택된 타일은 검정 2px 테두리로 구분한다(고정 높이라 레이아웃은 밀리지 않음)
79
+ outline: "border-border bg-card text-foreground hover:bg-muted aria-pressed:border-2 aria-pressed:border-foreground",
80
+ secondary: "bg-secondary text-secondary-foreground hover:bg-muted",
81
+ ghost: "text-foreground hover:bg-muted",
82
+ link: "text-foreground underline-offset-4 hover:underline"
83
+ },
84
+ size: {
85
+ default: "h-12 gap-2 px-2 text-[13px] font-normal",
86
+ lg: "h-12 gap-2 px-4 text-base font-semibold"
87
+ }
88
+ },
89
+ defaultVariants: {
90
+ variant: "default",
91
+ size: "default"
92
+ }
93
+ }
94
+ );
95
+ function Button({
96
+ className,
97
+ variant = "default",
98
+ size = "default",
99
+ ...props
100
+ }) {
101
+ return /* @__PURE__ */ jsxRuntime.jsx(
102
+ button.Button,
103
+ {
104
+ "data-slot": "button",
105
+ className: cn(buttonVariants({ variant, size, className })),
106
+ ...props
107
+ }
108
+ );
109
+ }
110
+ function AppGrid({ transfer, onCopy, copiedAppName }) {
111
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { "aria-labelledby": "app-grid-title", className: "space-y-2", children: [
112
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { id: "app-grid-title", className: "text-[13px] font-semibold", children: "\uC790\uC8FC \uC4F0\uB294 \uC571" }),
113
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "grid grid-cols-4 gap-2", children: chunk2YL4VYHX_js.LAUNCH_APPS.map((app) => {
114
+ const url = app.buildUrl(transfer);
115
+ return /* @__PURE__ */ jsxRuntime.jsx("li", { className: "flex", children: url ? (
116
+ // 일반 <a>: 커스텀 스킴을 라우터가 가로채지 않게 한다.
117
+ // 계좌가 채워지지 않는 앱은 누를 때 계좌번호를 복사해 두어 앱에서 붙여넣기만 하면 된다
118
+ /* @__PURE__ */ jsxRuntime.jsx(
119
+ "a",
120
+ {
121
+ className: cn(buttonVariants({ variant: "outline" }), "w-full"),
122
+ href: url,
123
+ onClick: app.prefilled ? void 0 : () => onCopy(app.name),
124
+ children: app.name
125
+ }
126
+ )
127
+ ) : (
128
+ // 열 수 없는 앱은 숨기지 않고 복사 타일로 대체한다
129
+ /* @__PURE__ */ jsxRuntime.jsx(
130
+ Button,
131
+ {
132
+ variant: "outline",
133
+ className: "w-full",
134
+ "aria-pressed": copiedAppName === app.name,
135
+ onClick: () => onCopy(app.name),
136
+ children: app.name
137
+ }
138
+ )
139
+ ) }, app.id);
140
+ }) }),
141
+ /* @__PURE__ */ jsxRuntime.jsx("p", { role: "status", className: "text-[13px] text-muted-foreground", children: copiedAppName && `\uACC4\uC88C\uBC88\uD638\uAC00 \uBCF5\uC0AC\uB410\uC5B4\uC694. ${copiedAppName} \uC571\uC744 \uC5F4\uC5B4 \uBD99\uC5EC\uB123\uC5B4 \uC8FC\uC138\uC694.` })
142
+ ] });
143
+ }
144
+ function CopyBar({ copied, onCopy }) {
145
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sticky bottom-0 border-t border-border bg-background pb-[env(safe-area-inset-bottom)]", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 py-3", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { size: "lg", className: "w-full", onClick: onCopy, "aria-live": "polite", children: copied ? "\uBCF5\uC0AC\uB410\uC5B4\uC694" : "\uACC4\uC88C\uBC88\uD638 \uBCF5\uC0AC" }) }) });
146
+ }
147
+ function GuideSteps() {
148
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { "aria-label": "\uC1A1\uAE08 \uBC29\uBC95", className: "space-y-4", children: [
149
+ /* @__PURE__ */ jsxRuntime.jsxs("ol", { className: "list-decimal space-y-2 pl-4 text-[13px]", children: [
150
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "\uACC4\uC88C\uBC88\uD638 \uBCF5\uC0AC" }),
151
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "\uAE08\uC735\uC571 \uC5F4\uAE30" }),
152
+ /* @__PURE__ */ jsxRuntime.jsx("li", { children: "\uBD99\uC5EC\uB123\uACE0 \uC740\uD589\xB7\uACC4\uC88C\uBC88\uD638\xB7\uC608\uAE08\uC8FC\xB7\uAE08\uC561 \uD655\uC778" })
153
+ ] }),
154
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[11px] leading-relaxed text-muted-foreground", children: "\uC571\uC774 \uC5F4\uB9AC\uC9C0 \uC54A\uC73C\uBA74 \uACC4\uC88C\uBC88\uD638\uB97C \uBCF5\uC0AC\uD574 \uC0AC\uC6A9 \uC911\uC778 \uAE08\uC735\uC571\uC5D0\uC11C \uC9C1\uC811 \uC1A1\uAE08\uD574 \uC8FC\uC138\uC694." }),
155
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[11px] leading-relaxed text-muted-foreground", children: "\uAE08\uC735\uC571 \uC1A1\uAE08 \uD654\uBA74\uC744 \uC5EC\uB294 \uD3B8\uC758 \uAE30\uB2A5\uC774\uBA70 \uAC00\uC2A4\uD384\uD53D\uC2A4\uB294 \uD574\uB2F9 \uAE08\uC735\uC571 \uD68C\uC0AC\uC640 \uC81C\uD734 \uAD00\uACC4\uAC00 \uC544\uB2C8\uC5D0\uC694. \uBCF4\uB0B4\uAE30 \uC804 \uBC1B\uB294 \uC740\uD589\xB7\uACC4\uC88C\uBC88\uD638\xB7\uC608\uAE08\uC8FC\xB7\uAE08\uC561\uC744 \uAF2D \uD655\uC778\uD574\uC8FC\uC138\uC694." })
156
+ ] });
157
+ }
158
+ function InvalidLink() {
159
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 py-8", children: /* @__PURE__ */ jsxRuntime.jsx(Card, { role: "alert", children: /* @__PURE__ */ jsxRuntime.jsx(CardContent, { className: "text-muted-foreground", children: "\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 \uB9C1\uD06C\uC608\uC694. \uAC00\uC2A4\uD384\uD53D\uC2A4 \uC785\uAE08 \uC548\uB0B4 \uD654\uBA74\uC5D0\uC11C QR\uC744 \uB2E4\uC2DC \uB9CC\uB4E4\uC5B4 \uC8FC\uC138\uC694." }) }) });
160
+ }
161
+ function TransferHeader({ title = "\uC1A1\uAE08 \uC548\uB0B4" }) {
162
+ return /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex h-12 items-center justify-between border-b border-border px-4", children: [
163
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[13px] font-semibold", children: "\uAC00\uC2A4\uD384\uD53D\uC2A4" }),
164
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-[13px] font-normal text-muted-foreground", children: title })
165
+ ] });
166
+ }
167
+ function useCopy(value, resetMs = 1500) {
168
+ const [copied, setCopied] = react.useState(false);
169
+ const [lastLabel, setLastLabel] = react.useState(null);
170
+ const timer = react.useRef(null);
171
+ react.useEffect(() => {
172
+ return () => {
173
+ if (timer.current) clearTimeout(timer.current);
174
+ };
175
+ }, []);
176
+ const copy = react.useCallback(
177
+ async (label) => {
178
+ try {
179
+ await navigator.clipboard.writeText(value);
180
+ } catch {
181
+ return;
182
+ }
183
+ setLastLabel(label ?? null);
184
+ setCopied(true);
185
+ if (timer.current) clearTimeout(timer.current);
186
+ timer.current = setTimeout(() => setCopied(false), resetMs);
187
+ },
188
+ [value, resetMs]
189
+ );
190
+ return { copied, lastLabel, copy };
191
+ }
192
+ function TransferView() {
193
+ const [view, setView] = react.useState({ status: "loading" });
194
+ react.useEffect(() => {
195
+ const transfer = chunk2YL4VYHX_js.parseTransferHash(window.location.hash);
196
+ setView(transfer ? { status: "ready", transfer } : { status: "invalid" });
197
+ }, []);
198
+ if (view.status === "loading") return null;
199
+ if (view.status === "invalid") {
200
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
201
+ /* @__PURE__ */ jsxRuntime.jsx(TransferHeader, {}),
202
+ /* @__PURE__ */ jsxRuntime.jsx(InvalidLink, {})
203
+ ] });
204
+ }
205
+ return /* @__PURE__ */ jsxRuntime.jsx(ReadyView, { transfer: view.transfer });
206
+ }
207
+ function ReadyView({ transfer }) {
208
+ const { copied, lastLabel, copy } = useCopy(transfer.accountNumber);
209
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
210
+ /* @__PURE__ */ jsxRuntime.jsx(TransferHeader, {}),
211
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 space-y-6 px-4 pb-6 pt-6", children: [
212
+ /* @__PURE__ */ jsxRuntime.jsx(AmountHero, { amount: transfer.amount }),
213
+ /* @__PURE__ */ jsxRuntime.jsx(
214
+ AccountCard,
215
+ {
216
+ bankName: transfer.bankName,
217
+ accountNumber: transfer.accountNumber,
218
+ accountHolder: transfer.accountHolder
219
+ }
220
+ ),
221
+ /* @__PURE__ */ jsxRuntime.jsx(AppGrid, { transfer, onCopy: (name) => void copy(name), copiedAppName: lastLabel }),
222
+ /* @__PURE__ */ jsxRuntime.jsx(GuideSteps, {})
223
+ ] }),
224
+ /* @__PURE__ */ jsxRuntime.jsx(CopyBar, { copied, onCopy: () => void copy() })
225
+ ] });
226
+ }
227
+ function NoticeText({ children }) {
228
+ return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[13px] text-muted-foreground", children });
229
+ }
230
+ var QUIET_ZONE = 4;
231
+ var PNG_MODULE_PX = 10;
232
+ var PNG_FILE_NAME = "gospelfix-qr.png";
233
+ function buildPathData(matrix) {
234
+ const segments = [];
235
+ matrix.forEach((row, r) => {
236
+ let c = 0;
237
+ while (c < row.length) {
238
+ if (!row[c]) {
239
+ c += 1;
240
+ continue;
241
+ }
242
+ const start = c;
243
+ while (c < row.length && row[c]) c += 1;
244
+ segments.push(`M${start + QUIET_ZONE} ${r + QUIET_ZONE}h${c - start}v1h-${c - start}z`);
245
+ }
246
+ });
247
+ return segments.join("");
248
+ }
249
+ function downloadPng(matrix) {
250
+ const total = matrix.length + QUIET_ZONE * 2;
251
+ const canvas = document.createElement("canvas");
252
+ canvas.width = total * PNG_MODULE_PX;
253
+ canvas.height = total * PNG_MODULE_PX;
254
+ const ctx = canvas.getContext("2d");
255
+ if (!ctx) return;
256
+ ctx.fillStyle = "#ffffff";
257
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
258
+ ctx.fillStyle = "#000000";
259
+ matrix.forEach((row, r) => {
260
+ row.forEach((dark, c) => {
261
+ if (!dark) return;
262
+ ctx.fillRect(
263
+ (c + QUIET_ZONE) * PNG_MODULE_PX,
264
+ (r + QUIET_ZONE) * PNG_MODULE_PX,
265
+ PNG_MODULE_PX,
266
+ PNG_MODULE_PX
267
+ );
268
+ });
269
+ });
270
+ canvas.toBlob((blob) => {
271
+ if (!blob) return;
272
+ const objectUrl = URL.createObjectURL(blob);
273
+ const a = document.createElement("a");
274
+ a.href = objectUrl;
275
+ a.download = PNG_FILE_NAME;
276
+ a.click();
277
+ setTimeout(() => URL.revokeObjectURL(objectUrl), 1e4);
278
+ }, "image/png");
279
+ }
280
+ function QrPreview({
281
+ bankLabel,
282
+ accountNumber,
283
+ accountHolder,
284
+ url,
285
+ matrix
286
+ }) {
287
+ const { lastLabel, copy } = useCopy(url);
288
+ const pathData = react.useMemo(() => buildPathData(matrix), [matrix]);
289
+ const total = matrix.length + QUIET_ZONE * 2;
290
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { "aria-label": "\uB9CC\uB4E0 QR", className: "space-y-4", children: [
291
+ /* @__PURE__ */ jsxRuntime.jsx(
292
+ AccountCard,
293
+ {
294
+ bankName: bankLabel,
295
+ accountNumber,
296
+ accountHolder
297
+ }
298
+ ),
299
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-2xl border border-border", children: /* @__PURE__ */ jsxRuntime.jsxs(
300
+ "svg",
301
+ {
302
+ role: "img",
303
+ "aria-label": "\uC1A1\uAE08 \uC548\uB0B4 QR \uCF54\uB4DC",
304
+ viewBox: `0 0 ${total} ${total}`,
305
+ shapeRendering: "crispEdges",
306
+ className: "block h-auto w-full",
307
+ children: [
308
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { width: total, height: total, fill: "white" }),
309
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: pathData, fill: "black" })
310
+ ]
311
+ }
312
+ ) }),
313
+ /* @__PURE__ */ jsxRuntime.jsx(NoticeText, { children: "QR\uC744 \uACF5\uC720\uD558\uAE30 \uC804\uC5D0 \uC740\uD589\xB7\uACC4\uC88C\uBC88\uD638\xB7\uC608\uAE08\uC8FC\uB97C \uAF2D \uD655\uC778\uD574 \uC8FC\uC138\uC694." }),
314
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
315
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "outline", type: "button", onClick: () => downloadPng(matrix), children: "PNG\uB85C \uC800\uC7A5" }),
316
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "outline", type: "button", onClick: () => void copy("link"), children: "\uB9C1\uD06C \uBCF5\uC0AC" })
317
+ ] }),
318
+ /* @__PURE__ */ jsxRuntime.jsx("p", { role: "status", className: "min-h-4 text-[13px] text-muted-foreground", children: lastLabel === "link" ? "\uB9C1\uD06C\uB97C \uBCF5\uC0AC\uD588\uC5B4\uC694." : "" })
319
+ ] });
320
+ }
321
+ function Input({ className, type, ...props }) {
322
+ return /* @__PURE__ */ jsxRuntime.jsx(
323
+ input.Input,
324
+ {
325
+ type,
326
+ "data-slot": "input",
327
+ className: cn(
328
+ "h-12 w-full min-w-0 rounded-2xl border border-input bg-card px-3 text-base font-normal text-foreground transition-colors outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-50 aria-[invalid=true]:border-2 aria-[invalid=true]:border-foreground",
329
+ className
330
+ ),
331
+ ...props
332
+ }
333
+ );
334
+ }
335
+ var Select = select.Select.Root;
336
+ function SelectValue({ className, ...props }) {
337
+ return /* @__PURE__ */ jsxRuntime.jsx(
338
+ select.Select.Value,
339
+ {
340
+ "data-slot": "select-value",
341
+ className: cn("flex-1 truncate text-left", className),
342
+ ...props
343
+ }
344
+ );
345
+ }
346
+ function SelectTrigger({
347
+ className,
348
+ children,
349
+ ...props
350
+ }) {
351
+ return /* @__PURE__ */ jsxRuntime.jsxs(
352
+ select.Select.Trigger,
353
+ {
354
+ "data-slot": "select-trigger",
355
+ className: cn(
356
+ "flex h-12 w-full items-center justify-between gap-2 rounded-2xl border border-input bg-card px-3 text-base font-normal whitespace-nowrap text-foreground transition-colors outline-none select-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-2 aria-[invalid=true]:border-foreground data-[placeholder]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0",
357
+ className
358
+ ),
359
+ ...props,
360
+ children: [
361
+ children,
362
+ /* @__PURE__ */ jsxRuntime.jsx(
363
+ select.Select.Icon,
364
+ {
365
+ render: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDownIcon, { className: "pointer-events-none size-4 text-muted-foreground" })
366
+ }
367
+ )
368
+ ]
369
+ }
370
+ );
371
+ }
372
+ function SelectContent({
373
+ className,
374
+ children,
375
+ side = "bottom",
376
+ sideOffset = 4,
377
+ align = "center",
378
+ alignOffset = 0,
379
+ // 선택 항목을 트리거 위에 겹치는 배치는 모바일에서 팝업이 화면 밖으로 밀릴 수 있어 끈다
380
+ alignItemWithTrigger = false,
381
+ ...props
382
+ }) {
383
+ return /* @__PURE__ */ jsxRuntime.jsx(select.Select.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
384
+ select.Select.Positioner,
385
+ {
386
+ side,
387
+ sideOffset,
388
+ align,
389
+ alignOffset,
390
+ alignItemWithTrigger,
391
+ collisionPadding: 8,
392
+ className: "isolate z-50",
393
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
394
+ select.Select.Popup,
395
+ {
396
+ "data-slot": "select-content",
397
+ className: cn(
398
+ "relative isolate z-50 max-h-[min(var(--available-height),20rem)] w-[var(--anchor-width)] min-w-36 overflow-x-hidden overflow-y-auto rounded-2xl border border-border bg-popover text-popover-foreground",
399
+ className
400
+ ),
401
+ ...props,
402
+ children: [
403
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollUpButton, {}),
404
+ /* @__PURE__ */ jsxRuntime.jsx(select.Select.List, { children }),
405
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollDownButton, {})
406
+ ]
407
+ }
408
+ )
409
+ }
410
+ ) });
411
+ }
412
+ function SelectItem({
413
+ className,
414
+ children,
415
+ ...props
416
+ }) {
417
+ return /* @__PURE__ */ jsxRuntime.jsxs(
418
+ select.Select.Item,
419
+ {
420
+ "data-slot": "select-item",
421
+ className: cn(
422
+ "relative flex min-h-12 w-full cursor-default items-center gap-2 py-2 pr-10 pl-3 text-base font-normal outline-none select-none data-[highlighted]:bg-muted data-[selected]:font-semibold data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
423
+ className
424
+ ),
425
+ ...props,
426
+ children: [
427
+ /* @__PURE__ */ jsxRuntime.jsx(select.Select.ItemText, { className: "flex-1", children }),
428
+ /* @__PURE__ */ jsxRuntime.jsx(
429
+ select.Select.ItemIndicator,
430
+ {
431
+ render: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pointer-events-none absolute right-3 flex size-4 items-center justify-center" }),
432
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckIcon, { className: "size-4" })
433
+ }
434
+ )
435
+ ]
436
+ }
437
+ );
438
+ }
439
+ function SelectScrollUpButton({
440
+ className,
441
+ ...props
442
+ }) {
443
+ return /* @__PURE__ */ jsxRuntime.jsx(
444
+ select.Select.ScrollUpArrow,
445
+ {
446
+ "data-slot": "select-scroll-up-button",
447
+ className: cn(
448
+ "top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1",
449
+ className
450
+ ),
451
+ ...props,
452
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUpIcon, { className: "size-4" })
453
+ }
454
+ );
455
+ }
456
+ function SelectScrollDownButton({
457
+ className,
458
+ ...props
459
+ }) {
460
+ return /* @__PURE__ */ jsxRuntime.jsx(
461
+ select.Select.ScrollDownArrow,
462
+ {
463
+ "data-slot": "select-scroll-down-button",
464
+ className: cn(
465
+ "bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1",
466
+ className
467
+ ),
468
+ ...props,
469
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDownIcon, { className: "size-4" })
470
+ }
471
+ );
472
+ }
473
+ function findInvalidField(bank, account, holder) {
474
+ const origin = "https://example.invalid";
475
+ if (holder.trim() && chunk2YL4VYHX_js.buildTransferUrl(origin, { bankName: bank, accountNumber: account })) {
476
+ return "holder";
477
+ }
478
+ if (chunk2YL4VYHX_js.buildTransferUrl(origin, { bankName: bank, accountNumber: "123456789" })) return "account";
479
+ return "bank";
480
+ }
481
+ var FIELD_ERROR_MESSAGE = {
482
+ bank: "\uC740\uD589\uC744 \uB2E4\uC2DC \uC120\uD0DD\uD574 \uC8FC\uC138\uC694.",
483
+ account: "\uACC4\uC88C\uBC88\uD638\uB97C \uB2E4\uC2DC \uD655\uC778\uD574 \uC8FC\uC138\uC694.",
484
+ holder: "\uC608\uAE08\uC8FC\uB97C \uB2E4\uC2DC \uD655\uC778\uD574 \uC8FC\uC138\uC694."
485
+ };
486
+ function CreateForm() {
487
+ const [bank, setBank] = react.useState(null);
488
+ const [account, setAccount] = react.useState("");
489
+ const [holder, setHolder] = react.useState("");
490
+ const [result, setResult] = react.useState(null);
491
+ const [errorField, setErrorField] = react.useState(null);
492
+ const clearResult = () => {
493
+ setResult(null);
494
+ setErrorField(null);
495
+ };
496
+ const handleSubmit = (event) => {
497
+ var _a;
498
+ event.preventDefault();
499
+ if (!bank) {
500
+ setResult(null);
501
+ setErrorField("bank");
502
+ return;
503
+ }
504
+ const url = chunk2YL4VYHX_js.buildTransferUrl(window.location.origin, {
505
+ bankName: bank,
506
+ accountNumber: account,
507
+ accountHolder: holder
508
+ });
509
+ if (!url) {
510
+ setResult(null);
511
+ setErrorField(findInvalidField(bank, account, holder));
512
+ return;
513
+ }
514
+ setErrorField(null);
515
+ setResult({
516
+ url,
517
+ matrix: chunk2YL4VYHX_js.createQrMatrix(url),
518
+ bankLabel: ((_a = chunk2YL4VYHX_js.BANK_OPTIONS.find((option) => option.value === bank)) == null ? void 0 : _a.label) ?? bank,
519
+ accountNumber: account.replace(/[^0-9]/g, ""),
520
+ accountHolder: holder.trim()
521
+ });
522
+ };
523
+ const errorFor = (field) => errorField === field ? /* @__PURE__ */ jsxRuntime.jsx("p", { id: `${field}-error`, role: "alert", className: "text-[13px] font-semibold text-foreground", children: FIELD_ERROR_MESSAGE[field] }) : null;
524
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 space-y-6 px-4 pb-8 pt-6", children: [
525
+ /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, noValidate: true, className: "space-y-4", children: [
526
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
527
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "bank", className: "block text-[13px] text-muted-foreground", children: "\uBC1B\uB294 \uC740\uD589" }),
528
+ /* @__PURE__ */ jsxRuntime.jsxs(
529
+ Select,
530
+ {
531
+ items: chunk2YL4VYHX_js.BANK_OPTIONS,
532
+ value: bank,
533
+ onValueChange: (value) => {
534
+ setBank(value);
535
+ clearResult();
536
+ },
537
+ children: [
538
+ /* @__PURE__ */ jsxRuntime.jsx(
539
+ SelectTrigger,
540
+ {
541
+ id: "bank",
542
+ "aria-invalid": errorField === "bank",
543
+ "aria-describedby": errorField === "bank" ? "bank-error" : void 0,
544
+ children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\uC740\uD589\uC744 \uC120\uD0DD\uD574 \uC8FC\uC138\uC694" })
545
+ }
546
+ ),
547
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: chunk2YL4VYHX_js.BANK_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
548
+ ]
549
+ }
550
+ ),
551
+ errorFor("bank")
552
+ ] }),
553
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
554
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "account", className: "block text-[13px] text-muted-foreground", children: "\uACC4\uC88C\uBC88\uD638" }),
555
+ /* @__PURE__ */ jsxRuntime.jsx(
556
+ Input,
557
+ {
558
+ id: "account",
559
+ inputMode: "numeric",
560
+ autoComplete: "off",
561
+ placeholder: "\uD558\uC774\uD508(-) \uC5C6\uC774 \uC785\uB825\uD574\uB3C4 \uB3FC\uC694",
562
+ value: account,
563
+ onChange: (event) => {
564
+ setAccount(event.target.value);
565
+ clearResult();
566
+ },
567
+ "aria-invalid": errorField === "account",
568
+ "aria-describedby": errorField === "account" ? "account-error" : void 0
569
+ }
570
+ ),
571
+ errorFor("account")
572
+ ] }),
573
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
574
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "holder", className: "block text-[13px] text-muted-foreground", children: "\uC608\uAE08\uC8FC (\uC120\uD0DD)" }),
575
+ /* @__PURE__ */ jsxRuntime.jsx(
576
+ Input,
577
+ {
578
+ id: "holder",
579
+ autoComplete: "off",
580
+ value: holder,
581
+ onChange: (event) => {
582
+ setHolder(event.target.value);
583
+ clearResult();
584
+ },
585
+ "aria-invalid": errorField === "holder",
586
+ "aria-describedby": errorField === "holder" ? "holder-error" : void 0
587
+ }
588
+ ),
589
+ errorFor("holder")
590
+ ] }),
591
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", size: "lg", className: "w-full", children: "QR \uB9CC\uB4E4\uAE30" })
592
+ ] }),
593
+ result && (result.matrix ? /* @__PURE__ */ jsxRuntime.jsx(
594
+ QrPreview,
595
+ {
596
+ bankLabel: result.bankLabel,
597
+ accountNumber: result.accountNumber,
598
+ accountHolder: result.accountHolder,
599
+ url: result.url,
600
+ matrix: result.matrix
601
+ }
602
+ ) : /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: "text-[13px] font-semibold text-foreground", children: "\uC785\uB825 \uB0B4\uC6A9\uC774 \uB108\uBB34 \uAE38\uC5B4\uC694. \uC608\uAE08\uC8FC\uB97C \uC904\uC5EC \uB2E4\uC2DC \uB9CC\uB4E4\uC5B4 \uC8FC\uC138\uC694." })),
603
+ /* @__PURE__ */ jsxRuntime.jsx(NoticeText, { children: "QR\uC744 \uC2A4\uCE94\uD55C \uC0AC\uB78C\uC774 \uAE08\uC735\uC571\uC5D0\uC11C \uAE08\uC561\uC744 \uC9C1\uC811 \uC785\uB825\uD574\uC694. \uB9C1\uD06C\uB97C \uBC1B\uC740 \uC0AC\uB78C\uC740 \uB204\uAD6C\uB098 \uC774 \uACC4\uC88C \uC815\uBCF4\uB97C \uBCFC \uC218 \uC788\uC5B4\uC694." })
604
+ ] });
605
+ }
606
+
607
+ exports.CreateForm = CreateForm;
608
+ exports.TransferView = TransferView;