@scaleflex/crop 2.0.1

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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +452 -0
  3. package/dist/a11y/aria.d.ts +5 -0
  4. package/dist/a11y/keyboard.d.ts +13 -0
  5. package/dist/animation/lerp.d.ts +15 -0
  6. package/dist/animation/spring.d.ts +15 -0
  7. package/dist/canvas/bleed-layer.d.ts +6 -0
  8. package/dist/canvas/crop-frame.d.ts +32 -0
  9. package/dist/canvas/grid-layer.d.ts +7 -0
  10. package/dist/canvas/hit-test.d.ts +10 -0
  11. package/dist/canvas/image-layer.d.ts +28 -0
  12. package/dist/canvas/overlay-layer.d.ts +6 -0
  13. package/dist/canvas/renderer.d.ts +34 -0
  14. package/dist/chunks/sfx-crop-1LGASewd.cjs +353 -0
  15. package/dist/chunks/sfx-crop-CEe6OfTZ.js +2030 -0
  16. package/dist/core/config.d.ts +10 -0
  17. package/dist/core/crop-controller.d.ts +65 -0
  18. package/dist/core/types.d.ts +270 -0
  19. package/dist/define.cjs +1194 -0
  20. package/dist/define.d.ts +1 -0
  21. package/dist/define.js +1746 -0
  22. package/dist/elements/base.d.ts +17 -0
  23. package/dist/elements/icons.d.ts +21 -0
  24. package/dist/elements/parse-shapes.d.ts +13 -0
  25. package/dist/elements/popover-anchor.d.ts +20 -0
  26. package/dist/elements/sfx-crop-canvas.d.ts +24 -0
  27. package/dist/elements/sfx-crop-canvas.styles.d.ts +1 -0
  28. package/dist/elements/sfx-crop-rotate.d.ts +42 -0
  29. package/dist/elements/sfx-crop-rotate.styles.d.ts +5 -0
  30. package/dist/elements/sfx-crop-shapes.d.ts +67 -0
  31. package/dist/elements/sfx-crop-shapes.styles.d.ts +6 -0
  32. package/dist/elements/sfx-crop-toolbar.d.ts +64 -0
  33. package/dist/elements/sfx-crop-toolbar.styles.d.ts +7 -0
  34. package/dist/elements/sfx-crop-zoom.d.ts +66 -0
  35. package/dist/elements/sfx-crop-zoom.styles.d.ts +7 -0
  36. package/dist/elements/sfx-crop.d.ts +134 -0
  37. package/dist/elements/sfx-crop.styles.d.ts +9 -0
  38. package/dist/export/exporter.d.ts +19 -0
  39. package/dist/index.cjs +2 -0
  40. package/dist/index.d.ts +22 -0
  41. package/dist/index.js +65 -0
  42. package/dist/interactions/drag-crop.d.ts +10 -0
  43. package/dist/interactions/pinch-zoom.d.ts +14 -0
  44. package/dist/interactions/pointer-tracker.d.ts +29 -0
  45. package/dist/interactions/resize-handles.d.ts +13 -0
  46. package/dist/interactions/wheel-zoom.d.ts +12 -0
  47. package/dist/react/define-CVJd5aYk.cjs +1545 -0
  48. package/dist/react/define-t4Z6KaLY.js +2590 -0
  49. package/dist/react/index-B-csHwK2.cjs +2 -0
  50. package/dist/react/index-CktjrogS.js +1468 -0
  51. package/dist/react/index.cjs +2 -0
  52. package/dist/react/index.d.ts +21 -0
  53. package/dist/react/index.js +10 -0
  54. package/dist/react/sfx-crop.d.ts +86 -0
  55. package/dist/react/use-sfx-crop-controller.d.ts +74 -0
  56. package/dist/react/use-sfx-crop.d.ts +31 -0
  57. package/dist/styles/shared.css.d.ts +20 -0
  58. package/dist/transforms/constrain.d.ts +68 -0
  59. package/dist/transforms/matrix.d.ts +23 -0
  60. package/dist/transforms/transform-state.d.ts +12 -0
  61. package/dist/utils/events.d.ts +16 -0
  62. package/dist/utils/math.d.ts +12 -0
  63. package/package.json +108 -0
