human2ai 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/dist/domain/composition/draft.js +1 -1
  4. package/dist/domain/composition/draft.js.map +1 -1
  5. package/locales/en/common.json +13 -2
  6. package/package.json +1 -1
  7. package/skills/human2ai/SKILL.md +1 -1
  8. package/web/out/404/index.html +1 -1
  9. package/web/out/404.html +1 -1
  10. package/web/out/__next.__PAGE__.txt +9 -9
  11. package/web/out/__next._full.txt +10 -10
  12. package/web/out/__next._tree.txt +6 -6
  13. package/web/out/_next/static/chunks/130-930cfe062cda6fb5.js +1 -0
  14. package/web/out/_next/static/chunks/166-64abdc6456626378.js +1 -0
  15. package/web/out/_next/static/chunks/{635-611c009924b842be.js → 380-6a6a9517cf13350e.js} +21 -21
  16. package/web/out/_next/static/chunks/678-6a688c1f8589183c.js +1 -0
  17. package/web/out/_next/static/chunks/app/_not-found/page-527a4b0506fa60cb.js +1 -0
  18. package/web/out/_next/static/chunks/app/composition/page-945cb9644c513407.js +1 -0
  19. package/web/out/_next/static/chunks/app/{layout-1dd9196cde94389c.js → layout-33fe456f6115412e.js} +1 -1
  20. package/web/out/_next/static/chunks/app/page-b027a8ffdb9dda66.js +1 -0
  21. package/web/out/_next/static/chunks/app/spatial/page-c52d564a39d3b592.js +1 -0
  22. package/web/out/_next/static/chunks/app/styles/page-87d77b1f3e8fdd21.js +1 -0
  23. package/web/out/_next/static/chunks/app/ui-sketch/page-69219e06cc93c28f.js +1 -0
  24. package/web/out/_next/static/chunks/main-app-4a71cca48ead7720.js +1 -0
  25. package/web/out/_next/static/chunks/next/dist/client/components/builtin/global-error-6a956dd8904b8723.js +1 -0
  26. package/web/out/_next/static/chunks/{webpack-d16ce1f994e98178.js → webpack-c0280e9af5fc8cd3.js} +1 -1
  27. package/web/out/_next/static/css/{ce1b4bb3ad3c6073.css → 0ab45995828642ec.css} +1 -1
  28. package/web/out/_next/static/css/0c7915cdb1509f9d.css +1 -0
  29. package/web/out/_next/static/css/{06743b5635914999.css → 4fb1bde9070d5094.css} +1 -1
  30. package/web/out/_next/static/css/c39f5ecbfc8cb532.css +1 -0
  31. package/web/out/_next/static/css/{3b7982b41ed8eccd.css → d42ebb6745c15e30.css} +1 -1
  32. package/web/out/_next/static/css/d787350911847f22.css +1 -0
  33. package/web/out/_next/static/css/db78da93b4de5040.css +1 -0
  34. package/web/out/_not-found/__next._full.txt +6 -6
  35. package/web/out/_not-found/__next._not-found.__PAGE__.txt +5 -5
  36. package/web/out/_not-found/__next._tree.txt +3 -3
  37. package/web/out/_not-found/index.html +1 -1
  38. package/web/out/_not-found/index.txt +6 -6
  39. package/web/out/brand/h2a-1024.png +0 -0
  40. package/web/out/brand/h2a-128.png +0 -0
  41. package/web/out/brand/h2a-16.png +0 -0
  42. package/web/out/brand/h2a-256.png +0 -0
  43. package/web/out/brand/h2a-32.png +0 -0
  44. package/web/out/brand/h2a-48.png +0 -0
  45. package/web/out/brand/h2a-512.png +0 -0
  46. package/web/out/brand/h2a-64.png +0 -0
  47. package/web/out/brand/h2a.svg +10 -1
  48. package/web/out/composition/__next._full.txt +11 -11
  49. package/web/out/composition/__next._tree.txt +7 -7
  50. package/web/out/composition/__next.composition.__PAGE__.txt +10 -10
  51. package/web/out/composition/index.html +1 -1
  52. package/web/out/composition/index.txt +11 -11
  53. package/web/out/favicon.ico +0 -0
  54. package/web/out/icon.svg +10 -1
  55. package/web/out/index.html +1 -1
  56. package/web/out/index.txt +10 -10
  57. package/web/out/spatial/__next._full.txt +9 -9
  58. package/web/out/spatial/__next._tree.txt +5 -5
  59. package/web/out/spatial/__next.spatial.__PAGE__.txt +8 -8
  60. package/web/out/spatial/index.html +1 -1
  61. package/web/out/spatial/index.txt +9 -9
  62. package/web/out/styles/__next._full.txt +9 -9
  63. package/web/out/styles/__next._tree.txt +5 -5
  64. package/web/out/styles/__next.styles.__PAGE__.txt +8 -8
  65. package/web/out/styles/index.html +1 -1
  66. package/web/out/styles/index.txt +9 -9
  67. package/web/out/ui-sketch/__next._full.txt +10 -10
  68. package/web/out/ui-sketch/__next._tree.txt +6 -6
  69. package/web/out/ui-sketch/__next.ui-sketch.__PAGE__.txt +9 -9
  70. package/web/out/ui-sketch/index.html +1 -1
  71. package/web/out/ui-sketch/index.txt +10 -10
  72. package/web/out/_next/static/chunks/130-7e9e715a084569bb.js +0 -1
  73. package/web/out/_next/static/chunks/166-96a8c6ae1e9aed59.js +0 -1
  74. package/web/out/_next/static/chunks/678-32d3aa1859450d63.js +0 -1
  75. package/web/out/_next/static/chunks/app/_not-found/page-b92817fdc4609975.js +0 -1
  76. package/web/out/_next/static/chunks/app/composition/page-6c12ee8472715448.js +0 -1
  77. package/web/out/_next/static/chunks/app/page-741ecaf9ee8c3c07.js +0 -1
  78. package/web/out/_next/static/chunks/app/spatial/page-5ba0940650df6c7f.js +0 -1
  79. package/web/out/_next/static/chunks/app/styles/page-1ccfc2c5fbc1e646.js +0 -1
  80. package/web/out/_next/static/chunks/app/ui-sketch/page-ef4f2e531583e684.js +0 -1
  81. package/web/out/_next/static/chunks/main-app-cf37a257d91ce62e.js +0 -1
  82. package/web/out/_next/static/chunks/next/dist/client/components/builtin/global-error-33b4f58f02e82215.js +0 -1
  83. package/web/out/_next/static/css/1f8501a43042a5a2.css +0 -1
  84. package/web/out/_next/static/css/39e8cace36461a15.css +0 -1
  85. package/web/out/_next/static/css/81ae71f1d3e9a866.css +0 -1
  86. package/web/out/_next/static/css/db96ae2e88545d96.css +0 -1
  87. /package/web/out/_next/static/{n4UcxqMmr_2CBmSxBp52z → Rem7hlT5iXtA-5codwSoe}/_buildManifest.js +0 -0
  88. /package/web/out/_next/static/{n4UcxqMmr_2CBmSxBp52z → Rem7hlT5iXtA-5codwSoe}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[130],{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:()=>m,GN:()=>p,J2:()=>s,L6:()=>g,Y8:()=>d,cq:()=>n,i:()=>l,lB:()=>u,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 m(e,t){return{x:(e.x-t.bounds.x)/t.bounds.width,y:(e.y-t.bounds.y)/t.bounds.height}}function u(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,m=i.endsWith("left")?r-d:a.x,u=i.startsWith("top")?o-c:a.y;return{...e,bounds:{x:m/n.width,y:u/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_:()=>u,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 m(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 u(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=m(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=m(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,u=(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*u**(n/(Math.PI/2)),e.mirrored?-n:n)}),g=c*(1+(Math.log(u)/(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 m=180*Math.atan2(c,d)/Math.PI;return"radial"===e.type?"free"===e.mode?{...e,angles:e.angles.map((e,t)=>t===r-1?m:e)}:{...e,rotation:m}:{...e,rotation:m,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),m=(0,n.VC)(c),u=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(m.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:u,images:h,axes:{focus:k(c.focusPoints,c),area:k(c.areas,c)},metrics:m,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=u).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),m=.004*c,u=.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 m=e.crop,u=m?s-m.x/m.width*i:s,h=m?l-m.y/m.height*n:l,p=m?i/m.width:i,g=m?n/m.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="${_(d)}" x="${$(u)}" y="${$(h)}" width="${$(p)}" height="${$(g)}" preserveAspectRatio="${m?"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*m)}" 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),u=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+u)-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="${$(m)}" 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*u)}" y1="${$(i)}" x2="${$(t+1.8*u)}" y2="${$(i)}" stroke="#1f1f1f" stroke-width="${$(m)}"/><line x1="${$(t)}" y1="${$(i-1.8*u)}" x2="${$(t)}" y2="${$(i+1.8*u)}" stroke="#1f1f1f" stroke-width="${$(m)}"/><circle cx="${$(t)}" cy="${$(i)}" r="${$(u)}" fill="#ffffff" stroke="#1f1f1f" stroke-width="${$(m)}"/>`)}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=_(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,m=s?`fill="url(#${n})" stroke="none" filter="url(#${n}-soften)"`:`fill="url(#${n})" stroke="#d6b95c" stroke-opacity="0.55" stroke-width="1.5"`,u="circle"===o.type?`<circle cx="${$(o.cx)}" cy="${$(o.cy)}" r="${$(o.radius)}" ${m}/>`:"ellipse"===o.type?`<ellipse cx="${$(o.cx)}" cy="${$(o.cy)}" rx="${$(o.radiusX)}" ry="${$(o.radiusY)}" ${m}/>`:`<polygon points="${o.points.map(e=>`${$(e.x)},${$(e.y)}`).join(" ")}" ${m}/>`,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="${_(e.id)}" transform="rotate(${$(e.rotation??0)} ${$(e.x*a.cq.width)} ${$(e.y*a.cq.height)})"><defs>${h}${p}</defs>${u}</g>`}function $(e){return String(Math.round(1e3*e)/1e3)}function _(e){return e.replaceAll("&","&amp;").replaceAll('"',"&quot;").replaceAll("<","&lt;").replaceAll(">","&gt;")}var T=i(27062);let F=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 T.Ajv2020({allErrors:!0}).compile(F);var R=i(59793)},4549:()=>{},12190:()=>{},12399:(e,t,i)=>{"use strict";i.d(t,{Oe:()=>y,Pw:()=>p,b5:()=>c,bl:()=>m,i1:()=>d,j4:()=>u,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 m=s.bones.find(e=>e.endJointId===i),h=!!(m&&(0,r.dS)(m.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&&m&&(m.lockRotation||u(m)))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&&m){let e=p(s,m,(l.parentId?x[l.parentId].rotation:c(t.rotation)).clone().invert().multiply(v.rotation));if(e.every((e,t)=>e>=m.limits.min[t]&&e<=m.limits.max[t])){m.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};m.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||u(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&&!u(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")),m=e=>{let t=new n.O9p().setFromQuaternion(e,"XYZ");return[t.x/l,t.y/l,t.z/l]},u=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 m(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 m=(0,a.kF)(e.footSize);if(n?.endsWith("-ankle")&&1!==m){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*(m-1)}}return n?.endsWith("-foot")&&(i.x*=e.footSize??1,i.y*=m,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 m=a.get(l);if(!m)throw Error("SPATIAL_INVALID: missing parent joint");let u=m.parentId?s(m.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=u.rotation.clone().multiply(y).normalize(),b=(t?.[l].offset.clone()??g(e,m)).applyQuaternion(x).add(u.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:()=>{},16415:(e,t,i)=>{"use strict";i.d(t,{jZ:()=>eP,zr:()=>e2,Cf:()=>eZ,x8:()=>ii,yP:()=>tf,X3:()=>ip,te:()=>iJ,J3:()=>iK,WL:()=>i6,Hx:()=>nT,cF:()=>i4,Ol:()=>tg,NX:()=>tH,SM:()=>i7,FU:()=>e5,LE:()=>ty,Nc:()=>e4,vB:()=>tp,MH:()=>tb,kC:()=>tu,Y$:()=>th,wN:()=>tm});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),m=i(1521);i(22392),i(16803);var u=i(46811),h=i(67282);let p=Object.freeze({minRows:3,maxRows:6}),g=(0,m.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,m.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,m.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,m.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,u.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,m.useState)(!1),[i,n]=(0,m.useState)({x:0,y:0}),a=(0,m.useRef)(null),r=(0,m.useRef)(null),o=(0,m.useCallback)(()=>t(!1),[]),s=(0,m.useCallback)(()=>{t(!1),a.current?.focus()},[]);return(0,m.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:u="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:F,onSelect:R,onNudge:q,onResize:E,onRotate:D,onDoubleClick:z,onDelete:B,onKeyDown:O,className:U,...J}){var W;let H=(0,m.useRef)(null),Y=(0,m.useRef)(null),V=!d&&!!(R||q||E||D||z||B||O),X=["human2ai-canvas-node",U].filter(Boolean).join(" "),G=s&&!d&&!!(c&&E),K=s&&!d&&b&&!!(c&&D),Q=f>0&&Number.isFinite(f)?f:1,Z=v/Q;function ee(t){let i=H.current;if(!i||i.pointerId!==t.pointerId||!E)return;t.preventDefault(),t.stopPropagation();let n=N(t,i.inverseMatrix),a="free"!==u||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"),m=t.startsWith("bottom"),u=l||d,h=c||m,p=e.x+e.width,g=e.y+e.height,f=o/e.width,y=s/e.height,x=1,b=1;if(u)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:u,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:m?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});E({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,_(e.currentTarget,e.pointerId))}function ei(e){Y.current?.pointerId===e.pointerId&&(Y.current=null,_(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,m=e.y-a,u=e.y+o,h=e.y+e.height-o,p=e.y+e.height+a;return"top"===t?P(l,m,d,u):"right"===t?P(d,u,c,h):"bottom"===t?P(l,h,d,p):"left"===t?P(s,u,l,h):"top-left"===t?P(s,m,l,u):"top-right"===t?P(d,m,c,u):"bottom-right"===t?P(d,h,c,p):P(s,h,l,p)}({bounds:c,handle:t,hitSize:y,screenScale:Q});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||!E)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-Z}),(0,n.jsx)("circle",{className:"human2ai-canvas-node__rotation-handle",cx:c.x+c.width/2,cy:c.y-Z,r:7/Q}),(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-Z,r:12/Q,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":E?u:void 0,"data-resizable":E?"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(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&&q?(t.preventDefault(),R?.(e,t),q(n)):O?.(t)}:void 0,onPointerDown:V?function(e){T(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=F?[[F.labels.nodeDescription,F.annotation],[F.labels.displayText,F.displayText],[F.labels.note,F.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 _(e,t){e.hasPointerCapture(t)&&e.releasePointerCapture(t)}function T(e){e.focus(),requestAnimationFrame(()=>{e.isConnected&&e.focus()})}function F(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(" "),m={...(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",{...m,cx:0,cy:0,r:e.size/2}):(0,n.jsx)("ellipse",{...m,cx:0,cy:0,rx:e.width/2,ry:e.height/2});if("rectangle"===t)return(0,n.jsx)("rect",{...m,x:-e.width/2,y:-e.height/2,width:e.width,height:e.height});let u=`0,${-2*e.height/3} ${-e.width/2},${e.height/3} ${e.width/2},${e.height/3}`;return(0,n.jsx)("polygon",{...m,points:u})}function R({id:e,label:t,bounds:i,selected:a=!1,locked:r=!1,onMove:o,onSelect:s,className:l,...d}){let c=(0,m.useRef)(null),u=(0,m.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&&(u.current=n.moved,c.current=null,t=e.currentTarget,i=e.pointerId,t.hasPointerCapture(i)&&t.releasePointerCapture(i),window.setTimeout(()=>{u.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)(F,{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){u.current&&(u.current=!1,e.preventDefault(),e.stopPropagation())},onPointerDown:function(e){if(a||r||!o||0!==e.button)return;u.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:q(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=q(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&&(u.current=e.moved,c.current=null,window.setTimeout(()=>{u.current=!1},0))}})]})})}function q(e,t){let i=new DOMPoint(e.clientX,e.clientY).matrixTransform(t);return{x:i.x,y:i.y}}function E({src:e,alt:t,width:i,height:a,fit:r="contain",crop:o=null,status:s="ready",loadingLabel:l="图片加载中",errorLabel:d="图片加载失败",emptyLabel:c="图片",opacity:u,className:h,onLoad:p,onError:g}){let f=`human2ai-canvas-image-${(0,m.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:u,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,m.useRef)(null),a=(0,m.useRef)(e),r=(0,m.useRef)(!1),o=(0,m.useRef)(0);return(0,m.useLayoutEffect)(()=>{a.current=e}),(0,m.useLayoutEffect)(()=>(r.current=!1,()=>{o.current+=1,t.destroy()}),[t,e.resetKey]),(0,m.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(67925),V=i(29415);async function X(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 G({src:e,crop:t,aspectRatio:i,labels:a,disabled:r=!1,onUpload:o,onReadFile:s,onCropChange:l}){var d;let c=(0,m.useRef)(null),u=(0,m.useRef)(!1),h=(0,m.useRef)(!1),p=(0,m.useId)(),g=(0,m.useRef)(null),f=(0,m.useRef)(null),y=(0,m.useRef)(null),x=(0,m.useRef)(null),[b,v]=(0,m.useState)(!1),[w,j]=(0,m.useState)(!1),[I,S]=(0,m.useState)(null),[P,C]=(0,m.useState)(!1),[M,A]=(0,m.useState)(null),[L,N]=(0,m.useState)(null),[$,_]=(0,m.useState)(null),[T,F]=(0,m.useState)(!1),[R,q]=(0,m.useState)(null),[E,D]=(0,m.useState)(!1),[B,O]=(0,m.useState)(!1),[et,ei]=(0,m.useState)(0),[en,ea]=(0,m.useState)(!1),[er,eo]=(0,m.useState)(""),es=`${p}-source`;async function el(e){if(r||u.current)return!1;u.current=!0,v(!0),j(!1);try{return await o(e),!0}catch{return j(!0),!1}finally{u.current=!1,v(!1),g.current&&(g.current.value="")}}async function ed(){if(e&&$?.src===e&&!u.current&&!h.current){h.current=!0,F(!0),q(null);try{await X($.file)}catch{q(e)}finally{h.current=!1,F(!1)}}}function ec(e){y.current=e,A(e)}function em(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 eu(e){let t=x.current;if(!t||t.pointerId!==e.pointerId)return;x.current=null;let i=y.current;i&&I&&l(i,Z(i,I))}(0,m.useLayoutEffect)(()=>{ea(!1)},[e]),(0,m.useEffect)(()=>{let t=!1;return N(null),_(null),q(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||(_({src:e,file:i}),N(n))}).catch(()=>{t||O(!0)}).finally(()=>{t||D(!1)}),()=>{t=!0}},[s,et,e]),(0,m.useLayoutEffect)(()=>{S(null),C(!1),A(null),y.current=null,x.current=null},[e]),(0,m.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,m.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)(V.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)(V.J,{mode:"with-icon",icon:(0,n.jsx)(J.A,{"aria-hidden":"true"}),loading:T,disabled:b||T||$?.src!==e,onClick:()=>{ed()},children:T?a.downloading:a.download}),(0,n.jsx)(V.J,{mode:"with-icon",icon:(0,n.jsx)(W.A,{"aria-hidden":"true"}),disabled:r||b,"aria-expanded":en,"aria-controls":es,onClick:()=>{eo(""),ea(!0),j(!1)},children:a.svgPaste}),null!==L&&(0,n.jsx)(Y.r,{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?en?a.svgSaveFailed:a.uploadFailed:a.fileTypes}),E&&(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)(V.J,{onClick:()=>ei(e=>e+1),children:a.retry})]}),en&&(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)(V.J,{loading:b,disabled:r||b||!er.trim(),onClick:async()=>{await el(new File([er],"image.svg",{type:"image/svg+xml"}))&&ea(!1)},children:a.svgApply}),(0,n.jsx)(V.J,{disabled:b,onClick:()=>{ea(!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=ee((e.clientX-t.left)/t.width-i.width/2,0,1-i.width),a=ee((e.clientY-t.top)/t.height-i.height/2,0,1-i.height),o={...i,x:n,y:a};ec(o),em(e,"move",void 0,o)},onPointerMove:function(e){var t,i,n;let a,r,o,s,l,d,c,m,u,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?Q(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,m=s?1-d:d,u=ee(a.width+(o?i:-i),Math.min(.05,c),c),h=ee(a.height+(s?n:-n),Math.min(.05,m),m),{x:o?l:l-u,y:s?d:d-h,width:u,height:h}))},onPointerUp:eu,onPointerCancel:eu,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=>em(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=Q(i,"ArrowLeft"===e.key?-n:"ArrowRight"===e.key?n:0,"ArrowUp"===e.key?-n:"ArrowDown"===e.key?n:0);ec(a),I&&l(a,Z(a,I))},children:K.map(e=>(0,n.jsx)("span",{className:"human2ai-canvas-image-editor-fields__crop-handle","data-crop-handle":e,"aria-hidden":"true",onPointerDown:t=>em(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(1713);let K=["north-west","north-east","south-east","south-west"];function Q(e,t,i){return{...e,x:ee(e.x+t,0,1-e.width),y:ee(e.y+i,0,1-e.height)}}function Z(e,t){return e.width*t.width/(e.height*t.height)}function ee(e,t,i){return Math.min(i,Math.max(t,e))}function et(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,m.useId)().replaceAll(":","")}`,u=["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:u,"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 ei({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 en({tool:e,viewportBounds:t,onPlace:i,onCancel:a}){let r=(0,m.useRef)(null),o=(0,m.useRef)(null),s=(0,m.useRef)(null),l=(0,m.useRef)(null),d=(0,m.useRef)(null),c=(0,m.useRef)({onPlace:i,onCancel:a});function u(){null!==l.current&&cancelAnimationFrame(l.current),l.current=null,d.current=null,r.current?.removeAttribute("d")}function h(){s.current=null,u(),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 m=c.matrixTransform(d.getScreenCTM().inverse()),u=s.current,h=!!(u&&Math.hypot(t.clientX-u.client.x,t.clientY-u.client.y)>=3);return i=e,n=u?.start??m,a=m,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,m.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,u()}},[]),(0,m.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||u()},onPointerUp:e=>{if(s.current?.pointerId!==e.pointerId)return;e.preventDefault(),e.stopPropagation();let t=p(e);s.current=null,u(),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 ea({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 er={title:"编辑节点",note:"备注",notePlaceholder:"说明这个节点表达什么",shotScale:"景别",shotScaleAuto:"自动",shotScaleForeground:"前景",shotScaleMidground:"中景",shotScaleBackground:"背景",deleteNode:"删除节点",confirmDeleteNode:"确认删除这个节点?",cancelDelete:"保留",shapeKind:"形状",pointKind:"点",lineKind:"线",textKind:"文字",imageKind:"图像",nodeDescription:"节点说明",originUser:"user",originAgent:"agent",originImport:"import"};function eo({nodeKind:e,metadata:t,onMetadataChange:i,onRequestClose:a,onDelete:r,labels:s,leadingFields:l,propertyFields:d,trailingFields:c,autoFocusField:m="note",disabled:u=!1,className:h,style:p,"aria-label":x}){var b,v;let w={...er,...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&&!u?{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":u||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"===m,value:t.note,placeholder:w.notePlaceholder,"aria-label":w.note,disabled:u,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:u,onChange:e=>i({shotScale:e})})}),d]})]}),c?(0,n.jsx)("aside",{className:"human2ai-canvas-node-editor__side-fields",children:c}):null]})})}var es=i(66234),el=i(84092),ed=i(19330),ec=i(50018),em=i(94423),eu=i(96313);i(88307);var eh=i(50052);function ep({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,m.useId)(),[f,y]=(0,m.useState)(a),x=void 0!==i,b=i??f,v=b?s:o;return(0,n.jsxs)("aside",{...(0,u.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)(em.A,{}):(0,n.jsx)(eu.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)(eh.I,{collapsed:b,children:(0,n.jsx)("div",{id:g,className:"yisi-side-action-panel-actions",children:t})})]})}i(49404);let eg={width:1,height:1},ef={x:0,y:0},ey={zoomOut:"缩小画布",zoomIn:"放大画布",currentZoom:"当前缩放",fitAll:"适应全部",help:"画布操作说明",interactionHelp:"滚轮缩放;按住右键拖动画布;按住空格键并使用左键拖动画布。",sideActions:"画布操作",collapseSideActions:"收起画布操作",expandSideActions:"展开画布操作"};function ex({children:e,onContextMenuRequest:t,cameraCenter:i,defaultCameraCenter:a=ef,zoom:r,defaultZoom:o=1,minimumZoom:s=.25,maximumZoom:l=4,fitRequest:d,contentBounds:c,backgroundPattern:u="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,m.useRef)(null),P=`human2ai-infinite-canvas-${(0,m.useId)().replaceAll(":","")}`,[M,A]=(0,m.useState)(eg),[L,N]=(0,m.useState)(a),[$,_]=(0,m.useState)(o),[T,F]=(0,m.useState)(!1),[R,q]=(0,m.useState)(!1),E=(0,m.useRef)(!1),D=(0,m.useRef)(!1),z=(0,m.useRef)(null),B=(0,m.useRef)(!1),O=(0,m.useRef)(null),U={...ey,...x},J=Math.min(s,l),W=Math.max(s,l),H=i??L,Y=ev(r??$,J,W),X={width:M.width/Y,height:M.height/Y},G={x:H.x-X.width/2,y:H.y-X.height/2,width:X.width,height:X.height},K=["human2ai-infinite-canvas-viewport",T?"human2ai-infinite-canvas-viewport--pan-ready":null,R?"human2ai-infinite-canvas-viewport--panning":null,w].filter(Boolean).join(" "),Q=en({x:0,y:0});function Z(e){void 0===i&&N(e),b?.(e)}function ee(e){let t=ev(e,J,W);void 0===r&&_(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=ev(Math.min(n/Math.max(1,e.width),a/Math.max(1,e.height)),J,W);Z({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,q(!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,m.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,m.useEffect)(()=>{let e=S.current;if(!e)return;let t=t=>{t.preventDefault();let i=ev(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);Z({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,m.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,m.useEffect)(()=>{let e=e=>{var t;"Space"!==e.code||!E.current||(t=e.target)instanceof HTMLElement&&(t.matches("input, textarea, select, button, a[href]")||t.isContentEditable)||(e.preventDefault(),D.current=!0,F(!0))},t=()=>{D.current=!1,F(!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":u,onPointerEnter:()=>{E.current=!0},onPointerLeave:()=>{E.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,q(!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||Z({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,q(!1)},onClickCapture:e=>{B.current&&(e.preventDefault(),e.stopPropagation(),B.current=!1)},onContextMenu:e=>e.preventDefault(),children:[(0,n.jsx)(eb,{pattern:u,patternId:P,screenOrigin:Q,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)(ep,{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)(V.J,{mode:"icon-only",size:"small",backgroundColor:"none",icon:(0,n.jsx)(es.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)(V.J,{mode:"icon-only",size:"small",backgroundColor:"none",icon:(0,n.jsx)(el.A,{"aria-hidden":"true"}),iconLabel:U.zoomIn,title:U.zoomIn,disabled:Y>=W,onClick:()=>ee(1.2*Y)}),(0,n.jsx)(V.J,{mode:"icon-only",size:"small",backgroundColor:"none",icon:(0,n.jsx)(ed.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)(V.J,{mode:"icon-only",size:"small",backgroundColor:"none",icon:(0,n.jsx)(ec.A,{"aria-hidden":"true"}),iconLabel:U.help})})]}):null]})}function eb({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 ev(e,t,i){return Math.min(i,Math.max(t,e))}i(98852);var ew=i(48511);function ej({draft:e,selectedIds:t=[],onSelect:i,locked:a=!1,onDraftChange:r,screenScale:o,labels:s}){let l=(0,m.useId)(),d=(0,j.i)(e.frame),c=(0,m.useRef)(null),u=(0,m.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&&u.current===e){u.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(),u.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:m}=(0,j.SZ)(i,e.frame),u=!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:u,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,u?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))})}),u&&1===t.length&&p&&m?(0,n.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:m.map((e,t)=>(0,n.jsx)("circle",{className:"human2ai-composition-plan__snap",cx:e.x,cy:e.y,r:3/o},t))}):null,u&&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 ek={circle:"圆形",triangle:"三角形",quadrilateral:"矩形"},eI={cornerLabel:"文字轮廓角点 {{index}}",lightSource:"作为光源",displayText:"显示文字",displayTextPlaceholder:"填写要显示的文字;留空由生图模型决定",visualWeight:"视觉权重",weightAuto:"自动",weightHigh:"高",weightMedium:"中",weightLow:"低",weightDecorative:"装饰"},eS={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:"重试"},eP="composition-frame";function eC({selectedPlanIds:e,planningLocked:t=!1,onPlanSelectionChange:i,planningLabels:s=ew.composition.planning,interactionResetKey:l,draft:d,appearance:c="editor",showPlanning:u=!0,frameLocked:h=!1,zoom:p,viewportAction:y,backgroundPattern:I,showViewportControls:S,sideActions:P,sideActionPlacement:C,sideActionPanelWidth:M,sideActionPanelDefaultCollapsed:L,viewportLabels:N,layerLabels:$,nodeEditorLabels:_,directionControlLabels:T=["动势线操作点 1","动势线操作点 2"],areaEditorLabels:q,imageEditorLabels:D,resolveImageSource:z,renderCameraReference:B,onImageUpload:U,onReadImageFile:J,selectedIds:W=[],onDraftChange:H,placementTool:Y=null,onPlacementToolChange:V,onSelectionChange:X,onItemDoubleClick:K,onZoomChange:Q,className:Z,style:ee,"aria-label":et="构图画布"}){let er=["human2ai-composition-canvas",`human2ai-composition-canvas--${c}`,h?"human2ai-composition-canvas--frame-locked":null,Z].filter(Boolean).join(" "),es=(0,m.useRef)(null),{contextMenuOpen:el,contextMenuPoint:ed,contextMenuPopupRef:ec,openContextMenuAt:em,closeContextMenu:eu,dismissContextMenu:eh}=b(),ep={...x,...$},[eg,ef]=(0,m.useState)(null),ey=(0,m.useRef)(null),eb=(0,m.useRef)(!1),ev=(0,m.useRef)(!1),eH=(0,m.useRef)(null),eV=(0,m.useRef)([]),eX=(0,m.useRef)(""),eG=(0,m.useRef)(0),[eK,eQ]=(0,m.useState)(!1),[eZ,e0]=(0,m.useState)(!1),[e1,e2]=(0,m.useState)(!1),[e5,e3]=(0,m.useState)(160),[e4,e8]=(0,m.useState)(null),[e6,e9]=(0,m.useState)(null),e7=(0,j.i)(d.frame),te="reference"===c?{...ee,"--human2ai-composition-reference-aspect":e7.width/e7.height}:ee,tt=(0,j.MR)(d),ti="reference"!==c&&!!H&&!h,tn="reference"!==c&&W.includes(eP),ta="reference"===c||tn?[]:[...new Set(W)].filter(e=>!!eB(d,e)),tr=new Set(ta),to=ta.length>1?function(e,t){let i=t.map(t=>eE(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?eB(d,e6.id):null,tc=e6?d.areas.find(({id:e})=>e===e6.id)??null:null,tm=e6?d.images.find(({id:e})=>e===e6.id)??null:null,tu={...eI,...q},th=(0,m.useId)().replace(/:/g,""),tp={...eS,...D},tg=(0,m.useRef)({draft:d,onDraftChange:H,interactionResetKey:l});(0,m.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&&(eV.current=(0,j.s6)(d,ta),eX.current=crypto.randomUUID(),eG.current=0,e.clipboardData.setData("application/x-human2ai-composition",eX.current),e.preventDefault(),e.stopPropagation())},onPasteFallback:function(e){if(e.defaultPrevented||!H||0===eV.current.length||e.clipboardData?.getData("application/x-human2ai-composition")!==eX.current)return;e.preventDefault(),e.stopPropagation();let t=eG.current+1,i=(0,j.CP)(d,eV.current,{x:24*t/j.cq.width,y:24*t/j.cq.height});0!==i.ids.length&&(eG.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:tu.weightAuto},{value:"high",label:tu.weightHigh},{value:"medium",label:tu.weightMedium},{value:"low",label:tu.weightLow},{value:"decorative",label:tu.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:_?.nodeDescription??"节点说明",displayText:tu.displayText,note:_?.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),e3(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),eb.current=!0,window.setTimeout(()=>{eb.current=!1},0)}function tw(e,t){if(ev.current){ev.current=!1;return}X?.(t.shiftKey?eT(ta,[e]):[e])}function tj(e,t){H&&H(eF(d,ta.length>1&&tr.has(e)?ta:[e],t))}function tk(e){if(!H||!eB(d,e))return;let t=ta.length>1&&tr.has(e)?ta:[e];H(eR(d,t)),X?.([]),e6&&t.includes(e6.id)&&tS()}function tI(e,t){e9({id:e,kind:t}),X?.([e]),K?.(e)}function tS(){e9(null)}function tP(e){if(!(e.target instanceof Element)||(eb.current=!1,ev.current=!1,0!==e.button))return;let t=eJ(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=e_(r,e5);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?eB(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)&&(eb.current=!0,e.preventDefault(),eW(e.currentTarget,e.pointerId))}function tC(e){let t=ey.current;if(!t||t.pointerId!==e.pointerId)return;let i=eJ(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,eQ(!0),eW(e.currentTarget,e.pointerId)),eb.current=!0,ev.current=!0,e.preventDefault(),!H))return;H(eF(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,eW(e.currentTarget,e.pointerId)),e.preventDefault(),eb.current=!0,e8(eq(t.start,i));return}if(e.preventDefault(),eb.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);e3(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=e_(d.directionLine,e5);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=>ez(eD(e),t)).map(e=>e.id),d=e.images.filter(e=>ez(eO(e),t)).map(e=>e.id),c=e.focusPoints.filter(i=>{let n=eE(e,i.id);return!!n&&ez(n,t)}).map(e=>e.id);return[...d,...l,...e.directionLine&&(i=e.directionLine,n=t,a=eU(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,eq(t.start,eJ(e,e.currentTarget))):[];X?.(0===i.length?[]:t.additive?eT(t.sourceSelectedIds,i):i),e8(null)}ey.current=null,eQ(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),window.setTimeout(()=>{eb.current=!1,ev.current=!1},0)}}function tN(e){ey.current?.pointerId===e.pointerId&&(ey.current=null,eQ(!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},m=JSON.stringify([ta,(t=c).x,t.y,t.width,t.height]);eH.current?.signature!==m&&(eH.current={signature:m,draft:d,ids:[...ta],bounds:c});let u=eH.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=u.draft,n=u.ids,a=u.bounds,r=h,o=e.scaleX,s=e.scaleY,l=e.proportional,n.reduce((e,t)=>{let n=eB(i,t);if(!n)return e;let d=eU(n),c={x:r.x+(d.x-a.x)*o,y:r.y+(d.y-a.y)*s},m=(0,j.Pe)(e,t,{x:c.x/j.cq.width,y:c.y/j.cq.height}),u=i.areas.find(e=>e.id===t);if(u){let e=(0,j.QR)(u,j.cq),i=eL(u,e);m=l?(0,j.oF)(m,t,u.area*o*s):(0,j.IU)(m,t,i.width*o/j.cq.width,i.height*s/j.cq.height)}let h=i.images.find(e=>e.id===t);h&&(m=(0,j.CV)(m,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;m=(0,j.hG)(m,t,180*Math.atan2(Math.sin(e)*s,Math.cos(e)*o)/Math.PI)}return m},i)))}function t_(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 tT(e){H&&H((0,j.Dr)(d,{x:e.bounds.x/j.cq.width,y:e.bounds.y/j.cq.height}))}function tF(e){!H||["+","=","-","_"].includes(e.key)&&(e.preventDefault(),X?.([eP]),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?.([eP]),em(e,t??es.current?.querySelector("[data-composition-scene]")??null)}function tq(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 tE(a){let r=a?.viewportBounds??e7,o="reference"===c?e7:r,m=a?.zoom??1,p=to?{x:to.x+to.width/2,y:to.y+to.height/2}:null;return(0,n.jsxs)(ea,{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":eK?"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?tq:void 0,onPointerDownCapture:"reference"!==c?e=>e.currentTarget.focus():void 0,onClickCapture:e=>{eb.current&&(e.stopPropagation(),eb.current=!1)},onClick:"reference"!==c&&X?e=>{if(eb.current){eb.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,eQ(!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:eP,label:"移动或缩放画框",bounds:e7,selected:tn,locked:!ti,resizeMode:"proportional",resizeCenter:{x:0,y:0},screenScale:m,resizeHitSize:40,minimumWidth:96,minimumHeight:96,onSelect:ti?()=>X?.([eP]):void 0,onNudge:ti?e=>{X?.([eP]),H?.((0,j.Dr)(d,{x:d.frame.bounds.x+e.x,y:d.frame.bounds.y+e.y}))}:void 0,onMove:ti?tT:void 0,onResize:ti?t_:void 0,onKeyDown:ti?tF: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=_?.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:eM(t,i),resizeMode:"proportional",resizeCenter:{x:0,y:0},screenScale:m,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=eY({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||K)?()=>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)(E,{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=eL(e,i),s=e.corners?(0,j.QR)({...e,x:0,y:0,rotation:0},j.cq):null,l=a?_?.textKind??"文字区域":ek[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:m,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=eY((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||K)?()=>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)(F,{type:"circle",size:2*i.radius,className:"human2ai-composition-canvas__shape"}):"ellipse"===i.type?(0,n.jsx)(F,{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)(F,{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)(eA,{width:i.width??0,height:i.height})]}):(0,n.jsx)(F,{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)(eN,{draft:d,label:_?.lineKind??"动势线",selected:tr.has(d.directionLine.id),onSelect:"reference"!==c?tw:void 0,onNudge:"reference"!==c&&H?tj:void 0,onDoubleClick:"reference"!==c&&(H||K)?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||K)?()=>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)(ei,{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)(e$,{directionLine:d.directionLine,distance:e5,screenScale:m,labels:T,onNudge:tA}):null,"reference"!==c&&u?(0,n.jsx)(ej,{draft:d,selectedIds:e,locked:t,onSelect:i,onDraftChange:Y?void 0:H,screenScale:m,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:eM(to.width,to.height),resizeMode:ts?"proportional":"free",resizeCenter:{x:0,y:0},screenScale:m,minimumWidth:16,minimumHeight:16,showRotationHandle:!1,tabIndex:-1,nudgeStep:.01,largeNudgeStep:.05,onNudge:e=>{H(eF(d,ta,e))},onResize:t$,onDelete:()=>{H(eR(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&&(eZ||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":tu.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)/m,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/m}),(0,n.jsx)("circle",{className:"human2ai-composition-canvas__transform-hit",r:12/m})]},i))},e.id)}):null,Y&&tx?(0,n.jsx)(en,{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=eL(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,m.useLayoutEffect)(()=>{void 0!==l&&(ey.current=null,eQ(!1),eH.current=null,e8(null),e9(null),e2(!1),eh())},[l]),(0,m.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,m.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:es,className:er,style:te,children:["reference"!==c?(0,n.jsx)(a.A,{trigger:[],autoFocus:!0,open:el,popupRender:e=>(0,n.jsx)("div",{ref:ec,children:e}),onOpenChange:e=>{e||eu()},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)),eu()}},children:(0,n.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",left:ed.x,top:ed.y,width:1,height:1,pointerEvents:"none"}})}):null,"reference"===c?tE():(0,n.jsx)(ex,{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(),Q?.(e)},"aria-label":`${et}视口`,children:tE}),tf.feedback,"reference"!==c&&e6&&td?(0,n.jsx)(eo,{nodeKind:e6.kind,metadata:td,labels:_,disabled:!H,leadingFields:tc&&(0,j.MY)(tc)?(0,n.jsx)(f,{label:tu.displayText,children:(0,n.jsx)(g,{name:"displayText",autoFocus:!0,value:tc.displayText??"",placeholder:tu.displayTextPlaceholder,"aria-label":tu.displayText,disabled:!H,onChange:e=>{H&&H((0,j.ai)(d,tc.id,{displayText:e.target.value}))}})}):void 0,propertyFields:tc||tm?(0,n.jsxs)(n.Fragment,{children:[tc&&!(0,j.MY)(tc)?(0,n.jsx)(f,{label:tu.lightSource,children:(0,n.jsx)(r.A,{checked:tc.isLightSource??!1,"aria-label":tu.lightSource,disabled:!H,onChange:e=>{H?.((0,j.ai)(d,tc.id,{isLightSource:e}))}})}):null,(0,n.jsx)(f,{label:tu.visualWeight,children:(0,n.jsx)(o.A,{className:"human2ai-canvas-node-editor__property-select",value:(tc??tm)?.visualWeight,options:ty,"aria-label":tu.visualWeight,disabled:!H,onChange:e=>{H&&H(tc?(0,j.ai)(d,tc.id,{visualWeight:e}):(0,j.QY)(d,tm.id,{visualWeight:e}))}})})]}):void 0,trailingFields:tm?.cameraReference&&B?B(tm):tm?(0,n.jsx)(G,{src:tm.assetId?z?.(tm.assetId):void 0,crop:tm.crop,aspectRatio:tm.width*j.cq.width/(tm.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===tm.id)&&i.onDraftChange?.((0,j.QY)(i.draft,tm.id,{assetId:t,crop:null}))},onCropChange:(e,t)=>{if(!H)return;let i=(0,j.QY)(d,tm.id,{crop:e});H((0,j.CV)(i,tm.id,tm.width,tm.width*j.cq.width/(t*j.cq.height)))}},tm.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 eM(e,t){return{x:-e/2,y:-t/2,width:e,height:t}}function eA({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 eL(e,t){if("circle"===t.type)return eM(2*t.radius,2*t.radius);if("ellipse"===t.type)return eM(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}:eM(i,t.height)}function eN({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 m=eU(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)(et,{type:"infinite",anchor:m,angle:c.rotation,bounds:l,dashArray:"10 8"})})}function e$({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:e_(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 e_(e,t){let i=eU(e);return[eH(i,e.rotation,-t/2),eH(i,e.rotation,t/2)]}function eT(e,t){let i=new Set(t);return[...e.filter(e=>!i.has(e)),...t.filter(t=>!e.includes(t))]}function eF(e,t,i){return t.reduce((t,n)=>{let a=eB(e,n);return a?(0,j.Pe)(t,n,{x:a.x+i.x,y:a.y+i.y}):t},e)}function eR(e,t){return t.reduce((e,t)=>eB(e,t)?(0,j.Ai)(e,t):e,e)}function eq(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 eE(e,t){let i=e.areas.find(e=>e.id===t);if(i)return eD(i);let n=e.images.find(e=>e.id===t);if(n)return eO(n);let a=e.focusPoints.find(e=>e.id===t);if(a){let e=eU(a);return{x:e.x-20,y:e.y-20,width:40,height:40}}if(e.directionLine?.id===t){let t=eU(e.directionLine);return{x:t.x-12,y:t.y-12,width:24,height:24}}return null}function eD(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 ez(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 eB(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 eO(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=eU(e);return{x:o.x-a/2,y:o.y-r/2,width:a,height:r}}function eU(e){return{x:e.x*j.cq.width,y:e.y*j.cq.height}}function eJ(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 eW(e,t){try{e.setPointerCapture(t)}catch{}}function eH(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 eY(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 eV=i(16269),eX=i(63835),eG=i(51055),eK=i(23139),eQ=i(48776);function eZ({draft:e,selectedIds:t,onSelect:i,locked:l=!1,onLockedChange:d,showPlanning:c=!0,onShowPlanningChange:m,onDraftChange:u,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||u((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)(eQ.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)(V.J,{mode:"icon-only",size:"small",icon:(0,n.jsx)(ec.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);u(n.draft),i([n.id])}},children:(0,n.jsx)(V.J,{mode:"icon-only",size:"small",icon:(0,n.jsx)(el.A,{}),iconLabel:h.add,disabled:y})}),(0,n.jsx)(C.A,{title:c?h.hideAll:h.showAll,children:(0,n.jsx)(V.J,{mode:"icon-only",size:"small",icon:c?(0,n.jsx)(eV.A,{}):(0,n.jsx)(eX.A,{}),iconLabel:c?h.hideAll:h.showAll,"aria-pressed":c,disabled:g||!m,onClick:()=>m?.(!c)})}),(0,n.jsx)(C.A,{title:l?h.unlock:h.lock,children:(0,n.jsx)(V.J,{mode:"icon-only",size:"small",icon:l?(0,n.jsx)(eG.A,{}):(0,n.jsx)(eK.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)(V.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)(V.J,{mode:"icon-only",size:"small",type:"text",icon:(0,n.jsx)(s.A,{}),iconLabel:p,disabled:y,onClick:()=>{y||(u((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 e0=i(43390),e1=i(74604);function e2({canUndo:e,canRedo:t,undo:i,redo:a,labels:r}){let[o,s]=(0,m.useState)(!1);return(0,m.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)(V.J,{mode:"icon-only",size:"small",icon:(0,n.jsx)(e0.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)(V.J,{mode:"icon-only",size:"small",icon:(0,n.jsx)(e1.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 e5(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=>`(${e9((e.x-a.x)/a.width)}%, ${e9((e.y-a.y)/a.height)}%)`).join("; ")})}else if("radial"===e.type)i="free"===e.mode?t("planningRadialFree",{x:e9(e.x),y:e9(e.y),rayCount:e.angles.length,angles:e.angles.map(e=>`${Math.round(10*e)/10}\xb0`).join(", ")}):t("planningRadial",{x:e9(e.x),y:e9(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:e9(e.x),y:e9(e.y),rotation:Math.round(10*e.rotation)/10,..."golden-spiral"===e.type?{scale:e9(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}),...e6(e,t),t("referencePosition",{x:e9(e.x),y:e9(e.y)})]),c=a.areas.map((e,i)=>[t(e.isLightSource?"lightSourceNumber":"text-region"===e.semanticType?"textRegionNumber":"areaNumber",{index:i+1}),...e6(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(e3(e.visualWeight))})],t("referencePosition",{x:e9(e.center.x),y:e9(e.center.y)}),...e.isLightSource?[]:[t("referenceArea",{area:e9(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"))})]:[]]),m=a.images.map((e,i)=>[t("imageNumber",{index:i+1}),...e6(e,t),..."auto"===e.visualWeight?[]:[t("visualWeight",{weight:t(e3(e.visualWeight))})],t("referencePosition",{x:e9(e.center.x),y:e9(e.center.y)}),t("referenceArea",{area:e9(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"))})]:[]]),u=a.directionLine?[t("flowHeading"),...e6(a.directionLine,t),t("flowReference",{x:e9(a.directionLine.x),y:e9(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:e9(a.metrics.occupiedArea)}),t("negativeSpace",{value:e9(a.metrics.negativeSpace)})]:[],...d.length?["",t("focusHeading")]:[],...d.flatMap(e=>["",...e]),...c.length?["",t("areaHeading")]:[],...c.flatMap(e=>["",...e]),...m.length?["",t("imageHeading")]:[],...m.flatMap(e=>["",...e]),...u.length?["",...u]:[]].join("\n").trimEnd()}function e3(e){return"high"===e?"weightHigh":"medium"===e?"weightMedium":"low"===e?"weightLow":"weightDecorative"}async function e4(e,t){var i;let n,a,r=await e8(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 e8(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 e6(e,t){return[...e.note.trim()?[t("note",{note:e.note.trim()})]:[],..."auto"===e.shotScale?[]:[t("shotScale",{shotScale:t(e.shotScale)})]]}function e9(e){return Math.round(100*e)}i(1820);var e7=i(8647),te=i(59030),tt=i(11902),ti=i(83499),tn=i(49762);function ta(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 tr(e,t){let i=new Set(t);return{...e,groups:e.groups.filter(e=>!e.itemIds.some(e=>i.has(e)))}}function to(e){return(0,v.EN)([...e.images,...e.rectangles,...e.texts].map(e=>e.id),e.layerOrder)}function ts(e,t,i){let n=to(e),a=(0,v.qP)(n,ta(e,t),i);return a===n?e:{...e,layerOrder:[...a]}}var tl=i(27062);let td=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 tc=i(33949);function tm(e){return e.stateTabs?.map(e=>({...e}))??["start",...e.stages.map(e=>e.id)].map((e,t)=>({id:e,number:t+1}))}function tu(e,t,i){return{...e,stateTabs:(0,tc.UR)(tm(e),t,i)}}function th(e,t){return{...e,stateTabs:(0,tc.kq)(tm(e),t)}}function tp(e,t){return{...e,stateTabs:(0,tc.aD)(tm(e),t),stages:e.stages.filter(e=>e.id!==t)}}let tg="start",tf={version:1,kind:"ui-layout-draft",frame:{x:0,y:0,width:960,height:560},overallNote:"",rectangles:[],texts:[],images:[],groups:[],stages:[]};function ty(e){return{...e,...e.layerOrder?{layerOrder:[...e.layerOrder]}:{},frame:{...e.frame},...e.stateTabs?{stateTabs:tm(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 tx(e,t){let i=ty(e);if(t===tg)return i;let n=tw(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 tb(e,t,i){if(i===tg||e.stages.some(e=>e.id===i))throw Error(`Duplicate UI sketch stage id: ${i}.`);let n=tm(e);if(!n.some(e=>e.id===t))throw Error(`Unknown UI sketch stage id: ${t}.`);let a=tx(e,t),r={id:i,rectangles:a.rectangles.map(tj),texts:a.texts.map(tk),images:a.images.map(tI)},o=t===tg?0:e.stages.findIndex(e=>e.id===t)+1;if(0===o&&t!==tg)throw Error(`Unknown UI sketch stage id: ${t}.`);let s=e.stages.map(tS);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}),{...ty(e),stages:s,stateTabs:n}}function tv(e,t,i){let n=t===tg?null:tw(e,t);if(t!==tg&&"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])),m=i.rectangles.map(e=>{let i=r.get(e.id);return i&&t!==tg?{...i,note:e.note,annotation:e.annotation,semanticType:e.semanticType,weight:e.weight}:{...e}}),u=i.texts.map(e=>{let i=o.get(e.id);return i&&t!==tg?{...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!==tg?{...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:m.map(t=>e.id===a?tj(l.get(t.id)??t):{...e.rectangles.find(e=>e.id===t.id)??tj(l.get(t.id)??t)}),texts:u.map(t=>e.id===a?tk(d.get(t.id)??t):{...e.texts.find(e=>e.id===t.id)??tk(d.get(t.id)??t)}),images:h.map(t=>e.id===a?tI(c.get(t.id)??t):{...e.images.find(e=>e.id===t.id)??tI(c.get(t.id)??t)})}));return"end"!==t||n||p.push({id:"end",rectangles:m.map(e=>tj(l.get(e.id)??e)),texts:u.map(e=>tk(d.get(e.id)??e)),images:h.map(e=>tI(c.get(e.id)??e))}),{...e,...i.layerOrder?{layerOrder:to(i)}:{},frame:{...i.frame},overallNote:i.overallNote,groups:i.groups.map(e=>({...e,itemIds:[...e.itemIds]})),rectangles:m,texts:u,images:h,stages:p,...e.stateTabs&&"end"===t&&!n?{stateTabs:[...tm(e),{id:"end",number:Math.max(...tm(e).map(e=>e.number))+1}]}:{}}}function tw(e,t){return e.stages.find(e=>e.id===t)??("end"===t?e.stages[0]:void 0)}function tj(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 tk(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 tI(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 tS(e){return{...e,rectangles:e.rectangles.map(e=>({...e})),texts:e.texts.map(e=>({...e})),images:e.images.map(e=>({...e}))}}function tP(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 tl.Ajv2020({allErrors:!0}).compile(td);let tC=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 tM({text:e,fontSize:t,lineHeight:i=1.4,fontFamily:a,fontWeight:r,fill:o,opacity:s,textAnchor:l="start",className:d,style:c,onBoundsChange:u,"aria-label":h=e}){let p=(0,m.useRef)(null),g=(0,m.useRef)(u),f=(0,m.useRef)(null);g.current=u;let y=["human2ai-canvas-text",d].filter(Boolean).join(" "),x=e.split("\n"),b=!!u;return(0,m.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 tA(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="${tL(t)}" y="${tL(l+i*s)}" font-size="${tL(n)}" text-anchor="${a}" dominant-baseline="middle">${tN(e||" ")}</text>`)}function tL(e){return String(Math.round(100*e)/100)}function tN(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function t$(e,t,i,n=tP){let a=[...e.images.flatMap((i,a)=>{var r,o,s,l;let d,c;return t_(e,i,n)?[(r=e,o=i,s=a,l=t,d=tq(r,o),c=o.note.trim(),[l("imageNumber",{index:s+1}),...c?[l("note",{note:c})]:[],l("visualWeight",{weight:tD(o.weight,l)}),`- ${l("referencePosition",d)}`,`- ${l("referenceSize",d)}`])]:[]}),...e.rectangles.flatMap((i,a)=>{var r,o,s,l;let d,c;return t_(e,i,n)?[(r=e,o=i,s=a,l=t,d=tq(r,o),c=o.note.trim(),[l("regionNumber",{index:s+1}),...c?[l("note",{note:c})]:[],l("visualWeight",{weight:tD(o.weight,l)}),`- ${l("referencePosition",d)}`,`- ${l("referenceSize",d)}`])]:[]}),...e.texts.flatMap((i,a)=>{var r,o,s,l;let d,c;return t_(e,i,n)?[(r=e,o=i,s=a,l=t,d=tE(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:tD(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)}),"",...tT(!1,t),...tF(e.overallNote,t),...i?.trim()?["",i.trim()]:[],...a.length?["",t("elementsHeading")]:[],...a.flatMap(e=>["",...e])].join("\n").trimEnd()}function t_(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 tT(e,t){return[t("layoutHeading"),t("canvasOrigin"),t("referenceValues"),t("perceptibleElementGuidance"),t("flexibleImplementation"),...e?[t("motionStateGuidance")]:[]]}function tF(e,t){let i=e.trim();return i?["",t("globalNoteHeading"),i]:[]}function tR(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 tq(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 tE(e,t){let i=tP(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 tD(e,t){return({auto:t("weightAuto"),high:t("weightHigh"),medium:t("weightMedium"),low:t("weightLow"),decorative:t("weightDecorative")})[e]}async function tz(e,t){var i;let n,a,r=await tB(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 tB(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="${tL(i)}" y="${tL(n)}" width="${tL(t.width)}" height="${tL(t.height)}" rx="8" fill="#eef5ff" stroke="#1677ff" stroke-width="2"/>`,...a?tA(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="${tL(n)}" y="${tL(a)}" width="${tL(i.width)}" height="${tL(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,m=`ui-image-${i.id.replace(/[^a-zA-Z0-9_-]/g,"-")}`;return{id:i.id,svg:`<g data-element-kind="image"><defs><clipPath id="${m}"><rect x="${tL(n)}" y="${tL(a)}" width="${tL(i.width)}" height="${tL(i.height)}"/></clipPath></defs><image href="${tN(r)}" x="${tL(s)}" y="${tL(l)}" width="${tL(d)}" height="${tL(c)}" preserveAspectRatio="${o?"none":"xMidYMid slice"}" clip-path="url(#${m})"/></g>`}}),o=e.texts.filter(e=>e.visible).map(t=>({id:t.id,svg:tA(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, &quot;Segoe UI&quot;, 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 tl.Ajv2020({allErrors:!0}).compile(tC),i(37588);let tO="frame:ui",tU="application/x-human2ai-ui-sketch",tJ={rectangle:{shape:"rectangle",width:280,height:108},image:{shape:"rectangle",width:320,height:180},text:{shape:"rectangle",width:84,height:20,clickOnly:!0}},tW={...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 tH({interactionResetKey:e,draft:t,activeStageId:i=tg,onDraftChange:d,writePrompt:c,writeSketch:u,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:_,onReadImageFile:T,className:q,style:D,"aria-label":z}){var B,U;let J={...tW,...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,m.useId)(),X=(0,m.useMemo)(()=>tx(t,i),[i,t]),[K,Q]=(0,m.useState)(null),[Z,ee]=(0,m.useState)([]),[et,ei]=(0,m.useState)(null),[er,eo]=(0,m.useState)(null),[ed,ec]=(0,m.useState)(!1),[em,eu]=(0,m.useState)(null),[ep,eg]=(0,m.useState)(null),[ef,ey]=(0,m.useState)(!1),[eb,ev]=(0,m.useState)(!1),[ew,ej]=(0,m.useState)(null),{contextMenuOpen:ek,contextMenuPoint:eI,contextMenuPopupRef:eS,openContextMenuAt:eP,closeContextMenu:eC,dismissContextMenu:eM}=b(),[eA,eL]=(0,m.useState)({}),[eN,e$]=(0,m.useState)(null),e_=(0,m.useRef)(null),eT=(0,m.useRef)(null),eF=(0,m.useRef)(null),eR=(0,m.useRef)(!1),eq=(0,m.useRef)(!1),eE=(0,m.useRef)(null),eD=(0,m.useRef)(""),ez=(0,m.useRef)(0),eB=tm(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(tX),eW=new Set(eJ),eH=eJ.length>1?function(e,t,i){let n=t.map(t=>tZ(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}}(X,eJ,eA):null,eY=et?tQ(X,et):null,eV=(0,m.useRef)({updateImage:th,interactionResetKey:e});(0,m.useLayoutEffect)(()=>{eV.current={updateImage:th,interactionResetKey:e}});let eX=O({disabled:!d||!!et||ed,resetKey:`${e}:${i}`,labels:W,onUpload:_,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),Q(null)},onCopy:function(e){let t;if(!e.clipboardData||0===eJ.length)return;let i=(t=new Set(ta(X,eG)),structuredClone({rectangles:X.rectangles.filter(e=>t.has(e.id)),texts:X.texts.filter(e=>t.has(e.id)),images:X.images.filter(e=>t.has(e.id)),groups:X.groups.filter(e=>e.itemIds.every(e=>t.has(e))),layerOrder:to(X).filter(e=>t.has(e))}));0!==i.layerOrder.length&&(eE.current=i,eD.current=tY("ui-sketch-clipboard"),ez.current=0,e.clipboardData.setData(tU,eD.current),e.preventDefault(),e.stopPropagation())},onPasteFallback:function(e){if(e.defaultPrevented||!d||!eE.current||e.clipboardData?.getData(tU)!==eD.current)return;e.preventDefault(),e.stopPropagation();let n=ez.current+1,a=function(e,t,i,n=tg){if(0===t.layerOrder.length)return{draft:e,ids:[]};let a=tx(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=[...to(e),...d],{draft:tv(e,n,a),ids:d}}(t,eE.current,{x:24*n,y:24*n},i);if(0===a.ids.length)return;ez.current=n,tf(),Q(null),d(a.draft);let r=new Set(a.ids);ee([...a.draft.rectangles.filter(e=>r.has(e.id)).map(e=>tV("rectangle",e.id)),...a.draft.texts.filter(e=>r.has(e.id)).map(e=>tV("text",e.id)),...a.draft.images.filter(e=>r.has(e.id)).map(e=>tV("image",e.id))])}}),eG=eJ.map(tG),eK=X.groups.filter(e=>e.itemIds.some(e=>eG.includes(e))),eQ=eG.length>=2&&!X.groups.some(e=>e.itemIds.length===eG.length&&e.itemIds.every(e=>eG.includes(e)));function eZ(e){d&&d(tv(t,i,"function"==typeof e?e(X):e))}function e0(e){tf(),ec(!1),Q(t=>t===e?null:e)}function e1({bounds:e}){var t,i;"rectangle"===K&&(t=e,eZ(e=>{let i={id:tY("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 ee([tV("rectangle",i.id)]),{...e,rectangles:[...e.rectangles,i]}})),"image"===K&&e2(e),"text"===K&&(i=e,eZ(e=>{let t={id:tY("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 ee([tV("text",t.id)]),ei(tV("text",t.id)),eo({kind:"text",item:t}),{...e,texts:[...e.texts,t]}})),Q(null),eR.current=!0,window.setTimeout(()=>{eR.current=!1},0)}function e2(e,t=null){eZ(i=>{let n={id:tY("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 ee([tV("image",n.id)]),{...i,images:[...i.images,n]}})}function e5(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 e3(e,t){if(eq.current){eq.current=!1;return}ee(t.shiftKey?t9(eJ,tK(X,[e])):tK(X,[e]))}function e4(e){if(!(e.target instanceof Element))return;let t=e.target.closest("[data-ui-sketch-item]"),i=t?.dataset.uiSketchItem;i&&tX(i)&&!eW.has(i)?ee(tK(X,[i])):e.target.closest("[data-canvas-frame]")&&ee([tO]),eP(e,t??eT.current?.querySelector("[data-ui-sketch-scene]")??null)}function e8(e,t){let i=eJ.length>1&&eW.has(e)?eJ:tK(X,[e]);eZ(e=>t3(e,i,t))}function e6(e){e9(eJ.length>1&&eW.has(e)?eJ:tK(X,[e]))}function e9(e){eZ(t=>{var i,n,a;let r,o,s;return i=t,o=new Set(n=e),s=new Set(n.map(tG)),{...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(tV("rectangle",e.id))),images:i.images.filter(e=>!o.has(tV("image",e.id))),texts:i.texts.filter(e=>!o.has(tV("text",e.id)))}}),ee([]),ei(null),eo(null)}function tl(e){eZ(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 td(e){eZ(t=>({...t,frame:{...t.frame,x:Math.round(e.bounds.x),y:Math.round(e.bounds.y)}}))}function tc(e,t){eZ(i=>({...i,rectangles:i.rectangles.map(i=>i.id===e?{...i,...t}:i)}))}function tu(e,t){eZ(i=>({...i,texts:i.texts.map(i=>i.id===e?{...i,...t}:i)}))}function th(e,t){eZ(i=>({...i,images:i.images.map(i=>i.id===e?{...i,...t}:i)}))}function tp(e){let t=tQ(X,e);t&&(ei(e),"rectangle"===t.kind?eo({kind:"rectangle",item:{...t.item}}):"text"===t.kind?eo({kind:"text",item:{...t.item}}):eo({kind:"image",item:{...t.item,crop:t.item.crop?{...t.item.crop}:null}}))}function tf(){ei(null),eo(null)}function tb(e){er&&(eo(t=>t?("rectangle"===t.kind||t.kind,{...t,item:{...t.item,...e}}):null),"rectangle"===er.kind?tc(er.item.id,e):"text"===er.kind?tu(er.item.id,e):th(er.item.id,e))}function tw(e){er?.kind==="text"&&(eo(t=>t?.kind==="text"?{...t,item:{...t.item,...e}}:t),tu(er.item.id,e))}function tj(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,eq.current=!1;let t=t8(e,e.currentTarget),i=e.target.closest("[data-ui-sketch-item]"),n=i?.dataset.uiSketchItem;if(n&&tX(n)&&tQ(X,n)){if(!d)return;let i=eW.has(n)?eJ:tK(X,[n]);e_.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 e_.current={type:"marquee",pointerId:e.pointerId,start:t,startClient:{x:e.clientX,y:e.clientY},moved:!1,sourceSelectedKeys:eJ,additive:e.shiftKey},tf()}function tk(e){let t=e_.current;if(!t||t.pointerId!==e.pointerId)return;let i=t8(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,t6(e.currentTarget,e.pointerId)),e.preventDefault(),eR.current=!0,eu(t4(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"),t6(e.currentTarget,e.pointerId)),e.preventDefault(),eR.current=!0,eq.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 tI(e){let t=e_.current;if(t&&t.pointerId===e.pointerId){if("marquee"===t.type){var i,n,a;let r=t.moved?tK(X,(i=X,n=t4(t.start,t8(e,e.currentTarget)),a=eA,[...i.images.map(e=>tV("image",e.id)),...i.rectangles.map(e=>tV("rectangle",e.id)),...i.texts.map(e=>tV("text",e.id))].filter(e=>{var t,r;let o=tZ(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)}))):[];ee(0===r.length?[]:t.additive?t9(t.sourceSelectedKeys,r):r),eu(null)}else if(t5(t),t.moved){let i=t8(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)&&eZ(e=>t3(e,t.keys,n))}e_.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),window.setTimeout(()=>{eR.current=!1,eq.current=!1},0)}}function tS(e){let t=e_.current;t&&t.pointerId===e.pointerId&&("move-items"===t.type&&t5(t),e_.current=null,eu(null),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))}async function tC(e){if(c)await c(e);else{if(!navigator.clipboard?.writeText)throw Error(J.promptUnsupported);await navigator.clipboard.writeText(e)}eg({type:"success",message:J.promptCopied})}async function tA(e){let i=tx(t,e);eg("downloaded"===(u?await u(ty(i)):await tz(i,$))?{type:"warning",message:J.sketchDownloaded}:{type:"success",message:J.sketchCopied})}async function tL(e){ey(!0);try{let i=await x?.(),n=e=>t0(e,eA);await tC("all"===e?function(e,t,i,n=tP){let a=tm(e);return 1===a.length?t$(tx(e,a[0].id),t,i,n):a.slice(1).map((r,o)=>{var s,l,d,c,m,u;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)},m=i,u=n,h=tx(s,l),p=tx(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,m,g,f=y.get(e.id);return f&&(t_(h,e,u)||t_(p,f,u))?[(i=h,n=p,a=e,r=f,o=t,s=c,l=tq(i,a),d=tq(n,r),m=a.note.trim(),g=tR(l,d,a.visible,r.visible,s),[s("imageNumber",{index:o+1}),...m?[s("note",{note:m})]:[],s("visualWeight",{weight:tD(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,m,f,y=g.get(e.id);return y&&(t_(h,e,u)||t_(p,y,u))?[(i=h,n=p,a=e,r=y,o=t,s=c,l=tq(i,a),d=tq(n,r),m=a.note.trim(),f=tR(l,d,a.visible,r.visible,s),[s("regionNumber",{index:o+1}),...m?[s("note",{note:m})]:[],s("visualWeight",{weight:tD(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,m,g,y;let x,b,v,w,j=f.get(e.id);return j&&(t_(h,e,u)||t_(p,j,u))?[(i=h,n=p,a=e,r=j,o=t,s=c,x=tE(i,a),b=tE(n,r),v=a.note.trim(),w=(l=x,d=b,m=a,g=r,y=s,[...m.visible!==g.visible?[y(g.visible?"changeVisible":"changeHidden")]:[],...l.x!==d.x||l.y!==d.y?[y("referencePosition",d)]:[],...Math.round(m.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:tD(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)}),"",...tT(x.length>0,c),...tF(s.overallNote,c),...m?.trim()?["",m.trim()]:[],...x.length?["",c("elementsHeading")]:[],...x.flatMap(e=>["",...e]),...x.length?["",c("motionClosing")]:[]].join("\n").trimEnd()}).join("\n\n")}(t,p,i,n):t$(tx(t,e),p,i,n))}catch(e){eg({type:"error",message:e instanceof Error?e.message:J.promptCopyFailed})}finally{ey(!1)}}async function tN(e){ev(!0);try{await tA(e)}catch(e){eg({type:"error",message:e instanceof Error?e.message:J.sketchCopyFailed})}finally{ev(!1)}}(0,m.useEffect)(()=>{if(!ep)return;let e=window.setTimeout(()=>eg(null),2e3);return()=>window.clearTimeout(e)},[ep]),(0,m.useEffect)(()=>{eO||ej(null)},[eO]),(0,m.useLayoutEffect)(()=>{if(void 0===e)return;let t=e_.current;t?.type==="move-items"&&t5(t),e_.current=null,ee([]),ei(null),eo(null),Q(null),ec(!1),eu(null),eM()},[e]),(0,m.useLayoutEffect)(()=>{Q(null),eM()},[i]),(0,m.useLayoutEffect)(()=>()=>{let e=e_.current;e?.type==="move-items"&&(t5(e),e_.current=null)},[i]);let tB=(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:X.overallNote,placeholder:J.overallNotePlaceholder,"aria-label":J.overallNoteAriaLabel,onChange:e=>eZ(t=>({...t,overallNote:e.target.value}))})]}),t7=eB.map(e=>({key:e.id,label:e.name??p("stateName",{number:e.number})})),ie=(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)(eh.u,{icon:(0,n.jsx)(e7.A,{"aria-hidden":"true"}),label:J.region,collapsedLabel:J.addRegion,"aria-current":"rectangle"===K||void 0,textColor:"rectangle"===K?"color.action.primary":"color.text.primary",disabled:!d,onClick:()=>e0("rectangle")}),(0,n.jsx)(eh.u,{icon:(0,n.jsx)(te.A,{"aria-hidden":"true"}),label:J.text,collapsedLabel:J.addText,"aria-current":"text"===K||void 0,textColor:"text"===K?"color.action.primary":"color.text.primary",disabled:!d,onClick:()=>e0("text")}),(0,n.jsx)(eh.u,{icon:(0,n.jsx)(tt.A,{"aria-hidden":"true"}),label:J.image,collapsedLabel:J.addImage,"aria-current":"image"===K||void 0,textColor:"image"===K?"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)(tn.A,{content:tB,trigger:"click",placement:"leftTop",open:ed,onOpenChange:ec,children:(0,n.jsx)("span",{className:"human2ai-ui-sketch-canvas__side-action",children:(0,n.jsx)(eh.u,{icon:(0,n.jsx)(ti.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"===ew,destroyOnHidden:!0,onOpenChange:e=>ej(t=>e?"prompt":"prompt"===t?null:t),menu:{items:[...t7,{type:"divider"},{key:"all",label:J.copyAllStages}],onClick:({key:e})=>{ej(null),tL(e)}},children:(0,n.jsx)("span",{className:"human2ai-ui-sketch-canvas__side-action",children:(0,n.jsx)(eh.u,{icon:(0,n.jsx)(H.A,{"aria-hidden":"true"}),label:J.copyPrompt,loading:ef})})}):(0,n.jsx)("span",{className:"human2ai-ui-sketch-canvas__side-action",children:(0,n.jsx)(eh.u,{icon:(0,n.jsx)(H.A,{"aria-hidden":"true"}),label:J.copyPrompt,loading:ef,onClick:()=>void tL(eB[0].id)})}),eO?(0,n.jsx)(a.A,{trigger:["click"],open:"sketch"===ew,destroyOnHidden:!0,onOpenChange:e=>ej(t=>e?"sketch":"sketch"===t?null:t),menu:{items:t7,onClick:({key:e})=>{ej(null),tN(e)}},children:(0,n.jsx)("span",{className:"human2ai-ui-sketch-canvas__side-action",children:(0,n.jsx)(eh.u,{icon:(0,n.jsx)(tt.A,{"aria-hidden":"true"}),label:J.copySketch,loading:eb})})}):(0,n.jsx)("span",{className:"human2ai-ui-sketch-canvas__side-action",children:(0,n.jsx)(eh.u,{icon:(0,n.jsx)(tt.A,{"aria-hidden":"true"}),label:J.copySketch,loading:eb,onClick:()=>void tN(eB[0].id)})})]})]}),it=["human2ai-ui-sketch-canvas",q].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:it,style:D,"data-ui-sketch-canvas":!0,"aria-label":z??J.canvas,children:[eX.feedback,ep?(0,n.jsx)("div",{className:`human2ai-ui-sketch-canvas__notice human2ai-ui-sketch-canvas__notice--${ep.type}`,role:"status",children:ep.message}):null,(0,n.jsxs)("div",{ref:eT,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||ts(X,eG,e)===X})),{type:"divider"},{key:"group",label:J.groupItems,disabled:!d||!eQ},{key:"ungroup",label:J.ungroupItems,disabled:!d||0===eK.length}],onClick:({key:e})=>{let t=v.JX.find(t=>t===e);t?eZ(e=>ts(e,eG,t)):"group"===e&&eQ?eZ(e=>(function(e,t,i){let n=ta(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:[...tr(e,n).groups,{id:i,itemIds:n}]}})(e,eG,tY("group"))):"ungroup"===e&&eK.length>0&&eZ(e=>tr(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)(ex,{onContextMenuRequest:e4,onCameraCenterChange:()=>eM(),onZoomChange:()=>eM(),defaultCameraCenter:{x:X.frame.x+X.frame.width/2,y:X.frame.y+X.frame.height/2},contentBounds:X.frame,backgroundPattern:"dots",sideActionPanelWidth:180,sideActionPanelDefaultCollapsed:S,sideActions:I?ie: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)(ea,{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]"))||(ee([]),tf())},onPointerDown:tj,onPointerMove:tk,onPointerUp:tI,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:X.layerOrder?eN:void 0,id:"ui-frame",label:J.frameAction,bounds:X.frame,selected:Z.includes(tO),resizeMode:"free",resizeCenter:{x:0,y:0},minimumWidth:10,minimumHeight:10,screenScale:e.zoom,resizeHitSize:32,locked:P,onSelect:()=>{ee([tO]),tf()},onMove:td,onResize:tl,className:"human2ai-ui-sketch-canvas__frame"}),(0,n.jsx)("g",{className:"human2ai-ui-sketch-canvas__frame-label",transform:`translate(${X.frame.x} ${X.frame.y-12})`,"aria-hidden":"true",children:(0,n.jsxs)("text",{children:[J.frameRange," \xb7 ",Math.round(X.frame.width)," \xd7 ",Math.round(X.frame.height)]})}),(0,v.jQ)([...X.images.map(t=>{let i=tV("image",t.id),a=eW.has(i),r=t1(t),o=t.assetId?$?.(t.assetId):void 0;return(0,n.jsx)("g",{"data-ui-sketch-preview":i,children:(0,n.jsx)(A,{controlsHost:X.layerOrder?eN:void 0,id:t.id,label:`${J.image}:${t.note.trim()||J.image}`,tooltip:e5(t),x:r.x,y:r.y,selected:a,bounds:eH&&a?void 0:t2(t.width,t.height),resizeMode:"proportional",resizeCenter:{x:0,y:0},screenScale:e.zoom,minimumWidth:8,minimumHeight:8,showRotationHandle:!1,onSelect:(e,t)=>e3(i,t),onNudge:e=>e8(i,e),onResize:e=>{th(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:()=>tp(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)(E,{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)}),...X.rectangles.map((t,i)=>{let a=tV("rectangle",t.id),r=eW.has(a),o=t1(t);return(0,n.jsx)("g",{"data-ui-sketch-preview":a,children:(0,n.jsx)(A,{controlsHost:X.layerOrder?eN:void 0,id:t.id,label:`${J.region}:${t.note.trim()||J.missingRegionNote}`,tooltip:e5(t),x:o.x,y:o.y,selected:r,bounds:eH&&r?void 0:t2(t.width,t.height),resizeMode:"free",resizeCenter:{x:0,y:0},screenScale:e.zoom,minimumWidth:8,minimumHeight:8,showRotationHandle:!1,onSelect:(e,t)=>e3(a,t),onNudge:e=>e8(a,e),onResize:e=>{tc(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:()=>tp(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)(F,{type:"rectangle",width:t.width,height:t.height,className:"human2ai-ui-sketch-canvas__rectangle-surface"})})},t.id)}),...X.texts.map(t=>{let i=tV("text",t.id),a=eW.has(i),r=t0(t,eA),o=t1(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:X.layerOrder?eN:void 0,id:t.id,label:`${J.text}:${l}`,tooltip:e5(t),x:o.x,y:o.y,selected:a,bounds:eH&&a?void 0:t2(r.width,r.height),resizeMode:"font-size",resizeCenter:{x:0,y:0},screenScale:e.zoom,minimumWidth:8,minimumHeight:8,showRotationHandle:!1,onSelect:(e,t)=>e3(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),eF.current?.signature!==n&&(eF.current={signature:n,fontSize:t.fontSize}),a=e.bounds.width/Math.max(1,e.sourceBounds.width),void tu(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(eF.current.fontSize*a))})},onDoubleClick:()=>tp(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)(tM,{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)})],X.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,em?(0,n.jsx)("rect",{className:"human2ai-ui-sketch-canvas__marquee",x:em.x,y:em.y,width:em.width,height:em.height,"aria-hidden":"true","data-ui-sketch-marquee":!0}):null,X.layerOrder?(0,n.jsx)("rect",{"data-canvas-layer-frame":!0,className:"human2ai-canvas-shape human2ai-canvas-frame__border",x:X.frame.x,y:X.frame.y,width:X.frame.width,height:X.frame.height,"aria-hidden":"true"}):null,(0,n.jsx)("g",{ref:e$,"data-canvas-controls-layer":!0}),K&&d?(0,n.jsx)(en,{tool:tJ[K],viewportBounds:e.viewportBounds,onPlace:e1,onCancel:()=>Q(null)},`${i}:${K}`):null]})}),et&&eY&&er?(0,n.jsxs)(y,{open:!0,title:"rectangle"===er.kind?J.editRegionNote:"text"===er.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:tf,onSave:()=>void 0,deleteAction:{label:"rectangle"===er.kind?J.deleteRegion:"text"===er.kind?J.deleteText:J.deleteNode,confirmTitle:"rectangle"===er.kind?J.confirmDeleteRegion:"text"===er.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"===er.kind?"human2ai-ui-sketch-canvas__editor-layout--image":null].filter(Boolean).join(" "),"data-human2ai-image-editor-layout":"image"===er.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":er.item.origin,children:(B=er.item.origin,U=J,"agent"===B?U.originAgent:"import"===B?U.originImport:U.originUser)})}),er.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:er.item.annotation})}):null,"text"===er.kind?(0,n.jsx)(f,{label:J.textContent,children:(0,n.jsx)(l.A,{autoFocus:!0,name:"textContent",value:er.item.text,placeholder:J.textPlaceholder,"aria-label":J.textContent,onChange:e=>tw({text:e.target.value})})}):null,(0,n.jsx)(f,{label:J.note,children:(0,n.jsx)(g,{autoFocus:"text"!==er.kind,name:"nodeNote",value:er.item.note,placeholder:"rectangle"===er.kind?J.regionPlaceholder:"text"===er.kind?J.textNotePlaceholder:J.imageNotePlaceholder,"aria-label":J.note,onChange:e=>tb({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:er.item.weight,options:eU,"aria-label":J.visualWeight,onChange:e=>tb({weight:e})})}),(0,n.jsx)(f,{label:J.visibility,children:(0,n.jsx)(r.A,{checked:er.item.visible,checkedChildren:J.visible,unCheckedChildren:J.hidden,"aria-label":J.visibility,onChange:e=>tb({visible:e})})}),"text"===er.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)(V.J,{mode:"icon-only",size:"small",icon:(0,n.jsx)(es.A,{"aria-hidden":"true"}),iconLabel:J.decreaseFontSize,disabled:er.item.fontSize<=8,onClick:()=>tw({fontSize:Math.max(8,Math.round(er.item.fontSize)-1)})}),(0,n.jsxs)("output",{"aria-live":"polite",children:[Math.round(er.item.fontSize),"px"]}),(0,n.jsx)(V.J,{mode:"icon-only",size:"small",icon:(0,n.jsx)(el.A,{"aria-hidden":"true"}),iconLabel:J.increaseFontSize,onClick:()=>tw({fontSize:Math.round(er.item.fontSize)+1})})]})]}):null]})]}),"image"===er.kind?(0,n.jsx)("aside",{className:"human2ai-ui-sketch-canvas__editor-side-fields",children:(0,n.jsx)(G,{src:er.item.assetId?$?.(er.item.assetId):void 0,crop:er.item.crop,aspectRatio:er.item.width/er.item.height,labels:W,onReadFile:T,disabled:!d||!_,onUpload:async t=>{if(!_)return;let i=await _(t),n=eV.current;n.interactionResetKey===e&&(eo(e=>e?.kind==="image"&&e.item.id===er.item.id?{...e,item:{...e.item,assetId:i,crop:null}}:e),n.updateImage(er.item.id,{assetId:i,crop:null}))},onCropChange:(e,i)=>{eo(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=ty(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,er.item.id,e,i))}},er.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(){Q(null),eZ(e=>({...e,rectangles:[],texts:[],images:[],groups:[]})),ee([]),ei(null),eo(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:ie}),w):null]})}function tY(e){return"u">typeof crypto&&"randomUUID"in crypto?`${e}-${crypto.randomUUID()}`:`${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`}function tV(e,t){return`${e}:${t}`}function tX(e){return e.startsWith("rectangle:")||e.startsWith("text:")||e.startsWith("image:")}function tG(e){return e.slice(e.indexOf(":")+1)}function tK(e,t){let i=new Set(ta(e,t.map(tG)));return[...e.rectangles.filter(e=>i.has(e.id)).map(e=>tV("rectangle",e.id)),...e.texts.filter(e=>i.has(e.id)).map(e=>tV("text",e.id)),...e.images.filter(e=>i.has(e.id)).map(e=>tV("image",e.id))]}function tQ(e,t){let i=tG(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 tZ(e,t,i){let n=tQ(e,t);return n?"rectangle"===n.kind||"image"===n.kind?n.item:t0(n.item,i):null}function t0(e,t){let i=tP(e),n=t[e.id];return n&&n.text===e.text&&n.fontSize===e.fontSize?{...i,width:n.width,height:n.height}:i}function t1(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function t2(e,t){return{x:-e/2,y:-t/2,width:e,height:t}}function t5(e){null!==e.animationFrame&&cancelAnimationFrame(e.animationFrame),e.previewElements.forEach(e=>e.removeAttribute("transform")),e.scene.removeAttribute("data-canvas-dragging")}function t3(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(tV("rectangle",e.id))?{...e,x:e.x+n.x,y:e.y+n.y}:e),images:e.images.map(e=>a.has(tV("image",e.id))?{...e,x:e.x+n.x,y:e.y+n.y}:e),texts:e.texts.map(e=>a.has(tV("text",e.id))?{...e,x:e.x+n.x,y:e.y+n.y}:e)}}function t4(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 t8(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 t6(e,t){try{e.setPointerCapture(t)}catch{}}function t9(e,t){let i=new Set(e);return t.forEach(e=>{i.has(e)?i.delete(e):i.add(e)}),[...i]}function t7(e="black"){return"white"===e?"var(--yisiui-color-text-inverse)":"var(--yisiui-color-text-primary)"}function ie({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,m.useMemo)(()=>new Map(e.map(e=>[e.key,e])),[e]),y=e[0].key,[x,b]=(0,m.useState)(d??y),v=(0,m.useId)(),w=(0,m.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,u.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":t7(o),...s?{"--yisiui-tab-switch-unselected-text-color":t7(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 it={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 ii(e){return"children"in e?(0,n.jsx)(ia,{...e}):(0,n.jsx)(ir,{...e})}function ia({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 ir({stateControls:e,interactionResetKey:t,selectedPlanIds:i,planningLocked:a=!1,onPlanSelectionChange:r,planningLabels:o,draft:s,status:l,refinement:d=null,activeView:c,onViewChange:m,selectedIds:u=[],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:_,areaEditorLabels:T,imageEditorLabels:F,resolveImageSource:R,renderCameraReference:q,onImageUpload:E,onReadImageFile:D,labels:z,className:B,style:O}){let U={...it,...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)(ia,{className:B,style:O,workflowStatus:W,activeView:Y,stateControls:e??(0,n.jsx)(ie,{items:X,value:Y,"aria-label":U.viewSwitch,onChange:e=>m(e)}),children:["draft"===Y?(0,n.jsx)(eC,{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:_,areaEditorLabels:T,imageEditorLabels:F,renderCameraReference:q,resolveImageSource:R,onImageUpload:E,onReadImageFile:D,selectedIds:u,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)(eC,{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)(io,{refinement:d,labels:U})]}):null,"reference"===Y?(0,n.jsx)(eC,{draft:V,appearance:"reference",layerLabels:N,nodeEditorLabels:$,resolveImageSource:R,"aria-label":U.referenceCanvas}):null]})}function io({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:is(i.maximumFocusShift)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:t.maximumAreaShift}),(0,n.jsx)("dd",{children:is(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 is(e){return`${(100*e).toFixed(1)}%`}var il=i(81309);i(42666);var id=i(92449);let ic={sidebar:"Application sidebar",navigation:"Application navigation",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",rightPanel:"Right panel",collapseRightPanel:"Collapse right panel",expandRightPanel:"Expand right panel"};function im(e){return"number"==typeof e?`${e}px`:e}function iu({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,m.useId)(),C=(0,m.useId)(),M=(0,m.useRef)(null),A=(0,m.useRef)(null),[L,N]=(0,m.useState)(g),[$,_]=(0,m.useState)(v),T=void 0!==p,F=void 0!==b,R=null!=l,q=null!=r&&!1!==r,E=!h||(p??L),D=R&&(!x||(b??$)),z={...ic,...k},B={"--yisi-app-shell-sidebar-width":im(y),"--yisi-app-shell-right-panel-width":im(j),...S};function O(e){T||N(e),f?.(e)}return(0,n.jsxs)("div",{...(0,u.S)("app-shell-frame","AppShellFrame","layout"),className:["yisi-app-shell-frame",!E?"yisi-app-shell-frame--sidebar-hidden":null,!D?"yisi-app-shell-frame--right-panel-hidden":null,I].filter(Boolean).join(" "),"data-sidebar-state":E?"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":!E,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&&E?(0,n.jsx)(c.Ay,{className:"yisi-app-shell-sidebar-toggle",type:"text",icon:(0,n.jsx)(id.D,{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&&!E?(0,n.jsx)(c.Ay,{className:"yisi-app-shell-content-toggle",type:"text",icon:(0,n.jsx)(id.D,{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&&!E&&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)(il.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,q||R&&x?(0,n.jsxs)("div",{className:"yisi-app-shell-content-trailing",children:[q?(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)(id.D,{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(!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 ih={productName:"human2ai",sidebar:"Human2AI 应用侧栏",navigation:"Human2AI 应用导航",collapseSidebar:"收起应用侧栏",expandSidebar:"展开应用侧栏",rightPanel:"页面属性",collapseRightPanel:"收起页面属性",expandRightPanel:"展开页面属性"};function ip({title:e,brand:t,children:i,sidebar:a,rightPanel:r,rightPanelOpen:o,onRightPanelOpenChange:s,labels:l,className:d}){let c={...ih,...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)(iu,{sidebar:a,sidebarTitle:t??c.productName,title:e?(0,n.jsx)("h1",{className:"human2ai-app-shell__page-title",children:e}):void 0,rightPanel:r,rightPanelOpen:o,onRightPanelOpenChange:s,sidebarWidth:280,rightPanelWidth:300,labels:c,children:i})})}var ig=i(6915),iy=i(14766),ix=i(510),ib=i(21494),iv=i(81793),iw=i(11075),ij=i(62067),ik=i(48389),iI=i(50152),iS=i(44081),iP=i(48624),iC=i(88398),iM=i(24909),iA=i(67872),iL=i(40684),iN=i(41103);i(52048),i(68071),i(12190);let i$={default:{},info:{color:"blue",icon:(0,n.jsx)(iP.A,{})},success:{color:"green",icon:(0,n.jsx)(iC.A,{})},warning:{color:"orange",icon:(0,n.jsx)(iM.A,{})},danger:{color:"red",icon:(0,n.jsx)(iA.A,{})},processing:{color:"processing",icon:(0,n.jsx)(iL.A,{})}};function i_({label:e,tone:t="default",icon:i,mode:a="icon-text",tooltip:r}){let o=i$[t],s=i??o.icon,l=(0,n.jsx)(iN.A,{...(0,u.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:iT}=iI.A;function iF(e){return e.isLeaf?null:(0,n.jsx)(ik.A,{className:"yisi-asset-skeleton-tree-switcher",rotate:90*!!e.expanded})}function iR(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 iq({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 iE({nodes:e,mode:t,className:i,currentKey:a=null,maxTitleLength:r=24,showCurrent:o,showContentOrder:s=!0,showLock:l,showStatus:d,canDragNode:c,switcherIcon:h,allowDrop:p,dropIndicatorRender:g,onDragStart:f,onDragEnd:y,onDragLeave:x,onDragOver:b,onDrop:v,...w}){var j,k,I,S,P;let C,M,A,L,[N,$]=(0,m.useState)(!1),[_,T]=(0,m.useState)(null),F=(0,m.useRef)(null),R=(0,m.useRef)(null),q=o??"view"===t,E=l??"edit"===t,D=d??"view"===t,z="edit"===t,B=(C=iR(e),M=new Map,A=1,!function e(t){for(let i of C.get(t)??[])"content"!==i.nodeKind||i.isDeleted||(M.set(i.key,String(A).padStart(2,"0")),A+=1),e(i.key)}(null),M),O=new Map(e.map(e=>[e.key,e])),U="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)&&(p?.(t)??!0):p;return(0,m.useEffect)(()=>()=>{null!==F.current&&window.clearTimeout(F.current),null!==R.current&&window.clearTimeout(R.current)},[]),(0,n.jsx)("div",{...(0,u.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":"",N?"yisi-asset-skeleton-tree-scrolling":"",i].filter(Boolean).join(" "),"data-mode":t,onScroll:function(){$(!0),null!==F.current&&window.clearTimeout(F.current),F.current=window.setTimeout(()=>{$(!1),F.current=null},700)},children:(0,n.jsx)(iS.A,{blockNode:!0,...w,className:"yisi-asset-skeleton-tree-control",allowDrop:U,draggable:"edit"===t&&{icon:!1,nodeDraggable:e=>{let t=O.get(String(e.key));return!!(t&&!t.locked&&!t.disabled&&!t.isDeleted&&(c?.(t)??!0))}},dropIndicatorRender:g??iq,expandAction:w.expandAction??"click",onDragStart:"edit"===t?function(e){f?.(e)}:f,onDragEnd:"edit"===t?function(e){y?.(e)}:y,onDragLeave:"edit"===t?function(e){x?.(e)}:x,onDragOver:"edit"===t?function(e){b?.(e)}:b,onDrop:"edit"===t?function(e){T(String(e.dragNode.key)),null!==R.current&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{T(null),R.current=null},720),v?.(e)}:v,switcherIcon:h??iF,treeData:(j=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||s||D&&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,z&&e.isDeleted?(0,n.jsx)(i_,{label:"[del]",tone:"danger",mode:"text-only"}):z&&e.isNew?(0,n.jsx)(i_,{label:"[new]",tone:"success",mode:"text-only"}):null,E&&e.locked?(0,n.jsx)(i_,{label:"锁定",tone:"warning",mode:"text-only",tooltip:e.lockedReason||"已锁定"}):null,(0,n.jsx)("div",{className:"yisi-asset-skeleton-tree-copy",children:(0,n.jsx)(iT,{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)(iT,{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,s?(0,n.jsx)(i_,{label:"当前",tone:"success",mode:"text-only"}):null,D&&e.status?(0,n.jsx)(i_,{label:e.status.label,tone:e.status.tone,icon:e.status.icon,mode:e.status.icon?"icon-only":"text-only"}):null]}):null]})},k=function(e){if(!s||"content"!==e.nodeKind)return;let t=B.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)(i_,{label:t,tone:e.contentOrderTone??"default",mode:"text-only",tooltip:`内容顺序 ${t}`}):null})},I=e=>!!e.disabled,S=e=>e.key===a,P=e=>e.key===_,L=iR(e),function e(t){return(L.get(t)??[]).map(t=>{let i=e(t.key);return{key:t.key,title:j(t),switcherIcon:k(t),disabled:I(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(" "),S(t)?"yisi-asset-skeleton-tree-item-current":"",P(t)?"yisi-asset-skeleton-tree-item-moved":""].filter(Boolean).join(" "),isLeaf:0===i.length,children:i.length?i:void 0}})}(null))})})}var iD=i(95948),iz=i(37132);i(17346);let iB={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 iO({value:e,options:t,onChange:i,"aria-label":a,placeholder:r,placement:s="bottom",disabled:l=!1,className:d,style:c}){let[u,h]=(0,m.useState)(!1),p=(0,m.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,m.useEffect)(()=>{f&&h(!1)},[f]),(0,m.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":u?"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:iB,disabled:f,listHeight:240,onChange:function(e){h(!1),i(e)},onOpenChange:function(e){y(),h(!f&&e)},open:u,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)(iz.A,{className:"human2ai-compact-dropdown-select__arrow","aria-hidden":"true"}),value:e,virtual:!1})})}i(80118);let iU={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 iJ({projects:e,sessions:t,currentSessionId:i=null,loading:r=!1,errorMessage:o,labels:s,languageSelector:u,repositoryLink:h,onCreateComposition:p,onCreateUiSketch:g,onCreateSpatial:f,onCreateProject:y,onOpenStyleLibrary:x,onRenameProject:b,onDeleteProject:v,onOpenSession:w,onRenameSession:j,onMoveSession:I,onDeleteSession:S,onRetry:P}){let M,A,L={...iU,...s},N=(0,m.useRef)(null),[$,_]=(0,m.useState)(!1),[T,F]=(0,m.useState)(""),[R,q]=(0,m.useState)(null),[E,D]=(0,m.useState)(null),[z,B]=(0,m.useState)([]),O=(0,m.useRef)(new Set),[U,J]=(0,m.useState)(null),[W,H]=(0,m.useState)(""),[Y,X]=(0,m.useState)(null),[G,K]=(0,m.useState)(null),[Q,Z]=(0,m.useState)(""),[ee,et]=(0,m.useState)(null),[ei,en]=(0,m.useState)(""),[ea,er]=(0,m.useState)(null),[eo,es]=(0,m.useState)(null),el=iY(e,T),ed=iY(e,W,U?.id),ec=t.some(e=>null===e.projectId);(0,m.useEffect)(()=>{let t=[...e.map(e=>iW(e.id)),...ec?["project:unassigned"]:[]],i=t.filter(e=>!O.current.has(e));O.current=new Set(t),0!==i.length&&B(e=>[...new Set([...e,...i])])},[ec,e]);let em=new Map(t.map(e=>[iH(e.id),e])),eu=(M=e.flatMap((e,i)=>{var r,o;let s,l,d,m;return[{key:iW(e.id),parentKey:null,order:i,nodeKind:"container",title:e.name,trailing:(r=e,s=L.newCompositionInProject(r.name),l=L.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)(tt.A,{"aria-hidden":"true"}),"aria-label":s,loading:"composition"===R&&E===r.id,disabled:!!(R&&("composition"!==R||E!==r.id)),onClick:e=>{e.stopPropagation(),eg(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)(ig.A,{"aria-hidden":"true"}),"aria-label":l,loading:"ui-sketch"===R&&E===r.id,disabled:!!(R&&("ui-sketch"!==R||E!==r.id)),onClick:e=>{e.stopPropagation(),ef(r.id)},onPointerDown:e=>e.stopPropagation()})}),f&&(0,n.jsx)(C.A,{title:L.newSpatialInProject(r.name),children:(0,n.jsx)(c.Ay,{className:"human2ai-workspace-sidebar__node-action",type:"text",size:"small",icon:(0,n.jsx)(iy.A,{}),"aria-label":L.newSpatialInProject(r.name),disabled:!!R,onClick:e=>{e.stopPropagation(),ey(r.id)},onPointerDown:e=>e.stopPropagation()})}),(o=r,d=t.some(e=>e.projectId===o.id),m=[{key:"rename",label:L.rename},{key:"delete",label:L.delete,danger:!0,disabled:d,title:d?L.deleteProjectDisabled:void 0}],(0,n.jsx)(a.A,{trigger:["click"],menu:{items:m,onClick:({key:e,domEvent:t})=>{t.stopPropagation(),es(null),"rename"===e?(J(o),H(o.name)):"delete"!==e||d||X(o)}},children:(0,n.jsx)(c.Ay,{className:"human2ai-workspace-sidebar__node-menu",type:"text",size:"small",icon:(0,n.jsx)(ix.A,{}),"aria-label":`${o.name}:${L.projectActions}`,title:L.projectActions,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})}))]}))},...t.filter(t=>t.projectId===e.id).map((t,i)=>({key:iH(t.id),parentKey:iW(e.id),order:i,nodeKind:"content",title:t.title,trailing:ep(t)}))]}),0===(A=t.filter(e=>null===e.projectId).map((e,t)=>({key:iH(e.id),parentKey:"project:unassigned",order:t,nodeKind:"content",title:e.title,trailing:ep(e)}))).length?M:[...M,{key:"project:unassigned",parentKey:null,order:e.length,nodeKind:"container",title:L.unassigned},...A]);function ep(t){let i=e.every(e=>e.id===t.projectId),r=[{key:"rename",label:L.rename},{key:"move",label:L.move,disabled:i,title:i?L.moveUnavailable:void 0},{key:"delete",label:L.delete,danger:!0}];return(0,n.jsx)(a.A,{trigger:["click"],menu:{items:r,onClick:({key:e,domEvent:n})=>{n.stopPropagation(),es(null),"rename"===e?(K(t),Z(t.title)):"move"!==e||i?"delete"===e&&er(t):(et(t),en(""))}},children:(0,n.jsx)(c.Ay,{className:"human2ai-workspace-sidebar__node-menu",type:"text",size:"small",icon:(0,n.jsx)(ix.A,{}),"aria-label":`${t.title}:${L.sessionActions}`,title:L.sessionActions,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})})}async function eg(e){eb(e),q("composition"),D(e??null),es(null);try{await p(e)}catch{es(L.actionFailed)}finally{q(null),D(null)}}async function ef(e){eb(e),q("ui-sketch"),D(e??null),es(null);try{await g(e)}catch{es(L.actionFailed)}finally{q(null),D(null)}}async function ey(e){eb(e),q("spatial"),D(e??null),es(null);try{await f?.(e)}catch{es(L.actionFailed)}finally{q(null),D(null)}}async function ex(){let e=T.trim();if(e&&!el&&!R){q("create-project"),es(null);try{await y(e),_(!1),F("")}catch(e){es(iV(e,L))}finally{q(null)}}}function eb(e){let t=e?iW(e):"project:unassigned";B(e=>e.includes(t)?e:[...e,t])}async function ev(){let e=W.trim();if(U&&e&&!ed&&!R){q("rename-project"),es(null);try{await b(U.id,e),J(null)}catch(e){es(iV(e,L))}finally{q(null)}}}async function ew(){if(Y&&!R){q("delete-project"),es(null);try{await v(Y.id),X(null)}catch(e){es(iV(e,L))}finally{q(null)}}}async function ej(){let e=Q.trim();if(G&&e&&!R){q("rename-session"),es(null);try{await j(G.id,e),K(null)}catch{es(L.actionFailed)}finally{q(null)}}}async function ek(){if(ee&&ei&&!R){q("move-session"),es(null);try{await I(ee.id,ei),et(null),en("")}catch{es(L.actionFailed)}finally{q(null)}}}async function eI(){if(ea&&!R){q("delete-session"),es(null);try{await S(ea.id),er(null)}catch{es(L.actionFailed)}finally{q(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:L.functionArea}),(0,n.jsx)(eh.u,{icon:(0,n.jsx)(tt.A,{"aria-hidden":"true"}),label:L.newComposition,collapsedLabel:L.newComposition,loading:"composition"===R&&null===E,disabled:!!(R&&("composition"!==R||null!==E)),onClick:()=>void eg()}),(0,n.jsx)(eh.u,{icon:(0,n.jsx)(ig.A,{"aria-hidden":"true"}),label:L.newUiSketch,collapsedLabel:L.newUiSketch,loading:"ui-sketch"===R&&null===E,disabled:!!(R&&("ui-sketch"!==R||null!==E)),onClick:()=>void ef()}),f&&(0,n.jsx)(eh.u,{icon:(0,n.jsx)(iy.A,{"aria-hidden":"true"}),label:L.newSpatial,collapsedLabel:L.newSpatial,loading:"spatial"===R&&null===E,disabled:!!(R&&"spatial"!==R),onClick:()=>void ey()}),(0,n.jsx)(eh.u,{icon:(0,n.jsx)(ib.A,{"aria-hidden":"true"}),label:L.newProject,collapsedLabel:L.newProject,disabled:!!R,onClick:function(){es(null),_(!0)}}),(0,n.jsx)(eh.u,{icon:(0,n.jsx)(iv.A,{"aria-hidden":"true"}),label:L.styleLibrary,collapsedLabel:L.styleLibrary,onClick:x}),!eo||$||U||Y||G||ee||ea?null:(0,n.jsx)("p",{className:"human2ai-workspace-sidebar__error",role:"alert",children:eo})]}),(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:L.projectArea}),r?(0,n.jsx)(iD.G,{className:"human2ai-workspace-sidebar__loading",label:L.loading,rows:6,compact:!0}):o?(0,n.jsxs)("div",{className:"human2ai-workspace-sidebar__state",role:"alert",children:[(0,n.jsx)("span",{children:L.loadFailed}),P?(0,n.jsx)(c.Ay,{type:"text",size:"small",icon:(0,n.jsx)(iw.A,{}),onClick:P,children:L.retry}):null]}):(0,n.jsx)(iE,{nodes:eu,mode:"view",defaultExpandAll:!0,showContentOrder:!1,showCurrent:!1,showIcon:!0,showStatus:!1,expandedKeys:z,onExpand:e=>B(e.map(String)),icon:({eventKey:e})=>{var t,i;let a,r,o=em.get(String(e));return o?(t=o.sessionType,i=L,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)(iy.A,{"aria-hidden":"true"}):a?(0,n.jsx)(tt.A,{"aria-hidden":"true"}):(0,n.jsx)(ig.A,{"aria-hidden":"true"})})):null},currentKey:i?iH(i):null,selectedKeys:i?[iH(i)]:[],onSelect:e=>{let t=String(e[0]??"");t.startsWith("session:")&&w(t.slice(8))}})]}),u||h?(0,n.jsxs)("div",{className:"human2ai-workspace-sidebar__language-selector",children:[h?(0,n.jsx)(V.J,{className:"human2ai-workspace-sidebar__repository-link",mode:"icon-only",icon:(0,n.jsx)(ij.A,{"aria-hidden":"true"}),iconLabel:h.label,title:h.label,href:h.href,target:"_blank",rel:"noopener noreferrer",backgroundColor:"none"}):null,u?(0,n.jsx)(iO,{...u}):null]}):null,(0,n.jsxs)(d.A,{open:$,title:L.newProject,okText:L.createProject,footer:(e,{OkBtn:t})=>(0,n.jsx)(t,{}),confirmLoading:"create-project"===R,okButtonProps:{disabled:!T.trim()||el},afterOpenChange:e=>{e&&N.current?.focus()},onOk:()=>void ex(),onCancel:function(){"create-project"!==R&&(_(!1),F(""),es(null))},children:[(0,n.jsx)(l.A,{ref:N,id:"human2ai-project-name",name:"projectName",value:T,maxLength:200,disabled:"create-project"===R,status:el?"error":void 0,placeholder:L.projectNamePlaceholder,"aria-label":L.projectNamePlaceholder,"aria-invalid":el,"aria-describedby":el||eo?"human2ai-project-name-error":void 0,onChange:e=>{F(e.target.value),es(null)},onPressEnter:()=>void ex()}),el||eo?(0,n.jsx)("p",{id:"human2ai-project-name-error",className:"human2ai-workspace-sidebar__error",role:"alert",children:el?L.projectNameConflict:eo}):null]}),(0,n.jsxs)(d.A,{open:!!U,title:L.renameProjectTitle,okText:L.confirmRename,footer:(e,{OkBtn:t})=>(0,n.jsx)(t,{}),confirmLoading:"rename-project"===R,okButtonProps:{disabled:!W.trim()||ed},onOk:()=>void ev(),onCancel:()=>{"rename-project"!==R&&J(null)},children:[(0,n.jsx)(l.A,{autoFocus:!0,id:"human2ai-project-rename",name:"projectName",value:W,maxLength:200,disabled:"rename-project"===R,status:ed?"error":void 0,placeholder:L.projectNamePlaceholder,"aria-label":L.projectNamePlaceholder,"aria-invalid":ed,"aria-describedby":ed||eo?"human2ai-project-rename-error":void 0,onChange:e=>{H(e.target.value),es(null)},onPressEnter:()=>void ev()}),ed||eo?(0,n.jsx)("p",{id:"human2ai-project-rename-error",className:"human2ai-workspace-sidebar__error",role:"alert",children:ed?L.projectNameConflict:eo}):null]}),(0,n.jsxs)(d.A,{open:!!Y,title:L.deleteProjectTitle,okText:L.delete,cancelText:L.cancel,confirmLoading:"delete-project"===R,okButtonProps:{danger:!0},onOk:()=>void ew(),onCancel:()=>{"delete-project"!==R&&X(null)},children:[(0,n.jsx)("p",{children:Y?.name}),(0,n.jsx)("p",{children:L.deleteProjectDescription}),eo?(0,n.jsx)("p",{className:"human2ai-workspace-sidebar__error",role:"alert",children:eo}):null]}),(0,n.jsxs)(d.A,{open:!!G,title:L.renameSessionTitle,okText:L.confirmRename,footer:(e,{OkBtn:t})=>(0,n.jsx)(t,{}),confirmLoading:"rename-session"===R,okButtonProps:{disabled:!Q.trim()},onOk:()=>void ej(),onCancel:()=>{"rename-session"!==R&&K(null)},children:[(0,n.jsx)(l.A,{autoFocus:!0,id:"human2ai-session-title",name:"sessionTitle",value:Q,maxLength:200,placeholder:L.renameSessionPlaceholder,"aria-label":L.renameSessionPlaceholder,onChange:e=>Z(e.target.value),onPressEnter:()=>void ej()}),eo?(0,n.jsx)("p",{className:"human2ai-workspace-sidebar__error",role:"alert",children:eo}):null]}),(0,n.jsxs)(d.A,{open:!!ee,title:L.moveSessionTitle,okText:L.move,footer:(e,{OkBtn:t})=>(0,n.jsx)(t,{}),confirmLoading:"move-session"===R,okButtonProps:{disabled:!ei},onOk:()=>void ek(),onCancel:()=>{"move-session"!==R&&(et(null),en(""))},children:[(0,n.jsx)("p",{children:ee?.title}),(0,n.jsx)(iO,{value:ei,options:[{value:"",label:L.selectProject,disabled:!0},...e.filter(e=>e.id!==ee?.projectId).map(e=>({value:e.id,label:e.name}))],onChange:en,"aria-label":L.selectProject,disabled:"move-session"===R}),eo?(0,n.jsx)("p",{className:"human2ai-workspace-sidebar__error",role:"alert",children:eo}):null]}),(0,n.jsxs)(d.A,{open:!!ea,title:L.deleteSessionTitle,okText:L.delete,cancelText:L.cancel,confirmLoading:"delete-session"===R,okButtonProps:{danger:!0},onOk:()=>void eI(),onCancel:()=>{"delete-session"!==R&&er(null)},children:[(0,n.jsx)("p",{children:ea?.title}),(0,n.jsx)("p",{children:L.deleteSessionDescription}),eo?(0,n.jsx)("p",{className:"human2ai-workspace-sidebar__error",role:"alert",children:eo}):null]})]})}function iW(e){return`project:${e}`}function iH(e){return`session:${e}`}function iY(e,t,i){let n=t.trim();return!!n&&e.some(e=>e.id!==i&&e.name.trim()===n)}function iV(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 iX(e){if(!navigator.clipboard?.writeText)throw Error("Clipboard API unavailable.");await navigator.clipboard.writeText(e)}function iG(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 iK({primaryItem:e,createdAt:t,updatedAt:i,nodeCount:a,agentCommand:r,locale:o,labels:s,writeText:l=iX,className:d,style:c}){let u=(0,m.useId)(),[h,p]=(0,m.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":u,className:["human2ai-session-details",d].filter(Boolean).join(" "),style:c,children:[(0,n.jsx)("h2",{id:u,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:iG(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:iG(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)(Y.r,{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 iQ=i(46759),iZ=i(61598),i0=i(92334),i1=i(11288);function i2({images:e,title:t,aspectRatio:i="3 / 2",className:a,...r}){let o=m.Children.toArray(e);return(0,n.jsxs)("figure",{...r,...(0,u.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 i5=(0,m.lazy)(()=>Promise.all([i.e(977),i.e(218),i.e(484)]).then(i.bind(i,88484))),i3=new Set(["image/png","image/jpeg","image/webp"]);function i4({styles:e,labels:t,loading:i=!1,errorMessage:a,imageUrl:r,modelUrl:o,onCreate:c,onUpdate:u,onDelete:p,onRetry:g,initialCategory:f,selection:y}){var x,b,v,w;let[j,I]=(0,m.useState)(f??"all"),[S,P]=(0,m.useState)("all"),[C,M]=(0,m.useState)(""),[A,L]=(0,m.useState)(null),[N,$]=(0,m.useState)("model"),[_,T]=(0,m.useState)(null),[F,R]=(0,m.useState)(null),[q,E]=(0,m.useState)(""),[D,z]=(0,m.useState)("visual"),[B,O]=(0,m.useState)(""),[U,J]=(0,m.useState)(""),[W,H]=(0,m.useState)([]),[Y,X]=(0,m.useState)([]),[G,K]=(0,m.useState)(!1),[Q,Z]=(0,m.useState)(!1),[ee,et]=(0,m.useState)(null),ei=(0,m.useRef)(null),en=(0,m.useRef)([]),ea=e.find(e=>e.id===A)??null,er=F&&"new"!==F?e.find(e=>e.id===F)??null:null,eo=er?.referenceImages.filter(e=>!Y.includes(e.id))??[],es=ea?.referenceImages.find(e=>e.id===_)??ea?.referenceImages[0]??null,ed=(0,m.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 ec(){G||(em(),R(null),X([]),et(null))}function em(){H(e=>{for(let t of e)URL.revokeObjectURL(t.previewUrl);return[]})}function eu(e){let i=e.filter(e=>i3.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=q.trim(),i=B.trim();if(!e||!i||!U.trim()||G||(er?!u:!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 u(er,n):await c(n);em(),R(null),X([]),L(e.id),T(e.referenceImages[0]?.id??null)}catch{et(t.operationFailed)}finally{K(!1)}}async function ep(){if(ea&&!Q&&p){Z(!0),et(null);try{await p(ea),L(null),T(null)}catch{et(t.operationFailed)}finally{Z(!1)}}}return(0,m.useEffect)(()=>{en.current=W},[W]),(0,m.useEffect)(()=>()=>{for(let e of en.current)URL.revokeObjectURL(e.previewUrl)},[]),(0,m.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)(iQ.A,{"aria-hidden":"true"}),value:C,placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,onChange:e=>M(e.target.value)}),(0,n.jsx)(ie,{"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)(ie,{"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)(V.J,{type:"primary",mode:"with-icon",icon:(0,n.jsx)(el.A,{"aria-hidden":"true"}),backgroundColor:"color.action.primaryActive",textColor:"color.text.onPrimary",onClick:function(){em(),R("new"),E(""),z("visual"),O(""),J(""),X([]),et(null)},children:t.newStyle}):null]}),i?(0,n.jsx)(iD.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)(V.J,{type:"text",mode:"with-icon",icon:(0,n.jsx)(iw.A,{"aria-hidden":"true"}),onClick:g,children:t.retry}):null]}):0===ed.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:ed.map(e=>{let i=e.referenceImages[0];return(0,n.jsxs)("div",{className:"human2ai-style-library__card",children:[(0,n.jsx)(i2,{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)(iZ.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),T(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)(i0.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:Q,onConfirm:ep,children:t.delete}):null,u?(0,n.jsx)(V.J,{type:"primary",mode:"with-icon",icon:(0,n.jsx)(i1.A,{"aria-hidden":"true"}),backgroundColor:"color.action.primaryActive",textColor:"color.text.onPrimary",onClick:()=>{em(),R(ea.id),E(ea.name),z(ea.category),O(ea.description),J(ea.promptSummary),X([]),et(null)},children:t.editStyle}):null,y?(0,n.jsx)(V.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:()=>{Q||G||(L(null),T(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)(ie,{"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)(m.Suspense,{fallback:(0,n.jsx)("div",{role:"status",children:t.model.loading}),children:(0,n.jsx)(i5,{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:()=>T(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!==F,title:er?t.editStyle:t.newStyle,footer:null,onCancel:ec,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:q,maxLength:200,placeholder:t.namePlaceholder,onChange:e=>E(e.target.value)})]}),(0,n.jsxs)("div",{className:"human2ai-style-library__field",children:[(0,n.jsx)("span",{children:t.category}),(0,n.jsx)(ie,{"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)(i8,{reference:e,previewUrl:r(e.styleId,e.id),removeLabel:t.removeReference,onRemove:()=>X(t=>[...t,e.id])},e.id)),W.map(e=>(0,n.jsx)(i8,{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)(el.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)(V.J,{disabled:G,onClick:ec,children:t.cancel}),(0,n.jsx)(V.J,{type:"primary",loading:G,disabled:!q.trim()||!B.trim()||!U.trim(),backgroundColor:"color.action.primaryActive",textColor:"color.text.onPrimary",onClick:()=>void eh(),children:t.save})]})]})})]})}function i8({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)(i0.A,{"aria-hidden":"true"})}),e?(0,n.jsx)("span",{children:e.position+1}):null]})}function i6({styles:e,currentStyle:t,category:i,labels:a,libraryLabels:r,imageUrl:o,modelUrl:s,onBind:l,onRetry:c,loading:u=!1,saving:h=!1,disabled:p=!1,error:g,pending:f=!1}){let[y,x]=(0,m.useState)(!1),b=(0,m.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)(V.J,{className:"human2ai-session-style-picker__choose",mode:"with-icon",icon:(0,n.jsx)(iz.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)(V.J,{type:"text",mode:"icon-only",icon:(0,n.jsx)(i0.A,{"aria-hidden":"true"}),"aria-label":a.unbind,disabled:p||h||u,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)(i0.A,{"aria-hidden":"true"}),width:1e3,footer:null,onCancel:()=>{h||x(!1)},destroyOnHidden:!0,children:(0,n.jsx)(i4,{styles:e,labels:r,loading:u,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 i9=i(1660);function i7({items:e,value:t,labels:i,onChange:r,onRename:o,onDelete:s,onCreate:c,onReorder:u}){let[h,p]=(0,m.useState)(null),[g,f]=(0,m.useState)(null),[y,x]=(0,m.useState)(""),[b,v]=(0,m.useState)(null),w=(0,m.useRef)(null),j=(0,m.useRef)(null),I=(0,m.useRef)(null),S=(0,m.useRef)(null),P=(0,m.useRef)(!1),A=(0,m.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 _(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 T(){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),u(i)}$()}function F(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,m.useEffect)(()=>{let e=()=>$();return window.addEventListener("blur",e),()=>{j.current&&clearTimeout(j.current),window.removeEventListener("blur",e)}},[]),(0,m.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)(V.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:_,onPointerUp:T,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),u(t),F(o.id)}else r(e[i].id),F(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)(V.J,{type:"text",mode:"icon-only",icon:(0,n.jsx)(i9.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)(V.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)?F(i,!0):F(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 ne=i(99441),nt=i(33960),ni=i(53239),nn=i(25865),na=i(28462),nr=i(28110),no=i(83424),ns=i(93319),nl=i(40129),nd=i(18522),nc=i(55408),nm=i(21071),nu=i(95813),nh=i(84910),np=i(76770),ng=i(15362);function nf(e){let t=(0,nm.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,nm.bK)(t,[e]);let l=(0,nm.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 ny=i(28179);let nx={ambient:.3,key:.85,direction:[-.65,.6,1.3],shadowSize:2048,shadowRadius:2,shadowStrength:.65},nb=e=>{let t=[];return e.traverse(e=>{e instanceof nh.eaF&&!e.userData.rig&&t.push(e)}),t};function nv(e,t,i){let n=nb(e),a=[],r=(e,t)=>{e.geometry.getAttribute("color")?.array!==t&&e.geometry.setAttribute("color",new nh.THS(t,3));let i=e.material;i.vertexColors=!0,i.shadowSide=nh.$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 nh.Pq0().fromBufferAttribute(t,i?i.getX(n+a):n+a).applyMatrix4(e.matrixWorld));a.push({a:r,b:o,c:s,bounds:new nh.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 nh.NRn;for(let e of t)i.union(e.bounds);if(t.length<=12)return{bounds:i,triangles:t};let n=i.getSize(new nh.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 nh.RlV,d=new nh.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)),m=new nh.Pq0,u=new nh.Pq0,h=new nh.Pq0,p=new nh.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 nh.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++){m.fromBufferAttribute(i,t).applyMatrix4(e.matrixWorld),u.fromBufferAttribute(n,t).applyNormalMatrix(a),h.set(.9>Math.abs(u.y)?0:1,+(.9>Math.abs(u.y)),0).cross(u).normalize(),p.crossVectors(u,h),l.origin.copy(m).addScaledVector(u,.025*f);let r=0;for(let[e,t,i]of g)l.direction.copy(u).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),nj=i(23347),nk=i(96826);class nI{constructor(e={}){this.options=e,this.scene=new nh.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,nj.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 nh.YJl&&(0,nk.m)(l,a))o.group.matrixAutoUpdate=!0,o.group.matrix.identity(),o={key:r,shapeKey:i,group:o.group,origin:(0,nj.NT)(a).invert()};else{let e=(0,ny.bh)(n);o&&(0,nj.sZ)(o.group,e)?((0,ny.en)(e),o={key:r,shapeKey:i,group:o.group,origin:(0,nj.NT)(a).invert()}):(o&&(this.scene.remove(o.group),(0,ny.en)(o.group)),o={key:r,shapeKey:i,group:e,origin:(0,nj.NT)(a).invert()})}"bones"in a&&t.showRig&&"geometric"!==a.appearance?(s.length&&o.group.add(...s),(0,ny.yz)(o.group,a,!0)):s.length&&(0,ny.en)(new nh.YJl().add(...s)),(0,nj.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,ny.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=nb(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&&nv(this.scene,e,this.colors),this.scheduleShading()):this.colors&&s===this.shadedTopology&&(t.dragging||!l)?n&&nv(this.scene,e,this.colors):(this.colors=nv(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=nv(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,ny.en)(this.scene),this.scene.clear(),this.entries.clear(),this.colors=void 0,this.shadedKey=void 0,this.shadedTopology=void 0}}function nS(e){let t=(0,m.useRef)(null),a=(0,m.useRef)(e);a.current=e;let r=(0,m.useRef)(null),[o,s]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e,n,o,l,d,c=t.current;try{e=new nu.JeP({antialias:!0,alpha:!0})}catch{s(!0);return}e.setPixelRatio(Math.min(window.devicePixelRatio,2)),e.shadowMap.enabled=!0,e.shadowMap.type=nh.QP0,e.shadowMap.autoUpdate=!1,c.appendChild(e.domElement);let m=new nh.Z58,u=new nh.ubm(45,1,.01,3e4);u.position.set(3,2.2,5);let h=new np.N(u,e.domElement);h.target.set(0,.9,0),h.update();let p=new nh.fTw(20,40,"#a4aeb8","#e0e4e8"),g=new nh.$p8(0xffffff);m.add(p,g);let f=new nh.ZyN(0xffffff);m.add(f,f.target);let y=new nh.B69;m.add(y);let x=new ng.ZU(u,e.domElement);x.setSpace("world"),x.setSize(.75),m.add(x.getHelper());let b=new nI({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;m.add(v);let w=new nh.YJl;m.add(w);let j=new nh.YJl;m.add(j);let k=!1,I=null,S=null,P=0,C=0,M=()=>{C||(C=requestAnimationFrame(()=>{C=0,e.render(m,u)}))},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?nx:{...nx,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 nh.NRn;for(let e of nb(t))i.union(new nh.NRn().setFromObject(e));let n=i.isEmpty()?new nh.Pq0:i.getCenter(new nh.Pq0),a=Math.max(.1,i.getSize(new nh.Pq0).length());e.position.copy(n).addScaledVector(new nh.Pq0(...nx.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 nh.NRn(new nh.Pq0(-.5,-.5,-.5),new nh.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)/nx.shadowSize;e.castShadow=!0,e.shadow.mapSize.setScalar(nx.shadowSize),e.shadow.radius=nx.shadowRadius,e.shadow.intensity=nx.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",m=JSON.stringify([t.cameras,t.cameraBoxes,a.current.showCameras,o&&("cameraId"in o||"cameraBoxId"in o)?o:null,s]);if(d!==m){for(let e of(d=m,(0,ny.en)(j),j.clear(),!1===a.current.showCameras?[]:t.cameras)){let t=o&&"cameraId"in o&&o.cameraId===e.id,i=(0,ny.Ls)(e);i.far=Math.max(2*i.near,i.position.distanceTo((0,nm.i1)(e.target))),i.updateProjectionMatrix();let n=new nh.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,ny.en)(w),w.clear(),t.cameraBoxes??[])){let t=o&&"cameraBoxId"in o&&o.cameraBoxId===e.id,i=new nh.iNn(e.size,e.size,e.size),n=new nh.DXC(new nh.TDQ(i),new nh.mrM({color:t?"#467bd3":"#9cbbd3",transparent:!0,opacity:t?.95:.45,depthTest:!1}));if(i.dispose(),n.position.copy((0,nm.i1)(e.position)),n.quaternion.copy((0,nm.b5)(e.rotation)),n.userData.cameraBoxId=e.id,n.renderOrder=1,w.add(n),t){let t=new nh.IzY(.25*e.size);t.position.copy(n.position),t.quaternion.copy(n.quaternion),w.add(t)}}}let u=o&&"characterId"in o&&o.handBoneId?t.characters.find(e=>e.id===o.characterId):void 0,h=u?.bones.find(e=>e.id===(o&&"characterId"in o?o.handBoneId:void 0)),p=u&&h?(0,nm.Au)(u,h):void 0,y=e=>o&&("characterId"in o?e.characterId===o.characterId&&(p?p.has(e.jointId)||e.jointId===h.startJointId||p.has(u.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 nh.eaF)||!(e.material instanceof nh.G_z))return;if(e instanceof nh.ZLX&&e.userData.rig){let t=new nh.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,nm.dS)(n.modelPart??"")&&t.characters.find(e=>e.id===n.characterId)?.appearance==="geometric"?e.material.color.lerp(new nh.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,nm.Oe)(i)[a.id];if(y.position.copy(e.position),y.quaternion.copy(e.rotation).multiply((0,nm.IA)(i,a)),a.lockRotation||(0,nm.j4)(a))return void M()}else if(n){let e=(0,nm.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,nm.i1)(i.position)),y.quaternion.copy((0,nm.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,nm.i1)(i.position)),y.quaternion.copy((0,nm.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,nm.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,nm.ms)(a)[r.startJointId].rotation,t=y.quaternion.clone().multiply((0,nm.IA)(a,r).invert());return{type:"rotate-bone",characterId:a.id,boneId:r.id,rotation:(0,nm.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=nf(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 _=()=>{M(),a.current.onViewChange?.({position:u.position.toArray(),target:h.target.toArray()})};h.addEventListener("change",_);let T=null,F=!1,R=-1/0,q=null,E=(t,i=!1)=>{let n=e.domElement.getBoundingClientRect(),a=new nh.tBo;a.setFromCamera(new nh.I9Y((t.clientX-n.left)/n.width*2-1,-(t.clientY-n.top)/n.height*2+1),u),a.near=u.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(u);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 nh.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(),T=[e.clientX,e.clientY],F=!1,0===e.button&&(!q||e.timeStamp-q.time>500||Math.hypot(e.clientX-q.x,e.clientY-q.y)>4)&&(q={selection:E(e,!0),x:e.clientX,y:e.clientY,time:e.timeStamp})}),e.domElement.addEventListener("pointermove",e=>{e.buttons&&T&&Math.hypot(e.clientX-T[0],e.clientY-T[1])>4&&(F=!0,R=performance.now(),q=null)}),e.domElement.addEventListener("pointerup",e=>{if(!T||F||0!==e.button||k||x.axis||a.current.disabled||Math.hypot(e.clientX-T[0],e.clientY-T[1])>4)return;let t=E(e);t&&a.current.onSelect(t)}),e.domElement.addEventListener("dblclick",e=>{if(0!==e.button||k||F||performance.now()-R<500||a.current.disabled)return;let t=q&&e.timeStamp-q.time<=500?q.selection:E(e,!0);q=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),u.aspect=t/i,u.updateProjectionMatrix(),M())});return D.observe(c),r.current={rebuild:A,select:L,cancel:$},A(a.current.draft),L(),_(),()=>{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,ny.en)(j),(0,ny.en)(w),f.dispose(),e.dispose(),e.forceContextLoss(),e.domElement.remove()}},[]),(0,m.useEffect)(()=>{r.current?.rebuild(e.draft),r.current?.select()},[e.draft,e.selection,e.mode,e.disabled,e.showRig,e.showCameras,e.interacting]),(0,m.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,nm.ms)(a)[n.jointId].position.toArray(),o=(0,nm.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,nm.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 nP=i(22146),nC=i(14956);async function nM(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,nC.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,nP.Sn),s.fillStyle="#374151",s.fillText(e[n].label,a+t/2,o+nP.Sn/2,t-8),s.drawImage(i,a,o+nP.Sn,t,t)}),new Promise((e,t)=>{o.toBlob(i=>i?e(i):t(Error("observation-image-export-failed")),"image/png")})}let nA=[{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"}],nL=[["front","back"],["left","right"],["top","bottom"]];function nN({active:e,boxes:t,selectedBoxId:i,onSelectBox:a,pass:r,onPassChange:s,source:l,labels:d,copiedLabel:c,retryLabel:u,disabled:h}){let[p,g]=(0,m.useState)(nP.em),[f,y]=(0,m.useState)(0),[x,b]=(0,m.useState)(null),[v,w]=(0,m.useState)(null),[j,k]=(0,m.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,m.useEffect)(()=>{let e;if(b(null),!M)return;let t=!1,i=JSON.parse(M);return nM(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 X(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)(ie,{"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:nA.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:nL.flatMap((e,t)=>e.map((e,i)=>{let a=!!(I&&p.includes(e));return(0,n.jsx)(V.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=>nP.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)(nc.A,{type:"error",message:d.referenceLoadFailed,action:(0,n.jsx)(V.J,{size:"small",disabled:h,onClick:()=>y(e=>e+1),children:u})}):A?(0,n.jsx)("img",{src:A.url,alt:`${I.name} \xb7 ${P} \xb7 ${C.map(e=>e.label).join(" / ")}`}):(0,n.jsx)(iD.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)(nc.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)(V.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)(V.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 n$=[{kind:"box",Icon:ne.A},{kind:"sphere",Icon:nt.A},{kind:"plane",Icon:e7.A}];function n_({value:e,onChange:t,...i}){let n=(0,m.useRef)(e),a=(0,m.useRef)(!1),r=(0,m.useRef)(!1),o=(0,m.useRef)(!1),[s,l]=(0,m.useState)(0);return(0,m.useLayoutEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]),(0,m.useLayoutEffect)(()=>{n.current=e,a.current=!1,r.current=!1},[e,i.disabled,s]),(0,m.createElement)(eQ.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 nT({draft:e,onOperation:t,showRig:i,onShowRigChange:a,showCameras:r,onShowCamerasChange:c,labels:u=ew.spatial,noteLabel:p=ew.notes.element.label,copiedLabel:y=ew.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:$=ew.canvas.tools.label,onRequestProperties:_,actions:T=ew.actions}){let F,R,q,[E,D]=(0,m.useState)(S?{cameraId:S}:null),[z,B]=(0,m.useState)(S?"parameters":"info"),[O,U]=(0,m.useState)("space"),[J,W]=(0,m.useState)([]),[Y,X]=(0,m.useState)(!0),[G,K]=(0,m.useState)(!0),Q=i??Y,Z=r??G,[ee,et]=(0,m.useState)(null),[ei,en]=(0,m.useState)(null),[ea,er]=(0,m.useState)(null),[eo,es]=(0,m.useState)(null),[el,ed]=(0,m.useState)(null),ec=(0,m.useRef)(0),em=()=>{cancelAnimationFrame(ec.current),ec.current=0,ed(null)},eu=(0,m.useRef)(null);(0,m.useLayoutEffect)(()=>(en(null),em(),()=>{cancelAnimationFrame(ec.current),ec.current=0}),[e,E,z,b,x,O,I]);let ep=(t,i)=>ei?.source===e&&ei.key===t?ei.value:i,eg=(e,t,i)=>{en(null),e!==t&&i(e)},ef=t=>(eu.current?.source!==e&&(eu.current={source:e,apply:nf(e)}),eu.current.apply(t)),[ey,ex]=(0,m.useState)("translate"),[eb,ev]=(0,m.useState)(S??e.cameras[0].id),[ej,ek]=(0,m.useState)("sheet"),[eI,eS]=(0,m.useState)(),[eP,eC]=(0,m.useState)("color"),[eM,eA]=(0,m.useState)({position:[3,2.2,5],target:[0,.9,0]}),eL=E&&"characterId"in E?e.characters.find(e=>e.id===E.characterId):void 0,eN=eL&&E&&"characterId"in E?eL.joints.find(e=>e.id===E.jointId):void 0,e$=eL&&E&&"characterId"in E?eL.bones.find(e=>e.id===E.boneId):void 0,e_=eL&&E&&"characterId"in E?eL.bones.find(e=>e.id===E.handBoneId):void 0,eT=el?.source!==e||el.characterId!==eL?.id||el.handBoneId!==e_?.id||b||x||"parameters"!==z||"space"!==O?null:el,eF=eN??e$??e_,eR=E&&"objectId"in E?e.objects.find(e=>e.id===E.objectId):void 0,eq=e.cameras.find(e=>e.id===(E&&"cameraId"in E?E.cameraId:eb))??e.cameras[0],eE=E&&"cameraId"in E?eq:void 0,eD=E&&"cameraBoxId"in E?e.cameraBoxes?.find(e=>e.id===E.cameraBoxId):void 0,ez=eD?A?.(eD.id,ej,eP):P?.(eq.id,eP),eB=e=>u[`cameraBox${e[0].toUpperCase()}${e.slice(1)}`],eO=eL??eR??eE??eD,eU=ee&&[...e.characters,...e.objects,...e.cameras,...e.cameraBoxes??[]].find(e=>e.id===ee.id),eJ=eL&&eN?(0,nm.ms)(eL)[eN.id]:void 0,eW=Number(((eL?.torsoRatio??nm.s4)*100).toFixed(1)),eH=ep("torsoRatio",eW),eY=e=>`${u.torso} ${Number(e.toFixed(1))}%, ${u.legs} ${Number((100-e).toFixed(1))}%`,eV=e=>u[`finger${e[0].toUpperCase()}${e.slice(1)}`],eX=(e,t=!1)=>{let i=(0,nm.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?u.thumbMetacarpal:u.thumbProximal:u[n]?.replace("{{finger}}",eV(i.finger))},eK=(e,t,i=e)=>eX(i)??(t===e?u["joint"+e.split("-").map(e=>e[0].toUpperCase()+e.slice(1)).join("")]??t:t),eQ=(e,t,i)=>eX(i,!0)??(t===e?u["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")?u.handLeft:u.handRight}`,e2=e=>`${e}-${globalThis.crypto.randomUUID()}`;(0,m.useLayoutEffect)(()=>{void 0!==I&&(E&&(!eO||"cameraId"in E&&!e.cameras.some(e=>e.id===E.cameraId)||"characterId"in E&&(E.jointId&&!eN||E.boneId&&!e$||E.handBoneId&&!e_))&&D(null),en(null),er(null),es(null),et(null))},[I]);let e5=e=>{b||t(e)},e3=(t,i=!1)=>{if(!eL||!e_||b||x)return;let n={...t,type:"pose-hand",characterId:eL.id,handBoneId:e_.id};cancelAnimationFrame(ec.current),ec.current=0;let a=()=>{ec.current=0;try{let t=ef(n);es(t.constrained?u.constrained:null),ed(i?{source:e,draft:t.draft,characterId:eL.id,handBoneId:e_.id}:null),i||e5(n)}catch{ed(null),es(u.constrained)}};i?ec.current=requestAnimationFrame(a):a()},e4=e=>{if(!eL||b||x)return;let t={type:"set-proportions",characterId:eL.id,height:eL.height,headRatio:eL.headRatio,torsoRatio:eL.torsoRatio??nm.s4,...e};try{ef(t),er(null),e5(t)}catch(e){er(e instanceof nm._1?u.proportionsLocked:u.constrained)}},e8=e=>{eL?e5({type:"put-character",character:{...eL,...e}}):eR?e5({type:"put-object",object:{...eR,...e}}):eE?e5({type:"put-camera",camera:{...eE,...e}}):eD&&e5({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)(n_,{"aria-label":`${e} ${[u.x,u.y,u.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:te,selections:tt}=(0,m.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)(iP.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,nm.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,nm.dS)(o.modelPart);(!t.terminal||l)&&r({characterId:e.id,jointId:t.id},eK(t.id,t.name,o?.modelPart),s.get(t.id)??i,3*a+1,t.lockPosition&&(0,n.jsx)(C.A,{title:u.lockPosition,children:(0,n.jsx)(eG.A,{"aria-label":u.lockPosition})})),o&&l?.segment!==0&&r({characterId:e.id,boneId:o.id},eQ(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:u.lockRotation,children:(0,n.jsx)(e1.A,{"aria-label":u.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,u,p]),ti=(t,i=!0)=>{if(et(null),en(null),er(null),es(null),D(t),t&&(i&&B("parameters"),_?.(),"cameraId"in t&&ev(t.cameraId),"cameraBoxId"in t&&eS(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,nm.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]:[]])])}},tn=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(C.A,{title:u.translate,children:(0,n.jsx)(V.J,{mode:"with-icon","aria-label":u.translate,"aria-pressed":"translate"===ey,icon:(0,n.jsx)(ni.A,{"aria-hidden":"true"}),disabled:b||x||!!(e$||e_),onClick:()=>ex("translate"),children:u.translateMode})}),(0,n.jsx)(C.A,{title:u.rotate,children:(0,n.jsx)(V.J,{mode:"with-icon","aria-label":u.rotate,"aria-pressed":"rotate"===ey,icon:(0,n.jsx)(e1.A,{"aria-hidden":"true"}),disabled:b||x||!!eN,onClick:()=>ex("rotate"),children:u.rotateMode})})]}),ta=(0,n.jsxs)("div",{className:"spatial-panel","data-canvas-editor":!0,children:[(0,n.jsx)(ie,{className:"spatial-panel-tabs","aria-label":u.panelViews,value:z,onChange:e=>{B(e),en(null)},items:[{key:"info",label:u.infoToolsTab,mode:"text-only"},{key:"objects",label:u.objects,mode:"text-only"},{key:"parameters",label:u.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)(eh.u,{icon:(0,n.jsx)(nn.A,{"aria-hidden":"true"}),label:u.addCharacter,disabled:b||x,onClick:()=>{let e=e2("character");e5({type:"add-character",id:e,name:u.character}),ti({characterId:e})}}),(0,n.jsx)(eh.u,{icon:(0,n.jsx)(na.A,{"aria-hidden":"true"}),label:u.addCamera,disabled:b||x,onClick:()=>{let t=e2("camera");e5({type:"put-camera",camera:(0,nm.oH)(t,u.camera.replace("{{number}}",String(e.cameras.length+1)))}),ti({cameraId:t})}})]}),(0,n.jsx)(eh.u,{icon:(0,n.jsx)(iZ.A,{"aria-hidden":"true"}),label:u.addCameraBox,disabled:b||x,onClick:()=>{let t=e2("camera-box");e5({type:"put-camera-box",box:(0,nm.ov)((0,nm.zP)(t,u.cameraBox),e,"scene")}),ti({cameraBoxId:t}),ek("sheet")}}),(0,n.jsx)("div",{className:"spatial-add-actions",children:n$.map(({kind:e,Icon:t})=>(0,n.jsx)(eh.u,{icon:(0,n.jsx)(t,{"aria-hidden":"true"}),label:u[e],disabled:b||x,onClick:()=>{let t=e2(e);e5({type:"put-object",object:{id:t,name:u[e],kind:e,position:[0,.3,0],rotation:[0,0,0],size:"plane"===e?[2,1,2]:[.6,.6,.6],color:"#b6a58c"}}),ti({objectId:t})}},e))}),(0,n.jsx)(nl.A,{checked:e.lightingEnabled??!1,disabled:b||x,onChange:e=>e5({type:"set-lighting",enabled:e.target.checked}),children:u.lightingEffects}),(0,n.jsx)(nl.A,{checked:Z,onChange:e=>(c??K)(e.target.checked),children:u.showCameras}),(0,n.jsx)(nl.A,{checked:Q,onChange:e=>(a??X)(e.target.checked),children:u.showRig}),Q&&(0,n.jsxs)("div",{className:"spatial-rig-legend",children:[(0,n.jsxs)("span",{children:[(0,n.jsx)("i",{className:"spatial-joint-dot"}),u.joints]}),(0,n.jsxs)("span",{children:[(0,n.jsx)("i",{className:"spatial-bone-dot"}),u.bones]})]})]})]}):"objects"===z?(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("section",{className:"spatial-objects","aria-label":u.objects,children:[(0,n.jsx)("h2",{children:u.objects}),x?(0,n.jsx)(iD.G,{label:u.title,rows:4}):(0,n.jsx)(iE,{className:"spatial-object-tree","aria-label":u.objects,nodes:te,mode:"view",showCurrent:!1,showContentOrder:!1,showStatus:!1,showLock:!1,showIcon:!0,expandAction:!1,expandedKeys:J,onExpand:e=>W(e),selectedKeys:E?[e9(E)]:[],onSelect:e=>ti(tt.get(String(e[0]))??null,!1),icon:({eventKey:e})=>{let t=tt.get(String(e));return t&&"cameraId"in t?(0,n.jsx)(na.A,{"aria-hidden":"true"}):t&&"cameraBoxId"in t?(0,n.jsx)(iZ.A,{"aria-hidden":"true"}):t&&"objectId"in t?(0,n.jsx)(e7.A,{"aria-hidden":"true"}):t&&"characterId"in t&&t.jointId?(0,n.jsx)(nr.A,{className:"spatial-joint-icon","aria-hidden":"true"}):t&&"characterId"in t&&t.boneId?(0,n.jsx)(no.A,{className:"spatial-bone-icon","aria-hidden":"true"}):(0,n.jsx)(nn.A,{"aria-hidden":"true"})}})]})}):(0,n.jsxs)(n.Fragment,{children:[!eO&&(0,n.jsx)("p",{className:"spatial-parameters-empty",children:u.selectObjectForParameters}),eO&&(0,n.jsxs)("section",{className:"spatial-parameters","aria-label":u.parameters,children:[(0,n.jsx)("h2",{children:u.parameters}),!eE&&!eF&&(0,n.jsx)("div",{className:"spatial-tool-modes",children:tn}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:eN?u.joints:e$?u.bones:u.name}),(0,n.jsx)(l.A,{"aria-label":u.name,defaultValue:eN?eK(eN.id,eN.name,eL?.bones.find(e=>e.endJointId===eN.id)?.modelPart):e$?eQ(e$.id,e$.name,e$.modelPart):e_?eZ(e_):eO.name,disabled:b||!!eF,onBlur:e=>{e.target.value.trim()&&e.target.value!==eO.name&&e8({name:e.target.value.trim()})}},`${eO.id}/${eF?.id??""}/${eO.name}`)]}),!eF&&(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)(nl.A,{checked:eN.lockPosition,disabled:b,onChange:e=>e5({type:"lock-joint",characterId:eL.id,jointId:eN.id,position:e.target.checked}),children:u.lockPosition})}),e6(u.position,eJ.position.toArray(),e=>e5({type:"move-joint",characterId:eL.id,jointId:eN.id,position:e}),eN.lockPosition,(0,nm.dS)(eL.bones.find(e=>e.endJointId===eN.id)?.modelPart??"")?.005:.05)]}):(e$||e_)&&eL?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"spatial-locks",children:(0,n.jsx)(nl.A,{checked:(e$??e_).lockRotation,disabled:b,onChange:e=>e5({type:"lock-bone",characterId:eL.id,boneId:(e$??e_).id,rotation:e.target.checked}),children:u.lockRotation})}),e6(u.localRotation,(e$??e_).rotation,e=>e5({type:"rotate-bone",characterId:eL.id,boneId:(e$??e_).id,rotation:e}),(e$??e_).lockRotation||(0,nm.j4)(e$??e_),5),e$&&e6(u.angleMinimum,e$.limits.min,e=>e5({type:"set-bone-limits",characterId:eL.id,boneId:e$.id,limits:{...e$.limits,min:e}}),(0,nm.j4)(e$),5),e$&&e6(u.angleMaximum,e$.limits.max,e=>e5({type:"set-bone-limits",characterId:eL.id,boneId:e$.id,limits:{...e$.limits,max:e}}),(0,nm.j4)(e$),5)]}):(0,n.jsxs)(n.Fragment,{children:[e6(u.position,eO.position,e=>e8({position:e})),eE?e6(u.target,eE.target,e=>e8({target:e})):e6(u.rotation,(eL??eR??eD).rotation,e=>e8({rotation:e}),!1,5)]}),eL&&e_&&(F=(0,nm.Au)(eL,e_),R=e=>eL.bones.find(t=>F.has(t.endJointId)&&(0,nm.dS)(t.modelPart)?.finger===e&&(0,nm.dS)(t.modelPart)?.segment===1),q=(t,i,a)=>(0,n.jsxs)("div",{className:"spatial-hand-control",children:[(0,n.jsx)("span",{children:t}),(0,n.jsx)(nd.A,{min:0,max:100,step:2,value:ep(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}),e3(a(i/100),!0)},onChangeComplete:e=>{em(),eg(e,Math.round(Math.max(0,Math.min(100,i))),e=>e3(a(e/100)))},onBlur:()=>{en(null),em()}})]},t),(0,n.jsxs)("div",{className:"spatial-hand-controls",children:[(0,n.jsx)(C.A,{title:u.resetHandHint,children:(0,n.jsx)(V.J,{mode:"with-icon",icon:(0,n.jsx)(e0.A,{"aria-hidden":"true"}),disabled:b||x,onClick:()=>{en(null),em(),es(null),e5({type:"reset-hand",characterId:eL.id,handBoneId:e_.id})},children:u.resetHand})}),nm.EG.filter(e=>R(e)).map(e=>q(u.fingerCurl.replace("{{finger}}",eV(e)),R(e).rotation[0]/(0,nm.oq)(e)[0]*100,t=>({curl:{[e]:t}}))),R("little")&&q(u.fingerSpread,R("little").rotation[2]/(e_.modelPart.startsWith("left")?-18:18)*100,e=>({spread:e})),R("thumb")&&q(u.thumbOpposition,R("thumb").rotation[1]/(e_.modelPart.startsWith("left")?60:-60)*100,e=>({thumbOpposition:e})),eo&&(0,n.jsx)("span",{className:"spatial-proportion-error",role:"alert",children:eo})]})),eL&&!eF&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(C.A,{title:u.resetPoseHint,children:(0,n.jsx)(V.J,{mode:"with-icon",icon:(0,n.jsx)(e0.A,{"aria-hidden":"true"}),disabled:b,onClick:()=>{er(null),en(null),e5({type:"reset-pose",characterId:eL.id})},children:u.resetPose})}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:u.appearance}),(0,n.jsx)(o.A,{"aria-label":u.appearance,value:eL.appearance,disabled:b||x,options:[{value:"quaternius",label:u.appearanceQuaternius},{value:"geometric",label:u.appearanceGeometric}],onChange:e=>e8({appearance:e})})]}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:u.bodyType}),(0,n.jsx)(o.A,{"aria-label":u.bodyType,value:eL.bodyType??"male",disabled:b||x,options:[{value:"male",label:u.bodyMale},{value:"female",label:u.bodyFemale}],onChange:e=>e4({bodyType:e})})]}),(0,n.jsxs)("div",{className:"spatial-dimensions",children:[(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:u.proportions}),(0,n.jsx)(n_,{controls:!1,"aria-label":u.proportions,min:2,max:12,step:.5,precision:1,value:eL.headRatio,disabled:b,onChange:e=>null!==e&&e4({headRatio:e})})]}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:u.height}),(0,n.jsx)(n_,{controls:!1,"aria-label":u.height,min:.2,max:20,step:.1,value:eL.height,disabled:b,onChange:e=>null!==e&&e4({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:[u.bodyLegRatio," ",(0,n.jsx)(C.A,{title:u.bodyLegRatioHint,children:(0,n.jsx)(iP.A,{tabIndex:0,"aria-label":u.bodyLegRatioHint})})]}),(0,n.jsx)(C.A,{title:u.resetBodyLegRatio,children:(0,n.jsx)(V.J,{size:"small",mode:"icon-only",icon:(0,n.jsx)(e0.A,{"aria-hidden":"true"}),"aria-label":u.resetBodyLegRatio,disabled:b||x,onClick:()=>e4({torsoRatio:nm.s4})})})]}),(0,n.jsxs)("div",{className:"spatial-ratio-values",children:[(0,n.jsxs)("span",{children:[u.torso," ",eH,"%"]}),(0,n.jsxs)("span",{children:[u.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)(nd.A,{className:"spatial-ratio-slider",min:100*nm.VO.min,max:100*nm.VO.max,step:2,value:eH,disabled:b||x,marks:eH%2?{[eH]:eH}:void 0,styles:{root:{left:`${100*nm.VO.min}%`,right:`${(1-nm.VO.max)*100}%`},rail:{background:"transparent"},track:{background:"transparent"}},ariaLabelForHandle:u.bodyLegRatio,ariaValueTextFormatterForHandle:eY,tooltip:{formatter:e=>eY(e??eH)},onChange:t=>en({source:e,key:"torsoRatio",value:t}),onChangeComplete:e=>eg(e,eW,e=>e4({torsoRatio:e/100})),onBlur:()=>en(null)})})]}),Object.keys(nm.aY).map(t=>{let i=nm.aY[t],a=Number(((eL[t]??1)*100).toFixed(1)),r=ep(t,a);return(0,n.jsxs)("div",{className:"spatial-shape-control",children:[(0,n.jsxs)("span",{children:[u[t],"neckLength"===t&&(0,n.jsxs)(n.Fragment,{children:[" ",(0,n.jsx)(C.A,{title:u.bodyShapeHint,children:(0,n.jsx)(iP.A,{tabIndex:0,"aria-label":u.bodyShapeHint})})]})]}),(0,n.jsx)(nd.A,{min:100*i.min,max:100*i.max,step:2,value:r,disabled:b||x,marks:r%2?{[r]:""}:void 0,ariaLabelForHandle:u[t],ariaValueTextFormatterForHandle:e=>`${e}%`,tooltip:{formatter:e=>`${e}%`},onChange:i=>en({source:e,key:t,value:i}),onChangeComplete:e=>eg(e,a,e=>e4({[t]:e/100})),onBlur:()=>en(null)}),(0,n.jsx)(n_,{"aria-label":u[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&&e4({[t]:e/100})})]},t)}),ea&&(0,n.jsx)("span",{className:"spatial-proportion-error",role:"alert",children:ea})]}),eR&&e6(u.size,eR.size,e=>e8({size:e})),(eL||eR)&&!eF&&(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:u.color}),(0,n.jsx)("input",{type:"color","aria-label":u.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:u.cameraBoxHint,children:(0,n.jsx)(iP.A,{tabIndex:0,"aria-label":u.cameraBoxHint})}),(0,n.jsx)(V.J,{size:"small",disabled:b||x||!e.characters.length&&!e.objects.length,onClick:()=>e5({type:"fit-camera-box",id:eD.id,region:"scene"}),children:u.fitCameraBoxScene}),(0,n.jsx)(V.J,{size:"small",disabled:b||x||!e.characters.length,onClick:()=>e5({type:"fit-camera-box",id:eD.id,region:"hands"}),children:u.fitCameraBoxHands})]}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:u.cameraBoxSize}),(0,n.jsx)(n_,{controls:!1,"aria-label":u.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:u.cameraBoxResolution}),(0,n.jsx)(o.A,{"aria-label":u.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})})]})]}),eE&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(V.J,{size:"small",disabled:b,onClick:()=>e8(eM),children:u.useView}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:u.projection}),(0,n.jsx)(o.A,{"aria-label":u.projection,value:eE.projection,disabled:b,options:[{value:"perspective",label:u.perspective},{value:"orthographic",label:u.orthographic}],onChange:e=>e8({projection:e})})]}),(0,n.jsxs)("label",{className:"spatial-field",children:[(0,n.jsx)("span",{children:"perspective"===eE.projection?u.fov:u.span}),(0,n.jsx)(n_,{controls:!1,"aria-label":"perspective"===eE.projection?u.fov:u.span,value:"perspective"===eE.projection?eE.fov:eE.span,min:"perspective"===eE.projection?10:.1,max:"perspective"===eE.projection?120:1e3,disabled:b,onChange:e=>null!==e&&e8("perspective"===eE.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?u.outputWidth:u.outputHeight}),(0,n.jsx)(n_,{controls:!1,"aria-label":"width"===e?u.outputWidth:u.outputHeight,min:128,max:2048,step:16,precision:0,disabled:b,value:eE[e],onChange:t=>null!==t&&e8({[e]:t})})]},e))}),(0,n.jsx)(nl.A,{checked:null===eE.background,disabled:b,onChange:e=>e8({background:e.target.checked?null:"#ffffff"}),children:u.transparent})]}),!eF&&(0,n.jsxs)("div",{className:"spatial-object-actions",children:[(0,n.jsx)(V.J,{mode:"with-icon",size:"small",icon:(0,n.jsx)(H.A,{"aria-hidden":"true"}),disabled:b,onClick:()=>{let e=e2("copy");eL?e5({type:"put-character",character:{...structuredClone(eL),id:e,position:[eL.position[0]+.8,eL.position[1],eL.position[2]]}}):eR?e5({type:"put-object",object:{...structuredClone(eR),id:e,position:[eR.position[0]+.8,eR.position[1],eR.position[2]]}}):eE?e5({type:"put-camera",camera:{...structuredClone(eE),id:e}}):eD&&e5({type:"put-camera-box",box:{...structuredClone(eD),id:e}})},children:u.duplicate}),(0,n.jsx)(h.x,{"aria-label":T.delete,size:"small",icon:(0,n.jsx)(s.A,{}),disabled:b||!!(eE&&1===e.cameras.length),confirmLabel:T.delete,cancelLabel:T.cancel,title:u.deleteConfirm,onConfirm:()=>{e5({type:"remove",id:eO.id}),D(null)},children:null})]})]},`${e9(E)}/${I??0}/${!!x}`),(0,n.jsxs)("section",{className:"spatial-preview","aria-label":u.cameraView,children:[(0,n.jsx)("h2",{children:eD?u.cameraBoxSheet:u.cameraView}),eD?(0,n.jsx)(o.A,{"aria-label":u.cameraBoxView,value:ej,options:["sheet",...nm.em].map(e=>({value:e,label:eB(e)})),onChange:ek}):(0,n.jsx)(o.A,{"aria-label":u.selectCamera,value:eq.id,options:e.cameras.map(e=>({value:e.id,label:e.name})),onChange:e=>{ev(e),eE&&ti({cameraId:e})}}),(0,n.jsx)(ie,{className:"spatial-reference-tabs","aria-label":u.referencePass,value:eP,onChange:e=>eC(e),items:[{key:"color",label:u.referenceColor,mode:"text-only",disabled:b||x},{key:"structure",label:u.referenceStructure,mode:"text-only",disabled:b||x},{key:"depth",label:u.referenceDepth,mode:"text-only",disabled:b||x},{key:"skeleton",label:u.referenceSkeleton,mode:"text-only",disabled:b||x}]}),ez&&(0,n.jsx)(nF,{source:ez,camera:eD?{id:`${eD.id}-${ej}`,name:`${eD.name} \xb7 ${eB(ej)}`,...(0,nm.D5)(eD,ej)}:eq,pass:eP,labels:u,retryLabel:T.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":u.title,children:(0,n.jsx)(ii,{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 ${T.retry}`:v,trigger:["hover","focus"],children:(0,n.jsx)(V.J,{mode:"icon-only",size:"small",textColor:"color.status.danger",backgroundColor:"none","aria-label":w?`${v} \xb7 ${T.retry}`:v,icon:(0,n.jsx)(ns.A,{"aria-hidden":"true"}),onClick:w})})}),(0,n.jsx)(ie,{className:"spatial-workspace-tabs","aria-label":u.workspaceViews,value:O,onChange:U,items:[{key:"space",label:u.spaceTab,mode:"text-only"},{key:"cameras",label:u.cameras,mode:"text-only"},{key:"cameraBoxes",label:u.cameraBoxTab,mode:"text-only"}]})]}),children:(0,n.jsx)("div",{className:"spatial-center",children:x?(0,n.jsx)(iD.G,{label:u.title,rows:6}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"spatial-space",hidden:"space"!==O,children:[j,(0,n.jsx)(nS,{interactionResetKey:I,interacting:!!eT,showRig:Q,showCameras:Z,draft:eT?.draft??e,selection:E,mode:ey,onSelect:ti,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&&(ti(n),et({id:a,name:r.name,...i}))},onOperation:e5,onViewChange:eA,label:u.viewport,errorLabel:u.webglFailed,disabled:b})]}),"cameras"===O&&(0,n.jsx)("section",{className:"spatial-camera-gallery","aria-label":u.cameras,children:e.cameras.map(e=>{let t=P?.(e.id,"color");return(0,n.jsxs)("figure",{className:"spatial-camera-card","data-selected":eE?.id===e.id,children:[(0,n.jsx)(V.J,{className:"spatial-camera-select",backgroundColor:"none","aria-label":`${e.name} \xb7 ${u.parameters}`,"aria-pressed":eE?.id===e.id,onClick:()=>ti({cameraId:e.id})}),(0,n.jsx)("div",{className:"spatial-camera-image",children:t?(0,n.jsx)(nF,{source:t,camera:e,pass:"color",labels:u,retryLabel:T.retry,disabled:b,gallery:!0},t):(0,n.jsx)("p",{className:"spatial-camera-pending",children:u.cameraPreviewPending})}),(0,n.jsx)("figcaption",{children:e.name})]},e.id)})}),(0,n.jsx)(nN,{active:"cameraBoxes"===O,boxes:e.cameraBoxes??[],selectedBoxId:eI,onSelectBox:e=>ti({cameraBoxId:e}),pass:eP,onPassChange:eC,source:A,labels:u,copiedLabel:y,retryLabel:T.retry,disabled:b})]})})})}),N&&(0,M.createPortal)(ta,N),ee&&eU&&(0,n.jsx)(d.A,{open:!0,title:u.editObject,footer:null,width:360,rootClassName:"spatial-object-editor-modal",destroyOnHidden:!0,mask:{closable:!0},closable:{"aria-label":T.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:u.name,children:(0,n.jsx)(l.A,{"aria-label":u.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 nF({source:e,camera:t,pass:i,labels:a,retryLabel:r,disabled:o,gallery:s}){let[l,d]=(0,m.useState)("loading"),[c,u]=(0,m.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)(iD.G,{label:h,rows:1}),"error"===l&&(0,n.jsx)(nc.A,{type:"error",message:a.referenceLoadFailed,action:(0,n.jsx)(V.J,{size:"small",disabled:o,onClick:()=>{d("loading"),u(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)(V.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})]})}},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:()=>m,zS:()=>u});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(m),...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 m(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 u(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,m=e.areas.reduce((e,t)=>e+t.area*c/d,0),u=a.map(e=>e/21600),h=u.reduce((e,t)=>e+t,0),p=o/21600;return{theoreticalArea:m,visibleAreaShares:u,occupiedArea:p,negativeSpace:1-p,clippedArea:Math.max(0,m-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:()=>m.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),m=i(54996),u=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 u.NRn,r=(0,l.b5)(e.rotation).invert(),o=new u.Pq0;try{n.traverse(e=>{if(!(e instanceof u.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 u.Pq0);return{...e,position:a.getCenter(new u.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 u="female"===s?r:a,h=j(u),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/(u.parts.find(e=>"head"===e.id).start[1]-u.bottom);for(let e of g.filter(e=>e.parentId)){let t=u.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,(u.parts[0].start[1]-u.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(m.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(m.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:()=>m,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(),m=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(m,c,m)})}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),m(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 m(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:()=>u,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 m(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 u(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=m(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(),m=(0,o.G_)(e.headRatio),u=i?e.palmSize??1:1,h=i?e.height/a.height*m.hand*u: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?m.handLength:1)*u,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(),m=p(e,a,!1);return new n.PTz().setFromRotationMatrix(new n.kn4().makeBasis(s.transformDirection(m),o.transformDirection(m),d.transformDirection(m)))}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}`,u=i.parts.find(e=>e.id===d),h=s?`${r}${o}-${l}-${s-1}`:t.endJointId,p=new n.Pq0(...u.end).sub(new n.Pq0(...u.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?m(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:m,style:u,"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?m??h:h,icon:"without-icon"===i?void 0:t,style:{...f,...u},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","expanding-switch":"switching","underline-tab-switch":"switching","dot-scrollbar":"scrolling","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:()=>m,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 m({collapsed:e,children:t}){return(0,n.jsx)(c.Provider,{value:e,children:t})}function u(e){return String(d.L[e])}function h({label:e,icon:t,description:i,actions:d=[],onClick:m,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:u(p),C=u("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:m,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:()=>Z,CP:()=>S,Ai:()=>T,oF:()=>M,CV:()=>N,Kd:()=>B,co:()=>O,IU:()=>A,z_:()=>L,rz:()=>$,hG:()=>_,ET:()=>E,ai:()=>R,QY:()=>q,s:()=>F,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"],m=["square","free","landscape","portrait"],u="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:"scene-composition",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 m={x:(o.x+s.x)/2,y:(o.y+s.y)/2},u=(-((m.x-r.x)*d)+(m.y-r.y)*l)/c;if(0===u)return a;let{points:h,...p}=a;return{...p,x:(m.x+d/c*u/2)/i.width,y:(m.y-l/c*u/2)/i.height,rotation:180*Math.atan2(d,l)/Math.PI+180*(u<0),width:c/i.width,height:Math.abs(u)/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,m=structuredClone(s);if(m.frame=c?(0,d.sw)(s.frame):structuredClone(s.frame),c&&(r=(i=(t=m).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})),m.plans&&new Set(m.plans.map(e=>e.id)).size!==m.plans.length)throw Error("Composition planning ids must be unique within a state.");m.plans&&(m.plans=m.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:Z(e.rotation,m.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 u=new Set;for(let e of[...m.focusPoints,...m.directionLine?[m.directionLine]:[],...m.areas,...m.images]){if(u.has(e.id))throw Error(`Duplicate draft item id: ${e.id}.`);u.add(e.id)}return m.directionLine=m.directionLine?{...m.directionLine,rotation:ee(m.directionLine.rotation)}:null,m.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")}),m.layerOrder&&(m.layerOrder=(0,n.u)(m)),m.images.forEach(e=>{e.rotation=ee(e.rotation),e.crop&&Q(e.crop)}),(0,a.Ib)(m)}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&&m.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(F(i.draft,i.id,{semanticType:u}),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===u}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,m=(n.y-r.y)*d.cq.height;o.points[i]={x:c*Math.cos(s)+m*Math.sin(s),y:-c*Math.sin(s)+m*Math.cos(s)};let u=o.points.map(e=>e.x),h=o.points.map(e=>e.y),p=Math.min(...u),g=Math.min(...h),f=Math.max(...u)-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 _(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 T(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 F(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 q(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&&Q(i.crop),Object.assign(a,i),n}function E(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:Z(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!==u||"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 Q(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 Z(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(16415),r=i(29717),o=i(99568),s=i.n(o),l=i(1521),d=i(8020),c=i(91093),m=i(60458);let u=[{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,m.hF)(),(0,m.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,repositoryLink:{href:"https://github.com/yisi-ai/human2ai",label:g("app.repositoryLink",{productName:g("app.title")})},languageSelector:{"aria-label":g("language.selectorLabel"),onChange:e=>{(0,c.EM)(e)&&p.changeLanguage(e)},options:u,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,m.$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,m.DZ)(g("spatial.untitled"),e??null);b(e=>[t,...e]),o.push(`/spatial?session=${encodeURIComponent(t.id)}`)},onCreateUiSketch:async e=>{let t=await (0,m.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,m.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,m.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,m.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,m.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,m.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,m.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:()=>u,wG:()=>m,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,...m}=e;return{...m,...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 m(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 u(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:()=>E,FX:()=>A,Fu:()=>k,GW:()=>m,Ht:()=>a,J_:()=>U,Jx:()=>h,ME:()=>I,MT:()=>N,MZ:()=>L,Nr:()=>g,Pf:()=>x,T8:()=>w,VQ:()=>M,X0:()=>u,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 F(`/api/v1/sessions/${encodeURIComponent(e)}`,{},t)}function r(e,t=null,i=globalThis.fetch){return F("/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 F("/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 F("/api/v1/projects",{},e)).projects}function l(e,t=globalThis.fetch){return F("/api/v1/projects",{method:"POST",body:JSON.stringify({name:e})},t)}function d(e,t,i,n=globalThis.fetch){return F(`/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 m(e=globalThis.fetch){return(await F("/api/v1/sessions",{},e)).sessions}async function u(e=globalThis.fetch){return(await F("/api/v1/styles",{},e)).styles}function h(e,t=globalThis.fetch){return F("/api/v1/styles",{method:"POST",body:JSON.stringify(e)},t)}function p(e,t,i=globalThis.fetch){return F(`/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 F(`/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 F(`/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 F(`/api/v1/sessions/${encodeURIComponent(e)}/style`,{},t)}function w(e,t,i,n=globalThis.fetch){return F(`/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 F(`/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 F(`/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 _(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 _(e,"ui-sketch",t,i,n)}function A(e,t,i=globalThis.fetch){return F(`/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 F(T(e,t),{},i)).draftVersions}function _(e,t,i,n,a){return F(T(e,t),{method:"POST",body:JSON.stringify({expectedLatestRevision:i,draft:n})},a)}function T(e,t){return`/api/v1/sessions/${encodeURIComponent(e)}/${t}/drafts`}async function F(e,t,i){let n=await R(e,t,i);return await q(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 q(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 q(e){try{return await e.json()}catch{throw new n("INVALID_SERVICE_RESPONSE",`Human2AI returned invalid JSON with HTTP ${e.status}`,e.status)}}function E(e,t=null,i=globalThis.fetch){return F("/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 F(`/api/v1/sessions/${encodeURIComponent(e)}/spatial/drafts/latest?knownRevision=${t}`,{},i)).draftVersion}function B(e,t,i,n=globalThis.fetch){return _(e,"spatial",t,i,n)}function O(e,t,i,n=globalThis.fetch){return F(`/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 F(`/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:m,danger:u=!0,...h}){return(0,n.jsx)(a.A,{title:e,description:m||t?(0,n.jsxs)("div",{className:"yisi-confirm-action-description",children:[m?(0,n.jsx)("strong",{children:m}):null,t?(0,n.jsx)("span",{children:t}):null]}):void 0,okText:d,cancelText:c,okButtonProps:{danger:u},onConfirm:l,children:(0,n.jsx)(r.Ay,{...h,...(0,o.S)("confirm-action","ConfirmAction","action-pattern"),danger:u,children:i})})}},67925:(e,t,i)=>{"use strict";i.d(t,{r:()=>m});var n=i(73365),a=i(48187),r=i(67872),o=i(1521),s=i(29415),l=i(2684),d=i(46811);function c(e,t){return(0,n.jsx)("span",{className:e,children:t})}function m({label:e,pendingLabel:t,successLabel:i,errorLabel:u,onAction:h,idleIcon:p,successIcon:g=(0,n.jsx)(a.A,{}),errorIcon:f=(0,n.jsx)(r.A,{}),feedbackDurationMs:y=1600,motion:x="auto",onStatusChange:b,onActionError:v,className:w,disabled:j,...k}){let[I,S]=(0,o.useState)("idle"),P=(0,o.useRef)(!0),C=(0,o.useRef)(!1),M=(0,o.useRef)(null);function A(e){P.current&&(S(e),b?.(e))}function L(){P.current&&null!==y&&(M.current=window.setTimeout(()=>{M.current=null,A("idle")},Math.max(0,y)))}async function N(){if(!C.current){C.current=!0,null!==M.current&&(window.clearTimeout(M.current),M.current=null),A("pending");try{if(await h(),!P.current)return;A("success"),L()}catch(e){if(!P.current)return;A("error"),v?.(e),L()}finally{C.current=!1}}}(0,o.useEffect)(()=>(P.current=!0,()=>{P.current=!1,null!==M.current&&window.clearTimeout(M.current)}),[]);let $="pending"===I?t:"success"===I?i:"error"===I?u:e,_="success"===I?c("yisi-action-button-feedback-icon",g):"error"===I?c("yisi-action-button-feedback-icon",f):p,T="pending"===I;return(0,n.jsx)(l.B,{attributes:(0,d.S)("action-button","ActionButton"),children:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(s.J,{...k,"aria-label":k["aria-label"]??$,"aria-busy":T||void 0,className:["yisi-action-button",`yisi-action-button-motion-${x}`,w].filter(Boolean).join(" "),"data-action-status":I,disabled:j||T,icon:_,loading:T,mode:"with-icon",onClick:()=>void N(),children:(0,n.jsx)("span",{"data-yisiui-slot":"label",children:$})}),(0,n.jsx)("span",{"aria-atomic":"true","aria-live":"polite",className:"yisi-action-button-announcement",role:"status",children:"idle"===I?"":$})]})})}i(21449)},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:()=>{},92449:(e,t,i)=>{"use strict";i.d(t,{D:()=>k});var n=i(73365),a=i(1521);i(20701);var r=i(46811);let o=(e,t,i)=>[e[0]+t[0]*i,e[1]+t[1]*i],s=(e,t)=>Math.hypot(t[0]-e[0],t[1]-e[1]),l=e=>e.map(e=>Number(e.toFixed(6))).join(" ");function d(e,t,i=!0,n=.72){let a=e.map((a,r)=>{let l=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=s(e,t),l=s(t,i),d=Math.max(0,Math.min(n,.49*r,.49*l));if(0===r||0===l||0===d)return{start:t,end:t,middle:t,curves:[]};let c=[(t[0]-e[0])/r,(t[1]-e[1])/r],m=[(i[0]-t[0])/l,(i[1]-t[1])/l],u=a*d,h=2*u-d,p=o(t,c,-d),g=o(t,m,d),f=o(p,c,u),y=o(g,m,-u),x=[(f[0]+y[0])/2,(f[1]+y[1])/2];return{start:p,end:g,middle:x,curves:[[p,o(p,c,h),f,x],[x,y,o(g,m,-h),g]]}}(e[(r+e.length-1)%e.length],a,e[(r+1)%e.length],l,n)});return{d:a.map((e,t)=>`${0===t?"M":"L"}${l(e.start)}${e.curves.map(e=>`C${e.slice(1).map(l).join(" ")}`).join("")}`).join("")+(i?"Z":""),corners:a}}let c=d([[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),m=d(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),u=d([[4,14],[4,20],[20,20],[20,14]],3.8,!1,.56),h=d([[12,3.4],[17.7,9.7],[6.3,9.7]],[2.1,1.8,1.8],!0,.56),p=d([[8,7],[16,7],[20,11],[20,21],[8,21]],[4.5,1.2,1.2,4.5,4.5],!0,.56),g=22/3*Math.tan(Math.PI/8),f=`M6.5 10C6.5 ${10-g} ${12-g} 4.5 12 4.5C${12+g} 4.5 17.5 ${10-g} 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`,y=d([[19.2,3.5],[20,9.7],[13.8,7.6]],1.8,!0,.56),x=d([[3,4.5],[21,4.5],[21,19.5],[3,19.5]],4.5,!0,.56),b=d([[3.8,3.8],[3.8,9.2],[9.2,9.2]],1.6,!0,.56),v=d([[12,4.5],[18,11],[6,11]],[2.1,2.3,2.3],!0,.56),w={"arrow-up":0,"arrow-down":180,"arrow-left":-90,"arrow-right":90};function j({name:e}){let t={className:"yisi-animated-icon-motion","data-animated-icon-part":"motion"};switch(e){case"arrow-up":case"arrow-down":case"arrow-left":case"arrow-right":return(0,n.jsxs)("g",{transform:`rotate(${w[e]} 12 12)`,children:[(0,n.jsxs)("g",{...t,children:[(0,n.jsx)("path",{d:"M12 10v9",strokeWidth:"2.2"}),(0,n.jsx)("path",{d:v.d,fill:"currentColor",stroke:"none"})]}),(0,n.jsx)("g",{className:"yisi-animated-icon-layer yisi-icon-arrow-air",opacity:"0",strokeWidth:"1.3",children:(0,n.jsx)("path",{d:"M12 20.8v1.5M9.8 20.2l-.9 1.1M14.2 20.2l.9 1.1"})})]});case"reset":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("g",{className:"yisi-animated-icon-layer yisi-icon-feedback yisi-icon-reset-ring",opacity:"0",strokeWidth:"1.2",children:(0,n.jsx)("circle",{cx:"12",cy:"12",r:"4.2"})}),(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:b.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:x.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"})}),(0,n.jsx)("g",{className:"yisi-animated-icon-layer yisi-icon-feedback yisi-icon-sidebar-wake",opacity:"0",strokeWidth:"1.2",children:(0,n.jsx)("path",{d:"M11 9h3M11 12h5M11 15h3"})})]});case"loading":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"8",opacity:"0.16"}),(0,n.jsxs)("g",{...t,children:[(0,n.jsx)("path",{d:"M12 4a8 8 0 1 1-8 8"}),(0,n.jsx)("g",{className:"yisi-animated-icon-layer yisi-icon-feedback yisi-icon-loading-trail",opacity:"0",strokeWidth:"1.2",children:(0,n.jsx)("path",{d:"M6.2 12a5.8 5.8 0 0 0 5.8 5.8"})})]})]});case"plus":return(0,n.jsxs)(n.Fragment,{children:[(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"})]}),(0,n.jsx)("g",{className:"yisi-animated-icon-layer yisi-icon-feedback yisi-icon-plus-spark",opacity:"0",strokeWidth:"1.3",children:(0,n.jsx)("path",{d:"M5.5 5.5l-1-1M18.5 5.5l1-1M5.5 18.5l-1 1M18.5 18.5l1 1"})})]});case"upload":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("path",{d:u.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:h.d})]}),(0,n.jsx)("g",{className:"yisi-animated-icon-layer yisi-icon-feedback yisi-icon-upload-ripple",opacity:"0",strokeWidth:"1.1",children:(0,n.jsx)("ellipse",{cx:"12",cy:"17.4",rx:"4.2",ry:"0.9"})})]});case"send":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("g",{...t,children:(0,n.jsx)("path",{d:`${c.d}M${l(c.corners[3].middle)}L${l(c.corners[1].middle)}`})}),(0,n.jsx)("g",{className:"yisi-animated-icon-layer yisi-icon-feedback yisi-icon-send-wake",opacity:"0",strokeWidth:"1.3",children:(0,n.jsx)("path",{d:"M4 16l3-3M4.5 20l4-4M8.5 21l2.5-2.5"})})]});case"refresh":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("g",{className:"yisi-animated-icon-layer yisi-icon-feedback yisi-icon-refresh-trail",opacity:"0",strokeWidth:"1.2",children:(0,n.jsx)("path",{d:"M8 8a5.65 5.65 0 0 1 6-1.3M16 16a5.65 5.65 0 0 1-6 1.3"})}),(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:y.d}),(0,n.jsx)("path",{d:y.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.jsx)("g",{className:"yisi-animated-icon-layer yisi-icon-feedback yisi-icon-copy-echo",opacity:"0",strokeWidth:"1.1",children:(0,n.jsx)("path",{d:p.d})}),(0,n.jsxs)("g",{...t,children:[(0,n.jsx)("path",{d:p.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.jsxs)(n.Fragment,{children:[(0,n.jsx)("g",{...t,children:(0,n.jsx)("path",{d:m.d})}),(0,n.jsx)("g",{className:"yisi-animated-icon-layer yisi-icon-feedback yisi-icon-star-spark",opacity:"0",strokeWidth:"1.2",children:(0,n.jsx)("path",{d:"M19.5 2.5v3M18 4h3M3.5 6v2M2.5 7h2M20 17.5V20M18.75 18.75h2.5"})})]});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:f})}),(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"})]}),(0,n.jsx)("g",{className:"yisi-animated-icon-layer yisi-icon-feedback yisi-icon-bell-waves",opacity:"0",strokeWidth:"1.2",children:(0,n.jsx)("path",{d:"M3.8 7Q1.5 10 3.8 13M20.2 7Q22.5 10 20.2 13"})})]});case"close":return(0,n.jsxs)(n.Fragment,{children:[(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"})]})}),(0,n.jsx)("g",{className:"yisi-animated-icon-layer yisi-icon-feedback yisi-icon-close-ring",opacity:"0",strokeWidth:"1.2",children:(0,n.jsx)("circle",{cx:"12",cy:"12",r:"8"})})]})}}let k=(0,a.forwardRef)(function({name:e,size:t="1em",label:i,loop:o=!1,playKey:s,duration:l=720,motion:d="auto",onAnimationComplete:c,className:m,style:u,...h},p){let[g,f]=(0,a.useState)(!1),[y,x]=(0,a.useState)({id:0,playing:!1}),b=(0,a.useRef)(null),v=(0,a.useRef)(s),w="none"!==d&&!g,k=Number.isFinite(l)&&l>0?l:720;(0,a.useEffect)(()=>{let e=window.matchMedia("(prefers-reduced-motion: reduce)"),t=()=>f(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]);let I=(0,a.useCallback)(()=>{w&&x(e=>({id:e.id+1,playing:!0}))},[w]),S=(0,a.useCallback)(()=>x(e=>({...e,playing:!1})),[]);return(0,a.useImperativeHandle)(p,()=>({play:I,stop:S}),[I,S]),(0,a.useEffect)(()=>{x(e=>({id:e.id+1,playing:o&&w}))},[e,o,w]),(0,a.useEffect)(()=>{s!==v.current&&void 0!==s&&I(),v.current=s},[s,I]),(0,a.useEffect)(()=>{let e=b.current,t=e=>{!o&&y.playing&&w&&e.target instanceof SVGElement&&"motion"===e.target.getAttribute("data-animated-icon-part")&&(S(),c?.())};return e?.addEventListener("animationend",t),()=>e?.removeEventListener("animationend",t)},[o,w,y.playing,c,S]),(0,n.jsx)("svg",{...h,ref:b,...(0,r.S)("animated-icon","AnimatedIcon"),className:["yisi-animated-icon",m].filter(Boolean).join(" "),"data-icon":e,"data-playing":y.playing&&w?"true":"false","data-loop":o?"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":`${k}ms`,...u},children:(0,n.jsx)(j,{name:e},`${e}:${y.id}`)})});k.displayName="AnimatedIcon"},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),m=i(77902);let u=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(u,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,m.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:m,modules:p,targets:g,sourceFrames:f,sourceBodyHeight:y}=h[e.bodyType??"male"],x=(0,o.ms)(e),b=e.height/m.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=m.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(u,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),u=!d&&a?a:m.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=u);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:m.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=m.weights[4*t+e];i&&(L.copy(N).applyMatrix4(u[m.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 _=new n.Q1f("brows"===t.material?"#514235":"eyes"===t.material?"#e7ded1":e.color),T=(w<2?1-k:0)+(j<2?k:0);if("brows"===t.material&&_.lerp(new n.Q1f(e.color),.9*T),"eyes"===t.material&&_.lerp(new n.Q1f("#514235"),T),f.material.color.copy(_),A.push(f),r){l&&(p.segments=(0,c.xQ)(e,m.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=m.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,_=new n.Pq0,T=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]),_.fromBufferAttribute(i,r[1]),T.fromBufferAttribute(i,r[2]);let o=_.sub($).cross(T.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":"#22C55E","color.brand.primaryHover":"#4ADE80","color.brand.primaryActive":"#16A34A","color.brand.primaryBg":"#F0FDF4","color.brand.primaryBgHover":"#DCFCE7","color.brand.primaryText":"#15803D","color.brand.onPrimary":"#FFFFFF","color.neutral.0":"#FFFFFF","color.neutral.25":"#FCFDFD","color.neutral.50":"#F8FAF9","color.neutral.100":"#F3F6F5","color.neutral.200":"#E2E9E7","color.neutral.300":"#C9D4D1","color.neutral.400":"#ADBDB8","color.neutral.500":"#7C918B","color.neutral.600":"#586B6F","color.neutral.700":"#48595C","color.neutral.800":"#334448","color.neutral.900":"#1F292B","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":"#48595C","color.status.infoBg":"#F3F6F5","color.status.processing":"#15803D","color.status.processingBg":"#F0FDF4","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(31, 41, 43, 0.06)","shadow.card":"0 4px 12px rgba(31, 41, 43, 0.04)","shadow.raised":"0 12px 30px rgba(31, 41, 43, 0.12)","motion.fast":"120ms","motion.normal":"180ms","motion.slow":"240ms","color.text.primary":"#1F292B","color.text.secondary":"#48595C","color.text.muted":"#586B6F","color.text.hint":"#586B6F","color.text.placeholder":"#586B6F","color.text.disabled":"#7C918B","color.text.inverse":"#FFFFFF","color.text.onPrimary":"#FFFFFF","color.border.default":"#C9D4D1","color.border.subtle":"#E2E9E7","color.border.control":"#7C918B","color.border.interactive":"#15803D","color.border.hover":"#ADBDB8","color.border.focus":"#15803D","color.border.disabled":"#E2E9E7","color.border.error":"#CF1322","color.border.warning":"#AD4E00","color.border.success":"#237804","color.surface.page":"#F3F6F5","color.surface.panel":"#FFFFFF","color.surface.soft":"#F8FAF9","color.surface.code":"#F8FAF9","color.surface.hover":"#F8FAF9","color.surface.selected":"#F0FDF4","color.surface.active":"#DCFCE7","color.surface.disabled":"#F3F6F5","color.surface.overlay":"rgba(31,41,43,0.45)","color.action.primary":"#22C55E","color.action.primaryHover":"#4ADE80","color.action.primaryActive":"#16A34A","color.action.secondaryHover":"#F8FAF9","color.action.secondaryActive":"#F0FDF4","color.action.link":"#15803D","color.action.linkHover":"#15803D","color.action.linkActive":"#15803D","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":"#48595C","color.feedback.infoBg":"#F3F6F5","color.feedback.processing":"#15803D","color.feedback.processingBg":"#F0FDF4","color.selection.background":"#F0FDF4","color.selection.text":"#15803D","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":"#F3F6F5","theme.light.panel":"#FFFFFF","theme.light.text":"#1F292B","theme.dark.page":"#141414","theme.dark.panel":"#1F1F1F","theme.dark.text":"#F5F5F5","theme.dark.interactive":"#4ADE80","motion.textSpeed.slow":.6,"motion.textSpeed.medium":1,"motion.textSpeed.fast":1.6,"surface.desktopWeb.pageBackground":"#F3F6F5","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(31, 41, 43, 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":"#4ADE80","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":"#22C55E","component.writingAgent.logic":"#722ED1","component.writingAgent.draft":"#08979C","component.writingAgent.annotation":"#C41D7F","component.writingAgent.support":"#586B6F","component.contentGraph.node.actorFill":"#F0FDF4","component.contentGraph.node.actorStroke":"#15803D","component.contentGraph.node.actorText":"#15803D","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":"#F8FAF9","component.contentGraph.node.defaultStroke":"#8B9BAE","component.contentGraph.node.defaultText":"#1F292B","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":"#48595C","component.contentGraph.label.background":"rgba(255,255,255,0.92)","component.contentGraph.label.border":"rgba(122,140,163,0.32)","component.contentGraph.selection":"#22C55E","component.focus.outline":"#15803D","component.focus.outlineWidth":"2px"}}}]);