@sealpixel/ui 1.0.0-rc.16 → 1.0.0-rc.17

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.
@@ -689,6 +689,36 @@ export class SealpixelEditor extends LitElement {
689
689
  background: var(--sealpixel-color-accent-soft, transparent);
690
690
  color: var(--sealpixel-color-fg);
691
691
  }
692
+ /*
693
+ * A source is loading: the mark, its core breathing. The outer square
694
+ * stands still and the inner one swells and fades, in the muted
695
+ * foreground so nothing reads as a warning. It stops under
696
+ * prefers-reduced-motion and still reads as the mark.
697
+ */
698
+ .empty.loading {
699
+ justify-items: center;
700
+ gap: calc(var(--sealpixel-space) * 2);
701
+ }
702
+ .empty.loading p {
703
+ margin: 0;
704
+ }
705
+ .mark {
706
+ display: block;
707
+ width: 40px;
708
+ height: 40px;
709
+ color: var(--sealpixel-color-fg-muted);
710
+ }
711
+ .mark .core {
712
+ transform-origin: 16px 16px;
713
+ animation: sealpixel-loading-breathe 1.8s var(--sealpixel-ease) infinite;
714
+ }
715
+ @keyframes sealpixel-loading-breathe {
716
+ 50% {
717
+ opacity: 0.45;
718
+ transform: scale(0.62);
719
+ }
720
+ }
721
+ }
692
722
  .error {
693
723
  grid-area: nav;
694
724
  align-self: end;
@@ -1360,7 +1390,13 @@ export class SealpixelEditor extends LitElement {
1360
1390
  }
1361
1391
  renderEmpty(state) {
1362
1392
  if (state?.status === 'loading') {
1363
- return html `<div class="empty" part="empty" role="status">${this.i18n.t('editor.loading')}</div>`;
1393
+ return html `<div class="empty loading" part="empty" role="status">
1394
+ <svg class="mark" viewBox="0 0 32 32" aria-hidden="true">
1395
+ <rect x="3" y="3" width="26" height="26" rx="5" fill="none" stroke="currentColor" stroke-width="2" />
1396
+ <rect class="core" x="11" y="11" width="10" height="10" rx="1.5" fill="currentColor" />
1397
+ </svg>
1398
+ <p>${this.i18n.t('editor.loading')}</p>
1399
+ </div>`;
1364
1400
  }
1365
1401
  return html `<div
1366
1402
  class="empty ${this._dragover ? 'dragover' : ''}"
@@ -1 +1 @@
1
- {"version":3,"file":"sealpixel-editor.js","sourceRoot":"","sources":["../../src/components/sealpixel-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EAMnB,cAAc,GAIf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,UAAU,EAA8B,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAK7C,gEAAgE;AAChE,SAAS,aAAa,CAAmB,IAAY;IACnD,OAAO;QACL,aAAa,EAAE,CAAC,KAAoB,EAAE,EAAE;YACtC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;gBAAE,OAAO,IAAI,CAAC;YACvD,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM,CAAC;YAChC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,CAAC,IAAI,CAAC,eAAe,IAAI,oBAAoB,CAAC,CAAC;gBACtD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,WAAW,EAAE,CAAC,KAAe,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KACzE,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH;;;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IACP,OAAO;IACP,QAAQ;CACT,CAAC,CAAC;AAEH,SAAS,WAAW,CAAC,MAA+B;IAClD,IAAI,CAAC,CAAC,MAAM,YAAY,WAAW,CAAC;QAAE,OAAO,KAAK,CAAC;IACnD,IAAI,MAAM,CAAC,iBAAiB,IAAI,MAAM,YAAY,mBAAmB;QAAE,OAAO,IAAI,CAAC;IACnF,OAAO,MAAM,YAAY,gBAAgB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,WAAW,CAAC,CAAS;IAC5B,IAAI,CAAC,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,IAAI,CAAC;IAC9B,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1E,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AAChD,CAAC","sourcesContent":["import {\n type AnyPlugin,\n type AssetResolver,\n canonicalJson,\n configurePlugins,\n createAssetResolver,\n createEditorSession,\n type EditorSession,\n type ExportResult,\n type OutputOptions,\n type PluginOptionsMap,\n type Renderer,\n SealpixelError,\n type SessionOptions,\n type SessionState,\n type SourceDescriptor,\n} from '@sealpixel/core';\nimport { defaultPlugins } from '@sealpixel/plugins';\nimport { css, html, LitElement, nothing, type TemplateResult } from 'lit';\nimport { SessionController } from '../controllers/session-controller.js';\nimport { createI18n, type Dictionary, type I18n } from '../i18n.js';\nimport { resolveLocale } from '../locales/index.js';\nimport { base, tokens } from '../theme.js';\nimport type { UiTool, UiToolContext } from '../tool.js';\nimport { toolsFor } from '../tools/index.js';\nimport type { SealpixelStage } from './sealpixel-stage.js';\n\nexport type EditorSource = File | Blob | Uint8Array | string;\n\n/** `plugin-options='{\"filter\":{...}}'` attribute ↔ property. */\nfunction jsonAttribute<T extends object>(name: string) {\n return {\n fromAttribute: (value: string | null) => {\n if (value === null || value.trim() === '') return null;\n try {\n return JSON.parse(value) as T;\n } catch {\n console.warn(`[sealpixel] ${name} is not valid JSON`);\n return null;\n }\n },\n toAttribute: (value: T | null) => (value ? JSON.stringify(value) : null),\n };\n}\n\n/**\n * The default editor. Headless `EditorSession` underneath; this element adds\n * the responsive shell, tools and events.\n *\n * Events: `sealpixel:ready`, `sealpixel:load`, `sealpixel:change` ({ log, index }),\n * `sealpixel:process` (ExportResult), `sealpixel:error` (SealpixelError).\n */\n/**\n * What makes a settings bar worth its height: a control, or anything that\n * draws. Plain `div`s are the tools' own scaffolding and never count.\n */\nconst PANEL_CONTENT = 'select, input, textarea, button, img, svg, canvas, a, [role]';\n\nexport class SealpixelEditor extends LitElement {\n static override styles = [\n tokens,\n base,\n css`\n :host {\n display: block;\n container-type: inline-size;\n background: var(--sealpixel-color-bg);\n color: var(--sealpixel-color-fg);\n height: 100%;\n min-height: 480px;\n min-width: 0;\n overflow: hidden;\n }\n :host(:focus) {\n outline: none;\n }\n .root {\n position: relative;\n display: grid;\n height: 100%;\n min-width: 0;\n grid-template:\n 'nav' auto\n 'stage' 1fr\n 'panel' auto\n 'toolbar' auto / 1fr;\n padding-bottom: env(safe-area-inset-bottom);\n }\n .root > * {\n min-width: 0;\n min-height: 0;\n }\n sealpixel-stage {\n grid-area: stage;\n min-height: 160px;\n }\n sealpixel-nav {\n grid-area: nav;\n }\n sealpixel-toolbar {\n grid-area: toolbar;\n }\n .panel {\n grid-area: panel;\n background: var(--sealpixel-color-surface);\n border-top: 1px solid var(--sealpixel-color-border);\n padding: var(--sealpixel-space) calc(var(--sealpixel-space) * 1.5);\n /*\n * The configured height, not a fitted one: a bar that grew and shrank\n * as the user moved between tools would resize the stage under them,\n * and the image would shift every time they changed their mind.\n *\n * The exception is a tool whose settings do not fit at all. Then the\n * bar takes the height they need, measured by syncPanelFit(), because\n * the alternative is worse: a fixed-height wrapping flex container has\n * no scrollable cross-axis overflow, so nothing scrolls and the sticky\n * choice row is pulled up over the settings. 34cqh caps both heights,\n * so a busy tool can never take the stage on a short viewport.\n */\n height: min(34cqh, max(var(--sealpixel-panel-size), var(--sealpixel-panel-fit, 0px)));\n overflow: auto;\n /*\n * A bottom bar lays its blocks across the width and wraps, where the\n * old right-hand column stacked them. Stacking five blocks in a bar\n * that is one or two rows tall would push the last of them out of\n * sight, so a block takes a full row only when it asks for one.\n */\n display: flex;\n flex-wrap: wrap;\n /*\n * Safe centring places the blocks in the middle while they fit and\n * at the start once they do not. Plain centring overflows a fixed bar\n * at both ends, and nothing scrolls back to what sits above the top.\n */\n align-items: center;\n align-content: safe center;\n justify-content: safe center;\n gap: var(--sealpixel-space) calc(var(--sealpixel-space) * 2);\n scrollbar-width: thin;\n scroll-behavior: smooth;\n }\n /*\n * A tool whose panel lays out to nothing gets no bar. Without this the\n * fixed height above reserves an empty surface and takes it off the\n * stage; see syncPanelFill(), which sets the attribute.\n */\n .panel[data-empty] {\n height: 0;\n padding: 0;\n border-top: 0;\n overflow: hidden;\n }\n /*\n * A dial needs room to be worth dragging, but it must not grow into all\n * of it: a dial that stretches pushes the controls beside it against the\n * two edges of the bar, and they stop reading as one group.\n */\n .panel > sealpixel-slider {\n flex: 0 1 360px;\n min-width: 240px;\n }\n /* Chips, presets and asset libraries always get their own full row. */\n .panel > .strip,\n .panel > .grid {\n flex: 1 1 100%;\n }\n .panel > .row,\n .panel > .rows,\n .panel > .field,\n .panel > .hint {\n flex: 0 1 auto;\n }\n /*\n * A tool panel has two kinds of control: the choice of what to work with\n * (a shape, a frame style, a preset, a parameter) and the settings for\n * whatever is chosen. The choice belongs at the bottom, next to the tool\n * rail it continues, and its settings appear above it. Side by side they\n * read as one undifferentiated row of buttons and it is not obvious which\n * of them changes what.\n *\n * Ordering here rather than in each tool keeps a panel's source in\n * reading order and lets a third-party tool join in with one class.\n */\n .panel > * {\n order: 1;\n }\n /*\n * Switching tools rebuilds the panel, so the rows rise on the new\n * children and never on a value change inside the open tool, where Lit\n * patches the same nodes.\n *\n * Transform only, deliberately. A fade would put the labels at partial\n * opacity for a moment, and a contrast audit that samples the panel\n * during that moment reports text it can read on screen as failing.\n * Transform also keeps the panel's own height still, which the layout\n * around it is measured against.\n */\n .panel > * {\n animation: sealpixel-panel-in var(--sealpixel-duration) var(--sealpixel-ease-out) both;\n }\n .panel > *:nth-child(2) {\n animation-delay: 25ms;\n }\n .panel > *:nth-child(n + 3) {\n animation-delay: 50ms;\n }\n @keyframes sealpixel-panel-in {\n from {\n transform: translateY(8px);\n }\n }\n /* Phones: option grids become one horizontal strip so the stage keeps its height. */\n .panel .grid,\n .panel .strip {\n display: flex;\n gap: var(--sealpixel-space);\n overflow-x: auto;\n scrollbar-width: none;\n padding-bottom: 2px;\n scroll-snap-type: x proximity;\n }\n .panel .grid::-webkit-scrollbar,\n .panel .strip::-webkit-scrollbar {\n display: none;\n }\n .panel .grid > *,\n .panel .strip > * {\n flex: 0 0 auto;\n min-width: 96px;\n scroll-snap-align: start;\n }\n .panel .strip > * {\n min-width: 0;\n }\n /*\n * The strip centres while it fits and scrolls from the first item once\n * it does not, so a short row of presets is not stranded at the left\n * edge of a wide bar.\n */\n .panel .strip {\n justify-content: safe center;\n align-items: end;\n scroll-behavior: smooth;\n }\n .panel .chips {\n gap: 2px;\n }\n /*\n * A segmented control: one pill holds the row, the segments share it. Six\n * separate buttons put six borders in a row and made the choice look like\n * six unrelated actions; one container says they are one decision with\n * one answer at a time.\n */\n .panel .group {\n display: inline-flex;\n gap: 2px;\n padding: 2px;\n background: var(--sealpixel-color-surface-2);\n border-radius: var(--sealpixel-radius-pill);\n flex: 0 0 auto;\n }\n .panel .group sealpixel-button::part(button) {\n background: transparent;\n border-color: transparent;\n min-height: calc(var(--sealpixel-control-height) - 4px);\n min-width: calc(var(--sealpixel-control-height) - 4px);\n padding: 0 calc(var(--sealpixel-space) * 1.25);\n }\n .panel .group sealpixel-button:hover::part(button) {\n background: color-mix(in srgb, var(--sealpixel-color-fg) 7%, transparent);\n }\n .panel .group sealpixel-button[pressed]::part(button) {\n background: var(--sealpixel-color-surface);\n color: var(--sealpixel-color-accent);\n box-shadow: var(--sealpixel-shadow-sm, none);\n }\n\n /* Filter tiles: the image is the control, the label only names it. */\n .panel .tiles {\n gap: calc(var(--sealpixel-space) * 0.75);\n }\n /*\n * The one control in the bar that gets bigger. Everywhere else the chrome\n * shrank; here the chrome is the point, because a preset is judged by\n * looking at it.\n */\n .panel .thumb {\n display: block;\n width: 100%;\n height: 64px;\n object-fit: cover;\n border-radius: var(--sealpixel-radius);\n background: var(--sealpixel-color-surface-2);\n box-shadow: 0 0 0 1px var(--sealpixel-color-border);\n transition:\n box-shadow var(--sealpixel-duration) var(--sealpixel-ease),\n transform var(--sealpixel-duration) var(--sealpixel-ease-spring);\n }\n .panel .tiles sealpixel-button {\n min-width: 84px;\n max-width: 84px;\n }\n .panel .tiles sealpixel-button::part(button) {\n flex-direction: column;\n gap: 6px;\n padding: 0;\n min-height: 0;\n height: auto;\n font-size: 11px;\n background: transparent;\n color: var(--sealpixel-color-fg-muted);\n }\n .panel .tiles sealpixel-button:hover .thumb {\n transform: translateY(-2px);\n }\n .panel .tiles sealpixel-button[pressed] .thumb {\n box-shadow:\n 0 0 0 2px var(--sealpixel-color-surface),\n 0 0 0 4px var(--sealpixel-color-accent);\n }\n .panel .tiles sealpixel-button[pressed]::part(button) {\n background: transparent;\n border-color: transparent;\n color: var(--sealpixel-color-fg);\n }\n /* Separates the untouched image from the presets. */\n .panel .divider {\n flex: 0 0 auto;\n align-self: stretch;\n width: 1px;\n min-width: 1px;\n margin: 6px calc(var(--sealpixel-space) * 0.5);\n background: var(--sealpixel-color-border);\n opacity: 0.55;\n }\n .panel .row.compact > sealpixel-button {\n flex: 0 0 auto;\n min-width: 72px;\n }\n /* Phones: sibling groups share one line and hints make room for the stage. */\n .panel .rows {\n display: flex;\n gap: var(--sealpixel-space);\n align-items: end;\n }\n /*\n * Content width, not an equal share. An equal share squeezed a text field\n * and a colour well down to a few pixels each and their labels ran into\n * one another; only a dial has a reason to take the leftover room.\n */\n .panel .rows > * {\n flex: 0 1 auto;\n min-width: 0;\n }\n /*\n * A dial needs travel to be worth dragging. Inside a settings row it was\n * sharing the width equally with a colour swatch and a checkbox and ended\n * up a few ticks wide, which is not a control any more. The row grows to\n * give it that width instead of shrinking to its contents.\n */\n /*\n * A settings row scrolls sideways when it is wider than the bar, the way\n * the choice row does. Letting it overflow instead left the last control\n * cut off at the edge with nothing to say it was there.\n */\n .panel > .rows {\n flex: 0 1 auto;\n max-width: 100%;\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: none;\n scroll-behavior: smooth;\n padding-bottom: 1px;\n }\n .panel > .rows::-webkit-scrollbar {\n display: none;\n }\n .panel > .rows > * {\n flex-shrink: 0;\n }\n .panel .rows > sealpixel-slider {\n flex: 0 1 260px;\n min-width: 220px;\n }\n .panel .rows .row {\n flex-wrap: nowrap;\n }\n .panel .rows .row > sealpixel-button {\n flex: 1 1 0;\n min-width: 0;\n }\n /*\n * A field fills its label, but never shrinks to nothing: a text box a\n * few pixels wide hides what was typed into it, and a select that narrow\n * hides which option is chosen.\n */\n .panel .rows select,\n .panel .rows input:not([type='checkbox']):not([type='color']) {\n width: 100%;\n min-width: 7em;\n }\n .panel .rows input[type='text'],\n .panel .rows textarea {\n min-width: 11em;\n }\n .panel .rows > .field:has(input[type='color']),\n .panel .rows > .field.check {\n flex: 0 0 auto;\n }\n /* A colour well is square, which makes the disc round. */\n .panel .rows > .field:has(input[type='color']) input {\n width: var(--sealpixel-control-height);\n aspect-ratio: 1;\n }\n .panel .swatches {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-bottom: 6px;\n }\n .panel .swatch {\n width: 24px;\n height: 24px;\n border-radius: 50%;\n border: 0;\n box-shadow: 0 0 0 1px var(--sealpixel-color-border);\n cursor: pointer;\n padding: 0;\n transition:\n transform var(--sealpixel-duration) var(--sealpixel-ease-spring),\n border-color var(--sealpixel-transition),\n box-shadow var(--sealpixel-duration) var(--sealpixel-ease);\n }\n .panel .swatch:hover {\n transform: scale(1.12);\n }\n .panel .swatch:active {\n transform: scale(0.94);\n }\n /* The ring sits off the disc, so the colour itself is never covered. */\n .panel .swatch[aria-pressed='true'] {\n box-shadow:\n 0 0 0 2px var(--sealpixel-color-surface),\n 0 0 0 3.5px var(--sealpixel-color-accent);\n }\n .panel:empty {\n display: none;\n }\n .toast {\n position: absolute;\n left: 50%;\n bottom: calc(var(--sealpixel-toolbar-size) + var(--sealpixel-space) * 2);\n /* Sits above the stage, never over the bar the user is working in. */\n transform: translateX(-50%);\n display: flex;\n align-items: center;\n gap: var(--sealpixel-space);\n max-width: calc(100% - var(--sealpixel-space) * 4);\n padding: calc(var(--sealpixel-space) * 1.25) calc(var(--sealpixel-space) * 2);\n border-radius: 999px;\n background: color-mix(in srgb, var(--sealpixel-color-surface) 92%, transparent);\n border: 1px solid var(--sealpixel-color-border);\n box-shadow: var(--sealpixel-shadow, 0 8px 24px rgba(0, 0, 0, 0.3));\n color: var(--sealpixel-color-fg);\n font-size: 13px;\n white-space: nowrap;\n backdrop-filter: blur(8px);\n cursor: pointer;\n z-index: 2;\n animation: sealpixel-toast-in var(--sealpixel-duration) var(--sealpixel-ease-out) both;\n }\n .toast:hover {\n border-color: var(--sealpixel-color-fg-muted);\n }\n .toast code {\n font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;\n color: var(--sealpixel-color-fg-muted);\n padding: 2px 8px;\n border-radius: 999px;\n background: var(--sealpixel-color-surface-2);\n }\n @keyframes sealpixel-toast-in {\n from {\n opacity: 0;\n transform: translate(-50%, 12px) scale(0.96);\n }\n }\n /*\n * Wide layouts move the tool rail to the left edge and nothing else. The\n * panel stays a bottom bar at every width, so a control sits in the same\n * place on a phone and on a desktop, and the stage keeps the full width\n * it needs for a landscape image.\n */\n @container (min-width: 48rem) {\n /*\n * The rail runs the full height beside both the stage and the bar.\n * Stopping it above the bar cost it the bar's height, and with ten or\n * more tools the last of them ended up scrolled out of sight behind\n * the settings of the one already open.\n */\n .root {\n grid-template:\n 'nav nav' auto\n 'toolbar stage' 1fr\n 'toolbar panel' auto / var(--sealpixel-toolbar-size) 1fr;\n }\n .panel {\n height: max(var(--sealpixel-panel-size), var(--sealpixel-panel-fit, 0px));\n padding: var(--sealpixel-space) calc(var(--sealpixel-space) * 2);\n }\n .panel[data-empty] {\n height: 0;\n padding: 0;\n }\n .toast {\n bottom: calc(var(--sealpixel-space) * 2);\n }\n }\n .panel .row {\n display: flex;\n gap: var(--sealpixel-space);\n flex-wrap: wrap;\n }\n .panel > .choice {\n order: 2;\n flex: 1 1 100%;\n justify-content: safe center;\n /*\n * Pinned to the foot of the bar. The choice is what gets the user out\n * of the tool they are in, so it has to stay reachable even when a\n * busy panel scrolls its settings.\n */\n position: sticky;\n bottom: 0;\n z-index: 1;\n background: var(--sealpixel-color-surface);\n padding-top: 4px;\n /*\n * One line that scrolls, never two that wrap. A wrapped second line\n * falls below the bar and takes whatever was on it out of reach, and\n * on a phone that was the reset button.\n */\n flex-wrap: nowrap;\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: none;\n scroll-behavior: smooth;\n }\n .panel > .choice::-webkit-scrollbar {\n display: none;\n }\n .panel > .choice > * {\n flex-shrink: 0;\n }\n .panel .field {\n display: grid;\n gap: 3px;\n justify-items: center;\n color: var(--sealpixel-color-fg-muted);\n }\n /* The label names the control; it is not the thing being read. */\n .panel .field > span,\n .panel .field > .lab {\n font-size: 11px;\n letter-spacing: 0.012em;\n line-height: 1.2;\n }\n .panel .hint {\n margin: 0;\n color: var(--sealpixel-color-fg-muted);\n font-size: 12px;\n }\n /*\n * Width and height are one measurement, so they sit against the link that\n * binds them rather than being two fields that happen to be adjacent.\n */\n .panel .dims {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n }\n .panel .dims input[type='number'] {\n width: 5.5em;\n min-width: 0;\n text-align: center;\n font-variant-numeric: tabular-nums;\n appearance: textfield;\n }\n .panel .dims input::-webkit-outer-spin-button,\n .panel .dims input::-webkit-inner-spin-button {\n appearance: none;\n margin: 0;\n }\n /* A value the link worked out, not one that was typed. */\n .panel .dims input.derived {\n color: var(--sealpixel-color-fg-muted);\n font-weight: 400;\n }\n .panel .dims sealpixel-button::part(button) {\n min-width: calc(var(--sealpixel-control-height) - 6px);\n min-height: calc(var(--sealpixel-control-height) - 6px);\n padding: 0;\n background: transparent;\n color: var(--sealpixel-color-fg-muted);\n }\n .panel .dims sealpixel-button[pressed]::part(button) {\n background: var(--sealpixel-color-accent-soft);\n color: var(--sealpixel-color-accent);\n }\n .panel .anchors {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: 4px;\n max-width: 180px;\n }\n .panel .field.check {\n grid-template-columns: auto 1fr;\n align-items: center;\n }\n .panel textarea {\n font: inherit;\n color: var(--sealpixel-color-fg);\n background: var(--sealpixel-color-surface-2);\n border: 1px solid var(--sealpixel-color-border);\n border-radius: var(--sealpixel-radius-sm);\n padding: var(--sealpixel-space);\n resize: vertical;\n }\n /* A colour is a disc, not a box: it shows the colour and nothing else. */\n .panel input[type='color'] {\n /* Without this the engine keeps its own swatch metrics inside the box\n and the disc comes out an ellipse. */\n appearance: none;\n min-height: var(--sealpixel-control-height);\n height: var(--sealpixel-control-height);\n width: var(--sealpixel-control-height);\n padding: 0;\n border: 0;\n border-radius: 50%;\n background: transparent;\n cursor: pointer;\n overflow: hidden;\n }\n /* The swatch has to be told to fill the box; it does not by default. */\n .panel input[type='color']::-webkit-color-swatch-wrapper {\n padding: 0;\n width: 100%;\n height: 100%;\n }\n .panel input[type='color']::-webkit-color-swatch {\n width: 100%;\n height: 100%;\n border: 0;\n border-radius: 50%;\n box-shadow: 0 0 0 1px var(--sealpixel-color-border);\n }\n .panel input[type='color']::-moz-color-swatch {\n width: 100%;\n height: 100%;\n border: 0;\n border-radius: 50%;\n box-shadow: 0 0 0 1px var(--sealpixel-color-border);\n }\n .panel input:not([type='checkbox']):not([type='color']),\n .panel select {\n font: inherit;\n font-size: 13px;\n color: var(--sealpixel-color-fg);\n background: var(--sealpixel-color-surface-2);\n border: 1px solid transparent;\n border-radius: var(--sealpixel-radius-pill);\n min-height: var(--sealpixel-control-height);\n padding: 0 calc(var(--sealpixel-space) * 1.5);\n }\n /*\n * The chevron is drawn rather than left to the platform, so a select sits\n * next to a pill button instead of looking like a form field that walked\n * in from another page. The right padding keeps the text off it.\n */\n .panel select {\n appearance: none;\n padding-right: calc(var(--sealpixel-space) * 3);\n background-image:\n linear-gradient(45deg, transparent 50%, currentColor 50%),\n linear-gradient(135deg, currentColor 50%, transparent 50%);\n background-size: 5px 5px, 5px 5px;\n background-position:\n right 14px top 52%,\n right 10px top 52%;\n background-repeat: no-repeat;\n color: var(--sealpixel-color-fg);\n }\n .empty {\n grid-area: stage;\n display: grid;\n place-content: center;\n gap: var(--sealpixel-space);\n text-align: center;\n color: var(--sealpixel-color-fg-muted);\n padding: var(--sealpixel-space);\n }\n .empty {\n transition:\n background var(--sealpixel-duration) var(--sealpixel-ease),\n color var(--sealpixel-duration) var(--sealpixel-ease);\n }\n .empty.dragover {\n outline: 2px dashed var(--sealpixel-color-accent);\n outline-offset: -8px;\n background: var(--sealpixel-color-accent-soft, transparent);\n color: var(--sealpixel-color-fg);\n }\n .error {\n grid-area: nav;\n align-self: end;\n justify-self: center;\n margin-top: calc(var(--sealpixel-toolbar-size) + 4px);\n z-index: 1;\n padding: 6px 10px;\n border-radius: var(--sealpixel-radius);\n background: var(--sealpixel-color-danger);\n color: white;\n font-size: 12px;\n box-shadow: var(--sealpixel-shadow-raised, none);\n animation: sealpixel-panel-in var(--sealpixel-duration) var(--sealpixel-ease-out) both;\n }\n `,\n ];\n\n static override properties = {\n plugins: { attribute: false },\n pluginOptions: {\n attribute: 'plugin-options',\n converter: jsonAttribute<PluginOptionsMap>('plugin-options'),\n },\n session: { attribute: false },\n renderer: { attribute: false },\n assets: { attribute: false },\n limits: {\n attribute: 'limits',\n converter: jsonAttribute<NonNullable<SessionOptions['limits']>>('limits'),\n },\n src: { attribute: false },\n editLog: { attribute: false },\n defaultEditLog: { attribute: false },\n output: { attribute: false },\n theme: { type: String, reflect: true },\n locale: { type: String },\n dictionary: { attribute: false },\n tools: { attribute: false },\n activeTool: { type: String, attribute: 'active-tool' },\n showExport: { type: String, attribute: 'show-export' },\n showDownload: { type: String, attribute: 'show-download' },\n showHistory: { type: String, attribute: 'show-history' },\n downloadLabel: { type: String, attribute: 'download-label' },\n _busy: { state: true },\n _processListeners: { state: true },\n _toast: { state: true },\n _dragover: { state: true },\n _wide: { state: true },\n _pluginTools: { state: true },\n };\n\n declare plugins: readonly AnyPlugin[] | null;\n /** `{ pluginId: partialOptions }` applied to `plugins` (or the defaults) through each plugin's `configure()`. */\n declare pluginOptions: PluginOptionsMap | null;\n declare session: EditorSession | null;\n declare renderer: Renderer | null;\n /** Fonts and images. Defaults to a fetch resolver over the plugins' declarations. */\n declare assets: AssetResolver | null;\n /**\n * How much of the original stays in the browser; `SessionOptions['limits']`\n * (JSON in the attribute). Above `maxClientMegapixels` (16 by default) the\n * image is not resident: Export and Download are disabled, and the host\n * renders the original outside the browser.\n */\n declare limits: SessionOptions['limits'] | null;\n declare src: EditorSource | null;\n /** Controlled mode: the host owns the log. */\n declare editLog: unknown;\n /** Uncontrolled: applied once on load. */\n declare defaultEditLog: unknown;\n declare output: OutputOptions;\n declare theme: 'dark' | 'light' | 'auto';\n declare locale: string;\n /** Overrides the shipped dictionary for `locale`; shipped locales resolve automatically. */\n declare dictionary: Dictionary | null;\n declare tools: Record<string, UiTool> | null;\n declare activeTool: string | null;\n /**\n * When the Export button is shown. `auto` (default) shows it only while a\n * `sealpixel:process` listener is attached, because Export hands the result to\n * the host and does nothing visible otherwise. Download is always shown.\n */\n declare showExport: 'auto' | 'always' | 'never';\n /** `always` (default) or `never`. Hosts that only consume `sealpixel:process` hide the button. */\n declare showDownload: 'always' | 'never';\n /** `all` (default), `buttons` (undo and redo, no timeline) or `none` (also disables the undo/redo shortcuts). */\n declare showHistory: 'all' | 'buttons' | 'none';\n /** Custom text for the Download button; the localized label when null. */\n declare downloadLabel: string | null;\n declare _busy: boolean;\n declare _processListeners: number;\n declare _toast: { text: string; hash: string } | null;\n declare _dragover: boolean;\n declare _wide: boolean;\n /** Tools loaded from `plugin.tool()`, keyed by plugin id. */\n declare _pluginTools: Record<string, UiTool>;\n private resizeObserver: ResizeObserver | null = null;\n private toolLoads = new Set<string>();\n\n /**\n * Used when no `renderer` property is set. `@sealpixel/element` installs a\n * factory that starts the bundled worker; without it the editor renders inline.\n */\n static defaultRendererFactory: ((plugins: readonly AnyPlugin[]) => Renderer) | null = null;\n\n private readonly ctl = new SessionController(this, null);\n private i18n: I18n = createI18n('en');\n private ownsSession = false;\n private lastEmittedVersion = -1;\n private lastAppliedControlled = '';\n private hint: { filter?: string; transform?: string; rotate?: number } | null = null;\n private previousTool: UiTool | null = null;\n /** The source the tools last heard about; `load` replaces the object, so identity is the guard. */\n private lastSource: SourceDescriptor | null = null;\n private loadedSrc: EditorSource | null = null;\n /** The edit log of a session released while the element was out of the document. */\n private detachedLog: { log: unknown; index: number } | null = null;\n /** Whether the owned session was released while the element was out of the document. */\n private released = false;\n\n constructor() {\n super();\n this.plugins = null;\n this.pluginOptions = null;\n this.session = null;\n this.renderer = null;\n this.assets = null;\n this.limits = null;\n this.src = null;\n this.editLog = undefined;\n this.defaultEditLog = undefined;\n this.output = { format: 'image/png' };\n this.theme = 'dark';\n this.locale = 'en';\n this.dictionary = null;\n this.tools = null;\n this.activeTool = null;\n this.showExport = 'auto';\n this.showDownload = 'always';\n this.showHistory = 'all';\n this.downloadLabel = null;\n this._busy = false;\n this._processListeners = 0;\n this._toast = null;\n this._dragover = false;\n this._wide = false;\n this._pluginTools = {};\n }\n\n // Export hands the result to the host, so the button is shown only while\n // someone listens for `sealpixel:process`. Listener counts are tracked here.\n override addEventListener<K extends keyof HTMLElementEventMap>(\n type: K,\n listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown,\n options?: boolean | AddEventListenerOptions,\n ): void;\n override addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void;\n override addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | ((ev: Event) => unknown),\n options?: boolean | AddEventListenerOptions,\n ): void {\n super.addEventListener(type, listener as EventListenerOrEventListenerObject, options);\n if (type === 'sealpixel:process') this._processListeners += 1;\n }\n\n override removeEventListener<K extends keyof HTMLElementEventMap>(\n type: K,\n listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown,\n options?: boolean | EventListenerOptions,\n ): void;\n override removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n override removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | ((ev: Event) => unknown),\n options?: boolean | EventListenerOptions,\n ): void {\n super.removeEventListener(type, listener as EventListenerOrEventListenerObject, options);\n if (type === 'sealpixel:process' && this._processListeners > 0) this._processListeners -= 1;\n }\n\n /** A renderer the editor made through the factory dies with the session; a host's renderer lives on. */\n private disposeOwnedRenderer(): void {\n if (this.sessionRenderer && this.sessionRenderer !== this.renderer) {\n this.sessionRenderer.dispose();\n }\n this.sessionRenderer = null;\n }\n\n /** `plugins` (or the defaults) with `pluginOptions` applied. Invalid options raise `sealpixel:error`. */\n private effectivePlugins(): readonly AnyPlugin[] {\n const base = this.plugins ?? defaultPlugins;\n if (!this.pluginOptions) return base;\n try {\n return configurePlugins(base, this.pluginOptions);\n } catch (error) {\n this.dispatchEvent(\n new CustomEvent('sealpixel:error', { detail: error, bubbles: true, composed: true }),\n );\n return base;\n }\n }\n\n /** The live session, created on first connection when none was passed. */\n getSession(): EditorSession {\n if (!this.ctl.session) this.ensureSession();\n return this.ctl.session as EditorSession;\n }\n getEditLog() {\n return this.getSession().getEditLog();\n }\n setEditLog(saved: unknown, index?: number) {\n this.getSession().setEditLog(saved, index);\n }\n undo() {\n this.getSession().undo();\n }\n redo() {\n this.getSession().redo();\n }\n timeTravel(index: number) {\n this.getSession().timeTravel(index);\n }\n async export(output: OutputOptions = this.output, options: { embedEditLog?: boolean } = {}) {\n return this.getSession().export({ output, ...options });\n }\n async download(\n options: { output?: OutputOptions; filename?: string; embedEditLog?: boolean } = {},\n ) {\n return this.getSession().download({ output: this.output, ...options });\n }\n\n private ensureSession(): void {\n if (this.ctl.session) return;\n if (this.session) {\n this.ctl.session = this.session;\n return;\n }\n const plugins = this.effectivePlugins();\n const renderer = this.renderer ?? SealpixelEditor.defaultRendererFactory?.(plugins) ?? null;\n this.sessionRenderer = renderer;\n const assets =\n this.assets ?? createAssetResolver({ assets: plugins.flatMap((p) => p.assets ?? []) });\n this.sessionAssets = this.assets;\n this.sessionLimits = this.limits;\n const session = createEditorSession({\n plugins,\n assets,\n ...(renderer ? { renderer } : {}),\n ...(this.limits ? { limits: this.limits } : {}),\n });\n this.ownsSession = true;\n this.ctl.session = session;\n this.dispatchEvent(new CustomEvent('sealpixel:ready', { bubbles: true, composed: true }));\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.ensureSession();\n // Out of the document long enough to lose the session: the source comes\n // back with the edit log it had when it left.\n if (this.released) {\n const restore = this.detachedLog ?? undefined;\n this.released = false;\n this.detachedLog = null;\n if (this.loadedSrc) void this.loadSource(this.loadedSrc, restore);\n }\n // Keyboard shortcuts need focus inside the editor. WebKit does not focus\n // buttons on click, so pull focus in on any pointer interaction.\n if (!this.hasAttribute('tabindex')) this.tabIndex = -1;\n this.addEventListener('keydown', this.onKeydown);\n this.addEventListener('pointerdown', this.onPointerDown);\n this.resizeObserver = new ResizeObserver((entries) => {\n const width = entries[0]?.contentRect.width ?? this.clientWidth;\n this._wide = width >= 768;\n });\n this.resizeObserver.observe(this);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.removeEventListener('keydown', this.onKeydown);\n this.removeEventListener('pointerdown', this.onPointerDown);\n this.resizeObserver?.disconnect();\n // A move in the DOM (an append into another parent, a portal, a keyed\n // reorder) disconnects and connects again in the same task. Disposing here\n // would throw the image and its history away on every move, so the\n // session goes only if the element is still out after the task.\n if (this.ownsSession) {\n queueMicrotask(() => {\n if (!this.isConnected) this.releaseSession();\n });\n }\n }\n\n /** Disposes the owned session and keeps its edit log for a later connection. */\n private releaseSession(): void {\n const session = this.ctl.session;\n if (!this.ownsSession || !session) return;\n this.released = true;\n this.detachedLog = session.getState().status === 'ready' ? session.getEditLog() : null;\n session.dispose();\n this.disposeOwnedRenderer();\n this.ctl.session = null;\n this.ownsSession = false;\n this.lastEmittedVersion = -1;\n this.lastSource = null;\n // The tools activate again on the session that replaces this one.\n this.previousTool = null;\n }\n\n override willUpdate(changed: Map<string, unknown>): void {\n if (changed.has('locale') || changed.has('dictionary')) {\n // A dictionary changes the strings it names; every other string stays\n // in the shipped locale.\n this.i18n = createI18n(this.locale, {\n ...resolveLocale(this.locale),\n ...(this.dictionary ?? {}),\n });\n }\n if (changed.has('session') && this.session && this.session !== this.ctl.session) {\n if (this.ownsSession) {\n this.ctl.session?.dispose();\n this.disposeOwnedRenderer();\n }\n this.ownsSession = false;\n this.ctl.session = this.session;\n }\n // A new plugin list or renderer needs a new session; reload the current source into it.\n if (\n (changed.has('plugins') ||\n changed.has('pluginOptions') ||\n changed.has('renderer') ||\n changed.has('assets') ||\n changed.has('limits')) &&\n this.ownsSession &&\n !this.sessionMatchesProps()\n ) {\n this.ctl.session?.dispose();\n this.disposeOwnedRenderer();\n this.ctl.session = null;\n this.ownsSession = false;\n this.toolLoads.clear();\n this._pluginTools = {};\n this.lastEmittedVersion = -1;\n this.lastSource = null;\n this.ensureSession();\n if (this.loadedSrc) void this.loadSource(this.loadedSrc);\n }\n if (changed.has('src') && this.src && this.src !== this.loadedSrc) {\n this.loadedSrc = this.src;\n void this.loadSource(this.src);\n }\n if (changed.has('editLog') && this.editLog != null) this.applyControlled();\n }\n\n override updated(): void {\n const state = this.ctl.state;\n const session = this.ctl.session;\n if (!state || !session) return;\n if (state.version !== this.lastEmittedVersion && state.status === 'ready') {\n this.lastEmittedVersion = state.version;\n const detail = session.getEditLog();\n this.lastAppliedControlled = canonicalJson(detail);\n this.dispatchEvent(\n new CustomEvent('sealpixel:change', { detail, bubbles: true, composed: true }),\n );\n }\n if (state.error && state.error !== this.lastError) {\n this.lastError = state.error;\n this.dispatchEvent(\n new CustomEvent('sealpixel:error', { detail: state.error, bubbles: true, composed: true }),\n );\n }\n this.syncActiveTool();\n this.syncSource(state);\n this.syncPanelFill();\n }\n private lastError: unknown = null;\n\n /** Tells every tool, active or not, that a new source has loaded. Once per source. */\n private syncSource(state: SessionState): void {\n if (state.status !== 'ready' || !state.source || state.source === this.lastSource) return;\n this.lastSource = state.source;\n const ctx = this.toolContext(state);\n for (const tool of this.currentTools()) tool.onSource?.(ctx);\n }\n\n /**\n * Collapses the settings bar when the open tool has nothing to put in it.\n *\n * A tool renders its own structure, and a structure can hold nothing: crop\n * with `rotation`, `flip` and `reset` off and a single enforced aspect emits\n * two empty wrappers. The bar is a fixed height on purpose — see `.panel` —\n * so that reserved an empty bordered surface and took the same height off\n * the stage. On the landing page's avatar card that was 240 px of nothing\n * against a 178 px stage, and the photo rendered at 10 percent.\n *\n * Read from the DOM rather than asked of the tool: every tool would\n * otherwise have to declare it, and a tool whose panel empties out only\n * under some options would get it wrong.\n *\n * Not measured by size either. The empty wrappers still lay out — the row\n * is 8px from its own gap and the group 4px from its border — so a\n * bounding box tells content and scaffolding apart not at all. What counts\n * is a control or a word: a custom element, a form control, or any text.\n */\n private syncPanelFill(): void {\n const panel = this.renderRoot.querySelector('.panel') as HTMLElement | null;\n if (!panel) return;\n const filled =\n (panel.textContent ?? '').trim().length > 0 ||\n Array.from(panel.querySelectorAll('*')).some(\n (node) => node.tagName.includes('-') || node.matches(PANEL_CONTENT),\n );\n panel.toggleAttribute('data-empty', !filled);\n this.syncPanelFit(panel, filled);\n }\n\n /**\n * Lets the settings bar grow to the height its content needs.\n *\n * The bar is a fixed height so that moving between tools does not resize\n * the stage under the user. When a tool needs more than that height, the\n * overflow has nowhere to go: a wrapping flex container of fixed height has\n * no scrollable cross-axis overflow, so `overflow: auto` never produces a\n * scrollbar, and the sticky choice row — which pins itself inside the\n * scrollport — is dragged up over the settings instead. The colour swatch\n * ends up half covered and the fill toggle disappears behind the shapes.\n *\n * WebKit is where this surfaced, on a real iPhone: it lays these controls\n * taller than Blink does, and at phone width crop, finetune and annotate\n * needed 138, 140 and 136 pixels against the 112 the bar had. Raising the\n * default would have taken those pixels off every stage in every engine, so\n * the height is measured instead and only the bar that needs more gets it.\n * `34cqh` still caps it, so a busy tool cannot eat the stage.\n */\n private syncPanelFit(panel: HTMLElement, filled: boolean): void {\n panel.style.removeProperty('--sealpixel-panel-fit');\n if (!filled) return;\n // Read after the reset, so a bar that has since shrunk measures its own\n // content and not the height it was given last time.\n const needed = panel.scrollHeight;\n if (needed > panel.clientHeight) {\n panel.style.setProperty('--sealpixel-panel-fit', `${needed}px`);\n }\n }\n\n private async loadSource(src: EditorSource, restore?: unknown): Promise<void> {\n const session = this.getSession();\n try {\n // `null` is \"no saved log\", the same as `undefined`: framework props\n // commonly type an absent log as null.\n const saved = this.editLog ?? restore ?? this.defaultEditLog ?? undefined;\n const bytes = src instanceof Uint8Array ? src : src;\n const descriptor = await session.load(bytes, saved === undefined ? {} : { editLog: saved });\n // Option defaults become real ops in an otherwise empty log.\n if (saved === undefined && session.getState().history.log.ops.length === 0) {\n for (const op of session.registry.initialOps(descriptor)) {\n session.dispatch({\n ...op,\n id: `init-${Math.random().toString(36).slice(2, 8)}`,\n } as Parameters<typeof session.dispatch>[0]);\n }\n }\n this.dispatchEvent(\n new CustomEvent('sealpixel:load', { detail: descriptor, bubbles: true, composed: true }),\n );\n if (!this.activeTool) {\n const first = this.currentTools()[0];\n if (first) this.activeTool = first.id;\n }\n } catch (error) {\n // A newer `src` replaced this load. That load reports its own outcome.\n if ((error as Error | null)?.name === 'ABORTED') return;\n this.dispatchEvent(\n new CustomEvent('sealpixel:error', { detail: error, bubbles: true, composed: true }),\n );\n }\n }\n\n private applyControlled(): void {\n const session = this.ctl.session;\n if (!session || session.getState().status !== 'ready' || this.editLog == null) return;\n const wanted = this.editLog as { log?: unknown; index?: number };\n const key = canonicalJson(wanted);\n if (key === this.lastAppliedControlled) return;\n try {\n session.setEditLog(wanted, wanted.index);\n this.lastAppliedControlled = key;\n } catch (error) {\n this.dispatchEvent(\n new CustomEvent('sealpixel:error', { detail: error, bubbles: true, composed: true }),\n );\n }\n }\n\n /** Whether the owned session was built from the current `plugins`, `renderer`, `assets` and `limits`. */\n private sessionMatchesProps(): boolean {\n const session = this.ctl.session;\n if (!session) return false;\n if (this.renderer && this.renderer !== this.sessionRenderer) return false;\n if (this.assets && this.assets !== this.sessionAssets) return false;\n if (canonicalJson(this.limits ?? null) !== canonicalJson(this.sessionLimits ?? null))\n return false;\n // Compare id, version and resolved options (options JSON may contain commas, so no string splitting).\n const key = (plugins: readonly AnyPlugin[]) =>\n canonicalJson(\n [...plugins]\n .sort((a, b) => a.id.localeCompare(b.id))\n .map((p) => [p.id, p.version, p.options ?? null]),\n );\n return key(this.effectivePlugins()) === key(session.registry.plugins);\n }\n private sessionRenderer: Renderer | null = null;\n private sessionAssets: AssetResolver | null = null;\n private sessionLimits: SessionOptions['limits'] | null = null;\n\n private currentTools(): UiTool[] {\n const plugins = this.effectivePlugins();\n this.loadPluginTools(plugins);\n return toolsFor(plugins, { ...this._pluginTools, ...(this.tools ?? {}) });\n }\n\n /** Plugins may ship their own tool; load each once and re-render when it arrives. */\n private loadPluginTools(plugins: readonly AnyPlugin[]): void {\n for (const plugin of plugins) {\n if (!plugin.tool || this.toolLoads.has(plugin.id)) continue;\n this.toolLoads.add(plugin.id);\n plugin\n .tool()\n .then((tool) => {\n this._pluginTools = { ...this._pluginTools, [plugin.id]: tool as unknown as UiTool };\n })\n .catch((error) => {\n this.dispatchEvent(\n new CustomEvent('sealpixel:error', { detail: error, bubbles: true, composed: true }),\n );\n });\n }\n }\n\n private get stage(): SealpixelStage | null {\n return this.renderRoot.querySelector('sealpixel-stage');\n }\n\n private toolContext(state: SessionState): UiToolContext {\n const session = this.getSession();\n const stage = this.stage;\n return {\n session,\n state,\n document: state.document,\n dispatch: (op) => {\n try {\n session.dispatch(op);\n } catch (error) {\n // A tool asked for something the options forbid: tell the user, keep the log intact.\n if (error instanceof SealpixelError && error.name === 'OPTION_VIOLATION') {\n this._toast = { text: error.message, hash: '' };\n this.announce(error.message);\n return;\n }\n throw error;\n }\n },\n t: this.i18n.t,\n stage: {\n width: state.preview?.image.width ?? 0,\n height: state.preview?.image.height ?? 0,\n zoom: stage?.zoom ?? 1,\n geometry: state.preview?.geometry ?? null,\n toImage: (x, y) => stage?.toImage(x, y) ?? { x: 0, y: 0 },\n },\n hint: (hint) => {\n this.hint = hint;\n const s = this.stage;\n if (s) {\n s.hintFilter = hint?.filter ?? '';\n s.hintTransform = hint?.transform ?? '';\n s.hintRotate = hint?.rotate ?? 0;\n }\n },\n refresh: () => this.requestUpdate(),\n animateNextView: () => this.stage?.glideNextView(),\n clipPreview: (clip) => {\n const s = this.stage;\n if (s) s.clip = clip ?? '';\n },\n layout: this._wide ? 'wide' : 'narrow',\n options: <T>(pluginId: string) =>\n session.registry.byId.get(pluginId)?.options as T | undefined,\n };\n }\n\n private syncActiveTool(): void {\n const state = this.ctl.state;\n if (!state || state.status !== 'ready') return;\n const tool = this.currentTools().find((t) => t.id === this.activeTool) ?? null;\n if (tool === this.previousTool) return;\n const ctx = this.toolContext(state);\n this.previousTool?.deactivate?.(ctx);\n tool?.activate?.(ctx);\n this.previousTool = tool;\n }\n\n private onPointerDown = () => {\n if (!this.matches(':focus-within')) this.focus({ preventScroll: true });\n };\n\n private onKeydown = (e: KeyboardEvent) => {\n const session = this.ctl.session;\n if (!session || session.getState().status !== 'ready') return;\n // Undo inside a text field belongs to the field: it takes back the typing,\n // not the last edit of the image.\n if (isTextEntry(e.composedPath()[0])) return;\n const mod = e.metaKey || e.ctrlKey;\n if (this.showHistory === 'none') return;\n if (mod && e.key.toLowerCase() === 'z') {\n e.preventDefault();\n if (e.shiftKey) session.redo();\n else session.undo();\n } else if (mod && e.key.toLowerCase() === 'y') {\n e.preventDefault();\n session.redo();\n }\n };\n\n private async onExport(): Promise<void> {\n const session = this.getSession();\n this._busy = true;\n try {\n const result: ExportResult = await session.export({ output: this.output });\n this.dispatchEvent(\n new CustomEvent('sealpixel:process', { detail: result, bubbles: true, composed: true }),\n );\n this.toast('toast.exported', result);\n } catch (error) {\n this.dispatchEvent(\n new CustomEvent('sealpixel:error', { detail: error, bubbles: true, composed: true }),\n );\n } finally {\n this._busy = false;\n }\n }\n\n private async onDownload(): Promise<void> {\n const session = this.getSession();\n this._busy = true;\n try {\n const { result } = await session.download({ output: this.output });\n this.dispatchEvent(\n new CustomEvent('sealpixel:process', { detail: result, bubbles: true, composed: true }),\n );\n this.toast('toast.downloaded', result);\n } catch (error) {\n this.dispatchEvent(\n new CustomEvent('sealpixel:error', { detail: error, bubbles: true, composed: true }),\n );\n } finally {\n this._busy = false;\n }\n }\n\n private announce(text: string): void {\n const live = this.renderRoot.querySelector('#live');\n if (live) live.textContent = text;\n }\n\n private toastTimer: ReturnType<typeof setTimeout> | null = null;\n\n /** Brief confirmation over the stage: format, size and hash of the result. */\n private toast(\n key: 'toast.exported' | 'toast.downloaded',\n result: Pick<ExportResult, 'mimeType' | 'width' | 'height' | 'hash' | 'bytes'>,\n ): void {\n const format = result.mimeType.replace('image/', '').toUpperCase();\n const size = formatBytes(result.bytes.byteLength);\n const text = this.i18n.t(key, { format, width: result.width, height: result.height, size });\n this._toast = { text, hash: result.hash.slice(0, 12) };\n this.announce(text);\n if (this.toastTimer) clearTimeout(this.toastTimer);\n this.toastTimer = setTimeout(() => {\n this._toast = null;\n this.toastTimer = null;\n }, 5000);\n }\n\n private onFiles(files: FileList | null): void {\n const file = files?.[0];\n if (file) this.src = file;\n }\n\n override render() {\n const state = this.ctl.state;\n const tools = this.currentTools();\n const tool = tools.find((t) => t.id === this.activeTool) ?? null;\n const ready = state?.status === 'ready';\n const ctx = state && ready ? this.toolContext(state) : null;\n const badges: Record<string, number> = {};\n if (ctx) {\n for (const t of tools) {\n const n = t.badge?.(ctx);\n if (n) badges[t.id] = n;\n }\n }\n const wide = this._wide;\n return html`\n <div class=\"root\" part=\"root\">\n <sealpixel-nav\n part=\"nav\"\n exportparts=\"undo, redo, history, export, download, dimensions, button\"\n .state=${state}\n .t=${this.i18n.t}\n .busy=${this._busy}\n .canExport=${state?.resident ?? false}\n .showExport=${this.showExport === 'always' || (this.showExport === 'auto' && this._processListeners > 0)}\n .showDownload=${this.showDownload !== 'never'}\n .showHistory=${this.showHistory}\n .downloadLabel=${this.downloadLabel}\n @nav-undo=${() => this.getSession().undo()}\n @nav-redo=${() => this.getSession().redo()}\n @nav-time-travel=${(e: CustomEvent<number>) => this.getSession().timeTravel(e.detail)}\n @nav-export=${() => this.onExport()}\n @nav-download=${() => this.onDownload()}\n ></sealpixel-nav>\n ${\n ready\n ? html`<sealpixel-stage\n part=\"stage\"\n exportparts=\"viewport, canvas, overlay, status\"\n .preview=${state?.preview ?? null}\n .t=${this.i18n.t}\n .pending=${state?.previewPending ?? false}\n .overlay=${ctx && tool?.overlay ? tool.overlay(ctx) : null}\n @stage-view=${() => this.requestUpdate()}\n ></sealpixel-stage>`\n : this.renderEmpty(state)\n }\n <div class=\"panel\" part=\"panel\">${ctx && tool ? tool.panel(ctx) : nothing}</div>\n <sealpixel-toolbar\n part=\"toolbar\"\n exportparts=\"tool, badge\"\n .tools=${tools}\n .badges=${badges}\n .active=${this.activeTool}\n .t=${this.i18n.t}\n .orientation=${wide ? 'vertical' : 'horizontal'}\n @tool-select=${(e: CustomEvent<string>) => {\n this.activeTool = e.detail;\n }}\n ></sealpixel-toolbar>\n ${state?.error ? html`<div class=\"error\" role=\"alert\">${this.i18n.t('editor.error', { message: state.error.message })}</div>` : nothing}\n ${\n this._toast\n ? html`<div class=\"toast\" part=\"toast\" data-testid=\"toast\" @click=${() => {\n this._toast = null;\n }}>\n <span>${this._toast.text}</span>\n ${this._toast.hash ? html`<code>${this._toast.hash}</code>` : nothing}\n </div>`\n : nothing\n }\n <span id=\"live\" class=\"visually-hidden\" role=\"status\" aria-live=\"polite\"></span>\n </div>\n `;\n }\n\n private renderEmpty(state: SessionState | null): TemplateResult {\n if (state?.status === 'loading') {\n return html`<div class=\"empty\" part=\"empty\" role=\"status\">${this.i18n.t('editor.loading')}</div>`;\n }\n return html`<div\n class=\"empty ${this._dragover ? 'dragover' : ''}\"\n part=\"empty\"\n @dragover=${(e: DragEvent) => {\n e.preventDefault();\n this._dragover = true;\n }}\n @dragleave=${() => {\n this._dragover = false;\n }}\n @drop=${(e: DragEvent) => {\n e.preventDefault();\n this._dragover = false;\n this.onFiles(e.dataTransfer?.files ?? null);\n }}\n >\n <p>${this.i18n.t('editor.empty')}</p>\n <label>\n <input class=\"visually-hidden\" type=\"file\" accept=\"image/png,image/jpeg,image/webp\" @change=${(e: Event) => this.onFiles((e.target as HTMLInputElement).files)} />\n <sealpixel-button variant=\"primary\" @click=${(e: Event) => ((e.currentTarget as HTMLElement).previousElementSibling as HTMLInputElement).click()}>\n ${this.i18n.t('editor.choose')}\n </sealpixel-button>\n </label>\n </div>`;\n }\n}\n\n/** Input types that hold no text, so Cmd/Ctrl+Z on them has nothing of their own to undo. */\nconst NON_TEXT_INPUTS = new Set([\n 'button',\n 'checkbox',\n 'color',\n 'file',\n 'image',\n 'radio',\n 'range',\n 'reset',\n 'submit',\n]);\n\nfunction isTextEntry(target: EventTarget | undefined): boolean {\n if (!(target instanceof HTMLElement)) return false;\n if (target.isContentEditable || target instanceof HTMLTextAreaElement) return true;\n return target instanceof HTMLInputElement && !NON_TEXT_INPUTS.has(target.type);\n}\n\nfunction formatBytes(n: number): string {\n if (n < 1024) return `${n} B`;\n if (n < 1024 * 1024) return `${(n / 1024).toFixed(n < 10240 ? 1 : 0)} KB`;\n return `${(n / (1024 * 1024)).toFixed(1)} MB`;\n}\n"]}
1
+ {"version":3,"file":"sealpixel-editor.js","sourceRoot":"","sources":["../../src/components/sealpixel-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EAMnB,cAAc,GAIf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,UAAU,EAA8B,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAK7C,gEAAgE;AAChE,SAAS,aAAa,CAAmB,IAAY;IACnD,OAAO;QACL,aAAa,EAAE,CAAC,KAAoB,EAAE,EAAE;YACtC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;gBAAE,OAAO,IAAI,CAAC;YACvD,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM,CAAC;YAChC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,CAAC,IAAI,CAAC,eAAe,IAAI,oBAAoB,CAAC,CAAC;gBACtD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,WAAW,EAAE,CAAC,KAAe,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC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G7B,CAAC;IACV,CAAC;;AAGH,6FAA6F;AAC7F,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,QAAQ;IACR,UAAU;IACV,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,QAAQ;CACT,CAAC,CAAC;AAEH,SAAS,WAAW,CAAC,MAA+B;IAClD,IAAI,CAAC,CAAC,MAAM,YAAY,WAAW,CAAC;QAAE,OAAO,KAAK,CAAC;IACnD,IAAI,MAAM,CAAC,iBAAiB,IAAI,MAAM,YAAY,mBAAmB;QAAE,OAAO,IAAI,CAAC;IACnF,OAAO,MAAM,YAAY,gBAAgB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,WAAW,CAAC,CAAS;IAC5B,IAAI,CAAC,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,IAAI,CAAC;IAC9B,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1E,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AAChD,CAAC","sourcesContent":["import {\n type AnyPlugin,\n type AssetResolver,\n canonicalJson,\n configurePlugins,\n createAssetResolver,\n createEditorSession,\n type EditorSession,\n type ExportResult,\n type OutputOptions,\n type PluginOptionsMap,\n type Renderer,\n SealpixelError,\n type SessionOptions,\n type SessionState,\n type SourceDescriptor,\n} from '@sealpixel/core';\nimport { defaultPlugins } from '@sealpixel/plugins';\nimport { css, html, LitElement, nothing, type TemplateResult } from 'lit';\nimport { SessionController } from '../controllers/session-controller.js';\nimport { createI18n, type Dictionary, type I18n } from '../i18n.js';\nimport { resolveLocale } from '../locales/index.js';\nimport { base, tokens } from '../theme.js';\nimport type { UiTool, UiToolContext } from '../tool.js';\nimport { toolsFor } from '../tools/index.js';\nimport type { SealpixelStage } from './sealpixel-stage.js';\n\nexport type EditorSource = File | Blob | Uint8Array | string;\n\n/** `plugin-options='{\"filter\":{...}}'` attribute ↔ property. */\nfunction jsonAttribute<T extends object>(name: string) {\n return {\n fromAttribute: (value: string | null) => {\n if (value === null || value.trim() === '') return null;\n try {\n return JSON.parse(value) as T;\n } catch {\n console.warn(`[sealpixel] ${name} is not valid JSON`);\n return null;\n }\n },\n toAttribute: (value: T | null) => (value ? JSON.stringify(value) : null),\n };\n}\n\n/**\n * The default editor. Headless `EditorSession` underneath; this element adds\n * the responsive shell, tools and events.\n *\n * Events: `sealpixel:ready`, `sealpixel:load`, `sealpixel:change` ({ log, index }),\n * `sealpixel:process` (ExportResult), `sealpixel:error` (SealpixelError).\n */\n/**\n * What makes a settings bar worth its height: a control, or anything that\n * draws. Plain `div`s are the tools' own scaffolding and never count.\n */\nconst PANEL_CONTENT = 'select, input, textarea, button, img, svg, canvas, a, [role]';\n\nexport class SealpixelEditor extends LitElement {\n static override styles = [\n tokens,\n base,\n css`\n :host {\n display: block;\n container-type: inline-size;\n background: var(--sealpixel-color-bg);\n color: var(--sealpixel-color-fg);\n height: 100%;\n min-height: 480px;\n min-width: 0;\n overflow: hidden;\n }\n :host(:focus) {\n outline: none;\n }\n .root {\n position: relative;\n display: grid;\n height: 100%;\n min-width: 0;\n grid-template:\n 'nav' auto\n 'stage' 1fr\n 'panel' auto\n 'toolbar' auto / 1fr;\n padding-bottom: env(safe-area-inset-bottom);\n }\n .root > * {\n min-width: 0;\n min-height: 0;\n }\n sealpixel-stage {\n grid-area: stage;\n min-height: 160px;\n }\n sealpixel-nav {\n grid-area: nav;\n }\n sealpixel-toolbar {\n grid-area: toolbar;\n }\n .panel {\n grid-area: panel;\n background: var(--sealpixel-color-surface);\n border-top: 1px solid var(--sealpixel-color-border);\n padding: var(--sealpixel-space) calc(var(--sealpixel-space) * 1.5);\n /*\n * The configured height, not a fitted one: a bar that grew and shrank\n * as the user moved between tools would resize the stage under them,\n * and the image would shift every time they changed their mind.\n *\n * The exception is a tool whose settings do not fit at all. Then the\n * bar takes the height they need, measured by syncPanelFit(), because\n * the alternative is worse: a fixed-height wrapping flex container has\n * no scrollable cross-axis overflow, so nothing scrolls and the sticky\n * choice row is pulled up over the settings. 34cqh caps both heights,\n * so a busy tool can never take the stage on a short viewport.\n */\n height: min(34cqh, max(var(--sealpixel-panel-size), var(--sealpixel-panel-fit, 0px)));\n overflow: auto;\n /*\n * A bottom bar lays its blocks across the width and wraps, where the\n * old right-hand column stacked them. Stacking five blocks in a bar\n * that is one or two rows tall would push the last of them out of\n * sight, so a block takes a full row only when it asks for one.\n */\n display: flex;\n flex-wrap: wrap;\n /*\n * Safe centring places the blocks in the middle while they fit and\n * at the start once they do not. Plain centring overflows a fixed bar\n * at both ends, and nothing scrolls back to what sits above the top.\n */\n align-items: center;\n align-content: safe center;\n justify-content: safe center;\n gap: var(--sealpixel-space) calc(var(--sealpixel-space) * 2);\n scrollbar-width: thin;\n scroll-behavior: smooth;\n }\n /*\n * A tool whose panel lays out to nothing gets no bar. Without this the\n * fixed height above reserves an empty surface and takes it off the\n * stage; see syncPanelFill(), which sets the attribute.\n */\n .panel[data-empty] {\n height: 0;\n padding: 0;\n border-top: 0;\n overflow: hidden;\n }\n /*\n * A dial needs room to be worth dragging, but it must not grow into all\n * of it: a dial that stretches pushes the controls beside it against the\n * two edges of the bar, and they stop reading as one group.\n */\n .panel > sealpixel-slider {\n flex: 0 1 360px;\n min-width: 240px;\n }\n /* Chips, presets and asset libraries always get their own full row. */\n .panel > .strip,\n .panel > .grid {\n flex: 1 1 100%;\n }\n .panel > .row,\n .panel > .rows,\n .panel > .field,\n .panel > .hint {\n flex: 0 1 auto;\n }\n /*\n * A tool panel has two kinds of control: the choice of what to work with\n * (a shape, a frame style, a preset, a parameter) and the settings for\n * whatever is chosen. The choice belongs at the bottom, next to the tool\n * rail it continues, and its settings appear above it. Side by side they\n * read as one undifferentiated row of buttons and it is not obvious which\n * of them changes what.\n *\n * Ordering here rather than in each tool keeps a panel's source in\n * reading order and lets a third-party tool join in with one class.\n */\n .panel > * {\n order: 1;\n }\n /*\n * Switching tools rebuilds the panel, so the rows rise on the new\n * children and never on a value change inside the open tool, where Lit\n * patches the same nodes.\n *\n * Transform only, deliberately. A fade would put the labels at partial\n * opacity for a moment, and a contrast audit that samples the panel\n * during that moment reports text it can read on screen as failing.\n * Transform also keeps the panel's own height still, which the layout\n * around it is measured against.\n */\n .panel > * {\n animation: sealpixel-panel-in var(--sealpixel-duration) var(--sealpixel-ease-out) both;\n }\n .panel > *:nth-child(2) {\n animation-delay: 25ms;\n }\n .panel > *:nth-child(n + 3) {\n animation-delay: 50ms;\n }\n @keyframes sealpixel-panel-in {\n from {\n transform: translateY(8px);\n }\n }\n /* Phones: option grids become one horizontal strip so the stage keeps its height. */\n .panel .grid,\n .panel .strip {\n display: flex;\n gap: var(--sealpixel-space);\n overflow-x: auto;\n scrollbar-width: none;\n padding-bottom: 2px;\n scroll-snap-type: x proximity;\n }\n .panel .grid::-webkit-scrollbar,\n .panel .strip::-webkit-scrollbar {\n display: none;\n }\n .panel .grid > *,\n .panel .strip > * {\n flex: 0 0 auto;\n min-width: 96px;\n scroll-snap-align: start;\n }\n .panel .strip > * {\n min-width: 0;\n }\n /*\n * The strip centres while it fits and scrolls from the first item once\n * it does not, so a short row of presets is not stranded at the left\n * edge of a wide bar.\n */\n .panel .strip {\n justify-content: safe center;\n align-items: end;\n scroll-behavior: smooth;\n }\n .panel .chips {\n gap: 2px;\n }\n /*\n * A segmented control: one pill holds the row, the segments share it. Six\n * separate buttons put six borders in a row and made the choice look like\n * six unrelated actions; one container says they are one decision with\n * one answer at a time.\n */\n .panel .group {\n display: inline-flex;\n gap: 2px;\n padding: 2px;\n background: var(--sealpixel-color-surface-2);\n border-radius: var(--sealpixel-radius-pill);\n flex: 0 0 auto;\n }\n .panel .group sealpixel-button::part(button) {\n background: transparent;\n border-color: transparent;\n min-height: calc(var(--sealpixel-control-height) - 4px);\n min-width: calc(var(--sealpixel-control-height) - 4px);\n padding: 0 calc(var(--sealpixel-space) * 1.25);\n }\n .panel .group sealpixel-button:hover::part(button) {\n background: color-mix(in srgb, var(--sealpixel-color-fg) 7%, transparent);\n }\n .panel .group sealpixel-button[pressed]::part(button) {\n background: var(--sealpixel-color-surface);\n color: var(--sealpixel-color-accent);\n box-shadow: var(--sealpixel-shadow-sm, none);\n }\n\n /* Filter tiles: the image is the control, the label only names it. */\n .panel .tiles {\n gap: calc(var(--sealpixel-space) * 0.75);\n }\n /*\n * The one control in the bar that gets bigger. Everywhere else the chrome\n * shrank; here the chrome is the point, because a preset is judged by\n * looking at it.\n */\n .panel .thumb {\n display: block;\n width: 100%;\n height: 64px;\n object-fit: cover;\n border-radius: var(--sealpixel-radius);\n background: var(--sealpixel-color-surface-2);\n box-shadow: 0 0 0 1px var(--sealpixel-color-border);\n transition:\n box-shadow var(--sealpixel-duration) var(--sealpixel-ease),\n transform var(--sealpixel-duration) var(--sealpixel-ease-spring);\n }\n .panel .tiles sealpixel-button {\n min-width: 84px;\n max-width: 84px;\n }\n .panel .tiles sealpixel-button::part(button) {\n flex-direction: column;\n gap: 6px;\n padding: 0;\n min-height: 0;\n height: auto;\n font-size: 11px;\n background: transparent;\n color: var(--sealpixel-color-fg-muted);\n }\n .panel .tiles sealpixel-button:hover .thumb {\n transform: translateY(-2px);\n }\n .panel .tiles sealpixel-button[pressed] .thumb {\n box-shadow:\n 0 0 0 2px var(--sealpixel-color-surface),\n 0 0 0 4px var(--sealpixel-color-accent);\n }\n .panel .tiles sealpixel-button[pressed]::part(button) {\n background: transparent;\n border-color: transparent;\n color: var(--sealpixel-color-fg);\n }\n /* Separates the untouched image from the presets. */\n .panel .divider {\n flex: 0 0 auto;\n align-self: stretch;\n width: 1px;\n min-width: 1px;\n margin: 6px calc(var(--sealpixel-space) * 0.5);\n background: var(--sealpixel-color-border);\n opacity: 0.55;\n }\n .panel .row.compact > sealpixel-button {\n flex: 0 0 auto;\n min-width: 72px;\n }\n /* Phones: sibling groups share one line and hints make room for the stage. */\n .panel .rows {\n display: flex;\n gap: var(--sealpixel-space);\n align-items: end;\n }\n /*\n * Content width, not an equal share. An equal share squeezed a text field\n * and a colour well down to a few pixels each and their labels ran into\n * one another; only a dial has a reason to take the leftover room.\n */\n .panel .rows > * {\n flex: 0 1 auto;\n min-width: 0;\n }\n /*\n * A dial needs travel to be worth dragging. Inside a settings row it was\n * sharing the width equally with a colour swatch and a checkbox and ended\n * up a few ticks wide, which is not a control any more. The row grows to\n * give it that width instead of shrinking to its contents.\n */\n /*\n * A settings row scrolls sideways when it is wider than the bar, the way\n * the choice row does. Letting it overflow instead left the last control\n * cut off at the edge with nothing to say it was there.\n */\n .panel > .rows {\n flex: 0 1 auto;\n max-width: 100%;\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: none;\n scroll-behavior: smooth;\n padding-bottom: 1px;\n }\n .panel > .rows::-webkit-scrollbar {\n display: none;\n }\n .panel > .rows > * {\n flex-shrink: 0;\n }\n .panel .rows > sealpixel-slider {\n flex: 0 1 260px;\n min-width: 220px;\n }\n .panel .rows .row {\n flex-wrap: nowrap;\n }\n .panel .rows .row > sealpixel-button {\n flex: 1 1 0;\n min-width: 0;\n }\n /*\n * A field fills its label, but never shrinks to nothing: a text box a\n * few pixels wide hides what was typed into it, and a select that narrow\n * hides which option is chosen.\n */\n .panel .rows select,\n .panel .rows input:not([type='checkbox']):not([type='color']) {\n width: 100%;\n min-width: 7em;\n }\n .panel .rows input[type='text'],\n .panel .rows textarea {\n min-width: 11em;\n }\n .panel .rows > .field:has(input[type='color']),\n .panel .rows > .field.check {\n flex: 0 0 auto;\n }\n /* A colour well is square, which makes the disc round. */\n .panel .rows > .field:has(input[type='color']) input {\n width: var(--sealpixel-control-height);\n aspect-ratio: 1;\n }\n .panel .swatches {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-bottom: 6px;\n }\n .panel .swatch {\n width: 24px;\n height: 24px;\n border-radius: 50%;\n border: 0;\n box-shadow: 0 0 0 1px var(--sealpixel-color-border);\n cursor: pointer;\n padding: 0;\n transition:\n transform var(--sealpixel-duration) var(--sealpixel-ease-spring),\n border-color var(--sealpixel-transition),\n box-shadow var(--sealpixel-duration) var(--sealpixel-ease);\n }\n .panel .swatch:hover {\n transform: scale(1.12);\n }\n .panel .swatch:active {\n transform: scale(0.94);\n }\n /* The ring sits off the disc, so the colour itself is never covered. */\n .panel .swatch[aria-pressed='true'] {\n box-shadow:\n 0 0 0 2px var(--sealpixel-color-surface),\n 0 0 0 3.5px var(--sealpixel-color-accent);\n }\n .panel:empty {\n display: none;\n }\n .toast {\n position: absolute;\n left: 50%;\n bottom: calc(var(--sealpixel-toolbar-size) + var(--sealpixel-space) * 2);\n /* Sits above the stage, never over the bar the user is working in. */\n transform: translateX(-50%);\n display: flex;\n align-items: center;\n gap: var(--sealpixel-space);\n max-width: calc(100% - var(--sealpixel-space) * 4);\n padding: calc(var(--sealpixel-space) * 1.25) calc(var(--sealpixel-space) * 2);\n border-radius: 999px;\n background: color-mix(in srgb, var(--sealpixel-color-surface) 92%, transparent);\n border: 1px solid var(--sealpixel-color-border);\n box-shadow: var(--sealpixel-shadow, 0 8px 24px rgba(0, 0, 0, 0.3));\n color: var(--sealpixel-color-fg);\n font-size: 13px;\n white-space: nowrap;\n backdrop-filter: blur(8px);\n cursor: pointer;\n z-index: 2;\n animation: sealpixel-toast-in var(--sealpixel-duration) var(--sealpixel-ease-out) both;\n }\n .toast:hover {\n border-color: var(--sealpixel-color-fg-muted);\n }\n .toast code {\n font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;\n color: var(--sealpixel-color-fg-muted);\n padding: 2px 8px;\n border-radius: 999px;\n background: var(--sealpixel-color-surface-2);\n }\n @keyframes sealpixel-toast-in {\n from {\n opacity: 0;\n transform: translate(-50%, 12px) scale(0.96);\n }\n }\n /*\n * Wide layouts move the tool rail to the left edge and nothing else. The\n * panel stays a bottom bar at every width, so a control sits in the same\n * place on a phone and on a desktop, and the stage keeps the full width\n * it needs for a landscape image.\n */\n @container (min-width: 48rem) {\n /*\n * The rail runs the full height beside both the stage and the bar.\n * Stopping it above the bar cost it the bar's height, and with ten or\n * more tools the last of them ended up scrolled out of sight behind\n * the settings of the one already open.\n */\n .root {\n grid-template:\n 'nav nav' auto\n 'toolbar stage' 1fr\n 'toolbar panel' auto / var(--sealpixel-toolbar-size) 1fr;\n }\n .panel {\n height: max(var(--sealpixel-panel-size), var(--sealpixel-panel-fit, 0px));\n padding: var(--sealpixel-space) calc(var(--sealpixel-space) * 2);\n }\n .panel[data-empty] {\n height: 0;\n padding: 0;\n }\n .toast {\n bottom: calc(var(--sealpixel-space) * 2);\n }\n }\n .panel .row {\n display: flex;\n gap: var(--sealpixel-space);\n flex-wrap: wrap;\n }\n .panel > .choice {\n order: 2;\n flex: 1 1 100%;\n justify-content: safe center;\n /*\n * Pinned to the foot of the bar. The choice is what gets the user out\n * of the tool they are in, so it has to stay reachable even when a\n * busy panel scrolls its settings.\n */\n position: sticky;\n bottom: 0;\n z-index: 1;\n background: var(--sealpixel-color-surface);\n padding-top: 4px;\n /*\n * One line that scrolls, never two that wrap. A wrapped second line\n * falls below the bar and takes whatever was on it out of reach, and\n * on a phone that was the reset button.\n */\n flex-wrap: nowrap;\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: none;\n scroll-behavior: smooth;\n }\n .panel > .choice::-webkit-scrollbar {\n display: none;\n }\n .panel > .choice > * {\n flex-shrink: 0;\n }\n .panel .field {\n display: grid;\n gap: 3px;\n justify-items: center;\n color: var(--sealpixel-color-fg-muted);\n }\n /* The label names the control; it is not the thing being read. */\n .panel .field > span,\n .panel .field > .lab {\n font-size: 11px;\n letter-spacing: 0.012em;\n line-height: 1.2;\n }\n .panel .hint {\n margin: 0;\n color: var(--sealpixel-color-fg-muted);\n font-size: 12px;\n }\n /*\n * Width and height are one measurement, so they sit against the link that\n * binds them rather than being two fields that happen to be adjacent.\n */\n .panel .dims {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n }\n .panel .dims input[type='number'] {\n width: 5.5em;\n min-width: 0;\n text-align: center;\n font-variant-numeric: tabular-nums;\n appearance: textfield;\n }\n .panel .dims input::-webkit-outer-spin-button,\n .panel .dims input::-webkit-inner-spin-button {\n appearance: none;\n margin: 0;\n }\n /* A value the link worked out, not one that was typed. */\n .panel .dims input.derived {\n color: var(--sealpixel-color-fg-muted);\n font-weight: 400;\n }\n .panel .dims sealpixel-button::part(button) {\n min-width: calc(var(--sealpixel-control-height) - 6px);\n min-height: calc(var(--sealpixel-control-height) - 6px);\n padding: 0;\n background: transparent;\n color: var(--sealpixel-color-fg-muted);\n }\n .panel .dims sealpixel-button[pressed]::part(button) {\n background: var(--sealpixel-color-accent-soft);\n color: var(--sealpixel-color-accent);\n }\n .panel .anchors {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: 4px;\n max-width: 180px;\n }\n .panel .field.check {\n grid-template-columns: auto 1fr;\n align-items: center;\n }\n .panel textarea {\n font: inherit;\n color: var(--sealpixel-color-fg);\n background: var(--sealpixel-color-surface-2);\n border: 1px solid var(--sealpixel-color-border);\n border-radius: var(--sealpixel-radius-sm);\n padding: var(--sealpixel-space);\n resize: vertical;\n }\n /* A colour is a disc, not a box: it shows the colour and nothing else. */\n .panel input[type='color'] {\n /* Without this the engine keeps its own swatch metrics inside the box\n and the disc comes out an ellipse. */\n appearance: none;\n min-height: var(--sealpixel-control-height);\n height: var(--sealpixel-control-height);\n width: var(--sealpixel-control-height);\n padding: 0;\n border: 0;\n border-radius: 50%;\n background: transparent;\n cursor: pointer;\n overflow: hidden;\n }\n /* The swatch has to be told to fill the box; it does not by default. */\n .panel input[type='color']::-webkit-color-swatch-wrapper {\n padding: 0;\n width: 100%;\n height: 100%;\n }\n .panel input[type='color']::-webkit-color-swatch {\n width: 100%;\n height: 100%;\n border: 0;\n border-radius: 50%;\n box-shadow: 0 0 0 1px var(--sealpixel-color-border);\n }\n .panel input[type='color']::-moz-color-swatch {\n width: 100%;\n height: 100%;\n border: 0;\n border-radius: 50%;\n box-shadow: 0 0 0 1px var(--sealpixel-color-border);\n }\n .panel input:not([type='checkbox']):not([type='color']),\n .panel select {\n font: inherit;\n font-size: 13px;\n color: var(--sealpixel-color-fg);\n background: var(--sealpixel-color-surface-2);\n border: 1px solid transparent;\n border-radius: var(--sealpixel-radius-pill);\n min-height: var(--sealpixel-control-height);\n padding: 0 calc(var(--sealpixel-space) * 1.5);\n }\n /*\n * The chevron is drawn rather than left to the platform, so a select sits\n * next to a pill button instead of looking like a form field that walked\n * in from another page. The right padding keeps the text off it.\n */\n .panel select {\n appearance: none;\n padding-right: calc(var(--sealpixel-space) * 3);\n background-image:\n linear-gradient(45deg, transparent 50%, currentColor 50%),\n linear-gradient(135deg, currentColor 50%, transparent 50%);\n background-size: 5px 5px, 5px 5px;\n background-position:\n right 14px top 52%,\n right 10px top 52%;\n background-repeat: no-repeat;\n color: var(--sealpixel-color-fg);\n }\n .empty {\n grid-area: stage;\n display: grid;\n place-content: center;\n gap: var(--sealpixel-space);\n text-align: center;\n color: var(--sealpixel-color-fg-muted);\n padding: var(--sealpixel-space);\n }\n .empty {\n transition:\n background var(--sealpixel-duration) var(--sealpixel-ease),\n color var(--sealpixel-duration) var(--sealpixel-ease);\n }\n .empty.dragover {\n outline: 2px dashed var(--sealpixel-color-accent);\n outline-offset: -8px;\n background: var(--sealpixel-color-accent-soft, transparent);\n color: var(--sealpixel-color-fg);\n }\n /*\n * A source is loading: the mark, its core breathing. The outer square\n * stands still and the inner one swells and fades, in the muted\n * foreground so nothing reads as a warning. It stops under\n * prefers-reduced-motion and still reads as the mark.\n */\n .empty.loading {\n justify-items: center;\n gap: calc(var(--sealpixel-space) * 2);\n }\n .empty.loading p {\n margin: 0;\n }\n .mark {\n display: block;\n width: 40px;\n height: 40px;\n color: var(--sealpixel-color-fg-muted);\n }\n .mark .core {\n transform-origin: 16px 16px;\n animation: sealpixel-loading-breathe 1.8s var(--sealpixel-ease) infinite;\n }\n @keyframes sealpixel-loading-breathe {\n 50% {\n opacity: 0.45;\n transform: scale(0.62);\n }\n }\n }\n .error {\n grid-area: nav;\n align-self: end;\n justify-self: center;\n margin-top: calc(var(--sealpixel-toolbar-size) + 4px);\n z-index: 1;\n padding: 6px 10px;\n border-radius: var(--sealpixel-radius);\n background: var(--sealpixel-color-danger);\n color: white;\n font-size: 12px;\n box-shadow: var(--sealpixel-shadow-raised, none);\n animation: sealpixel-panel-in var(--sealpixel-duration) var(--sealpixel-ease-out) both;\n }\n `,\n ];\n\n static override properties = {\n plugins: { attribute: false },\n pluginOptions: {\n attribute: 'plugin-options',\n converter: jsonAttribute<PluginOptionsMap>('plugin-options'),\n },\n session: { attribute: false },\n renderer: { attribute: false },\n assets: { attribute: false },\n limits: {\n attribute: 'limits',\n converter: jsonAttribute<NonNullable<SessionOptions['limits']>>('limits'),\n },\n src: { attribute: false },\n editLog: { attribute: false },\n defaultEditLog: { attribute: false },\n output: { attribute: false },\n theme: { type: String, reflect: true },\n locale: { type: String },\n dictionary: { attribute: false },\n tools: { attribute: false },\n activeTool: { type: String, attribute: 'active-tool' },\n showExport: { type: String, attribute: 'show-export' },\n showDownload: { type: String, attribute: 'show-download' },\n showHistory: { type: String, attribute: 'show-history' },\n downloadLabel: { type: String, attribute: 'download-label' },\n _busy: { state: true },\n _processListeners: { state: true },\n _toast: { state: true },\n _dragover: { state: true },\n _wide: { state: true },\n _pluginTools: { state: true },\n };\n\n declare plugins: readonly AnyPlugin[] | null;\n /** `{ pluginId: partialOptions }` applied to `plugins` (or the defaults) through each plugin's `configure()`. */\n declare pluginOptions: PluginOptionsMap | null;\n declare session: EditorSession | null;\n declare renderer: Renderer | null;\n /** Fonts and images. Defaults to a fetch resolver over the plugins' declarations. */\n declare assets: AssetResolver | null;\n /**\n * How much of the original stays in the browser; `SessionOptions['limits']`\n * (JSON in the attribute). Above `maxClientMegapixels` (16 by default) the\n * image is not resident: Export and Download are disabled, and the host\n * renders the original outside the browser.\n */\n declare limits: SessionOptions['limits'] | null;\n declare src: EditorSource | null;\n /** Controlled mode: the host owns the log. */\n declare editLog: unknown;\n /** Uncontrolled: applied once on load. */\n declare defaultEditLog: unknown;\n declare output: OutputOptions;\n declare theme: 'dark' | 'light' | 'auto';\n declare locale: string;\n /** Overrides the shipped dictionary for `locale`; shipped locales resolve automatically. */\n declare dictionary: Dictionary | null;\n declare tools: Record<string, UiTool> | null;\n declare activeTool: string | null;\n /**\n * When the Export button is shown. `auto` (default) shows it only while a\n * `sealpixel:process` listener is attached, because Export hands the result to\n * the host and does nothing visible otherwise. Download is always shown.\n */\n declare showExport: 'auto' | 'always' | 'never';\n /** `always` (default) or `never`. Hosts that only consume `sealpixel:process` hide the button. */\n declare showDownload: 'always' | 'never';\n /** `all` (default), `buttons` (undo and redo, no timeline) or `none` (also disables the undo/redo shortcuts). */\n declare showHistory: 'all' | 'buttons' | 'none';\n /** Custom text for the Download button; the localized label when null. */\n declare downloadLabel: string | null;\n declare _busy: boolean;\n declare _processListeners: number;\n declare _toast: { text: string; hash: string } | null;\n declare _dragover: boolean;\n declare _wide: boolean;\n /** Tools loaded from `plugin.tool()`, keyed by plugin id. */\n declare _pluginTools: Record<string, UiTool>;\n private resizeObserver: ResizeObserver | null = null;\n private toolLoads = new Set<string>();\n\n /**\n * Used when no `renderer` property is set. `@sealpixel/element` installs a\n * factory that starts the bundled worker; without it the editor renders inline.\n */\n static defaultRendererFactory: ((plugins: readonly AnyPlugin[]) => Renderer) | null = null;\n\n private readonly ctl = new SessionController(this, null);\n private i18n: I18n = createI18n('en');\n private ownsSession = false;\n private lastEmittedVersion = -1;\n private lastAppliedControlled = '';\n private hint: { filter?: string; transform?: string; rotate?: number } | null = null;\n private previousTool: UiTool | null = null;\n /** The source the tools last heard about; `load` replaces the object, so identity is the guard. */\n private lastSource: SourceDescriptor | null = null;\n private loadedSrc: EditorSource | null = null;\n /** The edit log of a session released while the element was out of the document. */\n private detachedLog: { log: unknown; index: number } | null = null;\n /** Whether the owned session was released while the element was out of the document. */\n private released = false;\n\n constructor() {\n super();\n this.plugins = null;\n this.pluginOptions = null;\n this.session = null;\n this.renderer = null;\n this.assets = null;\n this.limits = null;\n this.src = null;\n this.editLog = undefined;\n this.defaultEditLog = undefined;\n this.output = { format: 'image/png' };\n this.theme = 'dark';\n this.locale = 'en';\n this.dictionary = null;\n this.tools = null;\n this.activeTool = null;\n this.showExport = 'auto';\n this.showDownload = 'always';\n this.showHistory = 'all';\n this.downloadLabel = null;\n this._busy = false;\n this._processListeners = 0;\n this._toast = null;\n this._dragover = false;\n this._wide = false;\n this._pluginTools = {};\n }\n\n // Export hands the result to the host, so the button is shown only while\n // someone listens for `sealpixel:process`. Listener counts are tracked here.\n override addEventListener<K extends keyof HTMLElementEventMap>(\n type: K,\n listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown,\n options?: boolean | AddEventListenerOptions,\n ): void;\n override addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void;\n override addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | ((ev: Event) => unknown),\n options?: boolean | AddEventListenerOptions,\n ): void {\n super.addEventListener(type, listener as EventListenerOrEventListenerObject, options);\n if (type === 'sealpixel:process') this._processListeners += 1;\n }\n\n override removeEventListener<K extends keyof HTMLElementEventMap>(\n type: K,\n listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown,\n options?: boolean | EventListenerOptions,\n ): void;\n override removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n override removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | ((ev: Event) => unknown),\n options?: boolean | EventListenerOptions,\n ): void {\n super.removeEventListener(type, listener as EventListenerOrEventListenerObject, options);\n if (type === 'sealpixel:process' && this._processListeners > 0) this._processListeners -= 1;\n }\n\n /** A renderer the editor made through the factory dies with the session; a host's renderer lives on. */\n private disposeOwnedRenderer(): void {\n if (this.sessionRenderer && this.sessionRenderer !== this.renderer) {\n this.sessionRenderer.dispose();\n }\n this.sessionRenderer = null;\n }\n\n /** `plugins` (or the defaults) with `pluginOptions` applied. Invalid options raise `sealpixel:error`. */\n private effectivePlugins(): readonly AnyPlugin[] {\n const base = this.plugins ?? defaultPlugins;\n if (!this.pluginOptions) return base;\n try {\n return configurePlugins(base, this.pluginOptions);\n } catch (error) {\n this.dispatchEvent(\n new CustomEvent('sealpixel:error', { detail: error, bubbles: true, composed: true }),\n );\n return base;\n }\n }\n\n /** The live session, created on first connection when none was passed. */\n getSession(): EditorSession {\n if (!this.ctl.session) this.ensureSession();\n return this.ctl.session as EditorSession;\n }\n getEditLog() {\n return this.getSession().getEditLog();\n }\n setEditLog(saved: unknown, index?: number) {\n this.getSession().setEditLog(saved, index);\n }\n undo() {\n this.getSession().undo();\n }\n redo() {\n this.getSession().redo();\n }\n timeTravel(index: number) {\n this.getSession().timeTravel(index);\n }\n async export(output: OutputOptions = this.output, options: { embedEditLog?: boolean } = {}) {\n return this.getSession().export({ output, ...options });\n }\n async download(\n options: { output?: OutputOptions; filename?: string; embedEditLog?: boolean } = {},\n ) {\n return this.getSession().download({ output: this.output, ...options });\n }\n\n private ensureSession(): void {\n if (this.ctl.session) return;\n if (this.session) {\n this.ctl.session = this.session;\n return;\n }\n const plugins = this.effectivePlugins();\n const renderer = this.renderer ?? SealpixelEditor.defaultRendererFactory?.(plugins) ?? null;\n this.sessionRenderer = renderer;\n const assets =\n this.assets ?? createAssetResolver({ assets: plugins.flatMap((p) => p.assets ?? []) });\n this.sessionAssets = this.assets;\n this.sessionLimits = this.limits;\n const session = createEditorSession({\n plugins,\n assets,\n ...(renderer ? { renderer } : {}),\n ...(this.limits ? { limits: this.limits } : {}),\n });\n this.ownsSession = true;\n this.ctl.session = session;\n this.dispatchEvent(new CustomEvent('sealpixel:ready', { bubbles: true, composed: true }));\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.ensureSession();\n // Out of the document long enough to lose the session: the source comes\n // back with the edit log it had when it left.\n if (this.released) {\n const restore = this.detachedLog ?? undefined;\n this.released = false;\n this.detachedLog = null;\n if (this.loadedSrc) void this.loadSource(this.loadedSrc, restore);\n }\n // Keyboard shortcuts need focus inside the editor. WebKit does not focus\n // buttons on click, so pull focus in on any pointer interaction.\n if (!this.hasAttribute('tabindex')) this.tabIndex = -1;\n this.addEventListener('keydown', this.onKeydown);\n this.addEventListener('pointerdown', this.onPointerDown);\n this.resizeObserver = new ResizeObserver((entries) => {\n const width = entries[0]?.contentRect.width ?? this.clientWidth;\n this._wide = width >= 768;\n });\n this.resizeObserver.observe(this);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.removeEventListener('keydown', this.onKeydown);\n this.removeEventListener('pointerdown', this.onPointerDown);\n this.resizeObserver?.disconnect();\n // A move in the DOM (an append into another parent, a portal, a keyed\n // reorder) disconnects and connects again in the same task. Disposing here\n // would throw the image and its history away on every move, so the\n // session goes only if the element is still out after the task.\n if (this.ownsSession) {\n queueMicrotask(() => {\n if (!this.isConnected) this.releaseSession();\n });\n }\n }\n\n /** Disposes the owned session and keeps its edit log for a later connection. */\n private releaseSession(): void {\n const session = this.ctl.session;\n if (!this.ownsSession || !session) return;\n this.released = true;\n this.detachedLog = session.getState().status === 'ready' ? session.getEditLog() : null;\n session.dispose();\n this.disposeOwnedRenderer();\n this.ctl.session = null;\n this.ownsSession = false;\n this.lastEmittedVersion = -1;\n this.lastSource = null;\n // The tools activate again on the session that replaces this one.\n this.previousTool = null;\n }\n\n override willUpdate(changed: Map<string, unknown>): void {\n if (changed.has('locale') || changed.has('dictionary')) {\n // A dictionary changes the strings it names; every other string stays\n // in the shipped locale.\n this.i18n = createI18n(this.locale, {\n ...resolveLocale(this.locale),\n ...(this.dictionary ?? {}),\n });\n }\n if (changed.has('session') && this.session && this.session !== this.ctl.session) {\n if (this.ownsSession) {\n this.ctl.session?.dispose();\n this.disposeOwnedRenderer();\n }\n this.ownsSession = false;\n this.ctl.session = this.session;\n }\n // A new plugin list or renderer needs a new session; reload the current source into it.\n if (\n (changed.has('plugins') ||\n changed.has('pluginOptions') ||\n changed.has('renderer') ||\n changed.has('assets') ||\n changed.has('limits')) &&\n this.ownsSession &&\n !this.sessionMatchesProps()\n ) {\n this.ctl.session?.dispose();\n this.disposeOwnedRenderer();\n this.ctl.session = null;\n this.ownsSession = false;\n this.toolLoads.clear();\n this._pluginTools = {};\n this.lastEmittedVersion = -1;\n this.lastSource = null;\n this.ensureSession();\n if (this.loadedSrc) void this.loadSource(this.loadedSrc);\n }\n if (changed.has('src') && this.src && this.src !== this.loadedSrc) {\n this.loadedSrc = this.src;\n void this.loadSource(this.src);\n }\n if (changed.has('editLog') && this.editLog != null) this.applyControlled();\n }\n\n override updated(): void {\n const state = this.ctl.state;\n const session = this.ctl.session;\n if (!state || !session) return;\n if (state.version !== this.lastEmittedVersion && state.status === 'ready') {\n this.lastEmittedVersion = state.version;\n const detail = session.getEditLog();\n this.lastAppliedControlled = canonicalJson(detail);\n this.dispatchEvent(\n new CustomEvent('sealpixel:change', { detail, bubbles: true, composed: true }),\n );\n }\n if (state.error && state.error !== this.lastError) {\n this.lastError = state.error;\n this.dispatchEvent(\n new CustomEvent('sealpixel:error', { detail: state.error, bubbles: true, composed: true }),\n );\n }\n this.syncActiveTool();\n this.syncSource(state);\n this.syncPanelFill();\n }\n private lastError: unknown = null;\n\n /** Tells every tool, active or not, that a new source has loaded. Once per source. */\n private syncSource(state: SessionState): void {\n if (state.status !== 'ready' || !state.source || state.source === this.lastSource) return;\n this.lastSource = state.source;\n const ctx = this.toolContext(state);\n for (const tool of this.currentTools()) tool.onSource?.(ctx);\n }\n\n /**\n * Collapses the settings bar when the open tool has nothing to put in it.\n *\n * A tool renders its own structure, and a structure can hold nothing: crop\n * with `rotation`, `flip` and `reset` off and a single enforced aspect emits\n * two empty wrappers. The bar is a fixed height on purpose — see `.panel` —\n * so that reserved an empty bordered surface and took the same height off\n * the stage. On the landing page's avatar card that was 240 px of nothing\n * against a 178 px stage, and the photo rendered at 10 percent.\n *\n * Read from the DOM rather than asked of the tool: every tool would\n * otherwise have to declare it, and a tool whose panel empties out only\n * under some options would get it wrong.\n *\n * Not measured by size either. The empty wrappers still lay out — the row\n * is 8px from its own gap and the group 4px from its border — so a\n * bounding box tells content and scaffolding apart not at all. What counts\n * is a control or a word: a custom element, a form control, or any text.\n */\n private syncPanelFill(): void {\n const panel = this.renderRoot.querySelector('.panel') as HTMLElement | null;\n if (!panel) return;\n const filled =\n (panel.textContent ?? '').trim().length > 0 ||\n Array.from(panel.querySelectorAll('*')).some(\n (node) => node.tagName.includes('-') || node.matches(PANEL_CONTENT),\n );\n panel.toggleAttribute('data-empty', !filled);\n this.syncPanelFit(panel, filled);\n }\n\n /**\n * Lets the settings bar grow to the height its content needs.\n *\n * The bar is a fixed height so that moving between tools does not resize\n * the stage under the user. When a tool needs more than that height, the\n * overflow has nowhere to go: a wrapping flex container of fixed height has\n * no scrollable cross-axis overflow, so `overflow: auto` never produces a\n * scrollbar, and the sticky choice row — which pins itself inside the\n * scrollport — is dragged up over the settings instead. The colour swatch\n * ends up half covered and the fill toggle disappears behind the shapes.\n *\n * WebKit is where this surfaced, on a real iPhone: it lays these controls\n * taller than Blink does, and at phone width crop, finetune and annotate\n * needed 138, 140 and 136 pixels against the 112 the bar had. Raising the\n * default would have taken those pixels off every stage in every engine, so\n * the height is measured instead and only the bar that needs more gets it.\n * `34cqh` still caps it, so a busy tool cannot eat the stage.\n */\n private syncPanelFit(panel: HTMLElement, filled: boolean): void {\n panel.style.removeProperty('--sealpixel-panel-fit');\n if (!filled) return;\n // Read after the reset, so a bar that has since shrunk measures its own\n // content and not the height it was given last time.\n const needed = panel.scrollHeight;\n if (needed > panel.clientHeight) {\n panel.style.setProperty('--sealpixel-panel-fit', `${needed}px`);\n }\n }\n\n private async loadSource(src: EditorSource, restore?: unknown): Promise<void> {\n const session = this.getSession();\n try {\n // `null` is \"no saved log\", the same as `undefined`: framework props\n // commonly type an absent log as null.\n const saved = this.editLog ?? restore ?? this.defaultEditLog ?? undefined;\n const bytes = src instanceof Uint8Array ? src : src;\n const descriptor = await session.load(bytes, saved === undefined ? {} : { editLog: saved });\n // Option defaults become real ops in an otherwise empty log.\n if (saved === undefined && session.getState().history.log.ops.length === 0) {\n for (const op of session.registry.initialOps(descriptor)) {\n session.dispatch({\n ...op,\n id: `init-${Math.random().toString(36).slice(2, 8)}`,\n } as Parameters<typeof session.dispatch>[0]);\n }\n }\n this.dispatchEvent(\n new CustomEvent('sealpixel:load', { detail: descriptor, bubbles: true, composed: true }),\n );\n if (!this.activeTool) {\n const first = this.currentTools()[0];\n if (first) this.activeTool = first.id;\n }\n } catch (error) {\n // A newer `src` replaced this load. That load reports its own outcome.\n if ((error as Error | null)?.name === 'ABORTED') return;\n this.dispatchEvent(\n new CustomEvent('sealpixel:error', { detail: error, bubbles: true, composed: true }),\n );\n }\n }\n\n private applyControlled(): void {\n const session = this.ctl.session;\n if (!session || session.getState().status !== 'ready' || this.editLog == null) return;\n const wanted = this.editLog as { log?: unknown; index?: number };\n const key = canonicalJson(wanted);\n if (key === this.lastAppliedControlled) return;\n try {\n session.setEditLog(wanted, wanted.index);\n this.lastAppliedControlled = key;\n } catch (error) {\n this.dispatchEvent(\n new CustomEvent('sealpixel:error', { detail: error, bubbles: true, composed: true }),\n );\n }\n }\n\n /** Whether the owned session was built from the current `plugins`, `renderer`, `assets` and `limits`. */\n private sessionMatchesProps(): boolean {\n const session = this.ctl.session;\n if (!session) return false;\n if (this.renderer && this.renderer !== this.sessionRenderer) return false;\n if (this.assets && this.assets !== this.sessionAssets) return false;\n if (canonicalJson(this.limits ?? null) !== canonicalJson(this.sessionLimits ?? null))\n return false;\n // Compare id, version and resolved options (options JSON may contain commas, so no string splitting).\n const key = (plugins: readonly AnyPlugin[]) =>\n canonicalJson(\n [...plugins]\n .sort((a, b) => a.id.localeCompare(b.id))\n .map((p) => [p.id, p.version, p.options ?? null]),\n );\n return key(this.effectivePlugins()) === key(session.registry.plugins);\n }\n private sessionRenderer: Renderer | null = null;\n private sessionAssets: AssetResolver | null = null;\n private sessionLimits: SessionOptions['limits'] | null = null;\n\n private currentTools(): UiTool[] {\n const plugins = this.effectivePlugins();\n this.loadPluginTools(plugins);\n return toolsFor(plugins, { ...this._pluginTools, ...(this.tools ?? {}) });\n }\n\n /** Plugins may ship their own tool; load each once and re-render when it arrives. */\n private loadPluginTools(plugins: readonly AnyPlugin[]): void {\n for (const plugin of plugins) {\n if (!plugin.tool || this.toolLoads.has(plugin.id)) continue;\n this.toolLoads.add(plugin.id);\n plugin\n .tool()\n .then((tool) => {\n this._pluginTools = { ...this._pluginTools, [plugin.id]: tool as unknown as UiTool };\n })\n .catch((error) => {\n this.dispatchEvent(\n new CustomEvent('sealpixel:error', { detail: error, bubbles: true, composed: true }),\n );\n });\n }\n }\n\n private get stage(): SealpixelStage | null {\n return this.renderRoot.querySelector('sealpixel-stage');\n }\n\n private toolContext(state: SessionState): UiToolContext {\n const session = this.getSession();\n const stage = this.stage;\n return {\n session,\n state,\n document: state.document,\n dispatch: (op) => {\n try {\n session.dispatch(op);\n } catch (error) {\n // A tool asked for something the options forbid: tell the user, keep the log intact.\n if (error instanceof SealpixelError && error.name === 'OPTION_VIOLATION') {\n this._toast = { text: error.message, hash: '' };\n this.announce(error.message);\n return;\n }\n throw error;\n }\n },\n t: this.i18n.t,\n stage: {\n width: state.preview?.image.width ?? 0,\n height: state.preview?.image.height ?? 0,\n zoom: stage?.zoom ?? 1,\n geometry: state.preview?.geometry ?? null,\n toImage: (x, y) => stage?.toImage(x, y) ?? { x: 0, y: 0 },\n },\n hint: (hint) => {\n this.hint = hint;\n const s = this.stage;\n if (s) {\n s.hintFilter = hint?.filter ?? '';\n s.hintTransform = hint?.transform ?? '';\n s.hintRotate = hint?.rotate ?? 0;\n }\n },\n refresh: () => this.requestUpdate(),\n animateNextView: () => this.stage?.glideNextView(),\n clipPreview: (clip) => {\n const s = this.stage;\n if (s) s.clip = clip ?? '';\n },\n layout: this._wide ? 'wide' : 'narrow',\n options: <T>(pluginId: string) =>\n session.registry.byId.get(pluginId)?.options as T | undefined,\n };\n }\n\n private syncActiveTool(): void {\n const state = this.ctl.state;\n if (!state || state.status !== 'ready') return;\n const tool = this.currentTools().find((t) => t.id === this.activeTool) ?? null;\n if (tool === this.previousTool) return;\n const ctx = this.toolContext(state);\n this.previousTool?.deactivate?.(ctx);\n tool?.activate?.(ctx);\n this.previousTool = tool;\n }\n\n private onPointerDown = () => {\n if (!this.matches(':focus-within')) this.focus({ preventScroll: true });\n };\n\n private onKeydown = (e: KeyboardEvent) => {\n const session = this.ctl.session;\n if (!session || session.getState().status !== 'ready') return;\n // Undo inside a text field belongs to the field: it takes back the typing,\n // not the last edit of the image.\n if (isTextEntry(e.composedPath()[0])) return;\n const mod = e.metaKey || e.ctrlKey;\n if (this.showHistory === 'none') return;\n if (mod && e.key.toLowerCase() === 'z') {\n e.preventDefault();\n if (e.shiftKey) session.redo();\n else session.undo();\n } else if (mod && e.key.toLowerCase() === 'y') {\n e.preventDefault();\n session.redo();\n }\n };\n\n private async onExport(): Promise<void> {\n const session = this.getSession();\n this._busy = true;\n try {\n const result: ExportResult = await session.export({ output: this.output });\n this.dispatchEvent(\n new CustomEvent('sealpixel:process', { detail: result, bubbles: true, composed: true }),\n );\n this.toast('toast.exported', result);\n } catch (error) {\n this.dispatchEvent(\n new CustomEvent('sealpixel:error', { detail: error, bubbles: true, composed: true }),\n );\n } finally {\n this._busy = false;\n }\n }\n\n private async onDownload(): Promise<void> {\n const session = this.getSession();\n this._busy = true;\n try {\n const { result } = await session.download({ output: this.output });\n this.dispatchEvent(\n new CustomEvent('sealpixel:process', { detail: result, bubbles: true, composed: true }),\n );\n this.toast('toast.downloaded', result);\n } catch (error) {\n this.dispatchEvent(\n new CustomEvent('sealpixel:error', { detail: error, bubbles: true, composed: true }),\n );\n } finally {\n this._busy = false;\n }\n }\n\n private announce(text: string): void {\n const live = this.renderRoot.querySelector('#live');\n if (live) live.textContent = text;\n }\n\n private toastTimer: ReturnType<typeof setTimeout> | null = null;\n\n /** Brief confirmation over the stage: format, size and hash of the result. */\n private toast(\n key: 'toast.exported' | 'toast.downloaded',\n result: Pick<ExportResult, 'mimeType' | 'width' | 'height' | 'hash' | 'bytes'>,\n ): void {\n const format = result.mimeType.replace('image/', '').toUpperCase();\n const size = formatBytes(result.bytes.byteLength);\n const text = this.i18n.t(key, { format, width: result.width, height: result.height, size });\n this._toast = { text, hash: result.hash.slice(0, 12) };\n this.announce(text);\n if (this.toastTimer) clearTimeout(this.toastTimer);\n this.toastTimer = setTimeout(() => {\n this._toast = null;\n this.toastTimer = null;\n }, 5000);\n }\n\n private onFiles(files: FileList | null): void {\n const file = files?.[0];\n if (file) this.src = file;\n }\n\n override render() {\n const state = this.ctl.state;\n const tools = this.currentTools();\n const tool = tools.find((t) => t.id === this.activeTool) ?? null;\n const ready = state?.status === 'ready';\n const ctx = state && ready ? this.toolContext(state) : null;\n const badges: Record<string, number> = {};\n if (ctx) {\n for (const t of tools) {\n const n = t.badge?.(ctx);\n if (n) badges[t.id] = n;\n }\n }\n const wide = this._wide;\n return html`\n <div class=\"root\" part=\"root\">\n <sealpixel-nav\n part=\"nav\"\n exportparts=\"undo, redo, history, export, download, dimensions, button\"\n .state=${state}\n .t=${this.i18n.t}\n .busy=${this._busy}\n .canExport=${state?.resident ?? false}\n .showExport=${this.showExport === 'always' || (this.showExport === 'auto' && this._processListeners > 0)}\n .showDownload=${this.showDownload !== 'never'}\n .showHistory=${this.showHistory}\n .downloadLabel=${this.downloadLabel}\n @nav-undo=${() => this.getSession().undo()}\n @nav-redo=${() => this.getSession().redo()}\n @nav-time-travel=${(e: CustomEvent<number>) => this.getSession().timeTravel(e.detail)}\n @nav-export=${() => this.onExport()}\n @nav-download=${() => this.onDownload()}\n ></sealpixel-nav>\n ${\n ready\n ? html`<sealpixel-stage\n part=\"stage\"\n exportparts=\"viewport, canvas, overlay, status\"\n .preview=${state?.preview ?? null}\n .t=${this.i18n.t}\n .pending=${state?.previewPending ?? false}\n .overlay=${ctx && tool?.overlay ? tool.overlay(ctx) : null}\n @stage-view=${() => this.requestUpdate()}\n ></sealpixel-stage>`\n : this.renderEmpty(state)\n }\n <div class=\"panel\" part=\"panel\">${ctx && tool ? tool.panel(ctx) : nothing}</div>\n <sealpixel-toolbar\n part=\"toolbar\"\n exportparts=\"tool, badge\"\n .tools=${tools}\n .badges=${badges}\n .active=${this.activeTool}\n .t=${this.i18n.t}\n .orientation=${wide ? 'vertical' : 'horizontal'}\n @tool-select=${(e: CustomEvent<string>) => {\n this.activeTool = e.detail;\n }}\n ></sealpixel-toolbar>\n ${state?.error ? html`<div class=\"error\" role=\"alert\">${this.i18n.t('editor.error', { message: state.error.message })}</div>` : nothing}\n ${\n this._toast\n ? html`<div class=\"toast\" part=\"toast\" data-testid=\"toast\" @click=${() => {\n this._toast = null;\n }}>\n <span>${this._toast.text}</span>\n ${this._toast.hash ? html`<code>${this._toast.hash}</code>` : nothing}\n </div>`\n : nothing\n }\n <span id=\"live\" class=\"visually-hidden\" role=\"status\" aria-live=\"polite\"></span>\n </div>\n `;\n }\n\n private renderEmpty(state: SessionState | null): TemplateResult {\n if (state?.status === 'loading') {\n return html`<div class=\"empty loading\" part=\"empty\" role=\"status\">\n <svg class=\"mark\" viewBox=\"0 0 32 32\" aria-hidden=\"true\">\n <rect x=\"3\" y=\"3\" width=\"26\" height=\"26\" rx=\"5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" />\n <rect class=\"core\" x=\"11\" y=\"11\" width=\"10\" height=\"10\" rx=\"1.5\" fill=\"currentColor\" />\n </svg>\n <p>${this.i18n.t('editor.loading')}</p>\n </div>`;\n }\n return html`<div\n class=\"empty ${this._dragover ? 'dragover' : ''}\"\n part=\"empty\"\n @dragover=${(e: DragEvent) => {\n e.preventDefault();\n this._dragover = true;\n }}\n @dragleave=${() => {\n this._dragover = false;\n }}\n @drop=${(e: DragEvent) => {\n e.preventDefault();\n this._dragover = false;\n this.onFiles(e.dataTransfer?.files ?? null);\n }}\n >\n <p>${this.i18n.t('editor.empty')}</p>\n <label>\n <input class=\"visually-hidden\" type=\"file\" accept=\"image/png,image/jpeg,image/webp\" @change=${(e: Event) => this.onFiles((e.target as HTMLInputElement).files)} />\n <sealpixel-button variant=\"primary\" @click=${(e: Event) => ((e.currentTarget as HTMLElement).previousElementSibling as HTMLInputElement).click()}>\n ${this.i18n.t('editor.choose')}\n </sealpixel-button>\n </label>\n </div>`;\n }\n}\n\n/** Input types that hold no text, so Cmd/Ctrl+Z on them has nothing of their own to undo. */\nconst NON_TEXT_INPUTS = new Set([\n 'button',\n 'checkbox',\n 'color',\n 'file',\n 'image',\n 'radio',\n 'range',\n 'reset',\n 'submit',\n]);\n\nfunction isTextEntry(target: EventTarget | undefined): boolean {\n if (!(target instanceof HTMLElement)) return false;\n if (target.isContentEditable || target instanceof HTMLTextAreaElement) return true;\n return target instanceof HTMLInputElement && !NON_TEXT_INPUTS.has(target.type);\n}\n\nfunction formatBytes(n: number): string {\n if (n < 1024) return `${n} B`;\n if (n < 1024 * 1024) return `${(n / 1024).toFixed(n < 10240 ? 1 : 0)} KB`;\n return `${(n / (1024 * 1024)).toFixed(1)} MB`;\n}\n"]}
@@ -39,9 +39,15 @@ export declare class SealpixelStage extends LitElement {
39
39
  t: {
40
40
  attribute: boolean;
41
41
  };
42
+ revealed: {
43
+ type: BooleanConstructor;
44
+ state: boolean;
45
+ };
42
46
  };
43
47
  preview: PreviewState | null;
44
48
  pending: boolean;
49
+ /** The first preview has been drawn; the content is shown. */
50
+ revealed: boolean;
45
51
  overlay: TemplateResult | null;
46
52
  hintFilter: string;
47
53
  hintTransform: string;
@@ -28,9 +28,21 @@ export class SealpixelStage extends LitElement {
28
28
  touch-action: none;
29
29
  user-select: none;
30
30
  }
31
+ /*
32
+ * The first preview fades in over the checker instead of cutting in:
33
+ * the image arrives, it does not pop. Later previews draw straight onto
34
+ * the canvas, so only the first one is a reveal. The fade sits on the
35
+ * viewport, so the content's own transition stays the glide and nothing
36
+ * else.
37
+ */
31
38
  .viewport {
32
39
  position: absolute;
33
40
  inset: 0;
41
+ opacity: 0;
42
+ transition: opacity var(--sealpixel-duration-slow) var(--sealpixel-ease-out);
43
+ }
44
+ .viewport.revealed {
45
+ opacity: 1;
34
46
  }
35
47
  .content {
36
48
  position: absolute;
@@ -138,6 +150,7 @@ export class SealpixelStage extends LitElement {
138
150
  zoom: { type: Number },
139
151
  panEnabled: { type: Boolean },
140
152
  t: { attribute: false },
153
+ revealed: { type: Boolean, state: true },
141
154
  }; }
142
155
  constructor() {
143
156
  super();
@@ -193,6 +206,7 @@ export class SealpixelStage extends LitElement {
193
206
  });
194
207
  this.preview = null;
195
208
  this.pending = false;
209
+ this.revealed = false;
196
210
  this.overlay = null;
197
211
  this.hintFilter = '';
198
212
  this.hintTransform = '';
@@ -359,6 +373,7 @@ export class SealpixelStage extends LitElement {
359
373
  ctx.putImageData(new ImageData(data, image.width, image.height), 0, 0);
360
374
  }
361
375
  this.drawnVersion = preview.version;
376
+ this.revealed = true;
362
377
  // A real preview landed: drop tier-A hints.
363
378
  this.hintFilter = '';
364
379
  this.hintTransform = '';
@@ -399,7 +414,7 @@ export class SealpixelStage extends LitElement {
399
414
  const transform = `translate(${this.pan.x}px, ${this.pan.y}px) scale(${this.zoom})`;
400
415
  const hint = this.hintTransform || this.rotateHint();
401
416
  return html `
402
- <div class="viewport" part="viewport">
417
+ <div class="viewport ${this.revealed ? 'revealed' : ''}" part="viewport">
403
418
  <div class="content ${this.glide ? 'glide' : ''}" style="transform:${transform}">
404
419
  <canvas
405
420
  part="canvas"
@@ -1 +1 @@
1
- {"version":3,"file":"sealpix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,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE;iBAC/F,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;SAC5B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;KAC/B,CAAC;IACJ,CAAC;;AAGH,SAAS,KAAK,CAAC,CAAS,EAAE,EAAU,EAAE,EAAU;IAC9C,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { Geometry, PreviewState } from '@sealpixel/core';\nimport { css, html, LitElement, svg, type TemplateResult } from 'lit';\nimport { GestureController } from '../controllers/gesture-controller.js';\nimport { base } from '../theme.js';\nimport {\n type Affine,\n apply,\n invert,\n previewToSource,\n sameAffine,\n scaleOf,\n} from '../view-mapping.js';\n\ntype Translate = (key: string, params?: Record<string, string | number>) => string;\nconst DOUBLE_TAP_MS = 350;\nconst DOUBLE_TAP_PX = 24;\n\n/**\n * Shows the preview on a canvas, fitted and zoomable, with an SVG overlay in\n * image pixel coordinates for tool gizmos. Tier-A hints (CSS filter and\n * transform) are applied to the canvas until the next preview arrives.\n */\nexport class SealpixelStage extends LitElement {\n static override styles = [\n base,\n css`\n :host {\n display: block;\n position: relative;\n overflow: hidden;\n background-color: var(--sealpixel-color-bg);\n background-image:\n linear-gradient(45deg, var(--sealpixel-stage-checker-a) 25%, transparent 25%),\n linear-gradient(-45deg, var(--sealpixel-stage-checker-a) 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, var(--sealpixel-stage-checker-a) 75%),\n linear-gradient(-45deg, transparent 75%, var(--sealpixel-stage-checker-a) 75%);\n background-size: 16px 16px;\n background-position: 0 0, 0 8px, 8px -8px, -8px 0;\n touch-action: none;\n user-select: none;\n }\n .viewport {\n position: absolute;\n inset: 0;\n }\n .content {\n position: absolute;\n left: 0;\n top: 0;\n transform-origin: 0 0;\n will-change: transform;\n }\n /*\n * Only a view the user did not drag glides: a fit, a double tap, a\n * re-anchor after the geometry changed. A pinch, a wheel and a drag must\n * track the pointer exactly, so they clear the class in the same update\n * that writes the new transform and the image never lags behind a finger.\n */\n .content.glide {\n transition: transform var(--sealpixel-duration-slow) var(--sealpixel-ease-out);\n }\n canvas {\n display: block;\n image-rendering: auto;\n transform-origin: 50% 50%;\n box-shadow: var(--sealpixel-shadow, none);\n transition: clip-path var(--sealpixel-duration-slow) var(--sealpixel-ease-out);\n }\n svg.overlay {\n position: absolute;\n left: 0;\n top: 0;\n overflow: visible;\n pointer-events: none;\n }\n svg.overlay [data-interactive] {\n pointer-events: all;\n }\n /* The outline from the base styles scales with the zoom on an SVG shape;\n the stroke stays put and every engine paints it. */\n svg.overlay [tabindex]:focus-visible {\n stroke: var(--sealpixel-color-focus);\n }\n .status {\n position: absolute;\n right: var(--sealpixel-space);\n bottom: var(--sealpixel-space);\n padding: 3px 9px;\n border: 0;\n border-radius: 999px;\n background: color-mix(in srgb, var(--sealpixel-color-surface) 85%, transparent);\n color: var(--sealpixel-color-fg-muted);\n font: inherit;\n font-size: 12px;\n font-variant-numeric: tabular-nums;\n backdrop-filter: blur(6px);\n cursor: pointer;\n transition:\n color var(--sealpixel-transition),\n background var(--sealpixel-transition),\n opacity var(--sealpixel-duration) var(--sealpixel-ease);\n }\n /* Fitted means the button does nothing; it fades back rather than vanishing. */\n .status:disabled {\n cursor: default;\n opacity: 0.55;\n }\n .status:not(:disabled):hover {\n color: var(--sealpixel-color-fg);\n background: color-mix(in srgb, var(--sealpixel-color-surface) 96%, transparent);\n }\n .status:focus-visible {\n outline: 2px solid var(--sealpixel-color-focus);\n outline-offset: 2px;\n }\n /*\n * A full render is in flight. The dot breathes instead of sitting still,\n * because a static dot is read as part of the image. It starts at the\n * resting opacity, so a render that finishes within one frame does not\n * flash.\n */\n .pending {\n position: absolute;\n left: var(--sealpixel-space);\n top: var(--sealpixel-space);\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background: var(--sealpixel-color-accent);\n opacity: 0.8;\n animation: sealpixel-pending 1.4s var(--sealpixel-ease) infinite;\n }\n @keyframes sealpixel-pending {\n 50% {\n opacity: 0.25;\n transform: scale(0.7);\n }\n }\n `,\n ];\n\n static override properties = {\n preview: { attribute: false },\n pending: { type: Boolean },\n overlay: { attribute: false },\n hintFilter: { attribute: false },\n hintTransform: { attribute: false },\n hintRotate: { attribute: false },\n clip: { attribute: false },\n zoom: { type: Number },\n panEnabled: { type: Boolean },\n t: { attribute: false },\n };\n\n declare preview: PreviewState | null;\n declare pending: boolean;\n declare overlay: TemplateResult | null;\n declare hintFilter: string;\n declare hintTransform: string;\n /** A rotation hint in radians. Zero is none. While set, the next preview keeps the zoom. */\n declare hintRotate: number;\n /**\n * A CSS shape the preview is clipped to, or an empty string. A tool uses it\n * to take pixels away rather than paint over them: crop clips to its\n * rectangle so the stage's own backdrop shows around the result, which is\n * the only way the checker carries through without seams. Unlike a hint it\n * survives the next preview, because the tool owns it.\n */\n declare clip: string;\n declare zoom: number;\n declare panEnabled: boolean;\n declare t: Translate;\n\n private canvas: HTMLCanvasElement | null = null;\n private drawnVersion = -1;\n private pan = { x: 0, y: 0 };\n private fitted = false;\n /** Preview px → source px of the drawn preview; a change means the stage shows another view. */\n private viewMap: Affine | null = null;\n private lastTap: { x: number; y: number; at: number } | null = null;\n /**\n * True while the next transform should be animated. Every path that moves the\n * view sets it, so it can never linger from an earlier action into a drag.\n */\n private glide = false;\n /**\n * Set by a tool that wants the next preview to arrive as a movement rather\n * than a cut. Crop uses it: leaving the tool is the moment the image really\n * becomes the crop, and seeing it close is the only signal the user gets\n * that anything happened.\n */\n private glidePending = false;\n private resizeObserver: ResizeObserver | null = null;\n private readonly gestures = new GestureController(this, {\n drag: (e) => {\n if (!this.panEnabled) return;\n this.panBy(e.dx, e.dy);\n },\n // A second tap close to the first fits the image again (double-tap, double-click).\n tap: (e) => {\n const now = performance.now();\n const prev = this.lastTap;\n if (\n prev &&\n now - prev.at < DOUBLE_TAP_MS &&\n Math.hypot(e.x - prev.x, e.y - prev.y) < DOUBLE_TAP_PX\n ) {\n this.lastTap = null;\n this.fit(true);\n return;\n }\n this.lastTap = { x: e.x, y: e.y, at: now };\n },\n pinch: (e) => this.zoomAround(e.scale, e.cx, e.cy, e.dx, e.dy),\n wheelZoom: (e) => this.zoomAround(e.factor, e.cx, e.cy, 0, 0),\n // Plain scrolling pans only while the image is larger than the view;\n // otherwise the page scrolls as the user expects.\n wheelPan: (e) => {\n if (!this.overflows()) return false;\n this.panBy(e.dx, e.dy);\n return true;\n },\n });\n\n constructor() {\n super();\n this.preview = null;\n this.pending = false;\n this.overlay = null;\n this.hintFilter = '';\n this.hintTransform = '';\n this.hintRotate = 0;\n this.clip = '';\n this.zoom = 1;\n this.panEnabled = true;\n this.t = (key) => key;\n }\n\n get geometry(): Geometry | null {\n return this.preview?.geometry ?? null;\n }\n\n get imageWidth(): number {\n return this.preview?.image.width ?? 0;\n }\n\n get imageHeight(): number {\n return this.preview?.image.height ?? 0;\n }\n\n /** Converts a client point into preview image pixels. */\n toImage(clientX: number, clientY: number): { x: number; y: number } {\n const r = this.getBoundingClientRect();\n return {\n x: (clientX - r.left - this.pan.x) / this.zoom,\n y: (clientY - r.top - this.pan.y) / this.zoom,\n };\n }\n\n /** Asks for the next preview-driven view change to be animated, once. */\n glideNextView(): void {\n this.glidePending = true;\n }\n\n /** `glide` animates the move; a resize or a first load must not animate. */\n fit(glide = false): void {\n const w = this.imageWidth;\n const h = this.imageHeight;\n if (!w || !h) return;\n this.glide = glide;\n const r = this.getBoundingClientRect();\n this.zoom = this.fitZoom();\n this.pan = { x: (r.width - w * this.zoom) / 2, y: (r.height - h * this.zoom) / 2 };\n this.fitted = true;\n this.requestUpdate();\n this.viewChanged();\n }\n\n private fitZoom(): number {\n const r = this.getBoundingClientRect();\n const margin = 24;\n const zoom = Math.min(\n (r.width - margin) / this.imageWidth,\n (r.height - margin) / this.imageHeight,\n 4,\n );\n return Math.max(zoom, 0.01);\n }\n\n /**\n * The CSS for a rotation hint: the turn about the centre, at the current\n * zoom. When the turned preview lands, `draw` keeps that zoom (see\n * `turned`), so the render lands on top of the hint.\n */\n private rotateHint(): string {\n const a = this.hintRotate;\n if (!a) return '';\n return `rotate(${(a * 180) / Math.PI}deg)`;\n }\n\n /**\n * The preview now shows another view of the same source (a tool switched\n * between cropped and uncropped, a resize changed the output). Keep the\n * source pixel under the view centre where it was and keep its size on\n * screen, instead of fitting and letting the image jump. A view that was\n * fitted is fitted again only when the steady view would overflow.\n */\n private reanchor(prev: Affine, next: Affine, keepZoom = false): void {\n const r = this.getBoundingClientRect();\n const cx = r.width / 2;\n const cy = r.height / 2;\n const centre = apply(prev, (cx - this.pan.x) / this.zoom, (cy - this.pan.y) / this.zoom);\n const q = apply(invert(next), centre.x, centre.y);\n const zoom = Math.min(16, Math.max(0.05, (this.zoom * scaleOf(prev)) / scaleOf(next)));\n const iw = this.imageWidth * zoom;\n const ih = this.imageHeight * zoom;\n if (!keepZoom && this.fitted && (iw > r.width || ih > r.height)) {\n this.fit();\n return;\n }\n // No glide here on purpose: the point of re-anchoring is that the source\n // region does not appear to move at all. Animating it would show a slide\n // where the contract is that nothing happened.\n this.glide = false;\n this.zoom = zoom;\n this.pan = this.clampPan({ x: cx - q.x * zoom, y: cy - q.y * zoom });\n this.fitted = Math.abs(zoom - this.fitZoom()) < 1e-3;\n this.requestUpdate();\n this.viewChanged();\n }\n\n /** True when the zoomed image is larger than the view in at least one axis. */\n private overflows(): boolean {\n const r = this.getBoundingClientRect();\n return this.imageWidth * this.zoom > r.width || this.imageHeight * this.zoom > r.height;\n }\n\n /**\n * Keeps the image in view: an image smaller than the view stays fully\n * visible, a larger one never shows empty space beyond its edges.\n */\n private clampPan(pan: { x: number; y: number }): { x: number; y: number } {\n const r = this.getBoundingClientRect();\n const iw = this.imageWidth * this.zoom;\n const ih = this.imageHeight * this.zoom;\n if (!iw || !ih) return pan;\n const axis = (v: number, size: number, view: number) =>\n size <= view ? clamp(v, 0, view - size) : clamp(v, view - size, 0);\n return { x: axis(pan.x, iw, r.width), y: axis(pan.y, ih, r.height) };\n }\n\n private panBy(dx: number, dy: number): void {\n const next = this.clampPan({ x: this.pan.x + dx, y: this.pan.y + dy });\n if (next.x === this.pan.x && next.y === this.pan.y) return;\n this.glide = false;\n this.glidePending = false;\n this.pan = next;\n this.requestUpdate();\n this.viewChanged();\n }\n\n /** Zoom or pan changed: overlays scale their gizmos by zoom and must re-render. */\n private viewChanged(): void {\n this.dispatchEvent(\n new CustomEvent('stage-view', { detail: { zoom: this.zoom, pan: this.pan } }),\n );\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.resizeObserver = new ResizeObserver(() => {\n if (this.fitted) this.fit();\n });\n this.resizeObserver.observe(this);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.resizeObserver?.disconnect();\n }\n\n override firstUpdated(): void {\n this.canvas = this.renderRoot.querySelector('canvas');\n this.gestures.attach(this.renderRoot.querySelector('.viewport') as HTMLElement);\n }\n\n override updated(changed: Map<string, unknown>): void {\n if (changed.has('preview')) this.draw();\n }\n\n private draw(): void {\n const canvas = this.canvas;\n const preview = this.preview;\n if (!canvas || !preview) return;\n const { image } = preview;\n const sizeChanged = canvas.width !== image.width || canvas.height !== image.height;\n if (sizeChanged) {\n canvas.width = image.width;\n canvas.height = image.height;\n }\n // A rotation hint says the geometry change about to land is a turn: the\n // view then keeps its zoom, so the image and the crop frame stay where the\n // hint showed them, instead of fitting the larger box and shrinking both.\n const turned = this.hintRotate !== 0;\n if (preview.version !== this.drawnVersion || sizeChanged) {\n const ctx = canvas.getContext('2d');\n if (ctx) {\n const data = new Uint8ClampedArray(image.data.byteLength);\n data.set(image.data);\n ctx.putImageData(new ImageData(data, image.width, image.height), 0, 0);\n }\n this.drawnVersion = preview.version;\n // A real preview landed: drop tier-A hints.\n this.hintFilter = '';\n this.hintTransform = '';\n this.hintRotate = 0;\n }\n const nextMap = previewToSource(preview.viewGeometry);\n const prevMap = this.viewMap;\n this.viewMap = nextMap;\n if (this.glidePending) {\n // A tool asked to be seen. Fit rather than re-anchor: a crop that just\n // took half the image away should end up filling the stage, which is\n // what makes the move read as the crop closing.\n this.glidePending = false;\n this.fit(true);\n } else if (prevMap && !sameAffine(prevMap, nextMap)) this.reanchor(prevMap, nextMap, turned);\n else if (!prevMap || (!this.fitted && sizeChanged)) this.fit();\n }\n\n private zoomAround(factor: number, cx: number, cy: number, dx: number, dy: number): void {\n const next = Math.min(16, Math.max(0.05, this.zoom * factor));\n const k = next / this.zoom;\n this.glide = false;\n this.glidePending = false;\n this.zoom = next;\n this.pan = this.clampPan({\n x: cx - (cx - this.pan.x) * k + dx,\n y: cy - (cy - this.pan.y) * k + dy,\n });\n this.fitted = false;\n this.requestUpdate();\n this.viewChanged();\n }\n\n override render() {\n const w = this.imageWidth;\n const h = this.imageHeight;\n const transform = `translate(${this.pan.x}px, ${this.pan.y}px) scale(${this.zoom})`;\n const hint = this.hintTransform || this.rotateHint();\n return html`\n <div class=\"viewport\" part=\"viewport\">\n <div class=\"content ${this.glide ? 'glide' : ''}\" style=\"transform:${transform}\">\n <canvas\n part=\"canvas\"\n width=${w}\n height=${h}\n style=\"filter:${this.hintFilter || 'none'};transform:${hint || 'none'};clip-path:${this.clip || 'none'}\"\n role=\"img\"\n aria-label=\"preview\"\n ></canvas>\n ${\n this.overlay\n ? svg`<svg class=\"overlay\" part=\"overlay\" width=${w} height=${h} viewBox=\"0 0 ${w} ${h}\">${this.overlay}</svg>`\n : null\n }\n </div>\n </div>\n ${this.pending ? html`<div class=\"pending\" aria-hidden=\"true\"></div>` : null}\n <button\n type=\"button\"\n class=\"status\"\n part=\"status\"\n ?disabled=${this.fitted}\n title=${this.t('stage.fit')}\n aria-label=${`${this.t('stage.zoom', { percent: Math.round(this.zoom * 100) })}. ${this.t('stage.fit')}`}\n @click=${() => this.fit(true)}\n >${Math.round(this.zoom * 100)}%</button>\n `;\n }\n}\n\nfunction clamp(v: number, lo: number, hi: number): number {\n return v < lo ? lo : v > hi ? hi : v;\n}\n"]}
1
+ {"version":3,"file":"sealpixel-stage.js","sourceRoot":"","sources":["../../src/components/sealpixel-stage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAuB,MAAM,KAAK,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAEL,KAAK,EACL,MAAM,EACN,eAAe,EACf,UAAU,EACV,OAAO,GACR,MAAM,oBAAoB,CAAC;AAG5B,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;aAC5B,WAAM,GAAG;QACvB,IAAI;QACJ,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6HF;KACF,AAhIqB,CAgIpB;aAEc,eAAU,GAAG;QAC3B,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QAC7B,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;QAC1B,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QAC7B,UAAU,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QAChC,aAAa,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QACnC,UAAU,EAAE,EAAE,SAAS,EAA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,CAAC;qBACA,CAAC;4BACM,IAAI,CAAC,UAAU,IAAI,MAAM,cAAc,IAAI,IAAI,MAAM,cAAc,IAAI,CAAC,IAAI,IAAI,MAAM;;;;YAKtG,IAAI,CAAC,OAAO;YACV,CAAC,CAAC,GAAG,CAAA,6CAA6C,CAAC,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,QAAQ;YAC/G,CAAC,CAAC,IACN;;;QAGF,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA,gDAAgD,CAAC,CAAC,CAAC,IAAI;;;;;oBAK9D,IAAI,CAAC,MAAM;gBACf,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC;qBACd,GAAG,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE;iBAC/F,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;SAC5B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;KAC/B,CAAC;IACJ,CAAC;;AAGH,SAAS,KAAK,CAAC,CAAS,EAAE,EAAU,EAAE,EAAU;IAC9C,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { Geometry, PreviewState } from '@sealpixel/core';\nimport { css, html, LitElement, svg, type TemplateResult } from 'lit';\nimport { GestureController } from '../controllers/gesture-controller.js';\nimport { base } from '../theme.js';\nimport {\n type Affine,\n apply,\n invert,\n previewToSource,\n sameAffine,\n scaleOf,\n} from '../view-mapping.js';\n\ntype Translate = (key: string, params?: Record<string, string | number>) => string;\nconst DOUBLE_TAP_MS = 350;\nconst DOUBLE_TAP_PX = 24;\n\n/**\n * Shows the preview on a canvas, fitted and zoomable, with an SVG overlay in\n * image pixel coordinates for tool gizmos. Tier-A hints (CSS filter and\n * transform) are applied to the canvas until the next preview arrives.\n */\nexport class SealpixelStage extends LitElement {\n static override styles = [\n base,\n css`\n :host {\n display: block;\n position: relative;\n overflow: hidden;\n background-color: var(--sealpixel-color-bg);\n background-image:\n linear-gradient(45deg, var(--sealpixel-stage-checker-a) 25%, transparent 25%),\n linear-gradient(-45deg, var(--sealpixel-stage-checker-a) 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, var(--sealpixel-stage-checker-a) 75%),\n linear-gradient(-45deg, transparent 75%, var(--sealpixel-stage-checker-a) 75%);\n background-size: 16px 16px;\n background-position: 0 0, 0 8px, 8px -8px, -8px 0;\n touch-action: none;\n user-select: none;\n }\n /*\n * The first preview fades in over the checker instead of cutting in:\n * the image arrives, it does not pop. Later previews draw straight onto\n * the canvas, so only the first one is a reveal. The fade sits on the\n * viewport, so the content's own transition stays the glide and nothing\n * else.\n */\n .viewport {\n position: absolute;\n inset: 0;\n opacity: 0;\n transition: opacity var(--sealpixel-duration-slow) var(--sealpixel-ease-out);\n }\n .viewport.revealed {\n opacity: 1;\n }\n .content {\n position: absolute;\n left: 0;\n top: 0;\n transform-origin: 0 0;\n will-change: transform;\n }\n /*\n * Only a view the user did not drag glides: a fit, a double tap, a\n * re-anchor after the geometry changed. A pinch, a wheel and a drag must\n * track the pointer exactly, so they clear the class in the same update\n * that writes the new transform and the image never lags behind a finger.\n */\n .content.glide {\n transition: transform var(--sealpixel-duration-slow) var(--sealpixel-ease-out);\n }\n canvas {\n display: block;\n image-rendering: auto;\n transform-origin: 50% 50%;\n box-shadow: var(--sealpixel-shadow, none);\n transition: clip-path var(--sealpixel-duration-slow) var(--sealpixel-ease-out);\n }\n svg.overlay {\n position: absolute;\n left: 0;\n top: 0;\n overflow: visible;\n pointer-events: none;\n }\n svg.overlay [data-interactive] {\n pointer-events: all;\n }\n /* The outline from the base styles scales with the zoom on an SVG shape;\n the stroke stays put and every engine paints it. */\n svg.overlay [tabindex]:focus-visible {\n stroke: var(--sealpixel-color-focus);\n }\n .status {\n position: absolute;\n right: var(--sealpixel-space);\n bottom: var(--sealpixel-space);\n padding: 3px 9px;\n border: 0;\n border-radius: 999px;\n background: color-mix(in srgb, var(--sealpixel-color-surface) 85%, transparent);\n color: var(--sealpixel-color-fg-muted);\n font: inherit;\n font-size: 12px;\n font-variant-numeric: tabular-nums;\n backdrop-filter: blur(6px);\n cursor: pointer;\n transition:\n color var(--sealpixel-transition),\n background var(--sealpixel-transition),\n opacity var(--sealpixel-duration) var(--sealpixel-ease);\n }\n /* Fitted means the button does nothing; it fades back rather than vanishing. */\n .status:disabled {\n cursor: default;\n opacity: 0.55;\n }\n .status:not(:disabled):hover {\n color: var(--sealpixel-color-fg);\n background: color-mix(in srgb, var(--sealpixel-color-surface) 96%, transparent);\n }\n .status:focus-visible {\n outline: 2px solid var(--sealpixel-color-focus);\n outline-offset: 2px;\n }\n /*\n * A full render is in flight. The dot breathes instead of sitting still,\n * because a static dot is read as part of the image. It starts at the\n * resting opacity, so a render that finishes within one frame does not\n * flash.\n */\n .pending {\n position: absolute;\n left: var(--sealpixel-space);\n top: var(--sealpixel-space);\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background: var(--sealpixel-color-accent);\n opacity: 0.8;\n animation: sealpixel-pending 1.4s var(--sealpixel-ease) infinite;\n }\n @keyframes sealpixel-pending {\n 50% {\n opacity: 0.25;\n transform: scale(0.7);\n }\n }\n `,\n ];\n\n static override properties = {\n preview: { attribute: false },\n pending: { type: Boolean },\n overlay: { attribute: false },\n hintFilter: { attribute: false },\n hintTransform: { attribute: false },\n hintRotate: { attribute: false },\n clip: { attribute: false },\n zoom: { type: Number },\n panEnabled: { type: Boolean },\n t: { attribute: false },\n revealed: { type: Boolean, state: true },\n };\n\n declare preview: PreviewState | null;\n declare pending: boolean;\n /** The first preview has been drawn; the content is shown. */\n declare revealed: boolean;\n declare overlay: TemplateResult | null;\n declare hintFilter: string;\n declare hintTransform: string;\n /** A rotation hint in radians. Zero is none. While set, the next preview keeps the zoom. */\n declare hintRotate: number;\n /**\n * A CSS shape the preview is clipped to, or an empty string. A tool uses it\n * to take pixels away rather than paint over them: crop clips to its\n * rectangle so the stage's own backdrop shows around the result, which is\n * the only way the checker carries through without seams. Unlike a hint it\n * survives the next preview, because the tool owns it.\n */\n declare clip: string;\n declare zoom: number;\n declare panEnabled: boolean;\n declare t: Translate;\n\n private canvas: HTMLCanvasElement | null = null;\n private drawnVersion = -1;\n private pan = { x: 0, y: 0 };\n private fitted = false;\n /** Preview px → source px of the drawn preview; a change means the stage shows another view. */\n private viewMap: Affine | null = null;\n private lastTap: { x: number; y: number; at: number } | null = null;\n /**\n * True while the next transform should be animated. Every path that moves the\n * view sets it, so it can never linger from an earlier action into a drag.\n */\n private glide = false;\n /**\n * Set by a tool that wants the next preview to arrive as a movement rather\n * than a cut. Crop uses it: leaving the tool is the moment the image really\n * becomes the crop, and seeing it close is the only signal the user gets\n * that anything happened.\n */\n private glidePending = false;\n private resizeObserver: ResizeObserver | null = null;\n private readonly gestures = new GestureController(this, {\n drag: (e) => {\n if (!this.panEnabled) return;\n this.panBy(e.dx, e.dy);\n },\n // A second tap close to the first fits the image again (double-tap, double-click).\n tap: (e) => {\n const now = performance.now();\n const prev = this.lastTap;\n if (\n prev &&\n now - prev.at < DOUBLE_TAP_MS &&\n Math.hypot(e.x - prev.x, e.y - prev.y) < DOUBLE_TAP_PX\n ) {\n this.lastTap = null;\n this.fit(true);\n return;\n }\n this.lastTap = { x: e.x, y: e.y, at: now };\n },\n pinch: (e) => this.zoomAround(e.scale, e.cx, e.cy, e.dx, e.dy),\n wheelZoom: (e) => this.zoomAround(e.factor, e.cx, e.cy, 0, 0),\n // Plain scrolling pans only while the image is larger than the view;\n // otherwise the page scrolls as the user expects.\n wheelPan: (e) => {\n if (!this.overflows()) return false;\n this.panBy(e.dx, e.dy);\n return true;\n },\n });\n\n constructor() {\n super();\n this.preview = null;\n this.pending = false;\n this.revealed = false;\n this.overlay = null;\n this.hintFilter = '';\n this.hintTransform = '';\n this.hintRotate = 0;\n this.clip = '';\n this.zoom = 1;\n this.panEnabled = true;\n this.t = (key) => key;\n }\n\n get geometry(): Geometry | null {\n return this.preview?.geometry ?? null;\n }\n\n get imageWidth(): number {\n return this.preview?.image.width ?? 0;\n }\n\n get imageHeight(): number {\n return this.preview?.image.height ?? 0;\n }\n\n /** Converts a client point into preview image pixels. */\n toImage(clientX: number, clientY: number): { x: number; y: number } {\n const r = this.getBoundingClientRect();\n return {\n x: (clientX - r.left - this.pan.x) / this.zoom,\n y: (clientY - r.top - this.pan.y) / this.zoom,\n };\n }\n\n /** Asks for the next preview-driven view change to be animated, once. */\n glideNextView(): void {\n this.glidePending = true;\n }\n\n /** `glide` animates the move; a resize or a first load must not animate. */\n fit(glide = false): void {\n const w = this.imageWidth;\n const h = this.imageHeight;\n if (!w || !h) return;\n this.glide = glide;\n const r = this.getBoundingClientRect();\n this.zoom = this.fitZoom();\n this.pan = { x: (r.width - w * this.zoom) / 2, y: (r.height - h * this.zoom) / 2 };\n this.fitted = true;\n this.requestUpdate();\n this.viewChanged();\n }\n\n private fitZoom(): number {\n const r = this.getBoundingClientRect();\n const margin = 24;\n const zoom = Math.min(\n (r.width - margin) / this.imageWidth,\n (r.height - margin) / this.imageHeight,\n 4,\n );\n return Math.max(zoom, 0.01);\n }\n\n /**\n * The CSS for a rotation hint: the turn about the centre, at the current\n * zoom. When the turned preview lands, `draw` keeps that zoom (see\n * `turned`), so the render lands on top of the hint.\n */\n private rotateHint(): string {\n const a = this.hintRotate;\n if (!a) return '';\n return `rotate(${(a * 180) / Math.PI}deg)`;\n }\n\n /**\n * The preview now shows another view of the same source (a tool switched\n * between cropped and uncropped, a resize changed the output). Keep the\n * source pixel under the view centre where it was and keep its size on\n * screen, instead of fitting and letting the image jump. A view that was\n * fitted is fitted again only when the steady view would overflow.\n */\n private reanchor(prev: Affine, next: Affine, keepZoom = false): void {\n const r = this.getBoundingClientRect();\n const cx = r.width / 2;\n const cy = r.height / 2;\n const centre = apply(prev, (cx - this.pan.x) / this.zoom, (cy - this.pan.y) / this.zoom);\n const q = apply(invert(next), centre.x, centre.y);\n const zoom = Math.min(16, Math.max(0.05, (this.zoom * scaleOf(prev)) / scaleOf(next)));\n const iw = this.imageWidth * zoom;\n const ih = this.imageHeight * zoom;\n if (!keepZoom && this.fitted && (iw > r.width || ih > r.height)) {\n this.fit();\n return;\n }\n // No glide here on purpose: the point of re-anchoring is that the source\n // region does not appear to move at all. Animating it would show a slide\n // where the contract is that nothing happened.\n this.glide = false;\n this.zoom = zoom;\n this.pan = this.clampPan({ x: cx - q.x * zoom, y: cy - q.y * zoom });\n this.fitted = Math.abs(zoom - this.fitZoom()) < 1e-3;\n this.requestUpdate();\n this.viewChanged();\n }\n\n /** True when the zoomed image is larger than the view in at least one axis. */\n private overflows(): boolean {\n const r = this.getBoundingClientRect();\n return this.imageWidth * this.zoom > r.width || this.imageHeight * this.zoom > r.height;\n }\n\n /**\n * Keeps the image in view: an image smaller than the view stays fully\n * visible, a larger one never shows empty space beyond its edges.\n */\n private clampPan(pan: { x: number; y: number }): { x: number; y: number } {\n const r = this.getBoundingClientRect();\n const iw = this.imageWidth * this.zoom;\n const ih = this.imageHeight * this.zoom;\n if (!iw || !ih) return pan;\n const axis = (v: number, size: number, view: number) =>\n size <= view ? clamp(v, 0, view - size) : clamp(v, view - size, 0);\n return { x: axis(pan.x, iw, r.width), y: axis(pan.y, ih, r.height) };\n }\n\n private panBy(dx: number, dy: number): void {\n const next = this.clampPan({ x: this.pan.x + dx, y: this.pan.y + dy });\n if (next.x === this.pan.x && next.y === this.pan.y) return;\n this.glide = false;\n this.glidePending = false;\n this.pan = next;\n this.requestUpdate();\n this.viewChanged();\n }\n\n /** Zoom or pan changed: overlays scale their gizmos by zoom and must re-render. */\n private viewChanged(): void {\n this.dispatchEvent(\n new CustomEvent('stage-view', { detail: { zoom: this.zoom, pan: this.pan } }),\n );\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.resizeObserver = new ResizeObserver(() => {\n if (this.fitted) this.fit();\n });\n this.resizeObserver.observe(this);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.resizeObserver?.disconnect();\n }\n\n override firstUpdated(): void {\n this.canvas = this.renderRoot.querySelector('canvas');\n this.gestures.attach(this.renderRoot.querySelector('.viewport') as HTMLElement);\n }\n\n override updated(changed: Map<string, unknown>): void {\n if (changed.has('preview')) this.draw();\n }\n\n private draw(): void {\n const canvas = this.canvas;\n const preview = this.preview;\n if (!canvas || !preview) return;\n const { image } = preview;\n const sizeChanged = canvas.width !== image.width || canvas.height !== image.height;\n if (sizeChanged) {\n canvas.width = image.width;\n canvas.height = image.height;\n }\n // A rotation hint says the geometry change about to land is a turn: the\n // view then keeps its zoom, so the image and the crop frame stay where the\n // hint showed them, instead of fitting the larger box and shrinking both.\n const turned = this.hintRotate !== 0;\n if (preview.version !== this.drawnVersion || sizeChanged) {\n const ctx = canvas.getContext('2d');\n if (ctx) {\n const data = new Uint8ClampedArray(image.data.byteLength);\n data.set(image.data);\n ctx.putImageData(new ImageData(data, image.width, image.height), 0, 0);\n }\n this.drawnVersion = preview.version;\n this.revealed = true;\n // A real preview landed: drop tier-A hints.\n this.hintFilter = '';\n this.hintTransform = '';\n this.hintRotate = 0;\n }\n const nextMap = previewToSource(preview.viewGeometry);\n const prevMap = this.viewMap;\n this.viewMap = nextMap;\n if (this.glidePending) {\n // A tool asked to be seen. Fit rather than re-anchor: a crop that just\n // took half the image away should end up filling the stage, which is\n // what makes the move read as the crop closing.\n this.glidePending = false;\n this.fit(true);\n } else if (prevMap && !sameAffine(prevMap, nextMap)) this.reanchor(prevMap, nextMap, turned);\n else if (!prevMap || (!this.fitted && sizeChanged)) this.fit();\n }\n\n private zoomAround(factor: number, cx: number, cy: number, dx: number, dy: number): void {\n const next = Math.min(16, Math.max(0.05, this.zoom * factor));\n const k = next / this.zoom;\n this.glide = false;\n this.glidePending = false;\n this.zoom = next;\n this.pan = this.clampPan({\n x: cx - (cx - this.pan.x) * k + dx,\n y: cy - (cy - this.pan.y) * k + dy,\n });\n this.fitted = false;\n this.requestUpdate();\n this.viewChanged();\n }\n\n override render() {\n const w = this.imageWidth;\n const h = this.imageHeight;\n const transform = `translate(${this.pan.x}px, ${this.pan.y}px) scale(${this.zoom})`;\n const hint = this.hintTransform || this.rotateHint();\n return html`\n <div class=\"viewport ${this.revealed ? 'revealed' : ''}\" part=\"viewport\">\n <div class=\"content ${this.glide ? 'glide' : ''}\" style=\"transform:${transform}\">\n <canvas\n part=\"canvas\"\n width=${w}\n height=${h}\n style=\"filter:${this.hintFilter || 'none'};transform:${hint || 'none'};clip-path:${this.clip || 'none'}\"\n role=\"img\"\n aria-label=\"preview\"\n ></canvas>\n ${\n this.overlay\n ? svg`<svg class=\"overlay\" part=\"overlay\" width=${w} height=${h} viewBox=\"0 0 ${w} ${h}\">${this.overlay}</svg>`\n : null\n }\n </div>\n </div>\n ${this.pending ? html`<div class=\"pending\" aria-hidden=\"true\"></div>` : null}\n <button\n type=\"button\"\n class=\"status\"\n part=\"status\"\n ?disabled=${this.fitted}\n title=${this.t('stage.fit')}\n aria-label=${`${this.t('stage.zoom', { percent: Math.round(this.zoom * 100) })}. ${this.t('stage.fit')}`}\n @click=${() => this.fit(true)}\n >${Math.round(this.zoom * 100)}%</button>\n `;\n }\n}\n\nfunction clamp(v: number, lo: number, hi: number): number {\n return v < lo ? lo : v > hi ? hi : v;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealpixel/ui",
3
- "version": "1.0.0-rc.16",
3
+ "version": "1.0.0-rc.17",
4
4
  "description": "Default, themeable Sealpixel editor UI as Web Components (Lit). Optional: the core is headless.",
5
5
  "license": "BUSL-1.1",
6
6
  "repository": {