@things-factory/figure-ui 10.1.263 → 10.1.266

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/client/graphql/index.ts +14 -5
  2. package/client/graphql/store.ts +1 -1
  3. package/client/modeller/align.ts +13 -1
  4. package/client/modeller/clips.ts +90 -1
  5. package/client/modeller/editor-styles.ts +36 -0
  6. package/client/modeller/editor.ts +53 -6
  7. package/client/modeller/figure-clips.ts +82 -34
  8. package/client/modeller/joint-drag.ts +32 -2
  9. package/client/modeller/product-session.ts +53 -5
  10. package/client/modeller/refusals.ts +23 -0
  11. package/dist-client/graphql/index.d.ts +7 -1
  12. package/dist-client/graphql/index.js +7 -5
  13. package/dist-client/graphql/index.js.map +1 -1
  14. package/dist-client/graphql/store.js +1 -1
  15. package/dist-client/graphql/store.js.map +1 -1
  16. package/dist-client/modeller/align.d.ts +5 -0
  17. package/dist-client/modeller/align.js +10 -1
  18. package/dist-client/modeller/align.js.map +1 -1
  19. package/dist-client/modeller/clips.d.ts +58 -6
  20. package/dist-client/modeller/clips.js +89 -0
  21. package/dist-client/modeller/clips.js.map +1 -1
  22. package/dist-client/modeller/editor-styles.js +36 -0
  23. package/dist-client/modeller/editor-styles.js.map +1 -1
  24. package/dist-client/modeller/editor.d.ts +7 -0
  25. package/dist-client/modeller/editor.js +58 -5
  26. package/dist-client/modeller/editor.js.map +1 -1
  27. package/dist-client/modeller/figure-clips.d.ts +13 -1
  28. package/dist-client/modeller/figure-clips.js +87 -34
  29. package/dist-client/modeller/figure-clips.js.map +1 -1
  30. package/dist-client/modeller/joint-drag.d.ts +21 -2
  31. package/dist-client/modeller/joint-drag.js +20 -1
  32. package/dist-client/modeller/joint-drag.js.map +1 -1
  33. package/dist-client/modeller/links.d.ts +1 -1
  34. package/dist-client/modeller/product-session.d.ts +14 -2
  35. package/dist-client/modeller/product-session.js +43 -3
  36. package/dist-client/modeller/product-session.js.map +1 -1
  37. package/dist-client/modeller/refusals.d.ts +5 -0
  38. package/dist-client/modeller/refusals.js +22 -1
  39. package/dist-client/modeller/refusals.js.map +1 -1
  40. package/dist-client/route.d.ts +1 -1
  41. package/dist-client/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +8 -8
  43. package/test/align.test.ts +18 -0
  44. package/test/clips.test.ts +83 -0
  45. package/test/data-motion.test.ts +13 -4
  46. package/test/joint-drag.test.ts +49 -0
  47. package/test/joint-frames.test.ts +3 -2
  48. package/test/product-session.test.ts +98 -0
  49. package/translations/en.json +24 -2
  50. package/translations/es.json +24 -2
  51. package/translations/ja.json +24 -2
  52. package/translations/ko.json +24 -2
  53. package/translations/ms.json +24 -2
  54. package/translations/zh.json +24 -2
