cozyclay 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/app/index.html +4 -4
- package/dist/assets/analytics-BibyE5ar.js +6 -0
- package/dist/assets/{app-34i-iUy1.js → app-DhRJ-PBz.js} +40 -40
- package/dist/assets/compile-worker-DqiA4AaN.js +5 -0
- package/dist/assets/{first-shot-handoff-CrGZ3n_O.js → first-shot-handoff-Qx7SKl38.js} +1 -1
- package/dist/assets/{landing-mq5bnqFE.js → landing-DYg87MDY.js} +1 -1
- package/dist/assets/scene-asset-sync-DBYQBR0T.js +20 -0
- package/dist/assets/{workflow-dUhurYUc.js → workflow-BSA22Ofr.js} +1 -1
- package/dist/cozyclay-package.json +1 -1
- package/dist/index.html +3 -3
- package/dist/workflow/index.html +3 -3
- package/package.json +1 -1
- package/src/bus-task-scopes.js +69 -0
- package/src/bus-task-targets.js +48 -0
- package/src/bus-tasks.js +175 -0
- package/src/command-bus.js +14 -39
- package/src/command-history.js +36 -0
- package/src/commands/cast.js +10 -3
- package/src/commands/motion.js +2 -1
- package/src/commands/motion3.js +10 -4
- package/src/commands/shared.js +9 -0
- package/src/motion3/compiler/anchors.js +33 -5
- package/src/motion3/compiler/compile.js +20 -3
- package/src/motion3/compiler/grip.js +9 -3
- package/src/motion3/compiler/socket-grip.js +34 -10
- package/src/motion3/docs.js +1 -1
- package/src/motion3/fix/index.js +5 -3
- package/src/motion3/pipeline.js +2 -0
- package/src/motion3/qa/spec-checks.js +12 -1
- package/src/motion3/schema/topics.js +2 -2
- package/src/motion3/schema/types.js +1 -0
- package/src/motion3/skills/basic.js +61 -13
- package/src/motion3/skills/index.js +4 -2
- package/src/motion3/skills/info.js +1 -1
- package/src/motion3/skills/reach-human.js +139 -0
- package/src/motion3/skills/stance.js +92 -0
- package/src/motion3/sockets.js +21 -4
- package/src/motion3/views.js +28 -5
- package/src/studio-app-binding.js +2 -2
- package/src/studio-error-codes.js +1 -1
- package/src/studio-motion-visual.js +4 -4
- package/tools/run-tests.mjs +1 -1
- package/dist/assets/analytics-DbKG0NgD.js +0 -6
- package/dist/assets/compile-worker-DYpa2nvO.js +0 -5
- package/dist/assets/scene-asset-sync-7J-w5oNh.js +0 -20
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 3.0.3 - 2026-10-20
|
|
6
|
+
|
|
7
|
+
Grasp round 2, from a user's own cup, ball and steering-wheel sessions on 3.0.2.
|
|
8
|
+
|
|
9
|
+
Motion
|
|
10
|
+
|
|
11
|
+
- A grasp's IK target, QA REACH, the reachGrip contact and a goal's `near`
|
|
12
|
+
read one measure: the held part's surface. A cup reach that read 0.845 m
|
|
13
|
+
short while its goal passed now reports the real miss.
|
|
14
|
+
- A steering wheel (a thin disc) is a rim socket: each hand keeps its spot
|
|
15
|
+
on the rim while the wheel moves.
|
|
16
|
+
- A stance inside what it stands in slides out of it; standIdle with no `at`
|
|
17
|
+
before a reachGrip steps up within reach (`observations.placed`).
|
|
18
|
+
- An upright cup or can is wrapped from the side, not covered from the top.
|
|
19
|
+
- A reach to grasp moves like a person's: the wrist peaks at about a third
|
|
20
|
+
of the reach and approaches slowly, the hand stays open wider than the
|
|
21
|
+
object and closes on the approach, and the head turns to the object first.
|
|
22
|
+
- reachGrip names its fingers' prop apart from an existing one, cuts a hold
|
|
23
|
+
past the take's end instead of refusing it, and `motion.report` accepts
|
|
24
|
+
`characterId`. Contact sheets with a focus follow it when it moves.
|
|
25
|
+
|
|
26
|
+
Studio
|
|
27
|
+
|
|
28
|
+
- The command bus can run several agent tasks at once, each inside its own
|
|
29
|
+
scope (objects, characters, shots, stage, timeline, scene), with scoped
|
|
30
|
+
cancel and undo. The agent still runs one turn at a time until the task
|
|
31
|
+
mode ships.
|
|
32
|
+
|
|
5
33
|
## 3.0.2 - 2026-10-19
|
|
6
34
|
|
|
7
35
|
Fixes from an audit of the latest Studio agent sessions, and a grasp round.
|
package/dist/app/index.html
CHANGED
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
<title>CozyClay Studio — 3D staging and previs in your browser</title>
|
|
35
35
|
|
|
36
36
|
<script defer src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"token": "6a4384d1375d4ffc8a30a6346a8ad1a0"}'></script>
|
|
37
|
-
<script type="module" crossorigin src="/assets/app-
|
|
37
|
+
<script type="module" crossorigin src="/assets/app-DhRJ-PBz.js"></script>
|
|
38
38
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
39
|
-
<link rel="modulepreload" crossorigin href="/assets/analytics-
|
|
40
|
-
<link rel="modulepreload" crossorigin href="/assets/first-shot-handoff-
|
|
39
|
+
<link rel="modulepreload" crossorigin href="/assets/analytics-BibyE5ar.js">
|
|
40
|
+
<link rel="modulepreload" crossorigin href="/assets/first-shot-handoff-Qx7SKl38.js">
|
|
41
41
|
<link rel="modulepreload" crossorigin href="/assets/fflate.module-KbGj5-H6.js">
|
|
42
|
-
<link rel="modulepreload" crossorigin href="/assets/scene-asset-sync-
|
|
42
|
+
<link rel="modulepreload" crossorigin href="/assets/scene-asset-sync-DBYQBR0T.js">
|
|
43
43
|
<link rel="stylesheet" crossorigin href="/assets/scene-asset-sync-_S8NQl5B.css">
|
|
44
44
|
<link rel="stylesheet" crossorigin href="/assets/app-f-fkV5uP.css">
|
|
45
45
|
</head>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=.02,t=(e,t,n)=>Math.min(n,Math.max(t,e)),n=(e,t=0)=>typeof e==`number`&&Number.isFinite(e)?e:t;function r(e){let t=0;for(let n=0;n<e.length-1;n+=1)t+=(e[n]+e[n+1])/2;return t}function i(e,n){let r=t(n,0,1)*(e.length-1),i=Math.min(e.length-2,Math.floor(r)),a=r-i;return e[i]*(1-a)+e[i+1]*a}function a(e,t=24){if(!e.length)return Array(t).fill(1);if(e.length===1)return Array(t).fill(e[0]);let n=Array(t);for(let r=0;r<t;r+=1)n[r]=i(e,r/(t-1));return n}function o(e){let t=e.map(e=>Math.max(0,n(e,0))),i=r(t)/(t.length-1);return i<=1e-9?t.map(()=>1):t.map(e=>e/i)}function s(e){return e.every(e=>Math.abs(e-1)<1e-6)}function c(){return{cuts:[],envelopes:[Array(24).fill(1)]}}function l(e){return!e||e.cuts.length===0&&e.envelopes.every(s)}function u(e){if(!e||typeof e!=`object`)return null;let t=Array.isArray(e.cuts)?e.cuts:[],r=[];for(let e of t){let t=n(e?.t,NaN),i=n(e?.d,NaN);if(!(t>0&&t<1&&i>0&&i<1))continue;let a=r[r.length-1];a&&(t<=a.t+1e-6||i<=a.d+1e-6)||r.push({t,d:i})}let i=Array.isArray(e.envelopes)?e.envelopes:[],s=[];for(let e=0;e<=r.length;e+=1){let t=Array.isArray(i[e])?i[e].map(e=>n(e,1)):[];s.push(o(a(t.length>=2?t:[1,1])))}return{cuts:r,envelopes:s}}function d(e,r,i,a=.18){let o=e.length,s=Math.max(0,n(i,0)),c=t(n(r,0),0,1),l=a/3,u=Array(o);for(let e=0;e<o;e+=1){let t=Math.abs(e/(o-1)-c);u[e]=t<=l?1:t>=a?0:.5*(1+Math.cos((t-l)/(a-l)*Math.PI))}let d=e.map((e,t)=>Math.max(0,e*(1-u[t])+s*u[t])),f=e=>e===0||e===o-1?.5:1,p=o-1,m=0,ee=0;for(let e=0;e<o;e+=1)u[e]>1e-9?m+=f(e)*d[e]:ee+=f(e)*d[e];if(ee>1e-9){let e=Math.max(0,(p-m)/ee);for(let t=0;t<o;t+=1)u[t]<=1e-9&&(d[t]*=e);if(p-m<0){let e=p/m;for(let t=0;t<o;t+=1)u[t]>1e-9&&(d[t]*=e)}}else if(m>1e-9){let e=p/m;for(let t=0;t<o;t+=1)d[t]*=e}else return Array(o).fill(1);return d}function f(e,n){let i=e.length,a=r(e);if(a<=1e-9)return t(n,0,1);let o=t(n,0,1)*(i-1),s=Math.min(i-2,Math.floor(o)),c=o-s,l=0;for(let t=0;t<s;t+=1)l+=(e[t]+e[t+1])/2;let u=e[s]*(1-c)+e[s+1]*c;return l+=(e[s]+u)/2*c,l/a}function p(e,r){let i=t(n(r,0),0,1);if(!e)return i;let a=[{t:0,d:0},...e.cuts,{t:1,d:1}],o=0;for(;o<a.length-2&&i>a[o+1].t;)o+=1;let s=a[o],c=a[o+1],l=c.t-s.t,u=l>1e-9?(i-s.t)/l:1;return s.d+(c.d-s.d)*f(e.envelopes[o],u)}function m(e,t,n){let r=Array(24);for(let a=0;a<24;a+=1)r[a]=i(e,t+(n-t)*(a/23));return r}function ee(e,t){let r=e??c(),i=n(t,NaN);if(!(i>.02&&i<.98))return e;for(let t of r.cuts)if(Math.abs(t.t-i)<.02)return e;let a=p(r,i);if(!(a>1e-6&&a<1-1e-6))return e;let s=0;for(;s<r.cuts.length&&i>r.cuts[s].t;)s+=1;let l=s===0?{t:0}:r.cuts[s-1],u=s===r.cuts.length?{t:1}:r.cuts[s],d=(i-l.t)/(u.t-l.t),f=r.envelopes[s];return{cuts:[...r.cuts.slice(0,s),{t:i,d:a},...r.cuts.slice(s)],envelopes:[...r.envelopes.slice(0,s),o(m(f,0,d)),o(m(f,d,1)),...r.envelopes.slice(s+1)]}}function h(e,t){if(!e||!e.cuts[t])return e;let n=[{t:0,d:0},...e.cuts,{t:1,d:1}],r=n[t],a=n[t+1],s=n[t+2],c=(a.t-r.t)/(s.t-r.t),l=(a.d-r.d)/(s.d-r.d),u=1-c,d=1-l,f=e.envelopes[t],p=e.envelopes[t+1],m=Array(24);for(let e=0;e<24;e+=1){let t=e/23;if(t<=c){let n=i(f,c>1e-9?t/c:0);m[e]=l/Math.max(1e-9,c)*n}else{let n=i(p,u>1e-9?(t-c)/u:0);m[e]=d/Math.max(1e-9,u)*n}}return{cuts:[...e.cuts.slice(0,t),...e.cuts.slice(t+1)],envelopes:[...e.envelopes.slice(0,t),o(m),...e.envelopes.slice(t+2)]}}var g=Object.freeze([`keys`,`follow`,`rail`]),_=Object.freeze({distance:3,height:1.6,response:.7,lead:.25,railStartMode:`head`,maxDollySpeed:4,pitchOffsetDeg:0,orbitOffsetDeg:0});function te(e){return Array.isArray(e)?e.map(e=>({x:e.x,z:e.z})):null}function v(e){if(!e||typeof e!=`object`)return null;let t=Array.isArray(e.points)?e.points:Number.isFinite(e.start)&&Number.isFinite(e.end)?[{t:0,height:e.start},{t:1,height:e.end}]:null;if(!t)return null;let n=t.filter(e=>e&&Number.isFinite(e.t)&&Number.isFinite(e.height)).map(e=>({t:Math.max(0,Math.min(1,e.t)),height:Math.max(.1,e.height)})).sort((e,t)=>e.t-t.t).filter((e,t,n)=>t===n.length-1||n[t+1].t-e.t>1e-6).slice(0,8);return n.length<2?null:(n[0]={...n[0],t:0},n[n.length-1]={...n[n.length-1],t:1},{points:n})}function ne(e){return!e||typeof e!=`object`?null:e.mode===`off`?{mode:`off`}:e.mode===`range`?{mode:`range`,startFrame:e.startFrame,endFrame:e.endFrame}:null}function re(e){let t=Array.isArray(e?.ids)?e.ids.filter(e=>typeof e==`string`&&e).slice(0,4):[];if(t.length)return Number.isFinite(e.height)?{ids:t,height:e.height}:{ids:t};let n=e?.point;return n&&[n.x,n.y,n.z].every(Number.isFinite)?{point:{x:n.x,y:n.y,z:n.z}}:null}function ie(e,t){let n=t?re(e.aim):null,r=t&&Number.isFinite(e.focalMm)&&e.focalMm>0?e.focalMm:null;return{...n?{aim:n}:{},...r?{focalMm:r}:{}}}function y(e={}){let t=e&&typeof e==`object`?e:{},n=g.includes(t.mode)?t.mode:`keys`,r={..._,...t.followCam??{}},i=te(t.cameraRail),a=v(t.craneHeight)??(n===`rail`&&i?{points:[{t:0,height:r.height},{t:1,height:r.height}]}:null),o=u(t.dollyTiming);return{mode:n,followCam:r,cameraRail:i,railFollow:ne(t.railFollow),craneHeight:a,dollyTiming:l(o)?null:o,...ie(t,i)}}function ae(e){return y(e)}function oe(e,t={}){let n=y(e),r=t&&typeof t==`object`?t:{};return y({...n,...r,followCam:r.followCam?{...n.followCam,...r.followCam}:n.followCam,cameraRail:Object.hasOwn(r,`cameraRail`)?r.cameraRail:n.cameraRail,railFollow:Object.hasOwn(r,`railFollow`)?r.railFollow:n.railFollow,craneHeight:Object.hasOwn(r,`craneHeight`)?r.craneHeight:n.craneHeight,dollyTiming:Object.hasOwn(r,`dollyTiming`)?r.dollyTiming:n.dollyTiming})}function se(e){let t=y(e);return oe(t,{mode:t.mode===`rail`?`follow`:t.mode,cameraRail:null,railFollow:null,craneHeight:null})}var b=e=>e&&typeof e==`object`?Object.freeze({...e}):e,ce=Object.freeze([{path:`character.position`,type:`vec3`,persisted:!0,undoDomain:`cast`,normalizer:`createCharacterEntry`,min:{x:-240,y:0,z:-240},max:{x:240,y:240,z:240},gizmo:{min:{x:-4,y:0,z:-4},max:{x:4,y:240,z:4}},note:`y is the feet`},{path:`character.rot`,type:`number`,persisted:!0,undoDomain:`cast`,normalizer:`createCharacterEntry`,min:-180,max:180,angle:!0,note:`yaw degrees, wrapped at the upper bound`},{path:`character.scale`,type:`number`,persisted:!0,undoDomain:`cast`,normalizer:`createCharacterEntry`,min:.2,max:3},{path:`character.subject`,type:`string`,persisted:!0,undoDomain:`cast`,normalizer:`createCharacterEntry`},{path:`character.hidden`,type:`boolean`,persisted:!0,undoDomain:`cast`,normalizer:`createCharacterEntry`},{path:`character.parent`,type:`id`,nullable:!0,persisted:!0,undoDomain:`cast`,normalizer:`createCharacterEntry`,note:`scene object id the character is grouped under and rides; null stands in the world`},{path:`character.model`,type:`enum`,persisted:!0,undoDomain:`cast`,normalizer:`createCharacterEntry`,enum:[`y-bot-tpose`,`x-bot-tpose`,`proxy-figure`]},{path:`character.posture`,type:`enum`,persisted:!0,undoDomain:`cast`,normalizer:`createCharacterEntry`,enum:[`stand`,`sit`,`lie`]},{path:`character.tint`,type:`color`,persisted:!0,undoDomain:`cast`,normalizer:`createCharacterEntry`},{path:`character.identityImage`,type:`image`,persisted:!0,undoDomain:`cast`,normalizer:`createCharacterEntry`,note:`data:image only`},{path:`character.pose`,type:`id`,persisted:!0,undoDomain:`cast`,normalizer:`createCharacterEntry`},{path:`character.waypoints`,type:`array`,persisted:!0,undoDomain:`cast`,normalizer:`createCharacterEntry`,actions:[`character.addWaypoint`,`character.moveWaypoint`,`character.removeWaypoint`,`character.clearWaypoints`],note:`root path pins, addressed by frame`},{path:`character.sessionMotion`,type:`array`,persisted:!1,undoDomain:`cast`,normalizer:`createCharacterEntry`,note:`dropped by createCharacterEntry`},{path:`character.ikKeys`,type:`array`,persisted:!1,undoDomain:`cast`,normalizer:`createCharacterEntry`,actions:[`character.setIkKey`,`character.removeIkKey`,`character.clearIkKeys`],note:`dropped by createCharacterEntry; keys travel as JSON quaternions/positions`},{path:`object.renderer`,type:`enum`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`,enum:[`cube`,`sphere`,`capsule`,`cylinder`,`cone`,`plane`,`chair`,`car`,`small-plane`,`empty`,`light`,`effect`,`text`],note:`light is made from catalogue kind point-light or spot-light; effect (smoke, fire, rain, trail...) from kind effect; text (words, a sign, a logo) from kind text`},{path:`object.position`,type:`vec3`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`,min:{x:-240,y:0,z:-240},max:{x:240,y:240,z:240},note:`y is the object's base: y=0 rests on the floor; height/supportY rise from it`},{path:`object.rotation`,type:`vec3`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`,min:{x:-180,y:-180,z:-180},max:{x:180,y:180,z:180},angle:!0,note:`rot/rotX/rotZ degrees, wrapped at the upper bound`},{path:`object.scale`,type:`vec3`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`,min:{x:.01,y:.01,z:.01},max:{x:100,y:100,z:100}},{path:`object.name`,type:`string`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`},{path:`object.color`,type:`color`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`},{path:`object.opacity`,type:`number`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`,min:.05,max:1,note:`1 is solid; lower is see-through, e.g. 0.3 for clear glass`},{path:`object.parent`,type:`id`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`},{path:`object.attach`,type:`id`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`,actions:[`object.attach`,`object.detach`],note:`carried by a character's root or bone; channels convert so the prop stays put`},{path:`object.path`,type:`array`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`},{path:`object.remove`,type:`boolean`,persisted:!0,undoDomain:`objects`,normalizer:null,note:`lifecycle operation, not a document field`},{path:`object.cutout`,type:`image`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`,actions:[`asset.import`],note:`assetId-backed cutout record; imported pictures and models are placed by asset.import`},{path:`object.light`,type:`object`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`,note:`renderer light only. { type point|spot, color, intensity 0..1000 candela (lighter 0.45, candle 0.3, desk lamp 5, street lamp 40), range m (0 none), angle 1..89 deg spot half-angle, softness 0..1, shadow (first 2 lights only; inside a solid record it is blocked: receipt LIGHT_BLOCKED), flicker 0..1 (lighter 0.6), aim {x,y,z} world point or null = local -Y }, e.g. { intensity: 40, aim: { x: 0, y: 0, z: 1 } }; a take level track scales it`},{path:`object.glow`,type:`object`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`,note:`any record: self-lit colour plus additive halo, same under any stage light; casts no shadow, so a light inside a glowing bulb shines out. { color, intensity 0..20, halo 0..4 x the record's radius }, e.g. ember { color: "#ff5a1f", intensity: 6, halo: 2 }; null removes; a take level track scales it`},{path:`object.text`,type:`object`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`,note:`renderer text only: words in one record, e.g. object.add { kind: "text", text: { value: "CozyClay", size: 0.4 }, placement: { x, y, z, rot } }. { value: the words (up to 200 characters, \\n starts a line), size m height of a capital letter (default 0.3), depth m (0 = flat lettering in any script, default; above 0 = solid letters for Latin, digits and punctuation, and words with other characters stay flat), align left|center|right for several lines }. The record's footprint and height are measured from the words: x is the centre, y the bottom of the lowest line, and the letters face local +z and read toward local +x, so on a side facing +x set rot 90. Flat lettering on a surface: keep it 3 mm or more off the face. color is the letters' colour`},{path:`object.grasp`,type:`object`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`,note:`grasp sockets: where a hand takes hold of the record, in its own axes (m from the base pivot), moving and saving with it. { <name>: { at: [x,y,z], axis?: [x,y,z] the line across the palm (a bar, a handle), from?: [x,y,z] the side the hand comes from (the palm faces against it), thumb?: [x,y,z] the axis end the thumb takes } }, at most 8; null removes. A motion spec anchor { kind: "object", object, socket: <name>, grasp } takes a hand by one; a thin body (a bar, a can, a handle) is a socket of its own, named by its id`},{path:`object.effect`,type:`object`,persisted:!0,undoDomain:`objects`,normalizer:`normalizeSceneObject`,note:`renderer effect only (object.add kind "effect"). { preset: smoke|exhale|steam|fire|sparks|dust|rain|snow|trail, rate particles/s, life s, size m start diameter, grow end/start size, speed m/s along the record's local +Y (rotX 90 aims +Z), spread 0..1 cone, gravity m/s2 (+ falls, - rises), wind {x,y,z} m/s, color, opacity 0..1, additive (emissive: fire, sparks), seed int, area {x,y,z} m birth box (rain/snow/dust fall through it from its top), width m trail ribbon across local Y }. A new preset loads its defaults and fields in the same set override them, e.g. { preset: "fire", rate: 40 }; the record stores the merged numbers. Particles are born where the record is at each frame (route, parent, take carry), only while it and its parents are shown, at rate x the take level. To emit from the body (a breath at the mouth), a motion spec entry objects.<id> = { follow: "landmark:mouth", aim: "face" } moves it there every frame. Measure with inspect_studio { scope: "entities", ids }: effect { frame (the playhead), alive, emitter [x,y,z], bounds { min, max } m }`},{path:`stage.keyLight.x`,type:`number`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,min:-30,max:30},{path:`stage.keyLight.y`,type:`number`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,min:.5,max:30},{path:`stage.keyLight.z`,type:`number`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,min:-30,max:30},{path:`stage.keyLight.intensity`,type:`number`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,min:0,max:4},{path:`stage.keyLight.warmth`,type:`number`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,min:0,max:1},{path:`stage.environmentImage`,type:`image`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,note:`data:image only`},{path:`stage.environment`,type:`string`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,note:`location description every shot prompt is built from`},{path:`stage.style`,type:`string`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,note:`look / style line for shot prompts`},{path:`stage.hasEnvSheet`,type:`boolean`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,note:`author supplies an environment sheet instead of a description`},{path:`stage.camera`,documentPath:`shotAspect`,type:`enum`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,enum:[`16:9`,`2.39:1`,`9:16`,`1:1`,`4:3`,`12:7`,`fal 480P`],note:`output aspect ratio`},{path:`stage.cameraPresetId`,type:`id`,nullable:!0,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`},{path:`stage.sensorId`,type:`enum`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,enum:[`super16`,`super35`,`fullFrame`,`65mm`]},{path:`stage.keyLight.color`,type:`color`,nullable:!0,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,note:`key light colour #rrggbb, overrides warmth, e.g. "#9db6e6" cool moonlight or "#ffad5c" low sun; null = white tinted by warmth`},{path:`stage.lighting.preset`,type:`enum`,persisted:!0,readOnly:!0,undoDomain:`stage`,normalizer:`createSceneStage`,enum:[`studio`,`day`,`overcast`,`golden`,`dusk`,`night`,`interior`,`stage`],note:`label of the last recipe stage.applyLighting applied; studio is the neutral grey default`},{path:`stage.lighting.sky`,type:`color`,nullable:!0,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,note:`background and fog colour at the horizon, e.g. "#0b1426" night; null = the UI theme's studio grey`},{path:`stage.lighting.skyTop`,type:`color`,nullable:!0,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,note:`sky colour overhead: shot camera and exports grade from sky at the horizon to this, e.g. "#020408"; null = flat sky`},{path:`stage.lighting.ambient`,type:`number`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,min:0,max:3,note:`multiplier on the hemisphere and ambient light; 1 = studio, 0.6 = night, 0 = black stage`},{path:`stage.lighting.hemiSky`,type:`color`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,note:`hemisphere light from above, e.g. "#34507f" cool night sky; studio "#ffffff"`},{path:`stage.lighting.hemiGround`,type:`color`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,note:`hemisphere bounce from below, e.g. "#6e5136" warm ground; studio "#5a5d64"`},{path:`stage.lighting.fill`,type:`number`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,min:0,max:3,note:`multiplier on the fixed fill and rim lights; 1 = studio, 0 = key only`},{path:`stage.lighting.fog`,type:`number`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,min:0,max:1,note:`haze 0..1 fading the set into the sky colour: 0 = far horizon only, 0.45 = from ~18 m to ~38 m, 1 = from 2 m to 14 m`},{path:`stage.lighting.exposure`,type:`number`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,min:.2,max:3,note:`camera exposure multiplier on lit surfaces; 1 = studio, e.g. 1.4 to lift a dark frame`},{path:`stage.lighting.shadowSoftness`,type:`number`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,min:0,max:1,note:`key shadow penumbra; 0 = crisp (studio), 0.75 = soft moonlight, 1 = overcast`},{path:`stage.lighting.envLight`,type:`number`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,min:0,max:2,note:`sky environment light on every surface: a map from sky, skyTop, hemiGround and a glow toward the key (sun or moon) tints and fills clay from all sides; it takes over the flat hemisphere as it rises. 0 = hemisphere only (studio), 1 = the map alone at the same brightness (every other recipe), e.g. 1.4 for a brighter fill`},{path:`stage.lighting.ao`,type:`number`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,min:0,max:1,note:`ambient occlusion strength: contact darkening within ~0.5 m where a body meets the floor or a prop and in creases (armpits, the back of a squat's knees), in the viewport and every export. 0 = off (studio), 0.8 = most recipes, 1 = overcast`},{path:`stage.lighting.hdr`,type:`id`,nullable:!0,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,note:`HDR environment map that replaces the sky environment light: a built-in ("builtin:night-street", "builtin:overcast-field", "builtin:studio-softbox") or a file the user loaded ("hdr-<32 hex>"); inspect_studio { scope: "catalogue" } environments lists them with each map's brightest direction. It lights the set only while envLight > 0 (its light = map x hdrIntensity x envLight; studio has envLight 0, so set envLight 1). stage.applyLighting clears it unless keep has "lighting.hdr". null = the look's own sky`},{path:`stage.lighting.hdrRotation`,type:`number`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,min:-180,max:180,angle:!0,note:`degrees the HDR map turns about the vertical axis, light and backdrop together: +90 carries a light at +x (screen right from the default camera) to -z (behind the subject), so a brightest [x, y, z] lands at [x cos r + z sin r, y, z cos r - x sin r]; wrapped at the upper bound`},{path:`stage.lighting.hdrIntensity`,type:`number`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,min:0,max:4,note:`multiplier on the HDR map's radiance in its light and its backdrop; 1 = the file as authored, e.g. 0.5 to calm a bright daylight map`},{path:`stage.lighting.hdrBackground`,type:`boolean`,persisted:!0,undoDomain:`stage`,normalizer:`createSceneStage`,note:`true = the HDR map is the backdrop behind the set (the floor fades into its horizon), in the viewport, shot and every export; false = keep the look's sky as the backdrop and use the map only as light`},{path:`shot.crud`,type:`array`,persisted:!0,undoDomain:`shot`,normalizer:null,actions:[`shot.create`,`shot.split`,`shot.duplicate`,`shot.remove`,`shot.setRange`,`shot.reorder`],note:`create/split/duplicate/reorder/remove/range through the shared action registry`},{path:`shot.cameraKeys`,type:`array`,persisted:!0,undoDomain:`shot`,normalizer:null,frameMin:0},{path:`shot.cameraRail`,type:`array`,persisted:!0,undoDomain:`shot`,normalizer:`repairCamera`,actions:[`shot.setCameraRail`,`shot.clearCameraRail`],note:`rail points; crane/dolly timing follow the shot's camera block`},{path:`shot.targetModel`,type:`id`,persisted:!0,undoDomain:`shot`,normalizer:`repairCamera`},{path:`shot.kind`,type:`enum`,persisted:!0,undoDomain:`shot`,normalizer:null,readOnly:!0,enum:[`clip`,`still`],note:`clip or still; a still holds one picture for endFrame - startFrame + 1 frames`},{path:`shot.caption`,type:`string`,persisted:!0,undoDomain:`shot`,normalizer:null,readOnly:!0,note:`trimmed, at most 500 characters`},{path:`shot.cast`,type:`array`,persisted:!0,undoDomain:`shot`,normalizer:null,readOnly:!0,note:`per-shot placement overrides keyed by character id: { x, z, rot, posture?, pose? }`},{path:`shot.stylizedAssetId`,type:`id`,nullable:!0,persisted:!0,undoDomain:`shot`,normalizer:null,readOnly:!0,note:`image asset id only`},{path:`shot.freeCamera`,type:`vec3`,persisted:!1,undoDomain:`shot`,normalizer:null,note:`transient until keyed`},{path:`scenes`,type:`array`,persisted:!0,undoDomain:null,normalizer:null,actions:[`scene.create`,`scene.duplicate`,`scene.rename`,`scene.delete`,`scene.switch`],note:`the project's scene list and the open scene; outside the undo history`},{path:`project`,type:`string`,persisted:!0,undoDomain:null,normalizer:null,actions:[`project.save`],note:`save to the current project file; opening one needs the user's file picker`},{path:`selection`,type:`id`,persisted:!1,undoDomain:null,normalizer:null},{path:`timeline`,type:`number`,persisted:!1,undoDomain:null,normalizer:null},{path:`view.mode`,type:`enum`,persisted:!1,undoDomain:null,normalizer:null,enum:[`scene`,`pose`,`camera`,`motion`]},{path:`view.partColoursGuideModeInset`,type:`array`,persisted:!1,undoDomain:null,normalizer:null,actions:[`view.setPartColours`,`view.setGuideMode`,`view.setInset`,`view.setGhosts`],note:`partColours/guideMode/inset/ghosts; viewer settings, not document fields`},{path:`read.sceneDescription`,type:`string`,persisted:!1,undoDomain:null,normalizer:null},{path:`read.captureFrame`,type:`image`,persisted:!1,undoDomain:null,normalizer:null},{path:`undo`,type:`boolean`,persisted:!1,undoDomain:null,normalizer:null}].map(e=>Object.freeze({...e,...e.enum?{enum:Object.freeze([...e.enum])}:{},...e.actions?{actions:Object.freeze([...e.actions])}:{},...e.min&&typeof e.min==`object`?{min:b(e.min)}:{},...e.max&&typeof e.max==`object`?{max:b(e.max)}:{},...e.gizmo?{gizmo:Object.freeze({min:b(e.gizmo.min),max:b(e.gizmo.max)})}:{}})));function le(e){return ce.find(t=>t.path===e)}var x=e=>e.persisted!==!1&&!e.actions&&!e.readOnly,ue=Object.freeze(`INVALID_ARGUMENT.INVALID_CONTEXT.INVALID_IDENTITY.INVALID_TURN_ID.INVALID_SESSION_ID.INVALID_RECEIPT.INVALID_RANGE.INVALID_REQUEST.UNKNOWN_TOOL.UNKNOWN_VARIANT.DUPLICATE_NAME.CONTEXT_LIMIT.CONTEXT_TOO_LARGE.AMBIGUOUS_TARGET.AMBIGUOUS_BASIS.TARGET_NOT_READY.TARGET_BUSY.STALE_TARGET.STALE_SCENE.STALE_ENVIRONMENT.STALE_CURSOR.CAPABILITY_MISSING.LIVE_HUB_UNAVAILABLE.AUTH_REQUIRED.GENERATION_LIMIT.RATE_LIMITED.BACKEND_UNAVAILABLE.VERIFICATION_FAILED.REPAIR_REGRESSED.CANCELLED.UNCERTAIN_APPLY.UNDO_CONFLICT.CONFIRMATION_REQUIRED.TIMEOUT.UNDO_EXPIRED.INTERNAL_ERROR.SCOPE_DENIED.SCOPE_BUSY`.split(`.`)),de=e=>e?.code??([`TypeError`,`ReferenceError`,`RangeError`,`SyntaxError`].includes(e?.name)?`INTERNAL_ERROR`:`INVALID_ARGUMENT`),fe=`#c2c6c8`,pe=[`#e2e5e6`,fe,`#9aa1a5`,`#767d81`,`#d9b18c`,`#8fae9b`,`#d94a4a`,`#4a7bd9`,`#e2c04a`,`#4fa86a`],me=6,S=`cozyclay.objectColors.recent`,C=/^#?([0-9a-f]{3})$/i,he=/^#?([0-9a-f]{6})$/i;function ge(e){if(typeof e!=`string`)return null;let t=e.trim(),n=C.exec(t);if(n)return`#${n[1].toLowerCase().replace(/./g,e=>e+e)}`;let r=he.exec(t);return r?`#${r[1].toLowerCase()}`:null}function _e(e,t){let n=Array.isArray(e)?e.map(ge).filter((e,t,n)=>e&&n.indexOf(e)===t&&!pe.includes(e)):[],r=ge(t),i=(r&&!pe.includes(r)?[r,...n.filter(e=>e!==r)]:n).slice(0,me);return Array.isArray(e)&&i.length===e.length&&i.every((t,n)=>t===e[n])?e:i}function ve(e){try{let t=JSON.parse(e?.getItem(S)??`[]`);return _e(Array.isArray(t)?t:[],null)}catch{return[]}}function ye(e,t){try{e?.setItem(S,JSON.stringify(t))}catch{}}var be=`effect`,xe={kind:be,label:`Effect`,group:`Effects`,footprint:{width:0,depth:0},height:0,color:`#7fd4f0`},w=(e,t,n)=>({x:e,y:t,z:n}),Se=w(0,0,0),Ce=Object.freeze({smoke:{rate:60,life:2.8,size:.012,grow:6,speed:.05,spread:.1,gravity:-.3,wind:w(.02,0,0),color:`#7d8a99`,opacity:.42,additive:!1,area:Se,width:0},exhale:{rate:120,life:2.4,size:.035,grow:8,speed:.9,spread:.35,gravity:-.35,wind:w(.02,0,0),color:`#a3abb4`,opacity:.3,additive:!1,area:w(.01,0,.01),width:0},steam:{rate:26,life:2,size:.03,grow:4,speed:.1,spread:.2,gravity:-.45,wind:w(.02,0,0),color:`#bcc5ce`,opacity:.2,additive:!1,area:w(.07,0,.07),width:0},fire:{rate:140,life:.75,size:.12,grow:.3,speed:.4,spread:.15,gravity:-2.2,wind:Se,color:`#ff7a1f`,opacity:1,additive:!0,area:w(.22,0,.22),width:0},sparks:{rate:40,life:1,size:.012,grow:.6,speed:2.6,spread:.55,gravity:6,wind:Se,color:`#ff9d33`,opacity:1,additive:!0,area:w(.05,0,.05),width:0},dust:{rate:30,life:7,size:.014,grow:1.2,speed:0,spread:1,gravity:.01,wind:w(.04,0,.01),color:`#a89a82`,opacity:.55,additive:!1,area:w(3,2.2,3),width:0},rain:{rate:1600,life:1.2,size:.01,grow:1,speed:0,spread:0,gravity:9.8,wind:Se,color:`#9aabbd`,opacity:.4,additive:!1,area:w(8,5,8),width:0},snow:{rate:220,life:8,size:.025,grow:1,speed:0,spread:0,gravity:9.8,wind:w(.1,0,0),color:`#ffffff`,opacity:.85,additive:!1,area:w(8,4,8),width:0},trail:{rate:0,life:.3,size:0,grow:1,speed:0,spread:0,gravity:0,wind:Se,color:`#a7b8ca`,opacity:.75,additive:!1,area:Se,width:.5}}),T=Object.freeze(Object.keys(Ce)),we={rate:[0,2e3],life:[.05,12],size:[.001,5],grow:[.05,20],speed:[0,60],spread:[0,1],gravity:[-30,30],opacity:[0,1],width:[0,10]},Te={wind:[-20,20],area:[0,100]},Ee=2147483647,De=([e,t],n,r)=>{let i=Number(n);return Number.isFinite(i)?Math.min(t,Math.max(e,i)):r};function Oe(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n=T.includes(t.preset)?t.preset:`smoke`,r=Ce[n],i={preset:n};for(let[e,n]of Object.entries(we))i[e]=De(n,t[e],r[e]);for(let[e,n]of Object.entries(Te)){let a=t[e]&&typeof t[e]==`object`?t[e]:{};i[e]=w(...[`x`,`y`,`z`].map(t=>De(n,a[t],r[e][t])))}i.color=ge(t.color)??r.color,i.additive=typeof t.additive==`boolean`?t.additive:r.additive;let a=Number(t.seed);return i.seed=Number.isFinite(a)?Math.min(Ee,Math.max(0,Math.round(a))):1,i}function ke(e){return e?.renderer===`effect`?{effect:Oe(e.effect)}:{}}function Ae(e,t){let n=e?.set?.effect?.preset;if(!T.includes(n))return e;let r=t?.find?.(t=>t.id===e.id)?.effect;if(r?.preset===n)return e;let i=structuredClone(Ce[n]);return{...e,set:{...e.set,effect:{...i,seed:r?.seed??1,...e.set.effect}}}}var je=(e,t)=>({type:`number`,minimum:e,maximum:t}),Me=([e,t])=>({type:`object`,properties:{x:je(e,t),y:je(e,t),z:je(e,t)},required:[],additionalProperties:!1}),Ne=Object.freeze({type:`object`,properties:{preset:{type:`string`,enum:[...T]},...Object.fromEntries(Object.entries(we).map(([e,[t,n]])=>[e,je(t,n)])),...Object.fromEntries(Object.entries(Te).map(([e,t])=>[e,Me(t)])),color:{type:`string`,minLength:1,maxLength:32,pattern:`^#[0-9a-fA-F]{6}$`},additive:{type:`boolean`},seed:{type:`integer`,minimum:0,maximum:Ee}},required:[],additionalProperties:!1}),Pe=`text`,Fe=[375,307,454,1117,800,1213,1007,289,486,486,828,828,303,525,303,828,828,828,828,828,828,828,828,828,828,828,304,306,828,828,828,785,1374,1069,938,1043,968,824,778,1057,953,365,760,996,763,1135,949,1094,838,1096,947,915,894,926,997,1399,999,931,906,444,532,446,828,828,288,786,822,828,836,808,525,839,782,326,361,771,363,1174,782,871,824,833,513,775,511,782,828,1150,826,828,753,599,240,597,949],Ie=Object.freeze({resolution:1e3,ascent:1090,descent:333}),Le=1.5,Re=1.25,ze=.8,Be=.005,Ve={size:[.02,10],depth:[0,2]},He=200,Ue=8,We=[`left`,`center`,`right`],Ge=Object.freeze({value:`Text`,size:.3,depth:0,align:`center`}),Ke={kind:Pe,label:`Text`,group:`Text`,footprint:{width:1,depth:Be},height:.3,color:fe},qe=Object.freeze({type:`object`,properties:{value:{type:`string`,minLength:1,maxLength:He},size:{type:`number`,minimum:Ve.size[0],maximum:Ve.size[1]},depth:{type:`number`,minimum:Ve.depth[0],maximum:Ve.depth[1]},align:{type:`string`,enum:We}},required:[],additionalProperties:!1}),Je=([e,t],n,r)=>{let i=Number(n);return Number.isFinite(i)?Math.min(t,Math.max(e,i)):r};function Ye(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n=[...(typeof t.value==`string`?t.value.replace(/\r\n?/g,`
|
|
2
|
+
`).split(`
|
|
3
|
+
`).slice(0,Ue):[]).join(`
|
|
4
|
+
`)].slice(0,He).join(``);return{value:n.trim()?n:Ge.value,size:Je(Ve.size,t.size,Ge.size),depth:Je(Ve.depth,t.depth,Ge.depth),align:We.includes(t.align)?t.align:Ge.align}}var Xe=e=>e>=4352&&e<=4607||e>=11904&&e<=42191||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519;function Ze(e){let t=e.codePointAt(0);return t>=32&&t<=126?Fe[t-32]/Ie.resolution:Xe(t)?Re:ze}function Qe(e){return e.depth>0&&[...e.value].every(e=>e===`
|
|
5
|
+
`||e.codePointAt(0)>=32&&e.codePointAt(0)<=126)}function $e(e){let{size:t,align:n}=e,r=e.value.split(`
|
|
6
|
+
`),i=r.map(e=>[...e].reduce((e,t)=>e+Ze(t),0)*t),a=Math.max(...i,t*.2),o=Ie.descent/Ie.resolution*t;return{width:a,height:(r.length-1)*Le*t+(Ie.ascent+Ie.descent)/Ie.resolution*t,rows:r.map((e,s)=>({text:e,width:i[s],x:n===`left`?-a/2:n===`right`?a/2-i[s]:-i[s]/2,baseline:o+(r.length-1-s)*Le*t}))}}function et(e){if(e?.renderer!==`text`)return{};let t=Ye(e.text),{width:n,height:r}=$e(t),i=e=>Number(e.toFixed(4));return{text:t,footprint:{width:i(n),depth:i(Math.max(t.depth,Be))},height:i(r),supportY:i(r)}}function tt(e,t){if(e?.renderer!==`text`||t?.text===void 0||!t.text||typeof t.text!=`object`)return{};let n=et({renderer:Pe,text:{...e.text,...t.text}});return JSON.stringify(n.text)===JSON.stringify(e.text)?{}:n}var nt=24,rt=40,it=e=>{let t=JSON.stringify(e)??String(e);return t.length>rt?`${t.slice(0,37)}...`:t},at=e=>e===null?`null`:Array.isArray(e)?`an array`:typeof e==`object`?`an object`:typeof e==`number`&&!Number.isFinite(e)?String(e):`a ${typeof e}`,ot=e=>e.length>nt?`${e.slice(0,nt).join(`, `)}, ... (${e.length} in all)`:e.join(`, `),st=e=>Object.hasOwn(e,`const`)?JSON.stringify(e.const):e.type===`integer`?`an integer`:e.type===`array`?`an array${e.items?.type?` of ${e.items.type}s`:``}`:e.type===`object`?`an object`:e.type===`null`?`null`:`a ${e.type}`,ct=(e,t,n)=>`${e}: expected ${st(t)}, got ${Object.hasOwn(t,`const`)?it(n):at(n)}.`,lt=(e,t,n)=>{let r=Object.keys(t.properties);return`${e} has unknown field ${it(n)}; ${r.length?`allowed: ${ot(r)}`:`it takes no fields`}.`},ut=(e,t)=>`${e}: missing required field "${t}".`;function dt(e,t,n){if(!Array.isArray(n))return ct(e,t,n);let r=t.minItems??0,i=t.maxItems??1/0;return`${e}: expected ${r===i?`exactly ${r}`:i===1/0?`at least ${r}`:r===0?`at most ${i}`:`${r} to ${i}`} item${r===i&&r===1?``:`s`}, got ${n.length}.`}var ft=(e,t)=>{let n=new Set,r=t.map(e=>JSON.stringify(e)).find(e=>n.has(e)?!0:(n.add(e),!1));return`${e}: items must be unique; ${r&&r.length<=rt?r:`one item`} appears twice.`};function pt(e,t,n){if(typeof n!=`string`)return ct(e,t,n);if(!n.trim())return`${e}: must not be empty.`;let r=[...n].length;return t.maxLength!==void 0&&r>t.maxLength?t.description?`${e}: over ${t.maxLength} characters. ${t.description}`:`${e}: at most ${t.maxLength} characters, got ${r}.`:`${e}: ${it(n)} does not match ${t.pattern}.`}var mt=(e,t,n)=>`${e}: ${it(n)} is not one of: ${ot(t.enum)}.`;function ht(e,t,n){return typeof n!=`number`||!Number.isFinite(n)?ct(e,t,n):t.type===`integer`&&!Number.isSafeInteger(n)?`${e}: expected an integer, got ${n}.`:`${e}: must be greater than ${t.exclusiveMinimum}, got ${n}.`}var gt=e=>e.oneOf??e.anyOf?(e.oneOf??e.anyOf).every(gt):e.type!==`object`&&e.type!==`array`,_t=e=>[e.minimum,e.maximum].some(e=>e!==void 0)?` within [${[e.minimum??`-inf`,e.maximum??`inf`].join(`, `)}]`:``,vt=e=>e.oneOf??e.anyOf?(e.oneOf??e.anyOf).flatMap(vt):Object.hasOwn(e,`const`)?[JSON.stringify(e.const)]:e.enum?e.enum.map(e=>JSON.stringify(e)):e.type===`boolean`?[`true`,`false`]:[`${st(e)}${e.type===`number`||e.type===`integer`?_t(e):``}`];function yt(e,t,n){if(!t.every(({error:t})=>t.details?.path===e)||typeof n==`object`&&n&&!t.every(({branch:e})=>gt(e)))return null;let r=[...new Set(t.flatMap(({branch:e})=>vt(e)))],i=r.length>nt?[...r.slice(0,nt),`... (${r.length} in all)`]:r;return`${e} must be ${i.length>1?`${i.slice(0,-1).join(`, `)} or ${i.at(-1)}`:i[0]}, got ${typeof n==`object`&&n?at(n):it(n)}.`}var bt=[`storyboard`,`animation`],xt=[`stand`,`sit`,`lie`],St=65536,Ct=Object.freeze({entities:24,entityIndex:400,shots:8,assets:48,recentReceipts:3,jobs:8}),wt=Object.freeze([`inspect_studio`,`run_action`,`verify_result`]);Object.freeze([`operate_studio`,`arrange_objects`,`arrange_characters`,`patch_elements`,`frame_shot`,`undo_edit`]);var Tt=Object.freeze({inspect_studio:`Read the scene`,operate_studio:`Selection and view`,arrange_objects:`Arrange objects`,arrange_characters:`Arrange characters`,patch_elements:`Edit properties`,frame_shot:`Frame the shot`,verify_result:`Verify the result`,undo_edit:`Undo an edit`,run_action:`Run an editor action`}),Et=Object.freeze(Object.keys(Tt)),Dt=Object.freeze([`character`,`object`,`shot`,`stage`]);Object.freeze({character:`cast`,object:`objects`,shot:`shot`,stage:`stage`});var E=O({selectionKinds:[`scene`,`object`,`character`,`rig`,`camera`],modes:[`scene`,`pose`,`camera`,`motion`],shotModes:[`keys`,`follow`,`rail`],framingSizes:[`extreme close-up`,`close-up`,`medium close-up`,`medium shot`,`medium-wide shot`,`wide shot`,`extreme wide shot`],framingViews:[`front`,`front three-quarter`,`profile`,`rear three-quarter`,`back`],framingLevels:[`ground`,`low`,`hip`,`eye`,`high`,`overhead`],framingSides:[`left`,`right`],positionSides:[`left`,`right`,`front`,`behind`],positionBases:[`world`,`subject`,`shot_camera`],collisionPolicies:[`report`,`avoid`],objectOps:[`create`,`update`,`remove`,`group`,`ungroup`],characterOps:[`create`,`update`,`remove`],inspectionScopes:[`selection`,`scene`,`entities`,`shot`,`motion`,`catalogue`,`actions`,`document`],receiptStatuses:[`applied`,`partial`,`noop`,`transient`,`installed`,`undone`],opStatuses:[`applied`,`partial`,`noop`],jobStates:[`queued`,`generating`,`preparing`,`verifying`,`repairing`,`committing`,`reconciling`,`installed`,`review_required`,`failed`,`cancelled`,`stale_target`,`stale_environment`]}),D=class extends Error{constructor(e,t,n={}){super(t),this.name=`StudioProtocolError`,this.code=e,this.details=n}toJSON(){return{code:this.code,message:this.message,...Object.keys(this.details).length?{details:this.details}:{}}}},Ot=e=>new TextEncoder().encode(e).byteLength;function O(e){if(e&&typeof e==`object`&&!Object.isFrozen(e)){for(let t of Object.values(e))O(t);Object.freeze(e)}return e}var k=(e,t,n=`$`,r={})=>{throw new D(e,t,{path:n,...r})},kt=e=>typeof e==`object`&&!!e&&!Array.isArray(e),A=(e=120)=>({type:`string`,minLength:1,maxLength:e}),j=(e,t)=>({type:`number`,...e===void 0?{}:{minimum:e},...t===void 0?{}:{maximum:t}}),M=(e=0,t=2**53-1)=>({...j(e,t),type:`integer`}),N={type:`boolean`},P=e=>({const:e}),F=e=>({type:`string`,enum:e}),I=e=>({oneOf:[e,{type:`null`}]}),L=(e,t,n=0,r=!1)=>({type:`array`,items:e,minItems:n,maxItems:t,...r?{uniqueItems:r}:{}}),R=(e,t={})=>({type:`object`,properties:{...e,...t},required:Object.keys(e),additionalProperties:!1}),z=(...e)=>({oneOf:e}),At={type:`object`,properties:{},required:[],additionalProperties:!0},B={...A(),pattern:`^[A-Za-z0-9][A-Za-z0-9._:-]*$`},jt={...A(36),pattern:`^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$`},V=R({x:j(),y:j(),z:j()}),H={type:`number`,exclusiveMinimum:0},Mt=R({x:H,y:H,z:H}),Nt={...R({startFrame:M(),endFrameExclusive:M(1)}),"x-studio-range":!0},U=(e=100,t=1)=>L(B,e,t,!0),W=A(120),Pt={...A(120),description:`Object id, or the name of a part created EARLIER in this ops list (create it first).`},Ft={workspaceId:B,documentEpoch:B,sceneId:B,sceneEpoch:B},It=R(Ft),Lt=R({surface:P(`studio`),...Ft,workspaceHandle:I(B)}),Rt=R({scene:M(),physics:M(),view:M()}),zt=I(R({kind:F(E.selectionKinds),id:B},{hierarchyId:B})),Bt=R({mode:F(E.modes),frame:M(),playing:N,lookThrough:N,grid:N,autoColor:N}),Vt=z(R({world:V}),R({relativeTo:Pt,basis:F(E.positionBases),side:F(E.positionSides),gapM:j(0),support:z(P(`floor`),R({objectId:Pt}))}),R({between:L(Pt,2,2,!0),fraction:j(0,1),support:P(`floor`)}),R({onObject:Pt},{offsetXZ:R({x:j(),z:j()})})),Ht=z(R({yawDeg:j()}),R({towardId:Pt}),R({sameAsId:Pt}),R({awayFromId:Pt})),Ut=z(R({intent:R({size:F(E.framingSizes),view:F(E.framingViews),level:F(E.framingLevels),side:F(E.framingSides)},{focalMm:H})}),R({exact:R({position:V,lookAt:V,focalMm:H})})),Wt={...F([`parent`]),description:`"parent" reads position.world, rotationDeg and facing.yawDeg in the parent's local frame (its pivot and rotation, not its scale); omit for world space.`},Gt=z(R({op:P(`create`),source:R({kind:B}),position:Vt},{name:W,facing:Ht,scale:Mt,rotationDeg:{...V,description:`Euler XYZ degrees (x pitch, y yaw, z roll), as in update. Exclusive with facing. A pitched/rolled part rests its lowest corner on its support.`},parent:{...W,description:`Group this new object under a parent: an existing object id, or the name of an object created earlier in this same ops list. Moving the parent then moves it too.`},space:Wt}),R({op:P(`update`),id:B},{position:Vt,facing:Ht,rotationDeg:V,scale:Mt,color:A(32),name:W,hidden:N,space:Wt}),R({op:P(`remove`),id:B}),R({op:P(`group`),parentId:B,childIds:U()}),R({op:P(`ungroup`),childIds:U()})),Kt=z(R({op:P(`create`),name:W,position:Vt},{facing:Ht,scale:H}),R({op:P(`update`),characterId:B},{position:Vt,facing:Ht,scale:H,name:W,hidden:N}),R({op:P(`remove`),characterId:B})),qt={...A(2097152),pattern:`^data:image/[A-Za-z0-9.+-]+[;,]`},Jt=R({frame:M(),framing:R({pos:V,yaw:j(),pitch:j(),fovDeg:j(1,179)})},{id:B}),Yt=z(j(0,1),R({t:j(0,1)},{bank:j(-90,90),pitch:j(-90,90)})),Xt=I(R({points:L(V,64,2)},{speed:j(0,50),faceTravel:N,loop:N,extend:N,marks:L(Yt,6)})),Zt=R({},{type:F([`point`,`spot`]),color:{...A(32),pattern:`^#[0-9a-fA-F]{6}$`},intensity:j(0,1e3),range:j(0,100),angle:j(1,89),softness:j(0,1),shadow:N,flicker:j(0,1),aim:I(V)}),Qt=I(R({},{color:{...A(32),pattern:`^#[0-9a-fA-F]{6}$`},intensity:j(0,20),halo:j(0,4)})),$t=I(At),en={"character.pose":I(B),"character.identityImage":I(qt),"object.light":Zt,"object.glow":Qt,"object.grasp":$t,"object.effect":Ne,"object.text":qe,"object.parent":I(B),"object.path":Xt,"stage.environmentImage":I(qt),"shot.cameraKeys":L(Jt,64),"shot.targetModel":I(B)};function tn(e){if(Object.hasOwn(en,e.path))return en[e.path];if(e.type===`number`)return j(e.min,e.max);if(e.type===`boolean`)return N;if(e.type===`enum`)return F([...e.enum]);if(e.type===`id`)return B;if(e.type===`color`)return{...A(32),pattern:`^#[0-9a-fA-F]{6}$`};if(e.type===`image`)return I(qt);if(e.type===`vec3`){let{min:t,max:n}=e;return t&&typeof t==`object`&&n&&typeof n==`object`?R({x:j(t.x,n.x),y:j(t.y,n.y),z:j(t.z,n.z)}):V}return e.type===`string`?A(240):null}function nn(e){return e.filter(x).map(({path:e,type:t,min:n,max:r,enum:i,note:a})=>({path:e,type:t,...n===void 0?{}:{min:n&&typeof n==`object`?{...n}:n},...r===void 0?{}:{max:r&&typeof r==`object`?{...r}:r},...i?{enum:[...i]}:{},...a?{note:a}:{}}))}var rn=O(nn(ce));function an(e){let t={};for(let n of Dt){let r={};for(let t of e){if(!x(t)||!t.path.startsWith(`${n}.`))continue;let e=tn(t);e&&(r[t.path.slice(n.length+1)]=e)}t[n]={type:`object`,properties:r,required:[],additionalProperties:!1}}return t}var on=O(an(ce)),sn=O(Object.fromEntries(Dt.map(e=>[e,Object.keys(on[e].properties).map(t=>`${e}.${t}`)]))),cn=z(R({target:R({kind:P(`character`),id:B}),set:on.character}),R({target:R({kind:P(`object`),id:B}),set:on.object}),R({target:R({kind:P(`shot`)},{id:B}),set:on.shot}),R({target:R({kind:P(`stage`)}),set:on.stage})),ln={inspect_studio:R({scope:F(E.inspectionScopes)},{ids:U(32),select:U(32),query:W,cursor:A(512),limit:{...M(1,32),default:12}}),operate_studio:R({},{selection:zt,shotId:B,frame:M(),playing:N,mode:F(E.modes),view:R({},{lookThrough:N,grid:N,autoColor:N})}),arrange_objects:R({ops:{...L(Gt,100,1),description:`Applied in order, as one undo step. Each op sees the parts created by earlier ops, so build an assembly in one call: create the main part, then place the rest with position.onObject / relativeTo(+side,gapM) / between naming earlier parts (e.g. relativeTo "Hood"). Reference parts created in this call by name, never by id.`}},{collisionPolicy:{...F(E.collisionPolicies),default:`report`}}),arrange_characters:R({ops:L(Kt,8,1)}),patch_elements:R({ops:L(cn,32,1)}),frame_shot:R({subjectIds:U(1),framing:Ut},{shotId:B,caption:{type:`string`,maxLength:500},keyAtFrame:M()}),verify_result:R({checks:{...L(F([`placement`,`framing`,`motion`,`lighting`]),4,1,!0),description:`lighting measures the shot frame rendered at the playhead: checks.lighting { meanLuma 0..1, clippedPct (a channel at full scale), crushedPct (pure black), subjects: [{ id, meanLuma, contrast (5th to 95th percentile luma spread, 0..1) }] inside each target character's projected box, look: { preset, envLight, ao } the stage look's environment light and occlusion strength }. motion also answers exportFraming (one per character with a take): what the camera the export renders shows of the take over sampledFrames: camera (shot where a shot covers the frame, studio = the Studio camera as it stands when none does; shotIds), character { screenFraction [min, max] of the frame height, inFrame [lowest share of its joints' screen box inside the frame, frame], behindCamera, cut { head, hand_l, hand_r, foot_l, foot_r } }, and every object the take names { id, name, inFrame, out, cut }; out, cut and behindCamera are spans [first, last] of sampled frames; { character: { id }, reason } when it cannot be measured`}},{receiptId:B,targets:U(),range:z(P(`whole_clip`),Nt),visual:{...F([`none`,`frame`,`contact_sheet`,`plan`,`trace`]),default:`none`},frames:{...z(F([`even`,`beats`]),L(M(),8,1,!0)),default:`even`,description:`contact_sheet frames: even spacing, beats (grab/release, beat starts, the worst QA frames, then even fill, answered in visualRefs[0].picks), or up to 8 timeline frames of your choice`},views:{...L(F([`front`,`side`,`three-quarter`,`top`]),2,1,!0),description:`contact_sheet from cameras of its own around the character instead of the shot camera (which stays as it is): a row per view, each held still over the frames and framed on focus, so small actions fill the tile; side and three-quarter look from the focus's side; a sheet always holds two views at least 60 degrees apart: if the asked ones look along nearly one line, side, front or top is added and named in visualRefs[0].addedView`},focus:{...z(A(120),L(A(120),3,1,!0)),description:`with views: what to frame, as refs (object:<id>, joint:<Bone>, prop:<prop>.<point>, landmark:mouth); default the whole character`},trail:{...z(A(120),L(A(120),3,1,!0)),description:`with views: refs whose path over the range is drawn as one dot per frame (spacing shows speed; later frames faint, the tile's own frame ringed), colours in visualRefs[0].trails`},ghosts:{...N,description:`with views: each tile also shows the first target's poses around its frame as translucent ghosts (onion skin), earlier ones blue, later ones orange, carried props included, so spacing and arcs read in one tile; how many and how far apart is view.setGhosts (while it is off: 3 each side, every 4 frames), answered in visualRefs[0].ghosts`}}),undo_edit:R({receiptId:B}),run_action:R({action:B},{args:At,confirmationToken:B})},un=O(ln),dn=O(Et.map(e=>({name:e,slice:1,parameters:ln[e]}))),fn=R({min:V,max:V}),pn=R({id:B,kind:F([`object`,`character`,`rig`]),token:B},{name:W,detailsOmitted:N,position:V,yawDeg:j(),rotationDeg:V,scale:z(H,Mt),bounds:I(fn),libraryKind:B,renderer:B,color:I(A(32)),tint:I(A(32)),modelId:I(A(120)),assetId:B,parentId:I(B),attachment:I(R({characterId:B,bone:I(B)})),pathPointCount:M(0,64),pathMarks:L(z(j(0,1),R({t:j(0,1)},{bank:j(-90,90),pitch:j(-90,90)})),6),local:R({position:V,rotationDeg:V}),motion:R({takeId:I(B),frames:M(),ikKeyCount:M()},{poseId:I(B),keyIds:U(8,0)}),capabilities:R({rigReady:N,ik:N,measuredFeet:N}),characterKind:F([`rig`,`proxy`]),posture:F(xt)}),mn=R({id:B,kind:F([`object`,`character`,`rig`])},{name:W,position:V}),hn=R({id:B},{label:W,generation:P(`motion`),timeoutMs:M(1,3e5)}),gn=R({id:B,name:W,range:Nt,keyCount:M()},{subjectIds:U(24,0),kind:F([`clip`,`still`]),caption:A(500)}),_n=R({id:B,name:W,range:Nt,mode:F(E.shotModes)},{subjectIds:U(24,0),kind:F([`clip`,`still`]),caption:A(500)}),vn=R({position:V,lookAt:V,focalMm:H,sensorId:B,slate:W}),yn=F([`primitive`,`set-piece`,`image`,`mesh`]),bn=z(R({kind:B,name:W,type:yn}),R({id:B,name:W,type:yn})),xn=R({id:B,characterId:B,state:F(E.jobStates)},{targetIds:U(24,0),progress:I(j(0,1)),phase:W}),Sn=R({schema:P(`studio-context-v1`),host:Lt,revision:Rt,units:R({distance:P(`m`),angle:P(`deg`),up:P(`+Y`),yawZero:P(`+Z`),yawPositiveToward:P(`+X`),pivot:P(`base`),fps:P(24),rangeEnd:P(`exclusive`)}),scene:R({name:W,aspect:A(40),floorY:j(),frameCount:M(),objectCount:M(),characterCount:M()},{previsMode:F(bt)}),selection:zt,activeCharacterId:I(B),view:Bt,shot:I(_n),camera:I(vn),entities:L(pn,24),entityPage:R({returned:M(0,24),total:M(),truncated:N,nextCursor:I(A(512))}),shots:L(gn,8),shotsTruncated:N,assets:L(bn,Ct.assets),recentReceipts:L(R({id:B,summary:W,canUndoDirect:N}),3),jobs:L(xn,8),capabilities:R({profile:P(`studio-slice-1`),tools:L(F(Et),Et.length,0,!0)},{rigReady:N,cameraReady:N,bridgeReady:N,storyboard:N})},{entityIndex:L(mn,Ct.entityIndex),actionIndex:L(hn,512)}),Cn=R({...Ft,targetId:B,token:B}),wn=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`,`ultra`],Tn=R({dataUrl:{...A(6e6),pattern:`^data:image/(png|jpeg|webp);base64,`}},{name:A(120)}),En=R({surface:P(`studio`),sessionId:jt,turnId:jt,text:A(16e3),context:Sn},{model:A(120),effort:F(wn),attachFrame:N,attachments:L(Tn,4,1),supervisor:N}),Dn=R({surface:P(`studio`),sessionId:jt,turnId:jt},{jobId:B}),On=R({before:M(),after:M()}),kn=R({historyEntryId:B,entries:P(1),canUndoDirect:N}),An=R({characterId:B,beforeTakeId:I(B),takeId:B,targetToken:B,frameCount:M(1),fps:P(24),durationSeconds:H,blocks:L(R({sourceBeat:M(0,7),startFrame:M(),endFrameExclusive:M(1)}),120,1),selectionChanged:P(!1)}),jn=R({id:B,status:F([`verified`,`unverified`]),profile:P(`studio-motion-v1`),range:Nt,evaluatedFrames:M(),physicsRevision:M(),limitations:L(W,12)},{surfaceMeasured:N,maxFloorPenetrationM:j(0),maxContactSlipM:j(0),maxContactFloatM:j(0),unsupportedFrames:M(),supportedCollisionFrames:M(),continuityRegressed:N,semanticStatus:F([`pending_image_review`,`passed`,`failed`,`unavailable`])}),Mn=R({path:A(120)},{number:j(),text:I(A(512)),flag:N,vec:V,count:M(),bytes:M()}),Nn=R({},{position:V,yawDeg:j(),rotationDeg:V,scale:z(H,Mt),name:W,color:A(32),hidden:N,modelId:B,renderer:B,parentId:I(B),childIds:U(100,0),childCount:M(0),bounds:I(fn),removed:N,range:Nt,camera:vn,keyId:B,frame:M(),subjectIds:U(24,0),selection:zt,activeCharacterId:I(B),shotId:I(B),view:Bt,token:B,takeId:I(B),statureM:H,patched:L(Mn,32,1)}),Pn=[`left`,`right`,`on-axis`],Fn=R({coverage:W},{relationSatisfied:N,overlapIds:U(100,0),actualGapM:j(),requestedGapM:j(0),maximumFootprintOverlapM:j(0),basis:F(E.positionBases),clipped:N,occluded:N,behindCamera:N,screenFraction:j(0),derivedSize:F(E.framingSizes),support:W,baseY:j(),facesTargetId:B,cameraSide:F(Pn),axisConsistent:N,evaluatedFrames:M(1),sampledFrames:L(M(),64,1),sampledChecks:L(R({frame:M(),screenFraction:j(),clipped:N,behindCamera:N,occluded:N}),64,1),issueFrames:L(R({frame:M(),codes:L(W,4,1),screenFraction:j()}),64,0)}),In=R({subjects:L(R({id:B,position:V,yawDeg:j()}),24),pairs:L(R({a:B,b:B,distanceM:j(0)}),24),shots:L(R({shotId:B,subjectIds:U(2,0),camera:I(R({position:V,lookAt:V})),cameraSide:I(F(Pn)),occluders:L(R({subjectId:B,byObjectId:B}),8)}),8),axisConsistent:I(N)}),Ln=R({code:B},{id:B,message:W,suggestedOutwardDeltaM:j(),count:M()}),Rn={ok:P(!0),commandId:B,receiptId:B,host:It,status:F(E.receiptStatuses),authored:N,revision:On,affectedIds:U(100,0),delta:L(R({id:B,after:Nn}),8),checks:Fn,undo:I(kn),warnings:L(Ln,12)},zn={counts:R({created:M(),updated:M(),deleted:M()}),detailCursor:I(A(512))},Bn=L(R({index:M(),status:F(E.opStatuses)},{droppedPaths:L(A(120),32,1)}),32,1),Vn={...Rn,authored:P(!0),undo:kn},Hn={action:B,summary:A(240)},Un={completed:R({...Rn,status:P(`completed`),kind:F([`job`,`document`,`transaction`,`mutation`])},{...Hn,...zn,output:At,jobId:B,txId:B,nextHost:It,ops:Bn}),started:R({...Rn,status:P(`started`),kind:P(`job`),jobId:B,authored:P(!1),undo:P(null)},{...Hn}),applied:R({...Vn,status:P(`applied`)},{mutated:P(!0),ops:Bn,...zn,...Hn}),partial:R({...Vn,status:P(`partial`),ops:Bn},{mutated:P(!0),...zn}),noop:R({...Rn,status:P(`noop`),authored:P(!1),mutated:P(!1),undo:P(null)},{ops:Bn,...Hn}),transient:R({...Rn,status:P(`transient`),authored:P(!1),view:On,undo:P(null)},{mutated:N,...Hn}),installed:R({...Vn,status:P(`installed`),jobId:B,artifactId:B,installed:An,verification:jn},{mutated:P(!0),explicitUnverifiedAcceptance:N,acceptance:P(`advisory-policy`),repairs:R({autoPhysicsInvocations:M(0,1),fixCollisionsInvocations:M(0,1),remaining:M(0,2)}),...zn}),undone:R({...Vn,status:P(`undone`),undoneReceiptId:B,restoredTargets:L(Cn,100,1)},{mutated:P(!0),...zn})},Wn=z(...Object.values(Un)),Gn=R({ok:P(!1),commandId:B,host:It,code:F(ue),phase:F([`admission`,`execution`,`prepare`,`verify`,`repair`,`commit`,`reconcile`,`undo`]),affectedIds:U(100,0),expectedTargets:L(Cn,24),currentTargets:L(Cn,24),mutated:z(N,P(`unknown`)),preserved:R({authoredState:F([`unchanged`,`changed`,`unknown`])}),recovery:R({action:F([`none`,`inspect`,`retry`,`new_intent`,`reconcile`,`sign_in`])},{retryAllowed:N})},{message:A(500),jobId:B,txId:B,candidates:L(R({id:B,kind:F([`object`,`character`,`rig`]),position:I(V)}),5)}),Kn=O({catalogue:dn,variants:E,Vec3:V,FrameRange:Nt,PositionSpec:Vt,FacingSpec:Ht,ObjectOp:Gt,CharacterOp:Kt,Framing:Ut,Identity:It,Host:Lt,TargetGuard:Cn,Entity:pn,ShotSummary:gn,StudioContextV1:Sn,StudioTurn:En,StudioStop:Dn,Receipt:Wn,ReceiptVariants:Un,Failure:Gn,GeometryFacts:In});function G(e,t,n=`INVALID_ARGUMENT`,r=`$`){if(e.oneOf||e.anyOf){let i=[],a=[];for(let o of e.oneOf??e.anyOf)try{i.push(G(o,t,n,r))}catch(e){if(!(e instanceof D))throw e;a.push({branch:o,error:e})}if(i.length===0&&a.length){let e=kt(t)&&kt(t.target)?t.target.kind:void 0,i=e!==void 0&&a.find(({branch:t})=>t.properties?.target?.properties?.kind?.const===e),o=!i&&yt(r,a,t);throw o&&k(n,o,r),(i||a.reduce((e,t)=>t.error.details.path.length>e.error.details.path.length?t:e)).error}return i.length!==1&&e.oneOf&&k(n,`${r}: matches ${i.length} variants; send the fields of exactly one.`,r),i[0]}if(Object.hasOwn(e,`const`))return t!==e.const&&k(n,ct(r,e,t),r),t;if(e.type===`null`)return t!==null&&k(n,ct(r,e,t),r),null;if(e.type===`object`){kt(t)||k(n,ct(r,e,t),r);let i=e.additionalProperties===!0;for(let a of Object.keys(t))!Object.hasOwn(e.properties,a)&&!i&&k(n,lt(r,e,a),r);let a={};if(i)for(let n of Object.keys(t))Object.hasOwn(e.properties,n)||(a[n]=structuredClone(t[n]));for(let[i,o]of Object.entries(e.properties))Object.hasOwn(t,i)?a[i]=G(o,t[i],n,`${r}.${i}`):e.required.includes(i)?k(n,ut(r,i),`${r}.${i}`):Object.hasOwn(o,`default`)&&(a[i]=structuredClone(o.default));return e[`x-studio-range`]&&a.endFrameExclusive<=a.startFrame&&k(n,`Frame range must be nonempty and half-open.`,r),a}if(e.type===`array`){(!Array.isArray(t)||t.length<e.minItems||t.length>e.maxItems)&&k(n,dt(r,e,t),r);let i=t.map((t,i)=>G(e.items,t,n,`${r}[${i}]`));return e.uniqueItems&&new Set(i.map(e=>JSON.stringify(e))).size!==i.length&&k(n,ft(r,i),r),i}if(e.type===`string`)return(typeof t!=`string`||!t.trim()||e.maxLength!==void 0&&[...t].length>e.maxLength||e.pattern&&!new RegExp(e.pattern).test(t))&&k(n,pt(r,e,t),r),e.enum&&!e.enum.includes(t)&&k(n,mt(r,e,t),r),t;if(e.type===`boolean`)return typeof t!=`boolean`&&k(n,ct(r,e,t),r),t;if(e.type===`number`||e.type===`integer`)return(typeof t!=`number`||!Number.isFinite(t)||e.type===`integer`&&!Number.isSafeInteger(t)||e.exclusiveMinimum!==void 0&&t<=e.exclusiveMinimum)&&k(n,ht(r,e,t),r),(e.minimum!==void 0&&t<e.minimum||e.maximum!==void 0&&t>e.maximum)&&k(n,`${r}: Expected a number within [${[e.minimum,e.maximum].filter(e=>e!==void 0).join(`, `)}], got ${t}.`,r),t;throw Error(`Unsupported internal Studio schema.`)}var qn=e=>G(It,e,`INVALID_IDENTITY`);function Jn(e){return[...new Set([...[`object`,`character`,`rig`].includes(e.selection?.kind)?[e.selection.id]:[],...e.activeCharacterId?[e.activeCharacterId]:[],...e.shot?.subjectIds??[],...e.jobs.flatMap(e=>[e.characterId,...e.targetIds??[]])])]}function Yn(e){let t=Ot(JSON.stringify(e)??``);t>65536&&k(`CONTEXT_TOO_LARGE`,`Studio context exceeds ${St/1024} KiB.`,`$`,{bytes:t,maxBytes:St});let n=G(Sn,e,`INVALID_CONTEXT`),r=new Set(n.entities.map(e=>e.id));r.size!==n.entities.length&&k(`INVALID_CONTEXT`,`Duplicate entity ID.`);for(let e of Jn(n))r.has(e)||k(`TARGET_NOT_READY`,`Mandatory target is absent from context.`);n.activeCharacterId&&!n.entities.some(e=>e.id===n.activeCharacterId&&e.kind===`character`)&&k(`INVALID_CONTEXT`,`Active target is not a character.`),[`object`,`character`,`rig`].includes(n.selection?.kind)&&!n.entities.some(e=>e.id===n.selection.id&&e.kind===n.selection.kind)&&k(`INVALID_CONTEXT`,`Selection kind disagrees with the selected entity.`),n.selection?.kind===`scene`&&n.selection.id!==n.host.sceneId&&k(`INVALID_CONTEXT`,`Selected scene is not the bound scene.`);for(let e of n.entities)e.bounds&&[`x`,`y`,`z`].some(t=>e.bounds.min[t]>e.bounds.max[t])&&k(`INVALID_CONTEXT`,`Inverted entity bounds.`),e.kind===`object`&&typeof e.scale==`number`&&k(`INVALID_CONTEXT`,`Objects use three-axis scale.`),e.kind!==`object`&&kt(e.scale)&&k(`INVALID_CONTEXT`,`Cast uses scalar scale.`);let i=n.entityPage;if((i.returned!==n.entities.length||i.total<i.returned||i.truncated!==i.total>i.returned||(i.truncated?i.nextCursor===null:i.nextCursor!==null))&&k(`INVALID_CONTEXT`,`Entity pagination is inconsistent.`),n.entityIndex){let e=new Set(n.entityIndex.map(e=>e.id));e.size!==n.entityIndex.length&&k(`INVALID_CONTEXT`,`Duplicate entity index ID.`),(n.entityIndex.length>i.total||n.entities.some(t=>!e.has(t.id)))&&k(`INVALID_CONTEXT`,`Entity index must cover every detailed entity and no more than the total.`)}n.view.frame>=Math.max(1,n.scene.frameCount)&&k(`INVALID_CONTEXT`,`Playhead is outside the scene.`),new Set(n.shots.map(e=>e.id)).size!==n.shots.length&&k(`INVALID_CONTEXT`,`Duplicate shot ID.`);for(let e of[...n.shots,...n.shot?[n.shot]:[]])e.range.endFrameExclusive>n.scene.frameCount&&k(`INVALID_CONTEXT`,`Shot is outside the scene.`);return n.shot&&!n.shots.some(e=>e.id===n.shot.id&&e.range.startFrame===n.shot.range.startFrame&&e.range.endFrameExclusive===n.shot.range.endFrameExclusive)&&k(`INVALID_CONTEXT`,`Current shot and range must survive projection.`),n}function Xn(e){let t=new Set;for(let n of Array.isArray(e?.ops)?e.ops:[]){let e=kt(n)?n.target?.kind:void 0;if(Dt.includes(e)){t.add(e);for(let t of kt(n.set)?Object.keys(n.set):[])Object.hasOwn(on[e].properties,t)||k(`INVALID_ARGUMENT`,`Unknown ${e} path "${e}.${t}". Valid ${e} paths: ${sn[e].join(`, `)}.`)}}t.size>1&&k(`INVALID_ARGUMENT`,`One domain per patch: split character, object, shot and stage edits into separate commands.`)}function Zn(e){(!kt(e)||!Et.includes(e.name))&&k(`UNKNOWN_TOOL`,`Unsupported Studio tool.`),e.name===`patch_elements`&&Xn(e.args);let{args:t}=G(R({name:F(Et),args:ln[e.name]}),e);if(e.name===`inspect_studio`&&t.ids&&t.query!==void 0&&k(`INVALID_ARGUMENT`,`IDs and query are exclusive.`),e.name===`operate_studio`&&(!Object.keys(t).length||t.view&&!Object.keys(t.view).length)&&k(`INVALID_ARGUMENT`,`Transient operation must specify an action.`),t.ops){let e=t.ops.filter(e=>e.op===`create`&&e.name!==void 0).map(e=>e.name.normalize(`NFC`).trim());new Set(e).size!==e.length&&k(`DUPLICATE_NAME`,`Create names must be unique; resolve existing targets by ID.`);for(let e of t.ops)e.op===`update`&&Object.keys(e).length===2&&k(`INVALID_ARGUMENT`,`Update has no fields.`),e.facing&&e.rotationDeg&&k(`INVALID_ARGUMENT`,`Facing and rotationDeg are exclusive: facing sets yaw only (toward/away/same-as/yawDeg); rotationDeg {x,y,z} sets the full rotation, with y as the yaw.`),e.op===`group`&&e.childIds.includes(e.parentId)&&k(`INVALID_ARGUMENT`,`Cannot group an object under itself.`),e.op===`create`&&e.parent!==void 0&&e.name!==void 0&&e.parent.normalize(`NFC`).trim()===e.name.normalize(`NFC`).trim()&&k(`INVALID_ARGUMENT`,`Cannot group an object under itself.`);t.collisionPolicy===`avoid`&&!t.ops.some(e=>[`create`,`update`].includes(e.op)&&e.position?.relativeTo)&&k(`INVALID_ARGUMENT`,`collisionPolicy avoid needs at least one op with position.relativeTo (it nudges outward from that reference); other ops are placed as given.`)}if(e.name===`frame_shot`&&t.framing.exact&&JSON.stringify(t.framing.exact.position)===JSON.stringify(t.framing.exact.lookAt)&&k(`INVALID_ARGUMENT`,`Camera position and aim cannot coincide.`),e.name===`patch_elements`)for(let e of t.ops)Object.keys(e.set).length||k(`INVALID_ARGUMENT`,`Patch has no fields.`);return e.name===`verify_result`&&(!!t.receiptId==!!t.targets&&k(`INVALID_ARGUMENT`,`Exactly one of receiptId or targets is required.`),t.checks.includes(`motion`)&&t.range===void 0&&(t.range=`whole_clip`,Object.defineProperty(t,"rangeWasDefaulted",{value:!0,enumerable:!1}))),{name:e.name,args:t}}function K(e){if(e?.ok===!1){let t=G(Gn,e,`INVALID_RECEIPT`);return Ot(JSON.stringify(t))>8192&&k(`INVALID_RECEIPT`,`Failure receipt exceeds 8 KiB.`),(t.mutated===!1&&t.preserved.authoredState!==`unchanged`||t.mutated===!0&&t.preserved.authoredState!==`changed`||t.mutated===`unknown`&&(t.preserved.authoredState!==`unknown`||t.recovery.action!==`reconcile`||t.recovery.retryAllowed===!0))&&k(`INVALID_RECEIPT`,`Failure must preserve uncertainty and actual state evidence.`),O(t)}let t=G(Wn,e,`INVALID_RECEIPT`);if(Ot(JSON.stringify(t))>8192&&k(`INVALID_RECEIPT`,`Receipt exceeds 8 KiB; use a detail cursor.`),t.delta.some(e=>!t.affectedIds.includes(e.id)||!Object.keys(e.after).length)&&k(`INVALID_RECEIPT`,`Readback must identify affected targets and actual state.`),t.ops){let e=t.ops.some(e=>e.status===`partial`);t.ops.some((e,t)=>e.index!==t)&&k(`INVALID_RECEIPT`,`Operation results must report every operation in order.`),t.ops.some(e=>e.status===`partial`!=!!e.droppedPaths?.length)&&k(`INVALID_RECEIPT`,`A partial operation must name the paths the domain dropped, and only a partial one may.`),t.status===`applied`&&e&&k(`INVALID_RECEIPT`,`Applied status cannot hide a dropped path.`),t.status===`partial`&&!e&&k(`INVALID_RECEIPT`,`Partial status requires at least one dropped path.`),t.status===`noop`&&t.ops.some(e=>e.status===`applied`)&&k(`INVALID_RECEIPT`,`A noop cannot report an applied operation.`)}if(t.status===`started`||t.status===`completed`?(t.revision.after<t.revision.before&&!t.nextHost&&k(`INVALID_RECEIPT`,`Completion revisions must not move backwards in one document.`),t.status===`started`&&(t.authored||t.undo||t.revision.before!==t.revision.after)&&k(`INVALID_RECEIPT`,`Started jobs cannot claim an authored commit.`),t.kind===`mutation`&&(!t.authored||!t.undo||t.revision.after<=t.revision.before||!t.delta.length)&&k(`INVALID_RECEIPT`,`A completed composite mutation needs retained undo and advancing revision evidence.`),t.undo&&(!t.authored||!t.affectedIds.length)&&k(`INVALID_RECEIPT`,`An undo entry requires an authored result and affected targets.`)):t.status===`noop`||t.status===`transient`?((t.authored||t.undo!==null||t.revision.before!==t.revision.after)&&k(`INVALID_RECEIPT`,`Non-authored operations cannot create history or advance authored revision.`),t.status===`noop`&&(t.mutated!==!1||t.delta.length)&&k(`INVALID_RECEIPT`,`Noop must prove no mutation.`),t.status===`transient`&&(!t.view||t.view.after<t.view.before||!t.delta.length)&&k(`INVALID_RECEIPT`,`Transient receipt requires view revisions and actual readback.`)):((!t.authored||!t.undo||t.revision.after!==t.revision.before+1||!t.affectedIds.length||!t.delta.length||t.mutated===!1)&&k(`INVALID_RECEIPT`,`Authored mutation requires one revision and one undo entry with actual readback.`),t.delta.length<t.affectedIds.length&&!t.detailCursor&&k(`INVALID_RECEIPT`,`Omitted batch readback requires a detail cursor.`)),t.status===`undone`&&(new Set(t.restoredTargets.map(e=>e.targetId)).size!==t.affectedIds.length||t.restoredTargets.some(e=>!t.affectedIds.includes(e.targetId)||Object.keys(Ft).some(n=>e[n]!==t.host[n])))&&k(`INVALID_RECEIPT`,`Undo must identify every restored target and its new token in the bound host.`),t.status===`installed`){(!t.jobId||!t.artifactId||!t.installed||!t.verification||!t.affectedIds.includes(t.installed.characterId))&&k(`INVALID_RECEIPT`,`Installation requires correlated target, artifact and verification evidence.`);let{frameCount:e,blocks:n}=t.installed,r=0;for(let e of n)(e.startFrame!==r||e.endFrameExclusive<=r||e.endFrameExclusive-r>120)&&k(`INVALID_RECEIPT`,`Installed schedule is not contiguous or bounded.`),r=e.endFrameExclusive;(r!==e||t.installed.durationSeconds!==e/24||t.verification.range.startFrame!==0||t.verification.range.endFrameExclusive!==e||t.verification.evaluatedFrames>e)&&k(`INVALID_RECEIPT`,`Installed schedule and verification coverage disagree.`),t.verification.status===`verified`&&t.verification.evaluatedFrames!==e&&k(`INVALID_RECEIPT`,`Verified motion requires whole-clip coverage.`),t.verification.status===`unverified`&&t.explicitUnverifiedAcceptance!==!0&&t.acceptance!==`advisory-policy`&&k(`INVALID_RECEIPT`,`Unverified installation requires explicit user or advisory-policy acceptance.`)}else(t.installed||t.verification||t.jobId&&![`started`,`completed`].includes(t.status)||t.artifactId||t.repairs||t.explicitUnverifiedAcceptance!==void 0)&&k(`INVALID_RECEIPT`,`Installation evidence is exclusive to installed receipts.`);return O(t)}var Qn=[`begin`,`mark`,`rollback`,`finish`,`cancel`],$n=(e,t)=>Object.fromEntries(Qn.map(n=>[`agent.turn.${n}`,e({turnId:t})]));function er(e,t){if(e===`agent.turn.mark`)return t.mark={point:t.session?.savepoint()??null,affectedIds:new Set(t.affectedIds),since:new Set},{txId:t.txId,affectedIds:[],toasts:[]};let{mark:n}=t;if(!n)throw new D(`STALE_TARGET`,`The agent turn has no mark to roll back to.`);return t.mark=null,t.edits=(t.edits??[]).filter(e=>e.mark!==n),t.session?.rollback(n.point??void 0),t.affectedIds=n.affectedIds,{txId:t.txId,affectedIds:[...n.since],toasts:[]}}var tr=e=>e&&{point:e.session?.savepoint()??null,affectedIds:new Set(e.affectedIds),since:e.mark&&new Set(e.mark.since),mark:e.mark};function nr(e,t,n){return e&&t&&n?.ok&&n.authored&&(e.edits??=[]).push({...t,receiptId:n.receiptId,ids:n.affectedIds}),n}function rr(e,t,n,r,i){let a=e.edits??[],o=a.findIndex(e=>e.receiptId===t.receiptId);if(o<0)throw new D(`TARGET_BUSY`,`Finish the agent turn before traversing history or opening another transaction. Inside the turn, undo_edit with the receiptId of this message's newest edit reverts it${a.length?` (now ${a.at(-1).receiptId})`:``}; an earlier message's edit is undone after this one ends.`);let s=a[o];if(o<a.length-1)throw new D(`UNDO_CONFLICT`,`Later edits of this message come after it; undo them first, newest first: ${a.slice(o+1).reverse().map(e=>e.receiptId).join(`, `)}.`);return e.session.rollback(s.point??void 0),a.pop(),e.affectedIds=s.affectedIds,e.mark&&s.mark!==e.mark?e.mark={point:e.session.savepoint(),affectedIds:new Set(e.affectedIds),since:new Set}:e.mark&&(e.mark.since=s.since),{ok:!0,status:`completed`,kind:`transaction`,action:`edit.undo`,txId:e.txId,commandId:n.commandId,receiptId:crypto.randomUUID(),host:r.host,summary:`Undid ${s.receiptId} inside this message.`,authored:!1,revision:{before:r.revision,after:i().revision},affectedIds:s.ids,delta:[],checks:{coverage:`agent-turn-savepoint`},undo:null,warnings:[],output:{undoneReceiptId:s.receiptId}}}var ir=new Set([`timeline`,`scene`]),ar=/^(?:(?:object|character|shot):[A-Za-z0-9][A-Za-z0-9._:-]*|stage|timeline|scene)$/,or=e=>typeof e==`string`&&e.length<=140&&ar.test(e),sr=[`cast.replace`,`cast.setCustomPoses`,`cast.showExtras`,`cast.removePose`,`objects.replace`,`shot.replace`,`ai.prepareShot`],cr=[`shot.create`,`shot.createStill`,`shot.split`,`shot.duplicate`,`shot.remove`,`shot.reorder`,`shot.setRange`,`shot.setTimeline`],lr=[`object.add`,`object.createKit`,`asset.import`,`character.add`],ur=/^(character\.|characters?\b|cast\.(savePose|setLayer)$|ik\.|motion\.)/;function dr(e,t){let n=t?.objects??[],r=new Set,i=e=>{if(!(!e||r.has(`object:${e}`))){r.add(`object:${e}`);for(let t of n)t.parent===e&&i(t.id)}};for(let t of e)i(t);return[...r]}var fr=(e,t)=>e.flatMap(e=>e.op===`create`?[]:e.op===`group`?dr([e.parentId,...e.childIds],t):e.op===`ungroup`?dr(e.childIds,t):dr([e.id],t));function pr(e,t={},n={},r={}){if(r.kind===`document`||/^(scene|project)\./.test(e)||e===`load_scenes`||sr.includes(e))return[`scene`];if(r.readOnly||r.kind===`transient`||/^(view|timeline)\./.test(e)||[`motion.qa`,`motion.sample`,`motion.describe`,`motion.report`,`sculpt.compare`,`export.shotVideo`].includes(e)||lr.includes(e))return[];if(e===`objects.batch`)return[...new Set(t.ops.flatMap(e=>pr(e.name,e.args,n)))];if(e===`objects.arrange`)return[...new Set(fr(t.ops,n))];if(e===`characters.arrange`)return t.ops.flatMap(e=>e.op===`create`?[]:[`character:${e.characterId}`]);if(e.startsWith(`stage.`)||e===`shot.setLens`)return[`stage`];if(cr.includes(e))return[`timeline`];if(e.startsWith(`shot.`)){let e=t.shotId??t.id??n.selectedShotId;return e?[`shot:${e}`]:[`timeline`]}return e===`object.group`?dr([t.parent,...t.children],n):e===`object.ungroup`?dr(t.children,n):e===`object.remove`?dr(t.ids,n):e===`object.attach`||e===`motion.keyObject`?[`character:${t.characterId}`,...dr([t.objectId],n)]:e.startsWith(`object.`)?dr([t.id??t.objectId],n):ur.test(e)&&(t.characterId??t.id)?[`character:${t.characterId??t.id}`]:[`scene`]}function mr(e,t={}){return(t.objects??[]).some(t=>t.id===e)?`object:${e}`:(t.characters??[]).some(t=>t.id===e)?`character:${e}`:(t.shots??[]).some(t=>t.id===e)?`shot:${e}`:null}function hr(e,t,n){for(let r of n.values()){if(r.taskId===e)continue;let n=t.find(e=>r.keys.has(e)||ir.has(e)||[...r.keys].some(e=>ir.has(e)));if(n)return`${n} is held by task ${r.taskId}${r.title?` (${r.title})`:``}`}return null}var q=(e,t)=>{throw new D(e,t)},gr=[`begin`,`requestScope`,`mark`,`rollback`,`finish`,`cancel`,`undo`],_r=32,vr=e=>[...e].slice(0,6).join(`, `)+(e.length>6?` and ${e.length-6} more`:``);function yr({ports:e,emit:t}){let n=new Map,r=new Map,i=new Map,a=t=>{let[n,r]=t.split(/:(.*)/s);if(r!==void 0)return e.readTarget?.(r)??`absent`;let i=e.read();return n===`scene`?`r${i.revision}`:`${n}:${i.domainRevisions?.[n===`timeline`?`shot`:n]??0}`},o=t=>({key:t,value:e.snapshotTarget?e.snapshotTarget(t):q(`CAPABILITY_MISSING`,`This editor cannot snapshot task targets.`)});function s(n,r,o){if(n.skipped=r.filter(e=>e.value===null).map(e=>e.key),r=r.filter(e=>e.value!==null),!r.length)return null;e.restoreTargets||q(`CAPABILITY_MISSING`,`This editor cannot restore task targets.`);let{historyEntryId:s=null}=e.restoreTargets(r)??{};s&&i.set(s,n.taskId),n.restored=[...new Set(r.map(({key:t})=>t.includes(`:`)?t.slice(t.indexOf(`:`)+1):e.read().host.sceneId))];for(let{key:e}of r)n.tokens.set(e,a(e));return t?.({type:`task.${o}`,taskId:n.taskId,keys:r.map(e=>e.key)}),s}function c(e,t){let r=t.find(e=>!or(e));r!==void 0&&q(`INVALID_ARGUMENT`,`"${r}" is not a scope key: object:<id>, character:<id>, shot:<id>, stage, timeline or scene.`);let i=hr(e.taskId,t,n);i&&q(`SCOPE_BUSY`,`${i}; wait for it, or ask for what is free.`);for(let n of t)e.keys.has(n)||(e.keys.add(n),e.tokens.set(n,a(n)))}function l(t,n,r,i,{historyEntryId:a=null,affectedIds:o=[],output:s,warnings:c=[]}={}){let l=e.read();return n.skipped?.length&&(c=[...c,{code:`SCOPE_NOT_RESTORED`,message:`Left as they are (a document change has no undo): ${vr(n.skipped)}.`}]),n.skipped=null,K({ok:!0,status:`completed`,kind:`transaction`,commandId:r.commandId,receiptId:crypto.randomUUID(),host:i.host,action:t,txId:n.taskId,authored:!!a,revision:{before:i.revision,after:l.revision},affectedIds:a&&!o.length?n.restored:o,delta:[],checks:{coverage:`task-scope`},warnings:c,undo:a?{historyEntryId:a,entries:1,canUndoDirect:!1}:null,output:{scope:[...n.keys],...s}})}let u=(e,t)=>{(e.origin!==`agent`||e.taskId!==t)&&q(`CAPABILITY_MISSING`,`Only the owning task can control it.`)};return{get size(){return n.size},controls:(e,t)=>Object.fromEntries(gr.map(n=>[`task.${n}`,n===`begin`||n===`requestScope`?{...e({taskId:t,scope:{type:`array`,items:{type:`string`},maxItems:64}}),properties:{taskId:t,scope:{type:`array`,items:{type:`string`},maxItems:64},reads:{type:`array`,items:{type:`string`},maxItems:64},title:{type:`string`,maxLength:120}}}:e({taskId:t})])),of(e,t){if(!e.taskId)return null;let r=n.get(e.taskId);return!r&&!t.startsWith(`task.`)&&q(`STALE_TARGET`,`Task ${e.taskId} is not open.`),r??null},control(e,i,d,f,p){if(e===`task.undo`){let t=r.get(i.taskId)??q(`UNDO_EXPIRED`,`Task ${i.taskId} is not a finished task this editor still holds.`),n=[...t.final].filter(([e,t])=>a(e)!==t).map(([e])=>e);n.length&&q(`UNDO_CONFLICT`,`Changed since the task finished: ${vr(n)}; undo those first or edit by hand.`);let o=s(t,[...t.pre.values()],`undone`);return r.delete(i.taskId),l(e,t,d,f,{historyEntryId:o,affectedIds:t.affectedIds})}if(u(d,i.taskId),e===`task.begin`){p&&q(`TARGET_BUSY`,p),(n.has(i.taskId)||r.has(i.taskId))&&q(`INVALID_ARGUMENT`,`Task ${i.taskId} already exists.`);let a={taskId:i.taskId,title:i.title??``,keys:new Set,reads:new Set(i.reads??[]),tokens:new Map,pre:new Map,edits:[],notices:[],affectedIds:[]};return c(a,i.scope),n.set(a.taskId,a),t?.({type:`task.begun`,taskId:a.taskId,scope:[...a.keys]}),l(e,a,d,f)}let m=n.get(i.taskId)??q(`STALE_TARGET`,`Task ${i.taskId} is not open.`);if(e===`task.requestScope`)return c(m,i.scope),l(e,m,d,f);if(e===`task.mark`)return m.mark={values:[...m.keys].map(o),keys:new Set(m.keys)},l(e,m,d,f);if(e===`task.rollback`){let t=m.mark??q(`STALE_TARGET`,`The task has no mark to roll back to.`);m.mark=null;let n=[...m.keys].filter(e=>!t.keys.has(e)).map(e=>m.pre.get(e)??o(e)),r=s(m,[...t.values,...n],`rolledBack`);return m.edits=m.edits.filter(e=>e.mark!==t),l(e,m,d,f,{historyEntryId:r})}if(n.delete(m.taskId),e===`task.cancel`)return l(e,m,d,f,{historyEntryId:s(m,[...m.pre.values()],`cancelled`),affectedIds:m.affectedIds});for(m.final=new Map([...m.pre.keys()].map(e=>[e,a(e)])),r.set(m.taskId,m);r.size>_r;)r.delete(r.keys().next().value);return t?.({type:`task.finished`,taskId:m.taskId}),l(e,m,d,f,{affectedIds:m.affectedIds,output:{edits:m.edits.length}})},admit(e,t,r,i,s){if(!e&&(i.origin===`ui`||!n.size))return null;let c=t?.id?pr(t.id,r,s,t):[];if(!e){let e=c.find(e=>hr(null,[e],n));return e&&q(`SCOPE_BUSY`,`${hr(null,[e],n)}; this command waits for that task.`),null}let l=c.filter(t=>!e.keys.has(t));l.length&&q(`SCOPE_DENIED`,`Outside this task's scope: ${vr(l)}. Ask for it with task.requestScope, or leave it to the task that holds it.`);let u=c.filter(t=>e.tokens.has(t)&&a(t)!==e.tokens.get(t));if(u.length){for(let t of u)e.tokens.set(t,a(t));q(`STALE_TARGET`,`${vr(u)} changed outside this task (the user, or an undo) since it last looked; read it again, then retry.`)}for(let t of c)e.pre.has(t)||e.pre.set(t,o(t));return{task:e,keys:c,values:c.map(o),mark:e.mark}},record(r,o){if(!r||!o?.ok)return o;let{task:s}=r,c=e.read(),l=[];for(let e of o.affectedIds??[]){let t=mr(e,c);!t||s.keys.has(t)||(hr(s.taskId,[t],n)?l.push({code:`SCOPE_DENIED`,message:`${t} changed outside the task's scope.`}):(s.keys.add(t),r.keys.includes(t)||(s.pre.set(t,{key:t,value:void 0}),r.values.push({key:t,value:void 0}))))}for(let e of s.keys)s.tokens.set(e,a(e));if(o.authored){s.edits.push({receiptId:o.receiptId,values:r.values,keys:r.keys,mark:r.mark}),s.affectedIds=[...new Set([...s.affectedIds,...o.affectedIds])],o.undo?.historyEntryId&&i.set(o.undo.historyEntryId,s.taskId);for(let e of n.values())for(let n of r.keys)e!==s&&e.reads.has(n)&&(e.notices.push({code:`DEPENDENCY_CHANGED`,message:`${n}, which this task reads, was changed by task ${s.taskId}.`}),t?.({type:`task.dependencyChanged`,taskId:e.taskId,key:n,by:s.taskId}))}let u=s.notices.splice(0);return u.length||l.length?{...o,warnings:[...o.warnings,...l,...u].slice(0,12)}:o},traversal(e,t,r,a,o){let c=r.taskId?n.get(r.taskId):null;if(c&&e===`edit.undo`){let n=c.edits.findIndex(e=>e.receiptId===t.receiptId);n<0&&q(`TARGET_BUSY`,`Inside a task, undo_edit takes the receiptId of the task's own newest edit${c.edits.length?` (now ${c.edits.at(-1).receiptId})`:``}.`),n<c.edits.length-1&&q(`UNDO_CONFLICT`,`Later edits of this task come after it; undo them first, newest first: ${c.edits.slice(n+1).reverse().map(e=>e.receiptId).join(`, `)}.`);let i=c.edits.pop();return l(e,c,r,a,{historyEntryId:s(c,i.values,`editUndone`),output:{undoneReceiptId:i.receiptId}})}let u=n.get(i.get(o));return!c&&u&&q(`TARGET_BUSY`,`The last edit belongs to running task ${u.taskId}${u.title?` (${u.title})`:``}; cancel or undo it from that task.`),null},dispose(){n.clear(),r.clear(),i.clear()}}}var J=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Y=(e,t)=>{throw new D(e,t)},br=(e,t,n)=>e?.then?e.then(t,n):t(e),xr=e=>e.slice(-12).map(e=>({code:`STUDIO_TOAST`,message:[...e.message].slice(0,120).join(``)})),Sr=0;function Cr({registry:e,ports:t}){let n=new Map,r=new Map,i=new Map,a=new Set,o=new Map,s=new Map,c=null,l=yr({ports:t,emit:e=>d(e)});function u(n,r,i){if(i.origin===`ui`)return;if(n.exposure===`ui-only`&&Y(`CAPABILITY_MISSING`,n.uiOnlyHint??`This command is available only from the Studio UI.`),n.id===`load_scenes`){let t=e=>[...new Set(e.map(e=>e.id))].sort();if(J(t(r.document.scenes),t(e.state().scenes)))return}else if(n.exposure!==`confirm`||n.requiresConfirmation?.(e.state(),r)===!1)return;let a=o.get(i.confirmationToken);(!a||a.id!==n.id||!J(a.args,r)||!J(a.host,t.read().host)||a.expires<(t.now??Date.now)())&&Y(`CONFIRMATION_REQUIRED`,n.confirmationReason??`This command needs user confirmation.`),o.delete(i.confirmationToken)}let d=e=>{for(let t of a)t(e);t.emit?.(e)},f=Kn.TargetGuard.properties.targetId,p=e=>({type:`object`,properties:e,required:Object.keys(e),additionalProperties:!1}),m={type:`object`,properties:{},required:[],additionalProperties:!0},ee={...$n(p,f),...l.controls(p,f),"run.begin":p({id:f,args:m}),"run.update":p({txId:f,args:m}),"run.commit":p({txId:f}),"run.cancel":p({txId:f}),"job.await":{...p({jobId:f}),properties:{jobId:f,timeoutMs:{type:`integer`,minimum:1,maximum:3e5,default:3e4}}},"job.cancel":p({jobId:f}),"edit.undo":{...p({receiptId:f}),required:[]},"edit.redo":{...p({receiptId:f}),required:[]}},h=e=>(t.clearTimeout??clearTimeout)(e);function g(e,n=!1,i=new D(`CANCELLED`,`Transaction was cancelled.`)){r.delete(e.txId),h(e.timer),e.workTimer!==void 0&&h(e.workTimer),e.controller.abort(i),e.session.cancel({restore:J(e.before.host,t.read().host)}),d({type:`transaction.cancelled`,txId:e.txId,expired:n})}function _(e){e.timer!==void 0&&h(e.timer),e.timer=(t.setTimeout??setTimeout)(()=>g(e,!0),t.transactionIdleMs??3e4)}function te(n,a,o,d){if(n.startsWith(`task.`))return l.control(n,a,o,d,c?`Finish the agent turn first.`:r.size?`Finish the open command transaction first.`:null);if(n.startsWith(`agent.turn.`)){if((o.origin!==`agent`||o.turnId!==a.turnId)&&Y(`CAPABILITY_MISSING`,`Only the owning agent turn can control this transaction.`),n===`agent.turn.begin`)return(c||r.size||l.size)&&Y(`TARGET_BUSY`,`Finish the open transaction first.`),c={txId:a.turnId,before:d,affectedIds:new Set,toasts:[],session:null},v(n,c,o,d);c?.txId!==a.turnId&&Y(`STALE_TARGET`,`The agent turn is no longer open.`);let e=c;if(n===`agent.turn.mark`||n===`agent.turn.rollback`)return v(n,er(n,e),o,d);if(n===`agent.turn.cancel`)return c=null,e.session?.cancel(),v(n,e,o,d);try{e.historyEntryId=e.session?.commit().historyEntryId}catch(t){throw e.session?.cancel(),t}finally{c=null}return v(n,e,o,e.before)}let f=n===`edit.undo`||n===`edit.redo`,p=f&&l.traversal(n,a,o,d,n===`edit.undo`?t.history?.(!1):null);if(p)return p;if(c&&!n.startsWith(`job.`)&&!(f&&!c.session)){if(n===`edit.undo`&&o.turnId===c.txId)return K(rr(c,a,o,d,()=>t.read()));Y(`TARGET_BUSY`,`Finish the agent turn before traversing history or opening another transaction.`)}if(f){let e=n===`edit.redo`,r=t.history?.(e),i=a.receiptId?t.receipt(a.receiptId):s.get(r)??(r?{receiptId:r,host:d.host,affectedIds:[d.host.sceneId],undo:{historyEntryId:r,entries:1,canUndoDirect:!0}}:null);if(!a.receiptId&&!i)return K({ok:!0,status:`noop`,action:n,commandId:o.commandId,receiptId:crypto.randomUUID(),host:d.host,authored:!1,mutated:!1,revision:{before:d.revision,after:d.revision},affectedIds:[],delta:[],checks:{coverage:`native-history-restoration`},undo:null,warnings:[]});(!i?.undo||!t.isRetained(i))&&Y(`UNDO_EXPIRED`,`The receipt no longer has a retained history entry.`),J(i.host,d.host)||Y(`STALE_SCENE`,`The receipt belongs to another document.`),(e?r!==i.undo.historyEntryId:!t.canUndo(i))&&Y(`UNDO_CONFLICT`,`Another edit owns the history boundary.`),(e?t.redo:t.undo)();let c=t.read(),l=i.affectedIds,u=l.map(e=>({...d.host,targetId:e,token:t.readTarget?.(e)??`removed-${crypto.randomUUID()}`}));return K({ok:!0,status:e?`applied`:`undone`,commandId:o.commandId,receiptId:crypto.randomUUID(),host:d.host,authored:!0,revision:{before:d.revision,after:c.revision},affectedIds:l,delta:l.slice(0,8).map(e=>({id:e,after:{token:u.find(t=>t.targetId===e).token}})),checks:{coverage:`native-history-restoration`},undo:{...i.undo,canUndoDirect:e},warnings:[],...e?{action:n,mutated:!0}:{undoneReceiptId:i.receiptId,restoredTargets:u},...l.length>8?{detailCursor:o.commandId}:{}})}if(n.startsWith(`job.`)){let e=i.get(a.jobId);(!e||!J(e.host,d.host))&&Y(`STALE_TARGET`,`Job is not in this document.`),n===`job.cancel`&&!e.outcome&&e.controller.abort(new D(`CANCELLED`,`Job was cancelled.`));let r;return(n===`job.await`&&!e.outcome?Promise.race([e.completion,new Promise((e,n)=>{r=(t.setTimeout??setTimeout)(()=>n(new D(`TIMEOUT`,`Job is still running.`)),a.timeoutMs)})]):e.completion).then(t=>K({...t,commandId:o.commandId,...t.ok?{receiptId:crypto.randomUUID()}:{},jobId:e.id})).finally(()=>{r!==void 0&&h(r)})}let m;if(n===`run.begin`){r.size&&Y(`TARGET_BUSY`,`Finish or cancel the open command transaction first.`);let n=e.prepare(a.id,a.args);u(n.entry,n.args,o),n.entry.kind!==`mutation`&&Y(`INVALID_ARGUMENT`,`Only mutations can open a transaction.`),m={txId:crypto.randomUUID(),entry:n.entry,before:d,origin:o.origin,targetId:n.args.characterId??null,controller:new AbortController,session:t.beginAction(n.entry.undoDomain,n.args.characterId??null),affectedIds:new Set,toasts:[]},r.set(m.txId,m),_(m)}else{if(m=r.get(a.txId),(!m||!J(m.before.host,d.host))&&Y(`STALE_TARGET`,`Transaction is no longer open in this document.`),o.origin!==m.origin&&Y(`TARGET_BUSY`,`This transaction belongs to another origin.`),m.updating&&n!==`run.cancel`&&Y(`TARGET_BUSY`,`A transaction update is still running.`),n===`run.update`){let i=e.prepare(m.entry.id,a.args);m.entry.undoDomain===`motion`&&i.args.characterId!==m.targetId&&Y(`INVALID_ARGUMENT`,`A motion transaction keeps its original target.`);let s=[],c=t.captureToasts?.(e=>s.push(typeof e==`string`?{message:e}:e)),l={origin:o.origin,signal:m.controller.signal,check(){m.controller.signal.throwIfAborted(),(!r.has(m.txId)||!J(m.before.host,t.read().host))&&Y(`STALE_TARGET`,`Transaction is no longer current.`)}},u=e=>{c?.(),h(m.workTimer),m.updating=!1,l.check(),s.length&&t.read().revision===d.revision&&Y(`TARGET_NOT_READY`,s.at(-1).message);for(let t of e.affectedIds)m.affectedIds.add(t);return m.toasts.push(...s),_(m),v(n,m,o,d)},f=e=>{throw c?.(),h(m.workTimer),m.updating=!1,!(e instanceof D)&&s.length&&t.read().revision===d.revision&&(e=new D(`TARGET_NOT_READY`,s.at(-1).message)),r.has(m.txId)&&g(m),e};try{m.updating=!0,h(m.timer),m.workTimer=(t.setTimeout??setTimeout)(()=>g(m,!0,new D(`TIMEOUT`,`${m.entry.id} exceeded its deadline.`)),m.entry.timeoutMs??3e4);let n=m.session.run(()=>e.invoke(m.entry,i.args,l));if(!n?.then)return u(n);let r=new Promise((e,t)=>m.controller.signal.addEventListener(`abort`,()=>t(m.controller.signal.reason),{once:!0}));return Promise.race([n,r]).then(u,f)}catch(e){return f(e)}}if(n===`run.cancel`&&g(m),n===`run.commit`){r.delete(m.txId),h(m.timer);try{m.historyEntryId=m.session.commit().historyEntryId}catch(e){throw m.session.cancel({restore:!1}),e}}}return v(n,m,o,n===`run.commit`?m.before:d)}function v(e,n,r,i){let a=t.read();return K({ok:!0,status:`completed`,kind:`transaction`,commandId:r.commandId,receiptId:crypto.randomUUID(),host:i.host,action:e,txId:n.txId,authored:!!n.historyEntryId,revision:{before:i.revision,after:a.revision},affectedIds:[...n.affectedIds],delta:[],checks:{coverage:`wire-transaction`},warnings:xr(n.toasts),undo:n.historyEntryId?{historyEntryId:n.historyEntryId,entries:1,canUndoDirect:!0}:null})}function ne(e,n,r,i){let a=i??t.read().revision!==n.revision;return K({ok:!1,commandId:e.commandId,host:n.host,code:de(r),phase:a?`commit`:`admission`,affectedIds:[],expectedTargets:[],currentTargets:[],mutated:a,preserved:{authoredState:a?`changed`:`unchanged`},recovery:{action:`inspect`,retryAllowed:!1},message:[...String(r.message||r)].slice(0,500).join(``)})}let re=(e=[],t=[],n=0,r=12)=>{let i=[...n?[{code:`READBACK_TRUNCATED`,count:n,message:`Readback lists 8 of ${8+n} affected ids; inspect_studio scope entities with ids for the rest.`}]:[],...e,...xr(t)];return i.length<=r?i:[...i.slice(0,r-1),{code:`WARNINGS_TRUNCATED`,count:i.length-r+1,message:`${i.length-r+1} more warnings omitted.`}]};function ie(e,n,r,i,a,o=[],s=null){let c=t.read(),l=c.revision!==r.revision,u=a??(l?s?.txId:null)??null;e.kind===`mutation`&&l&&!a&&!s&&Y(`UNCERTAIN_APPLY`,`${e.id} changed the scene without one undoable entry.`);let d=e.kind===`job`||e.kind===`document`||e.kind===`mutation`&&l&&(s||c.revision>r.revision+1),f=d||l?i.affectedIds:e.kind===`transient`?[r.host.sceneId]:[];if(s&&l)for(let e of f)s.affectedIds.add(e),s.mark?.since.add(e);let p=a=>K({ok:!0,commandId:n.commandId,receiptId:crypto.randomUUID(),host:r.host,action:e.id,summary:i.summary,status:d?`completed`:e.kind===`transient`?`transient`:l?`applied`:`noop`,authored:l,...d?{kind:e.kind,...i.output===void 0?{}:{output:i.output},...J(r.host,c.host)?{}:{nextHost:c.host}}:e.kind===`transient`?{view:{before:r.viewRevision??0,after:c.viewRevision??0}}:{mutated:l},revision:{before:r.revision,after:c.revision},affectedIds:f,delta:f.slice(0,8).map(e=>({id:e,after:t.readback?.(e,c,a>0)??{removed:!0}})),checks:{coverage:`studio-action:${e.id}`,...i.checks},warnings:re(i.warnings,o,Math.max(0,f.length-8),a>1?4:12),undo:u?{historyEntryId:u,entries:1,canUndoDirect:!s}:null,...f.length>8?{detailCursor:n.commandId}:{}});for(let e=0;;e++)try{return p(e)}catch(t){if(e>=2||t?.code!==`INVALID_RECEIPT`||!/8 KiB/.test(t.message))throw t}}function y(a,o={},f={}){let p={origin:`ui`,commandId:crypto.randomUUID(),...f};p.origin===`ui`&&(a===`edit.undo`||a===`edit.redo`)&&t.finishHistoryGesture?.();let m=t.read(),g=t.journal();c&&!J(c.before.host,m.host)&&(c.session?.cancel({restore:!1}),c=null);let _=p.origin===`agent`&&p.turnId===c?.txId?c:null,v=l.of(p,a),re=(e,n,r,i=!1)=>_?(_.session??=t.beginAction(e,r),{result:_.session.run(()=>t.beginAction(e,r).run(n)),historyEntryId:null}):t.recordAction(e,n,r,i),y=!1,ae,oe,se,b,ce=!1,le,x=new AbortController,ue=()=>{oe!==void 0&&h(oe),se!==void 0&&h(se)},de=[],fe=()=>de.length&&t.read().revision===m.revision?new D(`TARGET_NOT_READY`,de.at(-1).message):null,pe=e=>{if(b?.background){let t=b.completionCommandId??=crypto.randomUUID();g.begin(t),e=K({...e,commandId:t,jobId:b.id})}let n=g.record(e);n.undo?.canUndoDirect&&!a.startsWith(`edit.`)&&s.set(n.undo.historyEntryId,n);for(let[e,n]of s)t.isRetained?.(n)===!1&&s.delete(e);return t.remember?.(n),n},me=e=>{ue(),ae?.(),ae=null,e instanceof D||(e=fe()??e),p.origin===`ui`&&e.uiMessage&&t.showRefusal?.(e.uiMessage);let n=ne(p,m,e,b?ce:void 0),r=y?pe(n):n;return b&&!b.completion&&(b.outcome=r,b.completion=Promise.resolve(r),d({type:`job.completed`,jobId:b.id,receipt:r})),r};try{p.origin!==`ui`&&!J(qn(p.host),m.host)&&Y(`STALE_SCENE`,`The live document changed.`),p.turnId&&!_&&a!==`agent.turn.begin`&&Y(`STALE_TARGET`,`The agent turn is no longer open.`);let s=JSON.stringify({id:a,args:o,...p});if(!g.begin(p.commandId,s))return g.get(p.commandId)??n.get(p.commandId)??ne(p,m,new D(`UNCERTAIN_APPLY`,`Command is still executing.`));y=!0;let{entry:c,args:f}=ee[a]?{args:G(ee[a],o)}:e.prepare(a,o);if(p.origin!==`ui`&&(!v&&!a.startsWith(`task.`)&&!c?.readOnly&&![`job.await`,`job.cancel`,`agent.turn.mark`,`agent.turn.rollback`,`agent.turn.finish`,`agent.turn.cancel`].includes(a)&&p.expectedRevision!==m.revision&&Y(`STALE_SCENE`,`Authored state changed; obtain fresh intent.`),!c?.readOnly&&m.busy&&!_&&!r.has(f.txId)&&!a.startsWith(`job.`)&&Y(`TARGET_BUSY`,`Finish the current editor gesture first.`)),ee[a])return br(te(a,f,p,m),pe,me);r.size&&Y(`TARGET_BUSY`,`Finish or cancel the open command transaction first.`),_&&c.kind===`document`&&Y(`TARGET_BUSY`,`Finish the agent turn before changing documents.`),u(c,f,p);let h=l.admit(v,c,f,p,m);ae=t.captureToasts?.(e=>de.push(typeof e==`string`?{message:e}:e));let S=c.domain??c.undoDomain,C=c.target?.(f,m)??f.characterId??f.shotId??f.objectId,he=C?t.readTarget?.(C):null,ge=S?m.domainRevisions?.[S]:null,_e=()=>{let e=t.read();he=C?t.readTarget?.(C):null,ge=S?e.domainRevisions?.[S]:null},ve=new Set,ye={origin:p.origin,signal:x.signal,check(){x.signal.throwIfAborted();let e=t.read();J(e.host,m.host)||Y(`STALE_TARGET`,`The open document or scene changed while the job was running.`),S&&!v&&e.domainRevisions?.[S]!==ge&&Y(`STALE_TARGET`,`The ${S} data changed while the job was running (revision ${ge} to ${e.domainRevisions?.[S]}); an edit landed between the request and its result.`),C&&t.readTarget?.(C)!==he&&Y(`STALE_TARGET`,`${C} changed while the job was running.`)},commit(e){ye.check(),S||Y(`INVALID_ARGUMENT`,`A committing job must declare its domain.`);let t=re(S,e,C??null);return t?.then&&Y(`INVALID_ARGUMENT`,`Job publication must be synchronous; prepare before commit.`),le=t.historyEntryId,ce||=!!le,b&&_e(),t.result},run(t,n={}){b?ye.check():x.signal.throwIfAborted();let r=e.prepare(t,n);u(r.entry,r.args,p);let i=()=>e.invoke(r.entry,r.args,ye),a=r.entry.kind===`mutation`?re(r.entry.undoDomain,i,r.args.characterId??null,!0):{result:i()};return b&&_e(),br(a,e=>br(e.result,t=>{b&&(ye.check(),_e(),ce||=!!e.historyEntryId);for(let e of t.affectedIds)ve.add(e);return t}))}};c.kind===`job`&&(b={id:crypto.randomUUID(),host:m.host,controller:x,background:!1},i.set(b.id,b)),oe=(t.setTimeout??setTimeout)(()=>{let e=new D(`TIMEOUT`,`${c.id} exceeded its deadline.`);x.abort(e)},b&&c.background===!0?3e5:c.timeoutMs??3e4);let be=()=>{let t=e.invoke(c,f,ye);if(!t?.then)return t;let n=new Promise((e,t)=>x.signal.addEventListener(`abort`,()=>t(x.signal.reason),{once:!0}));return Promise.race([t,n])},xe=tr(_),w=c.kind===`mutation`?re(c.undoDomain,be,f.characterId??null):{result:be(),historyEntryId:null},Se=({result:e,historyEntryId:t})=>br(e,e=>{ue(),ae?.(),ae=null;let n=e?.output===void 0?fe():null;if(n)throw n;return l.record(h,nr(_,xe,pe(ie(c,p,m,{...e,affectedIds:[...new Set([...e.affectedIds,...ve])]},t??le,de,_))))}),Ce=w?.then?w.then(Se):Se(w),T=Ce?.then?Ce.catch(me):Ce;if(b){b.completion=Promise.resolve(T).then(e=>(b.outcome=e,d({type:`job.completed`,jobId:b.id,receipt:e}),e));let e=()=>{b.background=!0;let e=t.read();return g.record(K({ok:!0,commandId:p.commandId,receiptId:crypto.randomUUID(),host:m.host,action:c.id,status:`started`,kind:`job`,jobId:b.id,authored:!1,revision:{before:e.revision,after:e.revision},affectedIds:[],delta:[],checks:{coverage:`studio-action:${c.id}`},warnings:[],undo:null}))};if(T?.then&&p.wait===!1)return e();if(T?.then&&c.background===!0){let r=Promise.race([b.completion,new Promise(n=>{se=(t.setTimeout??setTimeout)(()=>n(e()),c.timeoutMs??3e4)})]).finally(()=>n.delete(p.commandId));return n.set(p.commandId,r),r}}if(T?.then){let e=(b?.completion??T).finally(()=>n.delete(p.commandId));return n.set(p.commandId,e),e}return T}catch(e){return me(e)}}function ae(...e){Sr++;try{let t=y(...e);return t?.then?t.finally(()=>{Sr--}):(Sr--,t)}catch(e){throw Sr--,e}}return{run:ae,confirm(n,r={}){let i=e.prepare(n,r),a=crypto.randomUUID();return o.set(a,{id:n,args:i.args,host:t.read().host,expires:(t.now??Date.now)()+3e5}),a},subscribe(e){return a.add(e),()=>a.delete(e)},dispose(){c?.session?.cancel(),c=null,l.dispose();for(let e of r.values())g(e);for(let e of i.values())e.outcome||e.controller.abort(new D(`CANCELLED`,`Studio closed.`));a.clear()}}}var wr=Object.freeze([`pose_edit`,`object_insert`,`cutout_insert`,`object_transform`,`shot_add`,`shot_edit`,`camera_key_record`,`rail_edit`,`prompt_block_add`,`prompt_block_edit`]);function X(e,t){if(e===t)return!0;if(typeof e==`number`&&typeof t==`number`)return Math.abs(e-t)<1e-8;if(!e||!t||typeof e!=`object`||typeof t!=`object`)return!1;if(e instanceof Map||t instanceof Map)return e instanceof Map&&t instanceof Map&&e.size===t.size&&[...e].every(([e,n])=>t.has(e)&&X(n,t.get(e)));let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&X(e[n],t[n]))}var Tr=e=>({bones:e?.bones??{},rootY:e?.rootY??0}),Er=(e=[])=>e.map(({frame:e,framing:t})=>({frame:e,framing:t})),Dr=e=>({...e,camera:y(e.camera),cameraKeys:Er(e.cameraKeys)});function Or(e,t,n){if(t===n)return null;if(e===`pose`)return X(t,n)?null:`pose_edit`;if(e===`objects`){let e=n.find(e=>!t.some(t=>t.id===e.id));return e?e.renderer===`cutout`?`cutout_insert`:`object_insert`:X(t,n)?null:`object_transform`}if(e===`characters`){if(n.some(e=>!t.some(t=>t.id===e.id)))return`object_insert`;for(let e of n){let n=t.find(t=>t.id===e.id);if(n&&!X(Tr(n.pose),Tr(e.pose)))return`pose_edit`}let e=e=>e.map(({id:e,x:t,y:n=0,z:r,rot:i,scale:a=1,hidden:o=!1,model:s,tint:c,subject:l,identityImage:u})=>({id:e,x:t,y:n,z:r,rot:i,scale:a,hidden:o,model:s,tint:c,subject:l,identityImage:u}));return X(e(t),e(n))?null:`object_transform`}if(e===`shots`){if(n.some(e=>!t.some(t=>t.id===e.id)))return`shot_add`;for(let e of n){let n=t.find(t=>t.id===e.id);if(!n)continue;let r=y(e.camera),i=y(n.camera);if([`cameraRail`,`craneHeight`,`railFollow`,`dollyTiming`].some(e=>!X(r[e],i[e])))return`rail_edit`;let a=e.cameraKeys??[],o=n.cameraKeys??[];if(a.length>o.length||a.some(e=>{let t=o.find(t=>t.frame===e.frame);return t&&!X(t.framing,e.framing)}))return`camera_key_record`}return X(t.map(Dr),n.map(Dr))?null:`shot_edit`}return null}function kr(e){let t=new Set;return(n,r,i,a)=>{if(![`craft`,`playground`].includes(n)||t.has(n))return!1;let o=Or(r,i,a);return o?(t.add(n),e(`${n}:first_edit`,{edit_kind:o,definition_version:1}),!0):!1}}var Ar=`modulepreload`,jr=function(e){return`/`+e},Mr={},Nr=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=jr(t,n),t=s(t),t in Mr)return;Mr[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Ar,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Pr=Object.freeze([`read`,`camera`,`scene_write`,`prompt_authoring`,`frame_capture`,`motion_generate`,`motion_apply`,`project_io`,`other`]),Fr=Object.freeze([`workflow_read`,`workflow_write`,`workflow_run`,`frame_capture`,`image_generate`,`scene_write`,`other`]),Ir=Object.freeze([`workflow:run_requested`,`workflow:run_succeeded`,`workflow:run_failed`,`workflow:run_cancelled`,`workflow:result_applied`,`agent:turn_requested`,`agent:tool_executed`,`agent:turn_succeeded`,`agent:turn_failed`,`agent:turn_cancelled`,`agent:result_applied`,`mcp:tool_requested`,`mcp:tool_executed`,`mcp:result_applied`]),Lr=Object.freeze({"workflow:run_requested":[`surface`,`run_id`,`node_count_bucket`],"workflow:run_succeeded":[`run_id`,`duration_bucket`],"workflow:run_failed":[`run_id`,`duration_bucket`,`failure_code`],"workflow:run_cancelled":[`run_id`,`duration_bucket`,`failure_code`],"workflow:result_applied":[`run_id`],"agent:turn_requested":[`surface`,`turn_id`],"agent:tool_executed":[`turn_id`,`tool_category`,`outcome`,`duration_bucket`],"agent:turn_succeeded":[`turn_id`,`duration_bucket`],"agent:turn_failed":[`turn_id`,`duration_bucket`,`failure_code`],"agent:turn_cancelled":[`turn_id`,`duration_bucket`,`failure_code`],"agent:result_applied":[`turn_id`],"mcp:tool_requested":[`tool_category`,`request_id`],"mcp:tool_executed":[`tool_category`,`outcome`,`duration_bucket`,`request_id`],"mcp:result_applied":[`request_id`]}),Rr=Object.freeze({surface:new Set([`studio`,`workflow`]),node_count_bucket:new Set([`0`,`1-3`,`4-10`,`gte11`]),duration_bucket:new Set([`lt1s`,`1-3s`,`3-10s`,`10-30s`,`gte30s`]),tool_category:new Set([...Pr,...Fr]),outcome:new Set([`succeeded`,`failed`,`uncertain`,`cancelled`])}),zr=Object.freeze({source:new Set([`agent`,`manual`]),outcome:new Set([`ok`,`error`]),surface:new Set([`assets`,`agent`,`mcp`])}),Br=`cozyclay.analyticsOptOut`,Vr=`cozyclay.internalQa`,Hr=`cozyclay.analyticsActivation`,Ur=`cozyclay.useCaseAsked`,Wr=Object.freeze({pose:Object.freeze([`pose_edit`]),camera:Object.freeze([`camera_key_record`,`rail_edit`]),object:Object.freeze([`object_insert`,`cutout_insert`,`object_transform`]),shot:Object.freeze([`shot_add`,`shot_edit`]),prompt:Object.freeze([`prompt_block_add`,`prompt_block_edit`])}),Gr=Object.freeze(Object.keys(Wr).map(e=>`${e}_edit_bucket`)),Kr=Object.freeze([`animation`,`film`,`game`,`ad_mv`,`personal`,`other`,`skip`]),qr=Object.freeze([`team`,`solo`,`skip`]),Jr=new Set([`storyboard`,`animation`]),Yr=Object.freeze([`latest`,`outdated`,`unknown`]),Xr=Object.freeze([`https://cozyclay.org`,`https://www.cozyclay.org`]),Zr=Object.freeze({"install:first_launch":[`heard_from`],"app:session_started":[],"app:session_ended":[`duration_bucket`,`action_count_bucket`,`scenes_touched`,...Gr],"app:error":[`error_kind`,`error_type`,`error_source`,`error_file`,`error_line`,`error_col`],"device:profile":[`gpu_vendor`,`gpu_class`,`webgl`,`cpu_bucket`,`memory_bucket`,`frame_rate_bucket`],"survey:use_case":[`use_case`,`team`],"feature:used":[`name`],"hosted:composer_viewed":[],"hosted:login_started":[],"hosted:ticket_created":[],"hosted:result_opened":[],"hosted:opened_in_studio":[],"scene:created":[`scene_source`,`previs_mode`],"storyboard:panel_created":[`source`],"storyboard:panel_stylized":[`outcome`],"cast:proxy_added":[`surface`],"scene:loaded":[`scene_source`],"project:saved":[`object_count_bucket`,`shot_count_bucket`],"project:opened":[`age_bucket`],"craft:first_action":[`action_kind`],"craft:first_edit":[`edit_kind`,`definition_version`],"motion:backend_state":[`backend`,`host_configured`],"motion:generate_requested":[`surface`,`input_mode`,`request_id`],"motion:preflight_blocked":[`reason`,`surface`,`request_id`],"motion:preflight_passed":[`backend`,`surface`,`request_id`],"motion:job_started":[`backend`,`input_mode`,`request_id`],"motion:job_succeeded":[`backend`,`duration_bucket`,`input_mode`,`request_id`],"motion:job_failed":[`backend`,`duration_bucket`,`input_mode`,`error_code`,`request_id`],"motion:result_applied":[`request_id`,`backend`],"export:blocking_frame_succeeded":[`format`],"export:video_succeeded":[`format`],"export:keyframe_pack":[`entries`,`source`],"export:attempt_started":[`attempt_id`,`export_kind`,`format`,`surface`],"export:attempt_succeeded":[`attempt_id`,`export_kind`,`format`,`surface`,`duration_bucket`],"export:attempt_failed":[`attempt_id`,`export_kind`,`format`,`surface`,`duration_bucket`,`failure_code`],"export:attempt_cancelled":[`attempt_id`,`export_kind`,`format`,`surface`,`duration_bucket`,`failure_code`],"sample:played":[`from`],"playground:opened":[],"playground:first_action":[`action_kind`],"playground:first_edit":[`edit_kind`,`definition_version`],"activation:completed":[`activation_path`],"tutorial:started":[`surface`,`tutorial_version`,`start_source`],"tutorial:step_entered":[`surface`,`tutorial_version`,`step_kind`],"tutorial:step_completed":[`surface`,`tutorial_version`,`step_kind`,`elapsed_bucket`],"tutorial:completed":[`surface`,`tutorial_version`,`elapsed_bucket`],"tutorial:dismissed":[`surface`,`tutorial_version`,`step_kind`],sculpt_run:[`outcome`,`rounds`,`final_iou`,`duration_ms`,`had_target`],...Lr}),Qr=new Set([`pose_edit`,`pose_save`,`camera_fly`,`orbit`,`dolly_rail`,`crane_graph`,`timeline_scrub`,`prompt_block_add`,`shot_add`,`shot_cut`,`export_pose`,`export_frame`,`export_video`,`export_depth_video`,`export_keyframe_pack`,`fal_motion_open`,`mcp_connected`,`auto_color`,`plan_view`,`camera_tutorial`]),$r=Object.freeze([`x`,`hn`,`reddit`,`github`,`friend`,`other`,`site`,`playground`]),ei=new Set($r),ti=new Set([`prompt`,`text`,`url`,`path`,`file`]),ni=Object.freeze({backend:new Set([`none`,`local_kimodo`,`hosted`,`fal`]),host_configured:new Set([!0,!1]),surface:new Set([`timeline`,`line_edit`,`trail`,`mcp`,`fal_card`,`agent`]),input_mode:new Set([`prompt`,`pose`,`edit`,`a_to_b`,`still`]),reason:new Set([`unconfigured`,`unreachable`,`unsupported_route`,`locked`,`missing_input`]),error_code:new Set([`aborted`,`unsupported_route`,`generation_failed`,`quota`,`unknown`]),duration_bucket:new Set([`lt1s`,`1-3s`,`3-10s`,`10-30s`,`gte30s`])}),ri=new Set([`unsupported_codec`,`encode_failed`,`render_failed`,`aborted`,`unknown`]),ii=Object.freeze({export_kind:new Set([`video`,`depth_video`,`frame`,`keyframe_pack`,`workflow_send`,`animation_project`,`contact_sheet`,`panel_pack`,`animatic`]),format:new Set([`mp4`,`png`,`zip`,`cclayproject`]),surface:new Set([`studio`,`workflow`,`embed`]),duration_bucket:new Set([`lt1s`,`1-3s`,`3-10s`,`10-30s`,`gte30s`]),failure_code:ri}),ai=Object.freeze({surface:new Set([`studio`,`playground`]),tutorial_version:new Set([1]),start_source:new Set([`query`,`settings`,`landing`]),step_kind:new Set([`fly`,`walk`,`dolly`,`orbit`,`shot`,`rail`,`play`]),elapsed_bucket:new Set([`lt1s`,`1-3s`,`3-10s`,`10-30s`,`gte30s`])}),oi=Object.freeze([`done`,`cancelled`,`failed`]),si=10,ci=864e5,li=Object.freeze({workflow:new Set([`aborted`,`capture_failed`,`generation_failed`,`unknown`]),agent:new Set([`aborted`,`auth`,`rate_limited`,`tool_failed`,`upstream`,`unknown`])}),ui=Object.freeze({error_kind:new Set([`error`,`unhandled_rejection`]),error_type:new Set([`Error`,`TypeError`,`RangeError`,`ReferenceError`,`SyntaxError`,`EvalError`,`URIError`,`AggregateError`,`AbortError`,`TimeoutError`,`NotAllowedError`,`NotSupportedError`,`NotFoundError`,`NotReadableError`,`InvalidStateError`,`QuotaExceededError`,`SecurityError`,`NetworkError`,`DataCloneError`,`OperationError`,`EncodingError`,`UnknownError`,`DOMException`,`non_error`,`other`]),error_source:new Set([`app`,`extension`,`external`,`unknown`])}),di=/^[A-Za-z0-9_.-]{1,80}\.(?:m?js|jsx|ts|tsx)$/,fi=Object.freeze({gpu_vendor:new Set([`nvidia`,`amd`,`intel`,`apple`,`qualcomm`,`arm`,`software`,`other`,`unknown`]),gpu_class:new Set([`discrete`,`integrated`,`software`,`unknown`]),webgl:new Set([`webgl2`,`webgl1`,`none`]),cpu_bucket:new Set([`1-4`,`5-8`,`9-16`,`gte17`,`unknown`]),memory_bucket:new Set([`lt4`,`4-7`,`gte8`,`unknown`]),frame_rate_bucket:new Set([`lt20`,`20-40`,`40-55`,`gte55`,`unknown`])}),Z=null,pi=!1,Q=!1,mi=!1,hi=null,gi=!1,_i=!1,vi=0,yi=0,bi=0,xi=!1,Si=!1,Ci=new Set,wi=new Map(Object.entries(Wr).flatMap(([e,t])=>t.map(t=>[t,e]))),Ti=1e3,Ei=Object.fromEntries(Object.keys(Wr).map(e=>[e,0])),Di=null,Oi=-1/0,ki=10,Ai=new Set,ji=!1,Mi=!1,Ni=new Set([`app:session_started`,`app:session_ended`,`install:first_launch`,`motion:backend_state`,`app:error`,`device:profile`]);function Pi(){try{return globalThis.localStorage??null}catch{return null}}function Fi(e){try{return Pi()?.getItem(e)??null}catch{return null}}function Ii(e,t){try{Pi()?.setItem(e,t)}catch{}}function Li(e){return typeof e==`string`?e.trim().toLowerCase().replace(/[/.]+$/g,``):``}function Ri(e){return e===void 0?[...Xr]:e.split(`,`).map(Li).filter(Boolean)}function zi(e,t){let n=Li(e);return Array.isArray(t)&&t.some(e=>n===Li(e))}var Bi=e=>typeof e==`boolean`?!0:typeof e==`number`?Number.isFinite(e):typeof e==`string`&&e.length<=32&&!/\s/.test(e);function Vi(e,t){let n=Zr[e]??[];if(!t||typeof t!=`object`||Array.isArray(t))return{};let r={};for(let i of n)if(!(ti.has(i)||!Object.hasOwn(t,i))&&!(e===`feature:used`&&(i!==`name`||!Qr.has(t[i])))&&!(e===`install:first_launch`&&(i!==`heard_from`||!ei.has(t[i])))){if(e.startsWith(`export:attempt_`)){if(i===`attempt_id`){if(typeof t[i]!=`string`||!/^[a-f0-9]{32}$/.test(t[i]))continue}else if(!ii[i]?.has(t[i]))continue}if(!(e===`export:keyframe_pack`&&(i===`source`&&t[i]!==`workflow`||i===`entries`&&(!Number.isFinite(t[i])||t[i]<0)))&&!((e===`craft:first_edit`||e===`playground:first_edit`)&&(i===`edit_kind`&&!wr.includes(t[i])||i===`definition_version`&&t[i]!==1))){if(e.startsWith(`motion:`)){if(i===`request_id`){if(typeof t[i]!=`string`||!/^[a-f0-9]{32}$/.test(t[i]))continue}else if(!ni[i]?.has(t[i]))continue}if(!(e.startsWith(`tutorial:`)&&!ai[i]?.has(t[i]))){if(e.startsWith(`workflow:`)||e.startsWith(`agent:`)||e.startsWith(`mcp:`)){if(i===`run_id`||i===`turn_id`||i===`request_id`){if(typeof t[i]!=`string`||!/^[a-f0-9]{32}$/.test(t[i]))continue}else if(i===`surface`){if(!Rr.surface.has(t[i])||e.startsWith(`workflow:`)&&t[i]!==`workflow`)continue}else if(i===`node_count_bucket`&&!Rr.node_count_bucket.has(t[i]))continue;else if(i===`duration_bucket`&&!Rr.duration_bucket.has(t[i]))continue;else if(i===`tool_category`){if(!(e.startsWith(`agent:`)?Fr:Pr).includes(t[i]))continue}else if(i===`outcome`){if(!(e===`mcp:tool_executed`?[`succeeded`,`failed`,`uncertain`,`cancelled`]:[`succeeded`,`failed`,`cancelled`]).includes(t[i]))continue}else if(i===`failure_code`&&!li[e.startsWith(`agent:`)?`agent`:`workflow`].has(t[i]))continue}if(e===`app:error`){if(i===`error_file`){typeof t[i]==`string`&&di.test(t[i])&&(r[i]=t[i]);continue}if(i===`error_line`||i===`error_col`){Number.isInteger(t[i])&&t[i]>=0&&t[i]<=1e7&&(r[i]=t[i]);continue}if(!ui[i]?.has(t[i]))continue}if(!(e===`device:profile`&&!fi[i]?.has(t[i]))){if(e===`sculpt_run`){let e=t[i];i===`outcome`&&oi.includes(e)||i===`rounds`&&Number.isInteger(e)&&e>=0&&e<=si?r[i]=e:i===`final_iou`&&typeof e==`number`&&e>=0&&e<=1?r[i]=Math.round(e*100)/100:i===`duration_ms`&&typeof e==`number`&&e>=0&&e<=ci?r[i]=Math.round(e):i===`had_target`&&typeof e==`boolean`&&(r[i]=e);continue}i===`previs_mode`&&!Jr.has(t[i])||(e.startsWith(`storyboard:`)||e.startsWith(`cast:`))&&!zr[i]?.has(t[i])||e===`survey:use_case`&&(i===`use_case`&&!Kr.includes(t[i])||i===`team`&&!qr.includes(t[i]))||Bi(t[i])&&(r[i]=t[i])}}}}return r}Object.freeze([...Qr]);function Hi(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;return t===0?`0`:t<=3?`1-3`:t<=10?`4-10`:`gte11`}function Ui(e){return!Number.isFinite(e)||e<6e4?`lt1m`:e<3e5?`1-5m`:e<9e5?`5-15m`:e<18e5?`15-30m`:`gte30m`}function Wi(e){return!Number.isFinite(e)||e<0||e<36e5?`lt1h`:e<864e5?`1-24h`:e<6048e5?`1-7d`:e<2592e6?`7-30d`:`gte30d`}function Gi(){let e=String(globalThis.navigator?.userAgentData?.platform||globalThis.navigator?.platform||``).toLowerCase();return e.includes(`mac`)?`macos`:e.includes(`win`)?`windows`:e.includes(`linux`)?`linux`:e.includes(`android`)?`android`:e.includes(`iphone`)||e.includes(`ipad`)||e.includes(`ios`)?`ios`:`unknown`}function Ki(e){return!Number.isFinite(e)||e<1e3?`lt1s`:e<3e3?`1-3s`:e<1e4?`3-10s`:e<3e4?`10-30s`:`gte30s`}function qi(e){return!Number.isFinite(e)||e<=0?`unknown`:e<=4?`1-4`:e<=8?`5-8`:e<=16?`9-16`:`gte17`}function Ji(e){return!Number.isFinite(e)||e<=0?`unknown`:e<4?`lt4`:e<8?`4-7`:`gte8`}function Yi(e){return!Number.isFinite(e)||e<=0?`unknown`:e<20?`lt20`:e<40?`20-40`:e<55?`40-55`:`gte55`}function Xi(e){let t=String(e??``).toLowerCase();return t.trim()?/swiftshader|llvmpipe|softpipe|software|basic render driver/.test(t)?{gpu_vendor:`software`,gpu_class:`software`}:/nvidia|geforce|quadro|\brtx\b|\bgtx\b|tesla/.test(t)?{gpu_vendor:`nvidia`,gpu_class:`discrete`}:/\bamd\b|radeon|\bati\b/.test(t)?{gpu_vendor:`amd`,gpu_class:/radeon\(tm\) graphics|radeon graphics|vega \d+ graphics|\b(?:610|660|680|740|760|780|880|890)m\b/.test(t)?`integrated`:`discrete`}:/intel|iris|uhd graphics|hd graphics/.test(t)?{gpu_vendor:`intel`,gpu_class:/arc(?:\(tm\))? [ab]\d{3}/.test(t)?`discrete`:`integrated`}:/apple|\bm[1-9](?: pro| max| ultra)?\b/.test(t)?{gpu_vendor:`apple`,gpu_class:`integrated`}:/adreno|qualcomm/.test(t)?{gpu_vendor:`qualcomm`,gpu_class:`integrated`}:/\bmali\b|\barm\b|powervr/.test(t)?{gpu_vendor:`arm`,gpu_class:`integrated`}:{gpu_vendor:`other`,gpu_class:`unknown`}:{gpu_vendor:`unknown`,gpu_class:`unknown`}}var Zi=/((?:https?|chrome-extension|moz-extension|safari-extension|safari-web-extension):\/\/[^\s()]+?):(\d+):(\d+)/g;function Qi(e,t){if(typeof e!=`string`||!e)return`unknown`;if(/^(?:chrome|moz|safari|safari-web)-extension:/.test(e))return`extension`;try{return t&&new URL(e).origin===t?`app`:`external`}catch{return`unknown`}}function $i(e){try{let t=new URL(e).pathname.split(`/`).pop()??``;return di.test(t)?t:null}catch{return null}}function ea(e){try{if(e===null||typeof e!=`object`&&typeof e!=`function`)return`non_error`;let t=typeof e.name==`string`?e.name:``;return t&&t!==`non_error`&&t!==`other`&&ui.error_type.has(t)?t:typeof DOMException<`u`&&e instanceof DOMException?`DOMException`:e instanceof Error?`other`:`non_error`}catch{return`other`}}function ta({error:e,filename:t,lineno:n,colno:r,kind:i=`error`}={},a=globalThis.location?.origin??``){let o={error_kind:i===`unhandled_rejection`?`unhandled_rejection`:`error`,error_type:ea(e),error_source:`unknown`},s=typeof t==`string`&&t?{url:t,line:n,col:r}:null;if(!s||Qi(s.url,a)!==`app`){let t=``;try{t=typeof e?.stack==`string`?e.stack.slice(0,4e3):``}catch{t=``}let n=[...t.matchAll(Zi)].map(e=>({url:e[1],line:Number(e[2]),col:Number(e[3])}));s=n.find(e=>Qi(e.url,a)===`app`)??s??n[0]??null}if(!s||(o.error_source=Qi(s.url,a),o.error_source!==`app`))return o;let c=$i(s.url);return c&&(o.error_file=c),Number.isInteger(s.line)&&s.line>=0&&(o.error_line=s.line),Number.isInteger(s.col)&&s.col>=0&&(o.error_col=s.col),o}function na(e,t=Date.now()){let n=wi.get(e);if(!n)return!1;let r=n===Di&&t-Oi<Ti;return Di=n,Oi=t,r||(Ei[n]+=1),e===`pose_edit`&&Ca(`pose_edit`),!r}function ra(){return Object.fromEntries(Object.entries(Ei).map(([e,t])=>[`${e}_edit_bucket`,Hi(t)]))}function ia(e,t=`unknown`){try{if(e?.name===`AbortError`)return`aborted`;if(ri.has(e?.exportFailureCode))return e.exportFailureCode}catch{}return ri.has(t)?t:`unknown`}function aa(e,t={}){let n=!1,r=null,i=NaN,a=()=>performance.now(),o=$,s=()=>{try{return a()}catch{return NaN}},c=(e,t)=>{try{Promise.resolve(o(e,Vi(e,t))).catch(()=>{})}catch{}};try{a=t.now??a,o=t.capture??o;let n=[...globalThis.crypto.getRandomValues(new Uint8Array(16))].map(e=>e.toString(16).padStart(2,`0`)).join(``);r={...Vi(`export:attempt_started`,e),attempt_id:n},i=s(),c(`export:attempt_started`,r)}catch{r=null}let l=(e,t,a)=>{if(!n&&(n=!0,r))try{let n={...r,duration_bucket:Ki(s()-i)};e===`failed`&&(n.failure_code=ia(t,a),n.failure_code===`aborted`&&(e=`cancelled`)),c(`export:attempt_${e}`,n)}catch{}};return{succeed(){l(`succeeded`)},fail(e,t=`unknown`){l(`failed`,e,t)}}}var oa=[`$current_url`,`$initial_current_url`,`$referrer`,`$initial_referrer`],sa=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_content`,`utm_term`,`gad_source`,`mc_cid`,`gclid`,`gclsrc`,`dclid`,`gbraid`,`wbraid`,`fbclid`,`msclkid`,`twclid`,`li_fat_id`,`igshid`,`ttclid`,`rdt_cid`,`epik`,`qclid`,`sccid`,`irclid`,`_kx`,`ph_keyword`];function ca(e){return typeof e==`string`?e.split(`#`)[0].split(`?`)[0]:e}function la(e){if(!e||typeof e!=`object`||!e.properties)return e;let t=[e.properties,e.properties.$set,e.properties.$set_once,e.$set,e.$set_once].filter(e=>e&&typeof e==`object`&&!Array.isArray(e));for(let e of t){for(let t of oa)typeof e[t]==`string`&&(e[t]=ca(e[t]));for(let t of sa)delete e[t],delete e[`$initial_${t}`];for(let t of Object.keys(e))t.startsWith(`$session_entry_`)&&delete e[t]}return e}function ua(e){return e?.activationTracked!==!0}function da(){return mi?!0:ga()?.distribution===`npm`?ga()?.telemetryEnabled!==!0:Fi(Br)===`1`}function fa(){try{let e=Pi();if(!e)return;let t=[];for(let n=0;n<e.length;n+=1){let r=e.key(n);r&&r.startsWith(`ph_`)&&r.endsWith(`_posthog`)&&t.push(r)}for(let n of t)e.removeItem(n)}catch{}}async function pa(e){if(ga()?.distribution!==`npm`)return{ok:!0,enabled:e};try{let t=await fetch(`/__cozyclay/telemetry`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({enabled:e})});if(!t.ok)return{ok:!1,enabled:!e};let n=await t.json();return globalThis.__COZYCLAY_RUNTIME__=n,{ok:!0,enabled:n.telemetryEnabled===!0}}catch{return{ok:!1,enabled:!e}}}async function ma(e){let t=e===!0,n=ga()?.distribution===`npm`;mi=t;let r=await pa(!t);if(mi=!1,!r.ok)return da();let i=!r.enabled;if(Ii(Br,i?`1`:`0`),i&&fa(),n&&!i)return globalThis.location?.reload(),!1;if(!Z&&!i&&await xa(),!Z)return i;try{i?(Q=!1,Z.opt_out_capturing()):(Z.opt_in_capturing(),Q=pi)}catch{Q=!1}return i}function ha(){return{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_COZYCLAY_LIVE_PORT:`5184`}}function ga(){let e=globalThis.__COZYCLAY_RUNTIME__;return!e||typeof e!=`object`||Array.isArray(e)?null:e}function _a(e){try{let t=new URL(e);return t.protocol===`http:`&&[`127.0.0.1`,`localhost`].includes(t.hostname)}catch{return!1}}function va({env:e=ha(),origin:t=globalThis.location?.origin??``,runtime:n=ga()}={}){return e.PROD?n?.distribution===`npm`?n.telemetryEnabled===!0?_a(t)?typeof n.apiKey!=`string`||n.apiKey.length===0?{kind:`disabled`,reason:`no key`}:typeof n.installationId!=`string`||!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n.installationId)?{kind:`disabled`,reason:`invalid anonymous identity`}:{kind:`enabled`,distribution:`npm`,apiKey:n.apiKey,apiHost:n.apiHost||`https://t.cozyclay.org`,appVersion:n.appVersion||null,installationId:n.installationId,firstLaunch:n.firstLaunch===!0,firstLaunchHeardFrom:ei.has(n.firstLaunchHeardFrom)?n.firstLaunchHeardFrom:null,installKind:[`npx`,`global`,`clone`].includes(n.installKind)?n.installKind:`npx`,originKind:`local`,internalQa:n.internalQa===!0,updateStatus:Yr.includes(n.updateStatus)?n.updateStatus:`unknown`}:{kind:`disabled`,reason:`unapproved origin`}:{kind:`disabled`,reason:`opted out`}:e.VITE_POSTHOG_KEY?zi(t,Ri(e.VITE_POSTHOG_ALLOWED_ORIGINS))?{kind:`enabled`,distribution:`hosted`,apiKey:e.VITE_POSTHOG_KEY,apiHost:e.VITE_POSTHOG_HOST||`https://us.i.posthog.com`,appVersion:e.VITE_APP_VERSION||null,installationId:null,firstLaunch:!1,firstLaunchHeardFrom:null,installKind:null,originKind:`hosted`,internalQa:Fi(Vr)===`1`,updateStatus:null}:{kind:`disabled`,reason:`unapproved origin`}:{kind:`disabled`,reason:`no key`}:{kind:`disabled`,reason:`not production`}}function ya(e){return{distribution:e.distribution,...e.appVersion?{app_version:e.appVersion}:{},origin_kind:e.originKind,os:Gi(),...e.installKind?{install_kind:e.installKind}:{},...e.updateStatus?{update_status:e.updateStatus}:{},internal_qa:e.internalQa}}function ba(e){let t=va({env:e});return t.kind===`disabled`?t.reason:da()?`opted out`:null}async function xa(){if(pi||hi)return hi;if(ga()?.distribution!==`npm`){let e=new URLSearchParams(globalThis.location?.search??``).getAll(`internal_qa`);e.length===1&&(e[0]===`1`||e[0]===`0`)&&Ii(Vr,e[0])}let e=ha(),t=ba(e);if(t){_i||=(console.info(`[analytics] disabled: `+t),!0);return}hi=(async()=>{try{let t=await Nr(()=>import(`./module-MzlRiBjI.js`),[]);if(da())return;let n=va({env:e});if(n.kind===`disabled`)return;Z=t.default??t,Z.init(n.apiKey,{api_host:n.apiHost,defaults:`2025-05-24`,autocapture:!1,capture_pageview:!1,capture_pageleave:!1,person_profiles:`never`,persistence:n.distribution===`npm`?`memory`:`localStorage`,respect_dnt:!0,disable_session_recording:!0,capture_dead_clicks:!1,capture_performance:!1,disable_capture_url_hashes:!0,save_campaign_params:!1,save_referrer:!1,mask_personal_data_properties:!0,request_batching:!1,advanced_disable_feature_flags:!0,disable_external_dependency_loading:!0,disable_surveys:!0,ui_host:`https://us.posthog.com`,bootstrap:n.installationId?{distinctID:n.installationId,isIdentifiedID:!1}:void 0,before_send:la}),pi=!0,Q=!0;let r=ya(n);if(Z.register(r),globalThis.__cozyclayAnalytics={instance:Z},Z.capture(`$pageview`),vi=Date.now(),Pa(n,r),Da(),Na(),n.distribution===`npm`&&($(`app:session_started`),n.firstLaunch)){let e=n.firstLaunchHeardFrom;$(`install:first_launch`,e?{heard_from:e}:{})}}catch{console.info(`[analytics] initialization failed`)}})(),await hi}function $(e,t={}){if(!(!pi||!Q||!Z))try{if(da())return;let n=Vi(e,t);Ni.has(e)||(yi+=1,(e===`scene:created`||e===`scene:loaded`)&&(bi+=1)),Z.capture(e,n)}catch{}}function Sa(e,{hadTarget:t=!1}={}){return oi.includes(e?.stage)?{outcome:e.stage,rounds:e.round,...Number.isFinite(e.iou)?{final_iou:Math.round(e.iou*100)/100}:{},duration_ms:Math.round(e.elapsedMs),had_target:!!t}:null}function Ca(e){return!pi||!Q||!Z||!Qr.has(e)||Ci.has(e)?!1:(Ci.add(e),$(`feature:used`,{name:e}),!0)}function wa(){try{return pi&&Q&&!!Z&&!da()}catch{return!1}}function Ta(){return wa()&&Fi(Ur)!==`1`}function Ea(e,t){Ii(Ur,`1`),$(`survey:use_case`,{use_case:Kr.includes(e)?e:`skip`,team:qr.includes(t)?t:`skip`})}function Da(){if(ji||typeof window>`u`||typeof window.addEventListener!=`function`)return;ji=!0;let e=e=>{try{let t=ta(e),n=[t.error_kind,t.error_type,t.error_source,t.error_file,t.error_line,t.error_col].join(`|`);if(Ai.has(n)||Ai.size>=ki)return;Ai.add(n),$(`app:error`,t)}catch{}};window.addEventListener(`error`,t=>{try{if(typeof t?.message==`string`&&t.message.startsWith(`ResizeObserver loop`)||!t?.error&&!t?.filename)return;e({error:t?.error,filename:t?.filename,lineno:t?.lineno,colno:t?.colno,kind:`error`})}catch{}}),window.addEventListener(`unhandledrejection`,t=>{e({error:t?.reason,kind:`unhandled_rejection`})})}function Oa(){try{let e=globalThis.document?.createElement?.(`canvas`);if(!e?.getContext)return{webgl:`none`,renderer:``};let t=e.getContext(`webgl2`),n=t?`webgl2`:`none`;if(t||(t=e.getContext(`webgl`),t&&(n=`webgl1`)),!t)return{webgl:n,renderer:``};let r=``;try{let e=t.getExtension(`WEBGL_debug_renderer_info`);r=String(t.getParameter(e?e.UNMASKED_RENDERER_WEBGL:t.RENDERER)??``)}catch{r=``}try{t.getExtension(`WEBGL_lose_context`)?.loseContext()}catch{}return{webgl:n,renderer:r}}catch{return{webgl:`none`,renderer:``}}}var ka=8e3,Aa=3e3,ja=6e4;function Ma(){return new Promise(e=>{let t=globalThis.requestAnimationFrame;if(typeof t!=`function`){e(null);return}let n=()=>globalThis.document?.visibilityState===`hidden`,r=Date.now(),i=()=>{if(Date.now()-r>ja){e(null);return}if(n()){setTimeout(i,2e3);return}let a=0,o=0,s=r=>{if(n()){setTimeout(i,2e3);return}if(o||=r,a+=1,r-o>=Aa){e((a-1)*1e3/(r-o));return}t(s)};t(s)};setTimeout(i,ka)})}async function Na(){if(!(Mi||globalThis.document===void 0||typeof globalThis.requestAnimationFrame!=`function`)){Mi=!0;try{let{webgl:e,renderer:t}=Oa(),n=Xi(t),r=await Ma();$(`device:profile`,{...n,webgl:e,cpu_bucket:qi(globalThis.navigator?.hardwareConcurrency),memory_bucket:Ji(globalThis.navigator?.deviceMemory),frame_rate_bucket:Yi(r)})}catch{}}}function Pa(e,t){if(Si||typeof window>`u`)return;Si=!0;let n=()=>{if(!(xi||!vi)){xi=!0;try{if(!Q||!Z||da()||Z.has_opted_out_capturing())return;let n={api_key:e.apiKey,event:`app:session_ended`,properties:{...t,distinct_id:Z.get_distinct_id(),duration_bucket:Ui(Date.now()-vi),action_count_bucket:Hi(yi),scenes_touched:Math.min(20,bi),...ra()}},r=JSON.stringify(n),i=`${e.apiHost.replace(/\/$/,``)}/e/`;typeof globalThis.navigator?.sendBeacon==`function`?globalThis.navigator.sendBeacon(i,new Blob([r],{type:`application/json`})):fetch(i,{method:`POST`,body:r,keepalive:!0,headers:{"content-type":`application/json`}})}catch{}}};window.addEventListener(`pagehide`,n,{once:!0}),window.addEventListener(`beforeunload`,n,{once:!0})}function Fa(e){if(!(!pi||!Q||gi)){if(!ua({activationTracked:Fi(Hr)===`1`})){gi=!0;return}gi=!0,Ii(Hr,`1`),$(`activation:completed`,{activation_path:e})}}export{ke as $,wt as A,K as B,kr as C,l as Ct,St as D,Ct as E,Kn as F,Ke as G,Yn as H,O as I,Qe as J,Pe as K,Jn as L,un as M,E as N,rn as O,D as P,be as Q,tn as R,Nr as S,h as St,Cr as T,qn as U,Zn as V,G as W,tt as X,$e as Y,xe as Z,Ta as _,e as _t,wa as a,ve as at,Fa as b,c as bt,Wi as c,de as ct,xa as d,x as dt,Ae as et,na as f,ae as ft,ma as g,oe as gt,Sa as h,se as ht,Rr as i,ge as it,Tt as j,Dt as k,ia as l,ce as lt,Vi as m,ie as mt,Ir as n,fe as nt,Hi as o,_e as ot,Ea as p,y as pt,et as q,Lr as r,pe as rt,Ki as s,ye as st,Fr as t,Oe as tt,da as u,le as ut,aa as v,u as vt,Or as w,p as wt,Ca as x,ee as xt,$ as y,d as yt,Ot as z};
|