package/dist/define.js ADDED
@@ -0,0 +1,1746 @@
1
+ import { a as R, b as y, e as I, g as V, p as Q, t as tt, f as et, h as ot, s as C, i as rt, S as it } from "./chunks/sfx-crop-CEe6OfTZ.js";
2
+ import { css as T, html as d } from "lit";
3
+ import { property as a, state as E, query as U } from "lit/decorators.js";
4
+ import { unsafeHTML as v } from "lit/directives/unsafe-html.js";
5
+ const st = '<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 9V7a2 2 0 0 0-2-2h-6"/><path d="m15 8-3-3 3-3"/><path d="M4 14a2 2 0 0 0-2 2v3a2 2 0 0 0 2 2h13a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2Z"/></svg>', nt = '<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3"/><path d="M16 3h3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-3"/><path d="M12 20v2"/><path d="M12 15v2"/><path d="M12 10v2"/><path d="M12 5v2"/></svg>', K = '<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 2v14a2 2 0 0 0 2 2h14"/><path d="M18 22V8a2 2 0 0 0-2-2H2"/></svg>', at = '<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>', ct = '<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>', q = '<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/></svg>', G = '<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="5"/></svg>', lt = '<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="12" height="20" x="6" y="2" rx="2"/><rect width="20" height="12" x="2" y="6" rx="2"/></svg>', pt = '<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>', ht = '<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 22h20"/><rect x="3" y="6" width="18" height="14" rx="2" transform="rotate(-10 12 13)"/></svg>', dt = '<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', xt = '<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', ft = '<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', ut = '<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/></svg>', l = {
6
+ rotateLeft: "",
7
+ // populated below via a second block to avoid TDZ on const order
8
+ flipHorizontal: "",
9
+ tilt: "",
10
+ loupe: "",
11
+ zoomIn: "",
12
+ zoomOut: "",
13
+ cropAspect: "",
14
+ cropCustom: "",
15
+ cropCircle: "",
16
+ cropRoundedRect: "",
17
+ orientLandscape: "",
18
+ orientPortrait: "",
19
+ chevronDown: "",
20
+ reset: ""
21
+ };
22
+ l.rotateLeft = st;
23
+ l.flipHorizontal = nt;
24
+ l.tilt = ht;
25
+ l.loupe = ft;
26
+ l.zoomIn = dt;
27
+ l.zoomOut = xt;
28
+ l.cropAspect = lt;
29
+ l.cropCustom = K;
30
+ l.cropCircle = q;
31
+ l.cropRoundedRect = G;
32
+ l.orientLandscape = at;
33
+ l.orientPortrait = ct;
34
+ l.chevronDown = pt;
35
+ l.reset = ut;
36
+ function f(n, t) {
37
+ const e = t == null ? void 0 : t[n];
38
+ return typeof e == "string" && e.length > 0 ? e : l[n];
39
+ }
40
+ const gt = T`
41
+ :host {
42
+ /* Inline-flex so the host doesn't take toolbar space — the actual ruler
43
+ below uses position:fixed and anchors to the canvas bottom-center via
44
+ createPopoverAnchor, exactly where the legacy popover lived. */
45
+ position: relative;
46
+ display: inline-flex;
47
+ align-items: center;
48
+ }
49
+
50
+ .sfx-cr-rotate-root {
51
+ position: relative;
52
+ display: flex;
53
+ align-items: center;
54
+ justify-content: center;
55
+ }
56
+
57
+ .sfx-cr-rotate-popover {
58
+ position: fixed;
59
+ top: var(--sfx-cr-popover-top, 50%);
60
+ left: var(--sfx-cr-popover-left, 50%);
61
+ transform: translateX(-50%);
62
+ display: flex;
63
+ flex-direction: column;
64
+ align-items: center;
65
+ gap: 4px;
66
+ padding: 0;
67
+ background: transparent;
68
+ border: none;
69
+ box-shadow: none;
70
+ pointer-events: auto;
71
+ white-space: nowrap;
72
+ z-index: 10;
73
+ }
74
+
75
+ /* Ruler viewport — fixed width, overflow clipped. Ticks scroll inside. */
76
+ .sfx-cr-rotate-ruler {
77
+ position: relative;
78
+ width: var(--ruler-w, 260px);
79
+ height: 30px;
80
+ overflow: hidden;
81
+ cursor: grab;
82
+ touch-action: none;
83
+ user-select: none;
84
+ -webkit-user-select: none;
85
+ }
86
+ .sfx-cr-rotate-ruler.is-dragging { cursor: grabbing; }
87
+ .sfx-cr-rotate-ruler:focus-visible {
88
+ outline: 2px solid var(--sfx-cr-ring);
89
+ outline-offset: 2px;
90
+ border-radius: 4px;
91
+ }
92
+
93
+ /* Tick strip — absolutely positioned ticks, the whole strip is
94
+ translated along X in sync with the current value. */
95
+ .sfx-cr-rotate-ticks {
96
+ position: absolute;
97
+ top: 50%;
98
+ left: 0;
99
+ height: 100%;
100
+ will-change: transform;
101
+ /* Dark halo wrapping every tick so the white ink stays legible over a
102
+ bright photo. Applied to the strip so all ticks share one shadow pass. */
103
+ filter:
104
+ drop-shadow(0 0 1px var(--sfx-cr-ruler-halo, oklch(0 0 0 / 0.85)))
105
+ drop-shadow(0 0 2px var(--sfx-cr-ruler-halo, oklch(0 0 0 / 0.85)));
106
+ }
107
+
108
+ .sfx-cr-rotate-tick {
109
+ position: absolute;
110
+ top: 50%;
111
+ width: 1px;
112
+ height: 8px;
113
+ margin-left: -0.5px;
114
+ margin-top: -4px;
115
+ border-radius: 0.5px;
116
+ background: var(--sfx-cr-ruler-ink, var(--sfx-cr-text));
117
+ opacity: 0.9;
118
+ }
119
+ .sfx-cr-rotate-tick--major {
120
+ width: 1px;
121
+ height: 12px;
122
+ margin-left: -0.5px;
123
+ margin-top: -6px;
124
+ opacity: 1;
125
+ }
126
+
127
+ /* Fixed center indicator — single vertical line, slightly taller than ticks. */
128
+ .sfx-cr-rotate-indicator {
129
+ position: absolute;
130
+ top: calc(50% + 4px);
131
+ height: 16px;
132
+ left: 50%;
133
+ width: 4px;
134
+ margin-left: -2px;
135
+ background: var(--sfx-cr-ruler-ink, var(--sfx-cr-text));
136
+ border-radius: 2px;
137
+ pointer-events: none;
138
+ /* Same dark halo as the ticks so the centre marker stays visible. */
139
+ filter:
140
+ drop-shadow(0 0 1px var(--sfx-cr-ruler-halo, oklch(0 0 0 / 0.85)))
141
+ drop-shadow(0 0 2px var(--sfx-cr-ruler-halo, oklch(0 0 0 / 0.85)));
142
+ }
143
+
144
+ .sfx-cr-rotate-value {
145
+ font-size: 14px;
146
+ font-weight: 400;
147
+ color: var(--sfx-cr-ruler-ink, var(--sfx-cr-text));
148
+ text-align: center;
149
+ font-variant-numeric: tabular-nums;
150
+ letter-spacing: 0.2px;
151
+ /* Dark halo so the degree readout reads over both bright and dark photos. */
152
+ text-shadow:
153
+ 0 0 2px var(--sfx-cr-ruler-halo, oklch(0 0 0 / 0.85)),
154
+ 0 1px 2px var(--sfx-cr-ruler-halo, oklch(0 0 0 / 0.85));
155
+ }
156
+
157
+ @media (max-width: 768px) {
158
+ .sfx-cr-rotate-ruler { width: 220px; height: 22px; }
159
+ .sfx-cr-rotate-tick { height: 6px; margin-top: -3px; }
160
+ .sfx-cr-rotate-tick--major { height: 9px; margin-top: -4.5px; }
161
+ .sfx-cr-rotate-indicator {
162
+ top: calc(50% + 3px);
163
+ height: 12px;
164
+ width: 3px;
165
+ margin-left: -1.5px;
166
+ }
167
+ .sfx-cr-rotate-value { font-size: 12px; }
168
+ .sfx-cr-rotate-popover {
169
+ transform: translateX(-50%) translateY(24px);
170
+ }
171
+ }
172
+ @media (max-width: 480px) {
173
+ .sfx-cr-rotate-ruler { width: 180px; height: 20px; }
174
+ .sfx-cr-rotate-tick { height: 5px; margin-top: -2.5px; }
175
+ .sfx-cr-rotate-tick--major { height: 8px; margin-top: -4px; }
176
+ .sfx-cr-rotate-indicator {
177
+ top: calc(50% + 2px);
178
+ height: 10px;
179
+ }
180
+ .sfx-cr-rotate-value { font-size: 11px; }
181
+ .sfx-cr-rotate-popover {
182
+ transform: translateX(-50%) translateY(30px);
183
+ }
184
+ }
185
+
186
+ /* Narrow editor — make the ruler more compact when the toolbar
187
+ collapses into the vertical left rail. */
188
+ @container sfxcrop (max-width: 760px) {
189
+ .sfx-cr-rotate-ruler { width: 140px; height: 18px; }
190
+ .sfx-cr-rotate-tick { height: 5px; margin-top: -2.5px; }
191
+ .sfx-cr-rotate-tick--major { height: 8px; margin-top: -4px; }
192
+ .sfx-cr-rotate-indicator {
193
+ top: calc(50% + 2px);
194
+ height: 10px;
195
+ width: 3px;
196
+ margin-left: -1.5px;
197
+ }
198
+ .sfx-cr-rotate-value { font-size: 11px; }
199
+ }
200
+ `, vt = 72;
201
+ function W(n, t) {
202
+ let e = null, r = !1;
203
+ const o = () => {
204
+ var w;
205
+ let h = n;
206
+ for (let $ = 0; $ < 6; $++) {
207
+ const P = h.getRootNode();
208
+ if (!(P instanceof ShadowRoot)) break;
209
+ if (h = P.host, ((w = h.tagName) == null ? void 0 : w.toLowerCase()) === "sfx-crop") return h;
210
+ }
211
+ return null;
212
+ }, i = () => {
213
+ var P;
214
+ const h = (P = n.shadowRoot) == null ? void 0 : P.querySelector(t), w = o();
215
+ if (!h || !w) return;
216
+ const $ = w.getBoundingClientRect();
217
+ h.style.setProperty("--sfx-cr-popover-left", `${$.left + $.width / 2}px`), h.style.setProperty("--sfx-cr-popover-top", `${$.bottom - vt}px`);
218
+ }, s = () => i();
219
+ return { start: () => {
220
+ if (r) return;
221
+ r = !0, i(), window.addEventListener("resize", s), window.addEventListener("scroll", s, !0);
222
+ const h = o();
223
+ h && typeof ResizeObserver < "u" && (e = new ResizeObserver(() => i()), e.observe(h));
224
+ }, stop: () => {
225
+ r && (r = !1, window.removeEventListener("resize", s), window.removeEventListener("scroll", s, !0), e == null || e.disconnect(), e = null);
226
+ }, update: i };
227
+ }
228
+ var bt = Object.defineProperty, S = (n, t, e, r) => {
229
+ for (var o = void 0, i = n.length - 1, s; i >= 0; i--)
230
+ (s = n[i]) && (o = s(t, e, o) || o);
231
+ return o && bt(t, e, o), o;
232
+ };
233
+ const O = 6, A = 260, _ = 1, mt = 5, N = class N extends R {
234
+ constructor() {
235
+ super(...arguments), this.value = 0, this.min = -45, this.max = 45, this.icons = {}, this.dragging = !1, this.activePointer = null, this.pointerStartX = 0, this.pointerStartValue = 0, this.popoverAnchor = W(this, ".sfx-cr-rotate-popover"), this.onKeyDown = (t) => {
236
+ t.key === "ArrowLeft" ? (t.preventDefault(), this.emit(y(this.value - (t.shiftKey ? 5 : 1), this.min, this.max))) : t.key === "ArrowRight" && (t.preventDefault(), this.emit(y(this.value + (t.shiftKey ? 5 : 1), this.min, this.max)));
237
+ }, this.onPointerDown = (t) => {
238
+ if (this.activePointer === null) {
239
+ this.activePointer = t.pointerId, this.pointerStartX = t.clientX, this.pointerStartValue = this.value, this.dragging = !0;
240
+ try {
241
+ t.currentTarget.setPointerCapture(t.pointerId);
242
+ } catch {
243
+ }
244
+ }
245
+ }, this.onPointerMove = (t) => {
246
+ if (this.activePointer !== t.pointerId) return;
247
+ const e = t.clientX - this.pointerStartX, r = this.pointerStartValue - e / O;
248
+ this.emit(y(r, this.min, this.max));
249
+ }, this.onPointerUp = (t) => {
250
+ if (this.activePointer === t.pointerId) {
251
+ this.activePointer = null, this.dragging = !1;
252
+ try {
253
+ t.currentTarget.releasePointerCapture(t.pointerId);
254
+ } catch {
255
+ }
256
+ Math.abs(this.value) < 2 && this.emit(0);
257
+ }
258
+ }, this.onReset = () => {
259
+ this.emit(0);
260
+ };
261
+ }
262
+ connectedCallback() {
263
+ super.connectedCallback(), this.popoverAnchor.start();
264
+ }
265
+ disconnectedCallback() {
266
+ super.disconnectedCallback(), this.popoverAnchor.stop();
267
+ }
268
+ updated(t) {
269
+ (t.has("value") || t.has("dragging")) && this.popoverAnchor.update();
270
+ }
271
+ render() {
272
+ const t = `${this.value > 0 ? "+" : ""}${this.value.toFixed(1)}°`, e = A / 2 - (this.value - this.min) * O, r = A / O, o = 4, i = Math.max(this.min, Math.floor(this.value - r / 2 - o)), s = Math.min(this.max, Math.ceil(this.value + r / 2 + o)), u = [];
273
+ for (let p = Math.ceil(i / _) * _; p <= s; p += _)
274
+ u.push({ deg: p, major: p % mt === 0 });
275
+ return d`
276
+ <div class="sfx-cr-rotate-root" @keydown=${this.onKeyDown}>
277
+ <div class="sfx-cr-rotate-popover" role="group" aria-label="Fine rotation">
278
+ <div
279
+ class=${`sfx-cr-rotate-ruler${this.dragging ? " is-dragging" : ""}`}
280
+ role="slider"
281
+ aria-valuemin=${String(this.min)}
282
+ aria-valuemax=${String(this.max)}
283
+ aria-valuenow=${String(this.value)}
284
+ aria-valuetext=${t}
285
+ tabindex="0"
286
+ style=${`--ruler-w: ${A}px`}
287
+ @pointerdown=${this.onPointerDown}
288
+ @pointermove=${this.onPointerMove}
289
+ @pointerup=${this.onPointerUp}
290
+ @pointercancel=${this.onPointerUp}
291
+ @dblclick=${this.onReset}
292
+ >
293
+ <div class="sfx-cr-rotate-ticks" style=${`transform: translateX(${e.toFixed(1)}px)`}>
294
+ ${u.map((p) => d`
295
+ <span
296
+ class=${`sfx-cr-rotate-tick${p.major ? " sfx-cr-rotate-tick--major" : ""}`}
297
+ style=${`left: ${((p.deg - this.min) * O).toFixed(1)}px`}
298
+ ></span>
299
+ `)}
300
+ </div>
301
+ <div class="sfx-cr-rotate-indicator" aria-hidden="true"></div>
302
+ </div>
303
+ <span class="sfx-cr-rotate-value">${t}</span>
304
+ </div>
305
+ </div>
306
+ `;
307
+ }
308
+ /** Sync value without emitting — used by host to reflect controller state. */
309
+ setValue(t) {
310
+ this.value = y(t, this.min, this.max);
311
+ }
312
+ emit(t) {
313
+ this.value !== t && (this.value = t, this.dispatchEvent(new CustomEvent("sfx-crop-rotate-change", {
314
+ detail: { degrees: t },
315
+ bubbles: !0,
316
+ composed: !0
317
+ })));
318
+ }
319
+ };
320
+ N.styles = [I, gt];
321
+ let m = N;
322
+ S([
323
+ a({ type: Number })
324
+ ], m.prototype, "value");
325
+ S([
326
+ a({ type: Number })
327
+ ], m.prototype, "min");
328
+ S([
329
+ a({ type: Number })
330
+ ], m.prototype, "max");
331
+ S([
332
+ a({ attribute: !1 })
333
+ ], m.prototype, "icons");
334
+ S([
335
+ E()
336
+ ], m.prototype, "dragging");
337
+ const wt = T`
338
+ :host {
339
+ position: relative;
340
+ display: inline-block;
341
+ }
342
+
343
+ .sfx-cr-shape-trigger {
344
+ display: flex;
345
+ align-items: center;
346
+ gap: 6px;
347
+ padding: 8px 14px;
348
+ min-width: 84px;
349
+ height: 36px;
350
+ background: transparent;
351
+ color: var(--sfx-cr-text-secondary);
352
+ border: 1.5px solid var(--sfx-cr-border);
353
+ border-radius: 50px;
354
+ cursor: pointer;
355
+ font-family: var(--sfx-cr-font);
356
+ font-size: 14px;
357
+ font-weight: 500;
358
+ transition:
359
+ background var(--sfx-cr-transition),
360
+ border-color var(--sfx-cr-transition),
361
+ color var(--sfx-cr-transition),
362
+ transform var(--sfx-cr-transition),
363
+ box-shadow var(--sfx-cr-transition);
364
+ white-space: nowrap;
365
+ letter-spacing: 0.1px;
366
+ }
367
+
368
+ /* Fixed variant: translucent pill so the trigger reads over the photo
369
+ (no dimmed crop mask behind it). Plain background — no filter/transform. */
370
+ :host([variant="fixed"]) .sfx-cr-shape-trigger {
371
+ background: var(--sfx-cr-overlay-color);
372
+ }
373
+
374
+ .sfx-cr-shape-trigger:hover {
375
+ border-color: var(--sfx-cr-primary);
376
+ transform: translateY(-1px);
377
+ }
378
+
379
+ .sfx-cr-shape-trigger:focus-visible {
380
+ outline: 2px solid var(--sfx-cr-ring);
381
+ outline-offset: 2px;
382
+ }
383
+
384
+ .sfx-cr-shape-trigger-icon {
385
+ display: flex;
386
+ width: 20px;
387
+ height: 20px;
388
+ }
389
+ .sfx-cr-shape-trigger-icon svg { width: 100%; height: 100%; display: block; }
390
+
391
+ .sfx-cr-shape-trigger-label { line-height: 1; }
392
+
393
+ .sfx-cr-shape-chevron {
394
+ display: flex;
395
+ width: 14px;
396
+ height: 14px;
397
+ margin-left: auto;
398
+ transition: transform var(--sfx-cr-transition);
399
+ }
400
+ .sfx-cr-shape-chevron svg { width: 100%; height: 100%; display: block; }
401
+
402
+ :host([open]) .sfx-cr-shape-chevron {
403
+ transform: rotate(180deg);
404
+ }
405
+
406
+ .sfx-cr-shape-dropdown {
407
+ position: absolute;
408
+ top: calc(100% + 8px);
409
+ right: 0;
410
+ /* Size to the widest option + orientation toggle. Clamp to avoid
411
+ spilling off the viewport on very narrow screens. */
412
+ width: max-content;
413
+ min-width: 88px;
414
+ max-width: min(92vw, 200px);
415
+ max-height: min(55vh, 360px);
416
+ padding: 4px;
417
+ /* Barely-there grey tint with translucency so the panel picks up
418
+ whatever sits behind it (image, dark overlay, etc.) without reading
419
+ as a solid white box. backdrop-filter blur keeps text crisp on
420
+ busy backgrounds. */
421
+ background: var(--sfx-cr-dropdown-bg);
422
+ border: 1px solid var(--sfx-cr-border);
423
+ border-radius: var(--sfx-cr-radius-lg, 8px);
424
+ box-shadow: var(--sfx-cr-dropdown-shadow);
425
+ backdrop-filter: blur(14px) saturate(160%);
426
+ -webkit-backdrop-filter: blur(14px) saturate(160%);
427
+ display: flex;
428
+ flex-direction: column;
429
+ z-index: 100;
430
+ opacity: 0;
431
+ transform: translateY(6px) scale(0.96);
432
+ pointer-events: none;
433
+ transition: opacity 120ms ease-in, transform 120ms ease-in;
434
+ }
435
+
436
+ /* Orientation toggle — naked icon-only buttons centered at the top.
437
+ No border, no background: only the rectangle SVG is visible. Active
438
+ state is signalled by the icon's color (text) vs. inactive (muted). */
439
+ .sfx-cr-shape-orient {
440
+ display: flex;
441
+ justify-content: center;
442
+ gap: 8px;
443
+ margin-bottom: 4px;
444
+ }
445
+
446
+ .sfx-cr-shape-orient-btn {
447
+ display: flex;
448
+ align-items: center;
449
+ justify-content: center;
450
+ width: 36px;
451
+ height: 32px;
452
+ padding: 0;
453
+ background: transparent;
454
+ color: var(--sfx-cr-text-muted);
455
+ border: none;
456
+ border-radius: 4px;
457
+ cursor: pointer;
458
+ transition: color var(--sfx-cr-transition);
459
+ }
460
+ .sfx-cr-shape-orient-btn:hover {
461
+ color: var(--sfx-cr-text-secondary);
462
+ }
463
+ .sfx-cr-shape-orient-btn.is-active {
464
+ color: var(--sfx-cr-text-secondary);
465
+ }
466
+ .sfx-cr-shape-orient-btn svg {
467
+ width: 24px;
468
+ height: 24px;
469
+ /* display:block kills SVG's default baseline drop (inline elements sit
470
+ on the text baseline, leaving a few sub-pixels of descender space at
471
+ the bottom — enough to push a tightly-fitted icon visibly off-center).
472
+ The -1px translate is optical correction: both Lucide monitor (stand
473
+ under the screen) and smartphone (home-indicator dot near the bottom)
474
+ carry visual weight below their geometric centre. */
475
+ display: block;
476
+ transform: translateY(-1px);
477
+ }
478
+
479
+ .sfx-cr-shape-list {
480
+ flex: 1 1 auto;
481
+ display: flex;
482
+ flex-direction: column;
483
+ gap: 1px;
484
+ overflow-y: auto;
485
+ scrollbar-width: thin;
486
+ }
487
+ .sfx-cr-shape-list::-webkit-scrollbar {
488
+ width: 4px;
489
+ }
490
+ .sfx-cr-shape-list::-webkit-scrollbar-thumb {
491
+ background: var(--sfx-cr-border);
492
+ border-radius: 2px;
493
+ }
494
+
495
+ :host([open]) .sfx-cr-shape-dropdown {
496
+ opacity: 1;
497
+ transform: translateY(0) scale(1);
498
+ pointer-events: auto;
499
+ transition: opacity 220ms cubic-bezier(0.34, 1.2, 0.64, 1),
500
+ transform 220ms cubic-bezier(0.34, 1.2, 0.64, 1);
501
+ }
502
+
503
+ .sfx-cr-shape-option {
504
+ display: flex;
505
+ align-items: center;
506
+ gap: 8px;
507
+ /* Stretch to the dropdown's resolved (content-sized) width so all
508
+ rows share the same left edge + hover highlight. */
509
+ width: 100%;
510
+ padding: 5px 10px;
511
+ height: 30px;
512
+ background: transparent;
513
+ color: var(--sfx-cr-text-secondary);
514
+ border: none;
515
+ border-radius: var(--sfx-cr-radius-sm, 4px);
516
+ cursor: pointer;
517
+ font-family: var(--sfx-cr-font);
518
+ font-size: 14px;
519
+ font-weight: 500;
520
+ text-align: left;
521
+ transition: background var(--sfx-cr-transition), color var(--sfx-cr-transition);
522
+ }
523
+
524
+ .sfx-cr-shape-option:hover {
525
+ background: var(--sfx-cr-dropdown-hover);
526
+ color: var(--sfx-cr-primary);
527
+ }
528
+
529
+ .sfx-cr-shape-option:focus-visible {
530
+ outline: 2px solid var(--sfx-cr-ring);
531
+ outline-offset: -2px;
532
+ }
533
+
534
+ .sfx-cr-shape-option--active {
535
+ background: var(--sfx-cr-primary-bg);
536
+ color: var(--sfx-cr-primary);
537
+ }
538
+
539
+ .sfx-cr-shape-option-icon {
540
+ display: flex;
541
+ align-items: center;
542
+ justify-content: center;
543
+ width: 18px;
544
+ height: 18px;
545
+ color: var(--sfx-cr-text-secondary);
546
+ flex-shrink: 0;
547
+ }
548
+ .sfx-cr-shape-option-icon svg { width: 100%; height: 100%; display: block; }
549
+ .sfx-cr-shape-option--active .sfx-cr-shape-option-icon { color: var(--sfx-cr-primary); }
550
+
551
+ @media (max-width: 768px) {
552
+ /* Drop label + chevron and shrink to a square icon-only pill so
553
+ the shape icon sits dead-center. The base 84px min-width was
554
+ sized for the desktop "[icon] Aspect 16:9 ▾" layout and leaves
555
+ empty pill space on the right once those pieces are hidden. */
556
+ .sfx-cr-shape-trigger-label { display: none; }
557
+ .sfx-cr-shape-chevron { display: none; }
558
+ .sfx-cr-shape-trigger {
559
+ min-width: 0;
560
+ width: 36px;
561
+ padding: 0;
562
+ gap: 0;
563
+ justify-content: center;
564
+ }
565
+ }
566
+
567
+ /* Narrow editor: drop the textual label + chevron so the trigger
568
+ reduces to an icon-only 30×30 capsule that matches the rest of
569
+ the compact left-rail toolbar. Anchor the dropdown to the left
570
+ edge since the trigger now lives in the left column. Container
571
+ query keyed off the sfxcrop named container so a narrow editor on
572
+ a wide desktop also collapses. */
573
+ @container sfxcrop (max-width: 760px) {
574
+ /* Label/chevron also need hiding when only the editor (not viewport)
575
+ is narrow — the 768px @media above only triggers on small viewports. */
576
+ .sfx-cr-shape-trigger-label { display: none; }
577
+ .sfx-cr-shape-chevron { display: none; }
578
+ .sfx-cr-shape-trigger {
579
+ min-width: 0;
580
+ width: 30px;
581
+ height: 30px;
582
+ padding: 0;
583
+ gap: 0;
584
+ justify-content: center;
585
+ }
586
+ /* Shrink the icon SLOT (not just the SVG) and center its contents,
587
+ so the 16×16 SVG sits dead-center inside the 30×30 trigger. The
588
+ base .sfx-cr-shape-trigger-icon is 20×20 with display:flex but
589
+ no justify/align — leaving a 16×16 SVG inside top-left aligned. */
590
+ .sfx-cr-shape-trigger-icon {
591
+ width: 16px;
592
+ height: 16px;
593
+ align-items: center;
594
+ justify-content: center;
595
+ }
596
+ .sfx-cr-shape-trigger svg {
597
+ width: 16px;
598
+ height: 16px;
599
+ }
600
+ /* Fixed variant: match the toolbar's uniform 40×40 round icon buttons. */
601
+ :host([variant="fixed"]) .sfx-cr-shape-trigger {
602
+ width: 40px;
603
+ height: 40px;
604
+ }
605
+ /* Classic left-rail only: the trigger sits in the vertical rail, so the
606
+ dropdown opens to the SIDE (right of the trigger). Excluded from the
607
+ fixed variant — there the toolbar is a horizontal top bar, so the menu
608
+ must keep the default downward opening (below the trigger) to avoid
609
+ running off the screen edge. */
610
+ :host(:not([variant="fixed"])) .sfx-cr-shape-dropdown {
611
+ right: auto;
612
+ left: calc(100% + 6px);
613
+ top: auto;
614
+ bottom: -30px;
615
+ transform: translateY(6px) scale(0.96);
616
+ }
617
+ :host(:not([variant="fixed"])[open]) .sfx-cr-shape-dropdown {
618
+ transform: translateY(0) scale(1);
619
+ }
620
+ }
621
+ `;
622
+ var yt = Object.defineProperty, k = (n, t, e, r) => {
623
+ for (var o = void 0, i = n.length - 1, s; i >= 0; i--)
624
+ (s = n[i]) && (o = s(t, e, o) || o);
625
+ return o && yt(t, e, o), o;
626
+ };
627
+ function Z(n) {
628
+ let o, i;
629
+ n >= 1 ? (o = 18, i = 18 / n) : (i = 18, o = 18 * n);
630
+ const s = Math.max(0, o - 1.5), u = Math.max(0, i - 1.5), p = (22 - s) / 2, h = (22 - u) / 2, w = Math.min(3.5, Math.min(s, u) / 4);
631
+ return `<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22" fill="none" stroke="currentColor" stroke-width="${1.5}"><rect x="${p.toFixed(2)}" y="${h.toFixed(2)}" width="${s.toFixed(2)}" height="${u.toFixed(2)}" rx="${w.toFixed(2)}"/></svg>`;
632
+ }
633
+ function kt() {
634
+ return {
635
+ free: { value: "free", label: "Custom", icon: K, show: "both" },
636
+ circle: { value: "circle", label: "Circle", icon: q, show: "both" },
637
+ "rounded-rect": { value: "rounded-rect", label: "Rounded", icon: G, show: "both" },
638
+ square: { value: "square", label: "1:1", icon: Z(1), show: "both" }
639
+ };
640
+ }
641
+ const J = kt();
642
+ function j(n) {
643
+ const t = J[n];
644
+ if (t) return t;
645
+ const e = Q(n);
646
+ return e === null ? null : {
647
+ value: n,
648
+ label: n,
649
+ icon: Z(e),
650
+ show: e > 1 ? "landscape" : e < 1 ? "portrait" : "both"
651
+ };
652
+ }
653
+ const B = class B extends R {
654
+ constructor() {
655
+ super(...arguments), this.value = "free", this.shapes = [
656
+ "free",
657
+ "square",
658
+ "16:9",
659
+ "4:3",
660
+ "3:2",
661
+ "5:4",
662
+ "2:1",
663
+ "9:16",
664
+ "3:4",
665
+ "2:3",
666
+ "4:5",
667
+ "1:2"
668
+ ], this.open = !1, this.variant = "classic", this.icons = {}, this.orientation = "landscape", this.focusedIndex = -1, this.focusRafId = null, this.docClickHandler = () => {
669
+ this.open && this.close();
670
+ }, this.onTriggerClick = (t) => {
671
+ if (t.stopPropagation(), this.open)
672
+ this.close();
673
+ else {
674
+ const e = this.getVisibleOptions();
675
+ this.focusedIndex = Math.max(0, e.findIndex((r) => r.value === this.value)), this.open = !0, this.dispatchEvent(new CustomEvent("sfx-crop-popover-open", {
676
+ detail: { source: "shapes" },
677
+ bubbles: !0,
678
+ composed: !0
679
+ }));
680
+ }
681
+ }, this.onKeyDown = (t) => {
682
+ if (!this.open) return;
683
+ const e = this.getVisibleOptions();
684
+ switch (t.key) {
685
+ case "Escape":
686
+ t.preventDefault(), t.stopPropagation(), this.close();
687
+ break;
688
+ case "ArrowDown":
689
+ t.preventDefault(), t.stopPropagation(), this.focusOption(Math.min(this.focusedIndex + 1, e.length - 1));
690
+ break;
691
+ case "ArrowUp":
692
+ t.preventDefault(), t.stopPropagation(), this.focusOption(Math.max(this.focusedIndex - 1, 0));
693
+ break;
694
+ case "ArrowLeft":
695
+ t.preventDefault(), t.stopPropagation(), this.setOrientation("landscape");
696
+ break;
697
+ case "ArrowRight":
698
+ t.preventDefault(), t.stopPropagation(), this.setOrientation("portrait");
699
+ break;
700
+ case "Enter":
701
+ case " ":
702
+ if (t.preventDefault(), t.stopPropagation(), this.focusedIndex >= 0 && this.focusedIndex < e.length) {
703
+ const r = e[this.focusedIndex].value;
704
+ this.value = r, this.close(), this.emit(r);
705
+ }
706
+ break;
707
+ }
708
+ };
709
+ }
710
+ connectedCallback() {
711
+ super.connectedCallback(), document.addEventListener("click", this.docClickHandler);
712
+ }
713
+ disconnectedCallback() {
714
+ super.disconnectedCallback(), document.removeEventListener("click", this.docClickHandler), this.focusRafId !== null && (cancelAnimationFrame(this.focusRafId), this.focusRafId = null);
715
+ }
716
+ updated(t) {
717
+ if (t.has("open") && this.open) {
718
+ const e = j(this.value);
719
+ e && e.show !== "both" && (this.orientation = e.show), this.focusRafId = requestAnimationFrame(() => {
720
+ this.focusRafId = null;
721
+ const o = this.getVisibleOptions().findIndex((i) => i.value === this.value);
722
+ this.focusOption(o >= 0 ? o : 0);
723
+ });
724
+ }
725
+ }
726
+ render() {
727
+ const t = this.getVisibleOptions(), e = j(this.value) ?? J.free;
728
+ return d`
729
+ <div
730
+ @keydown=${this.onKeyDown}
731
+ @click=${(r) => r.stopPropagation()}
732
+ >
733
+ <button
734
+ type="button"
735
+ class="sfx-cr-shape-trigger"
736
+ aria-label="Select crop shape"
737
+ aria-haspopup="listbox"
738
+ aria-expanded=${this.open ? "true" : "false"}
739
+ @click=${this.onTriggerClick}
740
+ >
741
+ <span class="sfx-cr-shape-trigger-icon">${v(f("cropAspect", this.icons))}</span>
742
+ <span class="sfx-cr-shape-trigger-label">${e.label}</span>
743
+ <span class="sfx-cr-shape-chevron">${v(f("chevronDown", this.icons))}</span>
744
+ </button>
745
+ <div class="sfx-cr-shape-dropdown" role="listbox">
746
+ <div class="sfx-cr-shape-orient" role="tablist" aria-label="Orientation">
747
+ <button
748
+ type="button"
749
+ class=${`sfx-cr-shape-orient-btn${this.orientation === "landscape" ? " is-active" : ""}`}
750
+ role="tab"
751
+ aria-selected=${this.orientation === "landscape" ? "true" : "false"}
752
+ aria-label="Landscape orientations"
753
+ @click=${() => this.setOrientation("landscape")}
754
+ >${v(f("orientLandscape", this.icons))}</button>
755
+ <button
756
+ type="button"
757
+ class=${`sfx-cr-shape-orient-btn${this.orientation === "portrait" ? " is-active" : ""}`}
758
+ role="tab"
759
+ aria-selected=${this.orientation === "portrait" ? "true" : "false"}
760
+ aria-label="Portrait orientations"
761
+ @click=${() => this.setOrientation("portrait")}
762
+ >${v(f("orientPortrait", this.icons))}</button>
763
+ </div>
764
+ <div class="sfx-cr-shape-list" role="presentation">
765
+ ${t.map((r, o) => d`
766
+ <button
767
+ type="button"
768
+ class=${`sfx-cr-shape-option${r.value === this.value ? " sfx-cr-shape-option--active" : ""}`}
769
+ role="option"
770
+ aria-selected=${r.value === this.value ? "true" : "false"}
771
+ @click=${(i) => this.onOptionClick(i, r.value)}
772
+ data-index=${String(o)}
773
+ >
774
+ <span class="sfx-cr-shape-option-icon">${v(this.optionIcon(r))}</span>
775
+ <span class="sfx-cr-shape-option-label">${r.label}</span>
776
+ </button>
777
+ `)}
778
+ </div>
779
+ </div>
780
+ </div>
781
+ `;
782
+ }
783
+ /**
784
+ * Pick the icon for a dropdown option, consulting consumer overrides
785
+ * for the three non-ratio geometry shapes. Aspect-ratio options stay
786
+ * on their proportional rectangle — not overridable, and that's
787
+ * intentional since each one is generated from the ratio itself.
788
+ */
789
+ optionIcon(t) {
790
+ switch (t.value) {
791
+ case "free":
792
+ return f("cropCustom", this.icons);
793
+ case "circle":
794
+ return f("cropCircle", this.icons);
795
+ case "rounded-rect":
796
+ return f("cropRoundedRect", this.icons);
797
+ default:
798
+ return t.icon;
799
+ }
800
+ }
801
+ /** Sync value without emitting — used by host. */
802
+ setValue(t) {
803
+ this.value = t;
804
+ }
805
+ setOrientation(t) {
806
+ this.orientation !== t && (this.orientation = t, this.focusedIndex = -1);
807
+ }
808
+ /**
809
+ * Options visible under the current orientation tab, respecting the
810
+ * `shapes` allow-list. Each allowed name is resolved via `resolveShape`
811
+ * so consumer-supplied `"W:H"` strings (not in SHAPE_MAP) get a dynamic
812
+ * option with a proportional icon. Sorted: named shapes first in a
813
+ * fixed order, then ratios by numeric value.
814
+ */
815
+ getVisibleOptions() {
816
+ const t = [];
817
+ for (const e of this.shapes) {
818
+ const r = j(e);
819
+ r && (r.show !== "both" && r.show !== this.orientation || t.push(r));
820
+ }
821
+ return t.sort((e, r) => {
822
+ const o = { free: 0, circle: 1, "rounded-rect": 2, square: 3 }, i = o[e.value], s = o[r.value];
823
+ if (i !== void 0 && s !== void 0) return i - s;
824
+ if (i !== void 0) return -1;
825
+ if (s !== void 0) return 1;
826
+ const u = V(e.value) ?? 1, p = V(r.value) ?? 1;
827
+ return this.orientation === "portrait" ? p - u : u - p;
828
+ });
829
+ }
830
+ emit(t) {
831
+ this.dispatchEvent(new CustomEvent("sfx-crop-shape-change", {
832
+ detail: { shape: t },
833
+ bubbles: !0,
834
+ composed: !0
835
+ }));
836
+ }
837
+ close() {
838
+ this.open = !1;
839
+ }
840
+ onOptionClick(t, e) {
841
+ t.stopPropagation(), this.value = e, this.close(), this.emit(e);
842
+ }
843
+ focusOption(t) {
844
+ this.focusedIndex = t;
845
+ const e = this.renderRoot.querySelector(
846
+ `.sfx-cr-shape-option[data-index="${t}"]`
847
+ );
848
+ e == null || e.focus();
849
+ }
850
+ };
851
+ B.styles = [I, wt];
852
+ let g = B;
853
+ k([
854
+ a({ type: String })
855
+ ], g.prototype, "value");
856
+ k([
857
+ a({ attribute: !1 })
858
+ ], g.prototype, "shapes");
859
+ k([
860
+ a({ type: Boolean, reflect: !0 })
861
+ ], g.prototype, "open");
862
+ k([
863
+ a({ type: String, reflect: !0 })
864
+ ], g.prototype, "variant");
865
+ k([
866
+ a({ attribute: !1 })
867
+ ], g.prototype, "icons");
868
+ k([
869
+ E()
870
+ ], g.prototype, "orientation");
871
+ k([
872
+ E()
873
+ ], g.prototype, "focusedIndex");
874
+ const $t = T`
875
+ :host {
876
+ position: absolute;
877
+ top: 16px;
878
+ left: 0;
879
+ right: 0;
880
+ display: flex;
881
+ justify-content: center;
882
+ z-index: 5;
883
+ animation: sfx-cr-toolbar-enter 300ms ease forwards;
884
+ pointer-events: none;
885
+ }
886
+
887
+ :host([toolbar-position="bottom"]) {
888
+ top: auto;
889
+ bottom: 16px;
890
+ }
891
+
892
+ /* Fixed variant: the editor box IS the crop frame, so the floating bar sits
893
+ directly over the photo. Classic gets its button contrast for free from
894
+ the dimmed crop mask; fixed has none, so give each control its own
895
+ translucent pill to stay legible over arbitrary image content.
896
+
897
+ IMPORTANT: backgrounds only — no backdrop-filter / transform / filter
898
+ here or on any ancestor. Those create a containing block for
899
+ position:fixed descendants, which would re-anchor the canvas-bottom ruler
900
+ + shape popover (both fixed-positioned) to the bar and knock the 45-deg
901
+ tilt ruler off-screen. A plain background is safe. */
902
+ :host([variant="fixed"]) .sfx-cr-toolbar,
903
+ :host([variant="fixed"]) .sfx-cr-toolbar-group {
904
+ /* Fixed variant runs a slightly tighter uniform gap than classic. */
905
+ gap: 12px;
906
+ }
907
+ :host([variant="fixed"]) .sfx-cr-reset-btn,
908
+ :host([variant="fixed"]) .sfx-cr-toolbar-btn {
909
+ background: var(--sfx-cr-overlay-color);
910
+ }
911
+
912
+ /* Primary "Done" action — pinned to the right edge of the toolbar strip,
913
+ away from the centered control cluster. The host spans the full block
914
+ width (left:0/right:0), so right:16px sits near the block's edge. */
915
+ .sfx-cr-done-btn {
916
+ position: absolute;
917
+ right: 16px;
918
+ top: 50%;
919
+ transform: translateY(-50%);
920
+ pointer-events: auto;
921
+ display: inline-flex;
922
+ align-items: center;
923
+ justify-content: center;
924
+ height: 36px;
925
+ padding: 0 18px;
926
+ background: var(--sfx-cr-primary);
927
+ color: #fff;
928
+ border: none;
929
+ border-radius: 50px;
930
+ cursor: pointer;
931
+ font-family: var(--sfx-cr-font);
932
+ font-size: 14px;
933
+ font-weight: 600;
934
+ letter-spacing: 0.1px;
935
+ white-space: nowrap;
936
+ box-shadow: var(--sfx-cr-toolbar-shadow);
937
+ transition:
938
+ background var(--sfx-cr-transition),
939
+ transform var(--sfx-cr-transition);
940
+ }
941
+ .sfx-cr-done-btn:hover {
942
+ background: var(--sfx-cr-primary-hover);
943
+ transform: translateY(-50%) scale(1.02);
944
+ }
945
+ .sfx-cr-done-btn:active {
946
+ transform: translateY(-50%) scale(0.97);
947
+ }
948
+ .sfx-cr-done-btn:focus-visible {
949
+ outline: 2px solid var(--sfx-cr-ring);
950
+ outline-offset: 2px;
951
+ }
952
+
953
+ /* Hole-punch pattern: the toolbar host is pointer-transparent and
954
+ individual interactive children below opt back in. Gaps between
955
+ buttons fall through to the canvas — important when a crop handle
956
+ ends up under the floating toolbar and the user wants to grab it.
957
+ The rotate / zoom / shapes sub-elements already follow the same
958
+ pattern in their own stylesheets. */
959
+ .sfx-cr-toolbar {
960
+ display: flex;
961
+ flex-direction: row;
962
+ align-items: center;
963
+ gap: 16px;
964
+ padding: 4px 8px;
965
+ background: transparent;
966
+ color: var(--sfx-cr-toolbar-color);
967
+ border: none;
968
+ border-radius: 0;
969
+ box-shadow: none;
970
+ pointer-events: none;
971
+ }
972
+
973
+ .sfx-cr-toolbar-group {
974
+ display: flex;
975
+ flex-direction: row;
976
+ align-items: center;
977
+ /* Match the toolbar's own gap so spacing is uniform across every button
978
+ (Reset, rotate, flip, shapes), not tighter inside the group. */
979
+ gap: 16px;
980
+ }
981
+
982
+ /* Sub-element hosts — same hole-punch opt-in as the plain buttons.
983
+ Their hosts are tight inline-flex wrappers around a single trigger,
984
+ so re-enabling them adds no extra dead zone. */
985
+ sfx-crop-rotate,
986
+ sfx-crop-shapes {
987
+ pointer-events: auto;
988
+ }
989
+
990
+ /* The fine-tilt ruler renders as a canvas-anchored fixed popover, but its
991
+ inline host still occupies a zero-width slot in the toolbar row — which
992
+ doubles the gap between the flip button and the shape selector. Pull the
993
+ host out of flow so every visible button stays evenly spaced (both
994
+ variants). The popover is position:fixed, so this doesn't move it. */
995
+ sfx-crop-rotate {
996
+ position: absolute;
997
+ }
998
+
999
+ .sfx-cr-toolbar-btn {
1000
+ pointer-events: auto;
1001
+ width: 52px;
1002
+ height: 36px;
1003
+ display: flex;
1004
+ align-items: center;
1005
+ justify-content: center;
1006
+ background: transparent;
1007
+ color: var(--sfx-cr-text-secondary);
1008
+ /* Transparent default border → hover swaps in a colored ring without
1009
+ the layout shifting from 0 → 1 px. */
1010
+ border: 1px solid transparent;
1011
+ border-radius: 999px;
1012
+ cursor: pointer;
1013
+ padding: 0;
1014
+ transition:
1015
+ border-color var(--sfx-cr-transition),
1016
+ color var(--sfx-cr-transition),
1017
+ transform var(--sfx-cr-transition);
1018
+ }
1019
+
1020
+ .sfx-cr-toolbar-btn:hover {
1021
+ border-color: var(--sfx-cr-primary);
1022
+ transform: translateY(-1px);
1023
+ }
1024
+
1025
+ .sfx-cr-toolbar-btn:active {
1026
+ transform: translateY(0) scale(0.96);
1027
+ }
1028
+
1029
+ .sfx-cr-toolbar-btn:disabled {
1030
+ opacity: 0.45;
1031
+ cursor: not-allowed;
1032
+ }
1033
+
1034
+ .sfx-cr-toolbar-btn:disabled:hover {
1035
+ border-color: transparent;
1036
+ color: var(--sfx-cr-text-muted);
1037
+ transform: none;
1038
+ }
1039
+
1040
+ .sfx-cr-toolbar-btn:focus-visible {
1041
+ outline: 2px solid var(--sfx-cr-ring);
1042
+ outline-offset: 2px;
1043
+ }
1044
+
1045
+ .sfx-cr-toolbar-btn svg {
1046
+ width: 20px;
1047
+ height: 20px;
1048
+ display: block;
1049
+ }
1050
+
1051
+ /* Reset pill — mirrors the shape-selector trigger visual language:
1052
+ capsule border, transparent fill, primary-blue tint on hover. Lives
1053
+ before every other control so the user can wipe back to the initial
1054
+ state in one click. */
1055
+ .sfx-cr-reset-btn {
1056
+ pointer-events: auto;
1057
+ display: flex;
1058
+ align-items: center;
1059
+ gap: 6px;
1060
+ padding: 8px 14px;
1061
+ min-width: 84px;
1062
+ height: 36px;
1063
+ background: transparent;
1064
+ color: var(--sfx-cr-text-secondary);
1065
+ border: 1.5px solid var(--sfx-cr-border);
1066
+ border-radius: 50px;
1067
+ cursor: pointer;
1068
+ font-family: var(--sfx-cr-font);
1069
+ font-size: 14px;
1070
+ font-weight: 500;
1071
+ letter-spacing: 0.1px;
1072
+ white-space: nowrap;
1073
+ transition:
1074
+ background var(--sfx-cr-transition),
1075
+ border-color var(--sfx-cr-transition),
1076
+ color var(--sfx-cr-transition),
1077
+ transform var(--sfx-cr-transition),
1078
+ box-shadow var(--sfx-cr-transition);
1079
+ }
1080
+ .sfx-cr-reset-btn:hover {
1081
+ border-color: var(--sfx-cr-primary);
1082
+ transform: translateY(-1px);
1083
+ }
1084
+ .sfx-cr-reset-btn:focus-visible {
1085
+ outline: 2px solid var(--sfx-cr-ring);
1086
+ outline-offset: 2px;
1087
+ }
1088
+ .sfx-cr-reset-btn svg {
1089
+ width: 18px;
1090
+ height: 18px;
1091
+ display: block;
1092
+ }
1093
+
1094
+ @media (max-width: 768px) {
1095
+ .sfx-cr-toolbar {
1096
+ flex-wrap: wrap;
1097
+ justify-content: center;
1098
+ }
1099
+ }
1100
+
1101
+ @media (max-width: 480px) {
1102
+ .sfx-cr-toolbar {
1103
+ padding: 6px 8px;
1104
+ gap: 8px;
1105
+ }
1106
+ .sfx-cr-toolbar-group {
1107
+ gap: 8px;
1108
+ }
1109
+ .sfx-cr-toolbar-btn {
1110
+ width: 40px;
1111
+ height: 32px;
1112
+ }
1113
+ .sfx-cr-toolbar-btn svg {
1114
+ width: 18px;
1115
+ height: 18px;
1116
+ display: block;
1117
+ }
1118
+ }
1119
+
1120
+ /* Narrow editor (component itself is small, regardless of viewport):
1121
+ stack the toolbar vertically along the LEFT edge, icons only.
1122
+ Tucked tight against the edge with a compact 30×30 footprint so
1123
+ the photo behind keeps maximum breathing room. Triggered by the
1124
+ sfxcrop container set on the sfx-crop host — matches editor
1125
+ width, not viewport width, so a narrow column on a wide desktop
1126
+ gets the same compact layout.
1127
+
1128
+ EXCLUDED from the fixed variant via :not([variant="fixed"]): a fixed
1129
+ frame is often portrait/phone-shaped (narrow but tall), where the left
1130
+ rail looks wrong — fixed keeps the horizontal top bar at any width. */
1131
+ @container sfxcrop (max-width: 760px) {
1132
+ :host(:not([variant="fixed"])) {
1133
+ top: 8px;
1134
+ bottom: 8px;
1135
+ /* Stay full-width (don't collapse to a left-hugging strip): the Done
1136
+ button is absolutely positioned against this host, so the host must
1137
+ keep spanning to the container's right edge for Done to stay in the
1138
+ top-right corner. The button column is tucked left with padding
1139
+ instead of by repositioning the whole host. */
1140
+ left: 0;
1141
+ right: 0;
1142
+ padding-left: 4px;
1143
+ justify-content: flex-start;
1144
+ /* Cross-axis centers the stacked button column vertically inside
1145
+ the full-height host strip — toolbar floats in the middle of
1146
+ the photo regardless of its content height. */
1147
+ align-items: center;
1148
+ }
1149
+ :host(:not([variant="fixed"])[toolbar-position="bottom"]) {
1150
+ top: 8px;
1151
+ bottom: 8px;
1152
+ }
1153
+ /* Keep Done pinned to the editor's top-right corner — exactly where the
1154
+ desktop bar puts it — even though the host now spans the full photo
1155
+ height (top:50% would otherwise drop it to the vertical middle). A bit
1156
+ smaller and tucked tighter into the corner to free up the photo. */
1157
+ :host(:not([variant="fixed"])) .sfx-cr-done-btn {
1158
+ top: 6px;
1159
+ right: 8px;
1160
+ height: 28px;
1161
+ padding: 0 12px;
1162
+ font-size: 12px;
1163
+ transform: none;
1164
+ }
1165
+ :host(:not([variant="fixed"])) .sfx-cr-done-btn:hover { transform: scale(1.02); }
1166
+ :host(:not([variant="fixed"])) .sfx-cr-done-btn:active { transform: scale(0.97); }
1167
+ :host(:not([variant="fixed"])) .sfx-cr-toolbar {
1168
+ flex-direction: column;
1169
+ flex-wrap: nowrap;
1170
+ align-items: center;
1171
+ justify-content: flex-start;
1172
+ gap: 4px;
1173
+ padding: 3px;
1174
+ }
1175
+ :host(:not([variant="fixed"])) .sfx-cr-toolbar-group {
1176
+ flex-direction: column;
1177
+ gap: 4px;
1178
+ }
1179
+ :host(:not([variant="fixed"])) .sfx-cr-toolbar-btn {
1180
+ width: 30px;
1181
+ height: 30px;
1182
+ }
1183
+ :host(:not([variant="fixed"])) .sfx-cr-toolbar-btn svg {
1184
+ width: 16px;
1185
+ height: 16px;
1186
+ }
1187
+ :host(:not([variant="fixed"])) .sfx-cr-reset-btn {
1188
+ width: 30px;
1189
+ height: 30px;
1190
+ min-width: 0;
1191
+ padding: 0;
1192
+ gap: 0;
1193
+ justify-content: center;
1194
+ }
1195
+ :host(:not([variant="fixed"])) .sfx-cr-reset-btn svg {
1196
+ width: 16px;
1197
+ height: 16px;
1198
+ }
1199
+ :host(:not([variant="fixed"])) .sfx-cr-reset-btn span {
1200
+ display: none;
1201
+ }
1202
+ }
1203
+
1204
+ /* Fixed + narrow (portrait/phone frame): keep the horizontal top bar, but
1205
+ render every control as a uniform 40×40 round icon button, centered in
1206
+ the frame. (Reset / shapes labels are dropped — icon only.) */
1207
+ @container sfxcrop (max-width: 760px) {
1208
+ :host([variant="fixed"]) .sfx-cr-toolbar {
1209
+ flex-wrap: wrap;
1210
+ justify-content: center;
1211
+ gap: 10px;
1212
+ }
1213
+ :host([variant="fixed"]) .sfx-cr-toolbar-group {
1214
+ gap: 10px;
1215
+ }
1216
+ :host([variant="fixed"]) .sfx-cr-reset-btn,
1217
+ :host([variant="fixed"]) .sfx-cr-toolbar-btn {
1218
+ width: 40px;
1219
+ height: 40px;
1220
+ min-width: 0;
1221
+ padding: 0;
1222
+ gap: 0;
1223
+ justify-content: center;
1224
+ }
1225
+ :host([variant="fixed"]) .sfx-cr-reset-btn span {
1226
+ display: none;
1227
+ }
1228
+ :host([variant="fixed"]) .sfx-cr-done-btn {
1229
+ /* Stay in the top-right corner when the bar wraps to multiple rows
1230
+ (top:50% would otherwise centre Done over the taller wrapped bar),
1231
+ a bit smaller and tucked tighter into the corner. */
1232
+ top: 6px;
1233
+ right: 8px;
1234
+ height: 28px;
1235
+ padding: 0 12px;
1236
+ font-size: 12px;
1237
+ transform: none;
1238
+ }
1239
+ :host([variant="fixed"]) .sfx-cr-done-btn:hover { transform: scale(1.02); }
1240
+ :host([variant="fixed"]) .sfx-cr-done-btn:active { transform: scale(0.97); }
1241
+ }
1242
+ `;
1243
+ var Ct = Object.defineProperty, x = (n, t, e, r) => {
1244
+ for (var o = void 0, i = n.length - 1, s; i >= 0; i--)
1245
+ (s = n[i]) && (o = s(t, e, o) || o);
1246
+ return o && Ct(t, e, o), o;
1247
+ };
1248
+ const L = class L extends R {
1249
+ constructor() {
1250
+ super(...arguments), this.shape = "free", this.rotation = 0, this.showRotateButton = !0, this.showFlipButton = !0, this.showRotateSlider = !0, this.showShapeSelector = !0, this.toolbarPosition = "top", this.variant = "classic", this.availableShapes = null, this.icons = {}, this.onPopoverOpen = (t) => {
1251
+ var r;
1252
+ ((r = t.detail) == null ? void 0 : r.source) !== "shapes" && this.shapesEl && (this.shapesEl.open = !1);
1253
+ };
1254
+ }
1255
+ render() {
1256
+ const t = this.showRotateButton || this.showFlipButton, e = et(this.availableShapes) ?? [...ot];
1257
+ return d`
1258
+ <div class="sfx-cr-toolbar" @sfx-crop-popover-open=${this.onPopoverOpen}>
1259
+ <button
1260
+ type="button"
1261
+ class="sfx-cr-reset-btn"
1262
+ aria-label="Reset all changes"
1263
+ @click=${() => this.emit({ type: "reset" })}
1264
+ >
1265
+ ${v(f("reset", this.icons))}
1266
+ <span>Reset</span>
1267
+ </button>
1268
+
1269
+ ${t ? d`
1270
+ <div class="sfx-cr-toolbar-group">
1271
+ ${this.showRotateButton ? d`
1272
+ <button
1273
+ type="button"
1274
+ class="sfx-cr-toolbar-btn"
1275
+ aria-label="Rotate left 90°"
1276
+ @click=${() => this.emit({ type: "rotate-left" })}
1277
+ >${v(f("rotateLeft", this.icons))}</button>
1278
+ ` : null}
1279
+ ${this.showFlipButton ? d`
1280
+ <button
1281
+ type="button"
1282
+ class="sfx-cr-toolbar-btn"
1283
+ aria-label="Flip horizontal"
1284
+ @click=${() => this.emit({ type: "flip-h" })}
1285
+ >${v(f("flipHorizontal", this.icons))}</button>
1286
+ ` : null}
1287
+ </div>
1288
+ ` : null}
1289
+
1290
+ ${this.showRotateSlider ? d`
1291
+ <sfx-crop-rotate
1292
+ .value=${this.rotation}
1293
+ .icons=${this.icons}
1294
+ @sfx-crop-rotate-change=${(r) => this.emit({ type: "rotation", value: r.detail.degrees })}
1295
+ ></sfx-crop-rotate>
1296
+ ` : null}
1297
+
1298
+ ${this.showShapeSelector ? d`
1299
+ <sfx-crop-shapes
1300
+ .value=${this.shape}
1301
+ .shapes=${e}
1302
+ variant=${this.variant}
1303
+ .icons=${this.icons}
1304
+ @sfx-crop-shape-change=${(r) => this.emit({ type: "shape", value: r.detail.shape })}
1305
+ ></sfx-crop-shapes>
1306
+ ` : null}
1307
+ </div>
1308
+
1309
+ <button
1310
+ type="button"
1311
+ class="sfx-cr-done-btn"
1312
+ part="done"
1313
+ aria-label="Done"
1314
+ @click=${() => this.emit({ type: "save" })}
1315
+ >Done</button>
1316
+ `;
1317
+ }
1318
+ /** Sync the rotation slider without firing an event. */
1319
+ setRotationValue(t) {
1320
+ var e;
1321
+ this.rotation = t, (e = this.rotateEl) == null || e.setValue(t);
1322
+ }
1323
+ /** Sync the shape selector without firing an event. */
1324
+ setShapeValue(t) {
1325
+ var e;
1326
+ this.shape = t, (e = this.shapesEl) == null || e.setValue(t);
1327
+ }
1328
+ emit(t) {
1329
+ this.dispatchEvent(new CustomEvent("sfx-crop-toolbar-command", {
1330
+ detail: t,
1331
+ bubbles: !0,
1332
+ composed: !0
1333
+ }));
1334
+ }
1335
+ };
1336
+ L.styles = [I, tt, $t];
1337
+ let c = L;
1338
+ x([
1339
+ a({ type: String })
1340
+ ], c.prototype, "shape");
1341
+ x([
1342
+ a({ type: Number })
1343
+ ], c.prototype, "rotation");
1344
+ x([
1345
+ a({ type: Boolean, attribute: "show-rotate-button" })
1346
+ ], c.prototype, "showRotateButton");
1347
+ x([
1348
+ a({ type: Boolean, attribute: "show-flip-button" })
1349
+ ], c.prototype, "showFlipButton");
1350
+ x([
1351
+ a({ type: Boolean, attribute: "show-rotate-slider" })
1352
+ ], c.prototype, "showRotateSlider");
1353
+ x([
1354
+ a({ type: Boolean, attribute: "show-shape-selector" })
1355
+ ], c.prototype, "showShapeSelector");
1356
+ x([
1357
+ a({ type: String, attribute: "toolbar-position", reflect: !0 })
1358
+ ], c.prototype, "toolbarPosition");
1359
+ x([
1360
+ a({ type: String, reflect: !0 })
1361
+ ], c.prototype, "variant");
1362
+ x([
1363
+ a({ attribute: "available-shapes" })
1364
+ ], c.prototype, "availableShapes");
1365
+ x([
1366
+ a({ attribute: !1 })
1367
+ ], c.prototype, "icons");
1368
+ x([
1369
+ U("sfx-crop-rotate")
1370
+ ], c.prototype, "rotateEl");
1371
+ x([
1372
+ U("sfx-crop-shapes")
1373
+ ], c.prototype, "shapesEl");
1374
+ const zt = T`
1375
+ :host {
1376
+ position: relative;
1377
+ display: inline-flex;
1378
+ align-items: center;
1379
+ }
1380
+
1381
+ .sfx-cr-zoom-root {
1382
+ position: relative;
1383
+ display: flex;
1384
+ align-items: center;
1385
+ justify-content: center;
1386
+ }
1387
+
1388
+ /* Trigger — visually matches the other toolbar icon buttons. */
1389
+ .sfx-cr-zoom-trigger {
1390
+ width: 44px;
1391
+ height: 36px;
1392
+ display: flex;
1393
+ align-items: center;
1394
+ justify-content: center;
1395
+ padding: 0;
1396
+ background: transparent;
1397
+ color: var(--sfx-cr-text-secondary);
1398
+ border: 1px solid transparent;
1399
+ border-radius: 999px;
1400
+ cursor: pointer;
1401
+ transition:
1402
+ border-color var(--sfx-cr-transition),
1403
+ color var(--sfx-cr-transition),
1404
+ transform var(--sfx-cr-transition);
1405
+ }
1406
+ .sfx-cr-zoom-trigger:hover {
1407
+ border-color: var(--sfx-cr-primary);
1408
+ color: var(--sfx-cr-primary);
1409
+ transform: translateY(-1px);
1410
+ }
1411
+ .sfx-cr-zoom-trigger:active {
1412
+ transform: translateY(0) scale(0.96);
1413
+ }
1414
+ .sfx-cr-zoom-trigger:focus-visible {
1415
+ outline: 2px solid var(--sfx-cr-ring);
1416
+ outline-offset: 2px;
1417
+ }
1418
+ .sfx-cr-zoom-trigger svg {
1419
+ width: 20px;
1420
+ height: 20px;
1421
+ display: block;
1422
+ }
1423
+
1424
+ :host([open]) .sfx-cr-zoom-trigger {
1425
+ color: var(--sfx-cr-primary);
1426
+ }
1427
+
1428
+ /* Popover — transparent, floats above the trigger. */
1429
+ .sfx-cr-zoom-popover {
1430
+ position: fixed;
1431
+ top: var(--sfx-cr-popover-top, 50%);
1432
+ left: var(--sfx-cr-popover-left, 50%);
1433
+ transform: translateX(-50%) translateY(6px) scale(0.98);
1434
+ display: flex;
1435
+ flex-direction: column;
1436
+ align-items: center;
1437
+ gap: 4px;
1438
+ padding: 0;
1439
+ background: transparent;
1440
+ border: none;
1441
+ box-shadow: none;
1442
+ opacity: 0;
1443
+ pointer-events: none;
1444
+ transition: opacity 120ms ease-in, transform 120ms ease-in;
1445
+ white-space: nowrap;
1446
+ z-index: 10;
1447
+ }
1448
+
1449
+ :host([open]) .sfx-cr-zoom-popover {
1450
+ opacity: 1;
1451
+ transform: translateX(-50%) translateY(0) scale(1);
1452
+ pointer-events: auto;
1453
+ transition: opacity 220ms cubic-bezier(0.34, 1.2, 0.64, 1),
1454
+ transform 220ms cubic-bezier(0.34, 1.2, 0.64, 1);
1455
+ }
1456
+
1457
+ .sfx-cr-zoom-ruler {
1458
+ position: relative;
1459
+ width: var(--ruler-w, 260px);
1460
+ height: 30px;
1461
+ overflow: hidden;
1462
+ cursor: grab;
1463
+ touch-action: none;
1464
+ user-select: none;
1465
+ -webkit-user-select: none;
1466
+ }
1467
+ .sfx-cr-zoom-ruler.is-dragging { cursor: grabbing; }
1468
+ .sfx-cr-zoom-ruler:focus-visible {
1469
+ outline: 2px solid var(--sfx-cr-ring);
1470
+ outline-offset: 2px;
1471
+ border-radius: 4px;
1472
+ }
1473
+
1474
+ .sfx-cr-zoom-ticks {
1475
+ position: absolute;
1476
+ top: 50%;
1477
+ left: 0;
1478
+ height: 100%;
1479
+ will-change: transform;
1480
+ }
1481
+
1482
+ .sfx-cr-zoom-tick {
1483
+ position: absolute;
1484
+ top: 50%;
1485
+ width: 1px;
1486
+ height: 8px;
1487
+ margin-left: -0.5px;
1488
+ margin-top: -4px;
1489
+ border-radius: 0.5px;
1490
+ background: var(--sfx-cr-text);
1491
+ opacity: 0.55;
1492
+ }
1493
+ .sfx-cr-zoom-tick--major {
1494
+ width: 1px;
1495
+ height: 12px;
1496
+ margin-left: -0.5px;
1497
+ margin-top: -6px;
1498
+ opacity: 0.9;
1499
+ }
1500
+
1501
+ .sfx-cr-zoom-indicator {
1502
+ position: absolute;
1503
+ top: calc(50% + 4px);
1504
+ height: 16px;
1505
+ left: 50%;
1506
+ width: 4px;
1507
+ margin-left: -2px;
1508
+ background: var(--sfx-cr-text);
1509
+ border-radius: 2px;
1510
+ pointer-events: none;
1511
+ }
1512
+
1513
+ .sfx-cr-zoom-value {
1514
+ font-size: 14px;
1515
+ font-weight: 400;
1516
+ color: var(--sfx-cr-text);
1517
+ text-align: center;
1518
+ font-variant-numeric: tabular-nums;
1519
+ letter-spacing: 0.2px;
1520
+ }
1521
+
1522
+ @media (max-width: 768px) {
1523
+ /* Slimmer ruler + smaller readout on phones, mirroring the rotate
1524
+ popover. Push the popover down toward the canvas bottom edge so
1525
+ it doesn't sit in the middle of the photo. */
1526
+ .sfx-cr-zoom-ruler { width: 220px; height: 22px; }
1527
+ .sfx-cr-zoom-tick { height: 6px; margin-top: -3px; }
1528
+ .sfx-cr-zoom-tick--major { height: 9px; margin-top: -4.5px; }
1529
+ .sfx-cr-zoom-indicator {
1530
+ top: calc(50% + 3px);
1531
+ height: 12px;
1532
+ width: 3px;
1533
+ margin-left: -1.5px;
1534
+ }
1535
+ .sfx-cr-zoom-value { font-size: 12px; }
1536
+ :host([open]) .sfx-cr-zoom-popover {
1537
+ transform: translateX(-50%) translateY(24px) scale(1);
1538
+ }
1539
+ }
1540
+ @media (max-width: 480px) {
1541
+ .sfx-cr-zoom-ruler { width: 180px; height: 20px; }
1542
+ .sfx-cr-zoom-tick { height: 5px; margin-top: -2.5px; }
1543
+ .sfx-cr-zoom-tick--major { height: 8px; margin-top: -4px; }
1544
+ .sfx-cr-zoom-indicator {
1545
+ top: calc(50% + 2px);
1546
+ height: 10px;
1547
+ }
1548
+ .sfx-cr-zoom-value { font-size: 11px; }
1549
+ :host([open]) .sfx-cr-zoom-popover {
1550
+ transform: translateX(-50%) translateY(30px) scale(1);
1551
+ }
1552
+ }
1553
+
1554
+ /* Narrow editor — match the compact 30×30 trigger sizing of the
1555
+ rest of the vertical left-rail toolbar. Container query so a
1556
+ narrow editor on a wide desktop also collapses. */
1557
+ @container sfxcrop (max-width: 600px) {
1558
+ .sfx-cr-zoom-trigger {
1559
+ width: 30px;
1560
+ height: 30px;
1561
+ }
1562
+ .sfx-cr-zoom-trigger svg {
1563
+ width: 16px;
1564
+ height: 16px;
1565
+ }
1566
+ }
1567
+ `;
1568
+ var Pt = Object.defineProperty, z = (n, t, e, r) => {
1569
+ for (var o = void 0, i = n.length - 1, s; i >= 0; i--)
1570
+ (s = n[i]) && (o = s(t, e, o) || o);
1571
+ return o && Pt(t, e, o), o;
1572
+ };
1573
+ function D(n, t, e) {
1574
+ return Math.log(n / t) / Math.log(e / t);
1575
+ }
1576
+ function X(n, t, e) {
1577
+ return t * Math.pow(e / t, n);
1578
+ }
1579
+ const M = 260, Y = 260, H = 40, St = 5, F = class F extends R {
1580
+ constructor() {
1581
+ super(...arguments), this.min = 0.5, this.max = 5, this.value = 1, this.open = !1, this.icons = {}, this.dragging = !1, this.activePointer = null, this.pointerStartX = 0, this.pointerStartSlider = 0, this.autoCloseTimer = null, this.docClickHandler = () => {
1582
+ this.open && (this.clearAutoClose(), this.open = !1);
1583
+ }, this.popoverAnchor = W(this, ".sfx-cr-zoom-popover"), this.onTriggerClick = (t) => {
1584
+ t.stopPropagation(), this.clearAutoClose(), this.open = !this.open, this.open && this.dispatchEvent(new CustomEvent("sfx-crop-popover-open", {
1585
+ detail: { source: "zoom" },
1586
+ bubbles: !0,
1587
+ composed: !0
1588
+ }));
1589
+ }, this.onKeyDown = (t) => {
1590
+ if (this.open) {
1591
+ if (t.key === "Escape") {
1592
+ t.preventDefault(), t.stopPropagation(), this.open = !1;
1593
+ return;
1594
+ }
1595
+ if (t.key === "ArrowLeft" || t.key === "ArrowRight") {
1596
+ t.preventDefault();
1597
+ const e = t.key === "ArrowRight" ? 1 : -1, r = t.shiftKey ? 0.05 : 0.01, o = D(this.value, this.min, this.max), i = y(o + e * r, 0, 1);
1598
+ this.emit(X(i, this.min, this.max));
1599
+ }
1600
+ }
1601
+ }, this.onPointerDown = (t) => {
1602
+ if (this.activePointer === null) {
1603
+ this.clearAutoClose(), this.activePointer = t.pointerId, this.pointerStartX = t.clientX, this.pointerStartSlider = D(this.value, this.min, this.max), this.dragging = !0;
1604
+ try {
1605
+ t.currentTarget.setPointerCapture(t.pointerId);
1606
+ } catch {
1607
+ }
1608
+ }
1609
+ }, this.onPointerMove = (t) => {
1610
+ if (this.activePointer !== t.pointerId) return;
1611
+ const e = t.clientX - this.pointerStartX, r = y(this.pointerStartSlider - e / M, 0, 1);
1612
+ this.emit(X(r, this.min, this.max));
1613
+ }, this.onPointerUp = (t) => {
1614
+ if (this.activePointer === t.pointerId) {
1615
+ this.activePointer = null, this.dragging = !1;
1616
+ try {
1617
+ t.currentTarget.releasePointerCapture(t.pointerId);
1618
+ } catch {
1619
+ }
1620
+ }
1621
+ }, this.onReset = () => {
1622
+ this.emit(1);
1623
+ };
1624
+ }
1625
+ connectedCallback() {
1626
+ super.connectedCallback(), document.addEventListener("click", this.docClickHandler);
1627
+ }
1628
+ disconnectedCallback() {
1629
+ super.disconnectedCallback(), document.removeEventListener("click", this.docClickHandler), this.popoverAnchor.stop(), this.clearAutoClose();
1630
+ }
1631
+ updated(t) {
1632
+ t.has("open") && (this.open ? this.popoverAnchor.start() : this.popoverAnchor.stop()), this.open && (t.has("value") || t.has("dragging")) && this.popoverAnchor.update();
1633
+ }
1634
+ render() {
1635
+ const t = D(this.value, this.min, this.max), e = Math.round(this.value * 100), r = Y / 2 - t * M, o = [], i = 1 / H;
1636
+ for (let s = 0; s <= H; s++)
1637
+ o.push({ pos: s * i, major: s % St === 0 });
1638
+ return d`
1639
+ <div
1640
+ class="sfx-cr-zoom-root"
1641
+ @click=${(s) => s.stopPropagation()}
1642
+ @keydown=${this.onKeyDown}
1643
+ >
1644
+ <button
1645
+ type="button"
1646
+ class="sfx-cr-zoom-trigger"
1647
+ aria-label=${`Zoom — ${e}%`}
1648
+ aria-haspopup="dialog"
1649
+ aria-expanded=${this.open ? "true" : "false"}
1650
+ @click=${this.onTriggerClick}
1651
+ >${v(f("loupe", this.icons))}</button>
1652
+
1653
+ <div class="sfx-cr-zoom-popover" role="group" aria-label="Zoom controls">
1654
+ <div
1655
+ class=${`sfx-cr-zoom-ruler${this.dragging ? " is-dragging" : ""}`}
1656
+ role="slider"
1657
+ aria-valuemin=${String(this.min)}
1658
+ aria-valuemax=${String(this.max)}
1659
+ aria-valuenow=${this.value.toFixed(2)}
1660
+ aria-valuetext=${`${e}%`}
1661
+ tabindex="0"
1662
+ style=${`--ruler-w: ${Y}px`}
1663
+ @pointerdown=${this.onPointerDown}
1664
+ @pointermove=${this.onPointerMove}
1665
+ @pointerup=${this.onPointerUp}
1666
+ @pointercancel=${this.onPointerUp}
1667
+ @dblclick=${this.onReset}
1668
+ >
1669
+ <div class="sfx-cr-zoom-ticks" style=${`transform: translateX(${r.toFixed(1)}px)`}>
1670
+ ${o.map((s) => d`
1671
+ <span
1672
+ class=${`sfx-cr-zoom-tick${s.major ? " sfx-cr-zoom-tick--major" : ""}`}
1673
+ style=${`left: ${(s.pos * M).toFixed(1)}px`}
1674
+ ></span>
1675
+ `)}
1676
+ </div>
1677
+ <div class="sfx-cr-zoom-indicator" aria-hidden="true"></div>
1678
+ </div>
1679
+ <span class="sfx-cr-zoom-value">${e}%</span>
1680
+ </div>
1681
+ </div>
1682
+ `;
1683
+ }
1684
+ /** Sync value without emitting — used by host to reflect controller state. */
1685
+ setValue(t) {
1686
+ this.value = y(t, this.min, this.max);
1687
+ }
1688
+ /**
1689
+ * Open the popover and auto-close after `duration` ms of inactivity.
1690
+ * Subsequent calls debounce the close (so a stream of wheel events keeps
1691
+ * the slider visible). Manual interaction (trigger click, ruler drag)
1692
+ * cancels the pending close.
1693
+ *
1694
+ * If the popover is already open via manual click (no timer armed) this
1695
+ * is a no-op: a wheel burst must never hijack a user-opened popover into
1696
+ * auto-closing.
1697
+ */
1698
+ showTemporarily(t = 1500) {
1699
+ if (this.open && this.autoCloseTimer === null) return;
1700
+ const e = this.open;
1701
+ this.open = !0, e || this.dispatchEvent(new CustomEvent("sfx-crop-popover-open", {
1702
+ detail: { source: "zoom" },
1703
+ bubbles: !0,
1704
+ composed: !0
1705
+ })), this.clearAutoClose(), this.autoCloseTimer = setTimeout(() => {
1706
+ this.autoCloseTimer = null, this.open = !1;
1707
+ }, t);
1708
+ }
1709
+ clearAutoClose() {
1710
+ this.autoCloseTimer !== null && (clearTimeout(this.autoCloseTimer), this.autoCloseTimer = null);
1711
+ }
1712
+ emit(t) {
1713
+ this.value !== t && (this.value = t, this.dispatchEvent(new CustomEvent("sfx-crop-zoom-change", {
1714
+ detail: { scale: t },
1715
+ bubbles: !0,
1716
+ composed: !0
1717
+ })));
1718
+ }
1719
+ };
1720
+ F.styles = [I, zt];
1721
+ let b = F;
1722
+ z([
1723
+ a({ type: Number })
1724
+ ], b.prototype, "min");
1725
+ z([
1726
+ a({ type: Number })
1727
+ ], b.prototype, "max");
1728
+ z([
1729
+ a({ type: Number })
1730
+ ], b.prototype, "value");
1731
+ z([
1732
+ a({ type: Boolean, reflect: !0 })
1733
+ ], b.prototype, "open");
1734
+ z([
1735
+ a({ attribute: !1 })
1736
+ ], b.prototype, "icons");
1737
+ z([
1738
+ E()
1739
+ ], b.prototype, "dragging");
1740
+ C("sfx-crop-zoom", b);
1741
+ C("sfx-crop-rotate", m);
1742
+ C("sfx-crop-shapes", g);
1743
+ C("sfx-crop-canvas", rt);
1744
+ C("sfx-crop-toolbar", c);
1745
+ C("sfx-crop", it);
1746
+ //# sourceMappingURL=define.js.map