@@ -108,6 +108,18 @@ export function freeClipNameOf(asset, clip) {
108
108
  export const copyTargetsOf = (asset, clip) => [
109
109
  ...new Set([...(asset.drivers ?? []).filter(d => d.clip === clip).map(d => d.state), ...undrivenOf(asset, clip)])
110
110
  ];
111
+ /**
112
+ * Where a smooth track may be moved round its loop to, in seconds later, when `seconds` is not one of them: figure-model
113
+ * moves a smooth track only so that its new start is one of its keys (`driver-shift-off-key`). Null when it may go there.
114
+ */
115
+ export function shiftOffKeyOf(track, duration, seconds) {
116
+ if (track.interpolation !== 'smooth' || !seconds)
117
+ return null;
118
+ const D = duration;
119
+ const phase = ((seconds % D) + D) % D;
120
+ const fits = [...new Set(track.keys.map(k => round((D - k.seconds) % D)))].sort((a, b) => a - b);
121
+ return fits.some(s => Math.abs(s - phase) < 1e-6) ? null : fits;
122
+ }
111
123
  /** Whether a track can be moved round its loop: one that wraps and does not add up (figure-model's rule). */
112
124
  export const shiftable = (track) => track.loop === 'wrap' && !track.accumulates;
113
125
  /**
@@ -135,4 +147,81 @@ export const trackEdit = (clip, track, patch = {}) => ({
135
147
  loop: patch.loop ?? track.loop,
136
148
  interpolation: patch.interpolation ?? track.interpolation
137
149
  });
150
+ /** Whether two control values are one: the figure's numbers carry float noise past a millionth. */
151
+ const same = (a, b) => Math.abs(a - b) < 1e-6;
152
+ /**
153
+ * A new track's keys. By default it holds the pose the figure stands in now, from start to end: a track added to a pose
154
+ * made with care does not throw it to the control's ends (review 2026-11-09). `range` is the preset that swings the
155
+ * control over its whole range and back, so the loop closes where it began.
156
+ */
157
+ export function newTrackKeys(input, current, duration, how = 'hold') {
158
+ const min = input.min ?? 0;
159
+ const max = input.max ?? min;
160
+ if (how === 'range')
161
+ return [{ seconds: 0, value: min }, { seconds: round(duration / 2), value: max }, { seconds: duration, value: min }];
162
+ const value = current ?? min;
163
+ return [{ seconds: 0, value }, { seconds: duration, value }];
164
+ }
165
+ /**
166
+ * The edits that make a new clip `clip` with one track on `state` (ADR-0051 §3.2: only clips of one motion group play
167
+ * one control). A control no clip plays is taken as it is. A control a group's clips play puts the new clip in that
168
+ * group. A control one clip in no group plays makes a group of that clip and the new one -- the person adds 「열기」 to a
169
+ * door that has 「닫기」, and the two become one group, one playing at a time, without having to design the group first.
170
+ * All of it one step of the history.
171
+ */
172
+ export function newClipEdits(asset, state, clip, duration, keys) {
173
+ const track = { kind: 'set-driver', state, clip, duration, keys };
174
+ const writers = [...new Set((asset.drivers ?? []).filter(d => d.state === state).map(d => d.clip))];
175
+ if (!writers.length)
176
+ return { edits: [track], join: { kind: 'free' } };
177
+ const group = (asset.motionGroups ?? []).find(g => writers.some(c => g.clips.includes(c)));
178
+ if (group)
179
+ return { edits: [{ ...track, group: group.id }], join: { kind: 'group', group: group.id, label: group.label } };
180
+ const id = freeGroupIdOf(asset);
181
+ const label = asset.stateInputs?.[state]?.label ?? state;
182
+ const other = writers[0];
183
+ return {
184
+ edits: [{ kind: 'set-motion-group', group: { id, label, clips: [other], defaultClip: other, transitionSeconds: 0.2 } }, { ...track, group: id }],
185
+ join: { kind: 'new-group', group: id, label, clip: other }
186
+ };
187
+ }
188
+ /**
189
+ * 「이 자세 기억하기」: the pose the figure stands in now, kept in `clip` at `seconds` in one step (review 2026-11-09:
190
+ * a six-axis pose was six tracks keyed one by one). A track whose value there differs gets a key; a control the clip
191
+ * does not play yet and that moved since `base` -- the pose the clip was last shown or kept in -- gets a track that
192
+ * starts from where it was and reaches the pose at that moment (from the start when the moment is 0). A moved control
193
+ * another clip outside this clip's group plays is not taken; it is named in `skipped`.
194
+ */
195
+ export function rememberedPoseEdits(asset, clip, seconds, values, base) {
196
+ const found = clipsOf(asset).find(c => c.name === clip);
197
+ if (!found)
198
+ return { edits: [], skipped: [] };
199
+ const at = round(Math.min(Math.max(seconds, 0), found.duration));
200
+ const there = new Map(poseAt(asset, clip, at).map(c => [c.input, c.value]));
201
+ const edits = [];
202
+ for (const track of found.tracks) {
203
+ const now = values[track.state];
204
+ if (now === undefined || same(now, there.get(track.state) ?? now))
205
+ continue;
206
+ edits.push(trackEdit(found, track, { keys: withKey(track.keys, { seconds: at, value: now }) }));
207
+ }
208
+ const free = new Set(undrivenOf(asset, clip));
209
+ const skipped = [];
210
+ const played = new Set(found.tracks.map(t => t.state));
211
+ for (const input of asset.document.model.inputs) {
212
+ if (input.role !== 'state' || played.has(input.id))
213
+ continue;
214
+ const now = values[input.id];
215
+ const was = base[input.id];
216
+ if (now === undefined || was === undefined || same(now, was))
217
+ continue;
218
+ if (!free.has(input.id)) {
219
+ skipped.push(input.id);
220
+ continue;
221
+ }
222
+ const keys = at === 0 ? [{ seconds: 0, value: now }, { seconds: found.duration, value: now }] : [{ seconds: 0, value: was }, { seconds: at, value: now }];
223
+ edits.push({ kind: 'set-driver', state: input.id, clip, keys });
224
+ }
225
+ return { edits, skipped };
226
+ }
138
227
  //# sourceMappingURL=clips.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"clips.js","sourceRoot":"","sources":["../../client/modeller/clips.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AA4B7E,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,I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E,EAAE,EAAE,CAAC,CAAC;IACnI,IAAI,EAAE,YAAqB;IAC3B,KAAK,EAAE,KAAK,CAAC,KAAK;IAClB,IAAI,EAAE,IAAI,CAAC,IAAI;IACf,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI;IAC9B,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI;IAC9B,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa;CAC1D,CAAC,CAAA","sourcesContent":["import { driverValue, figureShiftedDriverKeys } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureDriver, FigureInputChange } from '@hatiolab/figure-model'\n\n/*\n * The figure's clips: controls played by keys over time, grouped into clips that each run on one\n * clock. Kept apart from the element so the reading is tested without a browser.\n */\nexport interface ClipKey {\n seconds: number\n value: number\n}\nexport interface ClipTrack {\n state: string\n label: string\n unit: string\n min: number\n max: number\n keys: ClipKey[]\n interpolation: 'linear' | 'step'\n loop: 'wrap' | 'hold'\n accumulates: boolean\n}\nexport interface Clip {\n name: string\n duration: number\n tracks: ClipTrack[]\n}\n\nconst round = (n: number) => Math.round(n * 1000) / 1000\n\nexport function clipsOf(asset: FigureAsset): Clip[] {\n const inputs = new Map(asset.document.model.inputs.map(i => [i.id, i]))\n const clips = new Map<string, Clip>()\n for (const d of asset.drivers ?? []) {\n const input = inputs.get(d.state)\n const clip = clips.get(d.clip) ?? { name: d.clip, duration: d.time.duration, tracks: [] }\n clip.tracks.push({\n state: d.state,\n label: asset.stateInputs?.[d.state]?.label ?? d.state,\n unit: input?.unit ?? '',\n min: input?.min ?? 0,\n max: input?.max ?? 0,\n keys: d.keys.map(k => ({ seconds: round(k.at * d.time.duration), value: k.value })),\n interpolation: d.interpolation,\n loop: d.loop,\n accumulates: d.accumulates\n })\n clips.set(d.clip, clip)\n }\n return [...clips.values()]\n}\n\n/**\n * The controls a new track of `clip` can take (ADR-0051 §3.2): one the clip does not play yet, and that no clip plays\n * outside the clip's motion group -- `group` for a clip not made yet. A clip in no group takes only a control no clip\n * plays. Without a clip, the controls no clip plays at all.\n */\nexport function undrivenOf(asset: FigureAsset, clip = '', group?: string): string[] {\n const groupOf = new Map((asset.motionGroups ?? []).flatMap(g => g.clips.map(c => [c, g.id] as const)))\n const mine = group ?? (clip ? groupOf.get(clip) : undefined)\n const taken = (state: string) =>\n (asset.drivers ?? []).some(d => d.state === state && (d.clip === clip || mine === undefined || groupOf.get(d.clip) !== mine))\n return asset.document.model.inputs.filter(i => i.role === 'state' && !taken(i.id)).map(i => i.id)\n}\n\n/** A motion group as the panel shows it: its setting, and the clips it holds in the clips' order. */\nexport interface ClipGroup {\n id: string\n label: string\n clips: string[]\n defaultClip: string\n transitionSeconds: number\n}\n\n/** The figure's motion groups, and the clips in none -- the ones a group can take. */\nexport function clipGroupsOf(asset: FigureAsset): { groups: ClipGroup[]; free: string[] } {\n const groups = (asset.motionGroups ?? []).map(g => ({ ...g, clips: [...g.clips] }))\n const grouped = new Set(groups.flatMap(g => g.clips))\n const free = [...new Set((asset.drivers ?? []).map(d => d.clip))].filter(c => !grouped.has(c))\n return { groups, free }\n}\n\n/** A group id not yet taken: `motion`, then `motion-2`, `motion-3`, … An id is not made from a label a person types. */\nexport function freeGroupIdOf(asset: FigureAsset): string {\n const taken = new Set((asset.motionGroups ?? []).map(g => g.id))\n if (!taken.has('motion')) return 'motion'\n let n = 2\n while (taken.has(`motion-${n}`)) n++\n return `motion-${n}`\n}\n\n/** The edit that writes a group back with a change: one whole group, as the kernel takes it. */\nexport const groupEdit = (group: ClipGroup, patch: Partial<Omit<ClipGroup, 'id'>> = {}) => ({\n kind: 'set-motion-group' as const,\n group: { id: group.id, label: patch.label ?? group.label, clips: patch.clips ?? group.clips, defaultClip: patch.defaultClip ?? group.defaultClip, transitionSeconds: patch.transitionSeconds ?? group.transitionSeconds }\n})\n\n/** The pose a clip gives at a moment, as one batch of state changes -- one step of the history. */\nexport function poseAt(asset: FigureAsset, clip: string, seconds: number): FigureInputChange[] {\n const units = new Map(asset.document.model.inputs.map(i => [i.id, i.unit]))\n return (asset.drivers ?? [])\n .filter((d: FigureDriver) => d.clip === clip)\n .map(d => {\n const unit = units.get(d.state)!\n return { kind: 'set-state' as const, input: d.state, unit, value: driverValue(d, seconds, unit === 'deg' || unit === 'rad' ? unit : 'other') }\n })\n}\n\n/** A key added at a moment, replacing one already there; the keys stay in time order. */\nexport function withKey(keys: readonly ClipKey[], key: ClipKey): ClipKey[] {\n return [...keys.filter(k => k.seconds !== key.seconds), key].sort((a, b) => a.seconds - b.seconds)\n}\n\n/**\n * A key typed where it stands: its moment, its value, or both. The first key stays at 0 (a track starts there); a moment\n * outside the clip, or on another key's, is refused (null) rather than taking that key's place unseen.\n */\nexport function withKeyChanged(keys: readonly ClipKey[], index: number, patch: Partial<ClipKey>, duration: number): ClipKey[] | null {\n const was = keys[index]\n if (!was) return null\n const next = { seconds: patch.seconds ?? was.seconds, value: patch.value ?? was.value }\n if (!Number.isFinite(next.seconds) || !Number.isFinite(next.value)) return null\n if (index === 0 && next.seconds !== 0) return null\n if (next.seconds < 0 || next.seconds > duration) return null\n if (keys.some((k, i) => i !== index && k.seconds === next.seconds)) return null\n return keys.map((k, i) => (i === index ? next : k)).sort((a, b) => a.seconds - b.seconds)\n}\n\n/** A track's keys without one; a track keeps at least its two ends, as the format asks. */\nexport function withoutKey(keys: readonly ClipKey[], index: number): ClipKey[] | null {\n if (keys.length <= 2 || index === 0) return null\n return keys.filter((_, i) => i !== index)\n}\n\n/** A name no clip has, for a copy: `walk-copy`, then `walk-copy-2`, … */\nexport function freeClipNameOf(asset: FigureAsset, clip: string): string {\n const taken = new Set((asset.drivers ?? []).map(d => d.clip))\n const base = `${clip}-copy`\n if (!taken.has(base)) return base\n let n = 2\n while (taken.has(`${base}-${n}`)) n++\n return `${base}-${n}`\n}\n\n/** The controls a track of `clip` can be copied onto: those it plays already, and those it may take. */\nexport const copyTargetsOf = (asset: FigureAsset, clip: string): string[] => [\n ...new Set([...(asset.drivers ?? []).filter(d => d.clip === clip).map(d => d.state), ...undrivenOf(asset, clip)])\n]\n\n/** Whether a track can be moved round its loop: one that wraps and does not add up (figure-model's rule). */\nexport const shiftable = (track: ClipTrack) => track.loop === 'wrap' && !track.accumulates\n\n/**\n * A track copied onto `target` -- itself, or another control -- played `seconds` later round its loop (robot dog\n * 2026-11-03: a leg's swing half a period after another's). One edit; a track the clip plays on `target` is replaced.\n */\nexport function copiedTrackEdit(asset: FigureAsset, clip: Clip, track: ClipTrack, target: string, seconds: number) {\n const driver = (asset.drivers ?? []).find(d => d.clip === clip.name && d.state === track.state)!\n return {\n kind: 'set-driver' as const,\n state: target,\n clip: clip.name,\n keys: seconds ? figureShiftedDriverKeys(driver, seconds) : track.keys,\n loop: track.loop,\n interpolation: track.interpolation,\n accumulates: track.accumulates\n }\n}\n\n/** The edit that writes a track back. */\nexport const trackEdit = (clip: Clip, track: ClipTrack, patch: Partial<Pick<ClipTrack, 'keys' | 'loop' | 'interpolation'>> = {}) => ({\n kind: 'set-driver' as const,\n state: track.state,\n clip: clip.name,\n keys: patch.keys ?? track.keys,\n loop: patch.loop ?? track.loop,\n interpolation: patch.interpolation ?? track.interpolation\n})\n"]}
1
+ {"version":3,"file":"clips.js","sourceRoot":"","sources":["../../client/modeller/clips.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AA4B7E,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;AAExD,MAAM,UAAU,OAAO,CAAC,KAAkB;IACxC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC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AAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAChD,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAAE,SAAQ;QAC5D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC1B,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;YAAE,SAAQ;QACtE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;YACtB,SAAQ;QACV,CAAC;QACD,MAAM,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;QACzJ,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAqB,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1E,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AAC3B,CAAC","sourcesContent":["import { driverValue, figureShiftedDriverKeys } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureDriver, FigureInputChange } from '@hatiolab/figure-model'\n\n/*\n * The figure's clips: controls played by keys over time, grouped into clips that each run on one\n * clock. Kept apart from the element so the reading is tested without a browser.\n */\nexport interface ClipKey {\n seconds: number\n value: number\n}\nexport interface ClipTrack {\n state: string\n label: string\n unit: string\n min: number\n max: number\n keys: ClipKey[]\n interpolation: 'linear' | 'step' | 'smooth'\n loop: 'wrap' | 'hold'\n accumulates: boolean\n}\nexport interface Clip {\n name: string\n duration: number\n tracks: ClipTrack[]\n}\n\nconst round = (n: number) => Math.round(n * 1000) / 1000\n\nexport function clipsOf(asset: FigureAsset): Clip[] {\n const inputs = new Map(asset.document.model.inputs.map(i => [i.id, i]))\n const clips = new Map<string, Clip>()\n for (const d of asset.drivers ?? []) {\n const input = inputs.get(d.state)\n const clip = clips.get(d.clip) ?? { name: d.clip, duration: d.time.duration, tracks: [] }\n clip.tracks.push({\n state: d.state,\n label: asset.stateInputs?.[d.state]?.label ?? d.state,\n unit: input?.unit ?? '',\n min: input?.min ?? 0,\n max: input?.max ?? 0,\n keys: d.keys.map(k => ({ seconds: round(k.at * d.time.duration), value: k.value })),\n interpolation: d.interpolation,\n loop: d.loop,\n accumulates: d.accumulates\n })\n clips.set(d.clip, clip)\n }\n return [...clips.values()]\n}\n\n/**\n * The controls a new track of `clip` can take (ADR-0051 §3.2): one the clip does not play yet, and that no clip plays\n * outside the clip's motion group -- `group` for a clip not made yet. A clip in no group takes only a control no clip\n * plays. Without a clip, the controls no clip plays at all.\n */\nexport function undrivenOf(asset: FigureAsset, clip = '', group?: string): string[] {\n const groupOf = new Map((asset.motionGroups ?? []).flatMap(g => g.clips.map(c => [c, g.id] as const)))\n const mine = group ?? (clip ? groupOf.get(clip) : undefined)\n const taken = (state: string) =>\n (asset.drivers ?? []).some(d => d.state === state && (d.clip === clip || mine === undefined || groupOf.get(d.clip) !== mine))\n return asset.document.model.inputs.filter(i => i.role === 'state' && !taken(i.id)).map(i => i.id)\n}\n\n/** A motion group as the panel shows it: its setting, and the clips it holds in the clips' order. */\nexport interface ClipGroup {\n id: string\n label: string\n clips: string[]\n defaultClip: string\n transitionSeconds: number\n}\n\n/** The figure's motion groups, and the clips in none -- the ones a group can take. */\nexport function clipGroupsOf(asset: FigureAsset): { groups: ClipGroup[]; free: string[] } {\n const groups = (asset.motionGroups ?? []).map(g => ({ ...g, clips: [...g.clips] }))\n const grouped = new Set(groups.flatMap(g => g.clips))\n const free = [...new Set((asset.drivers ?? []).map(d => d.clip))].filter(c => !grouped.has(c))\n return { groups, free }\n}\n\n/** A group id not yet taken: `motion`, then `motion-2`, `motion-3`, … An id is not made from a label a person types. */\nexport function freeGroupIdOf(asset: FigureAsset): string {\n const taken = new Set((asset.motionGroups ?? []).map(g => g.id))\n if (!taken.has('motion')) return 'motion'\n let n = 2\n while (taken.has(`motion-${n}`)) n++\n return `motion-${n}`\n}\n\n/** The edit that writes a group back with a change: one whole group, as the kernel takes it. */\nexport const groupEdit = (group: ClipGroup, patch: Partial<Omit<ClipGroup, 'id'>> = {}) => ({\n kind: 'set-motion-group' as const,\n group: { id: group.id, label: patch.label ?? group.label, clips: patch.clips ?? group.clips, defaultClip: patch.defaultClip ?? group.defaultClip, transitionSeconds: patch.transitionSeconds ?? group.transitionSeconds }\n})\n\n/** The pose a clip gives at a moment, as one batch of state changes -- one step of the history. */\nexport function poseAt(asset: FigureAsset, clip: string, seconds: number): FigureInputChange[] {\n const units = new Map(asset.document.model.inputs.map(i => [i.id, i.unit]))\n return (asset.drivers ?? [])\n .filter((d: FigureDriver) => d.clip === clip)\n .map(d => {\n const unit = units.get(d.state)!\n return { kind: 'set-state' as const, input: d.state, unit, value: driverValue(d, seconds, unit === 'deg' || unit === 'rad' ? unit : 'other') }\n })\n}\n\n/** A key added at a moment, replacing one already there; the keys stay in time order. */\nexport function withKey(keys: readonly ClipKey[], key: ClipKey): ClipKey[] {\n return [...keys.filter(k => k.seconds !== key.seconds), key].sort((a, b) => a.seconds - b.seconds)\n}\n\n/**\n * A key typed where it stands: its moment, its value, or both. The first key stays at 0 (a track starts there); a moment\n * outside the clip, or on another key's, is refused (null) rather than taking that key's place unseen.\n */\nexport function withKeyChanged(keys: readonly ClipKey[], index: number, patch: Partial<ClipKey>, duration: number): ClipKey[] | null {\n const was = keys[index]\n if (!was) return null\n const next = { seconds: patch.seconds ?? was.seconds, value: patch.value ?? was.value }\n if (!Number.isFinite(next.seconds) || !Number.isFinite(next.value)) return null\n if (index === 0 && next.seconds !== 0) return null\n if (next.seconds < 0 || next.seconds > duration) return null\n if (keys.some((k, i) => i !== index && k.seconds === next.seconds)) return null\n return keys.map((k, i) => (i === index ? next : k)).sort((a, b) => a.seconds - b.seconds)\n}\n\n/** A track's keys without one; a track keeps at least its two ends, as the format asks. */\nexport function withoutKey(keys: readonly ClipKey[], index: number): ClipKey[] | null {\n if (keys.length <= 2 || index === 0) return null\n return keys.filter((_, i) => i !== index)\n}\n\n/** A name no clip has, for a copy: `walk-copy`, then `walk-copy-2`, … */\nexport function freeClipNameOf(asset: FigureAsset, clip: string): string {\n const taken = new Set((asset.drivers ?? []).map(d => d.clip))\n const base = `${clip}-copy`\n if (!taken.has(base)) return base\n let n = 2\n while (taken.has(`${base}-${n}`)) n++\n return `${base}-${n}`\n}\n\n/** The controls a track of `clip` can be copied onto: those it plays already, and those it may take. */\nexport const copyTargetsOf = (asset: FigureAsset, clip: string): string[] => [\n ...new Set([...(asset.drivers ?? []).filter(d => d.clip === clip).map(d => d.state), ...undrivenOf(asset, clip)])\n]\n\n/**\n * Where a smooth track may be moved round its loop to, in seconds later, when `seconds` is not one of them: figure-model\n * moves a smooth track only so that its new start is one of its keys (`driver-shift-off-key`). Null when it may go there.\n */\nexport function shiftOffKeyOf(track: ClipTrack, duration: number, seconds: number): number[] | null {\n if (track.interpolation !== 'smooth' || !seconds) return null\n const D = duration\n const phase = ((seconds % D) + D) % D\n const fits = [...new Set(track.keys.map(k => round((D - k.seconds) % D)))].sort((a, b) => a - b)\n return fits.some(s => Math.abs(s - phase) < 1e-6) ? null : fits\n}\n\n/** Whether a track can be moved round its loop: one that wraps and does not add up (figure-model's rule). */\nexport const shiftable = (track: ClipTrack) => track.loop === 'wrap' && !track.accumulates\n\n/**\n * A track copied onto `target` -- itself, or another control -- played `seconds` later round its loop (robot dog\n * 2026-11-03: a leg's swing half a period after another's). One edit; a track the clip plays on `target` is replaced.\n */\nexport function copiedTrackEdit(asset: FigureAsset, clip: Clip, track: ClipTrack, target: string, seconds: number) {\n const driver = (asset.drivers ?? []).find(d => d.clip === clip.name && d.state === track.state)!\n return {\n kind: 'set-driver' as const,\n state: target,\n clip: clip.name,\n keys: seconds ? figureShiftedDriverKeys(driver, seconds) : track.keys,\n loop: track.loop,\n interpolation: track.interpolation,\n accumulates: track.accumulates\n }\n}\n\n/** The edit that writes a track back. */\nexport const trackEdit = (clip: Clip, track: ClipTrack, patch: Partial<Pick<ClipTrack, 'keys' | 'loop' | 'interpolation'>> = {}) => ({\n kind: 'set-driver' as const,\n state: track.state,\n clip: clip.name,\n keys: patch.keys ?? track.keys,\n loop: patch.loop ?? track.loop,\n interpolation: patch.interpolation ?? track.interpolation\n})\n\n/** Whether two control values are one: the figure's numbers carry float noise past a millionth. */\nconst same = (a: number, b: number) => Math.abs(a - b) < 1e-6\n\n/**\n * A new track's keys. By default it holds the pose the figure stands in now, from start to end: a track added to a pose\n * made with care does not throw it to the control's ends (review 2026-11-09). `range` is the preset that swings the\n * control over its whole range and back, so the loop closes where it began.\n */\nexport function newTrackKeys(input: { min?: number; max?: number }, current: number | undefined, duration: number, how: 'hold' | 'range' = 'hold'): ClipKey[] {\n const min = input.min ?? 0\n const max = input.max ?? min\n if (how === 'range') return [{ seconds: 0, value: min }, { seconds: round(duration / 2), value: max }, { seconds: duration, value: min }]\n const value = current ?? min\n return [{ seconds: 0, value }, { seconds: duration, value }]\n}\n\n/** What a new clip on a control joins, so that it may play it: nothing, a group already there, or a group made with the clip that plays it now. */\nexport type TrackJoin = { kind: 'free' } | { kind: 'group'; group: string; label: string } | { kind: 'new-group'; group: string; label: string; clip: string }\n\n/**\n * The edits that make a new clip `clip` with one track on `state` (ADR-0051 §3.2: only clips of one motion group play\n * one control). A control no clip plays is taken as it is. A control a group's clips play puts the new clip in that\n * group. A control one clip in no group plays makes a group of that clip and the new one -- the person adds 「열기」 to a\n * door that has 「닫기」, and the two become one group, one playing at a time, without having to design the group first.\n * All of it one step of the history.\n */\nexport function newClipEdits(asset: FigureAsset, state: string, clip: string, duration: number, keys: ClipKey[]): { edits: unknown[]; join: TrackJoin } {\n const track = { kind: 'set-driver' as const, state, clip, duration, keys }\n const writers = [...new Set((asset.drivers ?? []).filter(d => d.state === state).map(d => d.clip))]\n if (!writers.length) return { edits: [track], join: { kind: 'free' } }\n const group = (asset.motionGroups ?? []).find(g => writers.some(c => g.clips.includes(c)))\n if (group) return { edits: [{ ...track, group: group.id }], join: { kind: 'group', group: group.id, label: group.label } }\n const id = freeGroupIdOf(asset)\n const label = asset.stateInputs?.[state]?.label ?? state\n const other = writers[0]!\n return {\n edits: [{ kind: 'set-motion-group' as const, group: { id, label, clips: [other], defaultClip: other, transitionSeconds: 0.2 } }, { ...track, group: id }],\n join: { kind: 'new-group', group: id, label, clip: other }\n }\n}\n\n/**\n * 「이 자세 기억하기」: the pose the figure stands in now, kept in `clip` at `seconds` in one step (review 2026-11-09:\n * a six-axis pose was six tracks keyed one by one). A track whose value there differs gets a key; a control the clip\n * does not play yet and that moved since `base` -- the pose the clip was last shown or kept in -- gets a track that\n * starts from where it was and reaches the pose at that moment (from the start when the moment is 0). A moved control\n * another clip outside this clip's group plays is not taken; it is named in `skipped`.\n */\nexport function rememberedPoseEdits(asset: FigureAsset, clip: string, seconds: number, values: Record<string, number>, base: Record<string, number>): { edits: unknown[]; skipped: string[] } {\n const found = clipsOf(asset).find(c => c.name === clip)\n if (!found) return { edits: [], skipped: [] }\n const at = round(Math.min(Math.max(seconds, 0), found.duration))\n const there = new Map(poseAt(asset, clip, at).map(c => [c.input, c.value]))\n const edits: unknown[] = []\n for (const track of found.tracks) {\n const now = values[track.state]\n if (now === undefined || same(now, there.get(track.state) ?? now)) continue\n edits.push(trackEdit(found, track, { keys: withKey(track.keys, { seconds: at, value: now }) }))\n }\n const free = new Set(undrivenOf(asset, clip))\n const skipped: string[] = []\n const played = new Set(found.tracks.map(t => t.state))\n for (const input of asset.document.model.inputs) {\n if (input.role !== 'state' || played.has(input.id)) continue\n const now = values[input.id]\n const was = base[input.id]\n if (now === undefined || was === undefined || same(now, was)) continue\n if (!free.has(input.id)) {\n skipped.push(input.id)\n continue\n }\n const keys = at === 0 ? [{ seconds: 0, value: now }, { seconds: found.duration, value: now }] : [{ seconds: 0, value: was }, { seconds: at, value: now }]\n edits.push({ kind: 'set-driver' as const, state: input.id, clip, keys })\n }\n return { edits, skipped }\n}\n"]}
@@ -132,6 +132,42 @@ export const EditorStyles = css `
132
132
  min-height: 0;
133
133
  }
134
134
  /* Which size handles change one diameter (ADR-0140 4.1): a quiet line over the canvas, out of the gizmo's way. */
135
+ /* What a drag does on the joint of the part chosen: one line under the board, its buttons quiet text (review 2026-11-09). */
136
+ p[joint-handle] {
137
+ position: absolute;
138
+ bottom: 12px;
139
+ left: 50%;
140
+ z-index: 5;
141
+ transform: translateX(-50%);
142
+ display: flex;
143
+ flex-wrap: wrap;
144
+ align-items: center;
145
+ justify-content: center;
146
+ gap: 2px 8px;
147
+ /* As wide as its words: at left 50% the line would otherwise wrap at half the board. */
148
+ width: max-content;
149
+ max-width: calc(100% - 24px);
150
+ box-sizing: border-box;
151
+ margin: 0;
152
+ padding: 4px 6px 4px 12px;
153
+ border-radius: 16px;
154
+ background: var(--md-sys-color-surface-container-high);
155
+ color: var(--md-sys-color-on-surface-variant);
156
+ font-size: var(--ui-t-small, 11.5px);
157
+ }
158
+ p[joint-handle] button {
159
+ padding: 2px 6px;
160
+ border: none;
161
+ border-radius: 4px;
162
+ background: none;
163
+ color: var(--md-sys-color-primary);
164
+ font: inherit;
165
+ font-weight: 600;
166
+ cursor: pointer;
167
+ }
168
+ p[joint-handle] button:hover {
169
+ background: var(--md-sys-color-surface-container-highest);
170
+ }
135
171
  p[same-measure] {
136
172
  position: absolute;
137
173
  bottom: 12px;
@@ -1 +1 @@
1
- {"version":3,"file":"editor-styles.js","sourceRoot":"","sources":["../../client/modeller/editor-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,gHAAgH;AAChH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoc9B,CAAA","sourcesContent":["import { css } from 'lit'\n\n/** The modeller editor's own styles: the bar's tools, the panes, the start card, the side's tabs and panels. */\nexport const EditorStyles = css`\n :host {\n position: relative;\n display: flex;\n flex-direction: column;\n min-height: 0;\n height: 100%;\n /* The editor folds by the width it is given, not the window's (UX ruling, 2026-09-24). */\n container-type: inline-size;\n /* The app's one face (its typography theme's --theme-font) at the body size: a bare sans-serif here put a second\n face under everything the editor draws, beside the parts list and the shell in the app's own (2026-10-16). */\n font-family: var(--theme-font, ui-sans-serif, system-ui, sans-serif);\n font-size: var(--ui-t-body, 13px);\n color: var(--md-sys-color-on-surface);\n }\n /* The bar over the work is ox-canvas-bar (ADR-0060 decision 8): the folds at its edges, undo, redo and\n fit in the suite's places. What the editor puts in it - the mode switch, the status, save - is styled here. */\n ox-canvas-bar button[mode] {\n /* The bar's height, beside its 32px icons and the save (sweep 2026-10-27 U25). */\n height: 32px;\n border: 1px solid transparent;\n padding: 0 10px;\n border-radius: 999em;\n border-color: transparent;\n background: none;\n }\n ox-canvas-bar button[mode][aria-pressed='true'] {\n border-color: var(--md-sys-color-primary);\n }\n /* The gizmo's tools, drawn as the bar's own icon buttons (undo, redo, fit). */\n ox-canvas-bar .gizmo-tools {\n display: inline-flex;\n gap: 2px;\n padding-left: 4px;\n border-left: 1px solid var(--md-sys-color-outline-variant);\n }\n ox-canvas-bar button[tool] {\n display: inline-grid;\n place-items: center;\n width: 32px;\n height: 32px;\n padding: 0;\n border: none;\n border-radius: var(--md-sys-shape-corner-small, 8px);\n background: transparent;\n color: var(--md-sys-color-on-surface-variant);\n cursor: pointer;\n }\n ox-canvas-bar button[tool]:hover:not(:disabled) {\n background: var(--md-sys-color-surface-container-high);\n color: var(--md-sys-color-on-surface);\n }\n ox-canvas-bar button[tool][aria-pressed='true'] {\n background: var(--md-sys-color-secondary-container);\n color: var(--md-sys-color-on-secondary-container);\n }\n ox-canvas-bar button[tool]:disabled {\n opacity: 0.38;\n cursor: default;\n }\n /*\n Slotted into the bar from here, the tools do not get the bar's own icon size (20px, set inside its shadow): they\n showed at md-icon's 24px, heavier than undo, redo and fit beside them. The same size, and the bar's focus ring.\n */\n ox-canvas-bar button[tool] md-icon {\n --md-icon-size: 20px;\n }\n ox-canvas-bar button[tool]:focus-visible {\n outline: 2px solid var(--md-sys-color-primary);\n outline-offset: 1px;\n }\n figure-preview {\n min-width: 0;\n min-height: 0;\n }\n /* The edit canvas stays standing while the preview is in front (a 3D scene costs a third of a second to make), out of sight. */\n div[middle][hidden] {\n display: none;\n }\n /* The preview, once made, stays standing out of sight too: its 3D scene is not made again each time it is asked for. */\n figure-preview[hidden] {\n display: none;\n }\n ox-canvas-bar .status {\n padding: 0 8px;\n color: var(--md-sys-color-on-surface-variant);\n }\n /*\n The bar's two commitments, one shape (user 2026-10-18: 「발행버튼도 저장버튼도 라운드 버튼으로 … 버튼 안에 적절한 아이콘」):\n round, an icon inside, so neither is taken for the other. Save, done many times a day, is the filled one; release,\n a promise to whoever draws the figure, is outlined.\n */\n ox-canvas-bar button[save],\n ox-canvas-bar button[publish] {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n height: 32px;\n padding: 0 14px 0 10px;\n border-radius: 999em;\n font-weight: 600;\n }\n ox-canvas-bar button[save] md-icon,\n ox-canvas-bar button[publish] md-icon {\n --md-icon-size: 18px;\n }\n ox-canvas-bar button[save] {\n border: 1px solid transparent;\n color: var(--md-sys-color-on-primary);\n background: var(--md-sys-color-primary);\n }\n /* The three panes are ox-three-pane's (ADR-0060 decision 8): widths 200 | 1fr | 340, 160 | 300 under\n 860px and one column with the middle first under 560px are the frame's, as are the dividers. */\n ox-three-pane {\n flex: 1;\n min-height: 0;\n }\n figure-parts {\n min-height: 0;\n }\n figure-canvas {\n flex: 1;\n min-width: 0;\n min-height: 0;\n }\n div[middle] {\n position: relative;\n display: flex;\n min-width: 0;\n min-height: 0;\n }\n /* Which size handles change one diameter (ADR-0140 4.1): a quiet line over the canvas, out of the gizmo's way. */\n p[same-measure] {\n position: absolute;\n bottom: 12px;\n left: 50%;\n z-index: 5;\n transform: translateX(-50%);\n margin: 0;\n padding: 4px 10px;\n border-radius: 999em;\n background: var(--md-sys-color-surface-container-high);\n color: var(--md-sys-color-on-surface-variant);\n font-size: var(--ui-t-small, 11.5px);\n pointer-events: none;\n white-space: nowrap;\n }\n /* A new figure's first question, over the empty canvas. */\n div[start] {\n position: absolute;\n inset: 50% auto auto 50%;\n z-index: 10;\n color: var(--md-sys-color-on-surface);\n transform: translate(-50%, -50%);\n width: min(440px, calc(100% - 32px));\n box-sizing: border-box;\n padding: 20px;\n border-radius: 12px;\n background: var(--md-sys-color-surface, #fff);\n box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);\n }\n div[start] button[start-button] {\n width: auto;\n margin: 0;\n font-size: var(--ui-t-body);\n height: 36px;\n padding: 0 16px;\n border: 1px solid var(--md-sys-color-outline);\n border-radius: 999em;\n color: var(--md-sys-color-primary);\n background: var(--md-sys-color-surface, #fff);\n cursor: pointer;\n }\n div[start] button[start-button]:hover:not(:disabled) {\n background: var(--md-sys-color-primary-container);\n }\n div[start] button[start-button][pressed] {\n color: var(--md-sys-color-on-primary);\n background: var(--md-sys-color-primary);\n border-color: var(--md-sys-color-primary);\n }\n div[start] button[start-button]:disabled {\n opacity: 0.5;\n cursor: default;\n }\n div[start] h2 {\n margin: 0 0 12px;\n font-size: var(--ui-t-title);\n }\n div[start-paths] {\n display: grid;\n gap: 14px;\n }\n div[start-paths] h3 {\n margin: 0 0 6px;\n font-size: var(--ui-t-body);\n }\n div[start-shapes] {\n display: flex;\n gap: 8px;\n flex-wrap: wrap;\n }\n div[start] small {\n display: block;\n margin-top: 4px;\n color: var(--md-sys-color-on-surface-variant);\n }\n div[start] button[start-more] {\n display: block;\n text-align: left;\n margin: 4px 0 0;\n padding: 0;\n font: inherit;\n font-size: var(--ui-t-small);\n color: var(--md-sys-color-primary);\n background: none;\n border: none;\n cursor: pointer;\n }\n /* No rule under the last way to start: it closed nothing (sweep 2026-10-27 U23). */\n div[start-paths] > section:last-of-type {\n border-bottom: none;\n }\n /* The side: tabs over one panel at a time, each using the whole height. */\n /*\n The side's words at the panel's size (side-panel-styles: titles body, the rest small). The editor's host is at body\n for the bar, and the fields the editor drew itself -- the part's name -- stood a step larger than every other field.\n */\n aside {\n display: flex;\n flex-direction: column;\n min-height: 0;\n font-size: var(--ui-t-small, 11.5px);\n background: var(--md-sys-color-surface-container-lowest);\n }\n div[tabs] {\n display: flex;\n flex: none;\n border-bottom: 1px solid var(--md-sys-color-outline-variant);\n }\n button[tab] {\n flex: 1;\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 1px;\n min-width: 0;\n height: 48px;\n padding: 0;\n border: none;\n border-radius: 0;\n border-bottom: 2px solid transparent;\n background: none;\n color: var(--md-sys-color-on-surface-variant);\n }\n button[tab]:hover:not([on]) {\n background: var(--md-sys-color-surface-container);\n }\n button[tab][on] {\n color: var(--md-sys-color-primary);\n border-bottom-color: var(--md-sys-color-primary);\n }\n button[tab] md-icon {\n font-size: 20px;\n width: 20px;\n height: 20px;\n }\n button[tab] span[tab-label] {\n max-width: 100%;\n overflow: hidden;\n font-size: var(--ui-t-micro, 11px);\n line-height: 1.2;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n /* A range's two ends read as one: smallest – largest. */\n div[pair][range] {\n align-items: center;\n }\n div[pair][range] > span[dash] {\n flex: none;\n color: var(--md-sys-color-on-surface-variant);\n }\n /* The sections inside carry the margins (side-panel-styles); the panel only scrolls. */\n div[panel] {\n flex: 1;\n min-height: 0;\n overflow: auto;\n padding: 0;\n }\n div[panel][flush] {\n padding: 0;\n }\n /* Hidden, not removed: a panel keeps what it holds (the verdict its last answer) while another tab is open. */\n [off] {\n display: none !important;\n }\n /* The part's own numbers inside a group the links draw (size, place): one column, the panel's gap. */\n div[group-fields] {\n display: grid;\n gap: 6px;\n }\n /* The folded 「더 보기」: its title is the fold's handle, at the title's size. */\n section[more] > details > summary {\n padding: 0;\n }\n section[more] > details > summary > h3 {\n margin: 0;\n }\n div[more-body] {\n display: grid;\n gap: 16px;\n margin-top: 12px;\n }\n /*\n The view settings and the release history, opened from the bar over the right of the work: neither is about the\n part chosen, so neither takes a tab beside the part's (chief architect 2026-10-16). The fastening window stands in\n the same place, over the side panel, so the canvas it previews on stays in sight (user 2026-10-19).\n */\n :host {\n position: relative;\n }\n div[side-overlay] {\n position: absolute;\n top: var(--figure-bar-height, 44px);\n right: 8px;\n z-index: 5;\n display: flex;\n flex-direction: column;\n width: min(360px, calc(100% - 16px));\n max-height: calc(100% - var(--figure-bar-height, 44px) - 16px);\n background: var(--md-sys-color-surface-container-lowest);\n border: 1px solid var(--md-sys-color-outline-variant);\n border-radius: 8px;\n box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);\n }\n div[overlay-head] {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 8px 8px 12px;\n border-bottom: 1px solid var(--md-sys-color-outline-variant);\n }\n div[overlay-head] h3 {\n margin: 0;\n }\n div[overlay-head] button[quiet] {\n margin-left: 0;\n }\n [overlay-body] {\n min-height: 0;\n overflow: auto;\n }\n /* Which part the panel speaks of. Above z-index 1: a chip's label (md-filter-chip) sits at 1 and, coming later, was\n drawn over it when the panel scrolled (sweep 2026-10-27 U2). */\n div[subject] {\n position: sticky;\n top: 0;\n z-index: 2;\n display: grid;\n gap: 4px;\n padding: 10px 12px;\n background: var(--md-sys-color-surface-container-lowest);\n border-bottom: 1px solid var(--md-sys-color-outline-variant);\n }\n /* The panel's three sizes (side-panel-styles): the part's kind at the title's, its two lines at the hint's. */\n div[subject-summary] {\n display: grid;\n gap: 2px;\n }\n div[subject-summary] b {\n font-size: var(--ui-t-body, 13px);\n font-weight: 600;\n }\n div[subject-summary] b span {\n font-weight: 400;\n color: var(--md-sys-color-on-surface-variant);\n }\n div[subject-summary] small {\n color: var(--md-sys-color-on-surface-variant);\n }\n /*\n No rule here draws every button as a box: the side's buttons take the shared panel rules (SidePanelStyles), one\n height with the fields beside them, and only the bar's publish keeps an outline (user 2026-10-16: 「버튼 박스도\n 과하게 사용되어서」 -- a bare 「button」 rule had put a 32px box round every button the editor drew).\n */\n button {\n font: inherit;\n box-sizing: border-box;\n color: inherit;\n min-width: 0;\n cursor: pointer;\n }\n /* What blocks release, beside 「발행」: one red word button, and its list under the bar. */\n ox-canvas-bar button[release-blocked] {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n height: 32px;\n padding: 0 14px 0 10px;\n border: none;\n /* Round as save and release beside it: one shape for the bar's end. */\n border-radius: 999em;\n color: var(--md-sys-color-on-error-container);\n background: var(--md-sys-color-error-container);\n }\n ox-canvas-bar button[release-blocked] md-icon {\n --md-icon-size: 18px;\n }\n div[release-blockers] {\n position: absolute;\n top: 46px;\n right: 8px;\n z-index: 6;\n width: min(340px, calc(100% - 16px));\n padding: 8px 10px 10px;\n box-sizing: border-box;\n background: var(--md-sys-color-surface);\n border: 1px solid var(--md-sys-color-outline-variant);\n border-radius: 8px;\n box-shadow: var(--md-sys-elevation-2, 0 2px 8px #0003);\n }\n ox-canvas-bar button[publish] {\n border: 1px solid var(--md-sys-color-outline);\n color: var(--md-sys-color-primary);\n background: var(--md-sys-color-surface);\n }\n ox-canvas-bar button[publish][aria-pressed='true'] {\n background: var(--md-sys-color-secondary-container);\n color: var(--md-sys-color-on-secondary-container);\n }\n button:disabled {\n opacity: 0.45;\n cursor: default;\n }\n button[aria-pressed='true'] {\n background: var(--md-sys-color-secondary-container);\n color: var(--md-sys-color-on-secondary-container);\n border-color: var(--md-sys-color-primary);\n }\n .hint {\n color: var(--md-sys-color-on-surface-variant);\n line-height: 1.5;\n }\n /* A mirror asked about: under its row, the panel's own field rows (what comes with it, its names, how it turns). */\n div[mirror-form] {\n display: grid;\n gap: 6px;\n margin: 4px 0 8px;\n }\n`\n"]}
1
+ {"version":3,"file":"editor-styles.js","sourceRoot":"","sources":["../../client/modeller/editor-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,gHAAgH;AAChH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwe9B,CAAA","sourcesContent":["import { css } from 'lit'\n\n/** The modeller editor's own styles: the bar's tools, the panes, the start card, the side's tabs and panels. */\nexport const EditorStyles = css`\n :host {\n position: relative;\n display: flex;\n flex-direction: column;\n min-height: 0;\n height: 100%;\n /* The editor folds by the width it is given, not the window's (UX ruling, 2026-09-24). */\n container-type: inline-size;\n /* The app's one face (its typography theme's --theme-font) at the body size: a bare sans-serif here put a second\n face under everything the editor draws, beside the parts list and the shell in the app's own (2026-10-16). */\n font-family: var(--theme-font, ui-sans-serif, system-ui, sans-serif);\n font-size: var(--ui-t-body, 13px);\n color: var(--md-sys-color-on-surface);\n }\n /* The bar over the work is ox-canvas-bar (ADR-0060 decision 8): the folds at its edges, undo, redo and\n fit in the suite's places. What the editor puts in it - the mode switch, the status, save - is styled here. */\n ox-canvas-bar button[mode] {\n /* The bar's height, beside its 32px icons and the save (sweep 2026-10-27 U25). */\n height: 32px;\n border: 1px solid transparent;\n padding: 0 10px;\n border-radius: 999em;\n border-color: transparent;\n background: none;\n }\n ox-canvas-bar button[mode][aria-pressed='true'] {\n border-color: var(--md-sys-color-primary);\n }\n /* The gizmo's tools, drawn as the bar's own icon buttons (undo, redo, fit). */\n ox-canvas-bar .gizmo-tools {\n display: inline-flex;\n gap: 2px;\n padding-left: 4px;\n border-left: 1px solid var(--md-sys-color-outline-variant);\n }\n ox-canvas-bar button[tool] {\n display: inline-grid;\n place-items: center;\n width: 32px;\n height: 32px;\n padding: 0;\n border: none;\n border-radius: var(--md-sys-shape-corner-small, 8px);\n background: transparent;\n color: var(--md-sys-color-on-surface-variant);\n cursor: pointer;\n }\n ox-canvas-bar button[tool]:hover:not(:disabled) {\n background: var(--md-sys-color-surface-container-high);\n color: var(--md-sys-color-on-surface);\n }\n ox-canvas-bar button[tool][aria-pressed='true'] {\n background: var(--md-sys-color-secondary-container);\n color: var(--md-sys-color-on-secondary-container);\n }\n ox-canvas-bar button[tool]:disabled {\n opacity: 0.38;\n cursor: default;\n }\n /*\n Slotted into the bar from here, the tools do not get the bar's own icon size (20px, set inside its shadow): they\n showed at md-icon's 24px, heavier than undo, redo and fit beside them. The same size, and the bar's focus ring.\n */\n ox-canvas-bar button[tool] md-icon {\n --md-icon-size: 20px;\n }\n ox-canvas-bar button[tool]:focus-visible {\n outline: 2px solid var(--md-sys-color-primary);\n outline-offset: 1px;\n }\n figure-preview {\n min-width: 0;\n min-height: 0;\n }\n /* The edit canvas stays standing while the preview is in front (a 3D scene costs a third of a second to make), out of sight. */\n div[middle][hidden] {\n display: none;\n }\n /* The preview, once made, stays standing out of sight too: its 3D scene is not made again each time it is asked for. */\n figure-preview[hidden] {\n display: none;\n }\n ox-canvas-bar .status {\n padding: 0 8px;\n color: var(--md-sys-color-on-surface-variant);\n }\n /*\n The bar's two commitments, one shape (user 2026-10-18: 「발행버튼도 저장버튼도 라운드 버튼으로 … 버튼 안에 적절한 아이콘」):\n round, an icon inside, so neither is taken for the other. Save, done many times a day, is the filled one; release,\n a promise to whoever draws the figure, is outlined.\n */\n ox-canvas-bar button[save],\n ox-canvas-bar button[publish] {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n height: 32px;\n padding: 0 14px 0 10px;\n border-radius: 999em;\n font-weight: 600;\n }\n ox-canvas-bar button[save] md-icon,\n ox-canvas-bar button[publish] md-icon {\n --md-icon-size: 18px;\n }\n ox-canvas-bar button[save] {\n border: 1px solid transparent;\n color: var(--md-sys-color-on-primary);\n background: var(--md-sys-color-primary);\n }\n /* The three panes are ox-three-pane's (ADR-0060 decision 8): widths 200 | 1fr | 340, 160 | 300 under\n 860px and one column with the middle first under 560px are the frame's, as are the dividers. */\n ox-three-pane {\n flex: 1;\n min-height: 0;\n }\n figure-parts {\n min-height: 0;\n }\n figure-canvas {\n flex: 1;\n min-width: 0;\n min-height: 0;\n }\n div[middle] {\n position: relative;\n display: flex;\n min-width: 0;\n min-height: 0;\n }\n /* Which size handles change one diameter (ADR-0140 4.1): a quiet line over the canvas, out of the gizmo's way. */\n /* What a drag does on the joint of the part chosen: one line under the board, its buttons quiet text (review 2026-11-09). */\n p[joint-handle] {\n position: absolute;\n bottom: 12px;\n left: 50%;\n z-index: 5;\n transform: translateX(-50%);\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: center;\n gap: 2px 8px;\n /* As wide as its words: at left 50% the line would otherwise wrap at half the board. */\n width: max-content;\n max-width: calc(100% - 24px);\n box-sizing: border-box;\n margin: 0;\n padding: 4px 6px 4px 12px;\n border-radius: 16px;\n background: var(--md-sys-color-surface-container-high);\n color: var(--md-sys-color-on-surface-variant);\n font-size: var(--ui-t-small, 11.5px);\n }\n p[joint-handle] button {\n padding: 2px 6px;\n border: none;\n border-radius: 4px;\n background: none;\n color: var(--md-sys-color-primary);\n font: inherit;\n font-weight: 600;\n cursor: pointer;\n }\n p[joint-handle] button:hover {\n background: var(--md-sys-color-surface-container-highest);\n }\n p[same-measure] {\n position: absolute;\n bottom: 12px;\n left: 50%;\n z-index: 5;\n transform: translateX(-50%);\n margin: 0;\n padding: 4px 10px;\n border-radius: 999em;\n background: var(--md-sys-color-surface-container-high);\n color: var(--md-sys-color-on-surface-variant);\n font-size: var(--ui-t-small, 11.5px);\n pointer-events: none;\n white-space: nowrap;\n }\n /* A new figure's first question, over the empty canvas. */\n div[start] {\n position: absolute;\n inset: 50% auto auto 50%;\n z-index: 10;\n color: var(--md-sys-color-on-surface);\n transform: translate(-50%, -50%);\n width: min(440px, calc(100% - 32px));\n box-sizing: border-box;\n padding: 20px;\n border-radius: 12px;\n background: var(--md-sys-color-surface, #fff);\n box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);\n }\n div[start] button[start-button] {\n width: auto;\n margin: 0;\n font-size: var(--ui-t-body);\n height: 36px;\n padding: 0 16px;\n border: 1px solid var(--md-sys-color-outline);\n border-radius: 999em;\n color: var(--md-sys-color-primary);\n background: var(--md-sys-color-surface, #fff);\n cursor: pointer;\n }\n div[start] button[start-button]:hover:not(:disabled) {\n background: var(--md-sys-color-primary-container);\n }\n div[start] button[start-button][pressed] {\n color: var(--md-sys-color-on-primary);\n background: var(--md-sys-color-primary);\n border-color: var(--md-sys-color-primary);\n }\n div[start] button[start-button]:disabled {\n opacity: 0.5;\n cursor: default;\n }\n div[start] h2 {\n margin: 0 0 12px;\n font-size: var(--ui-t-title);\n }\n div[start-paths] {\n display: grid;\n gap: 14px;\n }\n div[start-paths] h3 {\n margin: 0 0 6px;\n font-size: var(--ui-t-body);\n }\n div[start-shapes] {\n display: flex;\n gap: 8px;\n flex-wrap: wrap;\n }\n div[start] small {\n display: block;\n margin-top: 4px;\n color: var(--md-sys-color-on-surface-variant);\n }\n div[start] button[start-more] {\n display: block;\n text-align: left;\n margin: 4px 0 0;\n padding: 0;\n font: inherit;\n font-size: var(--ui-t-small);\n color: var(--md-sys-color-primary);\n background: none;\n border: none;\n cursor: pointer;\n }\n /* No rule under the last way to start: it closed nothing (sweep 2026-10-27 U23). */\n div[start-paths] > section:last-of-type {\n border-bottom: none;\n }\n /* The side: tabs over one panel at a time, each using the whole height. */\n /*\n The side's words at the panel's size (side-panel-styles: titles body, the rest small). The editor's host is at body\n for the bar, and the fields the editor drew itself -- the part's name -- stood a step larger than every other field.\n */\n aside {\n display: flex;\n flex-direction: column;\n min-height: 0;\n font-size: var(--ui-t-small, 11.5px);\n background: var(--md-sys-color-surface-container-lowest);\n }\n div[tabs] {\n display: flex;\n flex: none;\n border-bottom: 1px solid var(--md-sys-color-outline-variant);\n }\n button[tab] {\n flex: 1;\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 1px;\n min-width: 0;\n height: 48px;\n padding: 0;\n border: none;\n border-radius: 0;\n border-bottom: 2px solid transparent;\n background: none;\n color: var(--md-sys-color-on-surface-variant);\n }\n button[tab]:hover:not([on]) {\n background: var(--md-sys-color-surface-container);\n }\n button[tab][on] {\n color: var(--md-sys-color-primary);\n border-bottom-color: var(--md-sys-color-primary);\n }\n button[tab] md-icon {\n font-size: 20px;\n width: 20px;\n height: 20px;\n }\n button[tab] span[tab-label] {\n max-width: 100%;\n overflow: hidden;\n font-size: var(--ui-t-micro, 11px);\n line-height: 1.2;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n /* A range's two ends read as one: smallest – largest. */\n div[pair][range] {\n align-items: center;\n }\n div[pair][range] > span[dash] {\n flex: none;\n color: var(--md-sys-color-on-surface-variant);\n }\n /* The sections inside carry the margins (side-panel-styles); the panel only scrolls. */\n div[panel] {\n flex: 1;\n min-height: 0;\n overflow: auto;\n padding: 0;\n }\n div[panel][flush] {\n padding: 0;\n }\n /* Hidden, not removed: a panel keeps what it holds (the verdict its last answer) while another tab is open. */\n [off] {\n display: none !important;\n }\n /* The part's own numbers inside a group the links draw (size, place): one column, the panel's gap. */\n div[group-fields] {\n display: grid;\n gap: 6px;\n }\n /* The folded 「더 보기」: its title is the fold's handle, at the title's size. */\n section[more] > details > summary {\n padding: 0;\n }\n section[more] > details > summary > h3 {\n margin: 0;\n }\n div[more-body] {\n display: grid;\n gap: 16px;\n margin-top: 12px;\n }\n /*\n The view settings and the release history, opened from the bar over the right of the work: neither is about the\n part chosen, so neither takes a tab beside the part's (chief architect 2026-10-16). The fastening window stands in\n the same place, over the side panel, so the canvas it previews on stays in sight (user 2026-10-19).\n */\n :host {\n position: relative;\n }\n div[side-overlay] {\n position: absolute;\n top: var(--figure-bar-height, 44px);\n right: 8px;\n z-index: 5;\n display: flex;\n flex-direction: column;\n width: min(360px, calc(100% - 16px));\n max-height: calc(100% - var(--figure-bar-height, 44px) - 16px);\n background: var(--md-sys-color-surface-container-lowest);\n border: 1px solid var(--md-sys-color-outline-variant);\n border-radius: 8px;\n box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);\n }\n div[overlay-head] {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 8px 8px 12px;\n border-bottom: 1px solid var(--md-sys-color-outline-variant);\n }\n div[overlay-head] h3 {\n margin: 0;\n }\n div[overlay-head] button[quiet] {\n margin-left: 0;\n }\n [overlay-body] {\n min-height: 0;\n overflow: auto;\n }\n /* Which part the panel speaks of. Above z-index 1: a chip's label (md-filter-chip) sits at 1 and, coming later, was\n drawn over it when the panel scrolled (sweep 2026-10-27 U2). */\n div[subject] {\n position: sticky;\n top: 0;\n z-index: 2;\n display: grid;\n gap: 4px;\n padding: 10px 12px;\n background: var(--md-sys-color-surface-container-lowest);\n border-bottom: 1px solid var(--md-sys-color-outline-variant);\n }\n /* The panel's three sizes (side-panel-styles): the part's kind at the title's, its two lines at the hint's. */\n div[subject-summary] {\n display: grid;\n gap: 2px;\n }\n div[subject-summary] b {\n font-size: var(--ui-t-body, 13px);\n font-weight: 600;\n }\n div[subject-summary] b span {\n font-weight: 400;\n color: var(--md-sys-color-on-surface-variant);\n }\n div[subject-summary] small {\n color: var(--md-sys-color-on-surface-variant);\n }\n /*\n No rule here draws every button as a box: the side's buttons take the shared panel rules (SidePanelStyles), one\n height with the fields beside them, and only the bar's publish keeps an outline (user 2026-10-16: 「버튼 박스도\n 과하게 사용되어서」 -- a bare 「button」 rule had put a 32px box round every button the editor drew).\n */\n button {\n font: inherit;\n box-sizing: border-box;\n color: inherit;\n min-width: 0;\n cursor: pointer;\n }\n /* What blocks release, beside 「발행」: one red word button, and its list under the bar. */\n ox-canvas-bar button[release-blocked] {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n height: 32px;\n padding: 0 14px 0 10px;\n border: none;\n /* Round as save and release beside it: one shape for the bar's end. */\n border-radius: 999em;\n color: var(--md-sys-color-on-error-container);\n background: var(--md-sys-color-error-container);\n }\n ox-canvas-bar button[release-blocked] md-icon {\n --md-icon-size: 18px;\n }\n div[release-blockers] {\n position: absolute;\n top: 46px;\n right: 8px;\n z-index: 6;\n width: min(340px, calc(100% - 16px));\n padding: 8px 10px 10px;\n box-sizing: border-box;\n background: var(--md-sys-color-surface);\n border: 1px solid var(--md-sys-color-outline-variant);\n border-radius: 8px;\n box-shadow: var(--md-sys-elevation-2, 0 2px 8px #0003);\n }\n ox-canvas-bar button[publish] {\n border: 1px solid var(--md-sys-color-outline);\n color: var(--md-sys-color-primary);\n background: var(--md-sys-color-surface);\n }\n ox-canvas-bar button[publish][aria-pressed='true'] {\n background: var(--md-sys-color-secondary-container);\n color: var(--md-sys-color-on-secondary-container);\n }\n button:disabled {\n opacity: 0.45;\n cursor: default;\n }\n button[aria-pressed='true'] {\n background: var(--md-sys-color-secondary-container);\n color: var(--md-sys-color-on-secondary-container);\n border-color: var(--md-sys-color-primary);\n }\n .hint {\n color: var(--md-sys-color-on-surface-variant);\n line-height: 1.5;\n }\n /* A mirror asked about: under its row, the panel's own field rows (what comes with it, its names, how it turns). */\n div[mirror-form] {\n display: grid;\n gap: 6px;\n margin: 4px 0 8px;\n }\n`\n"]}
@@ -94,6 +94,8 @@ export declare class FigureEditor extends LitElement {
94
94
  private middle;
95
95
  /** The gizmo shown on the selected part, as the tools in the bar and W · E · R choose it; none once the part changes. */
96
96
  private gizmoMode?;
97
+ /** 「관절 위치 편집」: while on, a drag on a part that hangs from a joint that moves moves where the joint sits, not its pose. Off on each new selection. */
98
+ private jointPlacing;
97
99
  /** A line saying what a command did besides what was asked; gone at the next command. */
98
100
  private notice;
99
101
  /**
@@ -144,6 +146,11 @@ export declare class FigureEditor extends LitElement {
144
146
  * gone or another figure opened has nothing to go back to: the editor closes.
145
147
  */
146
148
  private leaveSectionEditor;
149
+ /**
150
+ * On a part that hangs from a joint that moves, what a drag does, before it is dragged (review 2026-11-09): the handle
151
+ * that poses it, or why none does and where it is moved from -- and 「관절 위치 편집」 to move where the joint sits.
152
+ */
153
+ private renderJointHandle;
147
154
  /** While the size tool is on a round part: which of its handles change the one diameter (ADR-0140 4.1). */
148
155
  private renderSameMeasure;
149
156
  /** The scene toggles: the mode already shown takes the gizmo away. */
@@ -43,7 +43,7 @@ import { groupFields, ownerOf, partLabelOf, repeatOf } from './fields.js';
43
43
  import { SidePanelStyles } from '@things-factory/figure-viewer/dist-client/side-panel-styles.js';
44
44
  import { EditorStyles } from './editor-styles.js';
45
45
  import { ScrollbarStyles } from '@operato/styles';
46
- import { alignChanges, canMirror, mirrorEditOf, mirrorPlanOf } from './align.js';
46
+ import { alignChanges, canMirror, mirrorEditOf, mirroredClipsOf, mirrorPlanOf } from './align.js';
47
47
  import { paletteRecipe } from './palette.js';
48
48
  import { meshChoicesOf, meshPartOf } from './mesh-import.js';
49
49
  import './figure-mesh-choice.js';
@@ -60,7 +60,7 @@ import { sizeInputOf } from './size-response.js';
60
60
  import { canFollow, followableAxes, endPlaceKeyOf, followOf, sizeFollowersOf, measureNow, partSummaryOf, instanceRangeOf, instanceSizeToDeclare, proportionToFollow, rangeWith, turnsAboutAJoint, valueNow } from './links.js';
61
61
  import { jointFanOf } from './joint-fan.js';
62
62
  import { derivedOf } from './revision.js';
63
- import { jointDragOf } from './joint-drag.js';
63
+ import { jointDragOf, jointHandleOf } from './joint-drag.js';
64
64
  import { liveOverSession, NOTHING_LIVE, scrubLabel } from './live.js';
65
65
  import { startingShapeKindOfBody } from './starting-shape.js';
66
66
  import { GroupMenuStyles } from './group-menu.js';
@@ -108,6 +108,8 @@ let FigureEditor = class FigureEditor extends LitElement {
108
108
  this.moreOpen = FigureEditor_1.storedMoreOpen();
109
109
  /** What the middle shows: the parts being edited, or the figure placed on a board at eight sizes. */
110
110
  this.middle = 'edit';
111
+ /** 「관절 위치 편집」: while on, a drag on a part that hangs from a joint that moves moves where the joint sits, not its pose. Off on each new selection. */
112
+ this.jointPlacing = false;
111
113
  /** A line saying what a command did besides what was asked; gone at the next command. */
112
114
  this.notice = '';
113
115
  /**
@@ -296,8 +298,10 @@ let FigureEditor = class FigureEditor extends LitElement {
296
298
  }
297
299
  if (view && !view.geometry.some(g => ownerOf(g.id) === this.selected))
298
300
  this.selected = '';
299
- if (_changed.has('selected'))
301
+ if (_changed.has('selected')) {
300
302
  this.gizmoMode = undefined;
303
+ this.jointPlacing = false;
304
+ }
301
305
  /* The window is about the part chosen on the properties tab, being edited: it does not follow anywhere else. */
302
306
  if (this.fastening && (_changed.has('selected') || !this.selected || this.tab !== 'properties' || this.middle !== 'edit'))
303
307
  this.closeFastening();
@@ -328,6 +332,30 @@ let FigureEditor = class FigureEditor extends LitElement {
328
332
  this.selected = next;
329
333
  });
330
334
  }
335
+ /**
336
+ * On a part that hangs from a joint that moves, what a drag does, before it is dragged (review 2026-11-09): the handle
337
+ * that poses it, or why none does and where it is moved from -- and 「관절 위치 편집」 to move where the joint sits.
338
+ */
339
+ renderJointHandle(unavailable) {
340
+ const asset = this.asset();
341
+ if (unavailable || this.gizmoMode === 'scale' || !this.selected || !asset)
342
+ return nothing;
343
+ const handle = jointHandleOf(asset, this.selected);
344
+ if (!handle)
345
+ return nothing;
346
+ if (this.jointPlacing)
347
+ return html `<p joint-handle role="status">${i18next.t('figure.text.joint-placing', { joint: handle.joint })}
348
+ <button act @click=${() => (this.jointPlacing = false)}>${i18next.t('figure.button.joint-place-off')}</button></p>`;
349
+ const said = handle.kind === 'mimic'
350
+ ? i18next.t('figure.text.gizmo-joint-mimic', { joint: handle.joint, leader: handle.leader })
351
+ : handle.kind === 'several-axes'
352
+ ? i18next.t('figure.text.gizmo-joint-several-axes', { joint: handle.joint })
353
+ : i18next.t(`figure.text.joint-handle-${handle.kind}`, { joint: handle.joint });
354
+ const leaderPart = handle.kind === 'mimic' ? handle.leaderPart : undefined;
355
+ return html `<p joint-handle role="status">${said}
356
+ ${leaderPart ? html `<button act @click=${() => this.choose(leaderPart)}>${i18next.t('figure.button.select-leader', { leader: handle.leader })}</button>` : nothing}
357
+ <button act @click=${() => (this.jointPlacing = true)}>${i18next.t('figure.button.joint-place-on')}</button></p>`;
358
+ }
331
359
  /** While the size tool is on a round part: which of its handles change the one diameter (ADR-0140 4.1). */
332
360
  renderSameMeasure(unavailable) {
333
361
  if (unavailable || this.gizmoMode !== 'scale' || !this.selected)
@@ -697,12 +725,31 @@ let FigureEditor = class FigureEditor extends LitElement {
697
725
  const shown = this.shown();
698
726
  const asset = shown.asset;
699
727
  const drawn = view.geometry.find(g => g.id === id);
700
- const drag = drawn ? jointDragOf(asset, ownerOf(id), drawn, result, shown.inputs) : null;
728
+ const drag = drawn ? jointDragOf(asset, ownerOf(id), drawn, result, shown.inputs, { place: this.jointPlacing }) : null;
701
729
  if (drag) {
702
730
  if (drag.kind === 'value')
703
731
  this.run(() => this.session.apply([{ kind: 'set-state', input: drag.input, unit: drag.unit, value: drag.value }]));
704
732
  else if (drag.kind === 'joint')
705
733
  this.run(() => this.session.command({ kind: 'set-joint', joint: drag.joint }));
734
+ else if (drag.reason === 'place-off') {
735
+ /* A pose drag that would have moved the joint: nothing is written, and the way to move it is offered. */
736
+ this.refusals.point(i18next.t('figure.text.gizmo-joint-place-off', { joint: drag.joint }), {
737
+ label: i18next.t('figure.button.joint-place-on'),
738
+ run: () => (this.jointPlacing = true)
739
+ });
740
+ this.requestUpdate();
741
+ }
742
+ else if (drag.reason === 'mimic') {
743
+ /* A joint that follows another: the one it follows is a click away. */
744
+ const leader = jointHandleOf(asset, ownerOf(id));
745
+ const leaderPart = leader?.kind === 'mimic' ? leader.leaderPart : undefined;
746
+ const message = i18next.t('figure.text.gizmo-joint-mimic', { joint: drag.joint, leader: drag.leader ?? '' });
747
+ if (leaderPart)
748
+ this.refusals.point(message, { label: i18next.t('figure.button.select-leader', { leader: drag.leader ?? '' }), run: () => this.choose(leaderPart) });
749
+ else
750
+ this.refusals.say(message);
751
+ this.requestUpdate();
752
+ }
706
753
  else {
707
754
  this.error = i18next.t(`figure.text.gizmo-joint-${drag.reason}`, { joint: drag.joint, leader: drag.leader ?? '', axis: drag.axis ?? '' });
708
755
  this.requestUpdate();
@@ -825,6 +872,7 @@ let FigureEditor = class FigureEditor extends LitElement {
825
872
  ${i18next.t('figure.label.mirror-keep-motion')}
826
873
  </label>`
827
874
  : nothing}
875
+ ${(clips => (clips.length ? html `<p hint mirror-clips>${i18next.t('figure.text.mirror-copies-clips', { clips: clips.join(', ') })}</p>` : nothing))(mirroredClipsOf(this.shown().asset, m.part, m.form.chain))}
828
876
  <div pair>
829
877
  <button act ?disabled=${unavailable} @click=${() => this.mirrorWith(m.part, m.form)}>${i18next.t('figure.button.mirror-' + m.form.axis)}</button>
830
878
  <button act @click=${() => (this.mirroring = undefined)}>${i18next.t('figure.button.cancel')}</button>
@@ -1122,6 +1170,7 @@ let FigureEditor = class FigureEditor extends LitElement {
1122
1170
  @states=${(e) => this.run(() => this.session.apply(e.detail.changes))}
1123
1171
  @states-live=${(e) => this.hold(e.detail.values)}
1124
1172
  @part-edit=${(e) => this.run(() => this.session.edit(e.detail.edit))}
1173
+ @part-edits=${(e) => this.run(() => this.session.applyRecipe(e.detail.edits))}
1125
1174
  ></figure-clips>`;
1126
1175
  }
1127
1176
  /** One command, one step of the history. A refusal a person can meet here is said in their words. */
@@ -2096,7 +2145,7 @@ let FigureEditor = class FigureEditor extends LitElement {
2096
2145
  @render-error=${(e) => {
2097
2146
  this.error = e.detail.message;
2098
2147
  }}
2099
- ></figure-canvas>${this.renderSameMeasure(unavailable)}</div>
2148
+ ></figure-canvas>${this.renderSameMeasure(unavailable)}${this.renderJointHandle(unavailable)}</div>
2100
2149
  <aside slot="end">
2101
2150
  <div tabs>
2102
2151
  ${this.renderTab('properties', 'tune', i18next.t('figure.label.properties'))}
@@ -2399,6 +2448,10 @@ __decorate([
2399
2448
  state(),
2400
2449
  __metadata("design:type", String)
2401
2450
  ], FigureEditor.prototype, "gizmoMode", void 0);
2451
+ __decorate([
2452
+ state(),
2453
+ __metadata("design:type", Object)
2454
+ ], FigureEditor.prototype, "jointPlacing", void 0);
2402
2455
  __decorate([
2403
2456
  state(),
2404
2457
  __metadata("design:type", Object)