human2ai 0.1.4 → 0.1.6
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/README.en.md +51 -28
- package/README.md +51 -28
- package/dist/cli/main.js +33 -21
- package/dist/cli/main.js.map +1 -1
- package/dist/database/composition-session-repository.d.ts +2 -0
- package/dist/database/composition-session-repository.js +1 -0
- package/dist/database/composition-session-repository.js.map +1 -1
- package/dist/database/draft-version-store.d.ts +8 -1
- package/dist/database/draft-version-store.js +21 -4
- package/dist/database/draft-version-store.js.map +1 -1
- package/dist/database/project-session-repository.d.ts +24 -1
- package/dist/database/project-session-repository.js +80 -0
- package/dist/database/project-session-repository.js.map +1 -1
- package/dist/database/session-preview-validation.d.ts +3 -0
- package/dist/database/session-preview-validation.js +44 -0
- package/dist/database/session-preview-validation.js.map +1 -0
- package/dist/database/spatial-session-repository.d.ts +2 -0
- package/dist/database/spatial-session-repository.js +1 -0
- package/dist/database/spatial-session-repository.js.map +1 -1
- package/dist/database/svg-input.js +9 -1
- package/dist/database/svg-input.js.map +1 -1
- package/dist/database/ui-sketch-session-repository.d.ts +3 -0
- package/dist/database/ui-sketch-session-repository.js +6 -0
- package/dist/database/ui-sketch-session-repository.js.map +1 -1
- package/dist/domain/canvas-frame.d.ts +15 -0
- package/dist/domain/canvas-frame.js +24 -0
- package/dist/domain/canvas-frame.js.map +1 -0
- package/dist/domain/canvas-node-tone.d.ts +1 -0
- package/dist/domain/canvas-node-tone.js +9 -0
- package/dist/domain/canvas-node-tone.js.map +1 -0
- package/dist/domain/canvas-shape-overlap.d.ts +12 -0
- package/dist/domain/canvas-shape-overlap.js +79 -0
- package/dist/domain/canvas-shape-overlap.js.map +1 -0
- package/dist/domain/composition/analysis.d.ts +1 -0
- package/dist/domain/composition/analysis.js +6 -3
- package/dist/domain/composition/analysis.js.map +1 -1
- package/dist/domain/composition/draft.d.ts +6 -1
- package/dist/domain/composition/draft.js +43 -28
- package/dist/domain/composition/draft.js.map +1 -1
- package/dist/domain/composition/frame.d.ts +5 -8
- package/dist/domain/composition/frame.js +21 -68
- package/dist/domain/composition/frame.js.map +1 -1
- package/dist/domain/composition/index.d.ts +3 -3
- package/dist/domain/composition/index.js +3 -3
- package/dist/domain/composition/index.js.map +1 -1
- package/dist/domain/composition/raster.d.ts +2 -0
- package/dist/domain/composition/raster.js +19 -0
- package/dist/domain/composition/raster.js.map +1 -0
- package/dist/domain/composition/refinement/engine.js +1 -0
- package/dist/domain/composition/refinement/engine.js.map +1 -1
- package/dist/domain/composition/refinement/types.d.ts +1 -0
- package/dist/domain/composition/render.d.ts +6 -0
- package/dist/domain/composition/render.js +84 -20
- package/dist/domain/composition/render.js.map +1 -1
- package/dist/domain/composition/states.js +14 -8
- package/dist/domain/composition/states.js.map +1 -1
- package/dist/domain/composition/text-warp.d.ts +8 -0
- package/dist/domain/composition/text-warp.js +60 -0
- package/dist/domain/composition/text-warp.js.map +1 -0
- package/dist/domain/composition/types.d.ts +9 -4
- package/dist/domain/session/canvas-edit-history.d.ts +2 -0
- package/dist/domain/session/canvas-edit-history.js +2 -0
- package/dist/domain/session/canvas-edit-history.js.map +1 -1
- package/dist/domain/session/preview.d.ts +16 -0
- package/dist/domain/session/preview.js +48 -0
- package/dist/domain/session/preview.js.map +1 -0
- package/dist/domain/session/types.d.ts +8 -0
- package/dist/domain/ui-sketch/appearance.d.ts +12 -0
- package/dist/domain/ui-sketch/appearance.js +24 -0
- package/dist/domain/ui-sketch/appearance.js.map +1 -0
- package/dist/domain/ui-sketch/draft.js +3 -1
- package/dist/domain/ui-sketch/draft.js.map +1 -1
- package/dist/domain/ui-sketch/render.js +21 -17
- package/dist/domain/ui-sketch/render.js.map +1 -1
- package/dist/domain/ui-sketch/session-preview.d.ts +27 -0
- package/dist/domain/ui-sketch/session-preview.js +43 -0
- package/dist/domain/ui-sketch/session-preview.js.map +1 -0
- package/dist/domain/ui-sketch/types.d.ts +2 -0
- package/dist/server/app.d.ts +1 -1
- package/dist/server/app.js +8 -0
- package/dist/server/app.js.map +1 -1
- package/dist/server/routes/project-sessions.js +47 -3
- package/dist/server/routes/project-sessions.js.map +1 -1
- package/dist/server/routes/session-previews.d.ts +3 -0
- package/dist/server/routes/session-previews.js +104 -0
- package/dist/server/routes/session-previews.js.map +1 -0
- package/dist/server/session-preview-service.d.ts +55 -0
- package/dist/server/session-preview-service.js +255 -0
- package/dist/server/session-preview-service.js.map +1 -0
- package/locales/en/common.json +72 -8
- package/migrations/0011_session_groups.sql +21 -0
- package/package.json +1 -1
- package/schemas/composition-draft.schema.json +11 -2
- package/schemas/ui-sketch-draft.schema.json +85 -0
- package/skills/human2ai/SKILL.md +1 -1
- package/skills/human2ai/references/composition-projection.md +5 -3
- package/skills/human2ai/references/composition.md +51 -10
- package/skills/human2ai/references/ui-layout.md +7 -1
- package/web/out/404/index.html +1 -1
- package/web/out/404.html +1 -1
- package/web/out/__next.__PAGE__.txt +15 -14
- package/web/out/__next._full.txt +24 -23
- package/web/out/__next._tree.txt +6 -6
- package/web/out/_next/static/chunks/{635-611c009924b842be.js → 164-d8dd2b053f27bf62.js} +30 -30
- package/web/out/_next/static/chunks/348-6baeec6b3dbf02ab.js +1 -0
- package/web/out/_next/static/chunks/app/_not-found/page-742cf440bebb3b9b.js +1 -0
- package/web/out/_next/static/chunks/app/composition/page-8d037a4b99bb5546.js +1 -0
- package/web/out/_next/static/chunks/app/layout-ca2f61a5a618caea.js +1 -0
- package/web/out/_next/static/chunks/app/page-9b8bd42a93c9242c.js +1 -0
- package/web/out/_next/static/chunks/app/spatial/page-1d16089ca24b2eb8.js +1 -0
- package/web/out/_next/static/chunks/app/styles/page-e4d3c95957349351.js +1 -0
- package/web/out/_next/static/chunks/app/ui-sketch/page-23e5c3b12d99082c.js +1 -0
- package/web/out/_next/static/chunks/{main-app-cf37a257d91ce62e.js → main-app-5419a575f3ff4496.js} +1 -1
- package/web/out/_next/static/chunks/next/dist/client/components/builtin/global-error-15f5118ed5e001a8.js +1 -0
- package/web/out/_next/static/chunks/webpack-e781b4e158568ba0.js +1 -0
- package/web/out/_next/static/css/{3b7982b41ed8eccd.css → 210db1811016f805.css} +1 -1
- package/web/out/_next/static/css/2160a6bbf2cb551c.css +1 -0
- package/web/out/_next/static/css/28a4978acacc40b0.css +1 -0
- package/web/out/_next/static/css/{c739d0131cdcc891.css → 2a0db06638359895.css} +1 -1
- package/web/out/_next/static/css/4b1f9941c214d619.css +5 -0
- package/web/out/_next/static/css/9c61ee5fe683073a.css +1 -0
- package/web/out/_next/static/css/c39f5ecbfc8cb532.css +1 -0
- package/web/out/_not-found/__next._full.txt +21 -18
- package/web/out/_not-found/__next._not-found.__PAGE__.txt +11 -8
- package/web/out/_not-found/__next._tree.txt +5 -3
- package/web/out/_not-found/index.html +1 -1
- package/web/out/_not-found/index.txt +21 -18
- package/web/out/brand/h2a-1024.png +0 -0
- package/web/out/brand/h2a-128.png +0 -0
- package/web/out/brand/h2a-16.png +0 -0
- package/web/out/brand/h2a-256.png +0 -0
- package/web/out/brand/h2a-32.png +0 -0
- package/web/out/brand/h2a-48.png +0 -0
- package/web/out/brand/h2a-512.png +0 -0
- package/web/out/brand/h2a-64.png +0 -0
- package/web/out/brand/h2a.svg +10 -1
- package/web/out/composition/__next._full.txt +26 -26
- package/web/out/composition/__next._tree.txt +6 -7
- package/web/out/composition/__next.composition.__PAGE__.txt +13 -13
- package/web/out/composition/index.html +1 -1
- package/web/out/composition/index.txt +26 -26
- package/web/out/favicon.ico +0 -0
- package/web/out/icon.svg +10 -1
- package/web/out/index.html +1 -1
- package/web/out/index.txt +24 -23
- package/web/out/spatial/__next._full.txt +25 -24
- package/web/out/spatial/__next._tree.txt +5 -5
- package/web/out/spatial/__next.spatial.__PAGE__.txt +12 -11
- package/web/out/spatial/index.html +1 -1
- package/web/out/spatial/index.txt +25 -24
- package/web/out/styles/__next._full.txt +25 -24
- package/web/out/styles/__next._tree.txt +5 -5
- package/web/out/styles/__next.styles.__PAGE__.txt +12 -11
- package/web/out/styles/index.html +1 -1
- package/web/out/styles/index.txt +25 -24
- package/web/out/ui-sketch/__next._full.txt +26 -26
- package/web/out/ui-sketch/__next._tree.txt +6 -7
- package/web/out/ui-sketch/__next.ui-sketch.__PAGE__.txt +13 -13
- package/web/out/ui-sketch/index.html +1 -1
- package/web/out/ui-sketch/index.txt +26 -26
- package/web/out/_next/static/chunks/130-7e9e715a084569bb.js +0 -1
- package/web/out/_next/static/chunks/166-96a8c6ae1e9aed59.js +0 -1
- package/web/out/_next/static/chunks/20-0801fc297cda2a7a.js +0 -1
- package/web/out/_next/static/chunks/678-32d3aa1859450d63.js +0 -1
- package/web/out/_next/static/chunks/app/_not-found/page-b92817fdc4609975.js +0 -1
- package/web/out/_next/static/chunks/app/composition/page-6c12ee8472715448.js +0 -1
- package/web/out/_next/static/chunks/app/layout-1dd9196cde94389c.js +0 -1
- package/web/out/_next/static/chunks/app/page-741ecaf9ee8c3c07.js +0 -1
- package/web/out/_next/static/chunks/app/spatial/page-5ba0940650df6c7f.js +0 -1
- package/web/out/_next/static/chunks/app/styles/page-1ccfc2c5fbc1e646.js +0 -1
- package/web/out/_next/static/chunks/app/ui-sketch/page-ef4f2e531583e684.js +0 -1
- package/web/out/_next/static/chunks/next/dist/client/components/builtin/global-error-33b4f58f02e82215.js +0 -1
- package/web/out/_next/static/chunks/webpack-d16ce1f994e98178.js +0 -1
- package/web/out/_next/static/css/06743b5635914999.css +0 -5
- package/web/out/_next/static/css/1f8501a43042a5a2.css +0 -1
- package/web/out/_next/static/css/39e8cace36461a15.css +0 -1
- package/web/out/_next/static/css/81ae71f1d3e9a866.css +0 -1
- package/web/out/_next/static/css/ce1b4bb3ad3c6073.css +0 -1
- package/web/out/_next/static/css/db96ae2e88545d96.css +0 -1
- /package/web/out/_next/static/{n4UcxqMmr_2CBmSxBp52z → MtSBeMOcAQHxKAV1fmedM}/_buildManifest.js +0 -0
- /package/web/out/_next/static/{n4UcxqMmr_2CBmSxBp52z → MtSBeMOcAQHxKAV1fmedM}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[130],{362:(e,t,i)=>{"use strict";i.d(t,{jZ:()=>eL,zr:()=>e8,b2:()=>nn,Cf:()=>e3,x8:()=>is,yP:()=>tv,X3:()=>i_,te:()=>nr,J3:()=>nm,WL:()=>nj,Hx:()=>n5,cF:()=>nv,Ol:()=>tb,NX:()=>tG,SM:()=>nI,FU:()=>e6,LE:()=>tw,Nc:()=>e7,vB:()=>tx,MH:()=>tk,kC:()=>tf,Y$:()=>ty,wN:()=>tg});var n=i(73365),a=i(66381),r=i(44291),o=i(44040),s=i(81271),l=i(13360),d=i(3742),c=i(35659),u=i(1521);i(22392),i(16803);var m=i(46811),h=i(67282);let p=Object.freeze({minRows:3,maxRows:6}),g=(0,u.forwardRef)(function(e,t){let{autoSize:i,rows:a,className:r,...o}=e;return(0,n.jsx)(l.A.TextArea,{...o,ref:t,className:["yisi-text-mark-editor-textarea",r].filter(Boolean).join(" "),autoSize:p,"data-yisiui-auto-size":"content","data-yisiui-min-rows":"3","data-yisiui-max-rows":"6"})});function f({label:e,controlId:t,htmlFor:i,hint:a,children:r}){let o=(0,u.useId)(),s=t??i??r.props.id??o,l=a?`${s}-hint`:void 0,d=[r.props["aria-describedby"],l].filter(Boolean).join(" ")||void 0,c=(0,u.cloneElement)(r,{id:s,"aria-describedby":d});return(0,n.jsxs)("div",{className:"yisi-text-mark-editor-field",children:[(0,n.jsxs)("div",{className:"yisi-text-mark-editor-field-heading",children:[(0,n.jsx)("label",{className:"yisi-text-mark-editor-field-label",htmlFor:s,children:e}),a?(0,n.jsx)("span",{id:l,className:"yisi-text-mark-editor-field-hint",children:a}):null]}),c]})}function y({open:e,title:t,selectedText:i,selectedTextLabel:a,children:r,onCancel:o,onSave:l,saveLabel:p,cancelLabel:g,saveLoading:f=!1,saveDisabled:x=!1,deleteAction:b,error:v}){let w=(0,u.useId)();return(0,n.jsx)(d.A,{open:e,title:t,width:520,destroyOnHidden:!0,footer:null,closable:!f,keyboard:!f,mask:{closable:!f},focusable:{focusTriggerAfterClose:!0},rootClassName:"yisi-text-mark-editor-modal",onCancel:o,children:(0,n.jsxs)("div",{...(0,m.S)("text-mark-editor","TextMarkEditor"),className:"yisi-text-mark-editor","data-has-delete":b?"true":"false","aria-busy":f||void 0,children:[(0,n.jsxs)("section",{className:"yisi-text-mark-editor-context","aria-labelledby":w,children:[(0,n.jsx)("span",{id:w,className:"yisi-text-mark-editor-context-label",children:a}),(0,n.jsx)("blockquote",{className:"yisi-text-mark-editor-quote",children:i})]}),(0,n.jsx)("div",{className:"yisi-text-mark-editor-fields",children:r}),v?(0,n.jsx)("div",{className:"yisi-text-mark-editor-error",role:"alert",children:v}):null,(0,n.jsxs)("div",{className:"yisi-text-mark-editor-actions",children:[b?(0,n.jsx)(h.x,{className:"yisi-text-mark-editor-delete-action",type:"text",size:"small",icon:(0,n.jsx)(s.A,{"aria-hidden":"true"}),title:b.confirmTitle,description:b.confirmDescription,scopeLabel:b.scopeLabel,confirmLabel:b.confirmLabel??b.label,cancelLabel:b.confirmCancelLabel,disabled:f,onConfirm:b.onConfirm,children:b.label}):null,(0,n.jsx)(c.Ay,{disabled:f,onClick:o,children:g}),(0,n.jsx)(c.Ay,{type:"primary",loading:f,disabled:x,onClick:()=>void l(),children:p})]})]})})}let x={bringToFront:"置于顶层",bringForward:"上移一层",sendBackward:"下移一层",sendToBack:"置于底层"};function b(){let[e,t]=(0,u.useState)(!1),[i,n]=(0,u.useState)({x:0,y:0}),a=(0,u.useRef)(null),r=(0,u.useRef)(null),o=(0,u.useCallback)(()=>t(!1),[]),s=(0,u.useCallback)(()=>{t(!1),a.current?.focus()},[]);return(0,u.useEffect)(()=>{if(!e)return;let t=e=>{e.target instanceof Node&&r.current?.contains(e.target)||s()};return window.addEventListener("pointerdown",t,!0),()=>window.removeEventListener("pointerdown",t,!0)},[e,s]),{contextMenuOpen:e,contextMenuPoint:i,contextMenuPopupRef:r,openContextMenuAt:(e,i)=>{a.current=i,n({x:e.clientX,y:e.clientY}),t(!0)},closeContextMenu:s,dismissContextMenu:o}}var v=i(76109),w=i(34345),j=i(3693),k=i(27812);let I=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"];function S(e,t){return Number.isFinite(e)?Math.max(e,t):1}function P(e,t,i,n){return{x:e,y:t,width:Math.max(0,i-e),height:Math.max(0,n-t)}}var C=i(24539),M=i(98196);function A({id:e,label:t,children:i,x:a=0,y:r=0,rotation:o=0,selected:s=!1,controlsHost:l,locked:d=!1,bounds:c,resizeMode:m="free",resizeCenter:h,minimumWidth:p=8,minimumHeight:g=8,screenScale:f=1,resizeHitSize:y=24,resizeHandles:x=I,showRotationHandle:b=!0,rotationHandleOffset:v=32,nudgeStep:w=1,largeNudgeStep:j=10,tooltip:T,onSelect:R,onNudge:E,onResize:q,onRotate:D,onDoubleClick:z,onDelete:B,onKeyDown:O,className:U,...J}){var W;let H=(0,u.useRef)(null),Y=(0,u.useRef)(null),V=!d&&!!(R||E||q||D||z||B||O),X=["human2ai-canvas-node",U].filter(Boolean).join(" "),G=s&&!d&&!!(c&&q),K=s&&!d&&b&&!!(c&&D),Z=f>0&&Number.isFinite(f)?f:1,Q=v/Z;function ee(t){let i=H.current;if(!i||i.pointerId!==t.pointerId||!q)return;t.preventDefault(),t.stopPropagation();let n=N(t,i.inverseMatrix),a="free"!==m||t.shiftKey,r=function({bounds:e,handle:t,pointer:i,center:n={x:e.x+e.width/2,y:e.y+e.height/2},fromCenter:a=!1,proportional:r=!1,minimumWidth:o=1,minimumHeight:s=1}){let l=t.endsWith("left"),d=t.endsWith("right"),c=t.startsWith("top"),u=t.startsWith("bottom"),m=l||d,h=c||u,p=e.x+e.width,g=e.y+e.height,f=o/e.width,y=s/e.height,x=1,b=1;if(m)if(a){let t=l?e.x:p;x=S((i.x-n.x)/(t-n.x),f)}else x=S((l?p-i.x:i.x-e.x)/e.width,f);if(h)if(a){let t=c?e.y:g;b=S((i.y-n.y)/(t-n.y),y)}else b=S((c?g-i.y:i.y-e.y)/e.height,y);if(r){let e=function({scaleX:e,scaleY:t,movesHorizontally:i,movesVertically:n,minimumScale:a}){return i?n?Math.max(Math.abs(e-1)>=Math.abs(t-1)?e:t,a):Math.max(e,a):Math.max(t,a)}({scaleX:x,scaleY:b,movesHorizontally:m,movesVertically:h,minimumScale:Math.max(f,y)});x=e,b=e}let v=e.width*x,w=e.height*b;return{bounds:{x:a?n.x+(e.x-n.x)*x:l?p-v:d?e.x:e.x+(e.width-v)/2,y:a?n.y+(e.y-n.y)*b:c?g-w:u?e.y:e.y+(e.height-w)/2,width:v,height:w},scaleX:x,scaleY:b}}({bounds:i.sourceBounds,handle:i.handle,pointer:n,center:h,fromCenter:t.altKey,proportional:a,minimumWidth:p,minimumHeight:g});q({id:e,handle:i.handle,bounds:r.bounds,sourceBounds:i.sourceBounds,sourcePosition:i.sourcePosition,sourceRotation:i.sourceRotation,scaleX:r.scaleX,scaleY:r.scaleY,fromCenter:t.altKey,proportional:a})}function et(e){H.current?.pointerId===e.pointerId&&(H.current=null,F(e.currentTarget,e.pointerId))}function ei(e){Y.current?.pointerId===e.pointerId&&(Y.current=null,F(e.currentTarget,e.pointerId))}let en=(0,n.jsxs)(n.Fragment,{children:[c?(0,n.jsx)("rect",{className:"human2ai-canvas-node__outline",x:c.x,y:c.y,width:c.width,height:c.height,"aria-hidden":"true"}):null,G&&c?(0,n.jsx)("g",{className:"human2ai-canvas-node__resize-controls","aria-hidden":"true",children:(W=x,[...L,...I.filter(e=>!L.includes(e))].filter(e=>W.includes(e))).map(t=>{let i=function({bounds:e,handle:t,hitSize:i,screenScale:n=1}){let a=Math.max(0,i)/(n>0&&Number.isFinite(n)?n:1)/2,r=Math.min(a,e.width/3),o=Math.min(a,e.height/3),s=e.x-a,l=e.x+r,d=e.x+e.width-r,c=e.x+e.width+a,u=e.y-a,m=e.y+o,h=e.y+e.height-o,p=e.y+e.height+a;return"top"===t?P(l,u,d,m):"right"===t?P(d,m,c,h):"bottom"===t?P(l,h,d,p):"left"===t?P(s,m,l,h):"top-left"===t?P(s,u,l,m):"top-right"===t?P(d,u,c,m):"bottom-right"===t?P(d,h,c,p):P(s,h,l,p)}({bounds:c,handle:t,hitSize:y,screenScale:Z});return(0,n.jsx)("rect",{className:"human2ai-canvas-node__resize-hit","data-node-id":e,"data-resize-handle":t,x:i.x,y:i.y,width:i.width,height:i.height,onPointerDown:i=>(function(t,i){if(!c||!q)return;let n=t.currentTarget.closest("[data-canvas-node]")??t.currentTarget.ownerSVGElement?.querySelector(`[data-canvas-node="${CSS.escape(e)}"]`),s=n?.getScreenCTM();s&&(t.preventDefault(),t.stopPropagation(),n?.focus(),H.current={pointerId:t.pointerId,handle:i,sourceBounds:{...c},sourcePosition:{x:a,y:r},sourceRotation:o,inverseMatrix:s.inverse()},$(t.currentTarget,t.pointerId))})(i,t),onPointerMove:ee,onPointerUp:et,onPointerCancel:et,onLostPointerCapture:()=>{H.current=null}},t)})}):null,K&&c?(0,n.jsxs)("g",{className:"human2ai-canvas-node__rotation-control","aria-hidden":"true",children:[(0,n.jsx)("line",{className:"human2ai-canvas-node__rotation-stem",x1:c.x+c.width/2,y1:c.y,x2:c.x+c.width/2,y2:c.y-Q}),(0,n.jsx)("circle",{className:"human2ai-canvas-node__rotation-handle",cx:c.x+c.width/2,cy:c.y-Q,r:7/Z}),(0,n.jsx)("circle",{className:"human2ai-canvas-node__rotation-hit","data-node-id":e,"data-rotation-handle":"true",cx:c.x+c.width/2,cy:c.y-Q,r:12/Z,onPointerDown:function(t){if(!D)return;let i=t.currentTarget.closest("[data-canvas-node]")??t.currentTarget.ownerSVGElement?.querySelector(`[data-canvas-node="${CSS.escape(e)}"]`),n=i?.parentElement,s=n?.getScreenCTM();if(!s)return;let l=s.inverse(),d=N(t,l);t.preventDefault(),t.stopPropagation(),i?.focus(),Y.current={pointerId:t.pointerId,sourceRotation:o,startAngle:Math.atan2(d.y-r,d.x-a),inverseParentMatrix:l},$(t.currentTarget,t.pointerId)},onPointerMove:function(t){let i=Y.current;if(!i||i.pointerId!==t.pointerId||!D)return;t.preventDefault(),t.stopPropagation();let n=N(t,i.inverseParentMatrix),o=(Math.atan2(n.y-r,n.x-a)-i.startAngle)*180/Math.PI;D({id:e,rotation:i.sourceRotation+o,sourceRotation:i.sourceRotation})},onPointerUp:ei,onPointerCancel:ei,onLostPointerCapture:()=>{Y.current=null}})]}):null]}),ea=(0,n.jsxs)("g",{...J,...(0,k.Se)({namespace:"human2ai",id:"canvas-node",name:"CanvasNode",category:"module",origin:"project",status:"candidate"}),className:X,"data-canvas-node":e,"data-node-x":a,"data-node-y":r,"data-node-rotation":o,"data-selected":s?"true":"false","data-locked":d?"true":"false","data-resize-mode":q?m:void 0,"data-resizable":q?"true":"false","data-rotatable":D&&b?"true":"false","data-deletable":!d&&B?"true":"false","data-has-operation-outline":c?"true":"false",transform:`translate(${a} ${r}) rotate(${o})`,role:V?"button":J.role,"aria-label":V?t:J["aria-label"],"aria-pressed":V?s:void 0,"aria-disabled":d||void 0,"aria-keyshortcuts":!d&&B?"Delete Backspace":J["aria-keyshortcuts"],tabIndex:V?J.tabIndex??0:J.tabIndex,onClick:V?function(t){t.stopPropagation(),_(t.currentTarget),R?.(e,t)}:void 0,onDoubleClick:V&&z?function(t){t.stopPropagation(),z?.(e,t)}:void 0,onKeyDown:V?function(t){if(("Delete"===t.key||"Backspace"===t.key)&&s&&B){t.preventDefault(),t.stopPropagation(),B(e,t);return}if("Enter"===t.key||" "===t.key){if(!R)return;t.preventDefault(),R(e,t);return}let i=t.shiftKey?j:w,n={ArrowLeft:{x:-i,y:0},ArrowRight:{x:i,y:0},ArrowUp:{x:0,y:-i},ArrowDown:{x:0,y:i}}[t.key];n&&E?(t.preventDefault(),R?.(e,t),E(n)):O?.(t)}:void 0,onPointerDown:V?function(e){_(e.currentTarget),J.onPointerDown?.(e)}:J.onPointerDown,children:[i,l&&s?(0,M.createPortal)((0,n.jsx)("g",{className:X,"data-selected":"true","data-canvas-controls":e,transform:`translate(${a} ${r}) rotate(${o})`,children:en}),l):en]}),er=T?[[T.labels.nodeDescription,T.annotation],[T.labels.displayText,T.displayText],[T.labels.note,T.note]].filter(([,e])=>e?.trim()):[];return er.length>0?(0,n.jsx)(C.A,{title:(0,n.jsx)("dl",{className:"human2ai-canvas-node__tooltip",children:er.map(([e,t])=>(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:e}),(0,n.jsx)("dd",{children:t})]},e))}),mouseEnterDelay:0,mouseLeaveDelay:0,trigger:["hover","focus"],children:ea}):ea}i(4549);let L=["top","right","bottom","left"];function N(e,t){let i=new DOMPoint(e.clientX,e.clientY).matrixTransform(t);return{x:i.x,y:i.y}}function $(e,t){try{e.setPointerCapture(t)}catch{}}function F(e,t){e.hasPointerCapture(t)&&e.releasePointerCapture(t)}function _(e){e.focus(),requestAnimationFrame(()=>{e.isConnected&&e.focus()})}function T(e){let{type:t,className:i,fill:a,stroke:r,strokeWidth:o,opacity:s,style:l,"aria-label":d}=e,c=["human2ai-canvas-shape",i].filter(Boolean).join(" "),u={...(0,k.Se)({namespace:"human2ai",id:"canvas-shape",name:"CanvasShape",category:"module",origin:"project",status:"candidate"}),className:c,fill:a,stroke:r,strokeWidth:o,opacity:s,style:l,role:d?"img":void 0,"aria-label":d,"aria-hidden":!d||void 0,"data-shape-type":t};if("circle"===t)return"size"in e&&void 0!==e.size?(0,n.jsx)("circle",{...u,cx:0,cy:0,r:e.size/2}):(0,n.jsx)("ellipse",{...u,cx:0,cy:0,rx:e.width/2,ry:e.height/2});if("rectangle"===t)return(0,n.jsx)("rect",{...u,x:-e.width/2,y:-e.height/2,width:e.width,height:e.height});let m=`0,${-2*e.height/3} ${-e.width/2},${e.height/3} ${e.width/2},${e.height/3}`;return(0,n.jsx)("polygon",{...u,points:m})}function R({id:e,label:t,bounds:i,selected:a=!1,locked:r=!1,onMove:o,onSelect:s,className:l,...d}){let c=(0,u.useRef)(null),m=(0,u.useRef)(!1),h=["human2ai-canvas-frame__node",l].filter(Boolean).join(" "),p={x:-i.width/2,y:-i.height/2,width:i.width,height:i.height};function g(e){var t,i;let n=c.current;n?.pointerId===e.pointerId&&(m.current=n.moved,c.current=null,t=e.currentTarget,i=e.pointerId,t.hasPointerCapture(i)&&t.releasePointerCapture(i),window.setTimeout(()=>{m.current=!1},0))}return(0,n.jsx)("g",{...(0,k.Se)({namespace:"human2ai",id:"canvas-frame",name:"CanvasFrame",category:"module",origin:"project",status:"candidate"}),className:"human2ai-canvas-frame","data-canvas-frame":e,children:(0,n.jsxs)(A,{...d,id:e,label:t,x:i.x+i.width/2,y:i.y+i.height/2,bounds:p,selected:a,locked:r,onSelect:s,resizeHandles:I,showRotationHandle:!1,className:h,children:[(0,n.jsx)(T,{type:"rectangle",width:i.width,height:i.height,className:"human2ai-canvas-frame__border"}),(0,n.jsx)("rect",{className:"human2ai-canvas-frame__hit",x:p.x,y:p.y,width:p.width,height:p.height,"data-canvas-frame-hit":"true","data-frame-edge-mode":a?"resize":"move","data-frame-movable":a||r||!o?"false":"true","aria-hidden":"true",onClick:function(e){m.current&&(m.current=!1,e.preventDefault(),e.stopPropagation())},onPointerDown:function(e){if(a||r||!o||0!==e.button)return;m.current=!1;let t=e.currentTarget.closest("[data-canvas-frame]"),n=t?.querySelector("[data-canvas-node]"),s=t?.parentElement,l=s?.getScreenCTM();if(!l)return;let d=l.inverse();e.preventDefault(),e.stopPropagation(),n?.focus(),c.current={pointerId:e.pointerId,sourceBounds:{...i},start:E(e,d),startClient:{x:e.clientX,y:e.clientY},inverseMatrix:d,moved:!1},function(e,t){try{e.setPointerCapture(t)}catch{}}(e.currentTarget,e.pointerId)},onPointerMove:function(t){let i=c.current;if(!i||i.pointerId!==t.pointerId||!o||(t.preventDefault(),t.stopPropagation(),!i.moved&&3>Math.hypot(t.clientX-i.startClient.x,t.clientY-i.startClient.y)))return;i.moved=!0;let n=E(t,i.inverseMatrix),a={x:n.x-i.start.x,y:n.y-i.start.y};o({id:e,sourceBounds:i.sourceBounds,bounds:{...i.sourceBounds,x:i.sourceBounds.x+a.x,y:i.sourceBounds.y+a.y},delta:a})},onPointerUp:g,onPointerCancel:g,onLostPointerCapture:()=>{let e=c.current;e&&(m.current=e.moved,c.current=null,window.setTimeout(()=>{m.current=!1},0))}})]})})}function E(e,t){let i=new DOMPoint(e.clientX,e.clientY).matrixTransform(t);return{x:i.x,y:i.y}}function q({src:e,alt:t,width:i,height:a,fit:r="contain",crop:o=null,status:s="ready",loadingLabel:l="图片加载中",errorLabel:d="图片加载失败",emptyLabel:c="图片",opacity:m,className:h,onLoad:p,onError:g}){let f=`human2ai-canvas-image-${(0,u.useId)().replaceAll(":","")}`,y=["human2ai-canvas-image",h].filter(Boolean).join(" "),x=-i/2,b=-a/2,v="fill"===r?"none":`xMidYMid ${"cover"===r?"slice":"meet"}`;return(0,n.jsxs)("g",{...(0,k.Se)({namespace:"human2ai",id:"canvas-image",name:"CanvasImage",category:"module",origin:"project",status:"candidate"}),className:y,"data-image-fit":r,"data-image-status":s,role:"img","aria-label":t,opacity:m,children:[(0,n.jsx)("rect",{className:"human2ai-canvas-image__boundary",x:x,y:b,width:i,height:a,"aria-hidden":"true"}),"ready"===s&&e?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("defs",{children:(0,n.jsx)("clipPath",{id:f,children:(0,n.jsx)("rect",{x:x,y:b,width:i,height:a})})}),(0,n.jsx)("image",{className:"human2ai-canvas-image__content",href:e,x:o?x-o.x/o.width*i:x,y:o?b-o.y/o.height*a:b,width:o?i/o.width:i,height:o?a/o.height:a,preserveAspectRatio:o?"none":v,clipPath:`url(#${f})`,onLoad:p,onError:g,"aria-hidden":"true"})]}):(0,n.jsx)("text",{className:"human2ai-canvas-image__status",x:0,y:0,textAnchor:"middle",dominantBaseline:"middle","aria-hidden":"true",children:"loading"===s?l:"error"===s?d:c})]})}var D=i(67677);function z(e){for(let t of Array.from(e.items)){if("file"!==t.kind||!t.type.startsWith("image/"))continue;let e=t.getAsFile();if(e)return e}return Array.from(e.files).find(e=>e.type.startsWith("image/"))??null}async function B(e){let t=URL.createObjectURL(e);try{var i,n;let e,a=new Image;return a.src=t,await a.decode(),i=a.naturalWidth,n=a.naturalHeight,e=Math.min(1,320/Math.max(i,n)),{width:i*e,height:n*e}}finally{URL.revokeObjectURL(t)}}function O(e){let[t,i]=D.Ay.useMessage(),n=(0,u.useRef)(null),a=(0,u.useRef)(e),r=(0,u.useRef)(!1),o=(0,u.useRef)(0);return(0,u.useLayoutEffect)(()=>{a.current=e}),(0,u.useLayoutEffect)(()=>(r.current=!1,()=>{o.current+=1,t.destroy()}),[t,e.resetKey]),(0,u.useLayoutEffect)(()=>{let i=n.current;if(!i)return;let s=i.ownerDocument;function l(n){if(n.defaultPrevented||e.disabled)return;let l=n.target===s.body?s.activeElement:n.target;if(l instanceof Node&&i.contains(l))if("copy"===n.type)e.onCopy?.(n);else{let{x:s,y:l,width:d,height:c}=i.viewBox.baseVal;!function(i,n){if(i.defaultPrevented||e.disabled||!e.onUpload||!i.clipboardData)return!1;let s=i.target;if(s instanceof Element&&s.closest('input, textarea, [contenteditable="true"]'))return!1;let l=z(i.clipboardData);if(!l)return!1;if(i.preventDefault(),i.stopPropagation(),r.current)return!0;r.current=!0;let d=o.current,c=e.onUpload;return t.loading({key:"canvas-image-paste",content:e.labels.uploading,duration:0}),(async()=>{try{let e=await B(l);if(o.current!==d)return;let t=await c(l);if(o.current!==d||a.current.disabled)return;a.current.onImageReady({assetId:t,...n,...e})}catch{o.current===d&&t.error(a.current.labels.uploadFailed)}finally{o.current===d&&(r.current=!1,t.destroy("canvas-image-paste"))}})(),!0}(n,{x:s+d/2,y:l+c/2})&&e.onPasteFallback?.(n)}}return s.addEventListener("copy",l),s.addEventListener("paste",l),()=>{s.removeEventListener("copy",l),s.removeEventListener("paste",l)}}),{sceneRef:n,feedback:i}}var U=i(21184),J=i(65193),W=i(76793),H=i(17357),Y=i(48187),V=i(67872),X=i(29415),G=i(2684);function K(e,t){return(0,n.jsx)("span",{className:e,children:t})}function Z({label:e,pendingLabel:t,successLabel:i,errorLabel:a,onAction:r,idleIcon:o,successIcon:s=(0,n.jsx)(Y.A,{}),errorIcon:l=(0,n.jsx)(V.A,{}),feedbackDurationMs:d=1600,motion:c="auto",onStatusChange:h,onActionError:p,className:g,disabled:f,...y}){let[x,b]=(0,u.useState)("idle"),v=(0,u.useRef)(!0),w=(0,u.useRef)(!1),j=(0,u.useRef)(null);function k(e){v.current&&(b(e),h?.(e))}function I(){v.current&&null!==d&&(j.current=window.setTimeout(()=>{j.current=null,k("idle")},Math.max(0,d)))}async function S(){if(!w.current){w.current=!0,null!==j.current&&(window.clearTimeout(j.current),j.current=null),k("pending");try{if(await r(),!v.current)return;k("success"),I()}catch(e){if(!v.current)return;k("error"),p?.(e),I()}finally{w.current=!1}}}(0,u.useEffect)(()=>(v.current=!0,()=>{v.current=!1,null!==j.current&&window.clearTimeout(j.current)}),[]);let P="pending"===x?t:"success"===x?i:"error"===x?a:e,C="success"===x?K("yisi-action-button-feedback-icon",s):"error"===x?K("yisi-action-button-feedback-icon",l):o,M="pending"===x;return(0,n.jsx)(G.B,{attributes:(0,m.S)("action-button","ActionButton"),children:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(X.J,{...y,"aria-label":y["aria-label"]??P,"aria-busy":M||void 0,className:["yisi-action-button",`yisi-action-button-motion-${c}`,g].filter(Boolean).join(" "),"data-action-status":x,disabled:f||M,icon:C,loading:M,mode:"with-icon",onClick:()=>void S(),children:(0,n.jsx)("span",{"data-yisiui-slot":"label",children:P})}),(0,n.jsx)("span",{"aria-atomic":"true","aria-live":"polite",className:"yisi-action-button-announcement",role:"status",children:"idle"===x?"":P})]})})}async function Q(e){let t=window;if(t.showSaveFilePicker){let i;try{i=await t.showSaveFilePicker({suggestedName:e.name,types:[{accept:{[e.type]:[e.name.slice(e.name.lastIndexOf("."))]}}]})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return;throw e}let n=await i.createWritable();try{await n.write(e),await n.close()}catch(e){throw await n.abort().catch(()=>void 0),e}return}let i=URL.createObjectURL(e),n=document.createElement("a");n.href=i,n.download=e.name,document.body.append(n);try{n.click()}finally{n.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),6e4)}}function ee({src:e,crop:t,aspectRatio:i,labels:a,disabled:r=!1,onUpload:o,onReadFile:s,onCropChange:l}){var d;let c=(0,u.useRef)(null),m=(0,u.useRef)(!1),h=(0,u.useRef)(!1),p=(0,u.useId)(),g=(0,u.useRef)(null),f=(0,u.useRef)(null),y=(0,u.useRef)(null),x=(0,u.useRef)(null),[b,v]=(0,u.useState)(!1),[w,j]=(0,u.useState)(!1),[I,S]=(0,u.useState)(null),[P,C]=(0,u.useState)(!1),[M,A]=(0,u.useState)(null),[L,N]=(0,u.useState)(null),[$,F]=(0,u.useState)(null),[_,T]=(0,u.useState)(!1),[R,E]=(0,u.useState)(null),[q,D]=(0,u.useState)(!1),[B,O]=(0,u.useState)(!1),[Y,V]=(0,u.useState)(0),[G,K]=(0,u.useState)(!1),[er,eo]=(0,u.useState)(""),es=`${p}-source`;async function el(e){if(r||m.current)return!1;m.current=!0,v(!0),j(!1);try{return await o(e),!0}catch{return j(!0),!1}finally{m.current=!1,v(!1),g.current&&(g.current.value="")}}async function ed(){if(e&&$?.src===e&&!m.current&&!h.current){h.current=!0,T(!0),E(null);try{await Q($.file)}catch{E(e)}finally{h.current=!1,T(!1)}}}function ec(e){y.current=e,A(e)}function eu(e,t,i,n=y.current){if(!r&&n&&I){x.current={mode:t,pointerId:e.pointerId,startClientX:e.clientX,startClientY:e.clientY,startCrop:n,handle:i},e.currentTarget.closest("[data-crop-selection]")?.focus({preventScroll:!0});try{e.currentTarget.setPointerCapture?.(e.pointerId)}catch{}e.preventDefault(),e.stopPropagation()}}function em(e){let t=x.current;if(!t||t.pointerId!==e.pointerId)return;x.current=null;let i=y.current;i&&I&&l(i,en(i,I))}(0,u.useLayoutEffect)(()=>{K(!1)},[e]),(0,u.useEffect)(()=>{let t=!1;return N(null),F(null),E(null),O(!1),D(!!(e&&s)),e&&s&&s(e).then(async i=>{let n="image/svg+xml"===i.type?await i.text():null;t||(F({src:e,file:i}),N(n))}).catch(()=>{t||O(!0)}).finally(()=>{t||D(!1)}),()=>{t=!0}},[s,Y,e]),(0,u.useLayoutEffect)(()=>{S(null),C(!1),A(null),y.current=null,x.current=null},[e]),(0,u.useEffect)(()=>{var n,a,r;let o;if(!e||!I)return;let s=t?{...t}:{...r=(n=I,a=i,(o=n.width/n.height)>a?{x:0,y:0,width:a/o,height:1}:{x:0,y:0,width:1,height:o/a}),x:(1-r.width)/2,y:(1-r.height)/2};y.current=s,A(s)},[i,t,I,e]),(0,u.useEffect)(()=>{let e=c.current;if(!e)return;let t=e.closest('[role="dialog"]')??e,i=e.ownerDocument;function n(e){if(e.defaultPrevented||!e.clipboardData||r)return;let n=e.target===i.body?i.activeElement:e.target;if(!(n instanceof Node)||!t.contains(n))return;let a=z(e.clipboardData);a&&(e.preventDefault(),e.stopPropagation(),el(a))}return i.addEventListener("paste",n),()=>i.removeEventListener("paste",n)});let eh=I&&I.width<I.height?`min(100%, ${Math.round(360*I.width/I.height)}px)`:"100%";return(0,n.jsxs)("section",{ref:c,...(0,k.Se)({namespace:"human2ai",id:"canvas-image-editor-fields",name:"CanvasImageEditorFields",category:"module",origin:"project",status:"candidate"}),className:"human2ai-canvas-image-editor-fields","aria-labelledby":p,children:[(0,n.jsx)("div",{className:"human2ai-canvas-image-editor-fields__heading",children:(0,n.jsx)("span",{id:p,className:"yisi-text-mark-editor-field-label",children:a.content})}),(0,n.jsxs)("div",{className:"human2ai-canvas-image-editor-fields__actions",children:[(0,n.jsx)("input",{ref:g,className:"human2ai-canvas-image-editor-fields__input",type:"file",accept:"image/png,image/jpeg,image/webp,image/svg+xml,.svg",disabled:r||b,onChange:e=>{let t=e.target.files?.[0];t&&el(t)}}),(0,n.jsx)(X.J,{mode:"with-icon",icon:(0,n.jsx)(U.A,{}),loading:b,disabled:r||b,onClick:()=>g.current?.click(),children:b?a.uploading:e?a.replace:a.upload}),e&&s&&(0,n.jsx)(X.J,{mode:"with-icon",icon:(0,n.jsx)(J.A,{"aria-hidden":"true"}),loading:_,disabled:b||_||$?.src!==e,onClick:()=>{ed()},children:_?a.downloading:a.download}),(0,n.jsx)(X.J,{mode:"with-icon",icon:(0,n.jsx)(W.A,{"aria-hidden":"true"}),disabled:r||b,"aria-expanded":G,"aria-controls":es,onClick:()=>{eo(""),K(!0),j(!1)},children:a.svgPaste}),null!==L&&(0,n.jsx)(Z,{label:a.svgCopy,pendingLabel:a.svgCopying,successLabel:a.svgCopied,errorLabel:a.svgCopyFailed,idleIcon:(0,n.jsx)(H.A,{"aria-hidden":"true"}),disabled:b,onAction:()=>navigator.clipboard.writeText(L)},e)]}),(0,n.jsx)("span",{className:"human2ai-canvas-image-editor-fields__hint",role:w?"alert":void 0,children:w?G?a.svgSaveFailed:a.uploadFailed:a.fileTypes}),q&&(0,n.jsx)("span",{role:"status",children:a.sourceLoading}),R===e&&(0,n.jsx)("span",{role:"alert",children:a.downloadFailed}),B&&(0,n.jsxs)("div",{role:"alert",children:[a.sourceLoadFailed,(0,n.jsx)(X.J,{onClick:()=>V(e=>e+1),children:a.retry})]}),G&&(0,n.jsxs)("div",{id:es,className:"human2ai-canvas-image-editor-fields__source",children:[(0,n.jsx)("label",{htmlFor:`${es}-input`,children:a.svgSource}),(0,n.jsx)("textarea",{id:`${es}-input`,className:"yisi-text-mark-editor-textarea","aria-label":a.svgSource,value:er,onChange:e=>eo(e.target.value),disabled:r||b,rows:10,spellCheck:!1,autoFocus:!0}),(0,n.jsxs)("div",{className:"human2ai-canvas-image-editor-fields__actions",children:[(0,n.jsx)(X.J,{loading:b,disabled:r||b||!er.trim(),onClick:async()=>{await el(new File([er],"image.svg",{type:"image/svg+xml"}))&&K(!1)},children:a.svgApply}),(0,n.jsx)(X.J,{disabled:b,onClick:()=>{K(!1),j(!1)},children:a.cancel})]})]}),(0,n.jsx)("div",{className:"human2ai-canvas-image-editor-fields__preview-shell",children:e?P?(0,n.jsx)("div",{className:"human2ai-canvas-image-editor-fields__preview-status",role:"alert",children:a.cropLoadFailed}):(0,n.jsxs)("div",{ref:f,className:"human2ai-canvas-image-editor-fields__preview",style:{aspectRatio:I?`${I.width} / ${I.height}`:void 0,visibility:I?"visible":"hidden",width:eh},onPointerDown:function(e){let t=f.current?.getBoundingClientRect(),i=y.current;if(r||!t||!i)return;let n=ea((e.clientX-t.left)/t.width-i.width/2,0,1-i.width),a=ea((e.clientY-t.top)/t.height-i.height/2,0,1-i.height),o={...i,x:n,y:a};ec(o),eu(e,"move",void 0,o)},onPointerMove:function(e){var t,i,n;let a,r,o,s,l,d,c,u,m,h,p=x.current,g=f.current?.getBoundingClientRect();if(!p||p.pointerId!==e.pointerId||!g)return;let y=(e.clientX-p.startClientX)/g.width,b=(e.clientY-p.startClientY)/g.height;ec("move"===p.mode?ei(p.startCrop,y,b):(t=p,i=y,n=b,a=t.startCrop,o=(r=t.handle??"south-east").endsWith("east"),s=r.startsWith("south"),l=o?a.x:a.x+a.width,d=s?a.y:a.y+a.height,c=o?1-l:l,u=s?1-d:d,m=ea(a.width+(o?i:-i),Math.min(.05,c),c),h=ea(a.height+(s?n:-n),Math.min(.05,u),u),{x:o?l:l-m,y:s?d:d-h,width:m,height:h}))},onPointerUp:em,onPointerCancel:em,children:[(0,n.jsx)("img",{src:e,alt:"",draggable:!1,onLoad:e=>{let t=e.currentTarget;S({width:t.naturalWidth,height:t.naturalHeight}),C(!1)},onError:()=>{S(null),C(!0)}}),M?(0,n.jsx)("div",{className:"human2ai-canvas-image-editor-fields__crop-selection",style:(d=M,{left:`${100*d.x}%`,top:`${100*d.y}%`,width:`${100*d.width}%`,height:`${100*d.height}%`}),role:"group","aria-label":a.cropTitle,"aria-keyshortcuts":"ArrowLeft ArrowRight ArrowUp ArrowDown",tabIndex:r?-1:0,"data-crop-selection":!0,onPointerDown:e=>eu(e,"move"),onKeyDown:function(e){var t;let i=y.current;if(r||!i||"ArrowLeft"!==(t=e.key)&&"ArrowRight"!==t&&"ArrowUp"!==t&&"ArrowDown"!==t)return;e.preventDefault();let n=e.shiftKey?.05:.01,a=ei(i,"ArrowLeft"===e.key?-n:"ArrowRight"===e.key?n:0,"ArrowUp"===e.key?-n:"ArrowDown"===e.key?n:0);ec(a),I&&l(a,en(a,I))},children:et.map(e=>(0,n.jsx)("span",{className:"human2ai-canvas-image-editor-fields__crop-handle","data-crop-handle":e,"aria-hidden":"true",onPointerDown:t=>eu(t,"resize",e)},e))}):null]}):(0,n.jsx)("div",{className:"human2ai-canvas-image-editor-fields__preview-status","aria-label":a.content,children:(0,n.jsx)(U.A,{"aria-hidden":"true"})})})]})}i(21449),i(1713);let et=["north-west","north-east","south-east","south-west"];function ei(e,t,i){return{...e,x:ea(e.x+t,0,1-e.width),y:ea(e.y+i,0,1-e.height)}}function en(e,t){return e.width*t.width/(e.height*t.height)}function ea(e,t,i){return Math.min(i,Math.max(t,e))}function er(e){let{type:t,className:i,stroke:a,strokeWidth:r,dashArray:o,opacity:s,hitWidth:l,"aria-label":d}=e,c=`human2ai-canvas-line-arrow-${(0,u.useId)().replaceAll(":","")}`,m=["human2ai-canvas-line",i].filter(Boolean).join(" "),h="infinite"===t?function(e,t,i){let n=t*Math.PI/180,a={x:Math.cos(n),y:Math.sin(n)},r=i.x,o=i.x+i.width,s=i.y,l=i.y+i.height,d=[];function c(t){let i={x:e.x+a.x*t,y:e.y+a.y*t,distance:t};i.x<r-1e-6||i.x>o+1e-6||i.y<s-1e-6||i.y>l+1e-6||d.some(e=>1e-6>Math.hypot(e.x-i.x,e.y-i.y))||d.push(i)}return(Math.abs(a.x)>1e-6&&(c((r-e.x)/a.x),c((o-e.x)/a.x)),Math.abs(a.y)>1e-6&&(c((s-e.y)/a.y),c((l-e.y)/a.y)),d.length<2)?null:(d.sort((e,t)=>e.distance-t.distance),{start:d[0],end:d[d.length-1]})}(e.anchor,e.angle,e.bounds):{start:e.start,end:e.end};return(0,n.jsxs)("g",{...(0,k.Se)({namespace:"human2ai",id:"canvas-line",name:"CanvasLine",category:"module",origin:"project",status:"candidate"}),className:m,"data-line-type":t,role:d?"img":void 0,"aria-label":d,"aria-hidden":!d||void 0,opacity:s,children:["directed"===t?(0,n.jsx)("defs",{children:(0,n.jsx)("marker",{id:c,viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"4",markerHeight:"4",orient:"auto-start-reverse",markerUnits:"strokeWidth",children:(0,n.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"context-stroke"})})}):null,h?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("line",{className:"human2ai-canvas-line__hit",x1:h.start.x,y1:h.start.y,x2:h.end.x,y2:h.end.y,strokeWidth:l}),(0,n.jsx)("line",{className:"human2ai-canvas-line__visible",x1:h.start.x,y1:h.start.y,x2:h.end.x,y2:h.end.y,stroke:a,strokeWidth:r,strokeDasharray:o,markerEnd:"directed"===t?`url(#${c})`:void 0})]}):null]})}function eo({radius:e=6,className:t,fill:i,stroke:a,strokeWidth:r,opacity:o,"aria-label":s}){let l=["human2ai-canvas-point",t].filter(Boolean).join(" ");return(0,n.jsx)("circle",{...(0,k.Se)({namespace:"human2ai",id:"canvas-point",name:"CanvasPoint",category:"module",origin:"project",status:"candidate"}),className:l,cx:0,cy:0,r:e,fill:i,stroke:a,strokeWidth:r,opacity:o,role:s?"img":void 0,"aria-label":s,"aria-hidden":!s||void 0})}function es({tool:e,viewportBounds:t,onPlace:i,onCancel:a}){let r=(0,u.useRef)(null),o=(0,u.useRef)(null),s=(0,u.useRef)(null),l=(0,u.useRef)(null),d=(0,u.useRef)(null),c=(0,u.useRef)({onPlace:i,onCancel:a});function m(){null!==l.current&&cancelAnimationFrame(l.current),l.current=null,d.current=null,r.current?.removeAttribute("d")}function h(){s.current=null,m(),c.current.onCancel()}function p(t){var i,n,a;let l;o.current={clientX:t.clientX,clientY:t.clientY};let d=r.current.ownerSVGElement,c=d.createSVGPoint();c.x=t.clientX,c.y=t.clientY;let u=c.matrixTransform(d.getScreenCTM().inverse()),m=s.current,h=!!(m&&Math.hypot(t.clientX-m.client.x,t.clientY-m.client.y)>=3);return i=e,n=m?.start??u,a=u,l=h&&!i.clickOnly&&"point"!==i.shape,{start:{x:n.x,y:n.y},end:l?{x:a.x,y:a.y}:{x:n.x+i.width,y:n.y},dragged:l,bounds:{x:l?Math.min(n.x,a.x):n.x,y:l?Math.min(n.y,a.y):n.y,width:l?Math.max(8,Math.abs(a.x-n.x)):i.width,height:l?Math.max(8,Math.abs(a.y-n.y)):i.height}}}function g(t){d.current=t,null===l.current&&(l.current=requestAnimationFrame(()=>{l.current=null;let t=d.current;t&&r.current?.setAttribute("d",function(e,t){let{x:i,y:n,width:a,height:r}=t.bounds;return"point"===e.shape?`M ${i-8} ${n} H ${i+8} M ${i} ${n-8} V ${n+8}`:"line"===e.shape?`M ${t.start.x} ${t.start.y} L ${t.end.x} ${t.end.y}`:"ellipse"===e.shape?`M ${i} ${n+r/2} a ${a/2} ${r/2} 0 1 0 ${a} 0 a ${a/2} ${r/2} 0 1 0 ${-a} 0`:"triangle"===e.shape?`M ${i+a/2} ${n} L ${i+a} ${n+r} H ${i} Z`:`M ${i} ${n} h ${a} v ${r} h ${-a} Z`}(e,t))}))}return c.current={onPlace:i,onCancel:a},(0,u.useLayoutEffect)(()=>{function e(e){"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),h())}return r.current?.ownerSVGElement?.focus({preventScroll:!0}),window.addEventListener("keydown",e,!0),window.addEventListener("blur",h),()=>{window.removeEventListener("keydown",e,!0),window.removeEventListener("blur",h),s.current=null,m()}},[]),(0,u.useLayoutEffect)(()=>{o.current&&d.current&&g(p(o.current))},[t.x,t.y,t.width,t.height]),(0,n.jsxs)("g",{...(0,k.Se)({namespace:"human2ai",id:"canvas-placement",name:"CanvasPlacement",category:"module",origin:"project",status:"candidate"}),className:"human2ai-canvas-placement","data-canvas-placement":!0,onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onPointerDown:e=>{if(0!==e.button||s.current)return;e.preventDefault(),e.stopPropagation();let t=p(e);s.current={pointerId:e.pointerId,start:t.start,client:{x:e.clientX,y:e.clientY}},e.currentTarget.setPointerCapture(e.pointerId),g(t)},onPointerMove:e=>{e.stopPropagation(),s.current&&s.current.pointerId!==e.pointerId||(0===e.buttons||s.current)&&g(p(e))},onPointerLeave:()=>{s.current||m()},onPointerUp:e=>{if(s.current?.pointerId!==e.pointerId)return;e.preventDefault(),e.stopPropagation();let t=p(e);s.current=null,m(),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),c.current.onPlace(t)},onPointerCancel:e=>{e.stopPropagation(),s.current?.pointerId===e.pointerId&&h()},onLostPointerCapture:e=>{e.stopPropagation(),s.current?.pointerId===e.pointerId&&h()},children:[(0,n.jsx)("rect",{...t,fill:"transparent",pointerEvents:"all"}),(0,n.jsx)("path",{ref:r,className:"human2ai-canvas-placement__preview","aria-hidden":"true"})]})}function el({bounds:e,children:t,className:i,role:a="group",...r}){let o=["human2ai-canvas-scene",i].filter(Boolean).join(" ");return(0,n.jsx)("svg",{...r,...(0,k.Se)({namespace:"human2ai",id:"canvas-scene",name:"CanvasScene",category:"module",origin:"project",status:"candidate"}),className:o,viewBox:`${e.x} ${e.y} ${e.width} ${e.height}`,role:a,children:t})}i(53439),i(61176);let ed={title:"编辑节点",note:"备注",notePlaceholder:"说明这个节点表达什么",shotScale:"景别",shotScaleAuto:"自动",shotScaleForeground:"前景",shotScaleMidground:"中景",shotScaleBackground:"背景",deleteNode:"删除节点",confirmDeleteNode:"确认删除这个节点?",cancelDelete:"保留",shapeKind:"形状",pointKind:"点",lineKind:"线",textKind:"文字",imageKind:"图像",nodeDescription:"节点说明",originUser:"user",originAgent:"agent",originImport:"import"};function ec({nodeKind:e,metadata:t,onMetadataChange:i,onRequestClose:a,onDelete:r,labels:s,leadingFields:l,propertyFields:d,trailingFields:c,autoFocusField:u="note",disabled:m=!1,className:h,style:p,"aria-label":x}){var b,v;let w={...ed,...s},j=(b=e,v=w,"shape"===b?v.shapeKind:"point"===b?v.pointKind:"line"===b?v.lineKind:"text"===b?v.textKind:v.imageKind),I=[{value:"auto",label:w.shotScaleAuto},{value:"foreground",label:w.shotScaleForeground},{value:"midground",label:w.shotScaleMidground},{value:"background",label:w.shotScaleBackground}];return(0,n.jsx)(y,{open:!0,title:`${w.title} \xb7 ${j}`,selectedText:j,selectedTextLabel:w.title,saveLabel:"",cancelLabel:"",onCancel:a,onSave:()=>void 0,deleteAction:r&&!m?{label:w.deleteNode,confirmTitle:w.confirmDeleteNode,confirmCancelLabel:w.cancelDelete,onConfirm:r}:void 0,children:(0,n.jsxs)("div",{...(0,k.Se)({namespace:"human2ai",id:"canvas-node-editor",name:"Human2AiCanvasNodeEditor",category:"module",origin:"project",status:"candidate"}),className:["human2ai-canvas-node-editor",h].filter(Boolean).join(" "),style:p,"aria-label":x,"aria-disabled":m||void 0,"data-human2ai-auto-save-node-editor":!0,"data-node-kind":e,"data-empty":t.note||"auto"!==t.shotScale?"false":"true",children:[(0,n.jsxs)("div",{className:"human2ai-canvas-node-editor__primary-fields",children:[(0,n.jsx)("span",{className:"human2ai-canvas-node-editor__origin",children:"agent"===t.origin?w.originAgent:"import"===t.origin?w.originImport:w.originUser}),"user"!==t.origin&&t.annotation.trim()?(0,n.jsx)(f,{label:w.nodeDescription,children:(0,n.jsx)("p",{className:"human2ai-canvas-node-editor__description",children:t.annotation})}):null,l,(0,n.jsx)(f,{label:w.note,children:(0,n.jsx)(g,{name:"nodeNote",autoFocus:"note"===u,value:t.note,placeholder:w.notePlaceholder,"aria-label":w.note,disabled:m,onChange:e=>i({note:e.target.value})})}),(0,n.jsxs)("div",{className:"human2ai-canvas-node-editor__properties",children:[(0,n.jsx)(f,{label:w.shotScale,children:(0,n.jsx)(o.A,{className:"human2ai-canvas-node-editor__property-select human2ai-canvas-node-editor__shot-scale-select",value:t.shotScale,options:I,"aria-label":w.shotScale,disabled:m,onChange:e=>i({shotScale:e})})}),d]})]}),c?(0,n.jsx)("aside",{className:"human2ai-canvas-node-editor__side-fields",children:c}):null]})})}var eu=i(66234),em=i(84092),eh=i(19330),ep=i(50018),eg=i(94423),ef=i(96313);i(88307);var ey=i(50052);function ex({tools:e,children:t,collapsed:i,defaultCollapsed:a=!1,onCollapsedChange:r,collapseLabel:o="收起侧边面板",expandLabel:s="展开侧边面板",width:l=220,"aria-label":d="侧边操作面板",className:h,style:p}){let g=(0,u.useId)(),[f,y]=(0,u.useState)(a),x=void 0!==i,b=i??f,v=b?s:o;return(0,n.jsxs)("aside",{...(0,m.S)("side-action-panel","SideActionPanel","panel-pattern"),className:["yisi-side-action-panel",b?"yisi-side-action-panel--collapsed":null,h].filter(Boolean).join(" "),"data-collapsed":b?"true":"false","aria-label":d,style:{...p,width:b?48:l},children:[(0,n.jsxs)("div",{className:"yisi-side-action-panel-header",children:[e?(0,n.jsx)("div",{className:"yisi-side-action-panel-tools",role:"group","aria-label":"面板工具",children:e}):null,(0,n.jsx)(c.Ay,{className:"yisi-side-action-panel-toggle",type:"text",icon:b?(0,n.jsx)(eg.A,{}):(0,n.jsx)(ef.A,{}),"aria-label":v,title:v,"aria-expanded":!b,"aria-controls":g,onClick:function(){let e=!b;x||y(e),r?.(e)}})]}),(0,n.jsx)(ey.I,{collapsed:b,children:(0,n.jsx)("div",{id:g,className:"yisi-side-action-panel-actions",children:t})})]})}i(49404);let eb={width:1,height:1},ev={x:0,y:0},ew={zoomOut:"缩小画布",zoomIn:"放大画布",currentZoom:"当前缩放",fitAll:"适应全部",help:"画布操作说明",interactionHelp:"滚轮缩放;按住右键拖动画布;按住空格键并使用左键拖动画布。",sideActions:"画布操作",collapseSideActions:"收起画布操作",expandSideActions:"展开画布操作"};function ej({children:e,onContextMenuRequest:t,cameraCenter:i,defaultCameraCenter:a=ev,zoom:r,defaultZoom:o=1,minimumZoom:s=.25,maximumZoom:l=4,fitRequest:d,contentBounds:c,backgroundPattern:m="dots",showViewportControls:h=!0,sideActions:p,sideActionPlacement:g="right",sideActionPanelWidth:f,sideActionPanelDefaultCollapsed:y=!1,labels:x,onCameraCenterChange:b,onZoomChange:v,className:w,style:j,"aria-label":I="无限画布"}){let S=(0,u.useRef)(null),P=`human2ai-infinite-canvas-${(0,u.useId)().replaceAll(":","")}`,[M,A]=(0,u.useState)(eb),[L,N]=(0,u.useState)(a),[$,F]=(0,u.useState)(o),[_,T]=(0,u.useState)(!1),[R,E]=(0,u.useState)(!1),q=(0,u.useRef)(!1),D=(0,u.useRef)(!1),z=(0,u.useRef)(null),B=(0,u.useRef)(!1),O=(0,u.useRef)(null),U={...ew,...x},J=Math.min(s,l),W=Math.max(s,l),H=i??L,Y=eI(r??$,J,W),V={width:M.width/Y,height:M.height/Y},G={x:H.x-V.width/2,y:H.y-V.height/2,width:V.width,height:V.height},K=["human2ai-infinite-canvas-viewport",_?"human2ai-infinite-canvas-viewport--pan-ready":null,R?"human2ai-infinite-canvas-viewport--panning":null,w].filter(Boolean).join(" "),Z=en({x:0,y:0});function Q(e){void 0===i&&N(e),b?.(e)}function ee(e){let t=eI(e,J,W);void 0===r&&F(t),v?.(t)}function et(e,t=48){let i=Math.max(0,t),n=Math.max(1,M.width-2*i),a=Math.max(1,M.height-2*i),r=eI(Math.min(n/Math.max(1,e.width),a/Math.max(1,e.height)),J,W);Q({x:e.x+e.width/2,y:e.y+e.height/2}),ee(r)}function ei(e){return{x:G.x+e.x/Y,y:G.y+e.y/Y}}function en(e){return{x:(e.x-G.x)*Y,y:(e.y-G.y)*Y}}function ea(e){let i=z.current;i&&i.pointerId===e.pointerId&&(z.current=null,E(!1),e.preventDefault(),e.stopPropagation(),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),"pointerup"===e.type&&i.rightButton&&!i.moved&&t?.({clientX:e.clientX,clientY:e.clientY,target:i.contextTarget}),window.setTimeout(()=>{B.current=!1},0))}return(0,u.useEffect)(()=>{let e=S.current;if(!e)return;let t=()=>{let t=Math.max(1,e.clientWidth),i=Math.max(1,e.clientHeight);A(e=>e.width===t&&e.height===i?e:{width:t,height:i})};if(t(),"u"<typeof ResizeObserver)return;let i=new ResizeObserver(t);return i.observe(e),()=>i.disconnect()},[]),(0,u.useEffect)(()=>{let e=S.current;if(!e)return;let t=t=>{t.preventDefault();let i=eI(Y*Math.exp(-(.0015*t.deltaY)),J,W);if(i===Y)return;let n=e.getBoundingClientRect(),a={x:t.clientX-n.left,y:t.clientY-n.top},r=ei(a);Q({x:r.x+(n.width/2-a.x)/i,y:r.y+(n.height/2-a.y)/i}),ee(i)};return e.addEventListener("wheel",t,{passive:!1}),()=>e.removeEventListener("wheel",t)}),(0,u.useEffect)(()=>{!d||O.current===d.id||M.width<=1||M.height<=1||(O.current=d.id,et(d.bounds,d.padding))},[d,W,J,M.height,M.width]),(0,u.useEffect)(()=>{let e=e=>{var t;"Space"!==e.code||!q.current||(t=e.target)instanceof HTMLElement&&(t.matches("input, textarea, select, button, a[href]")||t.isContentEditable)||(e.preventDefault(),D.current=!0,T(!0))},t=()=>{D.current=!1,T(!1)},i=e=>{"Space"===e.code&&t()};return window.addEventListener("keydown",e),window.addEventListener("keyup",i),window.addEventListener("blur",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",i),window.removeEventListener("blur",t)}},[]),(0,n.jsxs)("div",{ref:S,...(0,k.Se)({namespace:"human2ai",id:"infinite-canvas-viewport",name:"InfiniteCanvasViewport",category:"module",origin:"project",status:"candidate"}),className:K,style:j,role:"region","aria-label":I,"data-camera-center-x":H.x,"data-camera-center-y":H.y,"data-camera-zoom":Y,"data-background-pattern":m,onPointerEnter:()=>{q.current=!0},onPointerLeave:()=>{q.current=!1},onPointerDownCapture:function(e){var t;if(!((t=e.target)instanceof Element&&t.closest("[data-infinite-canvas-ui]"))&&(2===e.button||0===e.button&&D.current)){z.current={pointerId:e.pointerId,sourceCameraCenter:H,startClient:{x:e.clientX,y:e.clientY},contextTarget:e.target,rightButton:2===e.button,moved:!1},B.current=!0,E(!0),e.preventDefault(),e.stopPropagation();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}}},onPointerMoveCapture:function(e){let i=z.current;!i||i.pointerId!==e.pointerId||(Math.hypot(e.clientX-i.startClient.x,e.clientY-i.startClient.y)>3&&(i.moved=!0),e.preventDefault(),e.stopPropagation(),B.current=!0,t&&i.rightButton&&!i.moved||Q({x:i.sourceCameraCenter.x-(e.clientX-i.startClient.x)/Y,y:i.sourceCameraCenter.y-(e.clientY-i.startClient.y)/Y}))},onPointerUpCapture:ea,onPointerCancelCapture:ea,onLostPointerCapture:()=>{z.current=null,E(!1)},onClickCapture:e=>{B.current&&(e.preventDefault(),e.stopPropagation(),B.current=!1)},onContextMenu:e=>e.preventDefault(),children:[(0,n.jsx)(ek,{pattern:m,patternId:P,screenOrigin:Z,zoom:Y}),(0,n.jsx)("div",{className:"human2ai-infinite-canvas-viewport__world-content",children:e({cameraCenter:H,zoom:Y,viewportSize:M,viewportBounds:G,screenToWorld:ei,worldToScreen:en})}),p?(0,n.jsx)("div",{className:`human2ai-infinite-canvas-viewport__side-actions human2ai-infinite-canvas-viewport__side-actions--${g}`,"data-infinite-canvas-ui":"true","data-side-action-placement":g,children:(0,n.jsx)(ex,{width:f,defaultCollapsed:y,"aria-label":U.sideActions,collapseLabel:U.collapseSideActions,expandLabel:U.expandSideActions,children:p})}):null,h?(0,n.jsxs)("div",{className:"human2ai-infinite-canvas-viewport__controls","data-infinite-canvas-ui":"true",role:"group","aria-label":U.currentZoom,children:[(0,n.jsx)(X.J,{mode:"icon-only",size:"small",backgroundColor:"none",icon:(0,n.jsx)(eu.A,{"aria-hidden":"true"}),iconLabel:U.zoomOut,title:U.zoomOut,disabled:Y<=J,onClick:()=>ee(Y/1.2)}),(0,n.jsxs)("output",{className:"human2ai-infinite-canvas-viewport__zoom","aria-label":`${U.currentZoom} ${Math.round(100*Y)}%`,"aria-live":"polite",children:[Math.round(100*Y),"%"]}),(0,n.jsx)(X.J,{mode:"icon-only",size:"small",backgroundColor:"none",icon:(0,n.jsx)(em.A,{"aria-hidden":"true"}),iconLabel:U.zoomIn,title:U.zoomIn,disabled:Y>=W,onClick:()=>ee(1.2*Y)}),(0,n.jsx)(X.J,{mode:"icon-only",size:"small",backgroundColor:"none",icon:(0,n.jsx)(eh.A,{"aria-hidden":"true"}),iconLabel:U.fitAll,title:U.fitAll,disabled:!c,onClick:()=>{c&&et(c)}}),(0,n.jsx)(C.A,{title:U.interactionHelp,placement:"topRight",children:(0,n.jsx)(X.J,{mode:"icon-only",size:"small",backgroundColor:"none",icon:(0,n.jsx)(ep.A,{"aria-hidden":"true"}),iconLabel:U.help})})]}):null]})}function ek({pattern:e,patternId:t,screenOrigin:i,zoom:a}){if("none"===e)return null;let r=32*a,o="dots"===e,s=o?i.x-r/2:i.x,l=o?i.y-r/2:i.y;return(0,n.jsxs)("svg",{className:"human2ai-infinite-canvas-viewport__background","data-canvas-background":e,"aria-hidden":"true",children:[(0,n.jsx)("defs",{children:(0,n.jsx)("pattern",{id:t,x:s,y:l,width:r,height:r,patternUnits:"userSpaceOnUse",children:o?(0,n.jsx)("circle",{className:"human2ai-infinite-canvas-viewport__background-dot",cx:r/2,cy:r/2,r:"1.5"}):(0,n.jsx)("path",{className:"human2ai-infinite-canvas-viewport__background-line",d:`M 0 0 H ${r} M 0 0 V ${r}`,strokeDasharray:"dashed-grid"===e?"4 4":void 0})})}),(0,n.jsx)("rect",{width:"100%",height:"100%",fill:`url(#${t})`})]})}function eI(e,t,i){return Math.min(i,Math.max(t,e))}i(98852);var eS=i(48511);function eP({draft:e,selectedIds:t=[],onSelect:i,locked:a=!1,onDraftChange:r,screenScale:o,labels:s}){let l=(0,u.useId)(),d=(0,j.i)(e.frame),c=(0,u.useRef)(null),m=(0,u.useRef)(null),h=!!(i&&r&&!a),p=e=>{let t=e.currentTarget.ownerSVGElement.getScreenCTM(),i=new DOMPoint(e.clientX,e.clientY).matrixTransform(t.inverse());return{x:i.x,y:i.y}};function g(t,i,n){return(0,j.gH)(t,e.frame,i,n)}function f(e,n){let a=n?t.includes(e)?t.filter(t=>t!==e):[...t,e]:t.includes(e)?[...t]:[e];return i?.(a),a}function y(e,t){if("click"===t.type&&m.current===e){m.current=null;return}"key"in t&&"Enter"!==t.key&&" "!==t.key||f(e,t.shiftKey||t.ctrlKey||t.metaKey)}function x(n){r?.((0,j.q3)(e,n)),i?.(t.filter(e=>e!==n))}function b(t,i,n){if(!h||0!==t.button)return;t.preventDefault(),t.stopPropagation(),t.currentTarget.focus(),m.current=i.id;let a=void 0===n?f(i.id,t.shiftKey||t.ctrlKey||t.metaKey):[i.id];a.includes(i.id)&&(1!==a.length||"symmetry"!==i.type||1===n)&&(c.current={pointerId:t.pointerId,plan:i,draft:e,ids:a,start:p(t),handle:n,moved:!1},t.currentTarget.setPointerCapture(t.pointerId))}function v(e){let t=c.current;h&&t&&t.pointerId===e.pointerId&&(c.current=null,e.stopPropagation(),"pointerup"!==e.type||t.moved||0!==t.handle||"golden-spiral"!==t.plan.type||r?.((0,j.sJ)(t.draft,{...t.plan,mirrored:!t.plan.mirrored})),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))}let w={onPointerMove:function(e){let t=c.current;if(!h||!t||t.pointerId!==e.pointerId)return;e.preventDefault(),e.stopPropagation();let i=p(e),n={x:i.x-t.start.x,y:i.y-t.start.y};!t.moved&&"golden-spiral"===t.plan.type&&0===t.handle&&Math.hypot(n.x,n.y)*o<4||(t.moved=!0,r?.(void 0===t.handle?(0,j.u7)(t.draft,t.ids,n):(0,j.sJ)(t.draft,g(t.plan,n,t.handle))))},onPointerUp:v,onPointerCancel:v,onLostPointerCapture:()=>{c.current=null}};return(0,n.jsxs)("g",{className:"human2ai-composition-plans",children:[(0,n.jsx)("defs",{children:(0,n.jsx)("clipPath",{id:l,children:(0,n.jsx)("rect",{x:d.x,y:d.y,width:d.width,height:d.height})})}),(e.plans??[]).filter(e=>e.visible).map(i=>{let{paths:d,handles:c,snapPoints:u}=(0,j.SZ)(i,e.frame),m=!a&&t.includes(i.id),p=h&&"thirds"!==i.type&&"golden-section"!==i.type;return(0,n.jsxs)("g",{children:[(0,n.jsx)(A,{id:i.id,label:s.types[i.type],selected:m,locked:!p,className:"human2ai-composition-plan","data-composition-plan":i.id,"data-plan-type":i.type,onSelect:p?y:void 0,onNudge:p?n=>r?.((0,j.u7)(e,m?t:[i.id],n)):void 0,onDelete:p?()=>x(i.id):void 0,onPointerDown:p?e=>b(e,i):void 0,...w,children:(0,n.jsx)("g",{clipPath:`url(#${l})`,children:d.map((e,t)=>(0,n.jsxs)("g",{children:[(0,n.jsx)("polyline",{className:"human2ai-composition-plan__line",points:e.map(e=>`${e.x},${e.y}`).join(" ")}),p?(0,n.jsx)("polyline",{className:"human2ai-composition-plan__hit",points:e.map(e=>`${e.x},${e.y}`).join(" ")}):null]},t))})}),m&&1===t.length&&p&&u?(0,n.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:u.map((e,t)=>(0,n.jsx)("circle",{className:"human2ai-composition-plan__snap",cx:e.x,cy:e.y,r:3/o},t))}):null,m&&1===t.length&&p?c.map((t,a)=>"symmetry"===i.type&&0===a?(0,n.jsx)("circle",{className:"human2ai-composition-plan__fixed",cx:t.x,cy:t.y,r:5/o,"aria-hidden":"true",pointerEvents:"none"},a):(0,n.jsxs)("g",{"data-plan-handle":a,transform:`translate(${t.x} ${t.y})`,tabIndex:0,role:"button","data-plan-action":"golden-spiral"===i.type&&0===a?"toggle-winding":void 0,"aria-label":"golden-spiral"===i.type&&0===a?s.spiralDirection:"radial"===i.type&&"free"===i.mode&&a>0?s.rayHandle.replace("{{index}}",String(a)):s.handle.replace("{{index}}",String(a+1)),"aria-pressed":"golden-spiral"===i.type&&0===a?i.mirrored:void 0,onPointerDown:e=>b(e,i,a),...w,onClick:e=>{e.stopPropagation(),e.currentTarget.focus()},onKeyDown:t=>{if("golden-spiral"===i.type&&0===a&&("Enter"===t.key||" "===t.key)){t.preventDefault(),t.stopPropagation(),t.repeat||r?.((0,j.sJ)(e,{...i,mirrored:!i.mirrored}));return}if("Delete"===t.key||"Backspace"===t.key){t.preventDefault(),t.stopPropagation(),x(i.id);return}let n=t.shiftKey?10:1,o={ArrowLeft:{x:-n,y:0},ArrowRight:{x:n,y:0},ArrowUp:{x:0,y:-n},ArrowDown:{x:0,y:n}};if(!o[t.key])return;t.preventDefault(),t.stopPropagation();let s=g(i,o[t.key],a);if("symmetry"===i.type){let n=(0,j.Y8)(e.frame),a=n.findIndex(e=>1e-8>Math.abs(e-i.rotation)),r="ArrowRight"===t.key||"ArrowDown"===t.key?1:-1;s={...i,rotation:n[(a+r+n.length)%n.length]}}r?.((0,j.sJ)(e,s))},children:["golden-spiral"===i.type&&0===a?(0,n.jsx)("title",{children:s.spiralDirection}):null,(0,n.jsx)("circle",{className:"human2ai-composition-plan__handle",r:5/o}),(0,n.jsx)("circle",{className:"human2ai-composition-plan__handle-hit",r:12/o})]},a)):null]},i.id)})]})}i(98151);let eC={circle:"圆形",triangle:"三角形",quadrilateral:"矩形"},eM={cornerLabel:"文字轮廓角点 {{index}}",lightSource:"作为光源",displayText:"显示文字",displayTextPlaceholder:"填写要显示的文字;留空由生图模型决定",visualWeight:"视觉权重",weightAuto:"自动",weightHigh:"高",weightMedium:"中",weightLow:"低",weightDecorative:"装饰"},eA={content:"图片内容",upload:"上传图片",download:"下载图片",downloading:"正在下载",downloadFailed:"图片下载失败,请重试。",replace:"替换图片",uploading:"正在上传",uploadFailed:"上传失败,请重试",fileTypes:"支持 PNG、JPEG、WebP、SVG,最大 10 MB",cropTitle:"裁剪图片",cropLoadFailed:"图片加载失败",svgSource:"SVG 源码",svgPaste:"粘贴 SVG",svgApply:"使用 SVG",svgSaveFailed:"SVG 保存失败,请检查代码后重试。",svgCopy:"复制源码",svgCopying:"正在复制源码",svgCopyFailed:"源码复制失败",sourceLoading:"正在读取图片内容",sourceLoadFailed:"图片内容读取失败,请重试。",svgCopied:"已复制",cancel:"取消",retry:"重试"},eL="composition-frame";function eN({selectedPlanIds:e,planningLocked:t=!1,onPlanSelectionChange:i,planningLabels:s=eS.composition.planning,interactionResetKey:l,draft:d,appearance:c="editor",showPlanning:m=!0,frameLocked:h=!1,zoom:p,viewportAction:y,backgroundPattern:I,showViewportControls:S,sideActions:P,sideActionPlacement:C,sideActionPanelWidth:M,sideActionPanelDefaultCollapsed:L,viewportLabels:N,layerLabels:$,nodeEditorLabels:F,directionControlLabels:_=["动势线操作点 1","动势线操作点 2"],areaEditorLabels:E,imageEditorLabels:D,resolveImageSource:z,renderCameraReference:B,onImageUpload:U,onReadImageFile:J,selectedIds:W=[],onDraftChange:H,placementTool:Y=null,onPlacementToolChange:V,onSelectionChange:X,onItemDoubleClick:G,onZoomChange:K,className:Z,style:Q,"aria-label":et="构图画布"}){let ei=["human2ai-composition-canvas",`human2ai-composition-canvas--${c}`,h?"human2ai-composition-canvas--frame-locked":null,Z].filter(Boolean).join(" "),en=(0,u.useRef)(null),{contextMenuOpen:ea,contextMenuPoint:er,contextMenuPopupRef:ed,openContextMenuAt:eu,closeContextMenu:em,dismissContextMenu:eh}=b(),ep={...x,...$},[eg,ef]=(0,u.useState)(null),ey=(0,u.useRef)(null),ex=(0,u.useRef)(!1),eb=(0,u.useRef)(!1),ev=(0,u.useRef)(null),ew=(0,u.useRef)([]),ek=(0,u.useRef)(""),eI=(0,u.useRef)(0),[eG,eZ]=(0,u.useState)(!1),[eQ,e0]=(0,u.useState)(!1),[e1,e2]=(0,u.useState)(!1),[e3,e5]=(0,u.useState)(160),[e4,e8]=(0,u.useState)(null),[e6,e9]=(0,u.useState)(null),e7=(0,j.i)(d.frame),te="reference"===c?{...Q,"--human2ai-composition-reference-aspect":e7.width/e7.height}:Q,tt=(0,j.MR)(d),ti="reference"!==c&&!!H&&!h,tn="reference"!==c&&W.includes(eL),ta="reference"===c||tn?[]:[...new Set(W)].filter(e=>!!eW(d,e)),tr=new Set(ta),to=ta.length>1?function(e,t){let i=t.map(t=>eO(e,t)).filter(e=>!!e);if(0===i.length)return null;let n=Math.min(...i.map(e=>e.x)),a=Math.min(...i.map(e=>e.y));return{x:n,y:a,width:Math.max(1,Math.max(...i.map(e=>e.x+e.width))-n),height:Math.max(1,Math.max(...i.map(e=>e.y+e.height))-a)}}(d,ta):null,ts=ta.some(e=>d.images.some(t=>t.id===e)),tl=y?{id:y.id,bounds:"fit-frame"===y.type?e7:tt,padding:48}:void 0,td=e6?eW(d,e6.id):null,tc=e6?d.areas.find(({id:e})=>e===e6.id)??null:null,tu=e6?d.images.find(({id:e})=>e===e6.id)??null:null,tm={...eM,...E},th=(0,u.useId)().replace(/:/g,""),tp={...eA,...D},tg=(0,u.useRef)({draft:d,onDraftChange:H,interactionResetKey:l});(0,u.useLayoutEffect)(()=>{tg.current={draft:d,onDraftChange:H,interactionResetKey:l}});let tf=O({disabled:"reference"===c||!H||!!e6,resetKey:l,labels:tp,onUpload:U,onCopy:function(e){0!==ta.length&&e.clipboardData&&(ew.current=(0,j.s6)(d,ta),ek.current=crypto.randomUUID(),eI.current=0,e.clipboardData.setData("application/x-human2ai-composition",ek.current),e.preventDefault(),e.stopPropagation())},onPasteFallback:function(e){if(e.defaultPrevented||!H||0===ew.current.length||e.clipboardData?.getData("application/x-human2ai-composition")!==ek.current)return;e.preventDefault(),e.stopPropagation();let t=eI.current+1,i=(0,j.CP)(d,ew.current,{x:24*t/j.cq.width,y:24*t/j.cq.height});0!==i.ids.length&&(eI.current=t,tS(),H(i.draft),X?.(i.ids))},onImageReady:({assetId:e,x:t,y:i,width:n,height:a})=>{let r=(0,j.xB)(d,{x:t/j.cq.width,y:i/j.cq.height,width:n/j.cq.width,height:a/j.cq.height});H?.((0,j.QY)(r.draft,r.id,{assetId:e})),X?.([r.id]),V?.(null)}}),ty=[{value:"auto",label:tm.weightAuto},{value:"high",label:tm.weightHigh},{value:"medium",label:tm.weightMedium},{value:"low",label:tm.weightLow},{value:"decorative",label:tm.weightDecorative}],tx="reference"!==c&&!!H&&("focus"!==Y||d.focusPoints.length<3)&&("direction"!==Y||!d.directionLine);function tb(e,t=""){return{annotation:e.annotation,displayText:t,note:e.note,labels:{nodeDescription:F?.nodeDescription??"节点说明",displayText:tm.displayText,note:F?.note??"备注"}}}function tv(e){let t;if(!Y||!H||!tx)return;let{bounds:i,start:n,end:a,dragged:r}=e,o={x:(i.x+i.width/2)/j.cq.width,y:(i.y+i.height*("triangle"===Y?2/3:.5))/j.cq.height};"focus"===Y?t=(0,j.eq)(d,{x:n.x/j.cq.width,y:n.y/j.cq.height}):"direction"===Y?(t=(0,j.JZ)(d),e5(r?Math.hypot(a.x-n.x,a.y-n.y):160),t.draft=(0,j.hG)((0,j.Pe)(t.draft,t.id,r?o:{x:n.x/j.cq.width,y:n.y/j.cq.height}),t.id,180*Math.atan2(a.y-n.y,a.x-n.x)/Math.PI)):"image"===Y?t=(0,j.xB)(d,{...o,width:i.width/j.cq.width,height:i.height/j.cq.height}):(t="text"===Y?(0,j.hN)(d,o):(0,j.Xn)(d,{...o,primitive:Y,aspect:"quadrilateral"===Y?"free":"square"}),r&&(t.draft=(0,j.IU)(t.draft,t.id,i.width/j.cq.width,i.height/j.cq.height))),H(t.draft),X?.([t.id]),V?.(null),ex.current=!0,window.setTimeout(()=>{ex.current=!1},0)}function tw(e,t){if(eb.current){eb.current=!1;return}X?.(t.shiftKey?eq(ta,[e]):[e])}function tj(e,t){H&&H(eD(d,ta.length>1&&tr.has(e)?ta:[e],t))}function tk(e){if(!H||!eW(d,e))return;let t=ta.length>1&&tr.has(e)?ta:[e];H(ez(d,t)),X?.([]),e6&&t.includes(e6.id)&&tS()}function tI(e,t){e9({id:e,kind:t}),X?.([e]),G?.(e)}function tS(){e9(null)}function tP(e){if(!(e.target instanceof Element)||(ex.current=!1,eb.current=!1,0!==e.button))return;let t=eV(e,e.currentTarget),i=e.target.closest("[data-handle]");if(i){if(!H)return;let n=i.dataset.itemId,a=i.dataset.handle;if(!n||!a)return;let r=d.directionLine?.id===n?d.directionLine:null;if("move-text-corner"===a&&e.ctrlKey){let r=d.areas.find(e=>e.id===n);if(!r||!(0,j.MY)(r))return;let o=(0,j.QR)(r,j.cq),s=Number(i.dataset.cornerIndex);if("polygon"!==o.type||!o.points[s])return;ey.current={type:a,pointerId:e.pointerId,sourceDraft:d,id:n,cornerIndex:s,start:t,startClient:{x:e.clientX,y:e.clientY},movingPoint:o.points[s],moved:!1},i.focus()}else{if(!r||"move-direction-point"!==a)return;let n=Number(i.dataset.pointIndex),o=eE(r,e3);ey.current={type:a,pointerId:e.pointerId,sourceDraft:d,pointIndex:n,fixedPoint:o[1-n],movingPoint:o[n],start:t},i.focus()}}else{let i=e.target.closest("[data-composition-item]"),n=i?.dataset.compositionItem,a=n?eW(d,n):null;if(n&&a){if(!H)return;let i=tr.has(n)?ta:[n];ey.current={type:"move-items",pointerId:e.pointerId,ids:i,sourceDraft:d,start:t,startClient:{x:e.clientX,y:e.clientY},moved:!1}}else{if(!X)return;ey.current={type:"marquee",pointerId:e.pointerId,sourceSelectedIds:ta,start:t,startClient:{x:e.clientX,y:e.clientY},moved:!1,additive:e.shiftKey}}}let n=ey.current;n&&("move-direction-point"===n.type||"move-text-corner"===n.type)&&(ex.current=!0,e.preventDefault(),eX(e.currentTarget,e.pointerId))}function tC(e){let t=ey.current;if(!t||t.pointerId!==e.pointerId)return;let i=eV(e,e.currentTarget);if("move-items"===t.type){if(!t.moved&&3>Math.hypot(e.clientX-t.startClient.x,e.clientY-t.startClient.y)||(t.moved||(t.moved=!0,eZ(!0),eX(e.currentTarget,e.pointerId)),ex.current=!0,eb.current=!0,e.preventDefault(),!H))return;H(eD(t.sourceDraft,t.ids,{x:(i.x-t.start.x)/j.cq.width,y:(i.y-t.start.y)/j.cq.height}));return}if("marquee"===t.type){if(!t.moved&&3>Math.hypot(e.clientX-t.startClient.x,e.clientY-t.startClient.y))return;t.moved||(t.moved=!0,eX(e.currentTarget,e.pointerId)),e.preventDefault(),ex.current=!0,e8(eB(t.start,i));return}if(e.preventDefault(),ex.current=!0,H){if("move-text-corner"===t.type){if(!t.moved&&3>Math.hypot(e.clientX-t.startClient.x,e.clientY-t.startClient.y))return;t.moved=!0;let n=(0,j.Wn)(t.sourceDraft,t.id,t.cornerIndex,{x:(t.movingPoint.x+i.x-t.start.x)/j.cq.width,y:(t.movingPoint.y+i.y-t.start.y)/j.cq.height});n!==t.sourceDraft&&H(n);return}tM(t.sourceDraft,t.pointIndex,{x:t.movingPoint.x+i.x-t.start.x,y:t.movingPoint.y+i.y-t.start.y},t.fixedPoint)}}function tM(e,t,i,n){let a=e.directionLine;if(!a||!H)return;let[r,o]=0===t?[i,n]:[n,i],s=o.x-r.x,l=o.y-r.y,d=Math.hypot(s,l);e5(d),H((0,j.hG)((0,j.Pe)(e,a.id,{x:(r.x+o.x)/2/j.cq.width,y:(r.y+o.y)/2/j.cq.height}),a.id,d<.001?a.rotation:180*Math.atan2(l,s)/Math.PI))}function tA(e,t){if(!d.directionLine)return;let i=eE(d.directionLine,e3);tM(d,e,{x:i[e].x+t.x,y:i[e].y+t.y},i[1-e])}function tL(e){let t=ey.current;if(t&&t.pointerId===e.pointerId){if("move-text-corner"===t.type&&tC(e),"marquee"===t.type){let i=t.moved?function(e,t){var i,n;let a,r,o,s;if(t.width<2&&t.height<2)return[];let l=e.areas.filter(e=>eJ(eU(e),t)).map(e=>e.id),d=e.images.filter(e=>eJ(eH(e),t)).map(e=>e.id),c=e.focusPoints.filter(i=>{let n=eO(e,i.id);return!!n&&eJ(n,t)}).map(e=>e.id);return[...d,...l,...e.directionLine&&(i=e.directionLine,n=t,a=eY(i),o={x:-Math.sin(r=i.rotation*Math.PI/180),y:Math.cos(r)},0>=Math.min(...s=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x,y:n.y+n.height},{x:n.x+n.width,y:n.y+n.height}].map(e=>(e.x-a.x)*o.x+(e.y-a.y)*o.y))&&Math.max(...s)>=0)?[e.directionLine.id]:[],...c]}(d,eB(t.start,eV(e,e.currentTarget))):[];X?.(0===i.length?[]:t.additive?eq(t.sourceSelectedIds,i):i),e8(null)}ey.current=null,eZ(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),window.setTimeout(()=>{ex.current=!1,eb.current=!1},0)}}function tN(e){ey.current?.pointerId===e.pointerId&&(ey.current=null,eZ(!1),e8(null),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))}function t$(e){var t,i,n,a,r,o,s,l;if(!H||ta.length<2)return;let c={x:e.sourcePosition.x+e.sourceBounds.x,y:e.sourcePosition.y+e.sourceBounds.y,width:e.sourceBounds.width,height:e.sourceBounds.height},u=JSON.stringify([ta,(t=c).x,t.y,t.width,t.height]);ev.current?.signature!==u&&(ev.current={signature:u,draft:d,ids:[...ta],bounds:c});let m=ev.current,h={x:e.sourcePosition.x+e.bounds.x,y:e.sourcePosition.y+e.bounds.y,width:e.bounds.width,height:e.bounds.height};H((i=m.draft,n=m.ids,a=m.bounds,r=h,o=e.scaleX,s=e.scaleY,l=e.proportional,n.reduce((e,t)=>{let n=eW(i,t);if(!n)return e;let d=eY(n),c={x:r.x+(d.x-a.x)*o,y:r.y+(d.y-a.y)*s},u=(0,j.Pe)(e,t,{x:c.x/j.cq.width,y:c.y/j.cq.height}),m=i.areas.find(e=>e.id===t);if(m){let e=(0,j.QR)(m,j.cq),i=e_(m,e);u=l?(0,j.oF)(u,t,m.area*o*s):(0,j.IU)(u,t,i.width*o/j.cq.width,i.height*s/j.cq.height)}let h=i.images.find(e=>e.id===t);h&&(u=(0,j.CV)(u,t,h.width*o,h.height*s));let p=i.directionLine?.id===t?i.directionLine:null;if(p&&o!==s){let e=p.rotation*Math.PI/180;u=(0,j.hG)(u,t,180*Math.atan2(Math.sin(e)*s,Math.cos(e)*o)/Math.PI)}return u},i)))}function tF(e){H&&H((0,j.co)(d,{x:e.sourcePosition.x+e.bounds.x,y:e.sourcePosition.y+e.bounds.y,width:e.bounds.width,height:e.bounds.height}))}function t_(e){H&&H((0,j.Dr)(d,{x:e.bounds.x/j.cq.width,y:e.bounds.y/j.cq.height}))}function tT(e){!H||["+","=","-","_"].includes(e.key)&&(e.preventDefault(),X?.([eL]),H((0,j.Kd)(d,"+"===e.key||"="===e.key?1.05:.95)))}function tR(e){if("reference"===c||!(e.target instanceof Element))return;let t=e.target.closest("[data-composition-item]"),i=t?.dataset.compositionItem;i&&!tr.has(i)?X?.([i]):e.target.closest("[data-canvas-frame]")&&X?.([eL]),eu(e,t??en.current?.querySelector("[data-composition-scene]")??null)}function tE(e){if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault(),e.stopPropagation();let t=e.target instanceof Element?e.target:e.currentTarget,i=t.getBoundingClientRect();tR({clientX:i.x+i.width/2,clientY:i.y+i.height/2,target:t});return}}function tq(a){let r=a?.viewportBounds??e7,o="reference"===c?e7:r,u=a?.zoom??1,p=to?{x:to.x+to.width/2,y:to.y+to.height/2}:null;return(0,n.jsxs)(el,{ref:tf.sceneRef,"data-composition-scene":!0,bounds:o,className:"human2ai-composition-canvas__svg","data-camera-center-x":a?.cameraCenter.x,"data-camera-center-y":a?.cameraCenter.y,"data-camera-zoom":a?.zoom,"data-frame-crop":"reference"===c?"true":void 0,"data-frame-locked":h?"true":void 0,"data-canvas-dragging":eG?"node":void 0,role:"group","aria-label":et,"aria-keyshortcuts":"reference"!==c?"Control+C Meta+C Control+V Meta+V":void 0,tabIndex:"reference"!==c?-1:void 0,onKeyDown:"reference"!==c?tE:void 0,onPointerDownCapture:"reference"!==c?e=>e.currentTarget.focus():void 0,onClickCapture:e=>{ex.current&&(e.stopPropagation(),ex.current=!1)},onClick:"reference"!==c&&X?e=>{if(ex.current){ex.current=!1;return}e.target instanceof Element&&(e.target.closest("[data-composition-item]")||e.target.closest("[data-handle]")||e.target.closest("[data-resize-handle]")||e.target.closest("[data-rotation-handle]"))||(X([]),i?.([]),tS())}:void 0,onPointerDown:"reference"!==c?tP:void 0,onPointerMove:"reference"!==c?tC:void 0,onPointerUp:"reference"!==c?tL:void 0,onPointerCancel:"reference"!==c?tN:void 0,onLostPointerCapture:"reference"!==c?()=>{ey.current=null,eZ(!1),e8(null)}:void 0,children:[(0,n.jsx)("rect",{className:"human2ai-composition-canvas__surface",x:"reference"===c?e7.x:r.x,y:"reference"===c?e7.y:r.y,width:"reference"===c?e7.width:r.width,height:"reference"===c?e7.height:r.height}),"reference"!==c?(0,n.jsx)(R,{controlsHost:d.layerOrder?eg:void 0,id:eL,label:"移动或缩放画框",bounds:e7,selected:tn,locked:!ti,resizeMode:"proportional",resizeCenter:{x:0,y:0},screenScale:u,resizeHitSize:40,minimumWidth:96,minimumHeight:96,onSelect:ti?()=>X?.([eL]):void 0,onNudge:ti?e=>{X?.([eL]),H?.((0,j.Dr)(d,{x:d.frame.bounds.x+e.x,y:d.frame.bounds.y+e.y}))}:void 0,onMove:ti?t_:void 0,onResize:ti?tF:void 0,onKeyDown:ti?tT:void 0,nudgeStep:.01,largeNudgeStep:.05,className:"human2ai-composition-canvas__frame"}):null,(0,v.jQ)([...d.images.map(e=>{let t=e.width*j.cq.width,i=e.height*j.cq.height,a=e.assetId?z?.(e.assetId):void 0,r=F?.imageKind??"图片";return(0,n.jsx)(A,{controlsHost:d.layerOrder?eg:void 0,id:e.id,label:`${r} ${e.id}`,tooltip:tb(e),x:e.x*j.cq.width,y:e.y*j.cq.height,rotation:e.rotation,selected:tr.has(e.id),bounds:"reference"===c||to&&tr.has(e.id)?void 0:e$(t,i),resizeMode:"proportional",resizeCenter:{x:0,y:0},screenScale:u,onSelect:"reference"!==c?tw:void 0,onNudge:"reference"!==c&&H?t=>tj(e.id,t):void 0,onResize:"reference"!==c&&H&&!(to&&tr.has(e.id))?t=>(function(e,t){if(!H||!d.images.some(t=>t.id===e))return;let i=eK({x:t.bounds.x+t.bounds.width/2,y:t.bounds.y+t.bounds.height/2},t.sourceRotation),n=(0,j.CV)(d,e,t.bounds.width/j.cq.width,t.bounds.height/j.cq.height);H((0,j.Pe)(n,e,{x:(t.sourcePosition.x+i.x)/j.cq.width,y:(t.sourcePosition.y+i.y)/j.cq.height}))})(e.id,t):void 0,onRotate:"reference"!==c&&H&&!(to&&tr.has(e.id))?t=>H((0,j.rz)(d,e.id,t.rotation)):void 0,onDoubleClick:"reference"!==c&&(H||G)?()=>tI(e.id,"image"):void 0,onDelete:"reference"!==c&&H?()=>tk(e.id):void 0,nudgeStep:.01,largeNudgeStep:.05,className:"human2ai-composition-canvas__item human2ai-composition-canvas__image","data-composition-item":e.id,"data-composition-kind":"image",children:(0,n.jsx)(q,{src:a,alt:e.note||r,width:t,height:i,fit:"cover",crop:e.crop,status:a?"ready":"empty",emptyLabel:r})},e.id)}),...d.areas.map((e,t)=>{let i=(0,j.QR)(e,j.cq),a=(0,j.MY)(e),r="circle"===i.type||"ellipse"===i.type?{x:i.cx,y:i.cy}:i.center,o=e_(e,i),s=e.corners?(0,j.QR)({...e,x:0,y:0,rotation:0},j.cq):null,l=a?F?.textKind??"文字区域":eC[e.primitive];return(0,n.jsx)(A,{controlsHost:d.layerOrder?eg:void 0,id:e.id,label:`选择${l} ${e.id}`,tooltip:tb(e,a?e.displayText:void 0),x:r.x,y:r.y,rotation:e.rotation??0,selected:tr.has(e.id),bounds:"reference"===c||to&&tr.has(e.id)?void 0:o,resizeCenter:{x:0,y:0},screenScale:u,onSelect:"reference"!==c?tw:void 0,onNudge:"reference"!==c&&H?t=>tj(e.id,t):void 0,onResize:"reference"!==c&&H&&!(to&&tr.has(e.id))?t=>(function(e,t){var i,n;if(!H)return;let a=d.areas.find(t=>t.id===e);if(!a)return;let r=eK((i=a,n=t.bounds,"triangle"===i.primitive?{x:n.x+n.width/2,y:n.y+2*n.height/3}:{x:n.x+n.width/2,y:n.y+n.height/2}),t.sourceRotation),o=(0,j.IU)(d,e,t.bounds.width/j.cq.width,t.bounds.height/j.cq.height);H((0,j.Pe)(o,e,{x:(t.sourcePosition.x+r.x)/j.cq.width,y:(t.sourcePosition.y+r.y)/j.cq.height}))})(e.id,t):void 0,onRotate:"reference"!==c&&H&&!(to&&tr.has(e.id))&&("circle"!==e.primitive||"free"===e.aspect)?t=>H((0,j.z_)(d,e.id,t.rotation)):void 0,onDoubleClick:"reference"!==c&&(H||G)?()=>tI(e.id,a?"text":"shape"):void 0,onDelete:"reference"!==c&&H?()=>tk(e.id):void 0,nudgeStep:.01,largeNudgeStep:.05,className:["human2ai-composition-canvas__item","human2ai-composition-canvas__area",`human2ai-composition-canvas__area--tone-${t%6}`,a?"human2ai-composition-canvas__area--text-region":null].filter(Boolean).join(" "),"data-composition-item":e.id,"data-composition-kind":a?"text-region":"area",children:e.isLightSource?(0,n.jsx)("g",{dangerouslySetInnerHTML:{__html:(0,j.gf)({...e,x:0,y:0,rotation:0},`${th}-light-${e.id}`,c)}}):"circle"===i.type?(0,n.jsx)(T,{type:"circle",size:2*i.radius,className:"human2ai-composition-canvas__shape"}):"ellipse"===i.type?(0,n.jsx)(T,{type:"circle",width:2*i.radiusX,height:2*i.radiusY,className:"human2ai-composition-canvas__shape"}):a?(0,n.jsxs)(n.Fragment,{children:[s?.type==="polygon"?(0,n.jsx)("polygon",{className:"human2ai-composition-canvas__shape",points:s.points.map(e=>`${e.x},${e.y}`).join(" "),"data-text-outline":!0}):(0,n.jsx)(T,{type:"rectangle",width:i.width??0,height:i.height,className:"human2ai-composition-canvas__shape"}),s?(0,n.jsx)("g",{className:"human2ai-composition-canvas__text-region-marks","aria-hidden":"true",children:(0,j.Dj)({...e,x:0,y:0,rotation:0},j.cq).map(([e,t],i)=>(0,n.jsx)("line",{x1:e.x,y1:e.y,x2:t.x,y2:t.y},i))}):(0,n.jsx)(eF,{width:i.width??0,height:i.height})]}):(0,n.jsx)(T,{type:"triangle"===e.primitive?"triangle":"rectangle",width:"triangle"===e.primitive?i.side??0:i.width??0,height:i.height,className:"human2ai-composition-canvas__shape"})},e.id)}),...d.directionLine?[(0,n.jsx)(eT,{draft:d,label:F?.lineKind??"动势线",selected:tr.has(d.directionLine.id),onSelect:"reference"!==c?tw:void 0,onNudge:"reference"!==c&&H?tj:void 0,onDoubleClick:"reference"!==c&&(H||G)?e=>tI(e,"line"):void 0,onDelete:"reference"!==c&&H?tk:void 0,bounds:o,tooltip:tb(d.directionLine)},d.directionLine.id)]:[],...d.focusPoints.map(e=>{let t=e.x*j.cq.width,i=e.y*j.cq.height,a=.018*Math.min(j.cq.width,j.cq.height);return(0,n.jsxs)(A,{controlsHost:d.layerOrder?eg:void 0,id:e.id,label:`选择焦点 ${e.id}`,tooltip:tb(e),x:t,y:i,selected:tr.has(e.id),onSelect:"reference"!==c?tw:void 0,onNudge:"reference"!==c&&H?t=>tj(e.id,t):void 0,onDoubleClick:"reference"!==c&&(H||G)?()=>tI(e.id,"point"):void 0,onDelete:"reference"!==c&&H?()=>tk(e.id):void 0,nudgeStep:.01,largeNudgeStep:.05,className:"human2ai-composition-canvas__item human2ai-composition-canvas__focus","data-composition-item":e.id,children:[(0,n.jsx)("circle",{className:"human2ai-composition-canvas__focus-ring",cx:0,cy:0,r:a}),(0,n.jsx)("line",{x1:-(1.5*a),y1:0,x2:1.5*a,y2:0}),(0,n.jsx)("line",{x1:0,y1:-(1.5*a),x2:0,y2:1.5*a}),(0,n.jsx)(eo,{className:"human2ai-composition-canvas__focus-dot",radius:4})]},e.id)})],d.layerOrder,e=>String(e.key)),"reference"!==c&&H&&1===ta.length&&d.directionLine?.id===ta[0]?(0,n.jsx)(eR,{directionLine:d.directionLine,distance:e3,screenScale:u,labels:_,onNudge:tA}):null,"reference"!==c&&m?(0,n.jsx)(eP,{draft:d,selectedIds:e,locked:t,onSelect:i,onDraftChange:Y?void 0:H,screenScale:u,labels:s},`${d.activeStateId??"default"}:${l??0}:${t}`):null,"reference"!==c&&to&&p&&H?(0,n.jsx)(A,{controlsHost:d.layerOrder?eg:void 0,id:"composition-multi-selection",label:`缩放 ${ta.length} 个所选元素`,x:p.x,y:p.y,selected:!0,bounds:e$(to.width,to.height),resizeMode:ts?"proportional":"free",resizeCenter:{x:0,y:0},screenScale:u,minimumWidth:16,minimumHeight:16,showRotationHandle:!1,tabIndex:-1,nudgeStep:.01,largeNudgeStep:.05,onNudge:e=>{H(eD(d,ta,e))},onResize:t$,onDelete:()=>{H(ez(d,ta)),X?.([])},className:"human2ai-composition-canvas__multi-selection",children:(0,n.jsx)("rect",{className:"human2ai-composition-canvas__multi-selection-surface",x:-to.width/2,y:-to.height/2,width:to.width,height:to.height,"aria-hidden":"true"})}):null,e4?(0,n.jsx)("rect",{className:"human2ai-composition-canvas__marquee",x:e4.x,y:e4.y,width:e4.width,height:e4.height,"aria-hidden":"true"}):null,"reference"===c?(0,n.jsx)("rect",{"data-composition-reference-frame":"true",x:e7.x,y:e7.y,width:e7.width,height:e7.height,fill:"none",stroke:"var(--yisiui-color-border-interactive)",strokeWidth:4,vectorEffect:"non-scaling-stroke",pointerEvents:"none","aria-hidden":"true"}):null,d.layerOrder&&"reference"!==c?(0,n.jsx)("rect",{"data-canvas-layer-frame":!0,className:"human2ai-canvas-shape human2ai-canvas-frame__border",x:e7.x,y:e7.y,width:e7.width,height:e7.height,"aria-hidden":"true"}):null,(0,n.jsx)("g",{ref:ef,"data-canvas-controls-layer":!0}),"reference"!==c&&H&&1===ta.length&&(eQ||e1)?d.areas.filter(e=>e.id===ta[0]&&(0,j.MY)(e)).map(e=>{let t=(0,j.QR)(e,j.cq);return"polygon"!==t.type?null:(0,n.jsx)("g",{className:"human2ai-composition-canvas__handles",onFocus:()=>e2(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||e2(!1)},children:t.points.map((t,i)=>(0,n.jsxs)("g",{"data-item-id":e.id,"data-handle":"move-text-corner","data-corner-index":i,className:"human2ai-composition-canvas__text-corner",transform:`translate(${t.x} ${t.y})`,role:"button",tabIndex:0,"aria-label":tm.cornerLabel.replace("{{index}}",String(i+1)),"aria-keyshortcuts":"ArrowLeft ArrowRight ArrowUp ArrowDown",onContextMenu:e=>{e.preventDefault(),e.stopPropagation()},onKeyDown:n=>{let a=(n.shiftKey?10:1)/u,r={ArrowLeft:{x:-a,y:0},ArrowRight:{x:a,y:0},ArrowUp:{x:0,y:-a},ArrowDown:{x:0,y:a}}[n.key];r&&(n.preventDefault(),n.stopPropagation(),H((0,j.Wn)(d,e.id,i,{x:(t.x+r.x)/j.cq.width,y:(t.y+r.y)/j.cq.height})))},children:[(0,n.jsx)("circle",{className:"human2ai-composition-canvas__transform-handle",r:7/u}),(0,n.jsx)("circle",{className:"human2ai-composition-canvas__transform-hit",r:12/u})]},i))},e.id)}):null,Y&&tx?(0,n.jsx)(es,{tool:function(e){if("focus"===e)return{shape:"point",width:16,height:16,clickOnly:!0};if("direction"===e)return{shape:"line",width:160,height:8};if("image"===e)return{shape:"rectangle",width:320,height:180};let t=("text"===e?(0,j.hN)((0,j.mq)()):(0,j.Xn)((0,j.mq)(),{primitive:e,aspect:"quadrilateral"===e?"free":"square"})).draft.areas[0],i=e_(t,(0,j.QR)(t,j.cq));return{shape:"circle"===e?"ellipse":"triangle"===e?"triangle":"rectangle",width:i.width,height:i.height}}(Y),viewportBounds:o,onPlace:tv,onCancel:()=>V?.(null)},Y):null]})}return(0,u.useLayoutEffect)(()=>{void 0!==l&&(ey.current=null,eZ(!1),ev.current=null,e8(null),e9(null),e2(!1),eh())},[l]),(0,u.useLayoutEffect)(()=>{let e=e=>e0(e.ctrlKey),t=()=>{e0(!1),e2(!1),ey.current?.type==="move-text-corner"&&(ey.current=null)};return window.addEventListener("keydown",e),window.addEventListener("keyup",e),window.addEventListener("blur",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",e),window.removeEventListener("blur",t)}},[]),(0,u.useLayoutEffect)(()=>{Y&&tS(),Y&&!tx&&V?.(null)},[Y,tx]),(0,n.jsxs)("div",{...(0,k.Se)({namespace:"human2ai",id:"composition-canvas",name:"CompositionCanvas",category:"module",origin:"project",status:"candidate"}),ref:en,className:ei,style:te,children:["reference"!==c?(0,n.jsx)(a.A,{trigger:[],autoFocus:!0,open:ea,popupRender:e=>(0,n.jsx)("div",{ref:ed,children:e}),onOpenChange:e=>{e||em()},menu:{items:v.JX.map(e=>({key:e,label:ep[e],disabled:!H||(0,w.q)(d,ta,e)===d})),onClick:({key:e})=>{let t=v.JX.find(t=>t===e);t&&H&&H((0,w.q)(d,ta,t)),em()}},children:(0,n.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",left:er.x,top:er.y,width:1,height:1,pointerEvents:"none"}})}):null,"reference"===c?tq():(0,n.jsx)(ej,{onContextMenuRequest:tR,onCameraCenterChange:eh,className:"human2ai-composition-canvas__viewport",defaultCameraCenter:{x:j.cq.width/2,y:j.cq.height/2},zoom:p,minimumZoom:.25,maximumZoom:4,fitRequest:tl,contentBounds:tt,backgroundPattern:I,showViewportControls:S,sideActions:P,sideActionPlacement:C,sideActionPanelWidth:M,sideActionPanelDefaultCollapsed:L,labels:N,onZoomChange:e=>{eh(),K?.(e)},"aria-label":`${et}视口`,children:tq}),tf.feedback,"reference"!==c&&e6&&td?(0,n.jsx)(ec,{nodeKind:e6.kind,metadata:td,labels:F,disabled:!H,leadingFields:tc&&(0,j.MY)(tc)?(0,n.jsx)(f,{label:tm.displayText,children:(0,n.jsx)(g,{name:"displayText",autoFocus:!0,value:tc.displayText??"",placeholder:tm.displayTextPlaceholder,"aria-label":tm.displayText,disabled:!H,onChange:e=>{H&&H((0,j.ai)(d,tc.id,{displayText:e.target.value}))}})}):void 0,propertyFields:tc||tu?(0,n.jsxs)(n.Fragment,{children:[tc&&!(0,j.MY)(tc)?(0,n.jsx)(f,{label:tm.lightSource,children:(0,n.jsx)(r.A,{checked:tc.isLightSource??!1,"aria-label":tm.lightSource,disabled:!H,onChange:e=>{H?.((0,j.ai)(d,tc.id,{isLightSource:e}))}})}):null,(0,n.jsx)(f,{label:tm.visualWeight,children:(0,n.jsx)(o.A,{className:"human2ai-canvas-node-editor__property-select",value:(tc??tu)?.visualWeight,options:ty,"aria-label":tm.visualWeight,disabled:!H,onChange:e=>{H&&H(tc?(0,j.ai)(d,tc.id,{visualWeight:e}):(0,j.QY)(d,tu.id,{visualWeight:e}))}})})]}):void 0,trailingFields:tu?.cameraReference&&B?B(tu):tu?(0,n.jsx)(ee,{src:tu.assetId?z?.(tu.assetId):void 0,crop:tu.crop,aspectRatio:tu.width*j.cq.width/(tu.height*j.cq.height),labels:tp,onReadFile:J,disabled:!H||!U,onUpload:async e=>{if(!H||!U)return;let t=await U(e),i=tg.current;i.interactionResetKey===l&&i.draft.images.some(({id:e})=>e===tu.id)&&i.onDraftChange?.((0,j.QY)(i.draft,tu.id,{assetId:t,crop:null}))},onCropChange:(e,t)=>{if(!H)return;let i=(0,j.QY)(d,tu.id,{crop:e});H((0,j.CV)(i,tu.id,tu.width,tu.width*j.cq.width/(t*j.cq.height)))}},tu.id):void 0,autoFocusField:tc&&(0,j.MY)(tc)?"none":"note",onMetadataChange:e=>{H&&H((0,j.s)(d,e6.id,e))},onRequestClose:tS,onDelete:()=>tk(e6.id)}):null]})}function e$(e,t){return{x:-e/2,y:-t/2,width:e,height:t}}function eF({width:e,height:t}){let i=-(.32*e),a=[-(.18*t),0,.18*t];return(0,n.jsx)("g",{className:"human2ai-composition-canvas__text-region-marks","aria-hidden":"true",children:[.64*e,.5*e,.58*e].map((e,t)=>(0,n.jsx)("line",{x1:i,x2:i+e,y1:a[t],y2:a[t]},a[t]))})}function e_(e,t){if("circle"===t.type)return e$(2*t.radius,2*t.radius);if("ellipse"===t.type)return e$(2*t.radiusX,2*t.radiusY);let i="triangle"===e.primitive?t.side??0:t.width??0;return"triangle"===e.primitive?{x:-i/2,y:-2*t.height/3,width:i,height:t.height}:e$(i,t.height)}function eT({draft:e,label:t,selected:i,onSelect:a,onNudge:r,onDoubleClick:o,onDelete:s,bounds:l,tooltip:d}){let c=e.directionLine;if(!c)return null;let u=eY(c);return(0,n.jsx)(A,{id:c.id,label:`${t} ${c.id}`,tooltip:d,selected:i,onSelect:a,onNudge:r?e=>r(c.id,e):void 0,onDoubleClick:o,onDelete:s?()=>s(c.id):void 0,nudgeStep:.01,largeNudgeStep:.05,className:"human2ai-composition-canvas__item human2ai-composition-canvas__direction","data-composition-item":c.id,children:(0,n.jsx)(er,{type:"infinite",anchor:u,angle:c.rotation,bounds:l,dashArray:"10 8"})})}function eR({directionLine:e,distance:t,screenScale:i,labels:a,onNudge:r}){let o=i>0&&Number.isFinite(i)?i:1,s=7/o,l=12/o;return(0,n.jsx)("g",{className:"human2ai-composition-canvas__handles",children:eE(e,t).map((t,i)=>(0,n.jsxs)("g",{className:"human2ai-composition-canvas__direction-control","data-item-id":e.id,"data-handle":"move-direction-point","data-point-index":i,transform:`translate(${t.x} ${t.y})`,role:"button",tabIndex:0,"aria-label":a[i],"aria-keyshortcuts":"ArrowLeft ArrowRight ArrowUp ArrowDown",onKeyDown:e=>{let t=(e.shiftKey?10:1)/o,n={ArrowLeft:{x:-t,y:0},ArrowRight:{x:t,y:0},ArrowUp:{x:0,y:-t},ArrowDown:{x:0,y:t}};n[e.key]&&(e.preventDefault(),e.stopPropagation(),r(i,n[e.key]))},children:[(0,n.jsx)("circle",{className:"human2ai-composition-canvas__transform-handle",r:s}),(0,n.jsx)("circle",{className:"human2ai-composition-canvas__transform-hit",r:l})]},i))})}function eE(e,t){let i=eY(e);return[eG(i,e.rotation,-t/2),eG(i,e.rotation,t/2)]}function eq(e,t){let i=new Set(t);return[...e.filter(e=>!i.has(e)),...t.filter(t=>!e.includes(t))]}function eD(e,t,i){return t.reduce((t,n)=>{let a=eW(e,n);return a?(0,j.Pe)(t,n,{x:a.x+i.x,y:a.y+i.y}):t},e)}function ez(e,t){return t.reduce((e,t)=>eW(e,t)?(0,j.Ai)(e,t):e,e)}function eB(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function eO(e,t){let i=e.areas.find(e=>e.id===t);if(i)return eU(i);let n=e.images.find(e=>e.id===t);if(n)return eH(n);let a=e.focusPoints.find(e=>e.id===t);if(a){let e=eY(a);return{x:e.x-20,y:e.y-20,width:40,height:40}}if(e.directionLine?.id===t){let t=eY(e.directionLine);return{x:t.x-12,y:t.y-12,width:24,height:24}}return null}function eU(e){let t=(0,j.QR)(e,j.cq);if("circle"===t.type)return{x:t.cx-t.radius,y:t.cy-t.radius,width:2*t.radius,height:2*t.radius};if("ellipse"===t.type)return{x:t.cx-t.radiusX,y:t.cy-t.radiusY,width:2*t.radiusX,height:2*t.radiusY};let i=Math.min(...t.points.map(e=>e.x)),n=Math.min(...t.points.map(e=>e.y));return{x:i,y:n,width:Math.max(...t.points.map(e=>e.x))-i,height:Math.max(...t.points.map(e=>e.y))-n}}function eJ(e,t){return!(e.x+e.width<t.x||t.x+t.width<e.x||e.y+e.height<t.y||t.y+t.height<e.y)}function eW(e,t){return e.areas.find(e=>e.id===t)??e.images.find(e=>e.id===t)??e.focusPoints.find(e=>e.id===t)??(e.directionLine?.id===t?e.directionLine:null)}function eH(e){let t=e.width*j.cq.width,i=e.height*j.cq.height,n=e.rotation*Math.PI/180,a=Math.abs(t*Math.cos(n))+Math.abs(i*Math.sin(n)),r=Math.abs(t*Math.sin(n))+Math.abs(i*Math.cos(n)),o=eY(e);return{x:o.x-a/2,y:o.y-r/2,width:a,height:r}}function eY(e){return{x:e.x*j.cq.width,y:e.y*j.cq.height}}function eV(e,t){let i=t.createSVGPoint();i.x=e.clientX,i.y=e.clientY;let n=t.getScreenCTM();if(!n)return{x:0,y:0};let a=i.matrixTransform(n.inverse());return{x:a.x,y:a.y}}function eX(e,t){try{e.setPointerCapture(t)}catch{}}function eG(e,t,i){let n=t*Math.PI/180;return{x:e.x+Math.cos(n)*i,y:e.y+Math.sin(n)*i}}function eK(e,t){let i=t*Math.PI/180,n=Math.cos(i),a=Math.sin(i);return{x:e.x*n-e.y*a,y:e.x*a+e.y*n}}var eZ=i(16269),eQ=i(63835),e0=i(51055),e1=i(23139),e2=i(48776);function e3({draft:e,selectedIds:t,onSelect:i,locked:l=!1,onLockedChange:d,showPlanning:c=!0,onShowPlanningChange:u,onDraftChange:m,labels:h,deleteLabel:p,disabled:g=!1}){let f=e.plans??[],y=g||l,x=1===t.length?f.find(e=>e.id===t[0]):void 0,b=x?.type==="symmetry"?h.symmetryHelp:x?.type==="golden-spiral"?h.spiralHelp:x?.type==="radial"?h.radialHelp:h.help,v=t=>{y||m((0,j.sJ)(e,t))},w=(e,t,i,a,r,o)=>(0,n.jsxs)("label",{className:"human2ai-composition-planning__field",children:[(0,n.jsx)("span",{children:e}),(0,n.jsx)(e2.A,{"aria-label":e,value:Math.round(100*t)/100,min:a,max:r,precision:o,step:1,controls:!1,disabled:y,onChange:e=>{null!==e&&Number.isFinite(e)&&(void 0===a||e>=a)&&(void 0===r||e<=r)&&(0!==o||Number.isInteger(e))&&i(e)}})]});return(0,n.jsxs)("section",{...(0,k.Se)({namespace:"human2ai",id:"composition-planning-panel",name:"CompositionPlanningPanel",category:"module",origin:"project",status:"candidate"}),className:"human2ai-composition-planning","aria-label":h.title,children:[(0,n.jsxs)("div",{className:"human2ai-composition-planning__heading",children:[(0,n.jsx)("h2",{children:h.title}),(0,n.jsx)(C.A,{title:b,children:(0,n.jsx)(X.J,{mode:"icon-only",size:"small",icon:(0,n.jsx)(ep.A,{}),iconLabel:b})}),(0,n.jsx)(a.A,{trigger:["click"],disabled:y,menu:{items:j.Hm.map(e=>({key:e,label:h.types[e]})),onClick:({key:t})=>{if(y)return;let n=(0,j.vF)(e,t);m(n.draft),i([n.id])}},children:(0,n.jsx)(X.J,{mode:"icon-only",size:"small",icon:(0,n.jsx)(em.A,{}),iconLabel:h.add,disabled:y})}),(0,n.jsx)(C.A,{title:c?h.hideAll:h.showAll,children:(0,n.jsx)(X.J,{mode:"icon-only",size:"small",icon:c?(0,n.jsx)(eZ.A,{}):(0,n.jsx)(eQ.A,{}),iconLabel:c?h.hideAll:h.showAll,"aria-pressed":c,disabled:g||!u,onClick:()=>u?.(!c)})}),(0,n.jsx)(C.A,{title:l?h.unlock:h.lock,children:(0,n.jsx)(X.J,{mode:"icon-only",size:"small",icon:l?(0,n.jsx)(e0.A,{}):(0,n.jsx)(e1.A,{}),iconLabel:l?h.unlock:h.lock,"aria-pressed":l,disabled:g||!d,onClick:()=>d?.(!l)})})]}),0===f.length?(0,n.jsx)("p",{className:"human2ai-composition-planning__empty",children:h.empty}):(0,n.jsx)("div",{className:"human2ai-composition-planning__list",children:f.map((a,o)=>(0,n.jsxs)("div",{className:"human2ai-composition-planning__row","data-plan-row":a.id,children:[(0,n.jsxs)(X.J,{type:"text",size:"small","aria-pressed":t.includes(a.id),disabled:y,className:"human2ai-composition-planning__select",onClick:e=>i(e.shiftKey||e.ctrlKey||e.metaKey?t.includes(a.id)?t.filter(e=>e!==a.id):[...t,a.id]:[a.id]),children:[h.types[a.type]," ",o+1]}),(0,n.jsx)(C.A,{title:h.visible,children:(0,n.jsx)(r.A,{size:"small",checked:a.visible,"aria-label":h.visible,disabled:y,onChange:e=>v({...a,visible:e})})}),(0,n.jsx)(X.J,{mode:"icon-only",size:"small",type:"text",icon:(0,n.jsx)(s.A,{}),iconLabel:p,disabled:y,onClick:()=>{y||(m((0,j.q3)(e,a.id)),i(t.filter(e=>e!==a.id)))}})]},a.id))}),x?(0,n.jsxs)("div",{className:"human2ai-composition-planning__properties","data-plan-properties":x.id,children:["thirds"===x.type||"golden-section"===x.type?(0,n.jsxs)("label",{className:"human2ai-composition-planning__field",children:[(0,n.jsx)("span",{children:h.axes}),(0,n.jsx)(o.A,{"aria-label":h.axes,value:x.axes,disabled:y,options:["both","horizontal","vertical"].map(e=>({value:e,label:h[e]})),onChange:e=>v({...x,axes:e})})]}):null,"radial"===x.type?(0,n.jsxs)("label",{className:"human2ai-composition-planning__field",children:[(0,n.jsx)("span",{children:h.radialMode}),(0,n.jsx)(o.A,{"aria-label":h.radialMode,value:x.mode,disabled:y,options:[{value:"uniform",label:h.radialUniform},{value:"free",label:h.radialFree}],onChange:e=>v((0,j.n_)(x,e))})]}):null,"golden-spiral"===x.type||"triangle"===x.type||"radial"===x.type?(0,n.jsxs)("div",{className:"human2ai-composition-planning__coordinates",children:[w(h.x,100*x.x,e=>v({...x,x:e/100})),w(h.y,100*x.y,e=>v({...x,y:e/100})),"radial"!==x.type||"uniform"===x.mode?w(h.rotation,x.rotation,e=>v({...x,rotation:e})):null,"golden-spiral"===x.type?w(h.scale,100*x.scale,e=>v({...x,scale:e/100}),1):null,"triangle"===x.type?(0,n.jsxs)(n.Fragment,{children:[w(h.width,100*x.width,e=>v({...x,width:e/100}),1),w(h.height,100*x.height,e=>v({...x,height:e/100}),1)]}):null,"radial"===x.type?(0,n.jsxs)(n.Fragment,{children:[w(h.rayCount,"free"===x.mode?x.angles.length:x.rayCount,e=>v((0,j.ht)(x,e)),2,36,0),"uniform"===x.mode?w(h.spread,x.spread,e=>v({...x,spread:e}),1,360):null]}):null]}):null,"golden-spiral"===x.type?(0,n.jsxs)("label",{className:"human2ai-composition-planning__toggle",children:[(0,n.jsx)("span",{children:h.mirrored}),(0,n.jsx)(r.A,{size:"small","aria-label":h.mirrored,checked:x.mirrored,disabled:y,onChange:e=>v({...x,mirrored:e})})]}):null,"triangle"===x.type?(0,n.jsx)("p",{className:"human2ai-composition-planning__help",children:h.triangleHelp}):null]}):null]})}var e5=i(43390),e4=i(74604);function e8({canUndo:e,canRedo:t,undo:i,redo:a,labels:r}){let[o,s]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{s(/Mac/.test(navigator.platform))},[]),(0,n.jsxs)("div",{...(0,k.Se)({namespace:"human2ai",id:"canvas-history-controls",name:"CanvasHistoryControls",category:"module",origin:"project",status:"candidate"}),className:"human2ai-canvas-history-controls",role:"group","aria-label":r.label,children:[(0,n.jsx)(X.J,{mode:"icon-only",size:"small",icon:(0,n.jsx)(e5.A,{"aria-hidden":"true"}),iconLabel:r.undo,title:`${r.undo} (${o?"⌘Z":"Ctrl+Z"})`,"aria-keyshortcuts":"Control+z Meta+z",disabled:!e,onClick:i}),(0,n.jsx)(X.J,{mode:"icon-only",size:"small",icon:(0,n.jsx)(e4.A,{"aria-hidden":"true"}),iconLabel:r.redo,title:`${r.redo} (${o?"⌘⇧Z":"Ctrl+Shift+Z"})`,"aria-keyshortcuts":"Control+Shift+z Meta+Shift+z Control+y",disabled:!t,onClick:a})]})}function e6(e,t,i){let n=(0,j.M6)(e),a=(0,j.bc)(n),r=n.plans??[],o=r.flatMap(e=>{let i;if("thirds"===e.type||"golden-section"===e.type)i=t("planningGrid",{type:t("thirds"===e.type?"planningThirds":"planningGoldenSection"),axes:t("both"===e.axes?"planningBoth":"horizontal"===e.axes?"planningHorizontal":"planningVertical")});else if("triangle"===e.type){let a=(0,j.i)(n.frame);i=t("planningTriangle",{points:(0,j.SZ)(e,n.frame).handles.map(e=>`(${ti((e.x-a.x)/a.width)}%, ${ti((e.y-a.y)/a.height)}%)`).join("; ")})}else if("radial"===e.type)i="free"===e.mode?t("planningRadialFree",{x:ti(e.x),y:ti(e.y),rayCount:e.angles.length,angles:e.angles.map(e=>`${Math.round(10*e)/10}\xb0`).join(", ")}):t("planningRadial",{x:ti(e.x),y:ti(e.y),rotation:Math.round(10*e.rotation)/10,rayCount:e.rayCount,spread:Math.round(10*e.spread)/10});else{if("symmetry"!==e.type&&"golden-spiral"!==e.type)return[];i=t("symmetry"===e.type?"planningSymmetry":"planningSpiral",{x:ti(e.x),y:ti(e.y),rotation:Math.round(10*e.rotation)/10,..."golden-spiral"===e.type?{scale:ti(e.scale),winding:t(e.mirrored?"planningCounterclockwise":"planningClockwise")}:{}})}return[i]}),s=a.areas.some(e=>"text-region"===e.semanticType),l=function(e,t){let i=Math.abs(e),n=Math.abs(t);for(;0!==n;)[i,n]=[n,i%n];return i||1}(n.frame.width,n.frame.height),d=a.focusPoints.map((e,i)=>[t("focusNumber",{index:i+1}),...tt(e,t),t("referencePosition",{x:ti(e.x),y:ti(e.y)})]),c=a.areas.map((e,i)=>[t(e.isLightSource?"lightSourceNumber":"text-region"===e.semanticType?"textRegionNumber":"areaNumber",{index:i+1}),...tt(e,t),...e.isLightSource&&"quadrilateral"===e.primitive?[t("lightBandGuidance")]:[],...e.displayText?.trim()?[t("displayText",{text:e.displayText.trim()})]:"text-region"===e.semanticType?[t("generatedDisplayText")]:[],..."auto"===e.visualWeight?[]:[t("visualWeight",{weight:t(e9(e.visualWeight))})],t("referencePosition",{x:ti(e.center.x),y:ti(e.center.y)}),...e.isLightSource?[]:[t("referenceArea",{area:ti(e.visibleAreaShare)})],...!e.isLightSource&&Math.abs(e.rotation)>1e-6?[t("referenceRotation",{rotation:Math.round(e.rotation)})]:[],...!e.isLightSource&&e.clippedSides.length?[t("referenceClipping",{sides:e.clippedSides.map(e=>t(e)).join(t("sideSeparator"))})]:[]]),u=a.images.map((e,i)=>[t("imageNumber",{index:i+1}),...tt(e,t),..."auto"===e.visualWeight?[]:[t("visualWeight",{weight:t(e9(e.visualWeight))})],t("referencePosition",{x:ti(e.center.x),y:ti(e.center.y)}),t("referenceArea",{area:ti(e.areaShare)}),...Math.abs(e.rotation)>1e-6?[t("referenceRotation",{rotation:Math.round(e.rotation)})]:[],...e.clippedSides.length?[t("referenceClipping",{sides:e.clippedSides.map(e=>t(e)).join(t("sideSeparator"))})]:[]]),m=a.directionLine?[t("flowHeading"),...tt(a.directionLine,t),t("flowReference",{x:ti(a.directionLine.x),y:ti(a.directionLine.y),rotation:Math.round(a.directionLine.rotation)})]:[];return[t("title"),"",t("outputRatio",{ratio:`${n.frame.width/l}:${n.frame.height/l}`}),t("processingSemantic",{semantic:t("editorial-layout"===n.processingSemantic?"editorialLayout":"scene-composition"===n.processingSemantic?"sceneComposition":"unselected")}),"",t("layoutHeading"),t("editorial-layout"===n.processingSemantic?"editorialGuidance":"scene-composition"===n.processingSemantic?"sceneGuidance":"unselectedGuidance"),t("regionSemanticsGuidance"),...a.areas.some(e=>e.isLightSource)?[t("lightSourceGuidance")]:[],...s?[t("displayTextGuidance")]:[],t("coordinateOrigin"),t("referenceValues"),t("flexibleImplementation"),t("referenceImageGuidance"),...a.overallNote.trim()?["",t("globalNoteHeading"),a.overallNote.trim()]:[],...i?.trim()?["",i.trim()]:[],...r.length?["",t("planningHeading"),t("planningGuidance"),...o]:[],...a.areas.length?["",t("metricsHeading"),t("occupied",{value:ti(a.metrics.occupiedArea)}),t("negativeSpace",{value:ti(a.metrics.negativeSpace)})]:[],...d.length?["",t("focusHeading")]:[],...d.flatMap(e=>["",...e]),...c.length?["",t("areaHeading")]:[],...c.flatMap(e=>["",...e]),...u.length?["",t("imageHeading")]:[],...u.flatMap(e=>["",...e]),...m.length?["",...m]:[]].join("\n").trimEnd()}function e9(e){return"high"===e?"weightHigh":"medium"===e?"weightMedium":"low"===e?"weightLow":"weightDecorative"}async function e7(e,t){var i;let n,a,r=await te(e,t);return navigator.clipboard?.write&&"u">typeof ClipboardItem?(await navigator.clipboard.write([new ClipboardItem({"image/png":r})]),"copied"):(i=r,n=URL.createObjectURL(i),(a=document.createElement("a")).href=n,a.download="composition-sketch.png",a.click(),URL.revokeObjectURL(n),"downloaded")}async function te(e,t){var i,n,a,r;let o=(0,j.M6)(e),s=new Blob([(i=o,n=t,(0,j.qU)(i,n))],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(s);try{let e=await (a=l,new Promise((e,t)=>{let i=new Image;i.onload=()=>e(i),i.onerror=()=>t(Error("The browser could not render the composition sketch.")),i.src=a})),t=document.createElement("canvas");t.width=o.frame.width,t.height=o.frame.height;let i=t.getContext("2d");if(!i)throw Error("The browser could not create the composition canvas.");return i.drawImage(e,0,0,t.width,t.height),await (r=t,new Promise((e,t)=>{r.toBlob(i=>{i?e(i):t(Error("The browser could not generate the composition PNG."))},"image/png")}))}finally{URL.revokeObjectURL(l)}}function tt(e,t){return[...e.note.trim()?[t("note",{note:e.note.trim()})]:[],..."auto"===e.shotScale?[]:[t("shotScale",{shotScale:t(e.shotScale)})]]}function ti(e){return Math.round(100*e)}i(1820);var tn=i(8647),ta=i(59030),tr=i(11902),to=i(83499),ts=i(49762);function tl(e,t){let i=new Set(t);for(let t of e.groups)t.itemIds.some(e=>i.has(e))&&t.itemIds.forEach(e=>i.add(e));return[...i]}function td(e,t){let i=new Set(t);return{...e,groups:e.groups.filter(e=>!e.itemIds.some(e=>i.has(e)))}}function tc(e){return(0,v.EN)([...e.images,...e.rectangles,...e.texts].map(e=>e.id),e.layerOrder)}function tu(e,t,i){let n=tc(e),a=(0,v.qP)(n,tl(e,t),i);return a===n?e:{...e,layerOrder:[...a]}}var tm=i(27062);let th=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://yisi.local/schemas/ui-sketch-draft.schema.json","title":"UI Sketch Draft","type":"object","additionalProperties":false,"required":["version","kind","frame","overallNote","rectangles","texts","images","groups","stages"],"properties":{"layerOrder":{"type":"array","uniqueItems":true,"items":{"type":"string","minLength":1}},"version":{"const":1},"kind":{"const":"ui-layout-draft"},"frame":{"$ref":"#/$defs/bounds"},"overallNote":{"type":"string"},"stateTabs":{"type":"array","minItems":1,"items":{"type":"object","additionalProperties":false,"required":["id","number"],"properties":{"id":{"type":"string","minLength":1},"number":{"type":"integer","minimum":1},"name":{"type":"string","minLength":1,"maxLength":100,"pattern":"\\\\S"}}}},"groups":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["id","itemIds"],"properties":{"id":{"type":"string","minLength":1},"itemIds":{"type":"array","minItems":2,"uniqueItems":true,"items":{"type":"string","minLength":1}}}}},"rectangles":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["id","x","y","width","height","note","annotation","semanticType","origin","visible","weight"],"properties":{"id":{"type":"string","minLength":1},"x":{"type":"number"},"y":{"type":"number"},"width":{"type":"number","exclusiveMinimum":0},"height":{"type":"number","exclusiveMinimum":0},"note":{"type":"string"},"annotation":{"type":"string"},"semanticType":{"type":"string"},"origin":{"enum":["user","agent","import"]},"visible":{"type":"boolean"},"weight":{"enum":["auto","high","medium","low","decorative"]}}}},"texts":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["id","x","y","text","fontSize","note","annotation","semanticType","origin","visible","weight"],"properties":{"id":{"type":"string","minLength":1},"x":{"type":"number"},"y":{"type":"number"},"text":{"type":"string"},"fontSize":{"type":"number","exclusiveMinimum":0},"note":{"type":"string"},"annotation":{"type":"string"},"semanticType":{"type":"string"},"origin":{"enum":["user","agent","import"]},"visible":{"type":"boolean"},"weight":{"enum":["auto","high","medium","low","decorative"]}}}},"images":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["id","x","y","width","height","assetId","crop","note","annotation","semanticType","origin","visible","weight"],"properties":{"id":{"type":"string","minLength":1},"x":{"type":"number"},"y":{"type":"number"},"width":{"type":"number","exclusiveMinimum":0},"height":{"type":"number","exclusiveMinimum":0},"assetId":{"type":["string","null"],"minLength":1},"crop":{"oneOf":[{"type":"null"},{"$ref":"#/$defs/imageCrop"}]},"note":{"type":"string"},"annotation":{"type":"string"},"semanticType":{"type":"string"},"origin":{"enum":["user","agent","import"]},"visible":{"type":"boolean"},"weight":{"enum":["auto","high","medium","low","decorative"]}}}},"stages":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["id","rectangles","texts","images"],"properties":{"id":{"type":"string","minLength":1,"not":{"const":"start"}},"rectangles":{"type":"array","items":{"$ref":"#/$defs/stageRectangle"}},"texts":{"type":"array","items":{"$ref":"#/$defs/stageText"}},"images":{"type":"array","items":{"$ref":"#/$defs/stageRectangle"}}}}}},"$defs":{"imageCrop":{"type":"object","additionalProperties":false,"required":["x","y","width","height"],"properties":{"x":{"type":"number","minimum":0,"maximum":1},"y":{"type":"number","minimum":0,"maximum":1},"width":{"type":"number","exclusiveMinimum":0,"maximum":1},"height":{"type":"number","exclusiveMinimum":0,"maximum":1}}},"bounds":{"type":"object","additionalProperties":false,"required":["x","y","width","height"],"properties":{"x":{"type":"number"},"y":{"type":"number"},"width":{"type":"number","exclusiveMinimum":0},"height":{"type":"number","exclusiveMinimum":0}}},"stageRectangle":{"type":"object","additionalProperties":false,"required":["id","x","y","width","height","visible"],"properties":{"id":{"type":"string","minLength":1},"x":{"type":"number"},"y":{"type":"number"},"width":{"type":"number","exclusiveMinimum":0},"height":{"type":"number","exclusiveMinimum":0},"visible":{"type":"boolean"}}},"stageText":{"type":"object","additionalProperties":false,"required":["id","x","y","fontSize","visible"],"properties":{"id":{"type":"string","minLength":1},"x":{"type":"number"},"y":{"type":"number"},"fontSize":{"type":"number","exclusiveMinimum":0},"visible":{"type":"boolean"}}}}}');var tp=i(33949);function tg(e){return e.stateTabs?.map(e=>({...e}))??["start",...e.stages.map(e=>e.id)].map((e,t)=>({id:e,number:t+1}))}function tf(e,t,i){return{...e,stateTabs:(0,tp.UR)(tg(e),t,i)}}function ty(e,t){return{...e,stateTabs:(0,tp.kq)(tg(e),t)}}function tx(e,t){return{...e,stateTabs:(0,tp.aD)(tg(e),t),stages:e.stages.filter(e=>e.id!==t)}}let tb="start",tv={version:1,kind:"ui-layout-draft",frame:{x:0,y:0,width:960,height:560},overallNote:"",rectangles:[],texts:[],images:[],groups:[],stages:[]};function tw(e){return{...e,...e.layerOrder?{layerOrder:[...e.layerOrder]}:{},frame:{...e.frame},...e.stateTabs?{stateTabs:tg(e)}:{},groups:e.groups.map(e=>({...e,itemIds:[...e.itemIds]})),rectangles:e.rectangles.map(e=>({...e})),texts:e.texts.map(e=>({...e})),images:e.images.map(e=>({...e,crop:e.crop?{...e.crop}:null})),stages:e.stages.map(e=>({...e,rectangles:e.rectangles.map(e=>({...e})),texts:e.texts.map(e=>({...e})),images:e.images.map(e=>({...e}))}))}}function tj(e,t){let i=tw(e);if(t===tb)return i;let n=tS(i,t);if("end"===t&&!n)return i;if(!n)throw Error(`Unknown UI sketch stage id: ${t}.`);let a=new Map(n.rectangles.map(e=>[e.id,e])),r=new Map(n.texts.map(e=>[e.id,e])),o=new Map(n.images.map(e=>[e.id,e]));return{...i,rectangles:i.rectangles.map(e=>({...e,...a.get(e.id)})),texts:i.texts.map(e=>({...e,...r.get(e.id)})),images:i.images.map(e=>({...e,...o.get(e.id)}))}}function tk(e,t,i){if(i===tb||e.stages.some(e=>e.id===i))throw Error(`Duplicate UI sketch stage id: ${i}.`);let n=tg(e);if(!n.some(e=>e.id===t))throw Error(`Unknown UI sketch stage id: ${t}.`);let a=tj(e,t),r={id:i,rectangles:a.rectangles.map(tP),texts:a.texts.map(tC),images:a.images.map(tM)},o=t===tb?0:e.stages.findIndex(e=>e.id===t)+1;if(0===o&&t!==tb)throw Error(`Unknown UI sketch stage id: ${t}.`);let s=e.stages.map(tA);return s.splice(o,0,r),n.splice(n.findIndex(e=>e.id===t)+1,0,{id:i,number:Math.max(...n.map(e=>e.number))+1}),{...tw(e),stages:s,stateTabs:n}}function tI(e,t,i){let n=t===tb?null:tS(e,t);if(t!==tb&&"end"!==t&&!n)throw Error(`Unknown UI sketch stage id: ${t}.`);let a=n?.id??t,r=new Map(e.rectangles.map(e=>[e.id,e])),o=new Map(e.texts.map(e=>[e.id,e])),s=new Map(e.images.map(e=>[e.id,e])),l=new Map(i.rectangles.map(e=>[e.id,e])),d=new Map(i.texts.map(e=>[e.id,e])),c=new Map(i.images.map(e=>[e.id,e])),u=i.rectangles.map(e=>{let i=r.get(e.id);return i&&t!==tb?{...i,note:e.note,annotation:e.annotation,semanticType:e.semanticType,weight:e.weight}:{...e}}),m=i.texts.map(e=>{let i=o.get(e.id);return i&&t!==tb?{...i,text:e.text,note:e.note,annotation:e.annotation,semanticType:e.semanticType,weight:e.weight}:{...e}}),h=i.images.map(e=>{let i=s.get(e.id);return i&&t!==tb?{...i,assetId:e.assetId,crop:e.crop?{...e.crop}:null,note:e.note,annotation:e.annotation,semanticType:e.semanticType,weight:e.weight}:{...e}}),p=e.stages.map(e=>({...e,rectangles:u.map(t=>e.id===a?tP(l.get(t.id)??t):{...e.rectangles.find(e=>e.id===t.id)??tP(l.get(t.id)??t)}),texts:m.map(t=>e.id===a?tC(d.get(t.id)??t):{...e.texts.find(e=>e.id===t.id)??tC(d.get(t.id)??t)}),images:h.map(t=>e.id===a?tM(c.get(t.id)??t):{...e.images.find(e=>e.id===t.id)??tM(c.get(t.id)??t)})}));return"end"!==t||n||p.push({id:"end",rectangles:u.map(e=>tP(l.get(e.id)??e)),texts:m.map(e=>tC(d.get(e.id)??e)),images:h.map(e=>tM(c.get(e.id)??e))}),{...e,...i.layerOrder?{layerOrder:tc(i)}:{},frame:{...i.frame},overallNote:i.overallNote,groups:i.groups.map(e=>({...e,itemIds:[...e.itemIds]})),rectangles:u,texts:m,images:h,stages:p,...e.stateTabs&&"end"===t&&!n?{stateTabs:[...tg(e),{id:"end",number:Math.max(...tg(e).map(e=>e.number))+1}]}:{}}}function tS(e,t){return e.stages.find(e=>e.id===t)??("end"===t?e.stages[0]:void 0)}function tP(e){let{id:t,x:i,y:n,width:a,height:r,visible:o}=e;return{id:t,x:i,y:n,width:a,height:r,visible:o}}function tC(e){let{id:t,x:i,y:n,fontSize:a,visible:r}=e;return{id:t,x:i,y:n,fontSize:a,visible:r}}function tM(e){let{id:t,x:i,y:n,width:a,height:r,visible:o}=e;return{id:t,x:i,y:n,width:a,height:r,visible:o}}function tA(e){return{...e,rectangles:e.rectangles.map(e=>({...e})),texts:e.texts.map(e=>({...e})),images:e.images.map(e=>({...e}))}}function tL(e){let t=e.text.split("\n"),i=Math.max(1,...t.map(e=>[...e].length));return{x:e.x,y:e.y,width:Math.max(e.fontSize,i*e.fontSize*.62),height:Math.max(e.fontSize,t.length*e.fontSize*1.4)}}new tm.Ajv2020({allErrors:!0}).compile(th);let tN=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","additionalProperties":false,"required":["sourceFingerprint","alignments"],"properties":{"sourceFingerprint":{"type":"string","minLength":1},"alignments":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["stageId","axis","edge","anchorId","itemIds"],"properties":{"stageId":{"type":"string","minLength":1},"axis":{"enum":["x","y"]},"edge":{"enum":["start","center","end"]},"anchorId":{"type":"string","minLength":1},"itemIds":{"type":"array","minItems":1,"uniqueItems":true,"items":{"type":"string","minLength":1}}}}}}}');function t$({text:e,fontSize:t,lineHeight:i=1.4,fontFamily:a,fontWeight:r,fill:o,opacity:s,textAnchor:l="start",className:d,style:c,onBoundsChange:m,"aria-label":h=e}){let p=(0,u.useRef)(null),g=(0,u.useRef)(m),f=(0,u.useRef)(null);g.current=m;let y=["human2ai-canvas-text",d].filter(Boolean).join(" "),x=e.split("\n"),b=!!m;return(0,u.useLayoutEffect)(()=>{if(!b)return;let e=p.current;if(!e)return;let t=!0;function i(){var i,n;if(!t)return;let a=e.getBBox(),r={x:a.x,y:a.y,width:a.width,height:a.height};i=f.current,n=r,i&&.01>Math.abs(i.x-n.x)&&.01>Math.abs(i.y-n.y)&&.01>Math.abs(i.width-n.width)&&.01>Math.abs(i.height-n.height)||(f.current=r,g.current?.(r))}i();let n="u"<typeof ResizeObserver?null:new ResizeObserver(i);return n?.observe(e),document.fonts?.ready.then(i),()=>{t=!1,n?.disconnect()}},[d,a,t,r,i,b,c,e,l]),(0,n.jsx)("text",{ref:p,...(0,k.Se)({namespace:"human2ai",id:"canvas-text",name:"CanvasText",category:"module",origin:"project",status:"candidate"}),className:y,"data-line-count":x.length,x:0,y:0,fontSize:t,fontFamily:a,fontWeight:r,fill:o,opacity:s,textAnchor:l,dominantBaseline:"text-before-edge",xmlSpace:"preserve",style:c,role:"img","aria-label":h,children:x.map((e,t)=>(0,n.jsx)("tspan",{x:0,dy:0===t?0:`${i}em`,children:e||"\xa0"},t))})}function tF(e,t,i,n,a,r){let o=e.split("\n"),s=1.4*n,l=r?i-(o.length-1)*s/2:i+n;return o.map((e,i)=>`<text x="${t_(t)}" y="${t_(l+i*s)}" font-size="${t_(n)}" text-anchor="${a}" dominant-baseline="middle">${tT(e||" ")}</text>`)}function t_(e){return String(Math.round(100*e)/100)}function tT(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function tR(e,t,i,n=tL){let a=[...e.images.flatMap((i,a)=>{var r,o,s,l;let d,c;return tE(e,i,n)?[(r=e,o=i,s=a,l=t,d=tB(r,o),c=o.note.trim(),[l("imageNumber",{index:s+1}),...c?[l("note",{note:c})]:[],l("visualWeight",{weight:tU(o.weight,l)}),`- ${l("referencePosition",d)}`,`- ${l("referenceSize",d)}`])]:[]}),...e.rectangles.flatMap((i,a)=>{var r,o,s,l;let d,c;return tE(e,i,n)?[(r=e,o=i,s=a,l=t,d=tB(r,o),c=o.note.trim(),[l("regionNumber",{index:s+1}),...c?[l("note",{note:c})]:[],l("visualWeight",{weight:tU(o.weight,l)}),`- ${l("referencePosition",d)}`,`- ${l("referenceSize",d)}`])]:[]}),...e.texts.flatMap((i,a)=>{var r,o,s,l;let d,c;return tE(e,i,n)?[(r=e,o=i,s=a,l=t,d=tO(r,o),c=o.note.trim(),[l("textNumber",{index:s+1}),l("displayText",{text:JSON.stringify(o.text)}),...c?[l("note",{note:c})]:[],l("visualWeight",{weight:tU(o.weight,l)}),`- ${l("referencePosition",d)}`,`- ${l("referenceFontSize",{fontSize:Math.max(1,Math.round(o.fontSize))})}`])]:[]})];return[t("staticTitle"),"",t("canvasSize",{width:Math.round(e.frame.width),height:Math.round(e.frame.height)}),"",...tq(!1,t),...tD(e.overallNote,t),...i?.trim()?["",i.trim()]:[],...a.length?["",t("elementsHeading")]:[],...a.flatMap(e=>["",...e])].join("\n").trimEnd()}function tE(e,t,i){if(!t.visible)return!1;let n="text"in t?i(t):t,a=e.frame;return n.x<a.x+a.width&&n.x+n.width>a.x&&n.y<a.y+a.height&&n.y+n.height>a.y}function tq(e,t){return[t("layoutHeading"),t("canvasOrigin"),t("referenceValues"),t("perceptibleElementGuidance"),t("flexibleImplementation"),...e?[t("motionStateGuidance")]:[]]}function tD(e,t){let i=e.trim();return i?["",t("globalNoteHeading"),i]:[]}function tz(e,t,i,n,a){return[...i!==n?[a(n?"changeVisible":"changeHidden")]:[],...e.x!==t.x||e.y!==t.y?[a("referencePosition",t)]:[],...e.width!==t.width||e.height!==t.height?[a("referenceSize",t)]:[]]}function tB(e,t){return{x:Math.round(t.x-e.frame.x),y:Math.round(t.y-e.frame.y),width:Math.max(1,Math.round(t.width)),height:Math.max(1,Math.round(t.height))}}function tO(e,t){let i=tL(t);return{x:Math.round(t.x-e.frame.x),y:Math.round(t.y-e.frame.y),width:Math.max(1,Math.round(i.width)),height:Math.max(1,Math.round(i.height))}}function tU(e,t){return({auto:t("weightAuto"),high:t("weightHigh"),medium:t("weightMedium"),low:t("weightLow"),decorative:t("weightDecorative")})[e]}async function tJ(e,t){var i;let n,a,r=await tW(e,t);return navigator.clipboard?.write&&"u">typeof ClipboardItem?(await navigator.clipboard.write([new ClipboardItem({"image/png":r})]),"copied"):(i=r,n=URL.createObjectURL(i),(a=document.createElement("a")).href=n,a.download="ui-sketch.png",a.click(),URL.revokeObjectURL(n),"downloaded")}async function tW(e,t){let i,n,a,r,o,s=new Blob([(i=Math.max(1,Math.round(e.frame.width)),n=Math.max(1,Math.round(e.frame.height)),a=e.rectangles.filter(e=>e.visible).map(t=>{let i=t.x-e.frame.x,n=t.y-e.frame.y,a=t.note.trim();return{id:t.id,svg:[`<rect x="${t_(i)}" y="${t_(n)}" width="${t_(t.width)}" height="${t_(t.height)}" rx="8" fill="#eef5ff" stroke="#1677ff" stroke-width="2"/>`,...a?tF(a,i+t.width/2,n+t.height/2,14,"middle",!0):[]].join("")}}),r=e.images.filter(e=>e.visible).map(i=>{let n=i.x-e.frame.x,a=i.y-e.frame.y,r=i.assetId?t?.(i.assetId):void 0;if(!r)return{id:i.id,svg:`<rect data-element-kind="image" x="${t_(n)}" y="${t_(a)}" width="${t_(i.width)}" height="${t_(i.height)}" fill="#eeeeee" stroke="#8f8f8f" stroke-width="2"/>`};let o=i.crop,s=o?n-o.x/o.width*i.width:n,l=o?a-o.y/o.height*i.height:a,d=o?i.width/o.width:i.width,c=o?i.height/o.height:i.height,u=`ui-image-${i.id.replace(/[^a-zA-Z0-9_-]/g,"-")}`;return{id:i.id,svg:`<g data-element-kind="image"><defs><clipPath id="${u}"><rect x="${t_(n)}" y="${t_(a)}" width="${t_(i.width)}" height="${t_(i.height)}"/></clipPath></defs><image href="${tT(r)}" x="${t_(s)}" y="${t_(l)}" width="${t_(d)}" height="${t_(c)}" preserveAspectRatio="${o?"none":"xMidYMid slice"}" clip-path="url(#${u})"/></g>`}}),o=e.texts.filter(e=>e.visible).map(t=>({id:t.id,svg:tF(t.text,t.x-e.frame.x,t.y-e.frame.y,t.fontSize,"start",!1).join("")})),[`<svg xmlns="http://www.w3.org/2000/svg" width="${i}" height="${n}" viewBox="0 0 ${i} ${n}">`,'<rect width="100%" height="100%" fill="#ffffff"/>','<g font-family="Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif" fill="#1f1f1f">',...(0,v.jQ)([...r,...a,...o],e.layerOrder,e=>e.id).map(e=>e.svg),"</g>","</svg>"].join(""))],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(s);try{var d,c;let t=await (d=l,new Promise((e,t)=>{let i=new Image;i.onload=()=>e(i),i.onerror=()=>t(Error("浏览器未能渲染 UI 界面。")),i.src=d})),i=document.createElement("canvas");i.width=Math.max(1,Math.round(e.frame.width)),i.height=Math.max(1,Math.round(e.frame.height));let n=i.getContext("2d");if(!n)throw Error("浏览器未能创建草图画布。");return n.drawImage(t,0,0,i.width,i.height),await (c=i,new Promise((e,t)=>{c.toBlob(i=>{i?e(i):t(Error("浏览器未能生成 UI 界面预览图。"))},"image/png")}))}finally{URL.revokeObjectURL(l)}}new tm.Ajv2020({allErrors:!0}).compile(tN),i(37588);let tH="frame:ui",tY="application/x-human2ai-ui-sketch",tV={rectangle:{shape:"rectangle",width:280,height:108},image:{shape:"rectangle",width:320,height:180},text:{shape:"rectangle",width:84,height:20,clickOnly:!0}},tX={...x,canvas:"UI 界面画布",canvasViewport:"UI 界面无限画布",scene:"UI 界面场景",region:"区域",addRegion:"添加区域",text:"文字",addText:"添加文字",image:"图片",addImage:"添加图片",newText:"文字",overallNote:"全局备注",clearCanvas:"清空画布",clearCanvasConfirmTitle:"确认清空画布?",clearCanvasConfirmDescription:"将移除全部区域、文字和图片。",clearCanvasCancel:"取消",groupItems:"建组",ungroupItems:"解组",copyGroup:"复制",copyPrompt:"复制提示词",copySketch:"复制预览图",copyAllStages:"动效",overallNoteTitle:"对整个界面的要求",overallNotePlaceholder:"例如:整体保持安静,突出当前任务和主要操作",overallNoteAriaLabel:"UI 界面的全局备注",fitFrame:"适应界面范围",interactionHelp:"选择节点工具后,单击放置;形状和图片可拖动确定尺寸;Esc 取消。滚轮缩放;按住右键,或空格键加左键拖动画布。",sideActions:"UI 界面操作",collapseSideActions:"收起 UI 界面操作",expandSideActions:"展开 UI 界面操作",frameAction:"移动或调整界面范围",frameRange:"界面范围",missingRegionNote:"未填写备注",editRegionNote:"编辑区域信息",editText:"编辑文字",nodeDescription:"节点说明",originUser:"user",originAgent:"agent",originImport:"import",note:"备注",textContent:"显示文字",regionPlaceholder:"这个区域表达什么布局内容",textPlaceholder:"输入文字",textNotePlaceholder:"这段文字表达什么",imageNotePlaceholder:"说明这个图片节点表达什么",shapeKind:"形状",emptyText:"---文字未输入---",visualWeight:"视觉权重",visibility:"显示状态",visible:"显示",hidden:"隐藏",weightAuto:"自动",weightHigh:"高",weightMedium:"中",weightLow:"低",weightDecorative:"装饰",fontSize:"字号",decreaseFontSize:"减小字号",increaseFontSize:"增大字号",cancel:"取消",deleteRegion:"删除区域",deleteText:"删除文字",deleteNode:"删除节点",confirmDeleteRegion:"确认删除这个区域?",confirmDeleteText:"确认删除这段文字?",confirmDeleteNode:"确认删除这个节点?",cancelDelete:"保留",promptUnsupported:"当前浏览器不支持复制提示词。",promptCopied:"复制成功",promptCopyFailed:"复制提示词失败。",sketchCopied:"复制成功",sketchDownloaded:"浏览器不支持复制图片,预览图已下载",sketchCopyFailed:"复制预览图失败。",selectedItemsPrefix:"已选择 ",selectedItemsSuffix:" 个元素",noSelection:"未选择元素"};function tG({interactionResetKey:e,draft:t,activeStageId:i=tb,onDraftChange:d,writePrompt:c,writeSketch:m,translatePrompt:p,resolveStylePrompt:x,toolHost:w=null,clearActionHost:j=null,showCanvasTools:I=!0,canvasSideActionPanelDefaultCollapsed:S=!1,interfaceFrameLocked:P=!1,labels:L,imageEditorLabels:N,resolveImageSource:$,onImageUpload:F,onReadImageFile:_,className:E,style:D,"aria-label":z}){var B,U;let J={...tX,...L},W={content:"图片内容",upload:"上传图片",download:"下载图片",downloading:"正在下载",downloadFailed:"图片下载失败,请重试。",replace:"替换图片",uploading:"正在上传",uploadFailed:"上传失败,请重试",fileTypes:"支持 PNG、JPEG、WebP、SVG,最大 10 MB",cropTitle:"裁剪图片",cropLoadFailed:"图片加载失败",svgSource:"SVG 源码",svgPaste:"粘贴 SVG",svgApply:"使用 SVG",svgSaveFailed:"SVG 保存失败,请检查代码后重试。",svgCopy:"复制源码",svgCopying:"正在复制源码",svgCopyFailed:"源码复制失败",sourceLoading:"正在读取图片内容",sourceLoadFailed:"图片内容读取失败,请重试。",svgCopied:"已复制",cancel:"取消",retry:"重试",...N},Y=(0,u.useId)(),V=(0,u.useMemo)(()=>tj(t,i),[i,t]),[G,K]=(0,u.useState)(null),[Z,Q]=(0,u.useState)([]),[et,ei]=(0,u.useState)(null),[en,ea]=(0,u.useState)(null),[er,eo]=(0,u.useState)(!1),[ed,ec]=(0,u.useState)(null),[eh,ep]=(0,u.useState)(null),[eg,ef]=(0,u.useState)(!1),[ex,eb]=(0,u.useState)(!1),[ev,ew]=(0,u.useState)(null),{contextMenuOpen:ek,contextMenuPoint:eI,contextMenuPopupRef:eS,openContextMenuAt:eP,closeContextMenu:eC,dismissContextMenu:eM}=b(),[eA,eL]=(0,u.useState)({}),[eN,e$]=(0,u.useState)(null),eF=(0,u.useRef)(null),e_=(0,u.useRef)(null),eT=(0,u.useRef)(null),eR=(0,u.useRef)(!1),eE=(0,u.useRef)(!1),eq=(0,u.useRef)(null),eD=(0,u.useRef)(""),ez=(0,u.useRef)(0),eB=tg(t),eO=eB.length>1,eU=[{value:"auto",label:J.weightAuto},{value:"high",label:J.weightHigh},{value:"medium",label:J.weightMedium},{value:"low",label:J.weightLow},{value:"decorative",label:J.weightDecorative}],eJ=Z.filter(tQ),eW=new Set(eJ),eH=eJ.length>1?function(e,t,i){let n=t.map(t=>t3(e,t,i)).filter(e=>!!e);if(!n.length)return null;let a=Math.min(...n.map(e=>e.x)),r=Math.min(...n.map(e=>e.y));return{x:a,y:r,width:Math.max(...n.map(e=>e.x+e.width))-a,height:Math.max(...n.map(e=>e.y+e.height))-r}}(V,eJ,eA):null,eY=et?t2(V,et):null,eV=(0,u.useRef)({updateImage:tm,interactionResetKey:e});(0,u.useLayoutEffect)(()=>{eV.current={updateImage:tm,interactionResetKey:e}});let eX=O({disabled:!d||!!et||er,resetKey:`${e}:${i}`,labels:W,onUpload:F,onImageReady:({assetId:e,x:t,y:i,width:n,height:a})=>{e2({x:t-n/2,y:i-a/2,width:n,height:a},e),K(null)},onCopy:function(e){let t;if(!e.clipboardData||0===eJ.length)return;let i=(t=new Set(tl(V,eG)),structuredClone({rectangles:V.rectangles.filter(e=>t.has(e.id)),texts:V.texts.filter(e=>t.has(e.id)),images:V.images.filter(e=>t.has(e.id)),groups:V.groups.filter(e=>e.itemIds.every(e=>t.has(e))),layerOrder:tc(V).filter(e=>t.has(e))}));0!==i.layerOrder.length&&(eq.current=i,eD.current=tK("ui-sketch-clipboard"),ez.current=0,e.clipboardData.setData(tY,eD.current),e.preventDefault(),e.stopPropagation())},onPasteFallback:function(e){if(e.defaultPrevented||!d||!eq.current||e.clipboardData?.getData(tY)!==eD.current)return;e.preventDefault(),e.stopPropagation();let n=ez.current+1,a=function(e,t,i,n=tb){if(0===t.layerOrder.length)return{draft:e,ids:[]};let a=tj(e,n),r=new Set([...a.rectangles,...a.texts,...a.images,...a.groups,...t.rectangles,...t.texts,...t.images,...t.groups].map(e=>e.id)),o=new Map;function s(e){let t=1;for(;r.has(`${e}-${t}`);)t+=1;let i=`${e}-${t}`;return r.add(i),i}function l(e,t){return e.map(e=>{let n=s(t);return o.set(e.id,n),{...structuredClone(e),id:n,origin:"user",x:e.x+i.x,y:e.y+i.y}})}a.rectangles.push(...l(t.rectangles,"rectangle")),a.texts.push(...l(t.texts,"text")),a.images.push(...l(t.images,"image")),a.groups.push(...t.groups.map(e=>({id:s("group"),itemIds:e.itemIds.map(e=>o.get(e))})));let d=t.layerOrder.map(e=>o.get(e));return a.layerOrder=[...tc(e),...d],{draft:tI(e,n,a),ids:d}}(t,eq.current,{x:24*n,y:24*n},i);if(0===a.ids.length)return;ez.current=n,tp(),K(null),d(a.draft);let r=new Set(a.ids);Q([...a.draft.rectangles.filter(e=>r.has(e.id)).map(e=>tZ("rectangle",e.id)),...a.draft.texts.filter(e=>r.has(e.id)).map(e=>tZ("text",e.id)),...a.draft.images.filter(e=>r.has(e.id)).map(e=>tZ("image",e.id))])}}),eG=eJ.map(t0),eK=V.groups.filter(e=>e.itemIds.some(e=>eG.includes(e))),eZ=eG.length>=2&&!V.groups.some(e=>e.itemIds.length===eG.length&&e.itemIds.every(e=>eG.includes(e)));function eQ(e){d&&d(tI(t,i,"function"==typeof e?e(V):e))}function e0(e){tp(),eo(!1),K(t=>t===e?null:e)}function e1({bounds:e}){var t,i;"rectangle"===G&&(t=e,eQ(e=>{let i={id:tK("rectangle"),x:Math.round(t.x),y:Math.round(t.y),width:Math.round(t.width),height:Math.round(t.height),note:"",annotation:"",semanticType:"",origin:"user",visible:!0,weight:"auto"};return Q([tZ("rectangle",i.id)]),{...e,rectangles:[...e.rectangles,i]}})),"image"===G&&e2(e),"text"===G&&(i=e,eQ(e=>{let t={id:tK("text"),x:Math.round(i.x),y:Math.round(i.y),text:J.newText,fontSize:14,note:"",annotation:"",semanticType:"",origin:"user",visible:!0,weight:"auto"};return Q([tZ("text",t.id)]),ei(tZ("text",t.id)),ea({kind:"text",item:t}),{...e,texts:[...e.texts,t]}})),K(null),eR.current=!0,window.setTimeout(()=>{eR.current=!1},0)}function e2(e,t=null){eQ(i=>{let n={id:tK("image"),x:Math.round(e.x),y:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height),note:"",annotation:"",semanticType:"",origin:"user",visible:!0,weight:"auto",assetId:t,crop:null};return Q([tZ("image",n.id)]),{...i,images:[...i.images,n]}})}function e3(e){return{annotation:e.annotation,displayText:"text"in e?e.text:void 0,note:e.note,labels:{nodeDescription:J.nodeDescription,displayText:J.textContent,note:J.note}}}function e5(e,t){if(eE.current){eE.current=!1;return}Q(t.shiftKey?ii(eJ,t1(V,[e])):t1(V,[e]))}function e4(e){if(!(e.target instanceof Element))return;let t=e.target.closest("[data-ui-sketch-item]"),i=t?.dataset.uiSketchItem;i&&tQ(i)&&!eW.has(i)?Q(t1(V,[i])):e.target.closest("[data-canvas-frame]")&&Q([tH]),eP(e,t??e_.current?.querySelector("[data-ui-sketch-scene]")??null)}function e8(e,t){let i=eJ.length>1&&eW.has(e)?eJ:t1(V,[e]);eQ(e=>t9(e,i,t))}function e6(e){e9(eJ.length>1&&eW.has(e)?eJ:t1(V,[e]))}function e9(e){eQ(t=>{var i,n,a;let r,o,s;return i=t,o=new Set(n=e),s=new Set(n.map(t0)),{...i,groups:(a=i.groups,r=new Set([...i.rectangles,...i.texts,...i.images].filter(e=>!s.has(e.id)).map(e=>e.id)),a.map(e=>({...e,itemIds:e.itemIds.filter(e=>r.has(e))})).filter(e=>e.itemIds.length>=2)),rectangles:i.rectangles.filter(e=>!o.has(tZ("rectangle",e.id))),images:i.images.filter(e=>!o.has(tZ("image",e.id))),texts:i.texts.filter(e=>!o.has(tZ("text",e.id)))}}),Q([]),ei(null),ea(null)}function e7(e){eQ(t=>({...t,frame:{x:Math.round(e.sourcePosition.x+e.bounds.x),y:Math.round(e.sourcePosition.y+e.bounds.y),width:Math.max(10,Math.round(e.bounds.width)),height:Math.max(10,Math.round(e.bounds.height))}}))}function te(e){eQ(t=>({...t,frame:{...t.frame,x:Math.round(e.bounds.x),y:Math.round(e.bounds.y)}}))}function tt(e,t){eQ(i=>({...i,rectangles:i.rectangles.map(i=>i.id===e?{...i,...t}:i)}))}function ti(e,t){eQ(i=>({...i,texts:i.texts.map(i=>i.id===e?{...i,...t}:i)}))}function tm(e,t){eQ(i=>({...i,images:i.images.map(i=>i.id===e?{...i,...t}:i)}))}function th(e){let t=t2(V,e);t&&(ei(e),"rectangle"===t.kind?ea({kind:"rectangle",item:{...t.item}}):"text"===t.kind?ea({kind:"text",item:{...t.item}}):ea({kind:"image",item:{...t.item,crop:t.item.crop?{...t.item.crop}:null}}))}function tp(){ei(null),ea(null)}function tf(e){en&&(ea(t=>t?("rectangle"===t.kind||t.kind,{...t,item:{...t.item,...e}}):null),"rectangle"===en.kind?tt(en.item.id,e):"text"===en.kind?ti(en.item.id,e):tm(en.item.id,e))}function ty(e){en?.kind==="text"&&(ea(t=>t?.kind==="text"?{...t,item:{...t.item,...e}}:t),ti(en.item.id,e))}function tx(e){if(!(e.target instanceof Element)||0!==e.button||e.target.closest("[data-resize-handle]")||e.target.closest("[data-canvas-frame]"))return;eR.current=!1,eE.current=!1;let t=ie(e,e.currentTarget),i=e.target.closest("[data-ui-sketch-item]"),n=i?.dataset.uiSketchItem;if(n&&tQ(n)&&t2(V,n)){if(!d)return;let i=eW.has(n)?eJ:t1(V,[n]);eF.current={type:"move-items",pointerId:e.pointerId,keys:i,scene:e.currentTarget,previewElements:Array.from(e.currentTarget.querySelectorAll("[data-ui-sketch-preview], [data-ui-sketch-multi-selection]")).filter(e=>i.includes(e.dataset.uiSketchPreview)||i.length>1&&e.hasAttribute("data-ui-sketch-multi-selection")),delta:{x:0,y:0},animationFrame:null,start:t,startClient:{x:e.clientX,y:e.clientY},moved:!1}}else eF.current={type:"marquee",pointerId:e.pointerId,start:t,startClient:{x:e.clientX,y:e.clientY},moved:!1,sourceSelectedKeys:eJ,additive:e.shiftKey},tp()}function tv(e){let t=eF.current;if(!t||t.pointerId!==e.pointerId)return;let i=ie(e,e.currentTarget);if("marquee"===t.type){if(!t.moved&&3>Math.hypot(e.clientX-t.startClient.x,e.clientY-t.startClient.y))return;t.moved||(t.moved=!0,it(e.currentTarget,e.pointerId)),e.preventDefault(),eR.current=!0,ec(t7(t.start,i));return}!t.moved&&3>Math.hypot(e.clientX-t.startClient.x,e.clientY-t.startClient.y)||(t.moved||(t.moved=!0,e.currentTarget.setAttribute("data-canvas-dragging","node"),it(e.currentTarget,e.pointerId)),e.preventDefault(),eR.current=!0,eE.current=!0,t.delta={x:Math.round(i.x-t.start.x),y:Math.round(i.y-t.start.y)},null===t.animationFrame&&(t.animationFrame=requestAnimationFrame(()=>{t.animationFrame=null;let e=`translate(${t.delta.x} ${t.delta.y})`;t.previewElements.forEach(t=>t.setAttribute("transform",e))})))}function tk(e){let t=eF.current;if(t&&t.pointerId===e.pointerId){if("marquee"===t.type){var i,n,a;let r=t.moved?t1(V,(i=V,n=t7(t.start,ie(e,e.currentTarget)),a=eA,[...i.images.map(e=>tZ("image",e.id)),...i.rectangles.map(e=>tZ("rectangle",e.id)),...i.texts.map(e=>tZ("text",e.id))].filter(e=>{var t,r;let o=t3(i,e,a);return!!o&&(t=o,r=n,t.x<=r.x+r.width&&t.x+t.width>=r.x&&t.y<=r.y+r.height&&t.y+t.height>=r.y)}))):[];Q(0===r.length?[]:t.additive?ii(t.sourceSelectedKeys,r):r),ec(null)}else if(t6(t),t.moved){let i=ie(e,e.currentTarget),n={x:Math.round(i.x-t.start.x),y:Math.round(i.y-t.start.y)};(0!==n.x||0!==n.y)&&eQ(e=>t9(e,t.keys,n))}eF.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),window.setTimeout(()=>{eR.current=!1,eE.current=!1},0)}}function tS(e){let t=eF.current;t&&t.pointerId===e.pointerId&&("move-items"===t.type&&t6(t),eF.current=null,ec(null),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))}async function tP(e){if(c)await c(e);else{if(!navigator.clipboard?.writeText)throw Error(J.promptUnsupported);await navigator.clipboard.writeText(e)}ep({type:"success",message:J.promptCopied})}async function tC(e){let i=tj(t,e);ep("downloaded"===(m?await m(tw(i)):await tJ(i,$))?{type:"warning",message:J.sketchDownloaded}:{type:"success",message:J.sketchCopied})}async function tM(e){ef(!0);try{let i=await x?.(),n=e=>t5(e,eA);await tP("all"===e?function(e,t,i,n=tL){let a=tg(e);return 1===a.length?tR(tj(e,a[0].id),t,i,n):a.slice(1).map((r,o)=>{var s,l,d,c,u,m;let h,p,g,f,y,x,b=a[o];return s=e,l=b.id,d=r.id,c=(e,i)=>{let n;return"startState"===e||"endState"===e?t("stateHeading",{name:(n="startState"===e?b:r).name??t("stateName",{number:n.number})}):t(e,i)},u=i,m=n,h=tj(s,l),p=tj(s,d),g=new Map(p.rectangles.map(e=>[e.id,e])),f=new Map(p.texts.map(e=>[e.id,e])),y=new Map(p.images.map(e=>[e.id,e])),x=[...h.images.flatMap((e,t)=>{var i,n,a,r,o,s;let l,d,u,g,f=y.get(e.id);return f&&(tE(h,e,m)||tE(p,f,m))?[(i=h,n=p,a=e,r=f,o=t,s=c,l=tB(i,a),d=tB(n,r),u=a.note.trim(),g=tz(l,d,a.visible,r.visible,s),[s("imageNumber",{index:o+1}),...u?[s("note",{note:u})]:[],s("visualWeight",{weight:tU(a.weight,s)}),s("startState"),` - ${s(a.visible?"visible":"hidden")}`,` - ${s("referencePosition",l)}`,` - ${s("referenceSize",l)}`,...g.length?[s("endState"),...g.map(e=>` - ${e}`)]:[]])]:[]}),...h.rectangles.flatMap((e,t)=>{var i,n,a,r,o,s;let l,d,u,f,y=g.get(e.id);return y&&(tE(h,e,m)||tE(p,y,m))?[(i=h,n=p,a=e,r=y,o=t,s=c,l=tB(i,a),d=tB(n,r),u=a.note.trim(),f=tz(l,d,a.visible,r.visible,s),[s("regionNumber",{index:o+1}),...u?[s("note",{note:u})]:[],s("visualWeight",{weight:tU(a.weight,s)}),s("startState"),` - ${s(a.visible?"visible":"hidden")}`,` - ${s("referencePosition",l)}`,` - ${s("referenceSize",l)}`,...f.length?[s("endState"),...f.map(e=>` - ${e}`)]:[]])]:[]}),...h.texts.flatMap((e,t)=>{var i,n,a,r,o,s,l,d,u,g,y;let x,b,v,w,j=f.get(e.id);return j&&(tE(h,e,m)||tE(p,j,m))?[(i=h,n=p,a=e,r=j,o=t,s=c,x=tO(i,a),b=tO(n,r),v=a.note.trim(),w=(l=x,d=b,u=a,g=r,y=s,[...u.visible!==g.visible?[y(g.visible?"changeVisible":"changeHidden")]:[],...l.x!==d.x||l.y!==d.y?[y("referencePosition",d)]:[],...Math.round(u.fontSize)!==Math.round(g.fontSize)?[y("referenceFontSize",{fontSize:Math.max(1,Math.round(g.fontSize))})]:[]]),[s("textNumber",{index:o+1}),s("displayText",{text:JSON.stringify(a.text)}),...v?[s("note",{note:v})]:[],s("visualWeight",{weight:tU(a.weight,s)}),s("startState"),` - ${s(a.visible?"visible":"hidden")}`,` - ${s("referencePosition",x)}`,` - ${s("referenceFontSize",{fontSize:Math.max(1,Math.round(a.fontSize))})}`,...w.length?[s("endState"),...w.map(e=>` - ${e}`)]:[]])]:[]})],[c("motionTitle"),"",c("canvasSize",{width:Math.round(s.frame.width),height:Math.round(s.frame.height)}),"",...tq(x.length>0,c),...tD(s.overallNote,c),...u?.trim()?["",u.trim()]:[],...x.length?["",c("elementsHeading")]:[],...x.flatMap(e=>["",...e]),...x.length?["",c("motionClosing")]:[]].join("\n").trimEnd()}).join("\n\n")}(t,p,i,n):tR(tj(t,e),p,i,n))}catch(e){ep({type:"error",message:e instanceof Error?e.message:J.promptCopyFailed})}finally{ef(!1)}}async function tA(e){eb(!0);try{await tC(e)}catch(e){ep({type:"error",message:e instanceof Error?e.message:J.sketchCopyFailed})}finally{eb(!1)}}(0,u.useEffect)(()=>{if(!eh)return;let e=window.setTimeout(()=>ep(null),2e3);return()=>window.clearTimeout(e)},[eh]),(0,u.useEffect)(()=>{eO||ew(null)},[eO]),(0,u.useLayoutEffect)(()=>{if(void 0===e)return;let t=eF.current;t?.type==="move-items"&&t6(t),eF.current=null,Q([]),ei(null),ea(null),K(null),eo(!1),ec(null),eM()},[e]),(0,u.useLayoutEffect)(()=>{K(null),eM()},[i]),(0,u.useLayoutEffect)(()=>()=>{let e=eF.current;e?.type==="move-items"&&(t6(e),eF.current=null)},[i]);let tN=(0,n.jsxs)("label",{className:"human2ai-ui-sketch-canvas__overall-editor",children:[(0,n.jsx)("span",{children:J.overallNoteTitle}),(0,n.jsx)(l.A.TextArea,{name:"overallNote",autoFocus:!0,autoSize:{minRows:4,maxRows:8},value:V.overallNote,placeholder:J.overallNotePlaceholder,"aria-label":J.overallNoteAriaLabel,onChange:e=>eQ(t=>({...t,overallNote:e.target.value}))})]}),tF=eB.map(e=>({key:e.id,label:e.name??p("stateName",{number:e.number})})),t_=(0,n.jsxs)("div",{className:"human2ai-ui-sketch-canvas__tool-groups",role:"group","aria-label":J.sideActions,"data-ui-sketch-tool-groups":!0,children:[(0,n.jsxs)("div",{className:"human2ai-ui-sketch-canvas__tool-group","data-ui-sketch-tool-group":"elements",children:[(0,n.jsx)(ey.u,{icon:(0,n.jsx)(tn.A,{"aria-hidden":"true"}),label:J.region,collapsedLabel:J.addRegion,"aria-current":"rectangle"===G||void 0,textColor:"rectangle"===G?"color.action.primary":"color.text.primary",disabled:!d,onClick:()=>e0("rectangle")}),(0,n.jsx)(ey.u,{icon:(0,n.jsx)(ta.A,{"aria-hidden":"true"}),label:J.text,collapsedLabel:J.addText,"aria-current":"text"===G||void 0,textColor:"text"===G?"color.action.primary":"color.text.primary",disabled:!d,onClick:()=>e0("text")}),(0,n.jsx)(ey.u,{icon:(0,n.jsx)(tr.A,{"aria-hidden":"true"}),label:J.image,collapsedLabel:J.addImage,"aria-current":"image"===G||void 0,textColor:"image"===G?"color.action.primary":"color.text.primary",disabled:!d,onClick:()=>e0("image")})]}),(0,n.jsx)("div",{className:"human2ai-ui-sketch-canvas__tool-group","data-ui-sketch-tool-group":"overall-note",children:(0,n.jsx)(ts.A,{content:tN,trigger:"click",placement:"leftTop",open:er,onOpenChange:eo,children:(0,n.jsx)("span",{className:"human2ai-ui-sketch-canvas__side-action",children:(0,n.jsx)(ey.u,{icon:(0,n.jsx)(to.A,{"aria-hidden":"true"}),label:J.overallNote})})})}),(0,n.jsxs)("div",{className:"human2ai-ui-sketch-canvas__tool-group","data-ui-sketch-tool-group":"copy",children:[(0,n.jsx)("span",{className:"human2ai-ui-sketch-canvas__tool-group-title",children:J.copyGroup}),eO?(0,n.jsx)(a.A,{trigger:["click"],open:"prompt"===ev,destroyOnHidden:!0,onOpenChange:e=>ew(t=>e?"prompt":"prompt"===t?null:t),menu:{items:[...tF,{type:"divider"},{key:"all",label:J.copyAllStages}],onClick:({key:e})=>{ew(null),tM(e)}},children:(0,n.jsx)("span",{className:"human2ai-ui-sketch-canvas__side-action",children:(0,n.jsx)(ey.u,{icon:(0,n.jsx)(H.A,{"aria-hidden":"true"}),label:J.copyPrompt,loading:eg})})}):(0,n.jsx)("span",{className:"human2ai-ui-sketch-canvas__side-action",children:(0,n.jsx)(ey.u,{icon:(0,n.jsx)(H.A,{"aria-hidden":"true"}),label:J.copyPrompt,loading:eg,onClick:()=>void tM(eB[0].id)})}),eO?(0,n.jsx)(a.A,{trigger:["click"],open:"sketch"===ev,destroyOnHidden:!0,onOpenChange:e=>ew(t=>e?"sketch":"sketch"===t?null:t),menu:{items:tF,onClick:({key:e})=>{ew(null),tA(e)}},children:(0,n.jsx)("span",{className:"human2ai-ui-sketch-canvas__side-action",children:(0,n.jsx)(ey.u,{icon:(0,n.jsx)(tr.A,{"aria-hidden":"true"}),label:J.copySketch,loading:ex})})}):(0,n.jsx)("span",{className:"human2ai-ui-sketch-canvas__side-action",children:(0,n.jsx)(ey.u,{icon:(0,n.jsx)(tr.A,{"aria-hidden":"true"}),label:J.copySketch,loading:ex,onClick:()=>void tA(eB[0].id)})})]})]}),tT=["human2ai-ui-sketch-canvas",E].filter(Boolean).join(" ");return(0,n.jsxs)("main",{...(0,k.Se)({namespace:"human2ai",id:"ui-sketch-canvas",name:"UiSketchCanvas",category:"module",origin:"project",status:"candidate"}),className:tT,style:D,"data-ui-sketch-canvas":!0,"aria-label":z??J.canvas,children:[eX.feedback,eh?(0,n.jsx)("div",{className:`human2ai-ui-sketch-canvas__notice human2ai-ui-sketch-canvas__notice--${eh.type}`,role:"status",children:eh.message}):null,(0,n.jsxs)("div",{ref:e_,className:"human2ai-ui-sketch-canvas__workspace",children:[(0,n.jsx)(a.A,{trigger:[],autoFocus:!0,open:ek,popupRender:e=>(0,n.jsx)("div",{ref:eS,children:e}),onOpenChange:e=>{e||eC()},menu:{items:[...v.JX.map(e=>({key:e,label:J[e],disabled:!d||tu(V,eG,e)===V})),{type:"divider"},{key:"group",label:J.groupItems,disabled:!d||!eZ},{key:"ungroup",label:J.ungroupItems,disabled:!d||0===eK.length}],onClick:({key:e})=>{let t=v.JX.find(t=>t===e);t?eQ(e=>tu(e,eG,t)):"group"===e&&eZ?eQ(e=>(function(e,t,i){let n=tl(e,t),a=new Set([...e.rectangles,...e.texts,...e.images].map(e=>e.id));if(n.length<2||n.some(e=>!a.has(e)))throw Error("A UI sketch group requires at least two existing items.");if(!i||a.has(i)||e.groups.some(e=>e.id===i))throw Error(`Duplicate or empty UI sketch group id: ${i}.`);return{...e,groups:[...td(e,n).groups,{id:i,itemIds:n}]}})(e,eG,tK("group"))):"ungroup"===e&&eK.length>0&&eQ(e=>td(e,eG)),eC()}},children:(0,n.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",left:eI.x,top:eI.y,width:1,height:1,pointerEvents:"none"}})}),(0,n.jsx)(ej,{onContextMenuRequest:e4,onCameraCenterChange:()=>eM(),onZoomChange:()=>eM(),defaultCameraCenter:{x:V.frame.x+V.frame.width/2,y:V.frame.y+V.frame.height/2},contentBounds:V.frame,backgroundPattern:"dots",sideActionPanelWidth:180,sideActionPanelDefaultCollapsed:S,sideActions:I?t_:void 0,"aria-label":J.canvasViewport,labels:{fitAll:J.fitFrame,interactionHelp:J.interactionHelp,sideActions:J.sideActions,collapseSideActions:J.collapseSideActions,expandSideActions:J.expandSideActions},children:e=>(0,n.jsxs)(el,{ref:eX.sceneRef,bounds:e.viewportBounds,className:"human2ai-ui-sketch-canvas__scene","aria-label":J.scene,"aria-keyshortcuts":d?"Control+C Meta+C Control+V Meta+V":void 0,"data-ui-sketch-scene":!0,tabIndex:-1,onPointerDownCapture:e=>e.currentTarget.focus(),onKeyDown:e=>{("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key)&&(e.preventDefault(),e4({target:e.target,clientX:e.target.getBoundingClientRect().x,clientY:e.target.getBoundingClientRect().y})),"Escape"===e.key&&eC()},onClickCapture:e=>{eR.current&&(e.stopPropagation(),eR.current=!1)},onClick:e=>{if(eR.current){eR.current=!1;return}e.target instanceof Element&&(e.target.closest("[data-ui-sketch-item]")||e.target.closest("[data-canvas-frame]")||e.target.closest("[data-resize-handle]"))||(Q([]),tp())},onPointerDown:tx,onPointerMove:tv,onPointerUp:tk,onPointerCancel:tS,onLostPointerCapture:tS,children:[(0,n.jsx)("rect",{className:"human2ai-ui-sketch-canvas__world-surface",x:e.viewportBounds.x,y:e.viewportBounds.y,width:e.viewportBounds.width,height:e.viewportBounds.height,"aria-hidden":"true"}),(0,n.jsx)(R,{controlsHost:V.layerOrder?eN:void 0,id:"ui-frame",label:J.frameAction,bounds:V.frame,selected:Z.includes(tH),resizeMode:"free",resizeCenter:{x:0,y:0},minimumWidth:10,minimumHeight:10,screenScale:e.zoom,resizeHitSize:32,locked:P,onSelect:()=>{Q([tH]),tp()},onMove:te,onResize:e7,className:"human2ai-ui-sketch-canvas__frame"}),(0,n.jsx)("g",{className:"human2ai-ui-sketch-canvas__frame-label",transform:`translate(${V.frame.x} ${V.frame.y-12})`,"aria-hidden":"true",children:(0,n.jsxs)("text",{children:[J.frameRange," \xb7 ",Math.round(V.frame.width)," \xd7 ",Math.round(V.frame.height)]})}),(0,v.jQ)([...V.images.map(t=>{let i=tZ("image",t.id),a=eW.has(i),r=t4(t),o=t.assetId?$?.(t.assetId):void 0;return(0,n.jsx)("g",{"data-ui-sketch-preview":i,children:(0,n.jsx)(A,{controlsHost:V.layerOrder?eN:void 0,id:t.id,label:`${J.image}:${t.note.trim()||J.image}`,tooltip:e3(t),x:r.x,y:r.y,selected:a,bounds:eH&&a?void 0:t8(t.width,t.height),resizeMode:"proportional",resizeCenter:{x:0,y:0},screenScale:e.zoom,minimumWidth:8,minimumHeight:8,showRotationHandle:!1,onSelect:(e,t)=>e5(i,t),onNudge:e=>e8(i,e),onResize:e=>{tm(t.id,{x:e.sourcePosition.x+e.bounds.x,y:e.sourcePosition.y+e.bounds.y,width:Math.max(8,e.bounds.width),height:Math.max(8,e.bounds.height)})},onDoubleClick:()=>th(i),onDelete:()=>e6(i),className:"human2ai-ui-sketch-canvas__item human2ai-ui-sketch-canvas__image","data-ui-sketch-item":i,"data-ui-sketch-kind":"image","data-ui-sketch-visible":t.visible,children:(0,n.jsx)(q,{src:o,alt:t.note||J.image,width:t.width,height:t.height,fit:"cover",crop:t.crop,status:o?"ready":"empty",emptyLabel:J.image})})},t.id)}),...V.rectangles.map((t,i)=>{let a=tZ("rectangle",t.id),r=eW.has(a),o=t4(t);return(0,n.jsx)("g",{"data-ui-sketch-preview":a,children:(0,n.jsx)(A,{controlsHost:V.layerOrder?eN:void 0,id:t.id,label:`${J.region}:${t.note.trim()||J.missingRegionNote}`,tooltip:e3(t),x:o.x,y:o.y,selected:r,bounds:eH&&r?void 0:t8(t.width,t.height),resizeMode:"free",resizeCenter:{x:0,y:0},screenScale:e.zoom,minimumWidth:8,minimumHeight:8,showRotationHandle:!1,onSelect:(e,t)=>e5(a,t),onNudge:e=>e8(a,e),onResize:e=>{tt(t.id,{x:Math.round(e.sourcePosition.x+e.bounds.x),y:Math.round(e.sourcePosition.y+e.bounds.y),width:Math.max(8,Math.round(e.bounds.width)),height:Math.max(8,Math.round(e.bounds.height))})},onDoubleClick:()=>th(a),onDelete:()=>e6(a),className:`human2ai-ui-sketch-canvas__item human2ai-ui-sketch-canvas__rectangle human2ai-ui-sketch-canvas__rectangle--tone-${i%6}`,"data-ui-sketch-item":a,"data-ui-sketch-kind":"rectangle","data-ui-sketch-visible":t.visible,children:(0,n.jsx)(T,{type:"rectangle",width:t.width,height:t.height,className:"human2ai-ui-sketch-canvas__rectangle-surface"})})},t.id)}),...V.texts.map(t=>{let i=tZ("text",t.id),a=eW.has(i),r=t5(t,eA),o=t4(r),s=0===t.text.length,l=s?J.emptyText:t.text;return(0,n.jsx)("g",{"data-ui-sketch-preview":i,children:(0,n.jsx)(A,{controlsHost:V.layerOrder?eN:void 0,id:t.id,label:`${J.text}:${l}`,tooltip:e3(t),x:o.x,y:o.y,selected:a,bounds:eH&&a?void 0:t8(r.width,r.height),resizeMode:"font-size",resizeCenter:{x:0,y:0},screenScale:e.zoom,minimumWidth:8,minimumHeight:8,showRotationHandle:!1,onSelect:(e,t)=>e5(i,t),onNudge:e=>e8(i,e),onResize:e=>{var i;let n,a;return i=t.id,n=function(e,t,i){let{sourceBounds:n,sourcePosition:a}=i;return[e,t,a.x,a.y,n.x,n.y,n.width,n.height].join(":")}(i,t.text,e),eT.current?.signature!==n&&(eT.current={signature:n,fontSize:t.fontSize}),a=e.bounds.width/Math.max(1,e.sourceBounds.width),void ti(i,{x:Math.round(e.sourcePosition.x+e.bounds.x),y:Math.round(e.sourcePosition.y+e.bounds.y),fontSize:Math.max(8,Math.round(eT.current.fontSize*a))})},onDoubleClick:()=>th(i),onDelete:()=>e6(i),className:"human2ai-ui-sketch-canvas__item human2ai-ui-sketch-canvas__text","data-ui-sketch-item":i,"data-ui-sketch-kind":"text","data-ui-sketch-visible":t.visible,children:(0,n.jsx)("g",{transform:`translate(${-r.width/2} ${-r.height/2})`,children:(0,n.jsx)(t$,{text:l,fontSize:t.fontSize,onBoundsChange:e=>{eL(i=>{let n=i[t.id];return n&&n.text===t.text&&n.fontSize===t.fontSize&&.01>Math.abs(n.width-e.width)&&.01>Math.abs(n.height-e.height)?i:{...i,[t.id]:{text:t.text,fontSize:t.fontSize,width:e.width,height:e.height}}})},className:["human2ai-ui-sketch-canvas__text-content",s?"human2ai-ui-sketch-canvas__text-content--empty":null].filter(Boolean).join(" ")})})})},t.id)})],V.layerOrder,e=>String(e.key)),eH?(0,n.jsx)("rect",{className:"human2ai-ui-sketch-canvas__multi-selection",x:eH.x,y:eH.y,width:eH.width,height:eH.height,"aria-hidden":"true","data-ui-sketch-multi-selection":!0}):null,ed?(0,n.jsx)("rect",{className:"human2ai-ui-sketch-canvas__marquee",x:ed.x,y:ed.y,width:ed.width,height:ed.height,"aria-hidden":"true","data-ui-sketch-marquee":!0}):null,V.layerOrder?(0,n.jsx)("rect",{"data-canvas-layer-frame":!0,className:"human2ai-canvas-shape human2ai-canvas-frame__border",x:V.frame.x,y:V.frame.y,width:V.frame.width,height:V.frame.height,"aria-hidden":"true"}):null,(0,n.jsx)("g",{ref:e$,"data-canvas-controls-layer":!0}),G&&d?(0,n.jsx)(es,{tool:tV[G],viewportBounds:e.viewportBounds,onPlace:e1,onCancel:()=>K(null)},`${i}:${G}`):null]})}),et&&eY&&en?(0,n.jsxs)(y,{open:!0,title:"rectangle"===en.kind?J.editRegionNote:"text"===en.kind?J.editText:J.image,selectedText:"rectangle"===eY.kind?eY.item.note.trim()||J.missingRegionNote:"text"===eY.kind?eY.item.text||J.emptyText:eY.item.note.trim()||J.image,selectedTextLabel:"rectangle"===eY.kind?J.region:"text"===eY.kind?J.text:J.image,saveLabel:"",cancelLabel:J.cancel,onCancel:tp,onSave:()=>void 0,deleteAction:{label:"rectangle"===en.kind?J.deleteRegion:"text"===en.kind?J.deleteText:J.deleteNode,confirmTitle:"rectangle"===en.kind?J.confirmDeleteRegion:"text"===en.kind?J.confirmDeleteText:J.confirmDeleteNode,confirmCancelLabel:J.cancelDelete,onConfirm:()=>e9([et])},children:[(0,n.jsx)("span",{hidden:!0,"data-ui-sketch-mark-editor":!0,"data-human2ai-auto-save-node-editor":!0}),(0,n.jsxs)("div",{className:["human2ai-ui-sketch-canvas__editor-layout","image"===en.kind?"human2ai-ui-sketch-canvas__editor-layout--image":null].filter(Boolean).join(" "),"data-human2ai-image-editor-layout":"image"===en.kind?"true":void 0,children:[(0,n.jsxs)("div",{className:"human2ai-ui-sketch-canvas__editor-primary-fields",children:[(0,n.jsx)("div",{className:"human2ai-ui-sketch-canvas__editor-origin-row",children:(0,n.jsx)("span",{className:"human2ai-ui-sketch-canvas__editor-origin","data-ui-sketch-origin":en.item.origin,children:(B=en.item.origin,U=J,"agent"===B?U.originAgent:"import"===B?U.originImport:U.originUser)})}),en.item.annotation.trim()?(0,n.jsx)(f,{label:J.nodeDescription,children:(0,n.jsx)("p",{className:"human2ai-ui-sketch-canvas__node-description","data-ui-sketch-node-description":!0,children:en.item.annotation})}):null,"text"===en.kind?(0,n.jsx)(f,{label:J.textContent,children:(0,n.jsx)(l.A,{autoFocus:!0,name:"textContent",value:en.item.text,placeholder:J.textPlaceholder,"aria-label":J.textContent,onChange:e=>ty({text:e.target.value})})}):null,(0,n.jsx)(f,{label:J.note,children:(0,n.jsx)(g,{autoFocus:"text"!==en.kind,name:"nodeNote",value:en.item.note,placeholder:"rectangle"===en.kind?J.regionPlaceholder:"text"===en.kind?J.textNotePlaceholder:J.imageNotePlaceholder,"aria-label":J.note,onChange:e=>tf({note:e.target.value})})}),(0,n.jsxs)("div",{className:"human2ai-ui-sketch-canvas__editor-properties",children:[(0,n.jsx)(f,{label:J.visualWeight,children:(0,n.jsx)(o.A,{className:"human2ai-ui-sketch-canvas__visual-weight-select",value:en.item.weight,options:eU,"aria-label":J.visualWeight,onChange:e=>tf({weight:e})})}),(0,n.jsx)(f,{label:J.visibility,children:(0,n.jsx)(r.A,{checked:en.item.visible,checkedChildren:J.visible,unCheckedChildren:J.hidden,"aria-label":J.visibility,onChange:e=>tf({visible:e})})}),"text"===en.kind?(0,n.jsxs)("div",{className:"human2ai-ui-sketch-canvas__editor-field",children:[(0,n.jsx)("span",{id:Y,className:"human2ai-ui-sketch-canvas__editor-field-label",children:J.fontSize}),(0,n.jsxs)("div",{className:"human2ai-ui-sketch-canvas__font-size-control",role:"group","aria-labelledby":Y,children:[(0,n.jsx)(X.J,{mode:"icon-only",size:"small",icon:(0,n.jsx)(eu.A,{"aria-hidden":"true"}),iconLabel:J.decreaseFontSize,disabled:en.item.fontSize<=8,onClick:()=>ty({fontSize:Math.max(8,Math.round(en.item.fontSize)-1)})}),(0,n.jsxs)("output",{"aria-live":"polite",children:[Math.round(en.item.fontSize),"px"]}),(0,n.jsx)(X.J,{mode:"icon-only",size:"small",icon:(0,n.jsx)(em.A,{"aria-hidden":"true"}),iconLabel:J.increaseFontSize,onClick:()=>ty({fontSize:Math.round(en.item.fontSize)+1})})]})]}):null]})]}),"image"===en.kind?(0,n.jsx)("aside",{className:"human2ai-ui-sketch-canvas__editor-side-fields",children:(0,n.jsx)(ee,{src:en.item.assetId?$?.(en.item.assetId):void 0,crop:en.item.crop,aspectRatio:en.item.width/en.item.height,labels:W,onReadFile:_,disabled:!d||!F,onUpload:async t=>{if(!F)return;let i=await F(t),n=eV.current;n.interactionResetKey===e&&(ea(e=>e?.kind==="image"&&e.item.id===en.item.id?{...e,item:{...e.item,assetId:i,crop:null}}:e),n.updateImage(en.item.id,{assetId:i,crop:null}))},onCropChange:(e,i)=>{ea(t=>t?.kind==="image"?{...t,item:{...t.item,crop:e,y:t.item.y+(t.item.height-t.item.width/i)/2,height:t.item.width/i}}:t),d?.(function(e,t,i,n){if(!Number.isFinite(n)||n<=0)throw Error("Image aspect ratio must be greater than zero.");i&&function(e){if(e.x+e.width>1+1e-9||e.y+e.height>1+1e-9)throw Error("Image crop must stay inside the source image.")}(i);let a=tw(e),r=a.images.find(e=>e.id===t);if(!r)throw Error(`Unknown UI sketch image: ${t}.`);r.crop=i?{...i}:null;let o=r.width/n;return r.y+=(r.height-o)/2,r.height=o,a.stages.forEach(e=>{let i=e.images.find(e=>e.id===t);if(!i)return;let a=i.width/n;i.y+=(i.height-a)/2,i.height=a}),a}(t,en.item.id,e,i))}},en.item.id)}):null]})]}):null]}),(0,n.jsx)("span",{className:"human2ai-ui-sketch-canvas__selection-status","aria-live":"polite",children:eJ.length?`${J.selectedItemsPrefix}${eJ.length}${J.selectedItemsSuffix}`:J.noSelection}),j?(0,M.createPortal)((0,n.jsx)(C.A,{title:J.clearCanvas,children:(0,n.jsx)("span",{children:(0,n.jsx)(h.x,{type:"text",size:"small",icon:(0,n.jsx)(s.A,{"aria-hidden":"true"}),"aria-label":J.clearCanvas,title:J.clearCanvasConfirmTitle,description:J.clearCanvasConfirmDescription,confirmLabel:J.clearCanvas,cancelLabel:J.clearCanvasCancel,onConfirm:function(){K(null),eQ(e=>({...e,rectangles:[],texts:[],images:[],groups:[]})),Q([]),ei(null),ea(null),eL({})},"data-ui-sketch-clear-canvas-action":!0,children:null})})}),j):null,w?(0,M.createPortal)((0,n.jsx)("div",{className:"human2ai-ui-sketch-canvas__external-tools","data-ui-sketch-external-tools":!0,children:t_}),w):null]})}function tK(e){return"u">typeof crypto&&"randomUUID"in crypto?`${e}-${crypto.randomUUID()}`:`${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`}function tZ(e,t){return`${e}:${t}`}function tQ(e){return e.startsWith("rectangle:")||e.startsWith("text:")||e.startsWith("image:")}function t0(e){return e.slice(e.indexOf(":")+1)}function t1(e,t){let i=new Set(tl(e,t.map(t0)));return[...e.rectangles.filter(e=>i.has(e.id)).map(e=>tZ("rectangle",e.id)),...e.texts.filter(e=>i.has(e.id)).map(e=>tZ("text",e.id)),...e.images.filter(e=>i.has(e.id)).map(e=>tZ("image",e.id))]}function t2(e,t){let i=t0(t);if(t.startsWith("rectangle:")){let t=e.rectangles.find(e=>e.id===i);return t?{kind:"rectangle",item:t}:null}if(t.startsWith("image:")){let t=e.images.find(e=>e.id===i);return t?{kind:"image",item:t}:null}let n=e.texts.find(e=>e.id===i);return n?{kind:"text",item:n}:null}function t3(e,t,i){let n=t2(e,t);return n?"rectangle"===n.kind||"image"===n.kind?n.item:t5(n.item,i):null}function t5(e,t){let i=tL(e),n=t[e.id];return n&&n.text===e.text&&n.fontSize===e.fontSize?{...i,width:n.width,height:n.height}:i}function t4(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function t8(e,t){return{x:-e/2,y:-t/2,width:e,height:t}}function t6(e){null!==e.animationFrame&&cancelAnimationFrame(e.animationFrame),e.previewElements.forEach(e=>e.removeAttribute("transform")),e.scene.removeAttribute("data-canvas-dragging")}function t9(e,t,i){if(!t.length)return e;let n={x:Math.round(i.x),y:Math.round(i.y)},a=new Set(t);return{...e,rectangles:e.rectangles.map(e=>a.has(tZ("rectangle",e.id))?{...e,x:e.x+n.x,y:e.y+n.y}:e),images:e.images.map(e=>a.has(tZ("image",e.id))?{...e,x:e.x+n.x,y:e.y+n.y}:e),texts:e.texts.map(e=>a.has(tZ("text",e.id))?{...e,x:e.x+n.x,y:e.y+n.y}:e)}}function t7(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function ie(e,t){let i=t.getBoundingClientRect(),n=t.viewBox.baseVal;return{x:n.x+(e.clientX-i.left)/Math.max(1,i.width)*n.width,y:n.y+(e.clientY-i.top)/Math.max(1,i.height)*n.height}}function it(e,t){try{e.setPointerCapture(t)}catch{}}function ii(e,t){let i=new Set(e);return t.forEach(e=>{i.has(e)?i.delete(e):i.add(e)}),[...i]}function ia(e="black"){return"white"===e?"var(--yisiui-color-text-inverse)":"var(--yisiui-color-text-primary)"}function ir({items:e,"aria-label":t,compact:i=!1,tabBackground:a,selectedBackground:r,selectedTextColor:o="black",unselectedTextColor:s,value:l,defaultValue:d,onChange:c,className:h,style:p}){if(e.length<2)throw Error("TabSwitch 至少需要两个子项。");let g=new Set;for(let t of e){if(g.has(t.key))throw Error(`TabSwitch 子项 key 必须唯一:${t.key}`);if(g.add(t.key),("icon-text"===t.mode||"icon-only"===t.mode)&&null==t.icon)throw Error(`TabSwitch 子项「${t.label}」使用 Icon 模式时必须提供 icon。`)}if(void 0!==l&&!g.has(l))throw Error(`TabSwitch value 不存在于 items:${l}`);if(void 0!==d&&!g.has(d))throw Error(`TabSwitch defaultValue 不存在于 items:${d}`);let f=(0,u.useMemo)(()=>new Map(e.map(e=>[e.key,e])),[e]),y=e[0].key,[x,b]=(0,u.useState)(d??y),v=(0,u.useId)(),w=(0,u.useRef)([]),j=l??(f.has(x)?x:y),k=f.get(j)?.disabled?e.find(e=>!e.disabled)?.key:j;function I(e){let t=f.get(e);t&&!t.disabled&&e!==j&&(void 0===l&&b(e),c?.(e,t))}return(0,n.jsx)("div",{...(0,m.S)("tab-switch","TabSwitch","component"),className:["yisi-tab-switch",i?"yisi-tab-switch-compact":null,h].filter(Boolean).join(" "),"data-density":i?"compact":"default",style:{...p,"--yisiui-tab-switch-background":a??"var(--yisiui-color-surface-page)","--yisiui-tab-switch-selected-background":r??"var(--yisiui-color-surface-panel)","--yisiui-tab-switch-selected-text-color":ia(o),...s?{"--yisiui-tab-switch-unselected-text-color":ia(s)}:{}},"aria-label":t,role:"radiogroup","aria-orientation":"horizontal",children:e.map((t,i)=>{let a;return(0,n.jsxs)("div",{className:["yisi-tab-switch-item",t.key===j?"yisi-tab-switch-active-item":null,t.disabled?"yisi-tab-switch-disabled-item":null].filter(Boolean).join(" "),children:[(0,n.jsxs)("label",{className:"yisi-tab-switch-label",title:"icon-only"===t.mode?t.ariaLabel??t.label:void 0,children:[(0,n.jsx)("input",{ref:e=>{w.current[i]=e},className:"yisi-tab-switch-input",type:"radio",name:v,value:t.key,checked:t.key===j,disabled:t.disabled,"aria-label":t.ariaLabel,tabIndex:t.disabled||t.key!==k?-1:0,onChange:()=>I(t.key),onKeyDown:t=>(function(t,i){let n,a=e.flatMap((e,t)=>e.disabled?[]:[t]),r=a.indexOf(i),o=a.length-1,s="rtl"===getComputedStyle(t.currentTarget).direction;switch(t.key){case"ArrowRight":case"ArrowLeft":n=(r+("ArrowRight"===t.key!==s?1:o))%a.length;break;case"ArrowDown":n=(r+1)%a.length;break;case"ArrowUp":n=(r+o)%a.length;break;case"Home":n=0;break;case"End":n=o;break;default:return}t.preventDefault();let l=a[n];void 0!==l&&(I(e[l].key),w.current[l]?.focus())})(t,i)}),(a=t.mode??"icon-text",(0,n.jsxs)("span",{className:"yisi-tab-switch-content",children:["text-only"!==a?(0,n.jsx)("span",{className:"yisi-tab-switch-icon","aria-hidden":"true",children:t.icon}):null,"icon-only"===a?(0,n.jsx)("span",{className:"yisi-tab-switch-visually-hidden",children:t.ariaLabel??t.label}):(0,n.jsx)("span",{className:"yisi-tab-switch-text",children:t.label})]}))]}),null!=t.rightSlot?(0,n.jsx)("div",{className:"yisi-tab-switch-right-slot","data-yisiui-slot":"rightSlot",children:t.rightSlot}):null]},t.key)})})}i(48308),i(71180);let io={draftView:"构图",refinedView:"精修",referenceView:"预览",viewSwitch:"构图视图",draftCanvas:"用户构图草图",refinedCanvas:"Agent 精修后的构图",referenceCanvas:"用于生图的结构参考",agentDecision:"Agent 判断",appliedMethods:"执行方法",protectionAudit:"变化记录",maximumFocusShift:"最大焦点位移",maximumAreaShift:"最大形状位移",maximumRotationShift:"最大旋转变化",objective:"精修目标",observations:"判断依据",uncertainties:"待确认事项",preserve:"保留关系",tradeoffs:"取舍",relations:"关系验证",retained:"保留原构图",target:"目标值",before:"原图测量",after:"精修测量",error:"达成偏差",unmeasurable:"不适用",framePlacement:"分割线定位",sizeRatio:"尺寸比例",mirrorSymmetry:"轴对称",focusFlow:"焦点引导",focusAnchor:"焦点定位",axisRelation:"轴线关系",rotationAlignment:"方向对齐",blockAlignment:"区域对齐",spacingRhythm:"等距排列"};function is(e){return"children"in e?(0,n.jsx)(il,{...e}):(0,n.jsx)(id,{...e})}function il({stateControls:e,children:t,className:i,style:a,workflowStatus:r,activeView:o,"data-active-stage":s}){return(0,n.jsxs)("section",{...(0,k.Se)({namespace:"human2ai",id:"composition-workflow-view",name:"CompositionWorkflowView",category:"module",origin:"project",status:"candidate"}),className:["human2ai-composition-workflow",i].filter(Boolean).join(" "),style:a,"data-workflow-status":r,"data-active-view":o,"data-active-stage":s,children:[(0,n.jsx)("div",{className:"human2ai-composition-workflow__toolbar",children:e}),(0,n.jsx)("div",{className:"human2ai-composition-workflow__stage",children:t})]})}function id({stateControls:e,interactionResetKey:t,selectedPlanIds:i,planningLocked:a=!1,onPlanSelectionChange:r,planningLabels:o,draft:s,status:l,refinement:d=null,activeView:c,onViewChange:u,selectedIds:m=[],onDraftChange:h,placementTool:p,onPlacementToolChange:g,onSelectionChange:f,onItemDoubleClick:y,showPlanning:x=!0,frameLocked:b=!1,canvasZoom:v,canvasViewportAction:w,onCanvasZoomChange:k,canvasBackgroundPattern:I,showCanvasViewportControls:S,canvasSideActions:P,canvasSideActionPlacement:C,canvasSideActionPanelWidth:M,canvasSideActionPanelDefaultCollapsed:A,canvasViewportLabels:L,canvasLayerLabels:N,nodeEditorLabels:$,directionControlLabels:F,areaEditorLabels:_,imageEditorLabels:T,resolveImageSource:R,renderCameraReference:E,onImageUpload:q,onReadImageFile:D,labels:z,className:B,style:O}){let U={...io,...z},J=d?.audit.passed===!0&&d.plan.sourceFingerprint===d.sourceFingerprint&&d.sourceFingerprint===(0,j.Oq)(s),W="ready"!==l||J?l:"stale",H="ready"===W&&J,Y="refined"!==c||H?c:"draft",V=H&&d?d.refinedDraft:s,X=[{key:"draft",label:U.draftView,mode:"text-only"},{key:"refined",label:U.refinedView,mode:"text-only",disabled:!H},{key:"reference",label:U.referenceView,mode:"text-only"}];return(0,n.jsxs)(il,{className:B,style:O,workflowStatus:W,activeView:Y,stateControls:e??(0,n.jsx)(ir,{items:X,value:Y,"aria-label":U.viewSwitch,onChange:e=>u(e)}),children:["draft"===Y?(0,n.jsx)(eN,{interactionResetKey:t,selectedPlanIds:i,planningLocked:a,onPlanSelectionChange:r,planningLabels:o,draft:s,showPlanning:x,frameLocked:b,zoom:v,viewportAction:w,backgroundPattern:I,showViewportControls:S,sideActions:P,sideActionPlacement:C,sideActionPanelWidth:M,sideActionPanelDefaultCollapsed:A,viewportLabels:L,layerLabels:N,nodeEditorLabels:$,directionControlLabels:F,areaEditorLabels:_,imageEditorLabels:T,renderCameraReference:E,resolveImageSource:R,onImageUpload:q,onReadImageFile:D,selectedIds:m,onDraftChange:h,placementTool:p,onPlacementToolChange:g,onSelectionChange:f,onItemDoubleClick:y,onZoomChange:k,"aria-label":U.draftCanvas},s.activeStateId):null,"refined"===Y&&d?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eN,{draft:d.refinedDraft,showPlanning:x,zoom:v,viewportAction:w,backgroundPattern:I,showViewportControls:S,viewportLabels:L,layerLabels:N,nodeEditorLabels:$,resolveImageSource:R,onZoomChange:k,"aria-label":U.refinedCanvas}),(0,n.jsx)(ic,{refinement:d,labels:U})]}):null,"reference"===Y?(0,n.jsx)(eN,{draft:V,appearance:"reference",layerLabels:N,nodeEditorLabels:$,resolveImageSource:R,"aria-label":U.referenceCanvas}):null]})}function ic({refinement:e,labels:t}){let i=e.audit.changes;if(2===e.plan.version){let i=e.plan,a={"focus-anchor":t.focusAnchor,"axis-relation":t.axisRelation,"rotation-alignment":t.rotationAlignment,"block-alignment":t.blockAlignment,"spacing-rhythm":t.spacingRhythm,"frame-placement":t.framePlacement,"size-ratio":t.sizeRatio,"mirror-symmetry":t.mirrorSymmetry,"focus-flow":t.focusFlow},r=[[t.observations,i.assessment.observations],[t.uncertainties,i.assessment.uncertainties],[t.preserve,i.preserve],[t.tradeoffs,i.tradeoffs]];return(0,n.jsxs)("div",{className:"human2ai-composition-workflow__summary human2ai-composition-workflow__summary--directed",children:[(0,n.jsxs)("section",{children:[(0,n.jsx)("h3",{children:t.objective}),(0,n.jsx)("p",{children:i.objective}),(0,n.jsx)("p",{children:i.assessment.intent}),(0,n.jsx)("p",{children:i.rationale}),"retain"===i.decision?(0,n.jsx)("strong",{children:t.retained}):null,r.filter(([,e])=>e.length).map(([e,t])=>(0,n.jsxs)("div",{className:"human2ai-composition-workflow__explanation",children:[(0,n.jsx)("h3",{children:e}),(0,n.jsx)("ul",{children:t.map((e,t)=>(0,n.jsx)("li",{children:e},t))})]},e))]}),i.operations.length>0?(0,n.jsxs)("section",{children:[(0,n.jsx)("h3",{children:t.relations}),(0,n.jsx)("ol",{className:"human2ai-composition-workflow__relations",children:i.operations.map((i,r)=>{let o=e.audit.relations?.find(e=>e.operationIndex===r);return(0,n.jsxs)("li",{"data-relation-passed":o?.passed,children:[(0,n.jsx)("strong",{children:a[i.method]}),(0,n.jsx)("p",{children:i.reason}),(0,n.jsx)("p",{children:i.expectedEffect}),o?(0,n.jsx)("dl",{children:[[t.target,o.target],[t.before,o.before],[t.after,o.after],[t.error,o.error]].map(([e,i])=>(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:e}),(0,n.jsx)("dd",{children:function(e,t,i){if(null===e)return i;if("frame-fraction"===t)return`${Number((100*e).toFixed(3))}%`;let n=Number(e.toFixed(4)).toString();return"degrees"===t?`${n}\xb0`:"pixels"===t?`${n} px`:n}(i,o.unit,t.unmeasurable)})]},String(e)))}):null]},r)})})]}):null]})}return(0,n.jsxs)("div",{className:"human2ai-composition-workflow__summary",children:[(0,n.jsxs)("section",{children:[(0,n.jsx)("h3",{children:t.agentDecision}),(0,n.jsx)("p",{children:e.plan.rationale})]}),(0,n.jsxs)("section",{children:[(0,n.jsx)("h3",{children:t.appliedMethods}),(0,n.jsx)("ul",{children:e.appliedOperations.map((e,t)=>(0,n.jsx)("li",{children:(0,n.jsx)("code",{children:`${e.method}@${e.methodVersion}`})},`${e.method}-${t}`))})]}),(0,n.jsxs)("section",{children:[(0,n.jsx)("h3",{children:t.protectionAudit}),(0,n.jsxs)("dl",{children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:t.maximumFocusShift}),(0,n.jsx)("dd",{children:iu(i.maximumFocusShift)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:t.maximumAreaShift}),(0,n.jsx)("dd",{children:iu(i.maximumAreaShift)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:t.maximumRotationShift}),(0,n.jsxs)("dd",{children:[i.maximumRotationShift.toFixed(1),"\xb0"]})]})]})]})]})}function iu(e){return`${(100*e).toFixed(1)}%`}var im=i(81309);i(42666),i(20701);let ih=(e,t,i)=>[e[0]+t[0]*i,e[1]+t[1]*i],ip=(e,t)=>Math.hypot(t[0]-e[0],t[1]-e[1]),ig=e=>e.map(e=>Number(e.toFixed(6))).join(" ");function iy(e,t,i=!0,n=.72){let a=e.map((a,r)=>{let o=i||0!==r&&r!==e.length-1?"number"==typeof t?t:t[r]??0:0;return function(e,t,i,n,a=.72){let r=ip(e,t),o=ip(t,i),s=Math.max(0,Math.min(n,.49*r,.49*o));if(0===r||0===o||0===s)return{start:t,end:t,middle:t,curves:[]};let l=[(t[0]-e[0])/r,(t[1]-e[1])/r],d=[(i[0]-t[0])/o,(i[1]-t[1])/o],c=a*s,u=2*c-s,m=ih(t,l,-s),h=ih(t,d,s),p=ih(m,l,c),g=ih(h,d,-c),f=[(p[0]+g[0])/2,(p[1]+g[1])/2];return{start:m,end:h,middle:f,curves:[[m,ih(m,l,u),p,f],[f,g,ih(h,d,-u),h]]}}(e[(r+e.length-1)%e.length],a,e[(r+1)%e.length],o,n)});return{d:a.map((e,t)=>`${0===t?"M":"L"}${ig(e.start)}${e.curves.map(e=>`C${e.slice(1).map(ig).join(" ")}`).join("")}`).join("")+(i?"Z":""),corners:a}}let ix=iy([[3.4,10.3],[20.4,3.6],[13.7,20.6],[10.7,13.3]],[3.1,3.8,3.1,1.7],!0,.56),ib=iy(function(e=9.5,t=4.8){return Array.from({length:10},(i,n)=>{let a=-Math.PI/2+n*Math.PI/5,r=n%2==0?e:t;return[12+r*Math.cos(a),12.3+r*Math.sin(a)]})}(9.8,5.2),[2.9,1.65,2.9,1.65,2.9,1.65,2.9,1.65,2.9,1.65],!0,.56),iv=iy([[4,14],[4,20],[20,20],[20,14]],3.8,!1,.56),iw=iy([[12,3.4],[17.7,9.7],[6.3,9.7]],[2.1,1.8,1.8],!0,.56),ij=iy([[8,7],[16,7],[20,11],[20,21],[8,21]],[4.5,1.2,1.2,4.5,4.5],!0,.56),ik=22/3*Math.tan(Math.PI/8),iI=`M6.5 10C6.5 ${10-ik} ${12-ik} 4.5 12 4.5C${12+ik} 4.5 17.5 ${10-ik} 17.5 10C17.5 13 17.9 14.6 18.6 15.8Q19.3 17 17.9 17H6.1Q4.7 17 5.4 15.8C6.1 14.6 6.5 13 6.5 10Z`,iS=iy([[19.2,3.5],[20,9.7],[13.8,7.6]],1.8,!0,.56),iP=iy([[3,4.5],[21,4.5],[21,19.5],[3,19.5]],4.5,!0,.56),iC=iy([[3.8,3.8],[3.8,9.2],[9.2,9.2]],1.6,!0,.56);function iM({name:e}){let t={className:"yisi-animated-icon-motion","data-animated-icon-part":"motion"};switch(e){case"reset":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"1.25",fill:"currentColor",stroke:"none"}),(0,n.jsxs)("g",{...t,children:[(0,n.jsx)("path",{d:"M5.5 7.35A8 8 0 1 1 4 12"}),(0,n.jsx)("path",{d:iC.d,fill:"currentColor",stroke:"none"})]})]});case"sidebar-left":case"sidebar-right":return(0,n.jsxs)("g",{transform:"sidebar-right"===e?"translate(24 0) scale(-1 1)":void 0,children:[(0,n.jsx)("path",{d:iP.d}),(0,n.jsx)("g",{...t,children:(0,n.jsx)("rect",{x:"5.5",y:"7",width:"4",height:"10",rx:"1.6",fill:"currentColor",stroke:"none"})})]});case"loading":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"8",opacity:"0.16"}),(0,n.jsx)("g",{...t,children:(0,n.jsx)("path",{d:"M12 4a8 8 0 1 1-8 8"})})]});case"plus":return(0,n.jsxs)("g",{...t,fill:"currentColor",stroke:"none",children:[(0,n.jsx)("rect",{x:"4.5",y:"10.8",width:"15",height:"2.4",rx:"1.2"}),(0,n.jsx)("rect",{x:"10.8",y:"4.5",width:"2.4",height:"15",rx:"1.2"})]});case"upload":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("path",{d:iv.d}),(0,n.jsx)("rect",{x:"5.5",y:"18.4",width:"13",height:"2.5",rx:"1.25",fill:"currentColor",stroke:"none"}),(0,n.jsxs)("g",{...t,children:[(0,n.jsx)("path",{d:"M12 8.7v6.8"}),(0,n.jsx)("path",{fill:"currentColor",stroke:"none",d:iw.d})]})]});case"send":return(0,n.jsx)("g",{...t,children:(0,n.jsx)("path",{d:`${ix.d}M${ig(ix.corners[3].middle)}L${ig(ix.corners[1].middle)}`})});case"refresh":return(0,n.jsxs)("g",{...t,children:[(0,n.jsx)("path",{d:"M4.5 9a8 8 0 0 1 13.7-2.7M19.5 15a8 8 0 0 1-13.7 2.7"}),(0,n.jsxs)("g",{fill:"currentColor",stroke:"none",children:[(0,n.jsx)("path",{d:iS.d}),(0,n.jsx)("path",{d:iS.d,transform:"rotate(180 12 12)"})]})]});case"copy":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("path",{d:"M6 16h-.5A2.5 2.5 0 0 1 3 13.5v-8A2.5 2.5 0 0 1 5.5 3h7A2.5 2.5 0 0 1 15 5.5"}),(0,n.jsxs)("g",{...t,children:[(0,n.jsx)("path",{d:ij.d}),(0,n.jsx)("path",{d:"M16 7v2a2 2 0 0 0 2 2h2Z",fill:"currentColor",stroke:"none"}),(0,n.jsx)("path",{d:"M11.5 15.5h5"})]})]});case"star":return(0,n.jsx)("g",{...t,children:(0,n.jsx)("path",{d:ib.d})});case"bell":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("circle",{cx:"12",cy:"3.2",r:"1.4",fill:"currentColor",stroke:"none"}),(0,n.jsx)("g",{...t,children:(0,n.jsx)("path",{d:iI})}),(0,n.jsxs)("g",{className:"yisi-animated-icon-layer yisi-icon-bell-clapper",children:[(0,n.jsx)("path",{d:"M12 17v1.5"}),(0,n.jsx)("rect",{x:"10.4",y:"18",width:"3.2",height:"3.6",rx:"1.6",fill:"currentColor",stroke:"none"})]})]});case"close":return(0,n.jsx)("g",{...t,children:(0,n.jsxs)("g",{transform:"rotate(45 12 12)",fill:"currentColor",stroke:"none",children:[(0,n.jsx)("rect",{x:"4.5",y:"10.8",width:"15",height:"2.4",rx:"1.2"}),(0,n.jsx)("rect",{x:"10.8",y:"4.5",width:"2.4",height:"15",rx:"1.2"})]})})}}let iA=(0,u.forwardRef)(function({name:e,size:t="1em",label:i,loop:a=!1,playKey:r,duration:o=720,motion:s="auto",onAnimationComplete:l,className:d,style:c,...h},p){let[g,f]=(0,u.useState)(!1),[y,x]=(0,u.useState)({id:0,playing:!1}),b=(0,u.useRef)(null),v=(0,u.useRef)(r),w="none"!==s&&!g,j=Number.isFinite(o)&&o>0?o:720;(0,u.useEffect)(()=>{let e=window.matchMedia("(prefers-reduced-motion: reduce)"),t=()=>f(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]);let k=(0,u.useCallback)(()=>{w&&x(e=>({id:e.id+1,playing:!0}))},[w]),I=(0,u.useCallback)(()=>x(e=>({...e,playing:!1})),[]);return(0,u.useImperativeHandle)(p,()=>({play:k,stop:I}),[k,I]),(0,u.useEffect)(()=>{x(e=>({id:e.id+1,playing:a&&w}))},[e,a,w]),(0,u.useEffect)(()=>{r!==v.current&&void 0!==r&&k(),v.current=r},[r,k]),(0,u.useEffect)(()=>{let e=b.current,t=e=>{!a&&y.playing&&w&&e.target instanceof SVGElement&&"motion"===e.target.getAttribute("data-animated-icon-part")&&(I(),l?.())};return e?.addEventListener("animationend",t),()=>e?.removeEventListener("animationend",t)},[a,w,y.playing,l,I]),(0,n.jsx)("svg",{...h,ref:b,...(0,m.S)("animated-icon","AnimatedIcon"),className:["yisi-animated-icon",d].filter(Boolean).join(" "),"data-icon":e,"data-playing":y.playing&&w?"true":"false","data-loop":a?"true":"false",viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:h.strokeWidth??1.8,strokeLinecap:"round",strokeLinejoin:"round",role:i?"img":void 0,"aria-label":i,"aria-hidden":!i||void 0,focusable:"false",style:{"--yisiui-animated-icon-duration":`${j}ms`,...c},children:(0,n.jsx)(iM,{name:e},`${e}:${y.id}`)})});iA.displayName="AnimatedIcon";let iL={sidebar:"Application sidebar",navigation:"Application navigation",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",rightPanel:"Right panel",collapseRightPanel:"Collapse right panel",expandRightPanel:"Expand right panel"};function iN(e){return"number"==typeof e?`${e}px`:e}function i$({sidebar:e,sidebarTitle:t,sidebarNavigation:i,title:a,headerExtra:r,backAction:o,sidebarCollapsedActions:s,rightPanel:l,children:d,collapsible:h=!0,sidebarOpen:p,defaultSidebarOpen:g=!0,onSidebarOpenChange:f,sidebarWidth:y="var(--yisiui-surface-desktop-web-sidebar-width)",rightPanelCollapsible:x=!0,rightPanelOpen:b,defaultRightPanelOpen:v=!0,onRightPanelOpenChange:w,rightPanelWidth:j="var(--yisiui-surface-desktop-web-sidebar-width)",labels:k,className:I,style:S}){let P=(0,u.useId)(),C=(0,u.useId)(),M=(0,u.useRef)(null),A=(0,u.useRef)(null),[L,N]=(0,u.useState)(g),[$,F]=(0,u.useState)(v),_=void 0!==p,T=void 0!==b,R=null!=l,E=null!=r&&!1!==r,q=!h||(p??L),D=R&&(!x||(b??$)),z={...iL,...k},B={"--yisi-app-shell-sidebar-width":iN(y),"--yisi-app-shell-right-panel-width":iN(j),...S};function O(e){_||N(e),f?.(e)}return(0,n.jsxs)("div",{...(0,m.S)("app-shell-frame","AppShellFrame","layout"),className:["yisi-app-shell-frame",!q?"yisi-app-shell-frame--sidebar-hidden":null,!D?"yisi-app-shell-frame--right-panel-hidden":null,I].filter(Boolean).join(" "),"data-sidebar-state":q?"open":"closed","data-right-panel-state":R?D?"open":"closed":"absent",style:B,children:[(0,n.jsx)("aside",{id:P,className:"yisi-app-shell-sidebar","aria-label":z.sidebar,"aria-hidden":!q,children:(0,n.jsxs)("div",{className:"yisi-app-shell-sidebar-content",children:[(0,n.jsxs)("div",{className:"yisi-app-shell-sidebar-top",children:[(0,n.jsxs)("div",{className:"yisi-app-shell-sidebar-heading",children:[t?(0,n.jsx)("div",{className:"yisi-app-shell-sidebar-title",children:t}):(0,n.jsx)("span",{"aria-hidden":"true"}),h&&q?(0,n.jsx)(c.Ay,{className:"yisi-app-shell-sidebar-toggle",type:"text",icon:(0,n.jsx)(iA,{ref:M,name:"sidebar-left",size:20}),"aria-label":z.collapseSidebar,title:z.collapseSidebar,"aria-expanded":"true","aria-controls":P,onPointerEnter:()=>M.current?.play(),onFocus:()=>M.current?.play(),onClick:()=>O(!1)}):null]}),i?(0,n.jsx)("nav",{className:"yisi-app-shell-sidebar-navigation","aria-label":z.navigation,children:i}):null]}),(0,n.jsx)("div",{className:"yisi-app-shell-sidebar-slot",children:e})]})}),(0,n.jsxs)("div",{className:"yisi-app-shell-content",children:[(0,n.jsxs)("header",{className:"yisi-app-shell-content-header",children:[(0,n.jsxs)("div",{className:"yisi-app-shell-content-leading",children:[h&&!q?(0,n.jsx)(c.Ay,{className:"yisi-app-shell-content-toggle",type:"text",icon:(0,n.jsx)(iA,{ref:M,name:"sidebar-left",size:20}),"aria-label":z.expandSidebar,title:z.expandSidebar,"aria-expanded":"false","aria-controls":P,onPointerEnter:()=>M.current?.play(),onFocus:()=>M.current?.play(),onClick:()=>O(!0)}):null,h&&!q&&s?(0,n.jsx)("div",{className:"yisi-app-shell-sidebar-collapsed-actions",children:s}):null,o?(0,n.jsx)(c.Ay,{className:"yisi-app-shell-content-back",type:"text",icon:o.icon??(0,n.jsx)(im.A,{}),"aria-label":o.label,title:o.label,onClick:o.onClick}):null]}),a?(0,n.jsx)("div",{className:"yisi-app-shell-content-title",title:"string"==typeof a?a:void 0,children:a}):null,E||R&&x?(0,n.jsxs)("div",{className:"yisi-app-shell-content-trailing",children:[E?(0,n.jsx)("div",{className:"yisi-app-shell-header-extra","data-yisiui-slot":"header-extra",children:r}):null,R&&x?(0,n.jsx)(c.Ay,{className:"yisi-app-shell-right-panel-toggle",type:"text",icon:(0,n.jsx)(iA,{ref:A,name:"sidebar-right",size:20}),"aria-label":D?z.collapseRightPanel:z.expandRightPanel,title:D?z.collapseRightPanel:z.expandRightPanel,"aria-expanded":D,"aria-controls":C,onPointerEnter:()=>A.current?.play(),onFocus:()=>A.current?.play(),onClick:()=>{var e;return e=!D,void(!T&&F(e),w?.(e))}}):null]}):null]}),(0,n.jsx)("div",{className:"yisi-app-shell-content-body",children:d})]}),R?(0,n.jsx)("aside",{id:C,className:"yisi-app-shell-right-panel","aria-label":z.rightPanel,"aria-hidden":!D,children:l}):null]})}i(15682);let iF={productName:"human2ai",sidebar:"Human2AI 应用侧栏",navigation:"Human2AI 应用导航",collapseSidebar:"收起应用侧栏",expandSidebar:"展开应用侧栏",rightPanel:"页面属性",collapseRightPanel:"收起页面属性",expandRightPanel:"展开页面属性"};function i_({title:e,brand:t,children:i,sidebar:a,rightPanel:r,rightPanelOpen:o,onRightPanelOpenChange:s,labels:l,className:d}){let c={...iF,...l};return(0,n.jsx)("div",{...(0,k.Se)({namespace:"human2ai",id:"app-shell",name:"Human2AiAppShell",category:"layout",origin:"project",status:"candidate"}),className:["human2ai-app-shell",d].filter(Boolean).join(" "),children:(0,n.jsx)(i$,{sidebar:a,sidebarTitle:t??c.productName,title:(0,n.jsx)("h1",{className:"human2ai-app-shell__page-title",children:e}),rightPanel:r,rightPanelOpen:o,onRightPanelOpenChange:s,sidebarWidth:280,rightPanelWidth:300,labels:c,children:i})})}var iT=i(6915),iR=i(14766),iE=i(510),iq=i(21494),iD=i(81793),iz=i(11075),iB=i(96965),iO=i(27476),iU=i(86547),iJ=i(93319),iW=i(88398),iH=i(53409),iY=i(48389),iV=i(50152),iX=i(44081),iG=i(48624),iK=i(24909),iZ=i(40684),iQ=i(41103);i(52048),i(68071),i(12190);let i0={default:{},info:{color:"blue",icon:(0,n.jsx)(iG.A,{})},success:{color:"green",icon:(0,n.jsx)(iW.A,{})},warning:{color:"orange",icon:(0,n.jsx)(iK.A,{})},danger:{color:"red",icon:(0,n.jsx)(V.A,{})},processing:{color:"processing",icon:(0,n.jsx)(iZ.A,{})}};function i1({label:e,tone:t="default",icon:i,mode:a="icon-text",tooltip:r}){let o=i0[t],s=i??o.icon,l=(0,n.jsx)(iQ.A,{...(0,m.S)("status-badge","StatusBadge","component"),className:`yisi-status-badge yisi-status-badge-${a}`,color:o.color,icon:"text-only"===a?void 0:s,"aria-label":"icon-only"===a&&"string"==typeof e?e:void 0,children:"icon-only"===a?(0,n.jsx)("span",{className:"yisi-status-badge-visually-hidden",children:e}):e});return(0,n.jsx)(C.A,{title:void 0===r?e:r,children:l})}i(63159);let{Text:i2}=iV.A,i3={planned:"计划中",ready:"可写作",drafted:"已起草",review_needed:"待审查",completed:"已完成",archived:"已归档"},i5={planned:(0,n.jsx)(iB.A,{}),ready:(0,n.jsx)(iO.A,{}),drafted:(0,n.jsx)(iU.A,{}),review_needed:(0,n.jsx)(iJ.A,{}),completed:(0,n.jsx)(iW.A,{}),archived:(0,n.jsx)(iH.A,{})},i4={planned:"default",ready:"info",drafted:"info",review_needed:"warning",completed:"success",archived:"default"};function i8(e){return e.isLeaf?null:(0,n.jsx)(iY.A,{className:"yisi-asset-skeleton-tree-switcher",rotate:90*!!e.expanded})}function i6(e){let t=new Map;for(let i of e){let e=t.get(i.parentKey)??[];e.push(i),t.set(i.parentKey,e)}for(let e of t.values())e.sort((e,t)=>e.order-t.order||e.title.localeCompare(t.title)||e.key.localeCompare(t.key));return t}function i9({dropPosition:e,dropLevelOffset:t,indent:i}){var a;return 0===e?null:(a={...-1===e?{top:0}:{bottom:0},left:-t*i,right:0},(0,n.jsxs)("span",{"aria-hidden":"true",className:"yisi-asset-skeleton-tree-drop-indicator",style:a,children:[(0,n.jsx)("span",{className:"yisi-asset-skeleton-tree-drop-indicator-dot"}),(0,n.jsx)("span",{className:"yisi-asset-skeleton-tree-drop-indicator-line"})]}))}function i7({nodes:e,mode:t,className:i,currentKey:a=null,maxTitleLength:r=24,showCurrent:o,showContentOrder:s=!0,showDraft:l,showLock:d,showStatus:c,canDragNode:h,switcherIcon:p,allowDrop:g,dropIndicatorRender:f,onDragStart:y,onDragEnd:x,onDragLeave:b,onDragOver:v,onDrop:w,...j}){var k,I,S,P,C;let M,A,L,N,[$,F]=(0,u.useState)(!1),[_,T]=(0,u.useState)(null),R=(0,u.useRef)(null),E=(0,u.useRef)(null),q=o??"view"===t,D=l??"edit"===t,z=d??"edit"===t,B=c??"view"===t,O="edit"===t,U=(M=i6(e),A=new Map,L=1,!function e(t){for(let i of M.get(t)??[])"content"!==i.nodeKind||i.isDeleted||(A.set(i.key,String(L).padStart(2,"0")),L+=1),e(i.key)}(null),A),J=new Map(e.map(e=>[e.key,e])),W="edit"===t?t=>(function(e,{dragNode:t,dropNode:i,dropPosition:n}){let a=new Map(e.map(e=>[e.key,e])),r=a.get(String(t.key)),o=a.get(String(i.key)),s=r?.nodeKind==="content"&&o?.nodeKind==="content"&&o.locked&&1===n;if(!r||!o||r.key===o.key||r.disabled||r.locked||r.isDeleted||o.disabled||o.isDeleted||o.locked&&!s)return!1;let l=o.parentKey;for(;null!==l;){if(l===r.key)return!1;l=a.get(l)?.parentKey??null}return"content"===r.nodeKind?"container"===o.nodeKind?0===n:"content"===o.nodeKind&&0!==n:"container"===o.nodeKind&&(0===n||r.parentKey===o.parentKey)})(e,t)&&(g?.(t)??!0):g;return(0,u.useEffect)(()=>()=>{null!==R.current&&window.clearTimeout(R.current),null!==E.current&&window.clearTimeout(E.current)},[]),(0,n.jsx)("div",{...(0,m.S)("asset-skeleton-tree","AssetSkeletonTree","tree-pattern"),className:["yisi-asset-skeleton-tree",`yisi-asset-skeleton-tree-${t}`,s?"yisi-asset-skeleton-tree-content-order-layout":"",$?"yisi-asset-skeleton-tree-scrolling":"",i].filter(Boolean).join(" "),"data-mode":t,onScroll:function(){F(!0),null!==R.current&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{F(!1),R.current=null},700)},children:(0,n.jsx)(iX.A,{blockNode:!0,...j,className:"yisi-asset-skeleton-tree-control",allowDrop:W,draggable:"edit"===t&&{icon:!1,nodeDraggable:e=>{let t=J.get(String(e.key));return!!(t&&!t.locked&&!t.disabled&&!t.isDeleted&&(h?.(t)??!0))}},dropIndicatorRender:f??i9,expandAction:j.expandAction??"click",onDragStart:"edit"===t?function(e){y?.(e)}:y,onDragEnd:"edit"===t?function(e){x?.(e)}:x,onDragLeave:"edit"===t?function(e){b?.(e)}:b,onDragOver:"edit"===t?function(e){v?.(e)}:v,onDrop:"edit"===t?function(e){T(String(e.dragNode.key)),null!==E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{T(null),E.current=null},720),w?.(e)}:w,switcherIcon:p??i8,treeData:(k=function(e){var i;let o,s=q&&a===e.key,l=(i=e.title,(o=Array.from(i.trim())).length<=r?i:`${o.slice(0,Math.max(1,r-1)).join("")}…`),d=!!(e.trailing||D&&e.hasDraft||s||(e.openTodoCount??0)>0||B&&"content"===e.nodeKind&&e.status);return(0,n.jsxs)("div",{className:["yisi-asset-skeleton-tree-node",`yisi-asset-skeleton-tree-node-${t}`,`yisi-asset-skeleton-tree-node-${e.nodeKind}`,e.isDeleted?"yisi-asset-skeleton-tree-node-deleted":""].filter(Boolean).join(" "),title:e.title,children:[e.isChanged?(0,n.jsx)("span",{className:"yisi-asset-skeleton-tree-state-announcement",children:"已变动"}):null,O&&e.isDeleted?(0,n.jsx)(i1,{label:"[del]",tone:"danger",mode:"text-only"}):O&&e.isNew?(0,n.jsx)(i1,{label:"[new]",tone:"success",mode:"text-only"}):null,z&&e.locked?(0,n.jsx)(i1,{label:"锁定",tone:"warning",mode:"text-only",tooltip:e.lockedReason||"已锁定"}):null,(0,n.jsx)("div",{className:"yisi-asset-skeleton-tree-copy",children:(0,n.jsx)(i2,{strong:"container"===e.nodeKind,ellipsis:!0,title:e.title,className:"yisi-asset-skeleton-tree-title",children:l})}),"container"===e.nodeKind&&e.description?(0,n.jsx)(i2,{ellipsis:!0,title:e.description,className:"yisi-asset-skeleton-tree-description",children:e.description}):null,d?(0,n.jsxs)("span",{className:"yisi-asset-skeleton-tree-trailing-area",children:[e.trailing?(0,n.jsx)("span",{className:"yisi-asset-skeleton-tree-trailing",children:e.trailing}):null,D&&e.hasDraft?(0,n.jsx)(i1,{label:"稿",tone:"success",mode:"text-only"}):null,s?(0,n.jsx)(i1,{label:"当前",tone:"success",mode:"text-only"}):null,(e.openTodoCount??0)>0?(0,n.jsx)(i1,{label:e.openTodoCount,tone:"danger",mode:"text-only",tooltip:`${e.openTodoCount} 个待处理问题`}):null,B&&"content"===e.nodeKind&&e.status?(0,n.jsx)(i1,{label:i3[e.status],tone:i4[e.status],icon:i5[e.status],mode:"icon-only"}):null]}):null]})},I=function(e){if(!s||"content"!==e.nodeKind)return;let t=U.get(e.key);return(0,n.jsx)("span",{className:["yisi-asset-skeleton-tree-content-order",t?"":"yisi-asset-skeleton-tree-content-order-empty"].filter(Boolean).join(" "),"aria-hidden":!t||void 0,children:t?(0,n.jsx)(i1,{label:t,tone:e.hasDraft?"success":"default",mode:"text-only",tooltip:`内容顺序 ${t}`}):null})},S=e=>!!e.disabled,P=e=>e.key===a,C=e=>e.key===_,N=i6(e),function e(t){return(N.get(t)??[]).map(t=>{let i=e(t.key);return{key:t.key,title:k(t),switcherIcon:I(t),disabled:S(t),className:[["yisi-asset-skeleton-tree-item",`yisi-asset-skeleton-tree-item-${t.nodeKind}`,t.locked?"yisi-asset-skeleton-tree-item-locked":"",t.isChanged?"yisi-asset-skeleton-tree-item-changed":"",t.isDeleted?"yisi-asset-skeleton-tree-item-deleted":"",t.isNew?"yisi-asset-skeleton-tree-item-new":"",...t.extraClassNames??[]].filter(Boolean).join(" "),P(t)?"yisi-asset-skeleton-tree-item-current":"",C(t)?"yisi-asset-skeleton-tree-item-moved":""].filter(Boolean).join(" "),isLeaf:0===i.length,children:i.length?i:void 0}})}(null))})})}var ne=i(95948),nt=i(37132);i(17346);let ni={bottomLeft:{points:["tl","bl"],offset:[0,-1],overflow:{adjustX:0,adjustY:1},htmlRegion:"scroll"},topLeft:{points:["bl","tl"],offset:[0,1],overflow:{adjustX:0,adjustY:1},htmlRegion:"scroll"}};function nn({value:e,options:t,onChange:i,"aria-label":a,placeholder:r,placement:s="bottom",disabled:l=!1,className:d,style:c}){let[m,h]=(0,u.useState)(!1),p=(0,u.useRef)(null),g=0===t.length,f=l||g;function y(){null!==p.current&&(window.clearTimeout(p.current),p.current=null)}function x(){y(),p.current=window.setTimeout(()=>{p.current=null,h(!1)},120)}function b(){y(),f||h(!0)}return(0,u.useEffect)(()=>{f&&h(!1)},[f]),(0,u.useEffect)(()=>()=>{null!==p.current&&window.clearTimeout(p.current)},[]),(0,n.jsx)("div",{...(0,k.Se)({namespace:"human2ai",id:"compact-dropdown-select",name:"CompactDropdownSelect",category:"switching",origin:"project",status:"candidate"}),className:["human2ai-compact-dropdown-select",d].filter(Boolean).join(" "),"data-open":m?"true":"false","data-placement":s,"data-empty":g?"true":"false",onMouseEnter:b,onMouseLeave:x,style:c,children:(0,n.jsx)(o.A,{"aria-label":a,className:"human2ai-compact-dropdown-select__control",classNames:{content:"human2ai-compact-dropdown-select__value",suffix:"human2ai-compact-dropdown-select__suffix",popup:{root:"human2ai-compact-dropdown-select__popup",list:"human2ai-compact-dropdown-select__list",listItem:"human2ai-compact-dropdown-select__option"}},builtinPlacements:ni,disabled:f,listHeight:240,onChange:function(e){h(!1),i(e)},onOpenChange:function(e){y(),h(!f&&e)},open:m,options:t.map(e=>({...e})),placement:"top"===s?"topLeft":"bottomLeft",placeholder:r,popupMatchSelectWidth:!0,popupRender:e=>(0,n.jsx)("div",{className:"human2ai-compact-dropdown-select__popup-content",onMouseEnter:b,onMouseLeave:x,children:e}),showSearch:!1,suffixIcon:(0,n.jsx)(nt.A,{className:"human2ai-compact-dropdown-select__arrow","aria-hidden":"true"}),value:e,virtual:!1})})}i(80118);let na={functionArea:"功能区",projectArea:"项目",newComposition:"新建构图",newCompositionInProject:e=>`在“${e}”中新建构图`,newSpatial:"新建 3D 空间",newSpatialInProject:e=>`在“${e}”中新建 3D 空间`,spatialSession:"3D 空间",newUiSketch:"新建 UI 界面",newUiSketchInProject:e=>`在“${e}”中新建 UI 界面`,newProject:"新建项目",styleLibrary:"风格库",projectNamePlaceholder:"输入项目名称",createProject:"创建",unassigned:"无项目",imageCompositionSession:"构图会话",uiLayoutSession:"UI 界面会话",sessionActions:"会话操作",projectActions:"项目操作",rename:"重命名",confirmRename:"确认",move:"移动",moveSessionTitle:"移动会话",selectProject:"选择项目",moveUnavailable:"没有可移动的项目",delete:"删除",projectNameConflict:"项目名称不能重复",renameProjectTitle:"重命名项目",deleteProjectTitle:"删除项目",deleteProjectDescription:"删除后无法恢复。",deleteProjectDisabled:"项目包含子项,无法删除",renameSessionTitle:"重命名会话",renameSessionPlaceholder:"输入会话名称",deleteSessionTitle:"删除会话",deleteSessionDescription:"删除后,该会话的草图和加工记录也会被删除。",cancel:"取消",loading:"正在加载项目",loadFailed:"项目列表加载失败",retry:"重试",actionFailed:"操作失败,请重试。"};function nr({projects:e,sessions:t,currentSessionId:i=null,loading:r=!1,errorMessage:o,labels:s,languageSelector:m,onCreateComposition:h,onCreateUiSketch:p,onCreateSpatial:g,onCreateProject:f,onOpenStyleLibrary:y,onRenameProject:x,onDeleteProject:b,onOpenSession:v,onRenameSession:w,onMoveSession:j,onDeleteSession:I,onRetry:S}){let P,M,A={...na,...s},L=(0,u.useRef)(null),[N,$]=(0,u.useState)(!1),[F,_]=(0,u.useState)(""),[T,R]=(0,u.useState)(null),[E,q]=(0,u.useState)(null),[D,z]=(0,u.useState)([]),B=(0,u.useRef)(new Set),[O,U]=(0,u.useState)(null),[J,W]=(0,u.useState)(""),[H,Y]=(0,u.useState)(null),[V,X]=(0,u.useState)(null),[G,K]=(0,u.useState)(""),[Z,Q]=(0,u.useState)(null),[ee,et]=(0,u.useState)(""),[ei,en]=(0,u.useState)(null),[ea,er]=(0,u.useState)(null),eo=nl(e,F),es=nl(e,J,O?.id),el=t.some(e=>null===e.projectId);(0,u.useEffect)(()=>{let t=[...e.map(e=>no(e.id)),...el?["project:unassigned"]:[]],i=t.filter(e=>!B.current.has(e));B.current=new Set(t),0!==i.length&&z(e=>[...new Set([...e,...i])])},[el,e]);let ed=new Map(t.map(e=>[ns(e.id),e])),ec=(P=e.flatMap((e,i)=>{var r,o;let s,l,d,u;return[{key:no(e.id),parentKey:null,order:i,nodeKind:"container",title:e.name,trailing:(r=e,s=A.newCompositionInProject(r.name),l=A.newUiSketchInProject(r.name),(0,n.jsxs)("span",{className:"human2ai-workspace-sidebar__project-actions",children:[(0,n.jsx)(C.A,{title:s,children:(0,n.jsx)(c.Ay,{className:"human2ai-workspace-sidebar__node-action",type:"text",size:"small",icon:(0,n.jsx)(tr.A,{"aria-hidden":"true"}),"aria-label":s,loading:"composition"===T&&E===r.id,disabled:!!(T&&("composition"!==T||E!==r.id)),onClick:e=>{e.stopPropagation(),em(r.id)},onPointerDown:e=>e.stopPropagation()})}),(0,n.jsx)(C.A,{title:l,children:(0,n.jsx)(c.Ay,{className:"human2ai-workspace-sidebar__node-action",type:"text",size:"small",icon:(0,n.jsx)(iT.A,{"aria-hidden":"true"}),"aria-label":l,loading:"ui-sketch"===T&&E===r.id,disabled:!!(T&&("ui-sketch"!==T||E!==r.id)),onClick:e=>{e.stopPropagation(),eh(r.id)},onPointerDown:e=>e.stopPropagation()})}),g&&(0,n.jsx)(C.A,{title:A.newSpatialInProject(r.name),children:(0,n.jsx)(c.Ay,{className:"human2ai-workspace-sidebar__node-action",type:"text",size:"small",icon:(0,n.jsx)(iR.A,{}),"aria-label":A.newSpatialInProject(r.name),disabled:!!T,onClick:e=>{e.stopPropagation(),ep(r.id)},onPointerDown:e=>e.stopPropagation()})}),(o=r,d=t.some(e=>e.projectId===o.id),u=[{key:"rename",label:A.rename},{key:"delete",label:A.delete,danger:!0,disabled:d,title:d?A.deleteProjectDisabled:void 0}],(0,n.jsx)(a.A,{trigger:["click"],menu:{items:u,onClick:({key:e,domEvent:t})=>{t.stopPropagation(),er(null),"rename"===e?(U(o),W(o.name)):"delete"!==e||d||Y(o)}},children:(0,n.jsx)(c.Ay,{className:"human2ai-workspace-sidebar__node-menu",type:"text",size:"small",icon:(0,n.jsx)(iE.A,{}),"aria-label":`${o.name}:${A.projectActions}`,title:A.projectActions,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})}))]}))},...t.filter(t=>t.projectId===e.id).map((t,i)=>({key:ns(t.id),parentKey:no(e.id),order:i,nodeKind:"content",title:t.title,trailing:eu(t)}))]}),0===(M=t.filter(e=>null===e.projectId).map((e,t)=>({key:ns(e.id),parentKey:"project:unassigned",order:t,nodeKind:"content",title:e.title,trailing:eu(e)}))).length?P:[...P,{key:"project:unassigned",parentKey:null,order:e.length,nodeKind:"container",title:A.unassigned},...M]);function eu(t){let i=e.every(e=>e.id===t.projectId),r=[{key:"rename",label:A.rename},{key:"move",label:A.move,disabled:i,title:i?A.moveUnavailable:void 0},{key:"delete",label:A.delete,danger:!0}];return(0,n.jsx)(a.A,{trigger:["click"],menu:{items:r,onClick:({key:e,domEvent:n})=>{n.stopPropagation(),er(null),"rename"===e?(X(t),K(t.title)):"move"!==e||i?"delete"===e&&en(t):(Q(t),et(""))}},children:(0,n.jsx)(c.Ay,{className:"human2ai-workspace-sidebar__node-menu",type:"text",size:"small",icon:(0,n.jsx)(iE.A,{}),"aria-label":`${t.title}:${A.sessionActions}`,title:A.sessionActions,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})})}async function em(e){ef(e),R("composition"),q(e??null),er(null);try{await h(e)}catch{er(A.actionFailed)}finally{R(null),q(null)}}async function eh(e){ef(e),R("ui-sketch"),q(e??null),er(null);try{await p(e)}catch{er(A.actionFailed)}finally{R(null),q(null)}}async function ep(e){ef(e),R("spatial"),q(e??null),er(null);try{await g?.(e)}catch{er(A.actionFailed)}finally{R(null),q(null)}}async function eg(){let e=F.trim();if(e&&!eo&&!T){R("create-project"),er(null);try{await f(e),$(!1),_("")}catch(e){er(nd(e,A))}finally{R(null)}}}function ef(e){let t=e?no(e):"project:unassigned";z(e=>e.includes(t)?e:[...e,t])}async function ex(){let e=J.trim();if(O&&e&&!es&&!T){R("rename-project"),er(null);try{await x(O.id,e),U(null)}catch(e){er(nd(e,A))}finally{R(null)}}}async function eb(){if(H&&!T){R("delete-project"),er(null);try{await b(H.id),Y(null)}catch(e){er(nd(e,A))}finally{R(null)}}}async function ev(){let e=G.trim();if(V&&e&&!T){R("rename-session"),er(null);try{await w(V.id,e),X(null)}catch{er(A.actionFailed)}finally{R(null)}}}async function ew(){if(Z&&ee&&!T){R("move-session"),er(null);try{await j(Z.id,ee),Q(null),et("")}catch{er(A.actionFailed)}finally{R(null)}}}async function ej(){if(ei&&!T){R("delete-session"),er(null);try{await I(ei.id),en(null)}catch{er(A.actionFailed)}finally{R(null)}}}return(0,n.jsxs)("div",{...(0,k.Se)({namespace:"human2ai",id:"workspace-sidebar",name:"Human2AiWorkspaceSidebar",category:"module",origin:"project",status:"candidate"}),className:"human2ai-workspace-sidebar",children:[(0,n.jsxs)("section",{className:"human2ai-workspace-sidebar__actions","aria-labelledby":"human2ai-sidebar-actions-title",children:[(0,n.jsx)("h2",{id:"human2ai-sidebar-actions-title",children:A.functionArea}),(0,n.jsx)(ey.u,{icon:(0,n.jsx)(tr.A,{"aria-hidden":"true"}),label:A.newComposition,collapsedLabel:A.newComposition,loading:"composition"===T&&null===E,disabled:!!(T&&("composition"!==T||null!==E)),onClick:()=>void em()}),(0,n.jsx)(ey.u,{icon:(0,n.jsx)(iT.A,{"aria-hidden":"true"}),label:A.newUiSketch,collapsedLabel:A.newUiSketch,loading:"ui-sketch"===T&&null===E,disabled:!!(T&&("ui-sketch"!==T||null!==E)),onClick:()=>void eh()}),g&&(0,n.jsx)(ey.u,{icon:(0,n.jsx)(iR.A,{"aria-hidden":"true"}),label:A.newSpatial,collapsedLabel:A.newSpatial,loading:"spatial"===T&&null===E,disabled:!!(T&&"spatial"!==T),onClick:()=>void ep()}),(0,n.jsx)(ey.u,{icon:(0,n.jsx)(iq.A,{"aria-hidden":"true"}),label:A.newProject,collapsedLabel:A.newProject,disabled:!!T,onClick:function(){er(null),$(!0)}}),(0,n.jsx)(ey.u,{icon:(0,n.jsx)(iD.A,{"aria-hidden":"true"}),label:A.styleLibrary,collapsedLabel:A.styleLibrary,onClick:y}),!ea||N||O||H||V||Z||ei?null:(0,n.jsx)("p",{className:"human2ai-workspace-sidebar__error",role:"alert",children:ea})]}),(0,n.jsxs)("section",{className:"human2ai-workspace-sidebar__projects","aria-labelledby":"human2ai-sidebar-projects-title","aria-busy":r,children:[(0,n.jsx)("h2",{id:"human2ai-sidebar-projects-title",children:A.projectArea}),r?(0,n.jsx)(ne.G,{className:"human2ai-workspace-sidebar__loading",label:A.loading,rows:6,compact:!0}):o?(0,n.jsxs)("div",{className:"human2ai-workspace-sidebar__state",role:"alert",children:[(0,n.jsx)("span",{children:A.loadFailed}),S?(0,n.jsx)(c.Ay,{type:"text",size:"small",icon:(0,n.jsx)(iz.A,{}),onClick:S,children:A.retry}):null]}):(0,n.jsx)(i7,{nodes:ec,mode:"view",defaultExpandAll:!0,showContentOrder:!1,showCurrent:!1,showIcon:!0,showStatus:!1,expandedKeys:D,onExpand:e=>z(e.map(String)),icon:({eventKey:e})=>{var t,i;let a,r,o=ed.get(String(e));return o?(t=o.sessionType,i=A,a="image-composition"===t,r="spatial"===t?i.spatialSession:a?i.imageCompositionSession:i.uiLayoutSession,(0,n.jsx)("span",{className:"human2ai-workspace-sidebar__session-type-icon","data-session-type":t,role:"img","aria-label":r,title:r,children:"spatial"===t?(0,n.jsx)(iR.A,{"aria-hidden":"true"}):a?(0,n.jsx)(tr.A,{"aria-hidden":"true"}):(0,n.jsx)(iT.A,{"aria-hidden":"true"})})):null},currentKey:i?ns(i):null,selectedKeys:i?[ns(i)]:[],onSelect:e=>{let t=String(e[0]??"");t.startsWith("session:")&&v(t.slice(8))}})]}),m?(0,n.jsx)("div",{className:"human2ai-workspace-sidebar__language-selector",children:(0,n.jsx)(nn,{...m})}):null,(0,n.jsxs)(d.A,{open:N,title:A.newProject,okText:A.createProject,footer:(e,{OkBtn:t})=>(0,n.jsx)(t,{}),confirmLoading:"create-project"===T,okButtonProps:{disabled:!F.trim()||eo},afterOpenChange:e=>{e&&L.current?.focus()},onOk:()=>void eg(),onCancel:function(){"create-project"!==T&&($(!1),_(""),er(null))},children:[(0,n.jsx)(l.A,{ref:L,id:"human2ai-project-name",name:"projectName",value:F,maxLength:200,disabled:"create-project"===T,status:eo?"error":void 0,placeholder:A.projectNamePlaceholder,"aria-label":A.projectNamePlaceholder,"aria-invalid":eo,"aria-describedby":eo||ea?"human2ai-project-name-error":void 0,onChange:e=>{_(e.target.value),er(null)},onPressEnter:()=>void eg()}),eo||ea?(0,n.jsx)("p",{id:"human2ai-project-name-error",className:"human2ai-workspace-sidebar__error",role:"alert",children:eo?A.projectNameConflict:ea}):null]}),(0,n.jsxs)(d.A,{open:!!O,title:A.renameProjectTitle,okText:A.confirmRename,footer:(e,{OkBtn:t})=>(0,n.jsx)(t,{}),confirmLoading:"rename-project"===T,okButtonProps:{disabled:!J.trim()||es},onOk:()=>void ex(),onCancel:()=>{"rename-project"!==T&&U(null)},children:[(0,n.jsx)(l.A,{autoFocus:!0,id:"human2ai-project-rename",name:"projectName",value:J,maxLength:200,disabled:"rename-project"===T,status:es?"error":void 0,placeholder:A.projectNamePlaceholder,"aria-label":A.projectNamePlaceholder,"aria-invalid":es,"aria-describedby":es||ea?"human2ai-project-rename-error":void 0,onChange:e=>{W(e.target.value),er(null)},onPressEnter:()=>void ex()}),es||ea?(0,n.jsx)("p",{id:"human2ai-project-rename-error",className:"human2ai-workspace-sidebar__error",role:"alert",children:es?A.projectNameConflict:ea}):null]}),(0,n.jsxs)(d.A,{open:!!H,title:A.deleteProjectTitle,okText:A.delete,cancelText:A.cancel,confirmLoading:"delete-project"===T,okButtonProps:{danger:!0},onOk:()=>void eb(),onCancel:()=>{"delete-project"!==T&&Y(null)},children:[(0,n.jsx)("p",{children:H?.name}),(0,n.jsx)("p",{children:A.deleteProjectDescription}),ea?(0,n.jsx)("p",{className:"human2ai-workspace-sidebar__error",role:"alert",children:ea}):null]}),(0,n.jsxs)(d.A,{open:!!V,title:A.renameSessionTitle,okText:A.confirmRename,footer:(e,{OkBtn:t})=>(0,n.jsx)(t,{}),confirmLoading:"rename-session"===T,okButtonProps:{disabled:!G.trim()},onOk:()=>void ev(),onCancel:()=>{"rename-session"!==T&&X(null)},children:[(0,n.jsx)(l.A,{autoFocus:!0,id:"human2ai-session-title",name:"sessionTitle",value:G,maxLength:200,placeholder:A.renameSessionPlaceholder,"aria-label":A.renameSessionPlaceholder,onChange:e=>K(e.target.value),onPressEnter:()=>void ev()}),ea?(0,n.jsx)("p",{className:"human2ai-workspace-sidebar__error",role:"alert",children:ea}):null]}),(0,n.jsxs)(d.A,{open:!!Z,title:A.moveSessionTitle,okText:A.move,footer:(e,{OkBtn:t})=>(0,n.jsx)(t,{}),confirmLoading:"move-session"===T,okButtonProps:{disabled:!ee},onOk:()=>void ew(),onCancel:()=>{"move-session"!==T&&(Q(null),et(""))},children:[(0,n.jsx)("p",{children:Z?.title}),(0,n.jsx)(nn,{value:ee,options:[{value:"",label:A.selectProject,disabled:!0},...e.filter(e=>e.id!==Z?.projectId).map(e=>({value:e.id,label:e.name}))],onChange:et,"aria-label":A.selectProject,disabled:"move-session"===T}),ea?(0,n.jsx)("p",{className:"human2ai-workspace-sidebar__error",role:"alert",children:ea}):null]}),(0,n.jsxs)(d.A,{open:!!ei,title:A.deleteSessionTitle,okText:A.delete,cancelText:A.cancel,confirmLoading:"delete-session"===T,okButtonProps:{danger:!0},onOk:()=>void ej(),onCancel:()=>{"delete-session"!==T&&en(null)},children:[(0,n.jsx)("p",{children:ei?.title}),(0,n.jsx)("p",{children:A.deleteSessionDescription}),ea?(0,n.jsx)("p",{className:"human2ai-workspace-sidebar__error",role:"alert",children:ea}):null]})]})}function no(e){return`project:${e}`}function ns(e){return`session:${e}`}function nl(e,t,i){let n=t.trim();return!!n&&e.some(e=>e.id!==i&&e.name.trim()===n)}function nd(e,t){if(e&&"object"==typeof e&&"code"in e){if("PROJECT_NAME_CONFLICT"===e.code)return t.projectNameConflict;if("PROJECT_NOT_EMPTY"===e.code)return t.deleteProjectDisabled}return t.actionFailed}async function nc(e){if(!navigator.clipboard?.writeText)throw Error("Clipboard API unavailable.");await navigator.clipboard.writeText(e)}function nu(e,t,i){if(!e)return i;let n=new Date(e);return Number.isNaN(n.getTime())?i:new Intl.DateTimeFormat(t,{dateStyle:"medium",timeStyle:"short"}).format(n)}function nm({primaryItem:e,createdAt:t,updatedAt:i,nodeCount:a,agentCommand:r,locale:o,labels:s,writeText:l=nc,className:d,style:c}){let m=(0,u.useId)(),[h,p]=(0,u.useState)(null);return(0,n.jsxs)("section",{...(0,k.Se)({namespace:"human2ai",id:"session-details",name:"SessionDetails",category:"module",origin:"project",status:"candidate"}),"aria-labelledby":m,className:["human2ai-session-details",d].filter(Boolean).join(" "),style:c,children:[(0,n.jsx)("h2",{id:m,children:s.title}),(0,n.jsxs)("dl",{className:"human2ai-session-details__list",children:[e?(0,n.jsxs)("div",{className:"human2ai-session-details__row",children:[(0,n.jsx)("dt",{children:e.label}),(0,n.jsx)("dd",{children:e.value})]}):null,(0,n.jsxs)("div",{className:"human2ai-session-details__row",children:[(0,n.jsx)("dt",{children:s.created}),(0,n.jsx)("dd",{children:t?(0,n.jsx)("time",{dateTime:t,children:nu(t,o,s.emptyValue)}):s.emptyValue})]}),(0,n.jsxs)("div",{className:"human2ai-session-details__row",children:[(0,n.jsx)("dt",{children:s.updated}),(0,n.jsx)("dd",{children:i?(0,n.jsx)("time",{dateTime:i,children:nu(i,o,s.emptyValue)}):s.emptyValue})]}),(0,n.jsxs)("div",{className:"human2ai-session-details__row",children:[(0,n.jsx)("dt",{children:s.nodes}),(0,n.jsx)("dd",{className:"human2ai-session-details__value",children:a})]}),(0,n.jsxs)("div",{className:"human2ai-session-details__row human2ai-session-details__row--agent",children:[(0,n.jsx)("dt",{children:s.agent}),(0,n.jsx)("dd",{children:(0,n.jsx)(Z,{className:"human2ai-session-details__action-button",size:"small",label:s.copyCommand,pendingLabel:s.copying,successLabel:s.copied,errorLabel:s.copyFailed,disabled:!r,idleIcon:(0,n.jsx)(H.A,{}),onAction:async()=>{let e="function"==typeof r?await r():r;if(!e?.trim())throw Error("Agent command is empty.");await l(e)},onStatusChange:e=>{"success"===e&&p(null)},onActionError:()=>p(s.copyFailed)})})]})]}),h?(0,n.jsx)("p",{className:"human2ai-session-details__error",role:"alert",children:h}):null]})}i(89448);var nh=i(46759),np=i(61598),ng=i(92334),nf=i(11288);function ny({images:e,title:t,aspectRatio:i="3 / 2",className:a,...r}){let o=u.Children.toArray(e);return(0,n.jsxs)("figure",{...r,...(0,m.S)("image-title-card","ImageTitleCard","card"),className:["yisi-image-title-card",a].filter(Boolean).join(" "),children:[(0,n.jsx)("div",{className:"yisi-image-title-card-media","data-empty":0===o.length?"true":void 0,"data-image-count":o.length,"data-yisiui-slot":"images",style:{aspectRatio:i},children:o.map((e,t)=>{var i;let a,r,s;return(0,n.jsx)("div",{className:"yisi-image-title-card-image",style:(a=(i=o.length)<=1?0:t/(i-1)*2-1,r=Math.min(7,3+i),s=Math.min(12,5+1.5*i),{"--yisiui-image-title-card-offset":`${a*s}%`,"--yisiui-image-title-card-rotation":`${a*r}deg`,"--yisiui-image-title-card-lift":`${5*Math.abs(a)}px`,zIndex:t+1}),children:e},t)})}),(0,n.jsx)("figcaption",{className:"yisi-image-title-card-title","data-yisiui-slot":"title",children:t})]})}i(37551),i(58206);let nx=(0,u.lazy)(()=>Promise.all([i.e(977),i.e(218),i.e(484)]).then(i.bind(i,88484))),nb=new Set(["image/png","image/jpeg","image/webp"]);function nv({styles:e,labels:t,loading:i=!1,errorMessage:a,imageUrl:r,modelUrl:o,onCreate:c,onUpdate:m,onDelete:p,onRetry:g,initialCategory:f,selection:y}){var x,b,v,w;let[j,I]=(0,u.useState)(f??"all"),[S,P]=(0,u.useState)("all"),[C,M]=(0,u.useState)(""),[A,L]=(0,u.useState)(null),[N,$]=(0,u.useState)("model"),[F,_]=(0,u.useState)(null),[T,R]=(0,u.useState)(null),[E,q]=(0,u.useState)(""),[D,z]=(0,u.useState)("visual"),[B,O]=(0,u.useState)(""),[U,J]=(0,u.useState)(""),[W,H]=(0,u.useState)([]),[Y,V]=(0,u.useState)([]),[G,K]=(0,u.useState)(!1),[Z,Q]=(0,u.useState)(!1),[ee,et]=(0,u.useState)(null),ei=(0,u.useRef)(null),en=(0,u.useRef)([]),ea=e.find(e=>e.id===A)??null,er=T&&"new"!==T?e.find(e=>e.id===T)??null:null,eo=er?.referenceImages.filter(e=>!Y.includes(e.id))??[],es=ea?.referenceImages.find(e=>e.id===F)??ea?.referenceImages[0]??null,el=(0,u.useMemo)(()=>{let t=C.trim().toLocaleLowerCase();return e.filter(e=>("all"===j||e.category===j)&&("all"===S||e.creatorType===S)&&(!t||e.name.toLocaleLowerCase().includes(t)||e.description.toLocaleLowerCase().includes(t)))},[j,S,C,e]);function ed(){G||(ec(),R(null),V([]),et(null))}function ec(){H(e=>{for(let t of e)URL.revokeObjectURL(t.previewUrl);return[]})}function eu(e){let i=e.filter(e=>nb.has(e.type)&&e.size>0&&e.size<=0xa00000);i.length!==e.length&&et(t.imageInvalid),0!==i.length&&H(e=>[...e,...i.map(e=>({file:e,previewUrl:URL.createObjectURL(e)}))])}async function eh(){let e=E.trim(),i=B.trim();if(!e||!i||!U.trim()||G||(er?!m:!c))return;K(!0),et(null);let n={name:e,category:D,description:i,promptSummary:U.trim(),newReferenceImages:W.map(({file:e})=>e),removedReferenceImageIds:Y};try{let e=er?await m(er,n):await c(n);ec(),R(null),V([]),L(e.id),_(e.referenceImages[0]?.id??null)}catch{et(t.operationFailed)}finally{K(!1)}}async function ep(){if(ea&&!Z&&p){Q(!0),et(null);try{await p(ea),L(null),_(null)}catch{et(t.operationFailed)}finally{Q(!1)}}}return(0,u.useEffect)(()=>{en.current=W},[W]),(0,u.useEffect)(()=>()=>{for(let e of en.current)URL.revokeObjectURL(e.previewUrl)},[]),(0,u.useEffect)(()=>{A&&!ea&&L(null)},[ea,A]),(0,n.jsxs)("section",{...(0,k.Se)({namespace:"human2ai",id:"style-library-view",name:"StyleLibraryView",category:"page",origin:"project",status:"candidate"}),className:"human2ai-style-library",children:[(0,n.jsxs)("header",{className:"human2ai-style-library__toolbar",children:[(0,n.jsx)(l.A,{className:"human2ai-style-library__search",allowClear:!0,prefix:(0,n.jsx)(nh.A,{"aria-hidden":"true"}),value:C,placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,onChange:e=>M(e.target.value)}),(0,n.jsx)(ir,{"aria-label":t.category,value:j,items:[{key:"all",label:t.allCategories,mode:"text-only"},{key:"visual",label:t.visualCategory,mode:"text-only"},{key:"ui",label:t.uiCategory,mode:"text-only"},{key:"spatial",label:t.spatialCategory,mode:"text-only"}],onChange:e=>I(e)}),(0,n.jsx)(ir,{"aria-label":t.creator,value:S,items:[{key:"all",label:t.allCreators,mode:"text-only"},{key:"user",label:t.userCreator,mode:"text-only"},{key:"agent",label:t.agentCreator,mode:"text-only"}],onChange:e=>P(e)}),c?(0,n.jsx)(X.J,{type:"primary",mode:"with-icon",icon:(0,n.jsx)(em.A,{"aria-hidden":"true"}),backgroundColor:"color.action.primaryActive",textColor:"color.text.onPrimary",onClick:function(){ec(),R("new"),q(""),z("visual"),O(""),J(""),V([]),et(null)},children:t.newStyle}):null]}),i?(0,n.jsx)(ne.G,{label:t.loading,rows:5}):a?(0,n.jsxs)("div",{className:"human2ai-style-library__page-state",role:"alert",children:[(0,n.jsx)("span",{children:t.loadFailed}),g?(0,n.jsx)(X.J,{type:"text",mode:"with-icon",icon:(0,n.jsx)(iz.A,{"aria-hidden":"true"}),onClick:g,children:t.retry}):null]}):0===el.length?(0,n.jsx)("div",{className:"human2ai-style-library__page-state",children:0===e.length?t.empty:t.noMatches}):(0,n.jsx)("div",{className:"human2ai-style-library__grid",children:el.map(e=>{let i=e.referenceImages[0];return(0,n.jsxs)("div",{className:"human2ai-style-library__card",children:[(0,n.jsx)(ny,{images:e.referenceImages.length?e.referenceImages.slice(0,3).map(t=>(0,n.jsx)("img",{src:r(e.id,t.id),alt:""},t.id)):e.previewModel?[(0,n.jsxs)("div",{className:"human2ai-style-library__model-cover",children:[(0,n.jsx)(np.A,{"aria-hidden":"true"}),(0,n.jsx)("span",{children:t.model.label})]},"model")]:[],title:e.name}),(0,n.jsx)("button",{className:"human2ai-style-library__card-trigger",type:"button","aria-label":t.openStyle(e.name),onClick:()=>{$("model"),L(e.id),_(i?.id??null),et(null)}})]},e.id)})}),(0,n.jsxs)(d.A,{open:!!ea,centered:!0,width:1120,title:ea?(0,n.jsxs)("div",{className:"human2ai-style-library__preview-heading",children:[(0,n.jsx)("span",{className:"human2ai-style-library__preview-title",children:ea.name}),(0,n.jsxs)("span",{className:"human2ai-style-library__badges",children:[(0,n.jsx)("span",{children:(x=ea.category,({visual:(b=t).visualCategory,ui:b.uiCategory,spatial:b.spatialCategory})[x])}),(0,n.jsx)("span",{children:(v=ea.creatorType,w=t,"user"===v?w.userCreator:w.agentCreator)})]})]}):null,closeIcon:(0,n.jsx)(ng.A,{"aria-label":t.closePreview}),footer:ea?(0,n.jsxs)("div",{className:"human2ai-style-library__preview-actions",children:[p?(0,n.jsx)(h.x,{type:"text",icon:(0,n.jsx)(s.A,{"aria-hidden":"true"}),title:t.deleteTitle,description:t.deleteDescription,scopeLabel:ea.name,confirmLabel:t.delete,cancelLabel:t.cancel,loading:Z,onConfirm:ep,children:t.delete}):null,m?(0,n.jsx)(X.J,{type:"primary",mode:"with-icon",icon:(0,n.jsx)(nf.A,{"aria-hidden":"true"}),backgroundColor:"color.action.primaryActive",textColor:"color.text.onPrimary",onClick:()=>{ec(),R(ea.id),q(ea.name),z(ea.category),O(ea.description),J(ea.promptSummary),V([]),et(null)},children:t.editStyle}):null,y?(0,n.jsx)(X.J,{className:"human2ai-style-library__select-action",type:"primary",loading:G,backgroundColor:"color.action.primaryActive",textColor:"color.text.onPrimary",onClick:async()=>{if(!G){K(!0),et(null);try{await y.onSelect(ea),L(null)}catch{et(t.operationFailed)}finally{K(!1)}}},children:y.label}):null]}):null,onCancel:()=>{Z||G||(L(null),_(null),et(null))},children:[ea?(0,n.jsxs)("div",{className:"human2ai-style-library__preview",children:[(0,n.jsxs)("section",{"aria-labelledby":"style-preview-references",children:[ea.previewModel&&o?(0,n.jsx)("div",{className:"human2ai-style-library__reference-switch",id:"style-preview-references",children:(0,n.jsx)(ir,{"aria-label":t.references,value:N,items:[{key:"model",label:t.model.label,mode:"text-only"},{key:"image",label:t.references,mode:"text-only"}],onChange:e=>$(e)})}):(0,n.jsx)("h2",{id:"style-preview-references",children:t.references}),ea.previewModel&&o&&"model"===N?(0,n.jsx)(u.Suspense,{fallback:(0,n.jsx)("div",{role:"status",children:t.model.loading}),children:(0,n.jsx)(nx,{url:o(ea.id,ea.previewModel.id),labels:t.model},ea.previewModel.id)}):es?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"human2ai-style-library__active-reference",children:(0,n.jsx)("img",{src:r(ea.id,es.id),alt:ea.name})}),ea.referenceImages.length>1?(0,n.jsx)("div",{className:"human2ai-style-library__thumbnails",children:ea.referenceImages.map((e,i)=>(0,n.jsx)("button",{type:"button","aria-label":`${t.references} ${i+1}`,"aria-pressed":e.id===es.id,onClick:()=>_(e.id),children:(0,n.jsx)("img",{src:r(ea.id,e.id),alt:""})},e.id))}):null]}):(0,n.jsx)("div",{className:"human2ai-style-library__no-reference",children:t.noReferences})]}),(0,n.jsxs)("section",{className:"human2ai-style-library__specification","aria-labelledby":"style-preview-description",tabIndex:0,children:[(0,n.jsx)("h2",{id:"style-preview-description",children:t.description}),(0,n.jsx)("p",{className:"human2ai-style-library__description",children:ea.description}),(0,n.jsx)("h2",{children:t.promptSummary}),(0,n.jsx)("p",{className:"human2ai-style-library__description",children:ea.promptSummary})]})]}):null,ee&&ea?(0,n.jsx)("p",{className:"human2ai-style-library__error",role:"alert",children:ee}):null]}),(0,n.jsx)(d.A,{open:null!==T,title:er?t.editStyle:t.newStyle,footer:null,onCancel:ed,children:(0,n.jsxs)("div",{className:"human2ai-style-library__editor",onPaste:function(e){let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith("image/"));0!==t.length&&(e.preventDefault(),eu(t))},children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("span",{children:t.name}),(0,n.jsx)(l.A,{autoFocus:!0,value:E,maxLength:200,placeholder:t.namePlaceholder,onChange:e=>q(e.target.value)})]}),(0,n.jsxs)("div",{className:"human2ai-style-library__field",children:[(0,n.jsx)("span",{children:t.category}),(0,n.jsx)(ir,{"aria-label":t.category,value:D,items:[{key:"visual",label:t.visualCategory,mode:"text-only"},{key:"ui",label:t.uiCategory,mode:"text-only"},{key:"spatial",label:t.spatialCategory,mode:"text-only"}],onChange:e=>z(e)})]}),(0,n.jsxs)("label",{children:[(0,n.jsx)("span",{children:t.description}),(0,n.jsx)(l.A.TextArea,{value:B,maxLength:2e4,autoSize:{minRows:6,maxRows:14},placeholder:"spatial"===D?t.spatialDescriptionPlaceholder:t.descriptionPlaceholder,onChange:e=>O(e.target.value)})]}),(0,n.jsxs)("div",{className:"human2ai-style-library__field",children:[(0,n.jsx)("span",{children:t.references}),(0,n.jsxs)("div",{className:"human2ai-style-library__editor-references",children:[eo.map(e=>(0,n.jsx)(nw,{reference:e,previewUrl:r(e.styleId,e.id),removeLabel:t.removeReference,onRemove:()=>V(t=>[...t,e.id])},e.id)),W.map(e=>(0,n.jsx)(nw,{previewUrl:e.previewUrl,removeLabel:t.removeReference,onRemove:()=>{URL.revokeObjectURL(e.previewUrl),H(t=>t.filter(t=>t!==e))}},e.previewUrl)),(0,n.jsxs)("button",{className:"human2ai-style-library__add-reference",type:"button",onClick:()=>ei.current?.click(),children:[(0,n.jsx)(em.A,{"aria-hidden":"true"}),(0,n.jsx)("span",{children:t.addReferences})]})]}),(0,n.jsx)("input",{ref:ei,className:"human2ai-style-library__file-input",type:"file",accept:"image/png,image/jpeg,image/webp",multiple:!0,onChange:function(e){eu(Array.from(e.target.files??[])),e.target.value=""}}),(0,n.jsxs)("span",{className:"human2ai-style-library__image-hint",children:[t.pasteHint," ",t.fileTypes]})]}),(0,n.jsxs)("label",{children:[(0,n.jsx)("span",{children:t.promptSummary}),(0,n.jsx)(l.A.TextArea,{value:U,maxLength:240,autoSize:{minRows:2,maxRows:3},placeholder:t.promptSummaryPlaceholder,onChange:e=>J(e.target.value)})]}),ee?(0,n.jsx)("p",{className:"human2ai-style-library__error",role:"alert",children:ee}):null,(0,n.jsxs)("div",{className:"human2ai-style-library__editor-actions",children:[(0,n.jsx)(X.J,{disabled:G,onClick:ed,children:t.cancel}),(0,n.jsx)(X.J,{type:"primary",loading:G,disabled:!E.trim()||!B.trim()||!U.trim(),backgroundColor:"color.action.primaryActive",textColor:"color.text.onPrimary",onClick:()=>void eh(),children:t.save})]})]})})]})}function nw({reference:e,previewUrl:t,removeLabel:i,onRemove:a}){return(0,n.jsxs)("div",{className:"human2ai-style-library__editor-reference",children:[(0,n.jsx)("img",{src:t,alt:""}),(0,n.jsx)("button",{type:"button","aria-label":i,onClick:a,children:(0,n.jsx)(ng.A,{"aria-hidden":"true"})}),e?(0,n.jsx)("span",{children:e.position+1}):null]})}function nj({styles:e,currentStyle:t,category:i,labels:a,libraryLabels:r,imageUrl:o,modelUrl:s,onBind:l,onRetry:c,loading:m=!1,saving:h=!1,disabled:p=!1,error:g,pending:f=!1}){let[y,x]=(0,u.useState)(!1),b=(0,u.useId)();return(0,n.jsxs)("section",{...(0,k.Se)({namespace:"human2ai",id:"session-style-picker",name:"SessionStylePicker",category:"module",origin:"project",status:"candidate"}),className:"human2ai-session-style-picker","aria-labelledby":b,children:[(0,n.jsx)("h2",{id:b,children:a.title}),(0,n.jsxs)("div",{className:"human2ai-session-style-picker__controls",children:[(0,n.jsx)(X.J,{className:"human2ai-session-style-picker__choose",mode:"with-icon",icon:(0,n.jsx)(nt.A,{"aria-hidden":"true"}),disabled:p||h,loading:h,onClick:()=>x(!0),children:t?.name??a.choose}),t?(0,n.jsx)(C.A,{title:a.unbind,children:(0,n.jsx)(X.J,{type:"text",mode:"icon-only",icon:(0,n.jsx)(ng.A,{"aria-hidden":"true"}),"aria-label":a.unbind,disabled:p||h||m,onClick:()=>void l(null).catch(()=>void 0)})}):null]}),t&&f?(0,n.jsx)("p",{className:"human2ai-session-style-picker__status",role:"status",children:a.pending}):null,g?(0,n.jsx)("p",{className:"human2ai-session-style-picker__error",role:"alert",children:g}):null,(0,n.jsx)(d.A,{open:y,title:a.dialogTitle,closable:{"aria-label":r.closePreview,disabled:h},closeIcon:(0,n.jsx)(ng.A,{"aria-hidden":"true"}),width:1e3,footer:null,onCancel:()=>{h||x(!1)},destroyOnHidden:!0,children:(0,n.jsx)(nv,{styles:e,labels:r,loading:m,errorMessage:g,imageUrl:o,modelUrl:s,initialCategory:i,onRetry:c,selection:{label:a.select,onSelect:async e=>{await l(e.id),x(!1)}}})})]})}i(68743);var nk=i(1660);function nI({items:e,value:t,labels:i,onChange:r,onRename:o,onDelete:s,onCreate:c,onReorder:m}){let[h,p]=(0,u.useState)(null),[g,f]=(0,u.useState)(null),[y,x]=(0,u.useState)(""),[b,v]=(0,u.useState)(null),w=(0,u.useRef)(null),j=(0,u.useRef)(null),I=(0,u.useRef)(null),S=(0,u.useRef)(null),P=(0,u.useRef)(!1),A=(0,u.useRef)(null),L=e.find(e=>e.id===g?.id),N=e.map(e=>e.id).join("\0");function $(){j.current&&clearTimeout(j.current),j.current=null,I.current=null,S.current=null,v(null)}function F(e){let t=I.current;if(!t)return;if(!t.active){Math.hypot(e.clientX-t.x,e.clientY-t.y)>6&&$();return}let i=[...w.current?.querySelectorAll("[data-state-id]")??[]],n=i.find(t=>e.clientX<t.getBoundingClientRect().right)??i.at(-1);if(!n)return;let a=n.getBoundingClientRect(),r={id:t.id,x:e.clientX,y:e.clientY,target:n.dataset.stateId,after:e.clientX>a.x+a.width/2};S.current=r,v(r);let o=w.current;if(o){let t=o.getBoundingClientRect();e.clientX>t.right-32?o.scrollLeft+=16:e.clientX<t.left+32&&(o.scrollLeft-=16)}}function _(){let t=S.current;if(t&&t.target!==t.id){let i=e.map(e=>e.id).filter(e=>e!==t.id);i.splice(i.indexOf(t.target)+ +!!t.after,0,t.id),m(i)}$()}function T(e,t=!1){requestAnimationFrame(()=>{let i=[...w.current?.querySelectorAll("[data-state-id]")??[]].find(t=>t.dataset.stateId===e);i?.querySelector(t?".human2ai-state-tabs__more":"button[aria-pressed]")?.focus()})}return(0,u.useEffect)(()=>{let e=()=>$();return window.addEventListener("blur",e),()=>{j.current&&clearTimeout(j.current),window.removeEventListener("blur",e)}},[]),(0,u.useEffect)(()=>{$()},[N,t]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{...(0,k.Se)({namespace:"human2ai",id:"ui-sketch-state-tabs",name:"UiSketchStateTabs",category:"module",origin:"project",status:"candidate"}),ref:w,className:"human2ai-state-tabs",role:"toolbar","aria-label":i.switch,onKeyDown:e=>{"Escape"===e.key&&$()},children:[e.map((o,s)=>(0,n.jsxs)("div",{className:"human2ai-state-tabs__item","data-state-id":o.id,"data-selected":t===o.id,"data-dragging":b?.id===o.id,"data-drop":b&&b.target===o.id&&b.id!==o.id?b.after?"after":"before":void 0,children:[(0,n.jsx)(C.A,{title:i.reorderHint,mouseEnterDelay:1,children:(0,n.jsx)(X.J,{type:"text","aria-pressed":t===o.id,tabIndex:t===o.id?0:-1,className:"human2ai-state-tabs__tab",onPointerDown:t=>{var i;return i=o.id,void(0===t.button&&!(e.length<2)&&($(),P.current=!1,I.current={id:i,x:t.clientX,y:t.clientY,active:!1},t.currentTarget.setPointerCapture(t.pointerId),j.current=setTimeout(()=>{if(!I.current)return;I.current.active=!0,P.current=!0,p(null);let e={id:i,x:t.clientX,y:t.clientY,target:i,after:!1};S.current=e,v(e)},350)))},onPointerMove:F,onPointerUp:_,onPointerCancel:$,onLostPointerCapture:$,onClick:()=>{if(P.current){P.current=!1;return}r(o.id)},onKeyDown:t=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(t.key))return;t.preventDefault();let i="Home"===t.key?0:"End"===t.key?e.length-1:Math.max(0,Math.min(e.length-1,s+("ArrowRight"===t.key?1:-1)));if(t.ctrlKey&&t.shiftKey){let t=e.map(e=>e.id);t.splice(s,1),t.splice(i,0,o.id),m(t),T(o.id)}else r(e[i].id),T(e[i].id)},children:(0,n.jsx)("span",{className:"human2ai-state-tabs__label",title:o.label,children:o.label})})}),(0,n.jsx)(a.A,{trigger:["click"],open:h===o.id,onOpenChange:e=>p(e?o.id:null),menu:{items:[{key:"new",label:i.new},{key:"rename",label:i.rename},{key:"delete",label:i.delete,danger:!0,disabled:1===e.length}],onClick:({key:e})=>{p(null),"new"===e?c(o.id):(A.current=o.id,x(o.label),f({id:o.id,kind:e}))}},children:(0,n.jsx)(X.J,{type:"text",mode:"icon-only",icon:(0,n.jsx)(nk.A,{"aria-hidden":"true"}),className:"human2ai-state-tabs__more","data-open":h===o.id,"aria-label":i.actions(o.label),"aria-haspopup":"menu","aria-expanded":h===o.id})})]},o.id)),1===e.length&&(0,n.jsx)(X.J,{type:"text",className:"human2ai-state-tabs__add",onClick:()=>c(t),children:i.add})]}),(0,n.jsx)(d.A,{open:!!L,title:g?.kind==="rename"?i.rename:i.deleteTitle(L?.label??""),closable:!1,okText:g?.kind==="rename"?i.rename:i.delete,cancelText:i.cancel,okButtonProps:{danger:g?.kind==="delete",disabled:g?.kind==="rename"?!y.trim():e.length<2},onCancel:()=>f(null),afterClose:()=>{let i=A.current;i&&e.some(e=>e.id===i)?T(i,!0):T(t)},onOk:()=>{if(L&&g){if("rename"===g.kind){if(!y.trim())return;o(g.id,y.trim())}else e.length>1&&s(g.id);f(null)}},destroyOnHidden:!0,afterOpenChange:e=>{e&&g?.kind==="rename"&&document.querySelector(".human2ai-state-tabs__name")?.select()},children:g?.kind==="rename"?(0,n.jsx)(l.A,{className:"human2ai-state-tabs__name","aria-label":i.name,value:y,maxLength:100,onChange:e=>x(e.target.value),onPressEnter:()=>{L&&y.trim()&&(o(L.id,y.trim()),f(null))}}):null}),b&&(0,M.createPortal)((0,n.jsx)("div",{className:"human2ai-state-tabs__ghost","aria-hidden":"true",style:{left:b.x+12,top:b.y+12},children:e.find(e=>e.id===b.id)?.label}),document.body)]})}i(73251);var nS=i(99441),nP=i(33960),nC=i(53239),nM=i(25865),nA=i(28462),nL=i(28110),nN=i(83424),n$=i(40129),nF=i(18522),n_=i(55408),nT=i(21071),nR=i(95813),nE=i(84910),nq=i(76770),nD=i(15362);function nz(e){let t=(0,nT.cj)(e);return e=>{let i="characterId"in e?e.characterId:"put-character"===e.type?e.character.id:void 0,n="put-object"===e.type?e.object.id:void 0,a="put-camera-box"===e.type?e.box.id:void 0,r=t.characters.find(e=>e.id===i),o=t.objects.find(e=>e.id===n),s=t.cameraBoxes?.find(e=>e.id===a);if(!r&&!o&&!s)return(0,nT.bK)(t,[e]);let l=(0,nT.bK)({...t,characters:r?[r]:[],objects:o?[o]:[],cameraBoxes:s?[s]:[]},[e]);return{constrained:l.constrained,draft:{...t,characters:r?t.characters.map(e=>e.id===i?l.draft.characters[0]:e):t.characters,objects:o?t.objects.map(e=>e.id===n?l.draft.objects[0]:e):t.objects,...t.cameraBoxes?{cameraBoxes:s?t.cameraBoxes.map(e=>e.id===a?l.draft.cameraBoxes[0]:e):t.cameraBoxes}:{}}}}}var nB=i(28179);let nO={ambient:.3,key:.85,direction:[-.65,.6,1.3],shadowSize:2048,shadowRadius:2,shadowStrength:.65},nU=e=>{let t=[];return e.traverse(e=>{e instanceof nE.eaF&&!e.userData.rig&&t.push(e)}),t};function nJ(e,t,i){let n=nU(e),a=[],r=(e,t)=>{e.geometry.getAttribute("color")?.array!==t&&e.geometry.setAttribute("color",new nE.THS(t,3));let i=e.material;i.vertexColors=!0,i.shadowSide=nE.$EB,e.castShadow=!0,e.receiveShadow=!0};if(i)return n.forEach((e,t)=>r(e,i[t])),i;for(let e of n){let t=e.geometry.getAttribute("position"),i=e.geometry.index;for(let n=0;n<(i?.count??t.count);n+=3){let[r,o,s]=[0,1,2].map(a=>new nE.Pq0().fromBufferAttribute(t,i?i.getX(n+a):n+a).applyMatrix4(e.matrixWorld));a.push({a:r,b:o,c:s,bounds:new nE.NRn().setFromPoints([r,o,s]),center:r.clone().add(o).add(s).multiplyScalar(1/3)})}}if(!a.length)return[];let o=[],s=function e(t){let i=new nE.NRn;for(let e of t)i.union(e.bounds);if(t.length<=12)return{bounds:i,triangles:t};let n=i.getSize(new nE.Pq0),a=n.x>n.y&&n.x>n.z?"x":n.y>n.z?"y":"z";t.sort((e,t)=>e.center[a]-t.center[a]);let r=Math.floor(t.length/2);return{bounds:i,left:e(t.slice(0,r)),right:e(t.slice(r))}}(a),l=new nE.RlV,d=new nE.Pq0,c=(e,t)=>!(e.bounds.distanceToPoint(l.origin)>t)&&!!l.intersectsBox(e.bounds)&&(e.triangles?e.triangles.some(e=>null!==l.intersectTriangle(e.a,e.b,e.c,!1,d)&&d.distanceToSquared(l.origin)<t*t):c(e.left,t)||c(e.right,t)),u=new nE.Pq0,m=new nE.Pq0,h=new nE.Pq0,p=new nE.Pq0,g=Array.from({length:8},(e,t)=>{let i=Math.sqrt(1-(t+.5)/8),n=Math.sqrt(1-i*i),a=2.399963229728653*t;return[n*Math.cos(a),n*Math.sin(a),i]});for(let e of n){let i=e.geometry.getAttribute("position"),n=e.geometry.getAttribute("normal"),a=new nE.dwI().getNormalMatrix(e.matrixWorld),d=t.characters.find(t=>t.id===e.userData.characterId),f=(d?.height??Math.max(...t.objects.find(t=>t.id===e.userData.objectId)?.size??[1]))*.025,y=new Float32Array(3*i.count);for(let t=0;t<i.count;t++){u.fromBufferAttribute(i,t).applyMatrix4(e.matrixWorld),m.fromBufferAttribute(n,t).applyNormalMatrix(a),h.set(.9>Math.abs(m.y)?0:1,+(.9>Math.abs(m.y)),0).cross(m).normalize(),p.crossVectors(m,h),l.origin.copy(u).addScaledVector(m,.025*f);let r=0;for(let[e,t,i]of g)l.direction.copy(m).multiplyScalar(i).addScaledVector(h,e).addScaledVector(p,t),c(s,f)&&r++;y.fill(1-.5*r/g.length,3*t,3*t+3)}r(e,y),o.push(y)}return o}var nW=i(42621),nH=i(23347),nY=i(96826);class nV{constructor(e={}){this.options=e,this.scene=new nE.YJl,this.entries=new Map,this.baseColors=new WeakMap,this.shading=!1,this.disposed=!1}update(e,t={}){let i=new Map,n=!1;for(let a of[...e.characters,...e.objects]){let r=JSON.stringify([(0,nW.N)(a),!!t.showRig]),o=this.entries.get(a.id);if(o?.key!==r){let i=JSON.stringify([(0,nW.N)({...a,position:[0,0,0],rotation:[0,0,0]}),!!t.showRig]);if(o?.shapeKey===i)o.group.matrixAutoUpdate=!1,o.group.matrix.copy((0,nH.NT)(a).multiply(o.origin)),o.group.matrixWorldNeedsUpdate=!0,o.key=r;else{let n="bones"in a?{...e,characters:[a],objects:[]}:{...e,characters:[],objects:[a]},s=o?.group.children.filter(e=>e.userData.rig)??[];s.length&&o.group.remove(...s);let l=o?.group.children[0];if(o&&"bones"in a&&l instanceof nE.YJl&&(0,nY.m)(l,a))o.group.matrixAutoUpdate=!0,o.group.matrix.identity(),o={key:r,shapeKey:i,group:o.group,origin:(0,nH.NT)(a).invert()};else{let e=(0,nB.bh)(n);o&&(0,nH.sZ)(o.group,e)?((0,nB.en)(e),o={key:r,shapeKey:i,group:o.group,origin:(0,nH.NT)(a).invert()}):(o&&(this.scene.remove(o.group),(0,nB.en)(o.group)),o={key:r,shapeKey:i,group:e,origin:(0,nH.NT)(a).invert()})}"bones"in a&&t.showRig&&"geometric"!==a.appearance?(s.length&&o.group.add(...s),(0,nB.yz)(o.group,a,!0)):s.length&&(0,nB.en)(new nE.YJl().add(...s)),(0,nH.SZ)(o.group,this.baseColors)}n=!0}i.set(a.id,o)}for(let[e,t]of this.entries)i.has(e)||(this.scene.remove(t.group),(0,nB.en)(t.group),n=!0);let a=[...i.values()].map(e=>e.group);a.some((e,t)=>this.scene.children[t]!==e)&&(this.scene.clear(),this.scene.add(...a),n=!0),this.entries=i,n&&this.scene.updateMatrixWorld(!0);let r=JSON.stringify([...i.values()].map(e=>e.key)),o=nU(this.scene),s=o.map(e=>JSON.stringify([e.userData,e.geometry.getAttribute("position").count])).join("/"),l=!this.colors||s!==this.shadedTopology||r!==this.shadedKey;return this.desired=!t.dragging&&l?{draft:e,key:r,topology:s}:void 0,this.options.shade?(this.colors&&s===this.shadedTopology||(this.colors=o.map(e=>new Float32Array(3*e.geometry.getAttribute("position").count).fill(1)),this.shadedTopology=s,this.shadedKey=void 0),n&&nJ(this.scene,e,this.colors),this.scheduleShading()):this.colors&&s===this.shadedTopology&&(t.dragging||!l)?n&&nJ(this.scene,e,this.colors):(this.colors=nJ(this.scene,e),this.shadedKey=r,this.shadedTopology=s),n}scheduleShading(){if(this.shading||!this.desired||this.disposed)return;let e=this.desired;this.shading=!0,this.options.shade(e.draft).then(t=>{this.disposed||this.desired?.key!==e.key||this.desired.topology!==e.topology||(this.colors=nJ(this.scene,e.draft,t),this.shadedKey=e.key,this.shadedTopology=e.topology,this.desired=void 0,this.options.onShaded?.())}).catch(()=>{this.desired?.key===e.key&&(this.desired=void 0)}).finally(()=>{this.shading=!1,this.scheduleShading()})}dispose(){this.disposed=!0,this.desired=void 0,(0,nB.en)(this.scene),this.scene.clear(),this.entries.clear(),this.colors=void 0,this.shadedKey=void 0,this.shadedTopology=void 0}}function nX(e){let t=(0,u.useRef)(null),a=(0,u.useRef)(e);a.current=e;let r=(0,u.useRef)(null),[o,s]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{let e,n,o,l,d,c=t.current;try{e=new nR.JeP({antialias:!0,alpha:!0})}catch{s(!0);return}e.setPixelRatio(Math.min(window.devicePixelRatio,2)),e.shadowMap.enabled=!0,e.shadowMap.type=nE.QP0,e.shadowMap.autoUpdate=!1,c.appendChild(e.domElement);let u=new nE.Z58,m=new nE.ubm(45,1,.01,3e4);m.position.set(3,2.2,5);let h=new nq.N(m,e.domElement);h.target.set(0,.9,0),h.update();let p=new nE.fTw(20,40,"#a4aeb8","#e0e4e8"),g=new nE.$p8(0xffffff);u.add(p,g);let f=new nE.ZyN(0xffffff);u.add(f,f.target);let y=new nE.B69;u.add(y);let x=new nD.ZU(m,e.domElement);x.setSpace("world"),x.setSize(.75),u.add(x.getHelper());let b=new nV({shade:e=>new Promise((t,a)=>{n??=new Worker(i.tu(new URL(i.p+i.u(101),i.b))),o=a,n.onmessage=e=>{o=void 0,t(e.data.colors)},n.onerror=e=>{n?.terminate(),n=void 0,o=void 0,a(e)},n.postMessage(e)}),onShaded:()=>{e.shadowMap.needsUpdate=!0,M()}}),v=b.scene;u.add(v);let w=new nE.YJl;u.add(w);let j=new nE.YJl;u.add(j);let k=!1,I=null,S=null,P=0,C=0,M=()=>{C||(C=requestAnimationFrame(()=>{C=0,e.render(u,m)}))},A=t=>{let i=b.update(t,{showRig:a.current.showRig,dragging:k||a.current.interacting}),n=!!t.lightingEnabled!==l;l=!!t.lightingEnabled;let r=t.lightingEnabled?nO:{...nO,ambient:1,key:0,shadowStrength:0};g.intensity=r.ambient*Math.PI,f.intensity=r.key*Math.PI,e.shadowMap.enabled=!!r.shadowStrength,(i||n)&&(e.shadowMap.enabled&&function(e,t){let i=new nE.NRn;for(let e of nU(t))i.union(new nE.NRn().setFromObject(e));let n=i.isEmpty()?new nE.Pq0:i.getCenter(new nE.Pq0),a=Math.max(.1,i.getSize(new nE.Pq0).length());e.position.copy(n).addScaledVector(new nE.Pq0(...nO.direction).normalize(),a),e.target.position.copy(n),e.target.updateMatrixWorld(),e.updateMatrixWorld();let r=e.shadow.camera;r.position.copy(e.position),r.lookAt(n),r.updateMatrixWorld();let o=i.isEmpty()?new nE.NRn(new nE.Pq0(-.5,-.5,-.5),new nE.Pq0(.5,.5,.5)):i.clone().applyMatrix4(r.matrixWorldInverse),s=.02*a;r.left=o.min.x-s,r.right=o.max.x+s,r.bottom=o.min.y-s,r.top=o.max.y+s,r.near=Math.max(.001,-o.max.z-s),r.far=Math.max(r.near+.1,-o.min.z+s),r.updateProjectionMatrix();let l=Math.max(r.right-r.left,r.top-r.bottom)/nO.shadowSize;e.castShadow=!0,e.shadow.mapSize.setScalar(nO.shadowSize),e.shadow.radius=nO.shadowRadius,e.shadow.intensity=nO.shadowStrength,e.shadow.normalBias=2*l,e.shadow.bias=-(2*l)/(r.far-r.near),e.shadow.needsUpdate=!0}(f,v),e.shadowMap.needsUpdate=!0);let o=a.current.selection,s=getComputedStyle(c).getPropertyValue("--yisiui-color-action-primary").trim()||"#467bd3",u=JSON.stringify([t.cameras,t.cameraBoxes,a.current.showCameras,o&&("cameraId"in o||"cameraBoxId"in o)?o:null,s]);if(d!==u){for(let e of(d=u,(0,nB.en)(j),j.clear(),!1===a.current.showCameras?[]:t.cameras)){let t=o&&"cameraId"in o&&o.cameraId===e.id,i=(0,nB.Ls)(e);i.far=Math.max(2*i.near,i.position.distanceTo((0,nT.i1)(e.target))),i.updateProjectionMatrix();let n=new nE.WTh(i),a=n.material;a.vertexColors=!1,a.color.set(t?s:"#9cbbd3"),a.transparent=!0,a.opacity=t?.95:.45,a.depthTest=!1,n.renderOrder=1,n.userData.cameraId=e.id,j.add(n)}for(let e of((0,nB.en)(w),w.clear(),t.cameraBoxes??[])){let t=o&&"cameraBoxId"in o&&o.cameraBoxId===e.id,i=new nE.iNn(e.size,e.size,e.size),n=new nE.DXC(new nE.TDQ(i),new nE.mrM({color:t?"#467bd3":"#9cbbd3",transparent:!0,opacity:t?.95:.45,depthTest:!1}));if(i.dispose(),n.position.copy((0,nT.i1)(e.position)),n.quaternion.copy((0,nT.b5)(e.rotation)),n.userData.cameraBoxId=e.id,n.renderOrder=1,w.add(n),t){let t=new nE.IzY(.25*e.size);t.position.copy(n.position),t.quaternion.copy(n.quaternion),w.add(t)}}}let m=o&&"characterId"in o&&o.handBoneId?t.characters.find(e=>e.id===o.characterId):void 0,h=m?.bones.find(e=>e.id===(o&&"characterId"in o?o.handBoneId:void 0)),p=m&&h?(0,nT.Au)(m,h):void 0,y=e=>o&&("characterId"in o?e.characterId===o.characterId&&(p?p.has(e.jointId)||e.jointId===h.startJointId||p.has(m.bones.find(t=>t.id===e.boneId)?.endJointId??""):o.jointId?e.jointId===o.jointId:!o.boneId||e.boneId===o.boneId):"objectId"in o&&e.objectId===o.objectId);v.traverse(e=>{if(!(e instanceof nE.eaF)||!(e.material instanceof nE.G_z))return;if(e instanceof nE.ZLX&&e.userData.rig){let t=new nE.Q1f,i="joint"===e.userData.rig?"#e6a65c":"#728aa1";e.userData.instances.forEach((n,a)=>e.setColorAt(a,t.set(y(n)?s:i))),e.instanceColor&&(e.instanceColor.needsUpdate=!0);return}let i=b.baseColors.get(e);if(i&&e.material.color.copy(i),!o)return;let n=e.userData;y(n)&&((0,nT.dS)(n.modelPart??"")&&t.characters.find(e=>e.id===n.characterId)?.appearance==="geometric"?e.material.color.lerp(new nE.Q1f("#ffffff"),.3):e.material.color.set(s))}),M()},L=()=>{if(k)return;let{draft:e,selection:t,mode:i,disabled:n}=a.current,r=t&&"characterId"in t?t.jointId?"translate":t.boneId||t.handBoneId?"rotate":i:i;if(x.setMode(r),x.setSpace(t&&"characterId"in t&&(t.boneId||t.handBoneId)?"local":"world"),x.detach(),n||!t||"cameraId"in t)return void M();if("characterId"in t){let i=e.characters.find(e=>e.id===t.characterId);if(!i)return;let n=i.joints.find(e=>e.id===t.jointId),a=i.bones.find(e=>e.id===(t.boneId??t.handBoneId));if(a){let e=(0,nT.Oe)(i)[a.id];if(y.position.copy(e.position),y.quaternion.copy(e.rotation).multiply((0,nT.IA)(i,a)),a.lockRotation||(0,nT.j4)(a))return void M()}else if(n){let e=(0,nT.ms)(i)[n.id];if(y.position.copy(e.position),y.quaternion.copy(e.rotation),n.lockPosition)return void M()}else y.position.copy((0,nT.i1)(i.position)),y.quaternion.copy((0,nT.b5)(i.rotation))}else{let i="cameraBoxId"in t?e.cameraBoxes?.find(e=>e.id===t.cameraBoxId):e.objects.find(e=>e.id===t.objectId);if(!i)return;y.position.copy((0,nT.i1)(i.position)),y.quaternion.copy((0,nT.b5)(i.rotation))}x.attach(y),M()},N=()=>{let{selection:e}=a.current,t=I??a.current.draft;if(!e||"cameraId"in e)return null;let i=y.position.toArray(),n=(0,nT.bl)(y.quaternion);if("characterId"in e){if(e.jointId)return{type:"move-joint",characterId:e.characterId,jointId:e.jointId,position:i};let a=t.characters.find(t=>t.id===e.characterId),r=a?.bones.find(t=>t.id===(e.boneId??e.handBoneId));if(a&&r){let e=(0,nT.ms)(a)[r.startJointId].rotation,t=y.quaternion.clone().multiply((0,nT.IA)(a,r).invert());return{type:"rotate-bone",characterId:a.id,boneId:r.id,rotation:(0,nT.Pw)(a,r,e.clone().invert().multiply(t))}}return a?{type:"put-character",character:{...a,position:i,rotation:n}}:null}if("cameraBoxId"in e){let a=t.cameraBoxes?.find(t=>t.id===e.cameraBoxId);return a?{type:"put-camera-box",box:{...a,position:i,rotation:n}}:null}let r=t.objects.find(t=>t.id===e.objectId);return r?{type:"put-object",object:{...r,position:i,rotation:n}}:null};x.addEventListener("mouseDown",()=>{k=!0,S=nz(I=a.current.draft),h.enabled=!1}),x.addEventListener("objectChange",()=>{k&&!P&&(P=requestAnimationFrame(()=>{P=0;let e=N();if(e&&I&&S)try{A(S(e).draft)}catch{A(I)}}))}),x.addEventListener("mouseUp",()=>{if(!k)return;let e=N();k=!1,h.enabled=!0,P&&(cancelAnimationFrame(P),P=0),e&&a.current.onOperation(e),I=null,S=null,A(a.current.draft),L()}),x.addEventListener("change",M);let $=()=>{k&&x.reset(),k=!1,I=null,S=null,h.enabled=!0,P&&(cancelAnimationFrame(P),P=0),A(a.current.draft),L()};e.domElement.addEventListener("pointercancel",$);let F=()=>{M(),a.current.onViewChange?.({position:m.position.toArray(),target:h.target.toArray()})};h.addEventListener("change",F);let _=null,T=!1,R=-1/0,E=null,q=(t,i=!1)=>{let n=e.domElement.getBoundingClientRect(),a=new nE.tBo;a.setFromCamera(new nE.I9Y((t.clientX-n.left)/n.width*2-1,-(t.clientY-n.top)/n.height*2+1),m),a.near=m.near,a.params.Line.threshold=.015;let r=v?a.intersectObjects(v.children,!0):[],o=i?r[0]:r.find(e=>"joint"===e.object.userData.rig)??r.find(e=>e.object.userData.rig)??r[0],s=a.intersectObjects([...w.children,...i?j.children:[]]).find(e=>{if(e.object.userData.cameraBoxId)return!0;if(!e.object.userData.cameraId||o)return!1;let i=e.point.clone().project(m);return i.z>=-1&&i.z<=1&&6>=Math.hypot(n.left+(i.x+1)*n.width/2-t.clientX,n.top+(1-i.y)*n.height/2-t.clientY)});if(s&&(!o||s.distance<o.distance)){let e=s.object.userData;return e.cameraId?{cameraId:e.cameraId}:{cameraBoxId:e.cameraBoxId}}if(o){let e=o.object instanceof nE.ZLX&&void 0!==o.instanceId?o.object.userData.instances[o.instanceId]:o.object.userData;return e.characterId?i?{characterId:e.characterId}:{characterId:e.characterId,jointId:e.jointId,boneId:e.boneId}:e.objectId?{objectId:e.objectId}:null}return null};e.domElement.addEventListener("pointerdown",e=>{c.focus(),_=[e.clientX,e.clientY],T=!1,0===e.button&&(!E||e.timeStamp-E.time>500||Math.hypot(e.clientX-E.x,e.clientY-E.y)>4)&&(E={selection:q(e,!0),x:e.clientX,y:e.clientY,time:e.timeStamp})}),e.domElement.addEventListener("pointermove",e=>{e.buttons&&_&&Math.hypot(e.clientX-_[0],e.clientY-_[1])>4&&(T=!0,R=performance.now(),E=null)}),e.domElement.addEventListener("pointerup",e=>{if(!_||T||0!==e.button||k||x.axis||a.current.disabled||Math.hypot(e.clientX-_[0],e.clientY-_[1])>4)return;let t=q(e);t&&a.current.onSelect(t)}),e.domElement.addEventListener("dblclick",e=>{if(0!==e.button||k||T||performance.now()-R<500||a.current.disabled)return;let t=E&&e.timeStamp-E.time<=500?E.selection:q(e,!0);E=null,t&&(e.preventDefault(),a.current.onEdit?.(t,{x:e.clientX,y:e.clientY}))});let D=new ResizeObserver(()=>{let{width:t,height:i}=c.getBoundingClientRect();t&&i&&(e.setSize(t,i),m.aspect=t/i,m.updateProjectionMatrix(),M())});return D.observe(c),r.current={rebuild:A,select:L,cancel:$},A(a.current.draft),L(),F(),()=>{for(let e of(r.current=null,P&&cancelAnimationFrame(P),C&&cancelAnimationFrame(C),D.disconnect(),h.dispose(),x.dispose(),p.geometry.dispose(),Array.isArray(p.material)?p.material:[p.material]))e.dispose();b.dispose(),n?.terminate(),o?.(new DOMException("","AbortError")),(0,nB.en)(j),(0,nB.en)(w),f.dispose(),e.dispose(),e.forceContextLoss(),e.domElement.remove()}},[]),(0,u.useEffect)(()=>{r.current?.rebuild(e.draft),r.current?.select()},[e.draft,e.selection,e.mode,e.disabled,e.showRig,e.showCameras,e.interacting]),(0,u.useEffect)(()=>{void 0!==e.interactionResetKey&&r.current?.cancel()},[e.interactionResetKey]),(0,n.jsx)("div",{...(0,k.Se)({namespace:"human2ai",id:"spatial-viewport",name:"SpatialViewport",category:"canvas",origin:"project",status:"candidate"}),ref:t,className:"spatial-viewport",tabIndex:0,role:"region","aria-label":e.label,onKeyDown:t=>{if("Enter"===t.key&&e.selection&&!e.disabled){t.preventDefault();let i=t.currentTarget.getBoundingClientRect();e.onEdit?.(e.selection,{x:i.left+i.width/2,y:i.top+i.height/2});return}if("Escape"===t.key){r.current?.cancel(),e.onSelect(null);return}let i={ArrowLeft:[0,-1],ArrowRight:[0,1],ArrowDown:[1,-1],ArrowUp:[1,1],PageDown:[2,-1],PageUp:[2,1]}[t.key],n=e.selection;if(!i||e.disabled||!n||!("characterId"in n))return;let a=e.draft.characters.find(e=>e.id===n.characterId);if(a){if(n.jointId){t.preventDefault();let r=(0,nT.ms)(a)[n.jointId].position.toArray(),o=(0,nT.dS)(a.bones.find(e=>e.endJointId===n.jointId)?.modelPart??"");r[i[0]]+=i[1]*(t.shiftKey?5:1)*(o?.002*a.height:.02),e.onOperation({type:"move-joint",characterId:a.id,jointId:n.jointId,position:r})}else if(n.boneId||n.handBoneId){t.preventDefault();let r=a.bones.find(e=>e.id===(n.boneId??n.handBoneId));if(r.lockRotation||(0,nT.j4)(r))return;let o=[...r.rotation];o[i[0]]+=i[1]*(t.shiftKey?10:2),e.onOperation({type:"rotate-bone",characterId:a.id,boneId:r.id,rotation:o})}}},children:o&&(0,n.jsx)("div",{className:"spatial-viewport__error",role:"alert",children:e.errorLabel})})}var nG=i(22146),nK=i(14956);async function nZ(e,t){let i=await Promise.all(e.map(e=>new Promise((t,i)=>{let n=new Image;n.crossOrigin="anonymous",n.onload=()=>t(n),n.onerror=()=>i(Error("observation-image-load-failed")),n.src=e.source}))),{width:n,height:a,tiles:r}=(0,nK.u)(t,e.map(e=>e.face)),o=document.createElement("canvas");o.width=n,o.height=a;let s=o.getContext("2d");if(!s)throw Error("observation-image-canvas-unavailable");return s.font="14px sans-serif",s.textAlign="center",s.textBaseline="middle",i.forEach((i,n)=>{let{left:a,top:o}=r[n];s.fillStyle="#f1f3f5",s.fillRect(a,o,t,nG.Sn),s.fillStyle="#374151",s.fillText(e[n].label,a+t/2,o+nG.Sn/2,t-8),s.drawImage(i,a,o+nG.Sn,t,t)}),new Promise((e,t)=>{o.toBlob(i=>i?e(i):t(Error("observation-image-export-failed")),"image/png")})}let nQ=[{face:"back",points:"42,8 73,24 73,60 42,44",rear:!0},{face:"left",points:"11,26 42,8 42,44 11,62",rear:!0},{face:"bottom",points:"11,62 42,44 73,60 42,78",rear:!0},{face:"top",points:"42,8 73,24 42,42 11,26"},{face:"front",points:"11,26 42,42 42,78 11,62"},{face:"right",points:"42,42 73,24 73,60 42,78"}],n0=[["front","back"],["left","right"],["top","bottom"]];function n1({active:e,boxes:t,selectedBoxId:i,onSelectBox:a,pass:r,onPassChange:s,source:l,labels:d,copiedLabel:c,retryLabel:m,disabled:h}){let[p,g]=(0,u.useState)(nG.em),[f,y]=(0,u.useState)(0),[x,b]=(0,u.useState)(null),[v,w]=(0,u.useState)(null),[j,k]=(0,u.useState)(null),I=t.find(e=>e.id===i)??t[0],S=(e,t=!1)=>d[`cameraBox${e[0].toUpperCase()}${e.slice(1)}${t?"Toggle":""}`],P="color"===r?d.referenceColor:"structure"===r?d.referenceStructure:"depth"===r?d.referenceDepth:d.referenceSkeleton,C=e&&I?p.map(e=>({face:e,source:l?.(I.id,e,r),label:S(e)})):[],M=C.length&&C.every(e=>e.source)?JSON.stringify({boxId:I.id,pass:r,resolution:I.resolution,views:C,attempt:f}):null,A=x?.key===M&&"blob"in x?x:null,L=x?.key===M&&"error"in x,N=j?.key===M?j:null;(0,u.useEffect)(()=>{let e;if(b(null),!M)return;let t=!1,i=JSON.parse(M);return nZ(i.views,i.resolution).then(i=>{t||(e=URL.createObjectURL(i),b({key:M,blob:i,url:e}))}).catch(()=>{t||b({key:M,error:!0})}),()=>{t=!0,e&&URL.revokeObjectURL(e)}},[M]);let $=async e=>{if(A&&I&&!h&&!v){w(e),k(null);try{if("copy"===e){if(!navigator.clipboard?.write||"u"<typeof ClipboardItem)throw Error("image-clipboard-unavailable");await navigator.clipboard.write([new ClipboardItem({"image/png":A.blob})]),k({key:A.key,message:c,error:!1})}else await Q(new File([A.blob],`${I.id}-${r}-${p.join("-")}.png`,{type:"image/png"}))}catch{k({key:A.key,message:"copy"===e?d.observationCopyFailed:d.observationDownloadFailed,error:!0})}finally{w(null)}}};return e?(0,n.jsxs)("section",{className:"spatial-observation","aria-label":d.cameraBoxTab,children:[(0,n.jsxs)("div",{className:"spatial-observation-toolbar",children:[(0,n.jsx)(o.A,{className:"spatial-observation-select","aria-label":d.cameraBoxTab,placeholder:d.cameraBoxTab,value:I?.id,disabled:h||!I,options:t.map(e=>({value:e.id,label:e.name})),onChange:a}),(0,n.jsx)(ir,{"aria-label":d.referencePass,value:r,onChange:e=>s(e),items:[{key:"color",label:d.referenceColor,mode:"text-only",disabled:h||!I},{key:"structure",label:d.referenceStructure,mode:"text-only",disabled:h||!I},{key:"depth",label:d.referenceDepth,mode:"text-only",disabled:h||!I},{key:"skeleton",label:d.referenceSkeleton,mode:"text-only",disabled:h||!I}]}),(0,n.jsxs)("div",{className:"spatial-observation-directions",role:"group","aria-label":d.cameraBoxView,children:[(0,n.jsx)("svg",{className:"spatial-observation-cube",viewBox:"0 0 84 86","aria-hidden":"true",children:nQ.map(({face:e,points:t,rear:i})=>(0,n.jsx)("polygon",{points:t,"data-face":e,"data-enabled":!!(I&&p.includes(e)),"data-rear":i||void 0},e))}),(0,n.jsx)("div",{className:"spatial-observation-face-buttons",children:n0.flatMap((e,t)=>e.map((e,i)=>{let a=!!(I&&p.includes(e));return(0,n.jsx)(X.J,{className:"spatial-observation-face-button",size:"small",style:{gridRow:i+1,gridColumn:`${2*t+i+1} / span 2`},"aria-label":S(e),"aria-pressed":a,disabled:h||!I,backgroundColor:a?"color.action.primary":"color.surface.soft",textColor:a?"color.text.inverse":"color.text.secondary",onClick:()=>g(t=>nG.em.filter(i=>i===e?!t.includes(e):t.includes(i))),children:S(e,!0)},e)}))})]})]}),(0,n.jsx)("div",{className:"spatial-observation-preview","aria-busy":!!(M&&!A&&!L),children:I?p.length?M?L?(0,n.jsx)(n_.A,{type:"error",message:d.referenceLoadFailed,action:(0,n.jsx)(X.J,{size:"small",disabled:h,onClick:()=>y(e=>e+1),children:m})}):A?(0,n.jsx)("img",{src:A.url,alt:`${I.name} \xb7 ${P} \xb7 ${C.map(e=>e.label).join(" / ")}`}):(0,n.jsx)(ne.G,{label:P,rows:3}):(0,n.jsx)("p",{className:"spatial-camera-pending",children:d.cameraPreviewPending}):(0,n.jsx)("p",{className:"spatial-camera-pending",children:d.noObservationDirections}):(0,n.jsx)("p",{className:"spatial-camera-pending",children:d.noCameraBoxes})}),N&&(N.error?(0,n.jsx)(n_.A,{type:"error",message:N.message}):(0,n.jsx)("p",{className:"spatial-observation-status",role:"status",children:N.message})),(0,n.jsxs)("div",{className:"spatial-observation-actions",children:[(0,n.jsx)(X.J,{mode:"with-icon",icon:(0,n.jsx)(H.A,{"aria-hidden":"true"}),loading:"copy"===v,disabled:h||!A||!!v,onClick:()=>void $("copy"),children:d.copyObservationImage}),(0,n.jsx)(X.J,{mode:"with-icon",icon:(0,n.jsx)(J.A,{"aria-hidden":"true"}),loading:"download"===v,disabled:h||!A||!!v,onClick:()=>void $("download"),children:d.downloadObservationImage})]})]}):null}i(78226);let n2=[{kind:"box",Icon:nS.A},{kind:"sphere",Icon:nP.A},{kind:"plane",Icon:tn.A}];function n3({value:e,onChange:t,...i}){let n=(0,u.useRef)(e),a=(0,u.useRef)(!1),r=(0,u.useRef)(!1),o=(0,u.useRef)(!1),[s,l]=(0,u.useState)(0);return(0,u.useLayoutEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]),(0,u.useLayoutEffect)(()=>{n.current=e,a.current=!1,r.current=!1},[e,i.disabled,s]),(0,u.createElement)(e2.A,{...i,key:`${e}/${!!i.disabled}/${s}`,defaultValue:e,onChange:e=>{n.current=e,a.current=!0},onPressEnter:e=>{e.nativeEvent.isComposing||e.target.blur()},onKeyDown:e=>{"Escape"===e.key&&(e.stopPropagation(),r.current=!0,e.currentTarget.blur())},onBlur:()=>{queueMicrotask(()=>{if(!o.current)return;let s=n.current;!r.current&&!i.disabled&&a.current&&null!==s&&Number.isFinite(s)&&s!==e&&t(s),a.current=!1,l(e=>e+1)})}})}function n5({draft:e,onOperation:t,showRig:i,onShowRigChange:a,showCameras:r,onShowCamerasChange:c,labels:m=eS.spatial,noteLabel:p=eS.notes.element.label,copiedLabel:y=eS.clipboard.copied,loading:x,disabled:b,error:v,onRetry:w,historyControls:j,interactionResetKey:I,initialCameraId:S,cameraSource:P,cameraBoxSource:A,details:L,panelHost:N,toolsLabel:$=eS.canvas.tools.label,onRequestProperties:F,actions:_=eS.actions}){let T,R,E,[q,D]=(0,u.useState)(S?{cameraId:S}:null),[z,B]=(0,u.useState)(S?"parameters":"info"),[O,U]=(0,u.useState)("space"),[J,W]=(0,u.useState)([]),[Y,V]=(0,u.useState)(!0),[G,K]=(0,u.useState)(!0),Z=i??Y,Q=r??G,[ee,et]=(0,u.useState)(null),[ei,en]=(0,u.useState)(null),[ea,er]=(0,u.useState)(null),[eo,es]=(0,u.useState)(null),[el,ed]=(0,u.useState)(null),ec=(0,u.useRef)(0),eu=()=>{cancelAnimationFrame(ec.current),ec.current=0,ed(null)},em=(0,u.useRef)(null);(0,u.useLayoutEffect)(()=>(en(null),eu(),()=>{cancelAnimationFrame(ec.current),ec.current=0}),[e,q,z,b,x,O,I]);let eh=(t,i)=>ei?.source===e&&ei.key===t?ei.value:i,ep=(e,t,i)=>{en(null),e!==t&&i(e)},eg=t=>(em.current?.source!==e&&(em.current={source:e,apply:nz(e)}),em.current.apply(t)),[ef,ex]=(0,u.useState)("translate"),[eb,ev]=(0,u.useState)(S??e.cameras[0].id),[ew,ej]=(0,u.useState)("sheet"),[ek,eI]=(0,u.useState)(),[eP,eC]=(0,u.useState)("color"),[eM,eA]=(0,u.useState)({position:[3,2.2,5],target:[0,.9,0]}),eL=q&&"characterId"in q?e.characters.find(e=>e.id===q.characterId):void 0,eN=eL&&q&&"characterId"in q?eL.joints.find(e=>e.id===q.jointId):void 0,e$=eL&&q&&"characterId"in q?eL.bones.find(e=>e.id===q.boneId):void 0,eF=eL&&q&&"characterId"in q?eL.bones.find(e=>e.id===q.handBoneId):void 0,e_=el?.source!==e||el.characterId!==eL?.id||el.handBoneId!==eF?.id||b||x||"parameters"!==z||"space"!==O?null:el,eT=eN??e$??eF,eR=q&&"objectId"in q?e.objects.find(e=>e.id===q.objectId):void 0,eE=e.cameras.find(e=>e.id===(q&&"cameraId"in q?q.cameraId:eb))??e.cameras[0],eq=q&&"cameraId"in q?eE:void 0,eD=q&&"cameraBoxId"in q?e.cameraBoxes?.find(e=>e.id===q.cameraBoxId):void 0,ez=eD?A?.(eD.id,ew,eP):P?.(eE.id,eP),eB=e=>m[`cameraBox${e[0].toUpperCase()}${e.slice(1)}`],eO=eL??eR??eq??eD,eU=ee&&[...e.characters,...e.objects,...e.cameras,...e.cameraBoxes??[]].find(e=>e.id===ee.id),eJ=eL&&eN?(0,nT.ms)(eL)[eN.id]:void 0,eW=Number(((eL?.torsoRatio??nT.s4)*100).toFixed(1)),eH=eh("torsoRatio",eW),eY=e=>`${m.torso} ${Number(e.toFixed(1))}%, ${m.legs} ${Number((100-e).toFixed(1))}%`,eV=e=>m[`finger${e[0].toUpperCase()}${e.slice(1)}`],eX=(e,t=!1)=>{let i=(0,nT.dS)(e);if(!i)return;let n=t?["","fingerProximalBone","fingerMiddleBone","fingerDistalBone"][i.segment]:["fingerRoot","fingerMiddleJoint","fingerDistalJoint","fingerTip"][i.segment];return t&&"thumb"===i.finger&&i.segment<3?1===i.segment?m.thumbMetacarpal:m.thumbProximal:m[n]?.replace("{{finger}}",eV(i.finger))},eG=(e,t,i=e)=>eX(i)??(t===e?m["joint"+e.split("-").map(e=>e[0].toUpperCase()+e.slice(1)).join("")]??t:t),eK=(e,t,i)=>eX(i,!0)??(t===e?m["bone"+i.split("-").map(e=>e[0].toUpperCase()+e.slice(1)).join("")]??t:t),eZ=e=>`${e.id===e.modelPart?"":e.id.slice(0,-e.modelPart.length).replace(/-$/,"")+" "}${e.modelPart.startsWith("left")?m.handLeft:m.handRight}`,eQ=e=>`${e}-${globalThis.crypto.randomUUID()}`;(0,u.useLayoutEffect)(()=>{void 0!==I&&(q&&(!eO||"cameraId"in q&&!e.cameras.some(e=>e.id===q.cameraId)||"characterId"in q&&(q.jointId&&!eN||q.boneId&&!e$||q.handBoneId&&!eF))&&D(null),en(null),er(null),es(null),et(null))},[I]);let e1=e=>{b||t(e)},e2=(t,i=!1)=>{if(!eL||!eF||b||x)return;let n={...t,type:"pose-hand",characterId:eL.id,handBoneId:eF.id};cancelAnimationFrame(ec.current),ec.current=0;let a=()=>{ec.current=0;try{let t=eg(n);es(t.constrained?m.constrained:null),ed(i?{source:e,draft:t.draft,characterId:eL.id,handBoneId:eF.id}:null),i||e1(n)}catch{ed(null),es(m.constrained)}};i?ec.current=requestAnimationFrame(a):a()},e3=e=>{if(!eL||b||x)return;let t={type:"set-proportions",characterId:eL.id,height:eL.height,headRatio:eL.headRatio,torsoRatio:eL.torsoRatio??nT.s4,...e};try{eg(t),er(null),e1(t)}catch(e){er(e instanceof nT._1?m.proportionsLocked:m.constrained)}},e8=e=>{eL?e1({type:"put-character",character:{...eL,...e}}):eR?e1({type:"put-object",object:{...eR,...e}}):eq?e1({type:"put-camera",camera:{...eq,...e}}):eD&&e1({type:"put-camera-box",box:{...eD,...e}})},e6=(e,t,i,a=!1,r=.05)=>(0,n.jsxs)("div",{className:"spatial-field",children:[(0,n.jsx)("span",{children:e}),(0,n.jsx)("div",{className:"spatial-vector",children:t.map((o,s)=>(0,n.jsx)(n3,{"aria-label":`${e} ${[m.x,m.y,m.z][s]}`,value:Number(o.toFixed(3)),step:r,controls:!1,disabled:b||a,onChange:e=>{if(null!==e){let n=[...t];n[s]=e,i(n)}}},s))})]}),e9=e=>e?"characterId"in e?JSON.stringify(["character",e.characterId,e.jointId??null,e.boneId??null,e.handBoneId??null]):"objectId"in e?JSON.stringify(["object",e.objectId]):"cameraBoxId"in e?JSON.stringify(["camera-box",e.cameraBoxId]):JSON.stringify(["camera",e.cameraId]):void 0,{nodes:e7,selections:te}=(0,u.useMemo)(()=>{let t=[],i=new Map,a=e=>e?.trim()?(0,n.jsx)(C.A,{title:(0,n.jsx)("span",{className:"spatial-note-tooltip",children:e}),children:(0,n.jsx)(iG.A,{tabIndex:0,"aria-label":p})}):void 0,r=(e,n,a,r,o)=>{let s=e9(e);i.set(s,e),t.push({key:s,title:n,parentKey:a,order:r,nodeKind:e&&"characterId"in e&&!e.jointId&&!e.boneId?"container":"content",trailing:o})};return e.characters.forEach((e,t)=>{let i=e9({characterId:e.id});r({characterId:e.id},e.name,null,t,a(e.note));let o=e.bones.filter(e=>e.modelPart.endsWith("-hand")),s=new Map;o.forEach(t=>{let n={characterId:e.id,handBoneId:t.id},a=e9(n);for(let o of(r(n,eZ(t),i,3*e.joints.findIndex(e=>e.id===t.endJointId)),(0,nT.Au)(e,t)))s.set(o,a);s.set(t.startJointId,a)}),e.joints.forEach((t,a)=>{let o=e.bones.find(e=>e.endJointId===t.id),l=o&&(0,nT.dS)(o.modelPart);(!t.terminal||l)&&r({characterId:e.id,jointId:t.id},eG(t.id,t.name,o?.modelPart),s.get(t.id)??i,3*a+1,t.lockPosition&&(0,n.jsx)(C.A,{title:m.lockPosition,children:(0,n.jsx)(e0.A,{"aria-label":m.lockPosition})})),o&&l?.segment!==0&&r({characterId:e.id,boneId:o.id},eK(o.id,o.name,o.modelPart),o.modelPart.endsWith("-wrist")?i:s.get(t.id)??i,3*a+2*!l,o.lockRotation&&(0,n.jsx)(C.A,{title:m.lockRotation,children:(0,n.jsx)(e4.A,{"aria-label":m.lockRotation})}))})}),e.objects.forEach((t,i)=>r({objectId:t.id},t.name,null,e.characters.length+i,a(t.note))),e.cameras.forEach((t,i)=>r({cameraId:t.id},t.name,null,e.characters.length+e.objects.length+i,a(t.note))),e.cameraBoxes?.forEach((t,i)=>r({cameraBoxId:t.id},t.name,null,e.characters.length+e.objects.length+e.cameras.length+i,a(t.note))),{nodes:t,selections:i}},[e,m,p]),tt=(t,i=!0)=>{if(et(null),en(null),er(null),es(null),D(t),t&&(i&&B("parameters"),F?.(),"cameraId"in t&&ev(t.cameraId),"cameraBoxId"in t&&eI(t.cameraBoxId),"characterId"in t)){t.jointId&&ex("translate"),(t.boneId||t.handBoneId)&&ex("rotate");let i=e9({characterId:t.characterId}),n=e.characters.find(e=>e.id===t.characterId),a=n?.bones.find(e=>e.id===t.boneId||e.endJointId===t.jointId),r=n&&a?(0,nT.oT)(n,a)??n.bones.find(e=>e.modelPart.endsWith("-hand")&&e.startJointId===t.jointId):void 0,o=r?e9({characterId:t.characterId,handBoneId:r.id}):void 0;W(e=>[...new Set([...e,i,...o?[o]:[]])])}},ti=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(C.A,{title:m.translate,children:(0,n.jsx)(X.J,{mode:"with-icon","aria-label":m.translate,"aria-pressed":"translate"===ef,icon:(0,n.jsx)(nC.A,{"aria-hidden":"true"}),disabled:b||x||!!(e$||eF),onClick:()=>ex("translate"),children:m.translateMode})}),(0,n.jsx)(C.A,{title:m.rotate,children:(0,n.jsx)(X.J,{mode:"with-icon","aria-label":m.rotate,"aria-pressed":"rotate"===ef,icon:(0,n.jsx)(e4.A,{"aria-hidden":"true"}),disabled:b||x||!!eN,onClick:()=>ex("rotate"),children:m.rotateMode})})]}),ta=(0,n.jsxs)("div",{className:"spatial-panel","data-canvas-editor":!0,children:[(0,n.jsx)(ir,{className:"spatial-panel-tabs","aria-label":m.panelViews,value:z,onChange:e=>{B(e),en(null)},items:[{key:"info",label:m.infoToolsTab,mode:"text-only"},{key:"objects",label:m.objects,mode:"text-only"},{key:"parameters",label:m.parameters,mode:"text-only"}]}),(0,n.jsx)("div",{className:"spatial-panel-body",children:"info"===z?(0,n.jsxs)(n.Fragment,{children:[L,(0,n.jsxs)("section",{className:"spatial-tools","aria-label":$,children:[(0,n.jsx)("h2",{children:$}),(0,n.jsxs)("div",{className:"spatial-add-actions",children:[(0,n.jsx)(ey.u,{icon:(0,n.jsx)(nM.A,{"aria-hidden":"true"}),label:m.addCharacter,disabled:b||x,onClick:()=>{let e=eQ("character");e1({type:"add-character",id:e,name:m.character}),tt({characterId:e})}}),(0,n.jsx)(ey.u,{icon:(0,n.jsx)(nA.A,{"aria-hidden":"true"}),label:m.addCamera,disabled:b||x,onClick:()=>{let t=eQ("camera");e1({type:"put-camera",camera:(0,nT.oH)(t,m.camera.replace("{{number}}",String(e.cameras.length+1)))}),tt({cameraId:t})}})]}),(0,n.jsx)(ey.u,{icon:(0,n.jsx)(np.A,{"aria-hidden":"true"}),label:m.addCameraBox,disabled:b||x,onClick:()=>{let t=eQ("camera-box");e1({type:"put-camera-box",box:(0,nT.ov)((0,nT.zP)(t,m.cameraBox),e,"scene")}),tt({cameraBoxId:t}),ej("sheet")}}),(0,n.jsx)("div",{className:"spatial-add-actions",children:n2.map(({kind:e,Icon:t})=>(0,n.jsx)(ey.u,{icon:(0,n.jsx)(t,{"aria-hidden":"true"}),label:m[e],disabled:b||x,onClick:()=>{let t=eQ(e);e1({type:"put-object",object:{id:t,name:m[e],kind:e,position:[0,.3,0],rotation:[0,0,0],size:"plane"===e?[2,1,2]:[.6,.6,.6],color:"#b6a58c"}}),tt({objectId:t})}},e))}),(0,n.jsx)(n$.A,{checked:e.lightingEnabled??!1,disabled:b||x,onChange:e=>e1({type:"set-lighting",enabled:e.target.checked}),children:m.lightingEffects}),(0,n.jsx)(n$.A,{checked:Q,onChange:e=>(c??K)(e.target.checked),children:m.showCameras}),(0,n.jsx)(n$.A,{checked:Z,onChange:e=>(a??V)(e.target.checked),children:m.showRig}),Z&&(0,n.jsxs)("div",{className:"spatial-rig-legend",children:[(0,n.jsxs)("span",{children:[(0,n.jsx)("i",{className:"spatial-joint-dot"}),m.joints]}),(0,n.jsxs)("span",{children:[(0,n.jsx)("i",{className:"spatial-bone-dot"}),m.bones]})]})]})]}):"objects"===z?(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("section",{className:"spatial-objects","aria-label":m.objects,children:[(0,n.jsx)("h2",{children:m.objects}),x?(0,n.jsx)(ne.G,{label:m.title,rows:4}):(0,n.jsx)(i7,{className:"spatial-object-tree","aria-label":m.objects,nodes:e7,mode:"view",showCurrent:!1,showContentOrder:!1,showStatus:!1,showDraft:!1,showLock:!1,showIcon:!0,expandAction:!1,expandedKeys:J,onExpand:e=>W(e),selectedKeys:q?[e9(q)]:[],onSelect:e=>tt(te.get(String(e[0]))??null,!1),icon:({eventKey:e})=>{let t=te.get(String(e));return t&&"cameraId"in t?(0,n.jsx)(nA.A,{"aria-hidden":"true"}):t&&"cameraBoxId"in t?(0,n.jsx)(np.A,{"aria-hidden":"true"}):t&&"objectId"in t?(0,n.jsx)(tn.A,{"aria-hidden":"true"}):t&&"characterId"in t&&t.jointId?(0,n.jsx)(nL.A,{className:"spatial-joint-icon","aria-hidden":"true"}):t&&"characterId"in t&&t.boneId?(0,n.jsx)(nN.A,{className:"spatial-bone-icon","aria-hidden":"true"}):(0,n.jsx)(nM.A,{"aria-hidden":"true"})}})]})}):(0,n.jsxs)(n.Fragment,{children:[!eO&&(0,n.jsx)("p",{className:"spatial-parameters-empty",children:m.selectObjectForParameters}),eO&&(0,n.jsxs)("section",{className:"spatial-parameters","aria-label":m.parameters,children:[(0,n.jsx)("h2",{children:m.parameters}),!eq&&!eT&&(0,n.jsx)("div",{className:"spatial-tool-modes",children:ti}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:eN?m.joints:e$?m.bones:m.name}),(0,n.jsx)(l.A,{"aria-label":m.name,defaultValue:eN?eG(eN.id,eN.name,eL?.bones.find(e=>e.endJointId===eN.id)?.modelPart):e$?eK(e$.id,e$.name,e$.modelPart):eF?eZ(eF):eO.name,disabled:b||!!eT,onBlur:e=>{e.target.value.trim()&&e.target.value!==eO.name&&e8({name:e.target.value.trim()})}},`${eO.id}/${eT?.id??""}/${eO.name}`)]}),!eT&&(0,n.jsx)(f,{label:p,children:(0,n.jsx)(g,{"aria-label":p,value:eO.note??"",disabled:b,onChange:e=>e8({note:e.target.value})})}),eJ&&eN&&eL?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"spatial-locks",children:(0,n.jsx)(n$.A,{checked:eN.lockPosition,disabled:b,onChange:e=>e1({type:"lock-joint",characterId:eL.id,jointId:eN.id,position:e.target.checked}),children:m.lockPosition})}),e6(m.position,eJ.position.toArray(),e=>e1({type:"move-joint",characterId:eL.id,jointId:eN.id,position:e}),eN.lockPosition,(0,nT.dS)(eL.bones.find(e=>e.endJointId===eN.id)?.modelPart??"")?.005:.05)]}):(e$||eF)&&eL?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"spatial-locks",children:(0,n.jsx)(n$.A,{checked:(e$??eF).lockRotation,disabled:b,onChange:e=>e1({type:"lock-bone",characterId:eL.id,boneId:(e$??eF).id,rotation:e.target.checked}),children:m.lockRotation})}),e6(m.localRotation,(e$??eF).rotation,e=>e1({type:"rotate-bone",characterId:eL.id,boneId:(e$??eF).id,rotation:e}),(e$??eF).lockRotation||(0,nT.j4)(e$??eF),5),e$&&e6(m.angleMinimum,e$.limits.min,e=>e1({type:"set-bone-limits",characterId:eL.id,boneId:e$.id,limits:{...e$.limits,min:e}}),(0,nT.j4)(e$),5),e$&&e6(m.angleMaximum,e$.limits.max,e=>e1({type:"set-bone-limits",characterId:eL.id,boneId:e$.id,limits:{...e$.limits,max:e}}),(0,nT.j4)(e$),5)]}):(0,n.jsxs)(n.Fragment,{children:[e6(m.position,eO.position,e=>e8({position:e})),eq?e6(m.target,eq.target,e=>e8({target:e})):e6(m.rotation,(eL??eR??eD).rotation,e=>e8({rotation:e}),!1,5)]}),eL&&eF&&(T=(0,nT.Au)(eL,eF),R=e=>eL.bones.find(t=>T.has(t.endJointId)&&(0,nT.dS)(t.modelPart)?.finger===e&&(0,nT.dS)(t.modelPart)?.segment===1),E=(t,i,a)=>(0,n.jsxs)("div",{className:"spatial-hand-control",children:[(0,n.jsx)("span",{children:t}),(0,n.jsx)(nF.A,{min:0,max:100,step:2,value:eh(t,Math.round(Math.max(0,Math.min(100,i)))),disabled:b||x,ariaLabelForHandle:t,tooltip:{formatter:e=>`${e}%`},onChange:i=>{en({source:e,key:t,value:i}),e2(a(i/100),!0)},onChangeComplete:e=>{eu(),ep(e,Math.round(Math.max(0,Math.min(100,i))),e=>e2(a(e/100)))},onBlur:()=>{en(null),eu()}})]},t),(0,n.jsxs)("div",{className:"spatial-hand-controls",children:[(0,n.jsx)(C.A,{title:m.resetHandHint,children:(0,n.jsx)(X.J,{mode:"with-icon",icon:(0,n.jsx)(e5.A,{"aria-hidden":"true"}),disabled:b||x,onClick:()=>{en(null),eu(),es(null),e1({type:"reset-hand",characterId:eL.id,handBoneId:eF.id})},children:m.resetHand})}),nT.EG.filter(e=>R(e)).map(e=>E(m.fingerCurl.replace("{{finger}}",eV(e)),R(e).rotation[0]/(0,nT.oq)(e)[0]*100,t=>({curl:{[e]:t}}))),R("little")&&E(m.fingerSpread,R("little").rotation[2]/(eF.modelPart.startsWith("left")?-18:18)*100,e=>({spread:e})),R("thumb")&&E(m.thumbOpposition,R("thumb").rotation[1]/(eF.modelPart.startsWith("left")?60:-60)*100,e=>({thumbOpposition:e})),eo&&(0,n.jsx)("span",{className:"spatial-proportion-error",role:"alert",children:eo})]})),eL&&!eT&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(C.A,{title:m.resetPoseHint,children:(0,n.jsx)(X.J,{mode:"with-icon",icon:(0,n.jsx)(e5.A,{"aria-hidden":"true"}),disabled:b,onClick:()=>{er(null),en(null),e1({type:"reset-pose",characterId:eL.id})},children:m.resetPose})}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:m.appearance}),(0,n.jsx)(o.A,{"aria-label":m.appearance,value:eL.appearance,disabled:b||x,options:[{value:"quaternius",label:m.appearanceQuaternius},{value:"geometric",label:m.appearanceGeometric}],onChange:e=>e8({appearance:e})})]}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:m.bodyType}),(0,n.jsx)(o.A,{"aria-label":m.bodyType,value:eL.bodyType??"male",disabled:b||x,options:[{value:"male",label:m.bodyMale},{value:"female",label:m.bodyFemale}],onChange:e=>e3({bodyType:e})})]}),(0,n.jsxs)("div",{className:"spatial-dimensions",children:[(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:m.proportions}),(0,n.jsx)(n3,{controls:!1,"aria-label":m.proportions,min:2,max:12,step:.5,precision:1,value:eL.headRatio,disabled:b,onChange:e=>null!==e&&e3({headRatio:e})})]}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:m.height}),(0,n.jsx)(n3,{controls:!1,"aria-label":m.height,min:.2,max:20,step:.1,value:eL.height,disabled:b,onChange:e=>null!==e&&e3({height:e})})]})]}),(0,n.jsxs)("div",{className:"spatial-body-ratio",children:[(0,n.jsxs)("div",{className:"spatial-ratio-heading",children:[(0,n.jsxs)("span",{children:[m.bodyLegRatio," ",(0,n.jsx)(C.A,{title:m.bodyLegRatioHint,children:(0,n.jsx)(iG.A,{tabIndex:0,"aria-label":m.bodyLegRatioHint})})]}),(0,n.jsx)(C.A,{title:m.resetBodyLegRatio,children:(0,n.jsx)(X.J,{size:"small",mode:"icon-only",icon:(0,n.jsx)(e5.A,{"aria-hidden":"true"}),"aria-label":m.resetBodyLegRatio,disabled:b||x,onClick:()=>e3({torsoRatio:nT.s4})})})]}),(0,n.jsxs)("div",{className:"spatial-ratio-values",children:[(0,n.jsxs)("span",{children:[m.torso," ",eH,"%"]}),(0,n.jsxs)("span",{children:[m.legs," ",Number((100-eH).toFixed(1)),"%"]})]}),(0,n.jsx)("div",{className:"spatial-ratio-track",style:{background:`linear-gradient(to right, var(--yisiui-color-action-primary) ${eH}%, var(--yisiui-color-border-default) ${eH}%)`},children:(0,n.jsx)(nF.A,{className:"spatial-ratio-slider",min:100*nT.VO.min,max:100*nT.VO.max,step:2,value:eH,disabled:b||x,marks:eH%2?{[eH]:eH}:void 0,styles:{root:{left:`${100*nT.VO.min}%`,right:`${(1-nT.VO.max)*100}%`},rail:{background:"transparent"},track:{background:"transparent"}},ariaLabelForHandle:m.bodyLegRatio,ariaValueTextFormatterForHandle:eY,tooltip:{formatter:e=>eY(e??eH)},onChange:t=>en({source:e,key:"torsoRatio",value:t}),onChangeComplete:e=>ep(e,eW,e=>e3({torsoRatio:e/100})),onBlur:()=>en(null)})})]}),Object.keys(nT.aY).map(t=>{let i=nT.aY[t],a=Number(((eL[t]??1)*100).toFixed(1)),r=eh(t,a);return(0,n.jsxs)("div",{className:"spatial-shape-control",children:[(0,n.jsxs)("span",{children:[m[t],"neckLength"===t&&(0,n.jsxs)(n.Fragment,{children:[" ",(0,n.jsx)(C.A,{title:m.bodyShapeHint,children:(0,n.jsx)(iG.A,{tabIndex:0,"aria-label":m.bodyShapeHint})})]})]}),(0,n.jsx)(nF.A,{min:100*i.min,max:100*i.max,step:2,value:r,disabled:b||x,marks:r%2?{[r]:""}:void 0,ariaLabelForHandle:m[t],ariaValueTextFormatterForHandle:e=>`${e}%`,tooltip:{formatter:e=>`${e}%`},onChange:i=>en({source:e,key:t,value:i}),onChangeComplete:e=>ep(e,a,e=>e3({[t]:e/100})),onBlur:()=>en(null)}),(0,n.jsx)(n3,{"aria-label":m[t],controls:!1,min:100*i.min,max:100*i.max,step:2,value:r,disabled:b||x,formatter:e=>`${e}%`,parser:e=>Number(e?.replace("%","")),onChange:e=>null!==e&&e3({[t]:e/100})})]},t)}),ea&&(0,n.jsx)("span",{className:"spatial-proportion-error",role:"alert",children:ea})]}),eR&&e6(m.size,eR.size,e=>e8({size:e})),(eL||eR)&&!eT&&(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:m.color}),(0,n.jsx)("input",{type:"color","aria-label":m.color,disabled:b,value:(eL??eR).color,onChange:e=>e8({color:e.target.value})})]}),eD&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"spatial-tool-modes",children:[(0,n.jsx)(C.A,{title:m.cameraBoxHint,children:(0,n.jsx)(iG.A,{tabIndex:0,"aria-label":m.cameraBoxHint})}),(0,n.jsx)(X.J,{size:"small",disabled:b||x||!e.characters.length&&!e.objects.length,onClick:()=>e1({type:"fit-camera-box",id:eD.id,region:"scene"}),children:m.fitCameraBoxScene}),(0,n.jsx)(X.J,{size:"small",disabled:b||x||!e.characters.length,onClick:()=>e1({type:"fit-camera-box",id:eD.id,region:"hands"}),children:m.fitCameraBoxHands})]}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:m.cameraBoxSize}),(0,n.jsx)(n3,{controls:!1,"aria-label":m.cameraBoxSize,value:Number(eD.size.toFixed(3)),min:.05,max:1e3,step:.05,disabled:b,onChange:e=>null!==e&&e8({size:e})})]}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:m.cameraBoxResolution}),(0,n.jsx)(o.A,{"aria-label":m.cameraBoxResolution,value:eD.resolution,disabled:b,options:[...new Set([128,256,512,1024,eD.resolution])].sort((e,t)=>e-t).map(e=>({value:e,label:`${e} \xd7 ${e}`})),onChange:e=>e8({resolution:e})})]})]}),eq&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(X.J,{size:"small",disabled:b,onClick:()=>e8(eM),children:m.useView}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:m.projection}),(0,n.jsx)(o.A,{"aria-label":m.projection,value:eq.projection,disabled:b,options:[{value:"perspective",label:m.perspective},{value:"orthographic",label:m.orthographic}],onChange:e=>e8({projection:e})})]}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:"perspective"===eq.projection?m.fov:m.span}),(0,n.jsx)(n3,{controls:!1,"aria-label":"perspective"===eq.projection?m.fov:m.span,value:"perspective"===eq.projection?eq.fov:eq.span,min:"perspective"===eq.projection?10:.1,max:"perspective"===eq.projection?120:1e3,disabled:b,onChange:e=>null!==e&&e8("perspective"===eq.projection?{fov:e}:{span:e})})]}),(0,n.jsx)("div",{className:"spatial-output-size",children:["width","height"].map(e=>(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:"width"===e?m.outputWidth:m.outputHeight}),(0,n.jsx)(n3,{controls:!1,"aria-label":"width"===e?m.outputWidth:m.outputHeight,min:128,max:2048,step:16,precision:0,disabled:b,value:eq[e],onChange:t=>null!==t&&e8({[e]:t})})]},e))}),(0,n.jsx)(n$.A,{checked:null===eq.background,disabled:b,onChange:e=>e8({background:e.target.checked?null:"#ffffff"}),children:m.transparent})]}),!eT&&(0,n.jsxs)("div",{className:"spatial-object-actions",children:[(0,n.jsx)(X.J,{mode:"with-icon",size:"small",icon:(0,n.jsx)(H.A,{"aria-hidden":"true"}),disabled:b,onClick:()=>{let e=eQ("copy");eL?e1({type:"put-character",character:{...structuredClone(eL),id:e,position:[eL.position[0]+.8,eL.position[1],eL.position[2]]}}):eR?e1({type:"put-object",object:{...structuredClone(eR),id:e,position:[eR.position[0]+.8,eR.position[1],eR.position[2]]}}):eq?e1({type:"put-camera",camera:{...structuredClone(eq),id:e}}):eD&&e1({type:"put-camera-box",box:{...structuredClone(eD),id:e}})},children:m.duplicate}),(0,n.jsx)(h.x,{"aria-label":_.delete,size:"small",icon:(0,n.jsx)(s.A,{}),disabled:b||!!(eq&&1===e.cameras.length),confirmLabel:_.delete,cancelLabel:_.cancel,title:m.deleteConfirm,onConfirm:()=>{e1({type:"remove",id:eO.id}),D(null)},children:null})]})]},`${e9(q)}/${I??0}/${!!x}`),(0,n.jsxs)("section",{className:"spatial-preview","aria-label":m.cameraView,children:[(0,n.jsx)("h2",{children:eD?m.cameraBoxSheet:m.cameraView}),eD?(0,n.jsx)(o.A,{"aria-label":m.cameraBoxView,value:ew,options:["sheet",...nT.em].map(e=>({value:e,label:eB(e)})),onChange:ej}):(0,n.jsx)(o.A,{"aria-label":m.selectCamera,value:eE.id,options:e.cameras.map(e=>({value:e.id,label:e.name})),onChange:e=>{ev(e),eq&&tt({cameraId:e})}}),(0,n.jsx)(ir,{className:"spatial-reference-tabs","aria-label":m.referencePass,value:eP,onChange:e=>eC(e),items:[{key:"color",label:m.referenceColor,mode:"text-only",disabled:b||x},{key:"structure",label:m.referenceStructure,mode:"text-only",disabled:b||x},{key:"depth",label:m.referenceDepth,mode:"text-only",disabled:b||x},{key:"skeleton",label:m.referenceSkeleton,mode:"text-only",disabled:b||x}]}),ez&&(0,n.jsx)(n4,{source:ez,camera:eD?{id:`${eD.id}-${ew}`,name:`${eD.name} \xb7 ${eB(ew)}`,...(0,nT.D5)(eD,ew)}:eE,pass:eP,labels:m,retryLabel:_.retry,disabled:b},ez)]})]})})]});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("section",{...(0,k.Se)({namespace:"human2ai",id:"spatial-workspace-view",name:"SpatialWorkspaceView",category:"composition",origin:"project",status:"candidate"}),className:"spatial-workspace","data-canvas-editor":!0,"aria-label":m.title,children:(0,n.jsx)(is,{className:"spatial-workflow","data-active-stage":O,stateControls:(0,n.jsxs)("div",{className:"spatial-workspace-controls",children:[v&&(0,n.jsx)("span",{className:"spatial-workspace-error",role:"alert","aria-label":v,children:(0,n.jsx)(C.A,{title:w?`${v} \xb7 ${_.retry}`:v,trigger:["hover","focus"],children:(0,n.jsx)(X.J,{mode:"icon-only",size:"small",textColor:"color.status.danger",backgroundColor:"none","aria-label":w?`${v} \xb7 ${_.retry}`:v,icon:(0,n.jsx)(iJ.A,{"aria-hidden":"true"}),onClick:w})})}),(0,n.jsx)(ir,{className:"spatial-workspace-tabs","aria-label":m.workspaceViews,value:O,onChange:U,items:[{key:"space",label:m.spaceTab,mode:"text-only"},{key:"cameras",label:m.cameras,mode:"text-only"},{key:"cameraBoxes",label:m.cameraBoxTab,mode:"text-only"}]})]}),children:(0,n.jsx)("div",{className:"spatial-center",children:x?(0,n.jsx)(ne.G,{label:m.title,rows:6}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"spatial-space",hidden:"space"!==O,children:[j,(0,n.jsx)(nX,{interactionResetKey:I,interacting:!!e_,showRig:Z,showCameras:Q,draft:e_?.draft??e,selection:q,mode:ef,onSelect:tt,onEdit:(t,i)=>{if(b||x)return;let n="characterId"in t?{characterId:t.characterId}:t,a="characterId"in n?n.characterId:"objectId"in n?n.objectId:"cameraId"in n?n.cameraId:n.cameraBoxId,r=[...e.characters,...e.objects,...e.cameras,...e.cameraBoxes??[]].find(e=>e.id===a);r&&(tt(n),et({id:a,name:r.name,...i}))},onOperation:e1,onViewChange:eA,label:m.viewport,errorLabel:m.webglFailed,disabled:b})]}),"cameras"===O&&(0,n.jsx)("section",{className:"spatial-camera-gallery","aria-label":m.cameras,children:e.cameras.map(e=>{let t=P?.(e.id,"color");return(0,n.jsxs)("figure",{className:"spatial-camera-card","data-selected":eq?.id===e.id,children:[(0,n.jsx)(X.J,{className:"spatial-camera-select",backgroundColor:"none","aria-label":`${e.name} \xb7 ${m.parameters}`,"aria-pressed":eq?.id===e.id,onClick:()=>tt({cameraId:e.id})}),(0,n.jsx)("div",{className:"spatial-camera-image",children:t?(0,n.jsx)(n4,{source:t,camera:e,pass:"color",labels:m,retryLabel:_.retry,disabled:b,gallery:!0},t):(0,n.jsx)("p",{className:"spatial-camera-pending",children:m.cameraPreviewPending})}),(0,n.jsx)("figcaption",{children:e.name})]},e.id)})}),(0,n.jsx)(n1,{active:"cameraBoxes"===O,boxes:e.cameraBoxes??[],selectedBoxId:ek,onSelectBox:e=>tt({cameraBoxId:e}),pass:eP,onPassChange:eC,source:A,labels:m,copiedLabel:y,retryLabel:_.retry,disabled:b})]})})})}),N&&(0,M.createPortal)(ta,N),ee&&eU&&(0,n.jsx)(d.A,{open:!0,title:m.editObject,footer:null,width:360,rootClassName:"spatial-object-editor-modal",destroyOnHidden:!0,mask:{closable:!0},closable:{"aria-label":_.cancel},onCancel:()=>et(null),style:{position:"absolute",margin:0,left:`min(${Math.max(16,ee.x+12)}px, calc(100vw - 376px))`,top:`min(${Math.max(16,ee.y+12)}px, calc(100vh - 360px))`},children:(0,n.jsxs)("div",{className:"spatial-object-editor-fields","data-spatial-object-editor":eU.id,"data-human2ai-auto-save-node-editor":!0,children:[(0,n.jsx)(f,{label:m.name,children:(0,n.jsx)(l.A,{"aria-label":m.name,value:ee.name,maxLength:200,disabled:b,onChange:e=>{let t=e.target.value;et({...ee,name:t}),t.trim()&&t.trim()!==eU.name&&e8({name:t.trim()})},onBlur:()=>et(e=>e?{...e,name:eU.name}:null)})}),(0,n.jsx)(f,{label:p,children:(0,n.jsx)(g,{autoFocus:!0,"aria-label":p,value:eU.note??"",disabled:b,onChange:e=>e8({note:e.target.value})})})]})})]})}function n4({source:e,camera:t,pass:i,labels:a,retryLabel:r,disabled:o,gallery:s}){let[l,d]=(0,u.useState)("loading"),[c,m]=(0,u.useState)(0),h="color"===i?a.referenceColor:"structure"===i?a.referenceStructure:"depth"===i?a.referenceDepth:a.referenceSkeleton;return(0,n.jsxs)(n.Fragment,{children:["loading"===l&&(0,n.jsx)(ne.G,{label:h,rows:1}),"error"===l&&(0,n.jsx)(n_.A,{type:"error",message:a.referenceLoadFailed,action:(0,n.jsx)(X.J,{size:"small",disabled:o,onClick:()=>{d("loading"),m(e=>e+1)},children:r})}),(0,n.jsx)("img",{src:e,loading:s?"lazy":"eager",alt:`${t.name} \xb7 ${h}`,width:t.width,height:t.height,onLoad:()=>d("ready"),onError:()=>d("error"),style:{display:"error"===l?"none":void 0,visibility:"loading"===l?"hidden":void 0,aspectRatio:`${t.width} / ${t.height}`,maxWidth:s?void 0:230*t.width/t.height}},c),!s&&(0,n.jsx)(X.J,{mode:"with-icon",size:"small",icon:(0,n.jsx)(J.A,{"aria-hidden":"true"}),disabled:o||"ready"!==l,href:o||"ready"!==l?void 0:e,download:`${t.id}-${i}.png`,children:a.downloadReference})]})}},1713:()=>{},1820:()=>{},2684:(e,t,i)=>{"use strict";i.d(t,{B:()=>o,P:()=>s});var n=i(73365),a=i(1521);let r=(0,a.createContext)(null);function o({attributes:e,children:t}){let i=(0,a.useContext)(r);return(0,n.jsx)(r.Provider,{value:i??e,children:t})}function s(e){return(0,a.useContext)(r)??e}},3500:(e,t,i)=>{"use strict";i.d(t,{BI:()=>o,Bi:()=>u,GN:()=>p,J2:()=>s,L6:()=>g,Y8:()=>d,cq:()=>n,i:()=>l,lB:()=>m,m1:()=>h,sw:()=>r,tw:()=>c});let n=Object.freeze({width:1200,height:800}),a=Object.freeze({width:1600,height:900});function r(e=a){var t;let i,o,s,l,d;return{...e,bounds:(t=e,i=.84*n.width,o=.84*n.height,s=Math.min(i/t.width,o/t.height),l=t.width*s,d=t.height*s,{x:(n.width-l)/2/n.width,y:(n.height-d)/2/n.height,width:l/n.width,height:d/n.height})}}function o(e,t){let i=Math.max(1,Math.floor(1600/Math.max(e,t)));return{width:Math.round(e*i),height:Math.round(t*i)}}function s(e,t){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0)return!1;let i=e/t;return i>=.5&&i<=2}function l(e){return{x:e.bounds.x*n.width,y:e.bounds.y*n.height,width:e.bounds.width*n.width,height:e.bounds.height*n.height}}function d(e){let t=180*Math.atan2(e.height,e.width)/Math.PI;return[...Array.from({length:8},(e,t)=>45*t),t,180-t,180+t,360-t].sort((e,t)=>e-t).filter((e,t,i)=>0===t||Math.abs(e-i[t-1])>1e-8)}function c(e,t){return{x:t.bounds.x+e.x*t.bounds.width,y:t.bounds.y+e.y*t.bounds.height}}function u(e,t){return{x:(e.x-t.bounds.x)/t.bounds.width,y:(e.y-t.bounds.y)/t.bounds.height}}function m(e,t){return{...e,bounds:{...e.bounds,x:t.x,y:t.y}}}function h(e,t,i="bottom-right"){let a=l(e),r=a.x+a.width,o=a.y+a.height,s=Math.max(t,Math.max(96/a.width,96/a.height)),d=a.width*s,c=a.height*s,u=i.endsWith("left")?r-d:a.x,m=i.startsWith("top")?o-c:a.y;return{...e,bounds:{x:u/n.width,y:m/n.height,width:d/n.width,height:c/n.height}}}function p(e,t){let i=t.width,a=t.height;if(i<96||a<96)return e;let r=i/a;if(!s(i,a))return e;let o=Math.min(4096,Math.max(e.width,e.height,r>=1?256*r:256/r));return{...r>=1?{width:Math.round(o),height:Math.round(o/r)}:{width:Math.round(o*r),height:Math.round(o)},bounds:{x:t.x/n.width,y:t.y/n.height,width:t.width/n.width,height:t.height/n.height}}}function g(e,t){let i=l(e),a=t.width/t.height,r={x:i.x+i.width/2,y:i.y+i.height/2},o=Math.sqrt(i.width*i.height*a),s=o/a,d=r.x-o/2,c=r.y-s/2;return{...t,bounds:{x:d/n.width,y:c/n.height,width:o/n.width,height:s/n.height}}}},3693:(e,t,i)=>{"use strict";i.d(t,{cq:()=>a.cq,Hm:()=>o,Xn:()=>n.Xn,xB:()=>n.xB,vF:()=>s,JZ:()=>n.JZ,eq:()=>n.eq,hN:()=>n.hN,QR:()=>r.QR,oA:()=>n.oA,MR:()=>r.MR,BI:()=>a.BI,SZ:()=>p,fQ:()=>R.fQ,Y8:()=>a.Y8,s6:()=>n.s6,wG:()=>R.wG,mq:()=>n.mq,PX:()=>R.PX,Oq:()=>v,i:()=>a.i,bc:()=>w,J2:()=>a.J2,MY:()=>n.MY,u7:()=>c,Dr:()=>n.Dr,Pe:()=>n.Pe,Wn:()=>n.Wn,CP:()=>n.CP,q3:()=>d,Ai:()=>n.Ai,uK:()=>R.uK,gf:()=>N,qU:()=>L,yU:()=>R.yU,sJ:()=>l,oF:()=>n.oF,CV:()=>n.CV,Kd:()=>n.Kd,co:()=>n.co,IU:()=>n.IU,z_:()=>n.z_,rz:()=>n.rz,hG:()=>n.hG,KZ:()=>R.KZ,n_:()=>m,ht:()=>h,ET:()=>n.ET,Dj:()=>r.Dj,gH:()=>g,ai:()=>n.ai,QY:()=>n.QY,s:()=>n.s,M6:()=>n.M6,VC:()=>n.VC});var n=i(52582),a=i(3500),r=i(19767);let o=["thirds","golden-section","symmetry","golden-spiral","triangle","radial"];function s(e,t){let i=(0,n.M6)(e),a=i.plans??[],r=1;for(;a.some(e=>e.id===`plan-${r}`);)r+=1;let o={id:`plan-${r}`,visible:!0},s="triangle"===t?{...o,type:t,x:.5,y:.5,rotation:0,width:.6,height:.6}:"symmetry"===t?{...o,type:t,x:.5,y:.5,rotation:90}:"golden-spiral"===t?{...o,type:t,x:.618,y:.382,rotation:135,scale:.65,mirrored:!1}:"radial"===t?{...o,type:t,mode:"uniform",x:.5,y:.5,rotation:0,rayCount:8,spread:360}:{...o,type:t,axes:"both"};return{draft:(0,n.M6)({...i,plans:[...a,s]}),id:s.id}}function l(e,t){return(0,n.M6)({...e,plans:(e.plans??[]).map(e=>e.id===t.id?t:e)})}function d(e,t){return(0,n.M6)({...e,plans:(e.plans??[]).filter(e=>e.id!==t)})}function c(e,t,i){return(0,n.M6)({...e,plans:(e.plans??[]).map(n=>t.includes(n.id)?g(n,e.frame,i):n)})}function u(e){if("free"===e.mode)return[...e.angles];let t=e.spread/(360===e.spread?e.rayCount:e.rayCount-1);return Array.from({length:e.rayCount},(i,n)=>(e.rotation+n*t)%360)}function m(e,t){if(e.mode===t)return e;let i={id:e.id,type:e.type,visible:e.visible,x:e.x,y:e.y},n=u(e);return"free"===t?{...i,mode:t,angles:n}:{...i,mode:t,rotation:n[0],rayCount:n.length,spread:360}}function h(e,t){if("uniform"===e.mode)return{...e,rayCount:t};let i=e.angles.slice(0,t);for(;i.length<t;){let e=[...i].sort((e,t)=>e-t),t=e.map((t,i)=>(e[i+1]??e[0]+360)-t),n=t.indexOf(Math.max(...t));i.push((e[n]+t[n]/2)%360)}return{...e,angles:i}}function p(e,t){let i=(0,a.i)(t),r=e=>({x:i.x+e.x*i.width,y:i.y+e.y*i.height});if("thirds"===e.type||"golden-section"===e.type){let t="thirds"===e.type?1/3:(3-Math.sqrt(5))/2,i=[];for(let n of[t,1-t])"horizontal"!==e.axes&&i.push([r({x:n,y:0}),r({x:n,y:1})]),"vertical"!==e.axes&&i.push([r({x:0,y:n}),r({x:1,y:n})]);return{paths:i,handles:[]}}if("triangle"===e.type){let t=r(e),n=e.rotation*Math.PI/180,a=e.width*i.width,o=e.height*i.height,s=[{x:0,y:-o/2},{x:-a/2,y:o/2},{x:a/2,y:o/2}].map(({x:e,y:i})=>({x:t.x+e*Math.cos(n)-i*Math.sin(n),y:t.y+e*Math.sin(n)+i*Math.cos(n)}));return{paths:[[...s,s[0]]],handles:s}}let o=r("symmetry"===e.type?{x:.5,y:.5}:e),s=("symmetry"===e.type?(0,n.km)(e.rotation,t):"radial"===e.type?0:e.rotation)*Math.PI/180,l=(e,t=0)=>({x:o.x+e*Math.cos(s+t),y:o.y+e*Math.sin(s+t)}),d=Math.min(i.width,i.height);if("symmetry"===e.type){let e=Math.hypot(i.width,i.height)+Math.hypot(o.x-i.x,o.y-i.y),n=(0,a.Y8)(t).map(e=>l(.3*d,e*Math.PI/180-s));return{paths:[[l(-e),l(e)]],handles:[o,l(.3*d)],snapPoints:n}}if("radial"===e.type){let t=Math.hypot(i.width,i.height)+Math.hypot(o.x-i.x,o.y-i.y),n=u(e).map(e=>e*Math.PI/180);return{paths:n.map(e=>[o,l(t,e)]),handles:[o,...("free"===e.mode?n:n.slice(0,1)).map(e=>l(.3*d,e))]}}let c=d*e.scale,m=(1+Math.sqrt(5))/2,h=6*Math.PI,p=Array.from({length:241},(t,i)=>{let n=(i/240-1)*h;return l(c*m**(n/(Math.PI/2)),e.mirrored?-n:n)}),g=c*(1+(Math.log(m)/(Math.PI/2))**2)*(h/240)**2/8;return{paths:[p],handles:[o,l(c)],maxCurveDeviation:g}}function g(e,t,i,r){if("thirds"===e.type||"golden-section"===e.type)return e;let o=(0,a.i)(t);if("symmetry"===e.type){let a={...e,x:.5,y:.5,rotation:(0,n.km)(e.rotation,t)};if(1!==r)return a;let{handles:[o,s]}=p(a,t),l=s.x+i.x-o.x,d=s.y+i.y-o.y;return 1>Math.hypot(l,d)?a:{...a,rotation:(0,n.km)(180*Math.atan2(d,l)/Math.PI,t)}}if(void 0===r||"triangle"!==e.type&&0===r)return{...e,x:e.x+i.x/o.width,y:e.y+i.y/o.height};let{handles:s}=p(e,t),l={x:o.x+e.x*o.width,y:o.y+e.y*o.height},d=s[r].x+i.x-l.x,c=s[r].y+i.y-l.y;if("triangle"===e.type){if(0===r)return 1>Math.hypot(d,c)?e:{...e,rotation:180*Math.atan2(c,d)/Math.PI+90,height:2*Math.hypot(d,c)/o.height};let t=e.rotation*Math.PI/180;return{...e,width:Math.max(.01,2*Math.abs(d*Math.cos(t)+c*Math.sin(t))/o.width),height:Math.max(.01,2*(-d*Math.sin(t)+c*Math.cos(t))/o.height)}}if(1>Math.hypot(d,c))return e;let u=180*Math.atan2(c,d)/Math.PI;return"radial"===e.type?"free"===e.mode?{...e,angles:e.angles.map((e,t)=>t===r-1?u:e)}:{...e,rotation:u}:{...e,rotation:u,scale:Math.max(.01,Math.hypot(d,c)/Math.min(o.width,o.height))}}function f(e,t){return{x:e.x-t.x,y:e.y-t.y}}function y(e,t){return e.x*t.y-e.y*t.x}function x(e,t){return{x:e.start.x+(e.end.x-e.start.x)*t,y:e.start.y+(e.end.y-e.start.y)*t}}var b=i(19204);function v(e){var t;let i=(0,n.M6)(e);return(0,b.U)(JSON.stringify({...(t=i).plans?{plans:t.plans}:{},...t.states?{activeStateId:t.activeStateId,states:t.states.map(({id:e,number:t,name:i,layout:n})=>({id:e,number:t,name:i,layout:n}))}:{},...t.layerOrder?{layerOrder:t.layerOrder}:{},version:t.version,kind:t.kind,processingSemantic:t.processingSemantic,frame:{width:t.frame.width,height:t.frame.height,bounds:{x:t.frame.bounds.x,y:t.frame.bounds.y,width:t.frame.bounds.width,height:t.frame.bounds.height}},...""===t.overallNote?{}:{overallNote:t.overallNote},focusPoints:t.focusPoints.map(({id:e,x:t,y:i,...n})=>({id:e,x:t,y:i,...M(n)})),...t.directionLine?{directionLine:{id:t.directionLine.id,x:t.directionLine.x,y:t.directionLine.y,rotation:t.directionLine.rotation,...M(t.directionLine)}}:{},areas:t.areas.map(e=>({id:e.id,primitive:e.primitive,x:e.x,y:e.y,area:e.area,aspect:e.aspect,...M(e),..."auto"===e.visualWeight?{}:{visualWeight:e.visualWeight},...e.displayText?{displayText:e.displayText}:{},...e.isLightSource?{isLightSource:!0}:{},...void 0===e.rotation?{}:{rotation:e.rotation},...void 0===e.width?{}:{width:e.width},...void 0===e.height?{}:{height:e.height},...void 0===e.corners?{}:{corners:e.corners}})),images:t.images.map(e=>({id:e.id,x:e.x,y:e.y,width:e.width,height:e.height,rotation:e.rotation,assetId:e.assetId,...e.cameraReference?{cameraReference:e.cameraReference}:{},crop:e.crop,...M(e),..."auto"===e.visualWeight?{}:{visualWeight:e.visualWeight}}))}))}function w(e){var t,i,o;let s,l,d,c=(0,n.M6)(e),u=(0,n.VC)(c),m=c.areas.map((e,t)=>{let i=(0,r.Sq)((0,r.QR)(e,a.cq)),n=(0,a.i)(c.frame),o=(0,a.Bi)(e,c.frame),s=n.width*n.height;return{id:e.id,primitive:e.primitive,note:e.note,annotation:e.annotation,semanticType:e.semanticType,shotScale:e.shotScale,visualWeight:e.visualWeight,isLightSource:e.isLightSource??!1,...void 0===e.displayText?{}:{displayText:e.displayText},center:{x:C(o.x),y:C(o.y)},areaShare:C(e.area*a.cq.width*a.cq.height/s),visibleAreaShare:C(u.visibleAreaShares[t]),rotation:C(e.rotation??0),clippedSides:I(i,c.frame),bounds:{minimumX:C((i.minimumX-n.x)/n.width),maximumX:C((i.maximumX-n.x)/n.width),minimumY:C((i.minimumY-n.y)/n.height),maximumY:C((i.maximumY-n.y)/n.height)}}}),h=c.images.map(e=>{let t=(0,r.xz)(e),i=(0,a.i)(c.frame),n=(0,a.Bi)(e,c.frame);return{id:e.id,note:e.note,annotation:e.annotation,semanticType:e.semanticType,shotScale:e.shotScale,visualWeight:e.visualWeight,center:{x:C(n.x),y:C(n.y)},widthShare:C(t.width/i.width),heightShare:C(t.height/i.height),areaShare:C(t.width*t.height/(i.width*i.height)),rotation:C(e.rotation),clippedSides:I({minimumX:t.x,maximumX:t.x+t.width,minimumY:t.y,maximumY:t.y+t.height},c.frame)}});return{version:1,kind:"composition-inspection",...c.plans?{plans:structuredClone(c.plans)}:{},planningIntersections:function(e){let t=(0,a.i)(e.frame),i=(e.plans??[]).flatMap(i=>{let n=p(i,e.frame);return("triangle"===i.type?n.paths[0].slice(0,-1).map((e,t)=>[e,n.paths[0][t+1]]):n.paths).map((a,r)=>({source:{planId:i.id,type:i.type,lineId:function(e,t){if("thirds"===e.type||"golden-section"===e.type){let i="both"===e.axes?t%2==0?"vertical":"horizontal":e.axes;return`${i}-${"both"===e.axes?Math.floor(t/2)+1:t+1}`}return"triangle"===e.type?`edge-${t+1}`:"radial"===e.type?`ray-${t+1}`:"symmetry"===e.type?"axis":"spiral"}(i,r),visible:i.visible},segments:a.slice(0,-1).map((e,t)=>({start:e,end:a[t+1]})),maxCurveDeviationPx:(n.maxCurveDeviation??0)*e.frame.width/t.width}))}),n=[];for(let e=0;e<i.length;e+=1)for(let a=e+1;a<i.length;a+=1){let r=i[e],o=i[a],s=[],l=[];for(let e of r.segments)for(let t of o.segments){let i=function(e,t){if(Math.max(e.start.x,e.end.x)+1e-7<Math.min(t.start.x,t.end.x)||Math.max(t.start.x,t.end.x)+1e-7<Math.min(e.start.x,e.end.x)||Math.max(e.start.y,e.end.y)+1e-7<Math.min(t.start.y,t.end.y)||Math.max(t.start.y,t.end.y)+1e-7<Math.min(e.start.y,e.end.y))return null;let i=f(e.end,e.start),n=f(t.end,t.start),a=f(t.start,e.start),r=Math.hypot(i.x,i.y),o=Math.hypot(n.x,n.y);if(r<=1e-7||o<=1e-7)return null;let s=y(i,n);if(Math.abs(s)<=1e-12*r*o){if(Math.abs(y(a,i))>1e-7*r)return null;let t=(a.x*i.x+a.y*i.y)/r**2,o=t+(n.x*i.x+n.y*i.y)/r**2,s=Math.max(0,Math.min(t,o)),l=Math.min(1,Math.max(t,o));return l<s-1e-7/r?null:l-s<=1e-7/r?{point:x(e,Math.max(0,Math.min(1,(s+l)/2)))}:{overlap:{start:x(e,s),end:x(e,l)}}}let l=y(a,n)/s,d=y(a,i)/s;return l<-1e-7/r||l>1+1e-7/r||d<-1e-7/o||d>1+1e-7/o?null:{point:x(e,Math.max(0,Math.min(1,l)))}}(e,t);i&&"point"in i?s.push(i.point):i&&l.push(i.overlap)}for(let e of s){if(e.x<t.x-1e-7||e.x>t.x+t.width+1e-7||e.y<t.y-1e-7||e.y>t.y+t.height+1e-7||l.some(t=>(function(e,t){let i=f(t.end,t.start),n=f(e,t.start),a=x(t,Math.max(0,Math.min(1,(n.x*i.x+n.y*i.y)/(i.x**2+i.y**2))));return 1e-7>=Math.hypot(e.x-a.x,e.y-a.y)})(e,t)))continue;let i=n.find(t=>1e-7>=Math.hypot(t.point.x-e.x,t.point.y-e.y));for(let t of(i||(i={point:e,sources:[],maxCurveDeviationPx:0},n.push(i)),[r.source,o.source]))i.sources.some(e=>e.planId===t.planId&&e.lineId===t.lineId)||i.sources.push(t);i.maxCurveDeviationPx=Math.max(i.maxCurveDeviationPx,r.maxCurveDeviationPx,o.maxCurveDeviationPx)}}return n.sort((e,t)=>e.point.y-t.point.y||e.point.x-t.point.x).map((i,n)=>{let r={x:Math.max(0,Math.min(1,(i.point.x-t.x)/t.width)),y:Math.max(0,Math.min(1,(i.point.y-t.y)/t.height))};return{id:`intersection-${n+1}`,framePoint:r,canvasPoint:(0,a.tw)(r,e.frame),sources:i.sources,precision:{kind:i.sources.some(e=>"golden-spiral"===e.type)?"approximate":"exact",maxCurveDeviationPx:i.maxCurveDeviationPx}}})}(c),sourceFingerprint:v(c),processingSemantic:c.processingSemantic,frame:structuredClone(c.frame),overallNote:c.overallNote,focusPoints:c.focusPoints.map(e=>({...e,...P(e,c.frame)})),directionLine:c.directionLine?{...c.directionLine,...P(c.directionLine,c.frame)}:null,areas:m,images:h,axes:{focus:k(c.focusPoints,c),area:k(c.areas,c)},metrics:u,guidance:(s=[...(t=c).directionLine?[{...t.directionLine,localAxis:"x"}]:[],...t.areas.filter(e=>"circle"!==e.primitive||"free"===e.aspect&&Math.abs(e.width*a.cq.width-e.height*a.cq.height)>1e-9).flatMap(e=>["x","y"].map(t=>({...e,localAxis:t})))],l=t.frame.width/(t.frame.bounds.width*a.cq.width),s.flatMap(e=>t.focusPoints.map(t=>{let i=(e.rotation??0)+90*("y"===e.localAxis),n=i*Math.PI/180,r=(t.x-e.x)*a.cq.width,o=(t.y-e.y)*a.cq.height,s=180*Math.atan2(o,r)/Math.PI-i;return{sourceId:e.id,focusId:t.id,localAxis:e.localAxis,angleError:1e-9>Math.hypot(r,o)?null:C(Math.abs((s%360+540)%360-180)),perpendicularDistance:C(Math.abs(r*Math.sin(n)-o*Math.cos(n))*l),forwardDistance:C((r*Math.cos(n)+o*Math.sin(n))*l)}}))),layout:"editorial-layout"===c.processingSemantic?(i=c,d={auto:[],high:[],medium:[],low:[],decorative:[]},(o=m).forEach(e=>d[e.visualWeight].push(e.id)),{alignmentTolerance:.02,textRegionIds:o.filter(({semanticType:e})=>"text-region"===e).map(({id:e})=>e),weightGroups:d,areas:o.map(e=>({id:e.id,widthShare:C(e.bounds.maximumX-e.bounds.minimumX),heightShare:C(e.bounds.maximumY-e.bounds.minimumY),margins:{top:e.bounds.minimumY,right:C(1-e.bounds.maximumX),bottom:C(1-e.bounds.maximumY),left:e.bounds.minimumX}})),pairs:function(e){let t=[];for(let i=0;i<e.length;i+=1)for(let n=i+1;n<e.length;n+=1){let a=e[i],r=e[n],o=a.bounds.maximumX-a.bounds.minimumX,s=r.bounds.maximumX-r.bounds.minimumX,l=a.bounds.maximumY-a.bounds.minimumY,d=r.bounds.maximumY-r.bounds.minimumY,c=[];for(let[e,t,i]of[["left",a.bounds.minimumX,r.bounds.minimumX],["center-x",a.center.x,r.center.x],["right",a.bounds.maximumX,r.bounds.maximumX],["top",a.bounds.minimumY,r.bounds.minimumY],["center-y",a.center.y,r.center.y],["bottom",a.bounds.maximumY,r.bounds.maximumY]]).02>=Math.abs(t-i)&&c.push(e);t.push({ids:[a.id,r.id],widthRatio:C(j(o,s)),heightRatio:C(j(l,d)),areaRatio:C(j(a.areaShare,r.areaShare)),horizontalGap:C(function(e,t,i,n){return t<i?i-t:n<e?e-n:0}(a.bounds.minimumX,a.bounds.maximumX,r.bounds.minimumX,r.bounds.maximumX)),verticalGap:C(function(e,t,i,n){return t<i?i-t:n<e?e-n:0}(a.bounds.minimumY,a.bounds.maximumY,r.bounds.minimumY,r.bounds.maximumY)),centerDistance:C(Math.hypot(a.center.x-r.center.x,a.center.y-r.center.y)),alignments:c})}return t}(o),focusRelations:i.focusPoints.map(e=>{let t=P(e,i.frame),n=o.map(e=>{var i,n;return{id:e.id,distance:(i=t,Math.hypot(Math.max((n=e.bounds).minimumX-i.x,0,i.x-n.maximumX),Math.max(n.minimumY-i.y,0,i.y-n.maximumY)))}}),a=n.filter(({distance:e})=>e<=1e-9).map(({id:e})=>e),r=n.sort((e,t)=>e.distance-t.distance)[0];return{focusId:e.id,containingAreaIds:a,nearestAreaId:r?.id??null,distance:r?C(r.distance):null}})}):null}}function j(e,t){return Math.max(e,t)/Math.min(e,t)}function k(e,t){let i=[],n=(0,a.i)(t.frame),r=Math.hypot(n.width,n.height);for(let t=0;t<e.length;t+=1)for(let n=t+1;n<e.length;n+=1){let a=S(e[t]),o=S(e[n]);i.push({ids:[e[t].id,e[n].id],angle:C(180*Math.atan2(o.y-a.y,o.x-a.x)/Math.PI),distance:C(Math.hypot(o.x-a.x,o.y-a.y)/r)})}return i}function I(e,t){let i=[],n=(0,a.i)(t),r=1e-9*Math.max(n.width,n.height);return e.minimumY<n.y-r&&i.push("top"),e.maximumX>n.x+n.width+r&&i.push("right"),e.maximumY>n.y+n.height+r&&i.push("bottom"),e.minimumX<n.x-r&&i.push("left"),i}function S(e){return{x:e.x*a.cq.width,y:e.y*a.cq.height}}function P(e,t){let i=(0,a.Bi)(e,t);return{x:C(i.x),y:C(i.y)}}function C(e){return Math.round(1e6*e)/1e6}function M(e){return{...""===e.note?{}:{note:e.note},...""===e.annotation?{}:{annotation:e.annotation},...""===e.semanticType?{}:{semanticType:e.semanticType},..."auto"===e.shotScale?{}:{shotScale:e.shotScale}}}var A=i(34345);function L(e,t){var i,o;let s,l=(0,n.M6)(e),d=(0,a.i)(l.frame),c=Math.min(d.width,d.height),u=.004*c,m=.018*c,h=[...l.images.map(e=>(function(e,t){let i=e.width*a.cq.width,n=e.height*a.cq.height,r=e.x*a.cq.width,o=e.y*a.cq.height,s=r-i/2,l=o-n/2,d=e.assetId?t?.(e.assetId):void 0,c=e.rotation?` transform="rotate(${$(e.rotation)} ${$(r)} ${$(o)})"`:"";if(!d)return`<rect data-region-kind="image" x="${$(s)}" y="${$(l)}" width="${$(i)}" height="${$(n)}" fill="#eeeeee" stroke="#8f8f8f" stroke-width="2"${c}/>`;let u=e.crop,m=u?s-u.x/u.width*i:s,h=u?l-u.y/u.height*n:l,p=u?i/u.width:i,g=u?n/u.height:n,f=`composition-image-${e.id.replace(/[^a-zA-Z0-9_-]/g,"-")}`;return`<g data-region-kind="image"${c}><defs><clipPath id="${f}"><rect x="${$(s)}" y="${$(l)}" width="${$(i)}" height="${$(n)}"/></clipPath></defs><image href="${F(d)}" x="${$(m)}" y="${$(h)}" width="${$(p)}" height="${$(g)}" preserveAspectRatio="${u?"none":"xMidYMid slice"}" clip-path="url(#${f})"/></g>`})(e,t)),...l.areas.map(e=>{var t;let i;if(e.isLightSource)return N(e,void 0,"reference");let n=(0,r.QR)(e,a.cq);if(e.corners&&"polygon"===n.type){let t=n.points.map(e=>`${$(e.x)},${$(e.y)}`).join(" "),i=(0,r.Dj)(e,a.cq).map(([e,t])=>`<line x1="${$(e.x)}" y1="${$(e.y)}" x2="${$(t.x)}" y2="${$(t.y)}" stroke="#555555" stroke-width="${$(2*u)}" stroke-linecap="round"/>`);return`<g data-region-kind="text-region"><polygon data-reference-role="text-outline" points="${t}" fill="#e3e3e3"/><g data-reference-role="typography">${i.join("")}</g></g>`}let o=(t=n,i=(0,r.Sq)(t),`<ellipse cx="${$((i.minimumX+i.maximumX)/2)}" cy="${$((i.minimumY+i.maximumY)/2)}" rx="${$((i.maximumX-i.minimumX)/2)}" ry="${$((i.maximumY-i.minimumY)/2)}" data-reference-role="influence-zone" fill="url(#composition-region-gradient)"/>`);if("text-region"!==e.semanticType)return`<g data-region-kind="content-region">${o}</g>`;let s=(0,r.Sq)(n),l=s.maximumX-s.minimumX,d=Math.min(.08*(s.maximumY-s.minimumY),.012*c),m=1.1*d,h=(s.minimumY+s.maximumY)/2,p=[.72,.48,.62].map((e,t)=>`<rect x="${$(s.minimumX+.14*l)}" y="${$(h+(t-1)*(d+m)-d/2)}" width="${$(l*e)}" height="${$(d)}" rx="${$(d/2)}" fill="#555555" fill-opacity="0.58"/>`);return`<g data-region-kind="text-region">${o}<g data-reference-role="typography">${p.join("")}</g></g>`})];if(l.directionLine){let e=(0,r.Wu)(l.directionLine,a.cq);h.push(`<line x1="${$(e.start.x)}" y1="${$(e.start.y)}" x2="${$(e.end.x)}" y2="${$(e.end.y)}" stroke="#1f1f1f" stroke-width="${$(u)}" stroke-dasharray="${$(.018*c)} ${$(.012*c)}"/>`)}for(let e of l.focusPoints){let t=e.x*a.cq.width,i=e.y*a.cq.height;h.push(`<line x1="${$(t-1.8*m)}" y1="${$(i)}" x2="${$(t+1.8*m)}" y2="${$(i)}" stroke="#1f1f1f" stroke-width="${$(u)}"/><line x1="${$(t)}" y1="${$(i-1.8*m)}" x2="${$(t)}" y2="${$(i+1.8*m)}" stroke="#1f1f1f" stroke-width="${$(u)}"/><circle cx="${$(t)}" cy="${$(i)}" r="${$(m)}" fill="#ffffff" stroke="#1f1f1f" stroke-width="${$(u)}"/>`)}return[`<svg xmlns="http://www.w3.org/2000/svg" width="${l.frame.width}" height="${l.frame.height}" viewBox="${$(d.x)} ${$(d.y)} ${$(d.width)} ${$(d.height)}">`,'<defs><radialGradient id="composition-region-gradient"><stop offset="0" stop-color="#8f8f8f" stop-opacity="0.32"/><stop offset="0.58" stop-color="#9a9a9a" stop-opacity="0.22"/><stop offset="1" stop-color="#b8b8b8" stop-opacity="0"/></radialGradient></defs>',`<rect x="${$(d.x)}" y="${$(d.y)}" width="${$(d.width)}" height="${$(d.height)}" fill="#ffffff"/>`,...(i=l,o=h,s=new Map([...i.images,...i.areas,...i.directionLine?[i.directionLine]:[],...i.focusPoints].map((e,t)=>[e.id,o[t]])),(0,A.u)(i).map(e=>s.get(e))),"</svg>"].join("")}function N(e,t=`composition-light-${e.id}`,i="editor"){let n=F(t),o=(0,r.QR)({...e,rotation:0},a.cq),s="reference"===i,l=(0,r.Sq)(o),d=l.maximumX-l.minimumX,c=l.maximumY-l.minimumY,u=s?`fill="url(#${n})" stroke="none" filter="url(#${n}-soften)"`:`fill="url(#${n})" stroke="#d6b95c" stroke-opacity="0.55" stroke-width="1.5"`,m="circle"===o.type?`<circle cx="${$(o.cx)}" cy="${$(o.cy)}" r="${$(o.radius)}" ${u}/>`:"ellipse"===o.type?`<ellipse cx="${$(o.cx)}" cy="${$(o.cy)}" rx="${$(o.radiusX)}" ry="${$(o.radiusY)}" ${u}/>`:`<polygon points="${o.points.map(e=>`${$(e.x)},${$(e.y)}`).join(" ")}" ${u}/>`,h="quadrilateral"===e.primitive?`<linearGradient id="${n}" x1="0" y1="0" x2="${d>=c?"0":"1"}" y2="${d>=c?"1":"0"}"><stop offset="0" stop-color="#ffe58a" stop-opacity="0"/><stop offset="0.3" stop-color="#ffe58a" stop-opacity="0.5"/><stop offset="0.5" stop-color="#fff8c4" stop-opacity="0.9"/><stop offset="0.7" stop-color="#ffe58a" stop-opacity="0.5"/><stop offset="1" stop-color="#ffe58a" stop-opacity="0"/></linearGradient>`:`<radialGradient id="${n}"><stop offset="0" stop-color="#fff8c4" stop-opacity="0.95"/><stop offset="0.55" stop-color="#ffe58a" stop-opacity="${s?"0.4":"0.65"}"/><stop offset="1" stop-color="#ffe58a" stop-opacity="${s?"0":"0.12"}"/></radialGradient>`,p=s?`<filter id="${n}-soften" x="-25%" y="-25%" width="150%" height="150%"><feGaussianBlur stdDeviation="${$(.06*Math.min(d,c))}"/></filter>`:"";return`<g data-region-kind="light-source" data-light-source-id="${F(e.id)}" transform="rotate(${$(e.rotation??0)} ${$(e.x*a.cq.width)} ${$(e.y*a.cq.height)})"><defs>${h}${p}</defs>${m}</g>`}function $(e){return String(Math.round(1e3*e)/1e3)}function F(e){return e.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">")}var _=i(27062);let T=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://yisi.local/schemas/composition-refinement-plan.schema.json","title":"Agent-authored Composition Refinement Plan","oneOf":[{"$ref":"#/$defs/legacyPlan"},{"$ref":"#/$defs/directedPlan"}],"$defs":{"focusAnchor":{"type":"object","additionalProperties":false,"required":["method","methodVersion","targetFocusId","anchor"],"properties":{"method":{"const":"focus-anchor"},"methodVersion":{"const":1},"targetFocusId":{"type":"string","pattern":"^focus-[0-9]+$"},"anchor":{"enum":["optical-center","geometric-center","golden-right-upper","golden-left-upper","golden-right-lower","golden-left-lower","third-right-upper","third-left-upper","third-right-lower","third-left-lower"]},"strength":{"const":"subtle","description":"Legacy compatibility field; does not restrict adjustment magnitude."},"reason":{"type":"string","minLength":1,"maxLength":2000},"expectedEffect":{"type":"string","minLength":1,"maxLength":2000}}},"axisRelation":{"type":"object","additionalProperties":false,"required":["method","methodVersion","focusIds","areaIds","relation"],"properties":{"method":{"const":"axis-relation"},"methodVersion":{"const":1},"focusIds":{"type":"array","minItems":2,"maxItems":2,"uniqueItems":true,"items":{"type":"string","pattern":"^focus-[0-9]+$"}},"areaIds":{"type":"array","minItems":2,"maxItems":2,"uniqueItems":true,"items":{"type":"string","pattern":"^area-[0-9]+$"}},"relation":{"enum":["parallel","perpendicular","mirrored-cross"]},"strength":{"const":"subtle","description":"Legacy compatibility field; does not restrict adjustment magnitude."},"reason":{"type":"string","minLength":1,"maxLength":2000},"expectedEffect":{"type":"string","minLength":1,"maxLength":2000}}},"rotationAlignment":{"type":"object","additionalProperties":false,"required":["method","methodVersion","targetAreaIds","axis"],"properties":{"method":{"const":"rotation-alignment"},"methodVersion":{"const":1},"targetAreaIds":{"type":"array","minItems":1,"uniqueItems":true,"items":{"type":"string","pattern":"^area-[0-9]+$"}},"axis":{"enum":["horizontal","vertical","rising-diagonal","falling-diagonal"]},"strength":{"const":"subtle","description":"Legacy compatibility field; does not restrict adjustment magnitude."},"reason":{"type":"string","minLength":1,"maxLength":2000},"expectedEffect":{"type":"string","minLength":1,"maxLength":2000}}},"blockAlignment":{"type":"object","additionalProperties":false,"required":["method","methodVersion","targetAreaIds","anchorAreaId","alignment"],"properties":{"method":{"const":"block-alignment"},"methodVersion":{"const":1},"targetAreaIds":{"type":"array","minItems":2,"uniqueItems":true,"items":{"type":"string","pattern":"^area-[0-9]+$"}},"anchorAreaId":{"type":"string","pattern":"^area-[0-9]+$"},"alignment":{"enum":["left","horizontal-center","right","top","vertical-center","bottom"]},"strength":{"const":"subtle","description":"Legacy compatibility field; does not restrict adjustment magnitude."},"reason":{"type":"string","minLength":1,"maxLength":2000},"expectedEffect":{"type":"string","minLength":1,"maxLength":2000}}},"spacingRhythm":{"type":"object","additionalProperties":false,"required":["method","methodVersion","targetAreaIds","axis","distribution"],"properties":{"method":{"const":"spacing-rhythm"},"methodVersion":{"const":1},"targetAreaIds":{"type":"array","minItems":3,"uniqueItems":true,"items":{"type":"string","pattern":"^area-[0-9]+$"}},"axis":{"enum":["horizontal","vertical"]},"distribution":{"const":"equal"},"strength":{"const":"subtle","description":"Legacy compatibility field; does not restrict adjustment magnitude."},"reason":{"type":"string","minLength":1,"maxLength":2000},"expectedEffect":{"type":"string","minLength":1,"maxLength":2000}}},"framePlacement":{"type":"object","additionalProperties":false,"required":["method","methodVersion","targetId","axis","alignment","division"],"properties":{"method":{"const":"frame-placement"},"methodVersion":{"const":1},"targetId":{"type":"string","pattern":"^(area|focus)-[0-9]+$"},"axis":{"enum":["x","y"]},"alignment":{"enum":["start","center","end"]},"division":{"enum":["center","golden-start","golden-end","third-start","third-end"]},"reason":{"type":"string","minLength":1,"maxLength":2000},"expectedEffect":{"type":"string","minLength":1,"maxLength":2000}}},"sizeRatio":{"type":"object","additionalProperties":false,"required":["method","methodVersion","targetAreaId","dimension","referenceId","referenceDimension","ratio"],"properties":{"method":{"const":"size-ratio"},"methodVersion":{"const":1},"targetAreaId":{"type":"string","pattern":"^area-[0-9]+$"},"dimension":{"enum":["width","height","area"]},"referenceId":{"type":"string","pattern":"^(frame|area-[0-9]+)$"},"referenceDimension":{"enum":["width","height","area"]},"ratio":{"type":"number","exclusiveMinimum":0},"reason":{"type":"string","minLength":1,"maxLength":2000},"expectedEffect":{"type":"string","minLength":1,"maxLength":2000}}},"mirrorSymmetry":{"type":"object","additionalProperties":false,"required":["method","methodVersion","anchorAreaId","targetAreaId","axis","division","match"],"properties":{"method":{"const":"mirror-symmetry"},"methodVersion":{"const":1},"anchorAreaId":{"type":"string","pattern":"^area-[0-9]+$"},"targetAreaId":{"type":"string","pattern":"^area-[0-9]+$"},"axis":{"enum":["vertical","horizontal"]},"division":{"enum":["center","golden-start","golden-end","third-start","third-end"]},"match":{"enum":["position","geometry"]},"reason":{"type":"string","minLength":1,"maxLength":2000},"expectedEffect":{"type":"string","minLength":1,"maxLength":2000}}},"focusFlow":{"type":"object","additionalProperties":false,"required":["method","methodVersion","sourceId","targetFocusId","localAxis"],"properties":{"method":{"const":"focus-flow"},"methodVersion":{"const":1},"sourceId":{"type":"string","pattern":"^(direction-1|area-[0-9]+)$"},"targetFocusId":{"type":"string","pattern":"^focus-[0-9]+$"},"localAxis":{"enum":["x","y"]},"reason":{"type":"string","minLength":1,"maxLength":2000},"expectedEffect":{"type":"string","minLength":1,"maxLength":2000}}},"legacyPlan":{"type":"object","additionalProperties":false,"required":["version","kind","sourceFingerprint","rationale","operations"],"properties":{"version":{"const":1},"kind":{"const":"composition-refinement-plan"},"sourceFingerprint":{"type":"string","pattern":"^draft-[0-9a-f]{8}$"},"rationale":{"type":"string","minLength":1,"maxLength":2000},"operations":{"type":"array","minItems":1,"maxItems":16,"items":{"oneOf":[{"$ref":"#/$defs/focusAnchor"},{"$ref":"#/$defs/axisRelation"},{"$ref":"#/$defs/rotationAlignment"},{"$ref":"#/$defs/blockAlignment"},{"$ref":"#/$defs/spacingRhythm"}]}}}},"directedPlan":{"type":"object","additionalProperties":false,"required":["version","kind","sourceFingerprint","rationale","operations","decision","objective","assessment","preserve","tradeoffs","fixedIds","focusLinks"],"properties":{"version":{"const":2},"kind":{"const":"composition-refinement-plan"},"sourceFingerprint":{"type":"string","pattern":"^draft-[0-9a-f]{8}$"},"rationale":{"type":"string","minLength":1,"maxLength":2000},"operations":{"type":"array","minItems":0,"maxItems":16,"items":{"allOf":[{"oneOf":[{"$ref":"#/$defs/focusAnchor"},{"$ref":"#/$defs/axisRelation"},{"$ref":"#/$defs/rotationAlignment"},{"$ref":"#/$defs/blockAlignment"},{"$ref":"#/$defs/spacingRhythm"},{"$ref":"#/$defs/framePlacement"},{"$ref":"#/$defs/sizeRatio"},{"$ref":"#/$defs/mirrorSymmetry"},{"$ref":"#/$defs/focusFlow"}]},{"type":"object","required":["reason","expectedEffect"]}]}},"decision":{"enum":["refine","retain"]},"objective":{"type":"string","minLength":1,"maxLength":2000},"assessment":{"type":"object","additionalProperties":false,"required":["intent","observations","uncertainties"],"properties":{"intent":{"type":"string","minLength":1,"maxLength":2000},"observations":{"type":"array","minItems":0,"maxItems":32,"items":{"type":"string","minLength":1,"maxLength":2000}},"uncertainties":{"type":"array","minItems":0,"maxItems":32,"items":{"type":"string","minLength":1,"maxLength":2000}}}},"preserve":{"type":"array","minItems":0,"maxItems":32,"items":{"type":"string","minLength":1,"maxLength":2000}},"tradeoffs":{"type":"array","minItems":0,"maxItems":32,"items":{"type":"string","minLength":1,"maxLength":2000}},"fixedIds":{"type":"array","minItems":0,"maxItems":32,"items":{"type":"string","pattern":"^(direction-1|(area|focus)-[0-9]+)$"},"uniqueItems":true},"focusLinks":{"type":"array","minItems":0,"maxItems":32,"items":{"type":"object","additionalProperties":false,"required":["focusId","areaId"],"properties":{"focusId":{"type":"string","pattern":"^focus-[0-9]+$"},"areaId":{"type":"string","pattern":"^area-[0-9]+$"}}}}},"allOf":[{"if":{"properties":{"decision":{"const":"retain"}}},"then":{"properties":{"operations":{"maxItems":0,"type":"array"}}},"else":{"properties":{"operations":{"minItems":1,"type":"array"}}}}]}}}');Object.freeze({"optical-center":{x:.5,y:.55},"geometric-center":{x:.5,y:.5},"golden-right-upper":{x:.61803398875,y:.38196601125},"golden-left-upper":{x:.38196601125,y:.38196601125},"golden-right-lower":{x:.61803398875,y:.61803398875},"golden-left-lower":{x:.38196601125,y:.61803398875},"third-right-upper":{x:2/3,y:1/3},"third-left-upper":{x:1/3,y:1/3},"third-right-lower":{x:2/3,y:2/3},"third-left-lower":{x:1/3,y:2/3}}),[...[{id:"frame-placement",description:"Place a subject center, edge, or focus on an Agent-selected frame division."},{id:"size-ratio",description:"Set an explicit physical length or area ratio between selected measurements."},{id:"mirror-symmetry",description:"Mirror a target area across a named frame axis, matching position or geometry."},{id:"focus-flow",description:"Aim an existing direction line or a subject's local axis at a selected focus."}].map(e=>({...e,id:e.id,version:1,decisionOwner:"agent",processingSemantics:["scene-composition","editorial-layout"]}))],new _.Ajv2020({allErrors:!0}).compile(T);var R=i(59793)},4549:()=>{},12190:()=>{},12399:(e,t,i)=>{"use strict";i.d(t,{Oe:()=>y,Pw:()=>p,b5:()=>c,bl:()=>u,i1:()=>d,j4:()=>m,ms:()=>f,p:()=>g,pT:()=>h,uO:()=>function e(t,i,a,o=!0){let s=structuredClone(t),l=s.joints.find(e=>e.id===i);if(!l)throw Error("SPATIAL_INVALID: unknown joint");let u=s.bones.find(e=>e.endJointId===i),h=!!(u&&(0,r.dS)(u.modelPart)),y=Object.fromEntries(s.joints.map(e=>{let t=s.bones.find(t=>t.endJointId===e.id);return[e.id,{offset:g(s,e),basis:t?(0,r.IA)(s,t):new n.PTz}]})),x=f(t);if(a.position&&l.lockPosition||a.rotation&&u&&(u.lockRotation||m(u)))return{character:t,constrained:!0};let b=[...t.joints.filter(e=>e.lockPosition).map(e=>({id:e.id,weight:100,position:x[e.id].position})),...t.bones.filter(e=>e.lockRotation).map(e=>({id:e.endJointId,weight:100,rotation:x[e.endJointId].rotation}))],v={id:i,weight:1,...a.position?{position:d(a.position)}:{},...a.rotation?{rotation:c(a.rotation)}:{}};if(v.rotation&&u){let e=p(s,u,(l.parentId?x[l.parentId].rotation:c(t.rotation)).clone().invert().multiply(v.rotation));if(e.every((e,t)=>e>=u.limits.min[t]&&e<=u.limits.max[t])){u.rotation=e;let n=f(s,y);if(b.every(e=>(!e.position||1e-5>e.position.distanceTo(n[e.id].position))&&(!e.rotation||1e-5>e.rotation.angleTo(n[e.id].rotation))))return{character:s,constrained:!1};u.rotation=[...t.bones.find(e=>e.endJointId===i).rotation]}}let w=new Set,j=i;for(;j&&(w.add(j),!(j=s.joints.find(e=>e.id===j).parentId)||!(s.joints.filter(e=>e.parentId===j).length>1)););let k=new Set([i]);for(let e of k)for(let t of s.joints.filter(t=>t.parentId===e))k.add(t.id);let I=[];for(let e of s.bones)if(!(e.lockRotation||m(e))&&(v.rotation?k.has(e.endJointId):!o||w.has(e.endJointId)))for(let t of[0,1,2])e.limits.max[t]-e.limits.min[t]<1e-4||I.push({get:()=>e.rotation[t],set:i=>{e.rotation[t]=Math.max(e.limits.min[t],Math.min(e.limits.max[t],i))},step:.05});if(!l.parentId)for(let e of[0,1,2])I.push({get:()=>s.position[e],set:t=>{s.position[e]=t},step:.001});let S=e=>{let t=new Set(s.bones.filter(e=>e.lockRotation&&!m(e)).map(e=>e.id)),i=e=>{let n=s.bones.find(t=>t.id===e),a=s.bones.find(e=>e.endJointId===n.startJointId);a&&t.has(a.id)&&i(a.id);let r=f(s,y)[n.startJointId].rotation;n.rotation=p(s,n,r.clone().invert().multiply(x[n.endJointId].rotation)).map((e,t)=>Math.max(n.limits.min[t],Math.min(n.limits.max[t],e))),t.delete(e)};for(let e of t)i(e);let n=f(s,y),a=[];for(let t of e)if(t.position&&a.push(...t.position.clone().sub(n[t.id].position).multiplyScalar(t.weight).toArray()),t.rotation){let e=t.rotation.clone().multiply(n[t.id].rotation.clone().invert()).normalize(),i=e.w<0?-1:1;a.push(2*e.x*i*t.weight,2*e.y*i*t.weight,2*e.z*i*t.weight)}return a},P=e=>e.reduce((e,t)=>e+t*t,0),C=(e,t)=>{for(let i=0;i<t;i++){let t=S(e),i=P(t);if(i<1e-12)break;let n=I.map(e=>e.get()),a=I.map((i,a)=>{i.set(n[a]+i.step);let r=i.get()-n[a];1e-10>Math.abs(r)&&(i.set(n[a]-i.step),r=i.get()-n[a]);let o=S(e);return i.set(n[a]),o.map((e,i)=>0===r?0:(t[i]-e)/r)}),r=function(e,t){let i=e.map((e,i)=>[...e,t[i]]),n=i.length;for(let e=0;e<n;e++){let t=e;for(let a=e+1;a<n;a++)Math.abs(i[a][e])>Math.abs(i[t][e])&&(t=a);[i[t],i[e]]=[i[e],i[t]];let a=i[e][e];if(!(1e-14>Math.abs(a))){for(let t=e;t<=n;t++)i[e][t]/=a;for(let t=0;t<n;t++){if(t===e)continue;let a=i[t][e];for(let r=e;r<=n;r++)i[t][r]-=a*i[e][r]}}}return i.map(e=>e[n])}(t.map((e,i)=>t.map((e,t)=>a.reduce((e,n)=>e+n[i]*n[t],0)+(i===t?h?1e-7*(s.height/1.8)**2:1e-5:0))),t),o=a.map(e=>e.reduce((e,t,i)=>e+t*r[i],0)),l=!1;for(let t of[1,.5,.2,.05])if(I.forEach((e,i)=>e.set(n[i]+Math.max(-15,Math.min(15,o[i]))*t)),P(S(e))<i-1e-14){l=!0;break}if(!l){I.forEach((e,t)=>e.set(n[t]));break}}};C([...b,v],65),b.length&&C(b,25),S(b);let M=f(s,y);if(!b.every(e=>(!e.position||1e-5>e.position.distanceTo(M[e.id].position))&&(!e.rotation||1e-5>e.rotation.angleTo(M[e.id].rotation))))return o&&!h?e(t,i,a,!1):{character:t,constrained:!0};let A=!!v.position&&v.position.distanceTo(M[i].position)>(h?5e-4*s.height:.005)||!!v.rotation&&v.rotation.angleTo(M[i].rotation)>.005;if(A&&o&&!h){let n=e(t,i,a,!1),r=e=>{let t=f(e)[i];return(v.position?.distanceTo(t.position)??0)+(v.rotation?.angleTo(t.rotation)??0)};if(r(n.character)<r(s))return n}return{character:s,constrained:A}}});var n=i(84910),a=i(54996),r=i(29169),o=i(2872),s=i(79283);let l=Math.PI/180,d=e=>new n.Pq0(...e),c=e=>new n.PTz().setFromEuler(new n.O9p(...e.map(e=>e*l),"XYZ")),u=e=>{let t=new n.O9p().setFromQuaternion(e,"XYZ");return[t.x/l,t.y/l,t.z/l]},m=e=>/^(left|right)-(shoulder|hip)$/.test(e.modelPart);function h(e,t,i=t.rotation){let n=(0,r.IA)(e,t);return n.clone().multiply(c(i)).multiply(n.invert())}function p(e,t,i){let n=(0,r.IA)(e,t);return u(n.clone().invert().multiply(i).multiply(n))}function g(e,t){let i=d(t.offset),n=e.bones.find(e=>e.endJointId===t.id)?.modelPart;if(n&&(0,r.dS)(n)){let i=e.bones.find(e=>e.endJointId===t.id),n=(0,r.oT)(e,i);if(n)return(0,r.xT)(e,t,n)}let l=(0,a.G_)(e.headRatio);if(n&&(["spine","chest","neck"].includes(n)||/-(shoulder|hip)$/.test(n))){let t=6*(0,a.UB)(l,n)*e.headRatio/(7*(e.headRatio-1));i.x*=t;let r=6*l.torsoDepth*e.headRatio/(7*(e.headRatio-1));i.z*=1+(r-1)*(1-l.softness)}let c=e.neckLength??1;if("neck"===n&&i.multiplyScalar(l.neck*c),"spine"===n||"chest"===n){let t=e.joints.find(e=>"neck"===e.id);t&&(i.y+=t.offset[1]*(1-l.neck)/2,i.z+=t.offset[2]*(1-l.neck)*l.torsoDepth*6*e.headRatio/(7*(e.headRatio-1))/2*(1-l.softness))}n&&/-(elbow|wrist)$/.test(n)&&i.multiplyScalar(l.armLength),n?.endsWith("-hand")&&i.multiplyScalar(l.handLength*(e.palmSize??1));let u=(0,a.kF)(e.footSize);if(n?.endsWith("-ankle")&&1!==u){let n=e.bones.find(e=>e.startJointId===t.id&&e.modelPart.endsWith("-foot"));if(n){let t="female"===e.bodyType?s:o,a=t.parts.find(e=>e.id===n.modelPart),r=d(e.joints.find(e=>e.id===n.endJointId).offset).length()/d(a.end).sub(d(a.start)).length();i.y+=(a.start[1]-t.bottom)*r*(u-1)}}return n?.endsWith("-foot")&&(i.x*=e.footSize??1,i.y*=u,i.z*=l.footLength*(e.footSize??1)),i}function f(e,t){let i=Object.create(null),a=new Map(e.joints.map(e=>[e.id,e])),r=new Map(e.bones.map(e=>[e.endJointId,e])),o=new Set,s=l=>{if(i[l])return i[l];if(o.has(l))throw Error("SPATIAL_INVALID: cyclic skeleton");o.add(l);let u=a.get(l);if(!u)throw Error("SPATIAL_INVALID: missing parent joint");let m=u.parentId?s(u.parentId):{position:d(e.position),rotation:c(e.rotation)},p=r.get(l),f=t?.[l].basis,y=p?f?f.clone().multiply(c(p.rotation)).multiply(f.clone().invert()):h(e,p):new n.PTz,x=m.rotation.clone().multiply(y).normalize(),b=(t?.[l].offset.clone()??g(e,u)).applyQuaternion(x).add(m.position);return o.delete(l),i[l]={position:b,rotation:x}};return e.joints.forEach(e=>s(e.id)),i}function y(e){let t=f(e);return Object.fromEntries(e.bones.map(e=>[e.id,{position:t[e.startJointId].position.clone(),rotation:t[e.endJointId].rotation.clone()}]))}},12853:()=>{},14956:(e,t,i)=>{"use strict";i.d(t,{u:()=>a});var n=i(22146);function a(e,t){let i=Math.min(3,t.length),a=Math.ceil(t.length/i);return{columns:i,rows:a,width:i*e+(i-1)*n.eJ,height:a*(e+n.Sn)+(a-1)*n.eJ,tiles:t.map((t,a)=>({face:t,left:a%i*(e+n.eJ),top:Math.floor(a/i)*(e+n.Sn+n.eJ)}))}}},15682:()=>{},16803:()=>{},17346:()=>{},19204:(e,t,i)=>{"use strict";function n(e){let t=JSON.stringify(function e(t){return Array.isArray(t)?t.map(e):t&&"object"==typeof t?Object.fromEntries(Object.entries(t).filter(([,e])=>void 0!==e).sort(([e],[t])=>e<t?-1:+(e>t)).map(([t,i])=>[t,e(i)])):t}(e));if(void 0===t)throw Error("Cannot fingerprint an undefined document.");return t}function a(e){let t=0x811c9dc5;for(let i=0;i<e.length;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,0x1000193);return`draft-${(t>>>0).toString(16).padStart(8,"0")}`}i.d(t,{U:()=>a,d:()=>n})},19767:(e,t,i)=>{"use strict";i.d(t,{$n:()=>s,Ab:()=>o,Dj:()=>l,MR:()=>c,PK:()=>p,QR:()=>r,Sq:()=>h,Wu:()=>d,xz:()=>u,zS:()=>m});var n=i(3500);let a={square:1,landscape:1.6,portrait:.625};function r(e,t){let i=t.width*t.height,n=e.area*i;if("circle"===e.primitive)return"free"===e.aspect&&e.width&&e.height?{type:"ellipse",cx:e.x*t.width,cy:e.y*t.height,radiusX:e.width*t.width/2,radiusY:e.height*t.height/2}:{type:"circle",cx:e.x*t.width,cy:e.y*t.height,radius:Math.sqrt(n/Math.PI)};let r={x:e.x*t.width,y:e.y*t.height};if("quadrilateral"===e.primitive){let i="free"===e.aspect?void 0:a[e.aspect],o="free"===e.aspect?e.width*t.width:Math.sqrt(n*i),s="free"===e.aspect?e.height*t.height:n/o;return{type:"polygon",points:(e.corners?e.corners.map(e=>({x:r.x+(e.x-.5)*o,y:r.y+(e.y-.5)*s})):[{x:r.x-o/2,y:r.y-s/2},{x:r.x+o/2,y:r.y-s/2},{x:r.x+o/2,y:r.y+s/2},{x:r.x-o/2,y:r.y+s/2}]).map(t=>g(t,r,e.rotation??0)),center:r,width:o,height:s}}let o="free"===e.aspect&&e.width&&e.height,s=o?e.width*t.width:Math.sqrt(4*n/Math.sqrt(3)),l=o?e.height*t.height:Math.sqrt(3)/2*s;return{type:"polygon",points:[{x:r.x,y:r.y-2*l/3},{x:r.x-s/2,y:r.y+l/3},{x:r.x+s/2,y:r.y+l/3}].map(t=>g(t,r,e.rotation??0)),center:r,side:s,height:l}}function o(e){return Math.abs(e.reduce((t,i,n)=>{let a=e[(n+1)%e.length];return t+i.x*a.y-a.x*i.y},0))/2}function s(e){return 4===e.length&&e.every((t,i)=>{let n=e[(i+1)%4],a=e[(i+2)%4];return(n.x-t.x)*(a.y-n.y)-(n.y-t.y)*(a.x-n.x)>1e-8})}function l(e,t){let i=r({...e,x:0,y:0,rotation:0},t);if("polygon"!==i.type)return[];let n={x:e.x*t.width,y:e.y*t.height};return[-.18,0,.18].map(t=>{let a=t*i.height,r=i.points.flatMap((e,t)=>{let n=i.points[(t+1)%i.points.length];return a<Math.min(e.y,n.y)||a>=Math.max(e.y,n.y)?[]:[e.x+(n.x-e.x)*(a-e.y)/(n.y-e.y)]}),o=Math.min(...r),s=Math.max(...r);return[.14,.86].map(t=>g({x:n.x+o+(s-o)*t,y:n.y+a},n,e.rotation??0))})}function d(e,t){let i={x:e.x*t.width,y:e.y*t.height},n=1.1*Math.hypot(t.width,t.height);return{type:"line",center:i,start:f(i,e.rotation+180,n),end:f(i,e.rotation,n)}}function c(e){var t;let i,a;return i=Math.min(...(t=[(0,n.i)(e.frame),...e.areas.map(e=>{let t;return{x:(t=h(r(e,n.cq))).minimumX,y:t.minimumY,width:t.maximumX-t.minimumX,height:t.maximumY-t.minimumY}}),...e.images.map(u),...e.focusPoints.map(e=>({x:e.x*n.cq.width-20,y:e.y*n.cq.height-20,width:40,height:40})),...e.directionLine?[{x:e.directionLine.x*n.cq.width,y:e.directionLine.y*n.cq.height,width:0,height:0}]:[]]).map(e=>e.x)),{x:i,y:a=Math.min(...t.map(e=>e.y)),width:Math.max(...t.map(e=>e.x+e.width))-i,height:Math.max(...t.map(e=>e.y+e.height))-a}}function u(e){let t={x:e.x*n.cq.width,y:e.y*n.cq.height},i=e.width*n.cq.width/2,a=e.height*n.cq.height/2,r=[{x:t.x-i,y:t.y-a},{x:t.x+i,y:t.y-a},{x:t.x+i,y:t.y+a},{x:t.x-i,y:t.y+a}].map(i=>g(i,t,e.rotation)),o=Math.min(...r.map(e=>e.x)),s=Math.max(...r.map(e=>e.x)),l=Math.min(...r.map(e=>e.y));return{x:o,y:l,width:s-o,height:Math.max(...r.map(e=>e.y))-l}}function m(e){let t=e.areas.map(e=>r(e,n.cq)),i=(0,n.i)(e.frame),a=t.map(()=>0),o=0,s=0,l=0;for(let e=0;e<120;e+=1)for(let n=0;n<180;n+=1){let r={x:i.x+(n+.5)/180*i.width,y:i.y+(e+.5)/120*i.height},d=!1;t.forEach((e,t)=>{(function(e,t){if("circle"===e.type)return Math.hypot(t.x-e.cx,t.y-e.cy)<=e.radius;if("ellipse"===e.type){let i=(t.x-e.cx)/e.radiusX,n=(t.y-e.cy)/e.radiusY;return i*i+n*n<=1}let i=!1;for(let n=0,a=e.points.length-1;n<e.points.length;a=n++){let r=e.points[n],o=e.points[a];r.y>t.y!=o.y>t.y&&t.x<(o.x-r.x)*(t.y-r.y)/(o.y-r.y)+r.x&&(i=!i)}return i})(e,r)&&(a[t]+=1,d=!0)}),d&&(o+=1,s+=(n+.5)/180,l+=(e+.5)/120)}let d=i.width*i.height,c=n.cq.width*n.cq.height,u=e.areas.reduce((e,t)=>e+t.area*c/d,0),m=a.map(e=>e/21600),h=m.reduce((e,t)=>e+t,0),p=o/21600;return{theoreticalArea:u,visibleAreaShares:m,occupiedArea:p,negativeSpace:1-p,clippedArea:Math.max(0,u-h),overlapArea:Math.max(0,h-p),visualCenter:o?{x:s/o,y:l/o}:{x:.5,y:.5}}}function h(e){return"circle"===e.type?{minimumX:e.cx-e.radius,maximumX:e.cx+e.radius,minimumY:e.cy-e.radius,maximumY:e.cy+e.radius}:"ellipse"===e.type?{minimumX:e.cx-e.radiusX,maximumX:e.cx+e.radiusX,minimumY:e.cy-e.radiusY,maximumY:e.cy+e.radiusY}:{minimumX:Math.min(...e.points.map(e=>e.x)),maximumX:Math.max(...e.points.map(e=>e.x)),minimumY:Math.min(...e.points.map(e=>e.y)),maximumY:Math.max(...e.points.map(e=>e.y))}}function p(e,t,i=1.6,n="quadrilateral"){let a=e*t.width*t.height,r="circle"===n?Math.PI/4:"triangle"===n?.5:1,o=Math.sqrt(a*i/r);return{width:o/t.width,height:a/r/o/t.height}}function g(e,t,i){let n=i*Math.PI/180,a=Math.cos(n),r=Math.sin(n),o=e.x-t.x,s=e.y-t.y;return{x:t.x+o*a-s*r,y:t.y+o*r+s*a}}function f(e,t,i){let n=t*Math.PI/180;return{x:e.x+Math.cos(n)*i,y:e.y+Math.sin(n)*i}}},20701:()=>{},21071:(e,t,i)=>{"use strict";i.d(t,{aY:()=>u.aY,s4:()=>k,em:()=>c.em,EG:()=>d.EG,mw:()=>c.mw,_1:()=>I,VO:()=>w,bl:()=>l.bl,bK:()=>L,Pw:()=>l.Pw,Oe:()=>l.Oe,D5:()=>f,oH:()=>S,zP:()=>g,wY:()=>P,IA:()=>d.IA,oq:()=>d.oq,dS:()=>d.dS,ov:()=>y,Au:()=>d.Au,j4:()=>l.j4,ms:()=>l.ms,oT:()=>d.oT,b5:()=>l.b5,wU:()=>A,cj:()=>M,i1:()=>l.i1});var n=i(27062),a=i(2872),r=i(79283);let o=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://yisi.local/schemas/spatial-draft.schema.json","type":"object","additionalProperties":false,"required":["version","kind","characters","objects","cameras"],"properties":{"version":{"const":2},"kind":{"const":"spatial-draft"},"lightingEnabled":{"type":"boolean"},"characters":{"type":"array","maxItems":24,"items":{"type":"object","additionalProperties":false,"required":["id","name","kind","position","rotation","height","headRatio","color","joints","bones","appearance"],"properties":{"id":{"type":"string","minLength":1,"maxLength":100},"name":{"type":"string","minLength":1,"maxLength":200},"kind":{"enum":["humanoid","custom"]},"position":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"rotation":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"height":{"type":"number","minimum":0.2,"maximum":20},"headRatio":{"type":"number","minimum":2,"maximum":12},"thumbLimitsVersion":{"const":2},"color":{"type":"string","pattern":"^#[0-9a-fA-F]{6}$"},"joints":{"type":"array","minItems":1,"maxItems":200,"items":{"type":"object","additionalProperties":false,"required":["id","name","parentId","offset","lockPosition","radius","terminal"],"properties":{"id":{"type":"string","minLength":1,"maxLength":100},"name":{"type":"string","minLength":1,"maxLength":200},"parentId":{"anyOf":[{"type":"string","minLength":1,"maxLength":100},{"type":"null"}]},"offset":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"lockPosition":{"type":"boolean"},"radius":{"type":"number","exclusiveMinimum":0,"maximum":10},"terminal":{"type":"boolean"}}}},"bones":{"type":"array","maxItems":199,"items":{"type":"object","additionalProperties":false,"required":["id","name","startJointId","endJointId","rotation","restRotation","limits","lockRotation","modelPart"],"properties":{"id":{"type":"string","minLength":1,"maxLength":100},"name":{"type":"string","minLength":1,"maxLength":200},"startJointId":{"type":"string","minLength":1,"maxLength":100},"endJointId":{"type":"string","minLength":1,"maxLength":100},"rotation":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"restRotation":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"limits":{"type":"object","additionalProperties":false,"required":["min","max"],"properties":{"min":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"max":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}}}},"lockRotation":{"type":"boolean"},"modelPart":{"type":"string","minLength":1,"maxLength":100}}}},"appearance":{"enum":["quaternius","geometric"]},"torsoRatio":{"type":"number","minimum":0.3,"maximum":0.7},"bodyType":{"enum":["male","female"]},"neckLength":{"type":"number","minimum":0.6,"maximum":1.4},"palmSize":{"type":"number","minimum":0.7,"maximum":1.3},"fingerLength":{"type":"number","minimum":0.6,"maximum":1.4},"footSize":{"type":"number","minimum":0.7,"maximum":1.4},"note":{"type":"string"}}}},"objects":{"type":"array","maxItems":100,"items":{"type":"object","additionalProperties":false,"required":["id","name","kind","position","rotation","size","color"],"properties":{"id":{"type":"string","minLength":1,"maxLength":100},"name":{"type":"string","minLength":1,"maxLength":200},"kind":{"enum":["box","sphere","plane"]},"position":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"rotation":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"size":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"color":{"type":"string","pattern":"^#[0-9a-fA-F]{6}$"},"note":{"type":"string"}}}},"cameras":{"type":"array","minItems":1,"maxItems":24,"items":{"type":"object","additionalProperties":false,"required":["id","name","position","target","projection","fov","span","width","height","background"],"properties":{"id":{"type":"string","minLength":1,"maxLength":100},"name":{"type":"string","minLength":1,"maxLength":200},"position":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"target":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"projection":{"enum":["perspective","orthographic"]},"fov":{"type":"number","minimum":10,"maximum":120},"span":{"type":"number","minimum":0.1,"maximum":1000},"width":{"type":"integer","minimum":128,"maximum":2048},"height":{"type":"integer","minimum":128,"maximum":2048},"background":{"anyOf":[{"type":"string","pattern":"^#[0-9a-fA-F]{6}$"},{"type":"null"}]},"note":{"type":"string"}}}},"cameraBoxes":{"type":"array","maxItems":24,"items":{"type":"object","additionalProperties":false,"required":["id","name","position","rotation","size","resolution"],"properties":{"id":{"type":"string","minLength":1,"maxLength":100},"name":{"type":"string","minLength":1,"maxLength":200},"position":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"rotation":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"size":{"type":"number","minimum":0.05,"maximum":1000},"resolution":{"type":"integer","minimum":128,"maximum":1024},"note":{"type":"string"}}}}}}');var s=i(19204),l=i(12399),d=i(29169),c=i(22146),u=i(54996),m=i(84910),h=i(28179),p=i(14956);function g(e,t){return{id:e,name:t,position:[0,.9,0],rotation:[0,0,0],size:2.4,resolution:512}}function f(e,t){if("string"==typeof t&&"sheet"!==t)return{width:e.resolution,height:e.resolution};let{width:i,height:n}=(0,p.u)(e.resolution,"string"==typeof t?c.em:t);return{width:i,height:n}}function y(e,t,i){let n=(0,h.bh)(t),a=new m.NRn,r=(0,l.b5)(e.rotation).invert(),o=new m.Pq0;try{n.traverse(e=>{if(!(e instanceof m.eaF))return;let t=String(e.userData.modelPart??"");if("hands"===i&&!t.endsWith("-hand")&&!(0,d.dS)(t))return;let n=e.geometry.getAttribute("position");for(let t=0;t<n.count;t++)a.expandByPoint(o.fromBufferAttribute(n,t).applyMatrix4(e.matrixWorld).applyQuaternion(r))})}finally{(0,h.en)(n)}if(a.isEmpty())return e;let s=a.getSize(new m.Pq0);return{...e,position:a.getCenter(new m.Pq0).applyQuaternion((0,l.b5)(e.rotation)).toArray(),size:Math.max(.05,1.15*Math.max(s.x,s.y,s.z))}}let x=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://yisi.local/schemas/spatial-operations.schema.json","type":"array","maxItems":100,"items":{"oneOf":[{"type":"object","additionalProperties":false,"required":["type","enabled"],"properties":{"type":{"const":"set-lighting"},"enabled":{"type":"boolean"}}},{"type":"object","additionalProperties":false,"required":["type","id","name"],"properties":{"type":{"const":"add-character"},"id":{"type":"string","minLength":1,"maxLength":100},"name":{"type":"string","minLength":1,"maxLength":200},"height":{"type":"number","minimum":0.2,"maximum":20},"headRatio":{"type":"number","minimum":2,"maximum":12},"torsoRatio":{"type":"number","minimum":0.3,"maximum":0.7},"bodyType":{"enum":["male","female"]},"neckLength":{"type":"number","minimum":0.6,"maximum":1.4},"palmSize":{"type":"number","minimum":0.7,"maximum":1.3},"fingerLength":{"type":"number","minimum":0.6,"maximum":1.4},"footSize":{"type":"number","minimum":0.7,"maximum":1.4},"appearance":{"enum":["quaternius","geometric"]}}},{"type":"object","additionalProperties":false,"required":["type","character"],"properties":{"type":{"const":"put-character"},"character":{"type":"object","additionalProperties":false,"required":["id","name","kind","position","rotation","height","headRatio","color","joints","bones","appearance"],"properties":{"id":{"type":"string","minLength":1,"maxLength":100},"name":{"type":"string","minLength":1,"maxLength":200},"kind":{"enum":["humanoid","custom"]},"position":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"rotation":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"height":{"type":"number","minimum":0.2,"maximum":20},"headRatio":{"type":"number","minimum":2,"maximum":12},"thumbLimitsVersion":{"const":2},"color":{"type":"string","pattern":"^#[0-9a-fA-F]{6}$"},"joints":{"type":"array","minItems":1,"maxItems":200,"items":{"type":"object","additionalProperties":false,"required":["id","name","parentId","offset","lockPosition","radius","terminal"],"properties":{"id":{"type":"string","minLength":1,"maxLength":100},"name":{"type":"string","minLength":1,"maxLength":200},"parentId":{"anyOf":[{"type":"string","minLength":1,"maxLength":100},{"type":"null"}]},"offset":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"lockPosition":{"type":"boolean"},"radius":{"type":"number","exclusiveMinimum":0,"maximum":10},"terminal":{"type":"boolean"}}}},"bones":{"type":"array","maxItems":199,"items":{"type":"object","additionalProperties":false,"required":["id","name","startJointId","endJointId","rotation","restRotation","limits","lockRotation","modelPart"],"properties":{"id":{"type":"string","minLength":1,"maxLength":100},"name":{"type":"string","minLength":1,"maxLength":200},"startJointId":{"type":"string","minLength":1,"maxLength":100},"endJointId":{"type":"string","minLength":1,"maxLength":100},"rotation":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"restRotation":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"limits":{"type":"object","additionalProperties":false,"required":["min","max"],"properties":{"min":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"max":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}}}},"lockRotation":{"type":"boolean"},"modelPart":{"type":"string","minLength":1,"maxLength":100}}}},"appearance":{"enum":["quaternius","geometric"]},"torsoRatio":{"type":"number","minimum":0.3,"maximum":0.7},"bodyType":{"enum":["male","female"]},"neckLength":{"type":"number","minimum":0.6,"maximum":1.4},"palmSize":{"type":"number","minimum":0.7,"maximum":1.3},"fingerLength":{"type":"number","minimum":0.6,"maximum":1.4},"footSize":{"type":"number","minimum":0.7,"maximum":1.4},"note":{"type":"string"}}}}},{"type":"object","additionalProperties":false,"required":["type","characterId","sourceJointId","parentId","idPrefix","offset"],"properties":{"type":{"const":"add-limb"},"characterId":{"type":"string","minLength":1,"maxLength":100},"sourceJointId":{"type":"string","minLength":1,"maxLength":100},"parentId":{"type":"string","minLength":1,"maxLength":100},"idPrefix":{"type":"string","minLength":1,"maxLength":100},"offset":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}}}},{"type":"object","additionalProperties":false,"required":["type","characterId","height","headRatio"],"properties":{"type":{"const":"set-proportions"},"characterId":{"type":"string","minLength":1,"maxLength":100},"height":{"type":"number","minimum":0.2,"maximum":20},"headRatio":{"type":"number","minimum":2,"maximum":12},"torsoRatio":{"type":"number","minimum":0.3,"maximum":0.7},"bodyType":{"enum":["male","female"]},"neckLength":{"type":"number","minimum":0.6,"maximum":1.4},"palmSize":{"type":"number","minimum":0.7,"maximum":1.3},"fingerLength":{"type":"number","minimum":0.6,"maximum":1.4},"footSize":{"type":"number","minimum":0.7,"maximum":1.4}}},{"type":"object","additionalProperties":false,"required":["type","characterId","jointId","position"],"properties":{"type":{"const":"move-joint"},"characterId":{"type":"string","minLength":1,"maxLength":100},"jointId":{"type":"string","minLength":1,"maxLength":100},"position":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}}}},{"type":"object","additionalProperties":false,"required":["type","characterId","jointId","position"],"properties":{"type":{"const":"lock-joint"},"characterId":{"type":"string","minLength":1,"maxLength":100},"jointId":{"type":"string","minLength":1,"maxLength":100},"position":{"type":"boolean"}}},{"type":"object","additionalProperties":false,"required":["type","object"],"properties":{"type":{"const":"put-object"},"object":{"type":"object","additionalProperties":false,"required":["id","name","kind","position","rotation","size","color"],"properties":{"id":{"type":"string","minLength":1,"maxLength":100},"name":{"type":"string","minLength":1,"maxLength":200},"kind":{"enum":["box","sphere","plane"]},"position":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"rotation":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"size":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"color":{"type":"string","pattern":"^#[0-9a-fA-F]{6}$"},"note":{"type":"string"}}}}},{"type":"object","additionalProperties":false,"required":["type","camera"],"properties":{"type":{"const":"put-camera"},"camera":{"type":"object","additionalProperties":false,"required":["id","name","position","target","projection","fov","span","width","height","background"],"properties":{"id":{"type":"string","minLength":1,"maxLength":100},"name":{"type":"string","minLength":1,"maxLength":200},"position":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"target":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"projection":{"enum":["perspective","orthographic"]},"fov":{"type":"number","minimum":10,"maximum":120},"span":{"type":"number","minimum":0.1,"maximum":1000},"width":{"type":"integer","minimum":128,"maximum":2048},"height":{"type":"integer","minimum":128,"maximum":2048},"background":{"anyOf":[{"type":"string","pattern":"^#[0-9a-fA-F]{6}$"},{"type":"null"}]},"note":{"type":"string"}}}}},{"type":"object","additionalProperties":false,"required":["type","id"],"properties":{"type":{"const":"remove"},"id":{"type":"string","minLength":1,"maxLength":100}}},{"type":"object","additionalProperties":false,"required":["type","characterId","boneId","rotation"],"properties":{"type":{"const":"rotate-bone"},"characterId":{"type":"string","minLength":1,"maxLength":100},"boneId":{"type":"string","minLength":1,"maxLength":100},"rotation":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}}}},{"type":"object","additionalProperties":false,"required":["type","characterId","boneId","rotation"],"properties":{"type":{"const":"lock-bone"},"characterId":{"type":"string","minLength":1,"maxLength":100},"boneId":{"type":"string","minLength":1,"maxLength":100},"rotation":{"type":"boolean"}}},{"type":"object","additionalProperties":false,"required":["type","characterId","boneId","limits"],"properties":{"type":{"const":"set-bone-limits"},"characterId":{"type":"string","minLength":1,"maxLength":100},"boneId":{"type":"string","minLength":1,"maxLength":100},"limits":{"type":"object","additionalProperties":false,"required":["min","max"],"properties":{"min":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"max":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}}}}}},{"type":"object","additionalProperties":false,"required":["type","characterId"],"properties":{"type":{"const":"reset-pose"},"characterId":{"type":"string","minLength":1,"maxLength":100}}},{"type":"object","additionalProperties":false,"required":["type","characterId","handBoneId"],"properties":{"type":{"const":"pose-hand"},"characterId":{"type":"string","minLength":1,"maxLength":100},"handBoneId":{"type":"string","minLength":1,"maxLength":100},"curl":{"type":"object","additionalProperties":false,"minProperties":1,"properties":{"thumb":{"type":"number","minimum":0,"maximum":1},"index":{"type":"number","minimum":0,"maximum":1},"middle":{"type":"number","minimum":0,"maximum":1},"ring":{"type":"number","minimum":0,"maximum":1},"little":{"type":"number","minimum":0,"maximum":1}}},"spread":{"type":"number","minimum":0,"maximum":1},"thumbOpposition":{"type":"number","minimum":0,"maximum":1}},"anyOf":[{"required":["curl"]},{"required":["spread"]},{"required":["thumbOpposition"]}]},{"type":"object","additionalProperties":false,"required":["type","characterId","handBoneId"],"properties":{"type":{"const":"reset-hand"},"characterId":{"type":"string","minLength":1,"maxLength":100},"handBoneId":{"type":"string","minLength":1,"maxLength":100}}},{"type":"object","additionalProperties":false,"required":["type","box"],"properties":{"type":{"const":"put-camera-box"},"box":{"type":"object","additionalProperties":false,"required":["id","name","position","rotation","size","resolution"],"properties":{"id":{"type":"string","minLength":1,"maxLength":100},"name":{"type":"string","minLength":1,"maxLength":200},"position":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"rotation":{"type":"array","minItems":3,"maxItems":3,"items":{"type":"number","minimum":-10000,"maximum":10000}},"size":{"type":"number","minimum":0.05,"maximum":1000},"resolution":{"type":"integer","minimum":128,"maximum":1024},"note":{"type":"string"}}}}},{"type":"object","additionalProperties":false,"required":["type","id","region"],"properties":{"type":{"const":"fit-camera-box"},"id":{"type":"string","minLength":1,"maxLength":100},"region":{"enum":["scene","hands"]}}}]}}'),b=new n.Ajv2020({allErrors:!0}).compile(x),v=new n.Ajv2020({allErrors:!0}).compile(o),w={min:.3,max:.7},j=e=>1-(e.parts[0].start[1]-e.bottom)/(e.parts.find(e=>"head"===e.id).start[1]-e.bottom),k=j(a);class I extends Error{constructor(...e){super(...e),this.code="SPATIAL_CONSTRAINT"}}function S(e="camera-1",t="Camera 1"){return{id:e,name:t,position:[3,2.2,5],target:[0,.9,0],projection:"perspective",fov:40,span:3.2,width:1200,height:900,background:null}}function P(){return{version:2,kind:"spatial-draft",lightingEnabled:!1,characters:[],objects:[],cameras:[S()]}}function C(e,t,i=1.8,n=7,o=k,s="male",c={}){let m="female"===s?r:a,h=j(m),p=i-i/n,g=[{id:"pelvis",name:"pelvis",parentId:null,offset:[0,0,0],radius:.027*i,lockPosition:!1,terminal:!1}],f=[],y=(e,t,n,a,r,o=!1)=>{g.push({id:e,name:e,parentId:t,offset:n,radius:.025*i,lockPosition:!1,terminal:o}),f.push({id:e,name:e,startJointId:t,endJointId:e,rotation:[0,0,0],restRotation:[0,0,0],limits:{min:a,max:r},lockRotation:!1,modelPart:e})};for(let[e,t]of(y("spine","pelvis",[0,.16*p,0],[-35,-35,-30],[45,35,30]),y("chest","spine",[0,.17*p,0],[-25,-40,-25],[25,40,25]),y("neck","chest",[0,.15*p,0],[-35,-45,-30],[35,45,30]),y("head","neck",[0,i/n,0],[-30,-45,-20],[30,45,20],!0),[["left",1],["right",-1]]))y(`${e}-shoulder`,"chest",[t*p*.14,0,0],[0,0,0],[0,0,0]),y(`${e}-elbow`,`${e}-shoulder`,[t*p*.07,-(.2*p),0],[-160,-90,-100],[160,90,100]),y(`${e}-wrist`,`${e}-elbow`,[t*p*.03,-(.2*p),0],[-150,-10,-10],[0,10,10]),y(`${e}-hand`,`${e}-wrist`,[t*p*.02,-(.09*p),0],[-70,-80,-30],[70,80,30]),y(`${e}-hip`,"pelvis",[t*p*.085,0,0],[0,0,0],[0,0,0]),y(`${e}-knee`,`${e}-hip`,[0,-(.25*p),0],[-120,-45,-45],[40,45,45]),y(`${e}-ankle`,`${e}-knee`,[0,-(.25*p),0],[0,-10,-10],[150,10,10]),y(`${e}-foot`,`${e}-ankle`,[0,-(.02*p),.09*p],[-35,-25,-20],[45,25,20],!0);let x=p/(m.parts.find(e=>"head"===e.id).start[1]-m.bottom);for(let e of g.filter(e=>e.parentId)){let t=m.parts.find(t=>t.id===e.id);if(e.offset=t.end.map((e,i)=>(e-t.start[i])*x),"head"===e.id&&(e.offset=[0,i/n,0]),/-(elbow|wrist|hand)$/.test(e.id)){let t=e.id.startsWith("left")?1:-1;e.offset=[t*(0,l.i1)(e.offset).length()*.342,-(.9397*(0,l.i1)(e.offset).length()),0]}}let b=(0,l.i1)(g.find(e=>"left-knee"===e.id).offset).add((0,l.i1)(g.find(e=>"left-ankle"===e.id).offset)),v=1+-(p*(h-o)/b.y),w=1+p*(o-h)/(g.find(e=>"spine"===e.id).offset[1]+g.find(e=>"chest"===e.id).offset[1]),I=(0,l.i1)([0,(m.parts[0].start[1]-m.bottom)*x,0]).addScaledVector(b,1-v);for(let e of g){let t=["spine","chest"].includes(e.id)?w:/-(knee|ankle)$/.test(e.id)?v:1;e.offset=e.offset.map(e=>e*t)}let S={id:e,name:t,kind:"humanoid",position:I.toArray(),rotation:[0,0,0],height:i,headRatio:n,torsoRatio:o,bodyType:s,thumbLimitsVersion:2,color:"#b2a090",joints:g,bones:f,appearance:c.appearance??"quaternius"};for(let e of Object.keys(u.aY))void 0!==c[e]&&(S[e]=c[e]);for(let e of[...f].filter(e=>e.modelPart.endsWith("-hand")))g.find(t=>t.id===e.endJointId).radius=.01*i,(0,d.jp)(S,e);return S}function M(e){if(!v(e))throw Error(`SPATIAL_INVALID: ${v.errors?.map(e=>`${e.instancePath} ${e.message}`).join("; ")}`);let t=structuredClone(e),i=[...t.characters,...t.objects,...t.cameras,...t.cameraBoxes??[]].map(e=>e.id);if(new Set(i).size!==i.length)throw Error("SPATIAL_INVALID: duplicate object id");for(let e of t.characters){if((0,d.Rq)(e),(0,d.cy)(e),new Set(e.joints.map(e=>e.id)).size!==e.joints.length||1!==e.joints.filter(e=>null===e.parentId).length)throw Error("SPATIAL_INVALID: skeleton must have unique joints and one root");let t=e.joints.filter(e=>e.parentId);if(e.bones.length!==t.length||new Set(e.bones.map(e=>e.id)).size!==e.bones.length||new Set(e.bones.map(e=>e.endJointId)).size!==t.length)throw Error("SPATIAL_INVALID: each non-root joint requires one unique incoming bone");for(let t of e.bones){let i=e.joints.find(e=>e.id===t.endJointId);if(!i||!i.parentId||i.parentId!==t.startJointId)throw Error("SPATIAL_INVALID: bone endpoints differ from joint hierarchy");for(let e of[0,1,2])if(t.limits.min[e]>t.limits.max[e]||[t.rotation[e],t.restRotation[e]].some(i=>i<t.limits.min[e]-1e-7||i>t.limits.max[e]+1e-7))throw new I(`Bone angle outside limits: ${t.id}`)}let i=(0,l.ms)(e);for(let t of e.joints){if(t.parentId&&1e-4>(0,l.i1)(t.offset).length())throw Error("SPATIAL_INVALID: zero bone length");if(!i[t.id].position.toArray().every(Number.isFinite))throw Error("SPATIAL_INVALID: non-finite transform")}if("humanoid"===e.kind){let t=C(e.id,e.name,e.height,e.headRatio,e.torsoRatio,e.bodyType);if(e.joints.length!==t.joints.length)throw Error("SPATIAL_INVALID: humanoid structure changed without custom morphology");for(let i of t.bones){let t=e.bones.find(e=>e.id===i.id);if(!t||t.endJointId!==i.endJointId||t.modelPart!==i.modelPart||(0,s.d)(t.restRotation)!==(0,s.d)(i.restRotation))throw Error("SPATIAL_INVALID: modified standard bone anatomy")}for(let i of t.joints){let t=e.joints.find(e=>e.id===i.id);if(!t||t.parentId!==i.parentId||t.offset.some((e,t)=>Math.abs(e-i.offset[t])>1e-10))throw Error("SPATIAL_INVALID: modified standard humanoid anatomy")}}}for(let e of t.objects)if(e.size.some(e=>e<=0))throw Error("SPATIAL_INVALID: positive object dimensions required");for(let e of t.cameras)if(.01>(0,l.i1)(e.position).distanceTo((0,l.i1)(e.target)))throw Error("SPATIAL_INVALID: camera target equals position");return t}function A(e){return(0,s.U)((0,s.d)(M(e)))}function L(e,t){if(!b(t))throw Error("SPATIAL_INVALID: invalid operations");let i=M(e),n=!1;if(!Array.isArray(t)||t.length>100)throw Error("SPATIAL_INVALID: operations must be a bounded array");for(let e of t){let t=structuredClone(i),a="characterId"in e?i.characters.find(t=>t.id===e.characterId):void 0;if("characterId"in e&&!a)throw Error("SPATIAL_INVALID: unknown character");switch(e.type){case"set-lighting":i.lightingEnabled=e.enabled;break;case"add-character":i.characters.push(C(e.id,e.name,e.height,e.headRatio,e.torsoRatio,e.bodyType,e));break;case"put-character":{let t=i.characters.findIndex(t=>t.id===e.character.id);t<0?i.characters.push(structuredClone(e.character)):i.characters[t]=structuredClone(e.character);break}case"add-limb":{if(!a.joints.some(t=>t.id===e.parentId))throw Error("SPATIAL_INVALID: unknown limb attachment");let t=a.joints.find(t=>t.id===e.sourceJointId);if(!t||!t.parentId)throw Error("SPATIAL_INVALID: source limb must have an upstream joint");let i=[t];for(let e=0;e<i.length;e++)i.push(...a.joints.filter(t=>t.parentId===i[e].id));a.kind="custom";let n=new Set(i.map(e=>e.id)),r=a.bones.filter(e=>n.has(e.endJointId));a.joints.push(...i.map((t,i)=>({...structuredClone(t),id:`${e.idPrefix}-${t.id}`,name:`${e.idPrefix} ${t.name}`,parentId:0===i?e.parentId:`${e.idPrefix}-${t.parentId}`,offset:0===i?e.offset:[...t.offset],lockPosition:!1}))),a.bones.push(...r.map(i=>({...structuredClone(i),id:`${e.idPrefix}-${i.id}`,name:`${e.idPrefix} ${i.name}`,startJointId:i.endJointId===t.id?e.parentId:`${e.idPrefix}-${i.startJointId}`,endJointId:`${e.idPrefix}-${i.endJointId}`,lockRotation:!1})));break}case"set-proportions":{let t=e.torsoRatio??a.torsoRatio??k,i=e.bodyType??a.bodyType??"male",n=C(a.id,a.name,a.height,a.headRatio,a.torsoRatio,a.bodyType),r=C(a.id,a.name,e.height,e.headRatio,t,i);if("humanoid"===a.kind)a.joints=r.joints.map(e=>({...a.joints.find(t=>t.id===e.id),offset:e.offset,radius:e.radius}));else for(let t of a.joints){let i=a.bones.find(e=>e.endJointId===t.id)?.modelPart,o=n.joints.find(e=>e.id===i),s=r.joints.find(e=>e.id===i),d=o?.parentId&&s?(0,l.i1)(s.offset).length()/(0,l.i1)(o.offset).length():e.height/a.height;t.offset=t.offset.map(e=>e*d),t.radius*=e.height/a.height}for(let o of(a.position=(0,l.i1)(a.position).add((0,l.i1)(r.position).sub((0,l.i1)(n.position)).applyQuaternion((0,l.b5)(a.rotation))).toArray(),a.height=e.height,a.headRatio=e.headRatio,a.torsoRatio=t,a.bodyType=i,Object.keys(u.aY)))void 0!==e[o]&&(a[o]=e[o]);break}case"lock-joint":{let t=a.joints.find(t=>t.id===e.jointId);if(!t)throw Error("SPATIAL_INVALID: unknown joint");void 0!==e.position&&(t.lockPosition=e.position);break}case"reset-pose":a.joints.forEach(e=>{e.lockPosition=!1}),a.bones.forEach(e=>{e.rotation=[...e.restRotation],e.lockRotation=!1});break;case"pose-hand":case"reset-hand":{let t=a.bones.find(t=>t.id===e.handBoneId&&t.modelPart.endsWith("-hand"));if(!t)throw Error("SPATIAL_INVALID: unknown hand");let i=(0,d.Au)(a,t);if("reset-hand"===e.type)a.joints.filter(e=>i.has(e.id)).forEach(e=>{e.lockPosition=!1}),a.bones.filter(e=>i.has(e.endJointId)).forEach(e=>{e.rotation=[...e.restRotation],e.lockRotation=!1});else for(let r of d.EG){if(e.curl?.[r]===void 0&&(void 0===e.spread||"thumb"===r)&&(void 0===e.thumbOpposition||"thumb"!==r))continue;let o=a.bones.filter(e=>i.has(e.endJointId)&&(0,d.dS)(e.modelPart)?.finger===r);if(4!==o.length)throw Error("SPATIAL_INVALID: incomplete finger");for(let i of o){let a=(0,d.dS)(i.modelPart).segment;if(!a)continue;let o=[...i.rotation],s=e.curl?.[r],l=t.modelPart.startsWith("left")?1:-1;void 0!==s&&("thumb"===r&&3===a?(o[0]=0,o[2]=-l*s*(0,d.oq)(r)[a-1]):o[0]=s*(0,d.oq)(r)[a-1]),1===a&&void 0!==e.spread&&"thumb"!==r&&(o[2]=e.spread*d.zK[r]*l),1===a&&void 0!==e.thumbOpposition&&"thumb"===r&&(o[1]=60*e.thumbOpposition*l,o[2]=-30*e.thumbOpposition*l);let c=o.map((e,t)=>Math.max(i.limits.min[t],Math.min(i.limits.max[t],e)));n||=c.some((e,t)=>e!==o[t]),i.rotation=c}}break}case"lock-bone":case"set-bone-limits":{let t=a.bones.find(t=>t.id===e.boneId);if(!t)throw Error("SPATIAL_INVALID: unknown bone");"lock-bone"===e.type?t.lockRotation=e.rotation:t.limits=structuredClone(e.limits);break}case"move-joint":case"rotate-bone":{let t="rotate-bone"===e.type?a.bones.find(t=>t.id===e.boneId):void 0;if("rotate-bone"===e.type&&!t)throw Error("SPATIAL_INVALID: unknown bone");if(t&&(0,l.j4)(t)&&"rotate-bone"===e.type){n||=e.rotation.some((e,i)=>e!==t.rotation[i]);break}let r="rotate-bone"===e.type?e.rotation.map((e,i)=>Math.max(t.limits.min[i],Math.min(t.limits.max[i],e))):void 0;r&&"rotate-bone"===e.type&&(n||=r.some((t,i)=>t!==e.rotation[i]));let o=t?(0,l.ms)(a):void 0,s="move-joint"===e.type?{position:e.position}:{rotation:(0,l.bl)(o[t.startJointId].rotation.clone().multiply((0,l.pT)(a,t,r)))},d=(0,l.uO)(a,"move-joint"===e.type?e.jointId:t.endJointId,s);if(i.characters[i.characters.indexOf(a)]=d.character,n||=d.constrained,t&&r){let e=d.character.bones.find(e=>e.id===t.id);n||=(0,l.b5)(e.rotation).angleTo((0,l.b5)(r))>.005}break}case"put-object":{let t=i.objects.findIndex(t=>t.id===e.object.id);t<0?i.objects.push(structuredClone(e.object)):i.objects[t]=structuredClone(e.object);break}case"put-camera":{let t=i.cameras.findIndex(t=>t.id===e.camera.id);t<0?i.cameras.push(structuredClone(e.camera)):i.cameras[t]=structuredClone(e.camera);break}case"put-camera-box":{let t=i.cameraBoxes??=[],n=t.findIndex(t=>t.id===e.box.id);n<0?t.push(structuredClone(e.box)):t[n]=structuredClone(e.box);break}case"fit-camera-box":{let t=i.cameraBoxes?.findIndex(t=>t.id===e.id)??-1;if(t<0)throw Error("SPATIAL_INVALID: camera box not found");i.cameraBoxes[t]=y(i.cameraBoxes[t],i,e.region);break}case"remove":i.characters=i.characters.filter(t=>t.id!==e.id),i.objects=i.objects.filter(t=>t.id!==e.id),i.cameras=i.cameras.filter(t=>t.id!==e.id),i.cameraBoxes&&(i.cameraBoxes=i.cameraBoxes.filter(t=>t.id!==e.id));break;default:throw Error("SPATIAL_INVALID: unknown operation")}!function(e,t,i={}){for(let n of e.characters){let e=t.characters.find(e=>e.id===n.id);if(!e)continue;let a=(0,l.ms)(n),r=(0,l.ms)(e);for(let t of n.joints){let i=e.joints.find(e=>e.id===t.id);if(i&&t.lockPosition&&i.lockPosition&&a[t.id].position.distanceTo(r[t.id].position)>1e-5)throw new I(`Fixed world position changed: ${t.id}`)}for(let t of n.bones){let o=e.bones.find(e=>e.id===t.id);if(o&&(0,l.j4)(t)){let e=i.resetPoseCharacterId===n.id&&(0,s.d)(o.rotation)===(0,s.d)(t.restRotation);if(o.modelPart!==t.modelPart||(0,s.d)(o.restRotation)!==(0,s.d)(t.restRotation)||!e&&(0,s.d)(o.rotation)!==(0,s.d)(t.rotation))throw new I(`Rigid connector rotation changed: ${t.id}`);if((0,s.d)(o.limits)!==(0,s.d)(t.limits))throw new I(`Rigid connector angle bounds changed: ${t.id}`)}if(o&&!i.allowLimitChanges&&(0,s.d)(o.limits)!==(0,s.d)(t.limits))throw new I(`Use set-bone-limits to change angle bounds: ${t.id}`);if(t.lockRotation&&o?.lockRotation&&a[t.endJointId].rotation.angleTo(r[o.endJointId].rotation)>1e-5)throw new I(`Fixed world rotation changed: ${t.id}`)}}}(t,i=M(i),{allowLimitChanges:"set-bone-limits"===e.type,resetPoseCharacterId:"reset-pose"===e.type?e.characterId:void 0})}return{draft:i,constrained:n}}},21449:()=>{},22146:(e,t,i)=>{"use strict";i.d(t,{Sn:()=>a,eJ:()=>r,em:()=>n,mw:()=>o});let n=["front","back","left","right","top","bottom"],a=28,r=12,o=["color","structure","depth","skeleton"]},22392:()=>{},23347:(e,t,i)=>{"use strict";i.d(t,{NT:()=>r,SZ:()=>l,sZ:()=>s});var n=i(84910),a=i(12399);let r=e=>new n.kn4().compose((0,a.i1)(e.position),(0,a.b5)(e.rotation),new n.Pq0(1,1,1)),o=e=>e instanceof n.eaF||e instanceof n.DXC;function s(e,t){let i=[],n=[];return e.traverse(e=>i.push(e)),t.traverse(e=>n.push(e)),!(i.length!==n.length||i.some((e,t)=>{let i=n[t];return e.type!==i.type||JSON.stringify(e.userData)!==JSON.stringify(i.userData)||!!o(e)&&!!o(i)&&(e.geometry.getAttribute("position").count!==i.geometry.getAttribute("position").count||e.geometry.index?.count!==i.geometry.index?.count||Object.entries(i.geometry.attributes).some(([t,i])=>e.geometry.getAttribute(t)?.array.length!==i.array.length))}))&&(i.forEach((e,t)=>{let i=n[t];if(e.position.copy(i.position),e.quaternion.copy(i.quaternion),e.scale.copy(i.scale),e.matrixAutoUpdate=i.matrixAutoUpdate,e.matrix.copy(i.matrix),o(e)&&o(i)){for(let[t,n]of Object.entries(i.geometry.attributes)){let i=e.geometry.getAttribute(t);i.array.set(n.array),i.needsUpdate=!0}e.geometry.index&&i.geometry.index&&(e.geometry.index.array.set(i.geometry.index.array),e.geometry.index.needsUpdate=!0),e.geometry.boundingBox=null,e.geometry.boundingSphere=null,Array.isArray(e.material)||Array.isArray(i.material)||e.material.copy(i.material)}}),!0)}function l(e,t){e.traverse(e=>{e instanceof n.eaF&&e.material instanceof n.G_z&&t.set(e,e.material.color.clone())})}},28179:(e,t,i)=>{"use strict";i.d(t,{Ls:()=>s,bh:()=>l,en:()=>u,yz:()=>d});var n=i(84910),a=i(96826),r=i(12399),o=i(29169);function s(e){let t=e.width/e.height,i="orthographic"===e.projection?new n.qUd(-e.span*t/2,e.span*t/2,e.span/2,-e.span/2,.01,3e4):new n.ubm(e.fov,t,.01,3e4);return i.position.copy((0,r.i1)(e.position)),i.lookAt((0,r.i1)(e.target)),i.updateMatrixWorld(),i}function l(e,t={}){let i=new n.YJl,o=(e,t,a,r,o,s=new n.Pq0(1,1,1))=>{let l=new n.eaF(e,new n.G_z({color:new n.Q1f(t),side:n.$EB}));return l.position.copy(a),l.quaternion.copy(r),l.scale.copy(s),l.userData=o,i.add(l),l};for(let n of e.characters)i.add((0,a.d)(n,t)),t.showRig&&"geometric"!==n.appearance&&d(i,n);for(let t of e.objects){let e=(0,r.i1)(t.size),i="sphere"===t.kind?new n.Gu$(.5,16,12):new n.iNn(1,1,1);"plane"===t.kind&&(e.y=.015),o(i,t.color,(0,r.i1)(t.position),(0,r.b5)(t.rotation),{objectId:t.id},e)}return i.updateMatrixWorld(!0),i}function d(e,t,i=!1){let a=function(e){let t=(0,r.ms)(e),i=[];for(let a of e.joints.filter(t=>!t.terminal||!!(0,o.dS)(e.bones.find(e=>e.endJointId===t.id)?.modelPart??"")))i.push({data:{characterId:e.id,rig:"joint",jointId:a.id},position:t[a.id].position,rotation:t[a.id].rotation,scale:new n.Pq0().setScalar(a.radius)});for(let a of e.bones){let r=(0,o.dS)(a.modelPart);if(r?.segment===0)continue;let s=t[a.startJointId].position,l=t[a.endJointId].position,d=l.clone().sub(s),c=d.length(),u=e.height*(r?.0018:.009);i.push({data:{characterId:e.id,rig:"bone",boneId:a.id},position:s.clone().add(l).multiplyScalar(.5),rotation:new n.PTz().setFromUnitVectors(new n.Pq0(0,1,0),d.normalize()),scale:new n.Pq0(u,c,u)})}return i}(t);if(i){let i=new n.kn4;for(let r of["joint","bone"]){let o=a.filter(e=>e.data.rig===r),s=e.children.find(e=>e instanceof n.ZLX&&e.userData.characterId===t.id&&e.userData.rig===r);s&&s.count!==o.length&&(e.remove(s),u(new n.YJl().add(s)),s=void 0),s||((s=new n.ZLX(c(r),new n.G_z({side:n.$EB,depthTest:!1}),o.length)).renderOrder=2,e.add(s)),s.userData={characterId:t.id,rig:r,instances:o.map(e=>e.data)};let l=new n.Q1f("joint"===r?"#e6a65c":"#728aa1");o.forEach((e,t)=>{s.setMatrixAt(t,i.compose(e.position,e.rotation,e.scale)),s.setColorAt(t,l)}),s.instanceMatrix.needsUpdate=!0,s.instanceColor&&(s.instanceColor.needsUpdate=!0),s.computeBoundingSphere()}return}let s=new Map(e.children.filter(e=>e.userData.rig&&e.userData.characterId===t.id).map(e=>[`${e.userData.rig}/${e.userData.jointId??e.userData.boneId}`,e])),l=(i,a)=>{let r=`${i}/${a}`,o=s.get(r);return s.delete(r),o||((o=new n.eaF(c(i),new n.G_z({side:n.$EB,depthTest:!1}))).userData={characterId:t.id,rig:i,["joint"===i?"jointId":"boneId"]:a},o.renderOrder=2,e.add(o)),o.material.color.set("joint"===i?"#e6a65c":"#728aa1"),o};for(let e of a){let t=l(e.data.rig,e.data.jointId??e.data.boneId);t.position.copy(e.position),t.quaternion.copy(e.rotation),t.scale.copy(e.scale)}for(let t of s.values())e.remove(t),t.geometry.dispose(),t.material.dispose()}let c=e=>"joint"===e?new n.Gu$(1,12,8):new n.Ho_(1,1,1,10);function u(e){e.traverse(e=>{if(e instanceof n.eaF||e instanceof n.DXC)for(let t of(e instanceof n.ZLX&&e.dispose(),e.geometry.dispose(),Array.isArray(e.material)?e.material:[e.material]))t.dispose()})}},29169:(e,t,i)=>{"use strict";i.d(t,{Au:()=>x,EG:()=>s,IA:()=>f,Jf:()=>p,PA:()=>g,Rq:()=>v,Yu:()=>c,cy:()=>m,dS:()=>l,jp:()=>b,oT:()=>h,oq:()=>w,t6:()=>d,xT:()=>y,zK:()=>j});var n=i(84910),a=i(2872),r=i(79283),o=i(54996);let s=["thumb","index","middle","ring","little"];function l(e){let t=/^(left|right)-(thumb|index|middle|ring|little)-([0-3])$/.exec(e);return t?{side:t[1],finger:t[2],segment:Number(t[3])}:null}let d=e=>e.endsWith("-hand")||!!l(e),c=e=>"female"===e.bodyType?r:a;function u(e,t){return 2===t?{min:[0,0,-45],max:[110,0,45]}:{min:[0,0,"left"===e?-90:0],max:[0,0,90*("left"!==e)]}}function m(e){if(2!==e.thumbLimitsVersion){for(let t of e.bones){let e=l(t.modelPart);if(e?.finger!=="thumb"||e.segment<2)continue;let i=[2===e.segment?110:90,0,0];t.limits.min.every(e=>0===e)&&t.limits.max.every((e,t)=>e===i[t])&&([t.rotation,t.restRotation].some(e=>e.some((e,t)=>e<0||e>i[t]))||(t.limits=u(e.side,e.segment),3===e.segment&&(t.limits.max[0]=Math.max(t.rotation[0],t.restRotation[0]))))}e.thumbLimitsVersion=2}}function h(e,t){let i=t;for(;i;){if(i.modelPart.endsWith("-hand"))return i;i=e.bones.find(e=>e.endJointId===i.startJointId)}}function p(e,t,i=!0){let a=c(e),r=a.parts.find(e=>e.id===t.modelPart),s=new n.Pq0(...r.end).sub(new n.Pq0(...r.start)),l=new n.Pq0(...e.joints.find(e=>e.id===t.endJointId).offset),d=l.length()/s.length(),u=(0,o.G_)(e.headRatio),m=i?e.palmSize??1:1,h=i?e.height/a.height*u.hand*m:d,g=new n.Pq0(0,1,0);return new n.kn4().compose(new n.Pq0,new n.PTz().setFromUnitVectors(g,l.normalize()),new n.Pq0(h,d*(i?u.handLength:1)*m,h)).multiply(new n.kn4().makeRotationFromQuaternion(new n.PTz().setFromUnitVectors(g,s.normalize()).invert()))}function g(e,t,i){let a=p(e,t);if(l(i)?.segment===0||(e.fingerLength??1)===(e.palmSize??1))return a;let r=c(e).parts.find(e=>e.id===i),o=new n.Pq0(...r.end).sub(new n.Pq0(...r.start)).normalize(),s=new n.kn4().makeRotationFromQuaternion(new n.PTz().setFromUnitVectors(new n.Pq0(0,1,0),o));return a.multiply(s).multiply(new n.kn4().makeScale(1,(e.fingerLength??1)/(e.palmSize??1),1)).multiply(s.clone().invert())}function f(e,t){let i=l(t.modelPart),a=i&&h(e,t);if(!i||!a||0===i.segment)return new n.PTz;let r=c(e).parts.find(e=>e.id===t.modelPart),o=new n.Pq0(...r.end).sub(new n.Pq0(...r.start)).normalize(),s=o.clone().cross(new n.Pq0(0,-1,0)).normalize(),d=s.clone().cross(o).normalize(),u=p(e,a,!1);return new n.PTz().setFromRotationMatrix(new n.kn4().makeBasis(s.transformDirection(u),o.transformDirection(u),d.transformDirection(u)))}function y(e,t,i){let a=e.bones.find(e=>e.endJointId===t.id).modelPart,r=g(e,i,a).multiply(p(e,i,!1).invert());return new n.Pq0(...t.offset).applyMatrix4(r)}function x(e,t){let i=new Set([t.endJointId]);for(let t of i)for(let n of e.joints.filter(e=>e.parentId===t))i.add(n.id);return i}function b(e,t){let i=c(e),a=p(e,t,!1),r=t.id.endsWith(t.modelPart)?t.id.slice(0,-t.modelPart.length):`${t.id}-`,o=t.modelPart.startsWith("left")?"left":"right";for(let l of s)for(let s=0;s<4;s++){let d=`${o}-${l}-${s}`,c=`${r}${d}`,m=i.parts.find(e=>e.id===d),h=s?`${r}${o}-${l}-${s-1}`:t.endJointId,p=new n.Pq0(...m.end).sub(new n.Pq0(...m.start)).applyMatrix4(a).toArray(),g=0===s?[0,0,0]:1===s?[-10,"thumb"===l?-70:0,"thumb"===l?-35:-20]:[0,0,0],f=0===s?[0,0,0]:1===s?[95,70*("thumb"===l),"thumb"===l?35:20]:[2===s?110:90,0,0];e.joints.push({id:c,name:c,parentId:h,offset:p,radius:.004*e.height,terminal:3===s,lockPosition:!1});let y="thumb"===l&&s>=2?u(o,s):{min:g,max:f};e.bones.push({id:c,name:c,startJointId:h,endJointId:c,rotation:[0,0,0],restRotation:[0,0,0],limits:y,lockRotation:!1,modelPart:d})}}function v(e){for(let t of e.bones.filter(e=>"left-hand"===e.modelPart||"right-hand"===e.modelPart)){let i=e.joints.find(e=>e.id===t.endJointId);if(!i?.terminal||e.joints.some(e=>e.parentId===i.id))continue;i.offset=i.offset.map(e=>.35*e),i.terminal=!1,i.radius=.01*e.height;let n=i.lockPosition;if(i.lockPosition=!1,b(e,t),n){let i=e.bones.find(i=>i.modelPart===t.modelPart.replace("hand","middle-3")&&x(e,t).has(i.endJointId));e.joints.find(e=>e.id===i.endJointId).lockPosition=!0}}}let w=e=>"thumb"===e?[35,50,55]:[70,95,65],j={thumb:0,index:16,middle:4,ring:-7,little:-18}},29415:(e,t,i)=>{"use strict";i.d(t,{J:()=>d});var n=i(73365),a=i(35659),r=i(2684),o=i(46811),s=i(99791);function l(e){return String(s.L[e])}function d({children:e,icon:t,mode:i="without-icon",backgroundColor:s,textColor:c,iconLabel:u,style:m,"aria-label":h,...p}){let g=(0,r.P)((0,o.S)("basic-button","BasicButton","component")),f={..."none"===s?{backgroundColor:"transparent",border:"none",boxShadow:"none"}:s?{backgroundColor:l(s),borderColor:l(s)}:{},...c&&"none"!==c?{color:l(c)}:{}};return(0,n.jsx)(a.Ay,{...p,...g,"aria-label":"icon-only"===i?u??h:h,icon:"without-icon"===i?void 0:t,style:{...f,...m},children:"icon-only"===i?void 0:e})}Object.keys(s.L).filter(e=>e.startsWith("color."))},33949:(e,t,i)=>{"use strict";function n(e,t,i){if(!e.some(e=>e.id===t))throw Error(`Unknown canvas state: ${t}.`);let n=i.trim();if(!n||n.length>100)throw Error("Canvas state name must contain 1 to 100 characters.");return e.map(e=>e.id===t?{...e,name:n}:e)}function a(e,t){let i=new Map(e.map(e=>[e.id,e]));if(t.length!==e.length||new Set(t).size!==e.length||t.some(e=>!i.has(e)))throw Error("Canvas state order must contain each state exactly once.");return t.map(e=>i.get(e))}function r(e,t){if(!e.some(e=>e.id===t))throw Error(`Unknown canvas state: ${t}.`);if(1===e.length)throw Error("A canvas must retain at least one state.");return e.filter(e=>e.id!==t)}i.d(t,{UR:()=>n,aD:()=>r,kq:()=>a})},34345:(e,t,i)=>{"use strict";i.d(t,{q:()=>r,u:()=>a});var n=i(76109);function a(e){return(0,n.EN)([...e.images,...e.areas,...e.directionLine?[e.directionLine]:[],...e.focusPoints].map(e=>e.id),e.layerOrder)}function r(e,t,i){let r=a(e),o=(0,n.qP)(r,t,i);return o===r?e:{...e,layerOrder:[...o]}}},37551:()=>{},37588:()=>{},42621:(e,t,i)=>{"use strict";i.d(t,{N:()=>r});var n=i(19204);let a=new WeakMap;function r(e){let{name:t,note:i,...r}=e,o=JSON.stringify(r),s=a.get(e);if(s?.raw===o)return s.key;let l=(0,n.d)(r);return a.set(e,{raw:o,key:l}),l}},42666:()=>{},46811:(e,t,i)=>{"use strict";i.d(t,{S:()=>r});var n=i(27812);let a={"basic-button":"button","action-button":"button","composite-button":"button","confirm-action":"button","number-badge":"number","animated-number":"number","border-scan":"motion","text-shine":"motion","tab-switch":"switching","underline-tab-switch":"switching","dot-scrollbar":"switching","status-card":"card","image-title-card":"card","decorative-title":"typography","animated-icon":"icon","status-badge":"status","status-light":"status","loading-state":"status","aspect-ratio-selector":"module","model-selector":"module","adaptive-accordion":"module","resizable-collapse-group":"module","asset-skeleton-tree":"module","message-composer":"module","text-mark-editor":"module","side-action-panel":"module","section-navigation-panel":"module","app-shell-frame":"layout"};function r(e,t,i){return(0,n.Se)({namespace:"yisiui",id:e,name:t,category:a[e],origin:"shared",status:"experimental"})}},48308:()=>{},49404:()=>{},50052:(e,t,i)=>{"use strict";i.d(t,{I:()=>u,u:()=>h});var n=i(73365),a=i(35659),r=i(50152),o=i(24539),s=i(1521);i(22392),i(94560);var l=i(46811),d=i(99791);let c=(0,s.createContext)(!1);function u({collapsed:e,children:t}){return(0,n.jsx)(c.Provider,{value:e,children:t})}function m(e){return String(d.L[e])}function h({label:e,icon:t,description:i,actions:d=[],onClick:u,textColor:p="color.text.primary",collapsed:g,collapsedLabel:f,"aria-current":y,"aria-label":x,title:b,disabled:v=!1,loading:w=!1,className:j}){let k=(0,s.useContext)(c),I=g??k,S=f??x??("string"==typeof e?e:b),P="none"===p?void 0:m(p),C=m("color.text.secondary");if(I&&!S)throw Error("CompositeButton collapsed state requires a plain-text label or collapsedLabel");let M=(0,n.jsx)(a.Ay,{className:"yisi-composite-button-main",size:"small",type:"text",icon:t,"aria-current":y,"aria-label":I?S:x,title:I?void 0:b,disabled:v,loading:w,onClick:u,style:P?{color:P}:void 0,children:I?null:(0,n.jsx)(r.A.Text,{className:"yisi-composite-button-label",style:{color:"inherit"},children:e})});return(0,n.jsxs)("div",{...(0,l.S)("composite-button","CompositeButton","component"),className:["yisi-composite-button",I?"yisi-composite-button--collapsed":null,!I&&d.length?"yisi-composite-button--has-actions":null,j].filter(Boolean).join(" "),"data-collapsed":I?"true":"false",children:[I?(0,n.jsx)(o.A,{title:S,placement:"right",children:M}):M,!I&&i?(0,n.jsx)(r.A.Text,{className:"yisi-composite-button-description",type:"secondary",style:{color:"var(--yisiui-color-text-muted)"},children:i}):null,!I&&d.length?(0,n.jsx)("div",{className:"yisi-composite-button-actions",role:"group","aria-label":"行操作",children:d.map(e=>(0,n.jsx)(a.Ay,{className:"yisi-composite-button-action",size:"small",type:"text",icon:e.icon,"aria-label":e.label,title:e.label,disabled:v||e.disabled,loading:e.loading,onClick:e.onClick,style:{color:C}},e.key))}):null]})}},52048:()=>{},52582:(e,t,i)=>{"use strict";i.d(t,{Xn:()=>b,xB:()=>w,JZ:()=>k,eq:()=>x,hN:()=>v,oA:()=>D,s6:()=>I,mq:()=>f,MY:()=>j,Dr:()=>z,Pe:()=>P,Wn:()=>C,km:()=>Q,CP:()=>S,Ai:()=>_,oF:()=>M,CV:()=>N,Kd:()=>B,co:()=>O,IU:()=>A,z_:()=>L,rz:()=>$,hG:()=>F,ET:()=>q,ai:()=>R,QY:()=>E,s:()=>T,M6:()=>y,VC:()=>U});var n=i(34345),a=i(59793),r=i(27062);let o=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://yisi.local/schemas/composition-draft.schema.json","title":"User Composition Draft","type":"object","additionalProperties":false,"required":["version","kind","processingSemantic","frame","overallNote","focusPoints","areas","images"],"allOf":[{"if":{"required":["states"]},"then":{"required":["activeStateId"]}},{"if":{"required":["activeStateId"]},"then":{"required":["states"]}}],"properties":{"plans":{"type":"array","items":{"$ref":"#/$defs/compositionPlan"}},"activeStateId":{"type":"string","minLength":1},"states":{"type":"array","minItems":1,"items":{"$ref":"#/$defs/state"}},"layerOrder":{"type":"array","uniqueItems":true,"items":{"type":"string","minLength":1}},"version":{"const":1},"kind":{"const":"composition-draft"},"processingSemantic":{"enum":[null,"scene-composition","editorial-layout"]},"frame":{"type":"object","additionalProperties":false,"required":["width","height"],"properties":{"width":{"type":"integer","minimum":256,"maximum":4096},"height":{"type":"integer","minimum":256,"maximum":4096},"bounds":{"type":"object","additionalProperties":false,"required":["x","y","width","height"],"properties":{"x":{"type":"number"},"y":{"type":"number"},"width":{"type":"number","exclusiveMinimum":0},"height":{"type":"number","exclusiveMinimum":0}}}}},"overallNote":{"type":"string"},"focusPoints":{"type":"array","maxItems":3,"items":{"$ref":"#/$defs/point"}},"directionLine":{"oneOf":[{"type":"null"},{"type":"object","additionalProperties":false,"required":["id","x","y","rotation","note","annotation","semanticType","shotScale"],"properties":{"id":{"const":"direction-1"},"x":{"type":"number"},"y":{"type":"number"},"rotation":{"type":"number"},"origin":{"enum":["user","agent","import"]},"note":{"type":"string"},"annotation":{"type":"string"},"semanticType":{"type":"string"},"shotScale":{"enum":["auto","foreground","midground","background"]}}}]},"areas":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["id","primitive","x","y","area","aspect","visualWeight","note","annotation","semanticType","shotScale"],"properties":{"id":{"type":"string","pattern":"^area-[0-9]+$"},"primitive":{"enum":["circle","triangle","quadrilateral"]},"x":{"type":"number"},"y":{"type":"number"},"area":{"type":"number","exclusiveMinimum":0},"aspect":{"enum":["square","free","landscape","portrait"]},"visualWeight":{"enum":["auto","high","medium","low","decorative"]},"displayText":{"type":"string"},"corners":{"$ref":"#/$defs/textCorners"},"isLightSource":{"type":"boolean"},"rotation":{"type":"number"},"width":{"type":"number","exclusiveMinimum":0},"height":{"type":"number","exclusiveMinimum":0},"origin":{"enum":["user","agent","import"]},"note":{"type":"string"},"annotation":{"type":"string"},"semanticType":{"type":"string"},"shotScale":{"enum":["auto","foreground","midground","background"]}},"allOf":[{"if":{"properties":{"aspect":{"const":"free"}}},"then":{"required":["width","height"]}},{"if":{"properties":{"semanticType":{"const":"text-region"}},"required":["semanticType"]},"then":{"required":["displayText"],"properties":{"isLightSource":{"const":false}}},"else":{"not":{"anyOf":[{"required":["displayText"]},{"required":["corners"]}]}}},{"if":{"required":["corners"]},"then":{"properties":{"primitive":{"const":"quadrilateral"},"aspect":{"const":"free"}}}}]}},"images":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["id","x","y","width","height","rotation","visualWeight","assetId","crop","note","annotation","semanticType","shotScale"],"properties":{"id":{"type":"string","pattern":"^image-[0-9]+$"},"x":{"type":"number"},"y":{"type":"number"},"width":{"type":"number","exclusiveMinimum":0},"height":{"type":"number","exclusiveMinimum":0},"rotation":{"type":"number"},"visualWeight":{"enum":["auto","high","medium","low","decorative"]},"cameraReference":{"type":"object","additionalProperties":false,"required":["sessionId","cameraId","renderedRevision"],"properties":{"sessionId":{"type":"string","minLength":1},"cameraId":{"type":"string","minLength":1},"renderedRevision":{"type":"integer","minimum":0}}},"assetId":{"type":["string","null"],"minLength":1},"crop":{"oneOf":[{"type":"null"},{"$ref":"#/$defs/imageCrop"}]},"origin":{"enum":["user","agent","import"]},"note":{"type":"string"},"annotation":{"type":"string"},"semanticType":{"type":"string"},"shotScale":{"enum":["auto","foreground","midground","background"]}}}}},"$defs":{"compositionPlan":{"type":"object","additionalProperties":false,"required":["id","visible","type"],"properties":{"id":{"type":"string","pattern":"^plan-[a-zA-Z0-9-]+$"},"visible":{"type":"boolean"},"axes":{"enum":["both","horizontal","vertical"]},"x":{"type":"number"},"y":{"type":"number"},"rotation":{"type":"number"},"scale":{"type":"number","exclusiveMinimum":0},"mirrored":{"type":"boolean"},"type":{"enum":["thirds","golden-section","symmetry","golden-spiral","triangle","radial"]},"width":{"type":"number","exclusiveMinimum":0},"height":{"type":"number","exclusiveMinimum":0},"rayCount":{"type":"integer","minimum":2,"maximum":36},"spread":{"type":"number","minimum":1,"maximum":360},"mode":{"enum":["uniform","free"]},"angles":{"type":"array","minItems":2,"maxItems":36,"items":{"type":"number"}}},"oneOf":[{"type":"object","properties":{"type":{"enum":["thirds","golden-section"]}},"required":["axes"],"not":{"anyOf":[{"required":["x"]},{"required":["y"]},{"required":["rotation"]},{"required":["scale"]},{"required":["mirrored"]},{"required":["width"]},{"required":["height"]},{"required":["rayCount"]},{"required":["spread"]},{"required":["mode"]},{"required":["angles"]}]}},{"type":"object","properties":{"type":{"enum":["symmetry"]}},"required":["x","y","rotation"],"not":{"anyOf":[{"required":["axes"]},{"required":["scale"]},{"required":["mirrored"]},{"required":["width"]},{"required":["height"]},{"required":["rayCount"]},{"required":["spread"]},{"required":["mode"]},{"required":["angles"]}]}},{"type":"object","properties":{"type":{"enum":["golden-spiral"]}},"required":["x","y","rotation","scale","mirrored"],"not":{"anyOf":[{"required":["axes"]},{"required":["width"]},{"required":["height"]},{"required":["rayCount"]},{"required":["spread"]},{"required":["mode"]},{"required":["angles"]}]}},{"type":"object","properties":{"type":{"enum":["triangle"]}},"required":["x","y","rotation","width","height"],"not":{"anyOf":[{"required":["axes"]},{"required":["scale"]},{"required":["mirrored"]},{"required":["rayCount"]},{"required":["spread"]},{"required":["mode"]},{"required":["angles"]}]}},{"type":"object","properties":{"type":{"enum":["radial"]},"mode":{"enum":["uniform"]}},"required":["x","y","rotation","rayCount","spread"],"not":{"anyOf":[{"required":["axes"]},{"required":["scale"]},{"required":["mirrored"]},{"required":["width"]},{"required":["height"]},{"required":["angles"]}]}},{"type":"object","properties":{"type":{"enum":["radial"]},"mode":{"enum":["free"]}},"required":["x","y","mode","angles"],"not":{"anyOf":[{"required":["axes"]},{"required":["rotation"]},{"required":["scale"]},{"required":["mirrored"]},{"required":["width"]},{"required":["height"]},{"required":["rayCount"]},{"required":["spread"]}]}}]},"state":{"type":"object","additionalProperties":false,"required":["id","number","layout"],"properties":{"id":{"type":"string","minLength":1,"maxLength":100},"number":{"type":"integer","minimum":1},"name":{"type":"string","minLength":1,"maxLength":100},"layout":{"type":"object","additionalProperties":false,"required":["frame","layerOrder","focusPoints","directionLine","areas","images"],"properties":{"plans":{"type":"array","items":{"$ref":"#/$defs/compositionPlan"}},"frame":{"allOf":[{"$ref":"#/properties/frame"},{"type":"object","required":["bounds"]}]},"layerOrder":{"$ref":"#/properties/layerOrder"},"focusPoints":{"type":"array","maxItems":3,"items":{"$ref":"#/$defs/layoutPoint"}},"directionLine":{"oneOf":[{"type":"null"},{"$ref":"#/$defs/layoutDirection"}]},"areas":{"type":"array","items":{"$ref":"#/$defs/layoutArea"}},"images":{"type":"array","items":{"$ref":"#/$defs/layoutImage"}}}}}},"layoutPoint":{"type":"object","additionalProperties":false,"required":["id","x","y"],"properties":{"id":{"type":"string","pattern":"^focus-[0-9]+$"},"x":{"type":"number"},"y":{"type":"number"}}},"layoutDirection":{"type":"object","additionalProperties":false,"required":["id","x","y","rotation"],"properties":{"id":{"const":"direction-1"},"x":{"type":"number"},"y":{"type":"number"},"rotation":{"type":"number"}}},"textCorners":{"type":"array","minItems":4,"maxItems":4,"items":{"type":"object","additionalProperties":false,"required":["x","y"],"properties":{"x":{"type":"number","minimum":0,"maximum":1},"y":{"type":"number","minimum":0,"maximum":1}}}},"layoutArea":{"type":"object","additionalProperties":false,"required":["id","x","y","area","aspect"],"properties":{"id":{"type":"string","pattern":"^area-[0-9]+$"},"x":{"type":"number"},"y":{"type":"number"},"area":{"type":"number","exclusiveMinimum":0},"corners":{"$ref":"#/$defs/textCorners"},"aspect":{"enum":["square","free","landscape","portrait"]},"rotation":{"type":"number"},"width":{"type":"number","exclusiveMinimum":0},"height":{"type":"number","exclusiveMinimum":0}},"allOf":[{"if":{"properties":{"aspect":{"const":"free"}}},"then":{"required":["width","height"]}}]},"layoutImage":{"type":"object","additionalProperties":false,"required":["id","x","y","width","height","rotation"],"properties":{"id":{"type":"string","pattern":"^image-[0-9]+$"},"x":{"type":"number"},"y":{"type":"number"},"width":{"type":"number","exclusiveMinimum":0},"height":{"type":"number","exclusiveMinimum":0},"rotation":{"type":"number"}}},"imageCrop":{"type":"object","additionalProperties":false,"required":["x","y","width","height"],"properties":{"x":{"type":"number","minimum":0,"maximum":1},"y":{"type":"number","minimum":0,"maximum":1},"width":{"type":"number","exclusiveMinimum":0,"maximum":1},"height":{"type":"number","exclusiveMinimum":0,"maximum":1}}},"point":{"type":"object","additionalProperties":false,"required":["id","x","y","note","annotation","semanticType","shotScale"],"properties":{"id":{"type":"string","pattern":"^focus-[0-9]+$"},"x":{"type":"number"},"y":{"type":"number"},"origin":{"enum":["user","agent","import"]},"note":{"type":"string"},"annotation":{"type":"string"},"semanticType":{"type":"string"},"shotScale":{"enum":["auto","foreground","midground","background"]}}}}}');function s(){return{origin:"user",note:"",annotation:"",semanticType:""}}var l=i(19767),d=i(3500);let c=["circle","triangle","quadrilateral"],u=["square","free","landscape","portrait"],m="text-region",h=["scene-composition","editorial-layout"],p=["auto","high","medium","low","decorative"],g=new r.Ajv2020({allErrors:!0}).compile(o);function f(e={width:1600,height:900}){return y({version:1,kind:"composition-draft",processingSemantic:null,frame:(0,d.sw)(e),overallNote:"",focusPoints:[],directionLine:null,areas:[],images:[],plans:[{id:"plan-1",type:"thirds",axes:"both",visible:!0}]})}function y(e){var t;let i,r,o,s=function(e){if(!e||"object"!=typeof e||Array.isArray(e))return e;let t="focusPoints"in e&&Array.isArray(e.focusPoints)?e.focusPoints.map(H):void 0,i="areas"in e&&Array.isArray(e.areas)?e.areas.map(Y):void 0,n="images"in e&&Array.isArray(e.images)?e.images.map(V):[],a="directionLine"in e?null===e.directionLine?null:H(e.directionLine):void 0;return{...e,...!("processingSemantic"in e)?{processingSemantic:null}:{},...!("overallNote"in e)?{overallNote:""}:{},...t?{focusPoints:t}:{},...i?{areas:i}:{},images:n,...void 0!==a?{directionLine:a}:{}}}(function e(t){if(!t||"object"!=typeof t||Array.isArray(t))return t;let i=t.frame,n=Array.isArray(t.plans)?t.plans.map(e=>{if(!e||"object"!=typeof e||Array.isArray(e))return e;let{enabled:t,note:n,...a}=e;if("radial"===a.type&&void 0===a.mode)return{...a,mode:"uniform"};if(a?.type!=="triangle"||!Array.isArray(a.points)||3!==a.points.length||!a.points.every(e=>e&&Number.isFinite(e.x)&&Number.isFinite(e.y))||!i||!Number.isFinite(i.width)||!Number.isFinite(i.height)||i.width<=0||i.height<=0)return a;let[r,o,s]=a.points.map(e=>({x:e.x*i.width,y:e.y*i.height})),l=s.x-o.x,d=s.y-o.y,c=Math.hypot(l,d);if(0===c)return a;let u={x:(o.x+s.x)/2,y:(o.y+s.y)/2},m=(-((u.x-r.x)*d)+(u.y-r.y)*l)/c;if(0===m)return a;let{points:h,...p}=a;return{...p,x:(u.x+d/c*m/2)/i.width,y:(u.y-l/c*m/2)/i.height,rotation:180*Math.atan2(d,l)/Math.PI+180*(m<0),width:c/i.width,height:Math.abs(m)/i.height}}):void 0,a=Array.isArray(t.states)?t.states.map(t=>t&&"object"==typeof t?{...t,layout:e(t.layout)}:t):void 0;return{...t,...n?{plans:n}:{},...a?{states:a}:{}}}(e));if(!g(s))throw Error((g.errors??[]).map(e=>"additionalProperties"===e.keyword?`${e.instancePath||"draft"} contains unknown field: ${String(e.params.additionalProperty)}`:`${e.instancePath||"draft"} ${e.message??"is invalid"}`).join("; "));J(s.frame);let c=!s.frame.bounds,u=structuredClone(s);if(u.frame=c?(0,d.sw)(s.frame):structuredClone(s.frame),c&&(r=(i=(t=u).frame.bounds).width*i.height,o=e=>{e.x=i.x+e.x*i.width,e.y=i.y+e.y*i.height},t.focusPoints.forEach(o),t.directionLine&&o(t.directionLine),t.areas.forEach(e=>{o(e),e.area*=r,void 0!==e.width&&(e.width*=i.width),void 0!==e.height&&(e.height*=i.height)}),t.images.forEach(e=>{o(e),e.width*=i.width,e.height*=i.height})),u.plans&&new Set(u.plans.map(e=>e.id)).size!==u.plans.length)throw Error("Composition planning ids must be unique within a state.");u.plans&&(u.plans=u.plans.map(e=>{let t={id:e.id,visible:e.visible};if("triangle"===e.type)return{...t,type:e.type,x:e.x,y:e.y,rotation:ee(e.rotation),width:e.width,height:e.height};if("radial"===e.type)return"free"===e.mode?{...t,type:e.type,x:e.x,y:e.y,mode:e.mode,angles:e.angles.map(ee)}:{...t,type:e.type,x:e.x,y:e.y,mode:e.mode,rotation:ee(e.rotation),rayCount:e.rayCount,spread:e.spread};if("symmetry"===e.type)return{...t,type:e.type,x:.5,y:.5,rotation:Q(e.rotation,u.frame)};if("golden-spiral"===e.type){let i={x:e.x,y:e.y,rotation:ee(e.rotation)};return{...t,type:e.type,...i,scale:e.scale,mirrored:e.mirrored}}return{...t,type:e.type,axes:e.axes}}));let m=new Set;for(let e of[...u.focusPoints,...u.directionLine?[u.directionLine]:[],...u.areas,...u.images]){if(m.has(e.id))throw Error(`Duplicate draft item id: ${e.id}.`);m.add(e.id)}return u.directionLine=u.directionLine?{...u.directionLine,rotation:ee(u.directionLine.rotation)}:null,u.areas.forEach(e=>{if(e.corners){if(!(0,l.$n)(e.corners))throw Error("Text region corners must form a convex quadrilateral.");let t=e.corners.map(e=>e.x),i=e.corners.map(e=>e.y);if(Math.min(...t)>1e-8||Math.min(...i)>1e-8||Math.max(...t)<1-1e-8||Math.max(...i)<1-1e-8)throw Error("Text region corners must span their normalized bounding box.");e.area=e.width*e.height*(0,l.Ab)(e.corners)}"circle"===e.primitive&&"free"!==e.aspect&&(e.rotation=0),"quadrilateral"===e.primitive&&("landscape"===e.aspect||"portrait"===e.aspect)&&(Object.assign(e,(0,l.PK)(e.area,d.cq,"landscape"===e.aspect?1.6:.625,e.primitive)),e.aspect="free")}),u.layerOrder&&(u.layerOrder=(0,n.u)(u)),u.images.forEach(e=>{e.rotation=ee(e.rotation),e.crop&&Z(e.crop)}),(0,a.Ib)(u)}function x(e,t){let i=y(e);if(i.focusPoints.length>=3)throw Error("A draft may contain at most 3 focus points.");let n={id:K("focus",[...i.focusPoints,...i.areas]),x:t.x,y:t.y,...W()};return i.focusPoints.push(n),{draft:i,id:n.id}}function b(e,t){let i=y(e);if(!c.includes(t.primitive))throw Error(`Unsupported primitive: ${t.primitive}.`);let n=Number(t.area)>0?Number(t.area):.08,a=t.aspect&&u.includes(t.aspect)?t.aspect:"square",r={id:K("area",[...i.focusPoints,...i.areas]),primitive:t.primitive,x:Number.isFinite(t.x)?t.x:.5,y:Number.isFinite(t.y)?t.y:.5,area:n,aspect:a,visualWeight:"auto",rotation:"circle"===t.primitive?0:ee(Number(t.rotation)||0),...W()};return"free"===a&&Object.assign(r,(0,l.PK)(n,d.cq,1.6,t.primitive)),i.areas.push(r),{draft:i,id:r.id}}function v(e,t={}){let i=b(e,{...t,primitive:"quadrilateral",aspect:"free"});return{draft:R(T(i.draft,i.id,{semanticType:m}),i.id,{displayText:""}),id:i.id}}function w(e,t={}){let i=y(e),n={id:K("image",[...i.focusPoints,...i.areas,...i.images]),x:Number.isFinite(t.x)?t.x:i.frame.bounds.x+i.frame.bounds.width/2,y:Number.isFinite(t.y)?t.y:i.frame.bounds.y+i.frame.bounds.height/2,width:Number.isFinite(t.width)&&t.width>0?t.width:320/d.cq.width,height:Number.isFinite(t.height)&&t.height>0?t.height:180/d.cq.height,rotation:ee(Number(t.rotation)||0),visualWeight:"auto",assetId:null,crop:null,...W()};return i.images.push(n),{draft:i,id:n.id}}function j(e){return e.semanticType===m}function k(e){let t=y(e);if(t.directionLine)throw Error("A draft may contain at most one direction line.");return t.directionLine={id:"direction-1",x:.5,y:.5,rotation:0,...W()},{draft:t,id:t.directionLine.id}}function I(e,t){let i=y(e);return[...new Set(t)].flatMap(e=>{let t=i.focusPoints.find(t=>t.id===e);if(t)return[{kind:"focus",item:structuredClone(t)}];let n=i.areas.find(t=>t.id===e);if(n)return[{kind:"area",item:structuredClone(n)}];let a=i.images.find(t=>t.id===e);return a?[{kind:"image",item:structuredClone(a)}]:i.directionLine?.id===e?[{kind:"direction",item:structuredClone(i.directionLine)}]:[]})}function S(e,t,i){let n=y(e),a=[];for(let e of t){if("focus"===e.kind){if(n.focusPoints.length>=3)continue;let t={...structuredClone(e.item),id:K("focus",[...n.focusPoints,...n.areas]),x:e.item.x+i.x,y:e.item.y+i.y};n.focusPoints.push(t),a.push(t.id);continue}if("area"===e.kind){let t={...structuredClone(e.item),id:K("area",[...n.focusPoints,...n.areas]),x:e.item.x+i.x,y:e.item.y+i.y};n.areas.push(t),a.push(t.id);continue}if("image"===e.kind){let t={...structuredClone(e.item),id:K("image",[...n.focusPoints,...n.areas,...n.images]),x:e.item.x+i.x,y:e.item.y+i.y};n.images.push(t),a.push(t.id);continue}n.directionLine||(n.directionLine={...structuredClone(e.item),id:"direction-1",x:e.item.x+i.x,y:e.item.y+i.y},a.push(n.directionLine.id))}return{draft:y(n),ids:a}}function P(e,t,i){let n=y(e),a=n.focusPoints.find(e=>e.id===t);if(a)return a.x=i.x,a.y=i.y,n;if(n.directionLine?.id===t)return n.directionLine.x=i.x,n.directionLine.y=i.y,n;let r=n.areas.find(e=>e.id===t)??n.images.find(e=>e.id===t);if(!r)throw Error(`Unknown draft item: ${t}.`);return r.x=i.x,r.y=i.y,n}function C(e,t,i,n){let a=y(e),r=X(a,t);if(!j(r)||!Number.isInteger(i)||i<0||i>3||!Number.isFinite(n.x)||!Number.isFinite(n.y))return e;let o=(0,l.QR)({...r,x:0,y:0,rotation:0},d.cq);if("polygon"!==o.type)return e;let s=(r.rotation??0)*Math.PI/180,c=(n.x-r.x)*d.cq.width,u=(n.y-r.y)*d.cq.height;o.points[i]={x:c*Math.cos(s)+u*Math.sin(s),y:-c*Math.sin(s)+u*Math.cos(s)};let m=o.points.map(e=>e.x),h=o.points.map(e=>e.y),p=Math.min(...m),g=Math.min(...h),f=Math.max(...m)-p,x=Math.max(...h)-g;if(f<8||x<8)return e;let b=o.points.map(e=>({x:(e.x-p)/f,y:(e.y-g)/x}));if(!(0,l.$n)(b))return e;let v=p+f/2,w=g+x/2;return r.x+=(v*Math.cos(s)-w*Math.sin(s))/d.cq.width,r.y+=(v*Math.sin(s)+w*Math.cos(s))/d.cq.height,r.width=f/d.cq.width,r.height=x/d.cq.height,r.aspect="free",r.corners=b,r.area=r.width*r.height*(0,l.Ab)(b),a}function M(e,t,i){let n=y(e),a=X(n,t);if(!Number.isFinite(i)||i<=0)return n;if("free"===a.aspect){let e=Math.sqrt(i/(a.corners?a.area:a.width*a.height));a.width*=e,a.height*=e}return a.area=i,n}function A(e,t,i,n){let a=y(e),r=a.areas.find(e=>e.id===t);if(!r)throw Error(`Unknown free area: ${t}.`);if(!Number.isFinite(i)||!Number.isFinite(n)||i<=0||n<=0)return a;r.width=i,r.height=n,r.aspect="free";let o=r.corners?(0,l.Ab)(r.corners):"circle"===r.primitive?Math.PI/4:"triangle"===r.primitive?.5:1;return r.area=i*n*o,a}function L(e,t,i){let n=y(e),a=X(n,t);return"circle"===a.primitive&&"free"!==a.aspect||(a.rotation=ee(i)),n}function N(e,t,i,n){let a=y(e),r=G(a,t);return!Number.isFinite(i)||!Number.isFinite(n)||i<=0||n<=0||(r.width=i,r.height=n),a}function $(e,t,i){let n=y(e);return G(n,t).rotation=ee(i),n}function F(e,t,i){let n=y(e);if(n.directionLine?.id!==t)throw Error(`Unknown draft direction line: ${t}.`);return n.directionLine.rotation=ee(i),n}function _(e,t){let i=y(e);return i.focusPoints=i.focusPoints.filter(e=>e.id!==t),i.areas=i.areas.filter(e=>e.id!==t),i.images=i.images.filter(e=>e.id!==t),i.directionLine?.id===t&&(i.directionLine=null),i.layerOrder&&(i.layerOrder=(0,n.u)(i)),i}function T(e,t,i){let n=y(e),a=n.focusPoints.find(e=>e.id===t)??n.areas.find(e=>e.id===t)??n.images.find(e=>e.id===t)??(n.directionLine?.id===t?n.directionLine:null);if(!a)throw Error(`Unknown draft item: ${t}.`);return Object.assign(a,i),n}function R(e,t,i){let n=y(e),a=X(n,t);if(void 0!==i.visualWeight&&!p.includes(i.visualWeight))throw Error(`Unsupported visual weight: ${i.visualWeight}.`);if(void 0!==i.displayText&&!j(a))throw Error(`Display text is only supported by text regions: ${t}.`);return void 0!==i.visualWeight&&(a.visualWeight=i.visualWeight),void 0!==i.displayText&&(a.displayText=i.displayText),void 0!==i.isLightSource&&(a.isLightSource=i.isLightSource),y(n)}function E(e,t,i){let n=y(e),a=G(n,t);if(void 0!==i.visualWeight&&!p.includes(i.visualWeight))throw Error(`Unsupported visual weight: ${i.visualWeight}.`);if(void 0!==i.assetId&&null!==i.assetId&&!i.assetId.trim())throw Error("Image asset id cannot be empty.");return i.crop&&Z(i.crop),Object.assign(a,i),n}function q(e,t){let i=y(e);if(!h.includes(t))throw Error(`Unsupported processing semantic: ${t}.`);return i.processingSemantic=t,i}function D(e,t){let i=y(e);return J(t),i.frame=(0,d.L6)(i.frame,t),i.plans&&(i.plans=i.plans.map(n=>{if("symmetry"!==n.type||1e-8>Math.abs(n.rotation/45-Math.round(n.rotation/45)))return n;let a=n.rotation*Math.PI/180,r=180*Math.atan2(Math.sin(a)*t.height/e.frame.height,Math.cos(a)*t.width/e.frame.width)/Math.PI;return{...n,rotation:Q(r,i.frame)}})),i}function z(e,t){let i=y(e);return i.frame=(0,d.lB)(i.frame,t),i}function B(e,t,i="bottom-right"){let n=y(e);return!Number.isFinite(t)||t<=0||(n.frame=(0,d.m1)(n.frame,t,i)),n}function O(e,t){let i=y(e);return i.frame=(0,d.GN)(i.frame,t),i}function U(e){return(0,l.zS)(y(e))}function J(e){if(!e||"object"!=typeof e||Array.isArray(e))throw Error("draft.frame must be an object.");let t=Object.keys(e).filter(e=>"width"!==e&&"height"!==e&&"bounds"!==e);if(t.length>0)throw Error(`draft.frame contains unknown fields: ${t.join(", ")}.`);for(let t of["width","height"])if(!Number.isInteger(e[t])||e[t]<256||e[t]>4096)throw Error(`draft.frame.${t} must be an integer from 256 to 4096.`);let i=e.width/e.height;if(!(0,d.J2)(e.width,e.height))throw Error("Draft aspect ratio must be between 1:2 and 2:1.");void 0!==e.bounds&&function(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw Error("draft.frame.bounds must be an object.");let i=Object.keys(e).filter(e=>!["x","y","width","height"].includes(e));if(i.length>0)throw Error(`draft.frame.bounds contains unknown fields: ${i.join(", ")}.`);for(let t of["x","y","width","height"])if(!Number.isFinite(e[t]))throw Error(`draft.frame.bounds.${t} must be a finite number.`);let n=e.width,a=e.height;if(n<=0||a<=0)throw Error("draft.frame.bounds width and height must be positive.");if(Math.abs(n*d.cq.width/(a*d.cq.height)-t)>.002)throw Error("draft.frame.bounds must match the frame aspect ratio.")}(e.bounds,i)}function W(){return{...s(),shotScale:"auto"}}function H(e){let t=!e||"object"!=typeof e||Array.isArray(e)?e:{...s(),...e};return!t||"object"!=typeof t||Array.isArray(t)?t:{shotScale:"auto",...t}}function Y(e){let t=H(e);if(!t||"object"!=typeof t||Array.isArray(t))return t;let i={visualWeight:"auto",...t};return i.semanticType!==m||"displayText"in i?i:{...i,displayText:""}}function V(e){let t=H(e);return!t||"object"!=typeof t||Array.isArray(t)?t:{visualWeight:"auto",assetId:null,crop:null,...t}}function X(e,t){let i=e.areas.find(e=>e.id===t);if(!i)throw Error(`Unknown draft area: ${t}.`);return i}function G(e,t){let i=e.images.find(e=>e.id===t);if(!i)throw Error(`Unknown draft image: ${t}.`);return i}function K(e,t){let i=new Set(t.map(e=>e.id)),n=1;for(;i.has(`${e}-${n}`);)n+=1;return`${e}-${n}`}function Z(e){if(e.x+e.width>1+1e-9||e.y+e.height>1+1e-9)throw Error("Image crop must stay inside the source image.")}function Q(e,t){let i=ee(e),n=e=>Math.abs((e-i+540)%360-180);return(0,d.Y8)(t).reduce((e,t)=>n(t)<n(e)?t:e)}function ee(e){return(e%360+360)%360}},53130:(e,t,i)=>{"use strict";i.d(t,{o:()=>h});var n=i(73365),a=i(362),r=i(29717),o=i(99568),s=i.n(o),l=i(1521),d=i(8020),c=i(91093),u=i(60458);let m=[{value:"zh-CN",label:"中文"},{value:"en",label:"EN"}];function h({currentSessionId:e=null,onCurrentSessionRename:t,...i}){let o=(0,r.useRouter)(),{i18n:p,t:g}=(0,d.Bd)(),[f,y]=(0,l.useState)([]),[x,b]=(0,l.useState)([]),[v,w]=(0,l.useState)(!0),[j,k]=(0,l.useState)(null),[I,S]=(0,l.useState)(0);return(0,l.useEffect)(()=>{let e=!1;return w(!0),k(null),Promise.all([(0,u.hF)(),(0,u.GW)()]).then(([t,i])=>{e||(y(t),b(i))}).catch(()=>{e||k(g("workspaceSidebar.loadFailed"))}).finally(()=>{e||w(!1)}),()=>{e=!0}},[I,g]),(0,n.jsx)(a.X3,{...i,brand:(0,n.jsxs)(s(),{href:"/",className:"human2ai-app-shell__brand",children:[(0,n.jsx)("img",{className:"human2ai-app-shell__brand-icon",src:"/brand/h2a.svg",alt:"",width:24,height:24}),g("app.title")]}),labels:{productName:g("app.title"),sidebar:g("shell.sidebar"),navigation:g("shell.navigation"),collapseSidebar:g("shell.collapseSidebar"),expandSidebar:g("shell.expandSidebar"),rightPanel:g("shell.rightPanel"),collapseRightPanel:g("shell.collapseRightPanel"),expandRightPanel:g("shell.expandRightPanel")},sidebar:(0,n.jsx)(a.te,{projects:f,sessions:x,currentSessionId:e,loading:v,errorMessage:j,languageSelector:{"aria-label":g("language.selectorLabel"),onChange:e=>{(0,c.EM)(e)&&p.changeLanguage(e)},options:m,placement:"top",value:(0,c.wl)(p.resolvedLanguage)},labels:{functionArea:g("workspaceSidebar.functionArea"),projectArea:g("workspaceSidebar.projectArea"),newComposition:g("workspaceSidebar.newComposition"),newCompositionInProject:e=>g("workspaceSidebar.newCompositionInProject",{project:e}),newSpatial:g("spatial.newSpace"),newSpatialInProject:e=>g("spatial.newInProject",{project:e}),spatialSession:g("spatial.title"),newUiSketch:g("workspaceSidebar.newUiSketch"),newUiSketchInProject:e=>g("workspaceSidebar.newUiSketchInProject",{project:e}),newProject:g("workspaceSidebar.newProject"),styleLibrary:g("styleLibrary.title"),projectNamePlaceholder:g("workspaceSidebar.projectNamePlaceholder"),createProject:g("actions.create"),unassigned:g("workspaceSidebar.unassigned"),imageCompositionSession:g("workspaceSidebar.imageCompositionSession"),uiLayoutSession:g("workspaceSidebar.uiLayoutSession"),sessionActions:g("workspaceSidebar.sessionActions"),projectActions:g("workspaceSidebar.projectActions"),rename:g("actions.rename"),confirmRename:g("workspaceSidebar.confirmRename"),move:g("actions.move"),moveSessionTitle:g("workspaceSidebar.moveSessionTitle"),selectProject:g("workspaceSidebar.selectProject"),moveUnavailable:g("workspaceSidebar.moveUnavailable"),delete:g("actions.delete"),projectNameConflict:g("workspaceSidebar.projectNameConflict"),renameProjectTitle:g("workspaceSidebar.renameProjectTitle"),deleteProjectTitle:g("workspaceSidebar.deleteProjectTitle"),deleteProjectDescription:g("workspaceSidebar.deleteProjectDescription"),deleteProjectDisabled:g("workspaceSidebar.deleteProjectDisabled"),renameSessionTitle:g("workspaceSidebar.renameSessionTitle"),renameSessionPlaceholder:g("workspaceSidebar.renameSessionPlaceholder"),deleteSessionTitle:g("workspaceSidebar.deleteSessionTitle"),deleteSessionDescription:g("workspaceSidebar.deleteSessionDescription"),cancel:g("actions.cancel"),loading:g("workspaceSidebar.loading"),loadFailed:g("workspaceSidebar.loadFailed"),retry:g("actions.retry"),actionFailed:g("errors.operationFailed")},onCreateComposition:async e=>{let t=await (0,u.$M)(g("composition.session.untitled"),e??null);b(e=>[t,...e]),o.push(`/composition?session=${encodeURIComponent(t.id)}`)},onCreateSpatial:async e=>{let t=await (0,u.DZ)(g("spatial.untitled"),e??null);b(e=>[t,...e]),o.push(`/spatial?session=${encodeURIComponent(t.id)}`)},onCreateUiSketch:async e=>{let t=await (0,u.vh)(g("uiSketch.session.untitled"),e??null);b(e=>[t,...e]),o.push(`/ui-sketch?session=${encodeURIComponent(t.id)}`)},onCreateProject:async e=>{let t=await (0,u.gA)(e);y(e=>[t,...e])},onOpenStyleLibrary:()=>o.push("/styles"),onRenameProject:async(e,t)=>{let i=f.find(t=>t.id===e);if(!i)throw Error("PROJECT_NOT_FOUND");let n=await (0,u.oB)(e,t,i.revision);y(t=>t.map(t=>t.id===e?n:t))},onDeleteProject:async e=>{let t=f.find(t=>t.id===e);if(!t)throw Error("PROJECT_NOT_FOUND");await (0,u.xx)(e,t.revision),y(t=>t.filter(t=>t.id!==e))},onOpenSession:e=>{let t=x.find(t=>t.id===e);if(!t)return;let i="spatial"===t.sessionType?"/spatial":"ui-layout"===t.sessionType?"/ui-sketch":"/composition";o.push(`${i}?session=${encodeURIComponent(e)}`)},onRenameSession:async(i,n)=>{let a=x.find(e=>e.id===i);if(!a)throw Error("SESSION_NOT_FOUND");let r=await (0,u.Fu)(i,n,a.revision);b(e=>e.map(e=>e.id===i?r:e)),e===i&&t?.(r.title)},onMoveSession:async(e,t)=>{let i=x.find(t=>t.id===e);if(!i)throw Error("SESSION_NOT_FOUND");let n=await (0,u.us)(e,t,i.revision);b(t=>t.map(t=>t.id===e?n:t))},onDeleteSession:async t=>{let i=x.find(e=>e.id===t);if(!i)throw Error("SESSION_NOT_FOUND");await (0,u.ME)(t,i.revision),b(e=>e.filter(e=>e.id!==t)),e===t&&o.push("/")},onRetry:()=>S(e=>e+1)})})}},53439:()=>{},54996:(e,t,i)=>{"use strict";i.d(t,{G_:()=>o,UB:()=>s,aY:()=>l,kF:()=>a,r8:()=>r});let n=[{heads:2,softness:1,torso:1.02,torsoDepth:1.5,headDepth:.9,shoulder:.94,hip:1,arm:1.02,forearm:1.08,thigh:1,calf:1.12,hand:1.35,foot:1.5,armLength:.84,handLength:1.2,footLength:1.75,neck:.42},{heads:3,softness:.82,torso:.94,torsoDepth:1.24,headDepth:.94,shoulder:.87,hip:.88,arm:.94,forearm:.96,thigh:.94,calf:1,hand:1.18,foot:1.26,armLength:.92,handLength:1.12,footLength:1.45,neck:.55},{heads:4,softness:.5,torso:.84,torsoDepth:1,headDepth:.94,shoulder:.84,hip:.84,arm:.75,forearm:.78,thigh:.84,calf:.8,hand:.88,foot:.94,armLength:.98,handLength:1.04,footLength:1.08,neck:.72},{heads:7,softness:0,torso:1,torsoDepth:1,headDepth:1,shoulder:1,hip:1,arm:1,forearm:1,thigh:1,calf:1,hand:1,foot:1,armLength:1,handLength:1,footLength:1,neck:1}],a=(e=1)=>1+(e-1)*.5;function r(e){let t=n.findIndex(t=>t.heads>=e);if(0===t)return[0,0,0];if(-1===t)return[3,3,0];let i=(e-n[t-1].heads)/(n[t].heads-n[t-1].heads);return[t-1,t,i*i*(3-2*i)]}function o(e){if(e>7){let t={...n[3]},i=Math.sqrt(7/e);for(let e of["torso","torsoDepth","shoulder","hip","arm","forearm","thigh","calf","hand","foot"])t[e]=i;return t}let[t,i,a]=r(e),o=n[t],s=n[i];return Object.fromEntries(Object.keys(o).map(e=>[e,o[e]+(s[e]-o[e])*a]))}function s(e,t){return t.endsWith("-shoulder")?e.shoulder:t.endsWith("-hip")?e.hip:t.endsWith("-elbow")?e.arm:t.endsWith("-wrist")?e.forearm:t.endsWith("-hand")?e.hand:t.endsWith("-knee")?e.thigh:t.endsWith("-ankle")?e.calf:t.endsWith("-foot")?e.foot:e.torso}let l={neckLength:{min:.6,max:1.4},palmSize:{min:.7,max:1.3},fingerLength:{min:.6,max:1.4},footSize:{min:.7,max:1.4}}},58206:()=>{},59793:(e,t,i)=>{"use strict";i.d(t,{Ib:()=>d,KZ:()=>c,PX:()=>p,fQ:()=>l,uK:()=>m,wG:()=>u,yU:()=>h});var n=i(33949),a=i(52582),r=i(34345);function o(e){return{...e.plans?{plans:structuredClone(e.plans)}:{},frame:{width:e.frame.width,height:e.frame.height,bounds:{x:e.frame.bounds.x,y:e.frame.bounds.y,width:e.frame.bounds.width,height:e.frame.bounds.height}},layerOrder:(0,r.u)(e),focusPoints:e.focusPoints.map(({id:e,x:t,y:i})=>({id:e,x:t,y:i})),directionLine:e.directionLine?(({id:e,x:t,y:i,rotation:n})=>({id:e,x:t,y:i,rotation:n}))(e.directionLine):null,areas:e.areas.map(({id:e,x:t,y:i,area:n,aspect:a,rotation:r,width:o,height:s,corners:l})=>({id:e,x:t,y:i,area:n,aspect:a,rotation:r,width:o,height:s,...l?{corners:structuredClone(l)}:{}})),images:e.images.map(({id:e,x:t,y:i,width:n,height:a,rotation:r})=>({id:e,x:t,y:i,width:n,height:a,rotation:r}))}}function s(e,t){let{plans:i,...n}=e,a=new Map(t.focusPoints.map(e=>[e.id,e])),r=new Map(t.areas.map(e=>[e.id,e])),o=new Map(t.images.map(e=>[e.id,e]));return{...n,...t.plans?{plans:structuredClone(t.plans)}:{},frame:structuredClone(t.frame),layerOrder:[...t.layerOrder],focusPoints:e.focusPoints.map(e=>({...e,...a.get(e.id)})),directionLine:e.directionLine?{...e.directionLine,...t.directionLine}:null,areas:e.areas.map(e=>{let t=r.get(e.id);if(!t)return{...e};let{x:i,y:n,area:a,aspect:o,rotation:s,width:l,height:d,corners:c,...u}=e;return{...u,...t}}),images:e.images.map(e=>({...e,...o.get(e.id)}))}}function l(e){return e.states??[{id:"state-1",number:1,layout:o(e)}]}function d(e){if(!e.states)return e;let{states:t,activeStateId:i,...n}=e;if(!t.some(e=>e.id===i))throw Error("Unknown active composition state.");if(new Set(t.map(({id:e})=>e)).size!==t.length||new Set(t.map(({number:e})=>e)).size!==t.length)throw Error("Composition state ids and numbers must be unique.");return e.states=t.map(e=>{if(void 0!==e.name&&!e.name.trim())throw Error("Composition state name must not be blank.");for(let t of[e.layout.focusPoints,e.layout.areas,e.layout.images])if(new Set(t.map(({id:e})=>e)).size!==t.length)throw Error("Duplicate composition state node id.");let t=(0,a.M6)(s(n,e.layout));return{...e,...void 0!==e.name?{name:e.name.trim()}:{},layout:o(e.id===i?n:t)}}),e}function c(e,t){let i=(0,a.M6)(e),n=l(i),r=n.find(e=>e.id===t);if(!r)throw Error(`Unknown composition state: ${t}.`);return(i.activeStateId??"state-1")===t?i:(0,a.M6)({...s(i,r.layout),states:n,activeStateId:t})}function u(e,t,i){let n=(0,a.M6)(e),r=[...l(n)],o=r.findIndex(e=>e.id===t);if(o<0||r.some(e=>e.id===i))throw Error("Invalid composition state source or new id.");let d={id:i,number:Math.max(...r.map(e=>e.number))+1,layout:structuredClone(r[o].layout)};return r.splice(o+1,0,d),(0,a.M6)({...s(n,d.layout),states:r,activeStateId:i})}function m(e,t,i){let r=(0,a.M6)(e);return{...r,activeStateId:r.activeStateId??"state-1",states:(0,n.UR)(l(r),t,i)}}function h(e,t){let i=(0,a.M6)(e);return{...i,activeStateId:i.activeStateId??"state-1",states:(0,n.kq)(l(i),t)}}function p(e,t){let i=(0,a.M6)(e),r=(0,n.aD)(l(i),t),o=l(i).findIndex(e=>e.id===t);return{...i.activeStateId===t?c(i,r[Math.max(0,o-1)].id):i,states:r}}},60458:(e,t,i)=>{"use strict";i.d(t,{$M:()=>r,DZ:()=>q,FX:()=>A,Fu:()=>k,GW:()=>u,Ht:()=>a,J_:()=>U,Jx:()=>h,ME:()=>I,MT:()=>N,MZ:()=>L,Nr:()=>g,Pf:()=>x,T8:()=>w,VQ:()=>M,X0:()=>m,YM:()=>v,aU:()=>y,dH:()=>C,gA:()=>l,g_:()=>f,gk:()=>J,hF:()=>s,hU:()=>P,he:()=>S,n8:()=>D,nn:()=>p,oB:()=>d,qz:()=>W,rO:()=>B,ul:()=>O,us:()=>j,vh:()=>o,wP:()=>n,x:()=>b,xx:()=>c,zV:()=>z});class n extends Error{constructor(e,t,i,n={}){super(t),this.code=e,this.status=i,this.details=n,this.name="Human2AiApiError"}}function a(e,t=globalThis.fetch){return T(`/api/v1/sessions/${encodeURIComponent(e)}`,{},t)}function r(e,t=null,i=globalThis.fetch){return T("/api/v1/sessions",{method:"POST",body:JSON.stringify({sessionType:"image-composition",title:e,...t?{projectId:t}:{}})},i)}function o(e,t=null,i=globalThis.fetch){return T("/api/v1/sessions",{method:"POST",body:JSON.stringify({sessionType:"ui-layout",title:e,...t?{projectId:t}:{}})},i)}async function s(e=globalThis.fetch){return(await T("/api/v1/projects",{},e)).projects}function l(e,t=globalThis.fetch){return T("/api/v1/projects",{method:"POST",body:JSON.stringify({name:e})},t)}function d(e,t,i,n=globalThis.fetch){return T(`/api/v1/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({name:t,expectedRevision:i})},n)}async function c(e,t,i=globalThis.fetch){await R(`/api/v1/projects/${encodeURIComponent(e)}`,{method:"DELETE",body:JSON.stringify({expectedRevision:t})},i)}async function u(e=globalThis.fetch){return(await T("/api/v1/sessions",{},e)).sessions}async function m(e=globalThis.fetch){return(await T("/api/v1/styles",{},e)).styles}function h(e,t=globalThis.fetch){return T("/api/v1/styles",{method:"POST",body:JSON.stringify(e)},t)}function p(e,t,i=globalThis.fetch){return T(`/api/v1/styles/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)},i)}async function g(e,t,i=globalThis.fetch){await R(`/api/v1/styles/${encodeURIComponent(e)}`,{method:"DELETE",body:JSON.stringify({expectedRevision:t})},i)}function f(e,t,i,n=globalThis.fetch){return T(`/api/v1/styles/${encodeURIComponent(e)}/references?filename=${encodeURIComponent(t.name)}&expectedRevision=${i}`,{method:"POST",headers:{"content-type":t.type||"application/octet-stream"},body:t},n)}function y(e,t,i,n=globalThis.fetch){return T(`/api/v1/styles/${encodeURIComponent(e)}/references/${encodeURIComponent(t)}`,{method:"DELETE",body:JSON.stringify({expectedRevision:i})},n)}function x(e,t){let i=`/api/v1/styles/${encodeURIComponent(e)}/references/${encodeURIComponent(t)}/content`;return void 0===globalThis.location?i:new URL(i,globalThis.location.origin).toString()}function b(e,t){return`/api/v1/styles/${encodeURIComponent(e)}/models/${encodeURIComponent(t)}/content`}function v(e,t=globalThis.fetch){return T(`/api/v1/sessions/${encodeURIComponent(e)}/style`,{},t)}function w(e,t,i,n=globalThis.fetch){return T(`/api/v1/sessions/${encodeURIComponent(e)}/style`,{method:"PATCH",body:JSON.stringify({styleId:t,expectedRevision:i})},n)}function j(e,t,i,n=globalThis.fetch){return T(`/api/v1/sessions/${encodeURIComponent(e)}/project`,{method:"PATCH",body:JSON.stringify({projectId:t,expectedRevision:i})},n)}function k(e,t,i,n=globalThis.fetch){return T(`/api/v1/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({title:t,expectedRevision:i})},n)}async function I(e,t,i=globalThis.fetch){await R(`/api/v1/sessions/${encodeURIComponent(e)}`,{method:"DELETE",body:JSON.stringify({expectedRevision:t})},i)}async function S(e,t=globalThis.fetch){return $(e,"composition",t)}function P(e,t,i,n=globalThis.fetch){return F(e,"composition",t,i,n)}async function C(e,t=globalThis.fetch){return $(e,"ui-sketch",t)}function M(e,t,i,n=globalThis.fetch){return F(e,"ui-sketch",t,i,n)}function A(e,t,i=globalThis.fetch){return T(`/api/v1/sessions/${encodeURIComponent(e)}/assets?filename=${encodeURIComponent(t.name)}`,{method:"POST",headers:{"content-type":t.type||"application/octet-stream"},body:t},i)}function L(e,t){let i=`/api/v1/sessions/${encodeURIComponent(e)}/assets/${encodeURIComponent(t)}/content`;return void 0===globalThis.location?i:new URL(i,globalThis.location.origin).toString()}async function N(e,t=globalThis.fetch){let i=await t(e);if(!i.ok)throw Error(`Image content request failed: ${i.status}`);let n=i.headers.get("content-type")?.split(";")[0].trim()??"",a={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/svg+xml":"svg"}[n];if(!a)throw Error(`Unsupported image content type: ${n}`);return new File([await i.blob()],`image.${a}`,{type:n})}async function $(e,t,i){return(await T(_(e,t),{},i)).draftVersions}function F(e,t,i,n,a){return T(_(e,t),{method:"POST",body:JSON.stringify({expectedLatestRevision:i,draft:n})},a)}function _(e,t){return`/api/v1/sessions/${encodeURIComponent(e)}/${t}/drafts`}async function T(e,t,i){let n=await R(e,t,i);return await E(n)}async function R(e,t,i){let a=await i(e,{...t,cache:"no-store",headers:void 0===t.body?t.headers:t.headers??{"content-type":"application/json"}});if(!a.ok){var r;let e=await E(a),t=(r=e)&&"object"==typeof r&&!Array.isArray(r)?e:{};throw new n("string"==typeof t.code?t.code:`HTTP_${a.status}`,"string"==typeof t.message?t.message:`Human2AI request failed with HTTP ${a.status}`,a.status,Object.fromEntries(Object.entries(t).filter(([e])=>"code"!==e&&"message"!==e)))}return a}async function E(e){try{return await e.json()}catch{throw new n("INVALID_SERVICE_RESPONSE",`Human2AI returned invalid JSON with HTTP ${e.status}`,e.status)}}function q(e,t=null,i=globalThis.fetch){return T("/api/v1/sessions",{method:"POST",body:JSON.stringify({sessionType:"spatial",title:e,projectId:t})},i)}function D(e,t=globalThis.fetch){return $(e,"spatial",t)}async function z(e,t=0,i=globalThis.fetch){return(await T(`/api/v1/sessions/${encodeURIComponent(e)}/spatial/drafts/latest?knownRevision=${t}`,{},i)).draftVersion}function B(e,t,i,n=globalThis.fetch){return F(e,"spatial",t,i,n)}function O(e,t,i,n=globalThis.fetch){return T(`/api/v1/sessions/${encodeURIComponent(e)}/spatial/drafts/restore`,{method:"POST",body:JSON.stringify({expectedLatestRevision:t,targetRevision:i})},n)}function U(e,t,i,n="color"){let a=new URLSearchParams;return a.set("renderer","8"),i&&a.set("revision",String(i)),"color"!==n&&a.set("pass",n),`/api/v1/sessions/${encodeURIComponent(e)}/spatial/cameras/${encodeURIComponent(t)}.png${a.size?`?${a}`:""}`}function J(e,t,i,n="sheet",a="color"){let r=new URLSearchParams({renderer:"4",revision:String(i),view:n,pass:a});return`/api/v1/sessions/${encodeURIComponent(e)}/spatial/camera-boxes/${encodeURIComponent(t)}.png?${r}`}function W(e,t,i,n=globalThis.fetch){return T(`/api/v1/sessions/${encodeURIComponent(e)}/spatial/operations`,{method:"POST",body:JSON.stringify({expectedLatestRevision:t,operations:i})},n)}},61176:()=>{},63159:()=>{},67282:(e,t,i)=>{"use strict";i.d(t,{x:()=>s});var n=i(73365),a=i(76191),r=i(35659);i(22392),i(12853);var o=i(46811);function s({title:e,description:t,children:i,onConfirm:l,confirmLabel:d="确认",cancelLabel:c="取消",scopeLabel:u,danger:m=!0,...h}){return(0,n.jsx)(a.A,{title:e,description:u||t?(0,n.jsxs)("div",{className:"yisi-confirm-action-description",children:[u?(0,n.jsx)("strong",{children:u}):null,t?(0,n.jsx)("span",{children:t}):null]}):void 0,okText:d,cancelText:c,okButtonProps:{danger:m},onConfirm:l,children:(0,n.jsx)(r.Ay,{...h,...(0,o.S)("confirm-action","ConfirmAction","action-pattern"),danger:m,children:i})})}},68071:()=>{},68743:()=>{},71180:()=>{},73251:()=>{},76109:(e,t,i)=>{"use strict";i.d(t,{EN:()=>a,JX:()=>n,jQ:()=>o,qP:()=>r});let n=["bringToFront","bringForward","sendBackward","sendToBack"];function a(e,t){let i=new Set(e),n=[];for(let e of t??[])i.delete(e)&&n.push(e);return[...n,...i]}function r(e,t,i){let n=new Set(t),a=[...e];if("bringToFront"===i||"sendToBack"===i){let t=e.filter(e=>n.has(e)),r=e.filter(e=>!n.has(e));a="bringToFront"===i?[...r,...t]:[...t,...r]}else if("bringForward"===i)for(let e=a.length-2;e>=0;e-=1)n.has(a[e])&&!n.has(a[e+1])&&([a[e],a[e+1]]=[a[e+1],a[e]]);else for(let e=1;e<a.length;e+=1)n.has(a[e])&&!n.has(a[e-1])&&([a[e],a[e-1]]=[a[e-1],a[e]]);return a.every((t,i)=>t===e[i])?e:a}function o(e,t,i){let n=new Map(e.map(e=>[i(e),e]));return a([...n.keys()],t).map(e=>n.get(e))}},78226:()=>{},80118:()=>{},88307:()=>{},89448:()=>{},93878:()=>{},94560:()=>{},95948:(e,t,i)=>{"use strict";i.d(t,{G:()=>o});var n=i(73365),a=i(87340);i(22392),i(93878);var r=i(46811);function o({label:e,rows:t=4,compact:i=!1,motion:s="auto",className:l,style:d}){let c=Number.isFinite(t)?Math.min(12,Math.max(1,Math.trunc(t))):4;return(0,n.jsxs)("section",{...(0,r.S)("loading-state","LoadingState"),className:["yisi-loading-state",i?"yisi-loading-state-compact":null,l].filter(Boolean).join(" "),"data-density":i?"compact":"default","data-motion":s,"aria-busy":"true","aria-label":e,style:d,children:[(0,n.jsx)("span",{className:"yisi-loading-state-announcement",role:"status","aria-live":"polite",children:e}),(0,n.jsx)("div",{className:"yisi-loading-state-skeleton","aria-hidden":"true",children:(0,n.jsx)(a.A,{active:"auto"===s,paragraph:{rows:c},title:{width:"42%"}})})]})}},96826:(e,t,i)=>{"use strict";i.d(t,{d:()=>y,m:()=>f});var n=i(84910),a=i(5105),r=i(52798),o=i(12399),s=i(54996),l=i(18989),d=i(29169),c=i(17340),u=i(77902);let m=new n.Pq0(0,1,0),h=Object.fromEntries(Object.entries({male:a,female:r}).map(([e,t])=>{let i=t.parts.map(e=>{let t=new n.Pq0(...e.start),i=new n.Pq0(...e.end).sub(t);return{length:i.length(),inverse:new n.kn4().compose(t,new n.PTz().setFromUnitVectors(m,i.normalize()),new n.Pq0(1,1,1)).invert()}}),a=t.modules.map(e=>{let i=[...new Set(e.indices)],n=new Map(i.map((e,t)=>[e,t]));return{...e,vertices:i,indices:e.indices.map(e=>n.get(e)),normalKeys:i.map(e=>t.positions.slice(3*e,3*e+3).join(","))}});return[e,{asset:t,modules:a,targets:(0,l.F)(t),sourceFrames:i,sourceBodyHeight:t.height-i[t.parts.findIndex(e=>"head"===e.id)].length}]})),p=new WeakMap,g=e=>JSON.stringify([e.id,e.appearance,e.bodyType??"male",e.bones.map(e=>[e.id,e.modelPart])]);function f(e,t){let i=p.get(e);return!!i&&"geometric"!==t.appearance&&i.key===g(t)&&(x(t,e,i),!0)}function y(e,t={}){if("geometric"===e.appearance)return(0,u.s)(e);let i=new n.YJl,a={key:g(e),handCreases:t.handCreases??!0,parts:[]};return p.set(i,a),x(e,i,a),i}function x(e,t,i){let a,r=i.handCreases,l=i.headRatio!==e.headRatio,{asset:u,modules:p,targets:g,sourceFrames:f,sourceBodyHeight:y}=h[e.bodyType??"male"],x=(0,o.ms)(e),b=e.height/u.height,v=(0,s.G_)(e.headRatio),[w,j,k]=(0,s.r8)(e.headRatio),I=new Map,S=[],P=(t,i)=>{let a,r=`${t?.id??"root"}/${i}`;if(I.has(r))return I.get(r);let l=f[i],c=u.parts[i],h=b*(0,s.UB)(v,c.id)*(c.id.endsWith("-hand")?e.palmSize??1:1),p=t?x[t.startJointId].position:(0,o.i1)(e.position),g=e.joints.find(e=>e.id===(t?.endJointId??"spine")),w=g?(0,o.p)(e,g):new n.Pq0(0,l.length*b,0),j=c.id.endsWith("-foot")?e.footSize??1:1,k=(0,s.kF)(j);w.x/=j,w.y/=k,w.z/=j;let S=w.length()/l.length,P="head"===c.id?S:h,C=t?x[t.endJointId].rotation.clone():(0,o.b5)(e.rotation),M=t&&(0,d.dS)(c.id)?(0,d.oT)(e,t):void 0;if(M)a=new n.kn4().compose(p,C,new n.Pq0(1,1,1)).multiply((0,d.PA)(e,M,c.id)).multiply(new n.kn4().makeTranslation(-c.start[0],-c.start[1],-c.start[2]));else if(["pelvis","spine","chest","neck"].includes(c.id)||/-(shoulder|hip)$/.test(c.id)){let t=(0,o.i1)(c.end).sub((0,o.i1)(c.start)),i=Math.abs(t.y)>1e-4?w.y/t.y:(e.height-e.height/e.headRatio)/y,r=new n.Pq0(h,i,b*v.torsoDepth),s=C.clone().multiply(new n.PTz().setFromUnitVectors(t.clone().multiply(r).normalize(),w.clone().normalize())),l=new n.kn4().makeTranslation(-c.start[0],-c.start[1],-c.start[2]);a=new n.kn4().compose(p,s,r).multiply(l);let d=g&&(0,o.i1)(g.offset).normalize().dot(t.clone().normalize())>1-1e-6;if(v.softness>0&&d&&["pelvis","spine","chest","neck"].includes(c.id)){let e=new n.kn4().set(r.x,(w.x-t.x*r.x)/t.y,0,0,0,r.y,0,0,0,(w.z-t.z*r.z)/t.y,r.z,0,0,0,0,1),i=new n.kn4().compose(p,C,new n.Pq0(1,1,1)).multiply(e).multiply(l);a.elements.forEach((e,t)=>{a.elements[t]=e+(i.elements[t]-e)*v.softness})}}else{let e=C.clone().multiply(new n.PTz().setFromUnitVectors(m,w.clone().normalize()));if(a=new n.kn4().compose(p,e,new n.Pq0(P,S,"head"===c.id?P*v.headDepth:P)).multiply(l.inverse),c.id.endsWith("-foot")&&v.softness>0){let e=(0,o.i1)(c.end).sub((0,o.i1)(c.start)),t=new n.Pq0(h,w.y/e.y,w.z/e.z);C.multiply(new n.PTz().setFromUnitVectors(e.multiply(t).normalize(),w.clone().normalize()));let i=new n.kn4().compose(p,C,t).multiply(new n.kn4().makeTranslation(-c.start[0],-c.start[1],-c.start[2]));a.elements.forEach((e,t)=>{a.elements[t]=e+(i.elements[t]-e)*v.softness})}}if(1!==j){let i=new n.kn4().compose(p,t?x[t.endJointId].rotation:(0,o.b5)(e.rotation),new n.Pq0(1,1,1));a.premultiply(i.clone().multiply(new n.kn4().makeScale(j,k,j)).multiply(i.invert()))}return I.set(r,a),a},C=new Map(e.bones.filter(e=>e.id===e.modelPart).map(e=>[e.modelPart,e])),M=0,A=[],L=(t,o)=>{let s=o&&o.id.endsWith(o.modelPart)?o.id.slice(0,-o.modelPart.length):"",d=!!(o&&o.id!==o.modelPart),m=!d&&a?a:u.parts.map((i,n)=>{let a=d?e.bones.find(e=>e.id===`${s}${i.id}`):C.get(i.id);return a?P(a,n):d&&o?P(o,t.part):P(void 0,n)});d||(a=m);let{vertices:h}=t,p=i.parts[M++];if(!p){let a=new n.LoY().setAttribute("position",new n.qtW(3*h.length,3));a.setIndex(t.indices);let r=new n.eaF(a,new n.G_z({side:n.$EB}));r.userData={characterId:e.id,...o?{boneId:o.id}:{},modelPart:u.parts[t.part].id},p={mesh:r,rest:new Float64Array(3*h.length),posed:new Float64Array(3*h.length),segments:[]},i.parts.push(p)}let{mesh:f,rest:y,posed:x}=p,b=f.geometry,I=new n.Pq0,L=new n.Pq0,N=new n.Pq0;for(let e=0;e<h.length;e++){let t=h[e],i=3*t,n=g[w],a=g[j];l&&(y[3*e]=n[i]+(a[i]-n[i])*k,y[3*e+1]=n[i+1]+(a[i+1]-n[i+1])*k,y[3*e+2]=n[i+2]+(a[i+2]-n[i+2])*k),N.fromArray(y,3*e),I.set(0,0,0);let r=0;for(let e=0;e<4;e++){let i=u.weights[4*t+e];i&&(L.copy(N).applyMatrix4(m[u.influences[4*t+e]]),I.addScaledVector(L,i),r+=i)}I.divideScalar(r),x[3*e]=I.x,x[3*e+1]=I.y,x[3*e+2]=I.z}let $=b.getAttribute("position");$.array.set(x),$.needsUpdate=!0,b.boundingBox=null,b.boundingSphere=null,b.computeVertexNormals(),"body"===t.material&&v.softness>0&&S.push({geometry:b,keys:t.normalKeys.map(e=>`${s}/${e}`)});let F=new n.Q1f("brows"===t.material?"#514235":"eyes"===t.material?"#e7ded1":e.color),_=(w<2?1-k:0)+(j<2?k:0);if("brows"===t.material&&F.lerp(new n.Q1f(e.color),.9*_),"eyes"===t.material&&F.lerp(new n.Q1f("#514235"),_),f.material.color.copy(F),A.push(f),r){l&&(p.segments=(0,c.xQ)(e,u.parts[t.part].id,y,t.indices));let i=(0,c.HK)(e,p.segments,x,p.creases);!i&&p.creases&&(p.creases.geometry.dispose(),p.creases.material.dispose(),p.creases=void 0,f.material.polygonOffset=!1),i&&(f.material.polygonOffset=!0,f.material.polygonOffsetFactor=1,f.material.polygonOffsetUnits=1,i.userData={...f.userData,reference:"finger-crease"},A.push(i),p.creases=i)}};for(let t of p){let i=u.parts[t.part].id;if("pelvis"===i)L(t);else for(let n of e.bones.filter(e=>e.modelPart===i))L(t,n)}let N=new Map,$=new n.Pq0,F=new n.Pq0,_=new n.Pq0;for(let{geometry:e,keys:t}of S){let i=e.getAttribute("position"),a=e.index;for(let e=0;e<a.count;e+=3){let r=[a.getX(e),a.getX(e+1),a.getX(e+2)];$.fromBufferAttribute(i,r[0]),F.fromBufferAttribute(i,r[1]),_.fromBufferAttribute(i,r[2]);let o=F.sub($).cross(_.sub($));for(let e of r){let i=t[e];N.has(i)||N.set(i,new n.Pq0),N.get(i).add(o)}}}for(let e of N.values())e.normalize();for(let{geometry:e,keys:t}of S){let i=e.getAttribute("normal");t.forEach((e,t)=>{$.fromBufferAttribute(i,t).lerp(N.get(e),v.softness).normalize(),i.setXYZ(t,$.x,$.y,$.z)})}(t.children.length!==A.length||A.some((e,i)=>t.children[i]!==e))&&(t.clear(),A.length&&t.add(...A)),i.headRatio=e.headRatio}},98151:()=>{},98852:()=>{},99791:(e,t,i)=>{"use strict";i.d(t,{L:()=>n});let n={"color.brand.primary":"#1677FF","color.brand.primaryHover":"#4096FF","color.brand.primaryActive":"#0958D9","color.brand.onPrimary":"#FFFFFF","color.neutral.0":"#FFFFFF","color.neutral.25":"#FCFDFE","color.neutral.50":"#FBFCFE","color.neutral.100":"#F4F6FB","color.neutral.200":"#EEF1F6","color.neutral.300":"#E8E8E8","color.neutral.400":"#D9E1EC","color.neutral.500":"#B8C4D2","color.neutral.600":"#6B7280","color.neutral.700":"#4B5563","color.neutral.800":"#344054","color.neutral.900":"#1F1F1F","color.paper.natural":"#F2E3C4","color.paper.sage":"#B9CA8B","color.paper.amber":"#E4B653","color.paper.rose":"#DC938B","color.paper.slate":"#98A9B0","color.paper.sky":"#87C3CC","color.paper.lavender":"#B79BC8","color.paper.clay":"#C9825D","color.status.success":"#237804","color.status.successBg":"#F6FFED","color.status.warning":"#AD4E00","color.status.warningBg":"#FFF7E6","color.status.danger":"#CF1322","color.status.dangerBg":"#FFF1F0","color.status.info":"#0958D9","color.status.infoBg":"#F0F7FF","color.status.processing":"#1677FF","color.status.processingBg":"#E6F4FF","font.family.sans":"-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif","font.family.mono":"SFMono-Regular, ui-monospace, Menlo, Monaco, Consolas, Liberation Mono, monospace","font.size.2xs":"11px","font.size.xs":"12px","font.size.sm":"13px","font.size.md":"14px","font.size.lg":"16px","font.size.xl":"20px","font.size.2xl":"24px","font.size.reading":"15px","font.size.display":"28px","font.weight.regular":400,"font.weight.medium":500,"font.weight.semibold":600,"font.weight.bold":700,"font.lineHeight.tight":1.2,"font.lineHeight.compact":1.35,"font.lineHeight.normal":1.6,"font.lineHeight.reading":1.9,"font.letterSpacing.normal":"0em","font.letterSpacing.label":"0.04em","font.variantNumeric.tabular":"tabular-nums","space.0":"0px","space.1":"4px","space.2":"8px","space.3":"12px","space.4":"16px","space.5":"20px","space.6":"24px","space.8":"32px","space.10":"40px","radius.sm":"6px","radius.md":"8px","radius.lg":"10px","radius.full":"9999px","shadow.panel":"0 16px 48px rgba(15, 23, 42, 0.06)","shadow.card":"0 4px 12px rgba(15, 23, 42, 0.04)","shadow.raised":"0 12px 30px rgba(15, 23, 42, 0.12)","motion.fast":"120ms","motion.normal":"180ms","motion.slow":"240ms","color.text.primary":"#1F1F1F","color.text.secondary":"#4B5563","color.text.muted":"#6B7280","color.text.hint":"#6B7280","color.text.placeholder":"#6B7280","color.text.disabled":"#B8C4D2","color.text.inverse":"#FFFFFF","color.text.onPrimary":"#FFFFFF","color.border.default":"#E8E8E8","color.border.subtle":"#EEF1F6","color.border.interactive":"#1677FF","color.border.hover":"#D9E1EC","color.border.focus":"#1677FF","color.border.disabled":"#EEF1F6","color.border.error":"#CF1322","color.border.warning":"#AD4E00","color.border.success":"#237804","color.surface.page":"#F4F6FB","color.surface.panel":"#FFFFFF","color.surface.soft":"#FBFCFE","color.surface.code":"#F6F8FA","color.surface.hover":"#FBFCFE","color.surface.selected":"#F0F7FF","color.surface.active":"#E6F4FF","color.surface.disabled":"#F4F6FB","color.surface.overlay":"rgba(15,23,42,0.45)","color.action.primary":"#1677FF","color.action.primaryHover":"#4096FF","color.action.primaryActive":"#0958D9","color.action.secondaryHover":"#FBFCFE","color.action.secondaryActive":"#F0F7FF","color.action.link":"#1677FF","color.action.linkHover":"#4096FF","color.action.linkActive":"#0958D9","color.feedback.success":"#237804","color.feedback.successBg":"#F6FFED","color.feedback.warning":"#AD4E00","color.feedback.warningBg":"#FFF7E6","color.feedback.danger":"#CF1322","color.feedback.dangerBg":"#FFF1F0","color.feedback.error":"#CF1322","color.feedback.errorBg":"#FFF1F0","color.feedback.info":"#0958D9","color.feedback.infoBg":"#F0F7FF","color.feedback.processing":"#1677FF","color.feedback.processingBg":"#E6F4FF","color.selection.background":"#F0F7FF","color.selection.text":"#0958D9","typography.pageTitle.fontFamily":"-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif","typography.pageTitle.fontSize":"28px","typography.pageTitle.fontWeight":700,"typography.pageTitle.lineHeight":1.2,"typography.pageTitle.letterSpacing":"0em","typography.sectionTitle.fontFamily":"-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif","typography.sectionTitle.fontSize":"20px","typography.sectionTitle.fontWeight":600,"typography.sectionTitle.lineHeight":1.2,"typography.sectionTitle.letterSpacing":"0em","typography.cardTitle.fontFamily":"-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif","typography.cardTitle.fontSize":"16px","typography.cardTitle.fontWeight":600,"typography.cardTitle.lineHeight":1.2,"typography.cardTitle.letterSpacing":"0em","typography.body.fontFamily":"-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif","typography.body.fontSize":"14px","typography.body.fontWeight":400,"typography.body.lineHeight":1.6,"typography.body.letterSpacing":"0em","typography.bodyStrong.fontFamily":"-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif","typography.bodyStrong.fontSize":"14px","typography.bodyStrong.fontWeight":600,"typography.bodyStrong.lineHeight":1.6,"typography.bodyStrong.letterSpacing":"0em","typography.bodySmall.fontFamily":"-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif","typography.bodySmall.fontSize":"13px","typography.bodySmall.fontWeight":400,"typography.bodySmall.lineHeight":1.35,"typography.bodySmall.letterSpacing":"0em","typography.label.fontFamily":"-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif","typography.label.fontSize":"12px","typography.label.fontWeight":600,"typography.label.lineHeight":1.35,"typography.label.letterSpacing":"0em","typography.kicker.fontFamily":"-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif","typography.kicker.fontSize":"11px","typography.kicker.fontWeight":600,"typography.kicker.lineHeight":1.35,"typography.kicker.letterSpacing":"0.04em","typography.status.fontFamily":"-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif","typography.status.fontSize":"11px","typography.status.lineHeight":1.35,"typography.status.letterSpacing":"0em","typography.button.fontFamily":"-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif","typography.button.fontSize":"14px","typography.button.fontWeight":500,"typography.button.lineHeight":1.35,"typography.button.letterSpacing":"0em","typography.meta.fontFamily":"-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif","typography.meta.fontSize":"12px","typography.meta.fontWeight":400,"typography.meta.lineHeight":1.35,"typography.meta.letterSpacing":"0em","typography.reading.fontFamily":"-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif","typography.reading.fontSize":"15px","typography.reading.fontWeight":400,"typography.reading.lineHeight":1.9,"typography.reading.letterSpacing":"0em","typography.code.fontFamily":"SFMono-Regular, ui-monospace, Menlo, Monaco, Consolas, Liberation Mono, monospace","typography.code.fontSize":"12px","typography.code.fontWeight":400,"typography.code.lineHeight":1.6,"typography.code.letterSpacing":"0em","typography.numeric.fontFamily":"-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif","typography.numeric.fontSize":"24px","typography.numeric.fontWeight":700,"typography.numeric.lineHeight":1.2,"typography.numeric.letterSpacing":"0em","typography.numeric.fontVariantNumeric":"tabular-nums","theme.light.page":"#F4F6FB","theme.light.panel":"#FFFFFF","theme.light.text":"#1F1F1F","theme.dark.page":"#141414","theme.dark.panel":"#1F1F1F","theme.dark.text":"#F5F5F5","motion.textSpeed.slow":.6,"motion.textSpeed.medium":1,"motion.textSpeed.fast":1.6,"surface.desktopWeb.pageBackground":"#F4F6FB","surface.desktopWeb.contentBackground":"#FFFFFF","surface.desktopWeb.sidebarWidth":"280px","surface.desktopWeb.contentMaxWidth":"1400px","surface.desktopWeb.pagePadding":"24px","surface.desktopWeb.sectionGap":"20px","surface.desktopWeb.panelPadding":"24px","component.button.height":"36px","component.button.radius":"8px","component.button.horizontalPadding":"14px","component.input.height":"36px","component.input.radius":"8px","component.card.radius":"8px","component.card.padding":"20px","component.card.shadow":"0 4px 12px rgba(15, 23, 42, 0.04)","component.statusLight.background":"#303030","component.statusLight.green":"#52C41A","component.statusLight.yellow":"#FADB14","component.statusLight.yellowOnLight":"#D0A003","component.statusLight.red":"#FF4D4F","component.borderScan.color":"#4096FF","component.borderScan.duration":"3200ms","component.borderScan.lineWidth":"3px","component.textShine.color":"#FFFFFF","component.textShine.beamWidth":"216px","component.textShine.beamAngle":"105deg","component.textShine.baseVelocity":96,"component.writingAgent.main":"#1677FF","component.writingAgent.logic":"#722ED1","component.writingAgent.draft":"#08979C","component.writingAgent.annotation":"#C41D7F","component.writingAgent.support":"#6B7280","component.contentGraph.node.actorFill":"#EAF4FF","component.contentGraph.node.actorStroke":"#1677FF","component.contentGraph.node.actorText":"#0958D9","component.contentGraph.node.eventFill":"#F6FFED","component.contentGraph.node.eventStroke":"#389E0D","component.contentGraph.node.eventText":"#135200","component.contentGraph.node.conflictFill":"#FFF7E6","component.contentGraph.node.conflictStroke":"#D46B08","component.contentGraph.node.conflictText":"#873800","component.contentGraph.node.knowledgeFill":"#E6FFFB","component.contentGraph.node.knowledgeStroke":"#08979C","component.contentGraph.node.knowledgeText":"#006D75","component.contentGraph.node.ruleFill":"#F9F0FF","component.contentGraph.node.ruleStroke":"#722ED1","component.contentGraph.node.ruleText":"#391085","component.contentGraph.node.skeletonFill":"#F5F5F5","component.contentGraph.node.skeletonStroke":"#8C8C8C","component.contentGraph.node.skeletonText":"#434343","component.contentGraph.node.defaultFill":"#FBFCFE","component.contentGraph.node.defaultStroke":"#8B9BAE","component.contentGraph.node.defaultText":"#1F1F1F","component.contentGraph.edge.causal":"#D46B08","component.contentGraph.edge.conflict":"#CF1322","component.contentGraph.edge.state":"#13A8A8","component.contentGraph.edge.evidence":"#389E0D","component.contentGraph.edge.reader":"#722ED1","component.contentGraph.edge.timeline":"#8C8C8C","component.contentGraph.edge.default":"#7A8CA3","component.contentGraph.label.text":"#4B5563","component.contentGraph.label.background":"rgba(255,255,255,0.92)","component.contentGraph.label.border":"rgba(122,140,163,0.32)","component.contentGraph.selection":"#1677FF","component.focus.outline":"#1677FF","component.focus.outlineWidth":"2px"}}}]);
|