@tom2012/cc-web 2026.5.16-a → 2026.5.16-b

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 (39) hide show
  1. package/README.md +1 -1
  2. package/frontend/dist/assets/{ChatOverlay-DxpbRiER.js → ChatOverlay-BK7ylWXg.js} +1 -1
  3. package/frontend/dist/assets/{GraphPreview-DRLMf3Nh.js → GraphPreview-T95ywRPB.js} +2 -2
  4. package/frontend/dist/assets/{MobilePage-CokExUMn.js → MobilePage-BLVs9_5k.js} +3 -3
  5. package/frontend/dist/assets/{OfficePreview-CyzAoUZx.js → OfficePreview-CKseq-SI.js} +2 -2
  6. package/frontend/dist/assets/{PdfPreview-C8QLFGii.js → PdfPreview-ceRqAiRR.js} +1 -1
  7. package/frontend/dist/assets/{ProjectPage-BPXSttKO.js → ProjectPage-5zeDKF0E.js} +5 -5
  8. package/frontend/dist/assets/{SettingsPage-BsGVZ7QV.js → SettingsPage-DOUbFJgH.js} +1 -1
  9. package/frontend/dist/assets/{SkillHubPage-DcT0Bqhf.js → SkillHubPage-C5PQe1qz.js} +1 -1
  10. package/frontend/dist/assets/{TrackEditor-DOTXUGor.js → TrackEditor-CXn9A5LH.js} +3 -3
  11. package/frontend/dist/assets/TrackVisualEditor-D7Nj1dV-.js +2 -0
  12. package/frontend/dist/assets/{chevron-down-BqO_s8Lw.js → chevron-down-B5k9UZaS.js} +1 -1
  13. package/frontend/dist/assets/{cssMode-DzbSJSBr.js → cssMode-UDf13VxV.js} +1 -1
  14. package/frontend/dist/assets/{editor.main-DC8nTgWW.js → editor.main-DL1nkpnc.js} +7 -7
  15. package/frontend/dist/assets/{freemarker2-BXB8PQ7I.js → freemarker2-CBpHtauL.js} +1 -1
  16. package/frontend/dist/assets/{handlebars-I7ch77qF.js → handlebars-DR18oibx.js} +1 -1
  17. package/frontend/dist/assets/{html-Do_yHKxU.js → html-R-xYVcDJ.js} +1 -1
  18. package/frontend/dist/assets/{htmlMode-BPR1scxz.js → htmlMode-CIT_YpSc.js} +1 -1
  19. package/frontend/dist/assets/index-BD_QmGXq.css +1 -0
  20. package/frontend/dist/assets/{index-OYFfhZJK.js → index-BOt8Hwdx.js} +1 -1
  21. package/frontend/dist/assets/{index-CN701B8t.js → index-B_HwDnfi.js} +1 -1
  22. package/frontend/dist/assets/{index-B8JeGt0F.js → index-CfixATeo.js} +1 -1
  23. package/frontend/dist/assets/{index-P75DiJki.js → index-CoQOKlkh.js} +2 -2
  24. package/frontend/dist/assets/{javascript-BNXRKlsL.js → javascript-Cy29oO-Z.js} +1 -1
  25. package/frontend/dist/assets/{jsonMode-DtjdCBU0.js → jsonMode-BB1s4t8K.js} +1 -1
  26. package/frontend/dist/assets/{jszip.min-CUjeMA7z.js → jszip.min-C28kgKJw.js} +1 -1
  27. package/frontend/dist/assets/{liquid-BpL1MpJR.js → liquid-DK8aRC0y.js} +1 -1
  28. package/frontend/dist/assets/{mdx-tEcPj6CQ.js → mdx-Dj-K4EeA.js} +1 -1
  29. package/frontend/dist/assets/{python-niOtt1WT.js → python-ukYfDUCJ.js} +1 -1
  30. package/frontend/dist/assets/{razor-D_eSXSai.js → razor-BTYacRNO.js} +1 -1
  31. package/frontend/dist/assets/{select-BkQpRbP5.js → select-Bs4K8_uQ.js} +1 -1
  32. package/frontend/dist/assets/{tsMode-Cxpc0mXx.js → tsMode-CShWyfNw.js} +1 -1
  33. package/frontend/dist/assets/{typescript-B9YDFBes.js → typescript-CDgMSZwF.js} +1 -1
  34. package/frontend/dist/assets/{user-Da5oNB1i.js → user-DCEdR_h8.js} +1 -1
  35. package/frontend/dist/assets/{xml-ozjuWHxB.js → xml-DF-swCPQ.js} +1 -1
  36. package/frontend/dist/assets/{yaml-QQs8YH67.js → yaml-S7G1WVd6.js} +1 -1
  37. package/frontend/dist/index.html +2 -2
  38. package/package.json +1 -1
  39. package/frontend/dist/assets/index-BmPb0Wl1.css +0 -1
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor.main-DL1nkpnc.js","assets/index-CoQOKlkh.js","assets/index-BD_QmGXq.css","assets/editor-B5EY1bb8.css","assets/index-CfixATeo.js"])))=>i.map(i=>d[i]);
2
+ import{r as e,W as t,be as n,j as r,_ as o}from"./index-CoQOKlkh.js";import{M as a,N as i}from"./ProjectPage-5zeDKF0E.js";import"./purify.es-CgRAQgUo.js";import"./ChatOverlay-BK7ylWXg.js";import"./chevron-down-B5k9UZaS.js";import"./index-BOt8Hwdx.js";import"./select-Bs4K8_uQ.js";import"./user-DCEdR_h8.js";function s(){return"n_"+Math.random().toString(36).slice(2,10)}const l={ask_user:function(){return{id:s(),type:"ask_user",outputVar:"input",fields:[{key:"value",label:"请输入",type:"text",required:!0}]}},fai:function(){return{id:s(),type:"fai",faiName:"analyze",outputVar:"r",inputs:[],outputs:[{name:"result",type:"string"}],promptTemplate:[{kind:"text",raw:"请分析"}]}},let:function(){return{id:s(),type:"let",varName:"x",value:{kind:"lit",raw:"0"}}},return:function(){return{id:s(),type:"return",value:{kind:"lit",raw:"null"}}}};function c(e,t){const n=[];for(const r of function(e,t){const n=[];for(let r=0;r<t;r++){const t=e.body[r];t&&("ask_user"===t.type?n.push({name:t.outputVar,source:"ask_user",parts:t.fields.map(e=>e.key)}):"fai"===t.type?n.push({name:t.outputVar,source:"fai",parts:t.outputs.map(e=>e.name)}):"let"===t.type&&n.push({name:t.varName,source:"let",parts:[]}))}return n}(e,t)){n.push(r.name);for(const e of r.parts)n.push(`${r.name}.${e}`)}return n}function d(e,t,n){if(0===n.length)return!1;return c(e,t).includes(n.join("."))}function u(e){return e.path.join(".")}function p(e){return e.raw}function f(e){return"var"===e.kind?u(e):p(e)}function h(e){return"var"===e.kind?u(e):"lit"===e.kind?p(e):`${f((t=e).left)} ${t.op} ${f(t.right)}`;var t}function g(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\$/g,"\\$").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function m(e){return` // @@nid: ${e}`}function v(e){const t=e.inputs.map(e=>`${e.argName}:${e.argType}`).join("|"),n=e.outputs.map(e=>{const t=e.constraints??{},n=[];void 0!==t.min&&void 0!==t.max&&n.push(`range=${t.min}-${t.max}`),void 0!==t.maxLen&&n.push(`maxLen=${t.maxLen}`);const r=n.length?`;${n.join(",")}`:"";return"array"===e.type?`${e.name}:array<${e.innerType??"string"}>${r}`:`${e.name}:${e.type}${r}`}).join("|"),r=JSON.stringify(e.promptTemplate);return{faiName:e.faiName,inputsKey:t,outputsKey:n,promptKey:r}}function b(e,t){return`fai ${e}(${t.inputs.map(e=>`${e.argName}: ${e.argType}`).join(", ")}) -> ${t.outputs.map(e=>{let t=e.type;"array"===e.type&&(t=`array<${e.innerType??"string"}>`);const n=e.constraints??{},r=[];"number"==typeof n.min&&"number"==typeof n.max&&r.push(`${n.min}-${n.max}`),"number"==typeof n.maxLen&&r.push(`maxLen=${n.maxLen}`);const o=r.length?` ${r.join(" ")}`:"";return`${e.name}: ${t}${o}`}).join(", ")} { }`}function x(e,t){const n=[...e.inputs.map(e=>"var"===e.source.kind?u(e.source):p(e.source)),function(e){let t="";for(const n of e)"text"===n.kind?t+=g(n.raw):t+="${"+n.path.join(".")+"}";return`"${t}"`}(e.promptTemplate)].join(", ");return[m(e.id),` let ${e.outputVar} = ${t}(${n})`].join("\n")}function y(e){return"ask_user"===e.type||"fai"===e.type?e.outputVar:"let"===e.type?e.varName:null}function w(e){const t=[];if("fai"===e.type){for(const n of e.inputs)"var"===n.source.kind&&t.push(n.source);for(const n of e.promptTemplate)"ref"===n.kind&&t.push({kind:"var",path:n.path})}else("let"===e.type||"return"===e.type)&&N(e.value,t);return t}function N(e,t){"var"!==e.kind?"triple"===e.kind&&("var"===e.left.kind&&t.push(e.left),"var"===e.right.kind&&t.push(e.right)):t.push(e)}function j(e){const t=[];if(function(e,t){const n=new Map;for(let r=0;r<e.body.length;r++){const o=e.body[r];for(const n of w(o))d(e,r,n.path)||t.push({nodeIndex:r,nodeId:o.id,message:`variable "${n.path.join(".")}" not visible at this position`});const a=y(o);if(a){const e=n.get(a);e?t.push({nodeIndex:r,nodeId:o.id,message:`name "${a}" already declared at node #${e.index}`}):n.set(a,{index:r,id:o.id})}}}(e,t),t.length>0)return{ok:!1,errors:t};const n=[];for(const a of e.body)"fai"===a.type&&n.push(a);const r=function(e){const t=[],n=new Map;for(const r of e){const e=v(r);let o=t.find(t=>{return n=t.shape,r=e,n.faiName===r.faiName&&n.inputsKey===r.inputsKey&&n.outputsKey===r.outputsKey&&n.promptKey===r.promptKey;var n,r});if(!o){let n=e.faiName,a=2;for(;t.some(e=>e.declName===n);)n=`${e.faiName}_${a++}`;o={declName:n,declSource:b(n,r),shape:e},t.push(o)}n.set(r.id,o.declName)}return{decls:t,nodeIdToDeclName:n}}(n),o=[];for(let a=0;a<e.body.length;a++){const n=e.body[a];o.push(C(n,a,t,r))}if(t.length>0)return{ok:!1,errors:t};const s=0===r.decls.length?"":r.decls.map(e=>e.declSource).join("\n\n")+"\n\n";return{ok:!0,source:[a,i,"",s,"func main() -> any {",o.join("\n"),"}","export main",""].join("\n")}}function C(e,t,n,r){if("ask_user"===e.type)return function(e){const t=e.fields.map(e=>{const t=[`key: "${e.key}"`,`label: "${e.label}"`,`type: "${e.type}"`];return"enum"===e.type&&e.variants&&t.push(`variants: [${e.variants.map(e=>`"${e}"`).join(", ")}]`),!1===e.required&&t.push("required: false"),` { ${t.join(", ")} }`});return[m(e.id),` let ${e.outputVar} = __ccweb_ask_user({`," fields: [",t.join(",\n")," ]"," })"].join("\n")}(e);if("let"===e.type)return function(e){return[m(e.id),` let ${e.varName} = ${h(e.value)}`].join("\n")}(e);if("return"===e.type)return function(e){return[m(e.id),` return ${h(e.value)}`].join("\n")}(e);if("fai"===e.type){const o=r.nodeIdToDeclName.get(e.id);return o?x(e,o):(n.push({nodeIndex:t,nodeId:e.id,message:"fai dedupe lost node"}),"")}return n.push({nodeIndex:t,nodeId:e.id,message:"unknown node type"}),` // <unknown ${e.id}>`}const k="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function E(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function D(e){return"nodeType"in e}function R(e){var t,n;return e?E(e)?e:D(e)&&null!=(t=null==(n=e.ownerDocument)?void 0:n.defaultView)?t:window:window}function S(e){const{Document:t}=R(e);return e instanceof t}function M(e){return!E(e)&&e instanceof R(e).HTMLElement}function T(e){return e instanceof R(e).SVGElement}function O(e){return e?E(e)?e.document:D(e)?S(e)?e:M(e)||T(e)?e.ownerDocument:document:document:document}const $=k?e.useLayoutEffect:e.useEffect;function A(t){const n=e.useRef(t);return $(()=>{n.current=t}),e.useCallback(function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return null==n.current?void 0:n.current(...t)},[])}function L(t,n){void 0===n&&(n=[t]);const r=e.useRef(t);return $(()=>{r.current!==t&&(r.current=t)},n),r}function I(t,n){const r=e.useRef();return e.useMemo(()=>{const e=t(r.current);return r.current=e,e},[...n])}function P(t){const n=A(t),r=e.useRef(null),o=e.useCallback(e=>{e!==r.current&&(null==n||n(e,r.current)),r.current=e},[]);return[r,o]}function z(t){const n=e.useRef();return e.useEffect(()=>{n.current=t},[t]),n.current}let B={};function _(t,n){return e.useMemo(()=>{if(n)return n;const e=null==B[t]?0:B[t]+1;return B[t]=e,t+"-"+e},[t,n])}function K(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((t,n)=>{const r=Object.entries(n);for(const[o,a]of r){const n=t[o];null!=n&&(t[o]=n+e*a)}return t},{...t})}}const V=K(1),F=K(-1);function X(e){if(!e)return!1;const{KeyboardEvent:t}=R(e.target);return t&&e instanceof t}function Y(e){if(function(e){if(!e)return!1;const{TouchEvent:t}=R(e.target);return t&&e instanceof t}(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return function(e){return"clientX"in e&&"clientY"in e}(e)?{x:e.clientX,y:e.clientY}:null}const W=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[W.Translate.toString(e),W.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),U="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function q(e){return e.matches(U)?e:e.querySelector(U)}const J={display:"none"};function H(e){let{id:n,value:r}=e;return t.createElement("div",{id:n,style:J},r)}function G(e){let{id:n,announcement:r,ariaLiveType:o="assertive"}=e;return t.createElement("div",{id:n,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":o,"aria-atomic":!0},r)}const Q=e.createContext(null);const Z={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},ee={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function te(r){let{announcements:o=ee,container:a,hiddenTextDescribedById:i,screenReaderInstructions:s=Z}=r;const{announce:l,announcement:c}=function(){const[t,n]=e.useState("");return{announce:e.useCallback(e=>{null!=e&&n(e)},[]),announcement:t}}(),d=_("DndLiveRegion"),[u,p]=e.useState(!1);if(e.useEffect(()=>{p(!0)},[]),function(t){const n=e.useContext(Q);e.useEffect(()=>{if(!n)throw new Error("useDndMonitor must be used within a children of <DndContext>");return n(t)},[t,n])}(e.useMemo(()=>({onDragStart(e){let{active:t}=e;l(o.onDragStart({active:t}))},onDragMove(e){let{active:t,over:n}=e;o.onDragMove&&l(o.onDragMove({active:t,over:n}))},onDragOver(e){let{active:t,over:n}=e;l(o.onDragOver({active:t,over:n}))},onDragEnd(e){let{active:t,over:n}=e;l(o.onDragEnd({active:t,over:n}))},onDragCancel(e){let{active:t,over:n}=e;l(o.onDragCancel({active:t,over:n}))}}),[l,o])),!u)return null;const f=t.createElement(t.Fragment,null,t.createElement(H,{id:i,value:s.draggable}),t.createElement(G,{id:d,announcement:c}));return a?n.createPortal(f,a):f}var ne,re;function oe(){}(re=ne||(ne={})).DragStart="dragStart",re.DragMove="dragMove",re.DragEnd="dragEnd",re.DragCancel="dragCancel",re.DragOver="dragOver",re.RegisterDroppable="registerDroppable",re.SetDroppableDisabled="setDroppableDisabled",re.UnregisterDroppable="unregisterDroppable";const ae=Object.freeze({x:0,y:0});function ie(e,t){const n=Y(e);if(!n)return"0 0";return(n.x-t.left)/t.width*100+"% "+(n.y-t.top)/t.height*100+"%"}function se(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function le(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),i=o-r,s=a-n;if(r<o&&n<a){const n=t.width*t.height,r=e.width*e.height,o=i*s;return Number((o/(n+r-o)).toFixed(4))}return 0}const ce=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const a of r){const{id:e}=a,r=n.get(e);if(r){const n=le(r,t);n>0&&o.push({id:e,data:{droppableContainer:a,value:n}})}}return o.sort(se)};function de(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ae}function ue(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}const pe=ue(1);function fe(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}const he={ignoreTransform:!1};function ge(e,t){void 0===t&&(t=he);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=R(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=fe(t);if(!r)return e;const{scaleX:o,scaleY:a,x:i,y:s}=r,l=e.left-i-(1-o)*parseFloat(n),c=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=o?e.width/o:e.width,u=a?e.height/a:e.height;return{width:d,height:u,top:c,right:l+d,bottom:c+u,left:l}}(n,t,r))}const{top:r,left:o,width:a,height:i,bottom:s,right:l}=n;return{top:r,left:o,width:a,height:i,bottom:s,right:l}}function me(e){return ge(e,{ignoreTransform:!0})}function ve(e,t){const n=[];return e?function r(o){if(null!=t&&n.length>=t)return n;if(!o)return n;if(S(o)&&null!=o.scrollingElement&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!M(o)||T(o))return n;if(n.includes(o))return n;const a=R(e).getComputedStyle(o);return o!==e&&function(e,t){void 0===t&&(t=R(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(e=>{const r=t[e];return"string"==typeof r&&n.test(r)})}(o,a)&&n.push(o),function(e,t){return void 0===t&&(t=R(e).getComputedStyle(e)),"fixed"===t.position}(o,a)?n:r(o.parentNode)}(e):n}function be(e){const[t]=ve(e,1);return null!=t?t:null}function xe(e){return k&&e?E(e)?e:D(e)?S(e)||e===O(e).scrollingElement?window:M(e)?e:null:null:null}function ye(e){return E(e)?e.scrollX:e.scrollLeft}function we(e){return E(e)?e.scrollY:e.scrollTop}function Ne(e){return{x:ye(e),y:we(e)}}var je,Ce;function ke(e){return!(!k||!e)&&e===document.scrollingElement}function Ee(e){const t={x:0,y:0},n=ke(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}(Ce=je||(je={}))[Ce.Forward=1]="Forward",Ce[Ce.Backward=-1]="Backward";const De={x:.2,y:.2};function Re(e,t,n,r,o){let{top:a,left:i,right:s,bottom:l}=n;void 0===r&&(r=10),void 0===o&&(o=De);const{isTop:c,isBottom:d,isLeft:u,isRight:p}=Ee(e),f={x:0,y:0},h={x:0,y:0},g=t.height*o.y,m=t.width*o.x;return!c&&a<=t.top+g?(f.y=je.Backward,h.y=r*Math.abs((t.top+g-a)/g)):!d&&l>=t.bottom-g&&(f.y=je.Forward,h.y=r*Math.abs((t.bottom-g-l)/g)),!p&&s>=t.right-m?(f.x=je.Forward,h.x=r*Math.abs((t.right-m-s)/m)):!u&&i<=t.left+m&&(f.x=je.Backward,h.x=r*Math.abs((t.left+m-i)/m)),{direction:f,speed:h}}function Se(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Me(e){return e.reduce((e,t)=>V(e,Ne(t)),ae)}function Te(e,t){if(void 0===t&&(t=ge),!e)return;const{top:n,left:r,bottom:o,right:a}=t(e);be(e)&&(o<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Oe=[["x",["left","right"],function(e){return e.reduce((e,t)=>e+ye(t),0)}],["y",["top","bottom"],function(e){return e.reduce((e,t)=>e+we(t),0)}]];class $e{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=ve(t),r=Me(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[o,a,i]of Oe)for(const e of a)Object.defineProperty(this,e,{get:()=>{const t=i(n),a=r[o]-t;return this.rect[e]+a},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ae{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)})},this.target=e}add(e,t,n){var r;null==(r=this.target)||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function Le(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return"number"==typeof t?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t&&r>t.y}var Ie,Pe,ze,Be;function _e(e){e.preventDefault()}function Ke(e){e.stopPropagation()}(Pe=Ie||(Ie={})).Click="click",Pe.DragStart="dragstart",Pe.Keydown="keydown",Pe.ContextMenu="contextmenu",Pe.Resize="resize",Pe.SelectionChange="selectionchange",Pe.VisibilityChange="visibilitychange",(Be=ze||(ze={})).Space="Space",Be.Down="ArrowDown",Be.Right="ArrowRight",Be.Left="ArrowLeft",Be.Up="ArrowUp",Be.Esc="Escape",Be.Enter="Enter",Be.Tab="Tab";const Ve={start:[ze.Space,ze.Enter],cancel:[ze.Esc],end:[ze.Space,ze.Enter,ze.Tab]},Fe=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case ze.Right:return{...n,x:n.x+25};case ze.Left:return{...n,x:n.x-25};case ze.Down:return{...n,y:n.y+25};case ze.Up:return{...n,y:n.y-25}}};class Xe{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new Ae(O(t)),this.windowListeners=new Ae(R(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Ie.Resize,this.handleCancel),this.windowListeners.add(Ie.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Ie.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Te(n),t(ae)}handleKeyDown(e){if(X(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:o=Ve,coordinateGetter:a=Fe,scrollBehavior:i="smooth"}=r,{code:s}=e;if(o.end.includes(s))return void this.handleEnd(e);if(o.cancel.includes(s))return void this.handleCancel(e);const{collisionRect:l}=n.current,c=l?{x:l.left,y:l.top}:ae;this.referenceCoordinates||(this.referenceCoordinates=c);const d=a(e,{active:t,context:n.current,currentCoordinates:c});if(d){const t=F(d,c),r={x:0,y:0},{scrollableAncestors:o}=n.current;for(const n of o){const o=e.code,{isTop:a,isRight:s,isLeft:l,isBottom:c,maxScroll:u,minScroll:p}=Ee(n),f=Se(n),h={x:Math.min(o===ze.Right?f.right-f.width/2:f.right,Math.max(o===ze.Right?f.left:f.left+f.width/2,d.x)),y:Math.min(o===ze.Down?f.bottom-f.height/2:f.bottom,Math.max(o===ze.Down?f.top:f.top+f.height/2,d.y))},g=o===ze.Right&&!s||o===ze.Left&&!l,m=o===ze.Down&&!c||o===ze.Up&&!a;if(g&&h.x!==d.x){const e=n.scrollLeft+t.x,a=o===ze.Right&&e<=u.x||o===ze.Left&&e>=p.x;if(a&&!t.y)return void n.scrollTo({left:e,behavior:i});r.x=a?n.scrollLeft-e:o===ze.Right?n.scrollLeft-u.x:n.scrollLeft-p.x,r.x&&n.scrollBy({left:-r.x,behavior:i});break}if(m&&h.y!==d.y){const e=n.scrollTop+t.y,a=o===ze.Down&&e<=u.y||o===ze.Up&&e>=p.y;if(a&&!t.x)return void n.scrollTo({top:e,behavior:i});r.y=a?n.scrollTop-e:o===ze.Down?n.scrollTop-u.y:n.scrollTop-p.y,r.y&&n.scrollBy({top:-r.y,behavior:i});break}}this.handleMove(e,V(F(d,this.referenceCoordinates),r))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function Ye(e){return Boolean(e&&"distance"in e)}function We(e){return Boolean(e&&"delay"in e)}Xe.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=Ve,onActivation:o}=t,{active:a}=n;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const t=a.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==o||o({event:e.nativeEvent}),!0)}return!1}}];class Ue{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=R(e);return e instanceof t?e:O(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:o}=e,{target:a}=o;this.props=e,this.events=t,this.document=O(a),this.documentListeners=new Ae(this.document),this.listeners=new Ae(n),this.windowListeners=new Ae(R(a)),this.initialCoordinates=null!=(r=Y(o))?r:ae,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Ie.Resize,this.handleCancel),this.windowListeners.add(Ie.DragStart,_e),this.windowListeners.add(Ie.VisibilityChange,this.handleCancel),this.windowListeners.add(Ie.ContextMenu,_e),this.documentListeners.add(Ie.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(We(t))return this.timeoutId=setTimeout(this.handleStart,t.delay),void this.handlePending(t);if(Ye(t))return void this.handlePending(t)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){const{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Ie.Click,Ke,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Ie.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:o}=this,{onMove:a,options:{activationConstraint:i}}=o;if(!r)return;const s=null!=(t=Y(e))?t:ae,l=F(r,s);if(!n&&i){if(Ye(i)){if(null!=i.tolerance&&Le(l,i.tolerance))return this.handleCancel();if(Le(l,i.distance))return this.handleStart()}return We(i)&&Le(l,i.tolerance)?this.handleCancel():void this.handlePending(i,l)}e.cancelable&&e.preventDefault(),a(s)}handleEnd(){const{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){const{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===ze.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const qe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Je extends Ue{constructor(e){const{event:t}=e,n=O(t.target);super(e,qe,n)}}Je.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!(!n.isPrimary||0!==n.button)&&(null==r||r({event:n}),!0)}}];const He={move:{name:"mousemove"},end:{name:"mouseup"}};var Ge,Qe;(Qe=Ge||(Ge={}))[Qe.RightClick=2]="RightClick";(class extends Ue{constructor(e){super(e,He,O(e.event.target))}}).activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==Ge.RightClick&&(null==r||r({event:n}),!0)}}];const Ze={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};var et,tt,nt,rt;function ot(t){let{acceleration:n,activator:r=et.Pointer,canScroll:o,draggingRect:a,enabled:i,interval:s=5,order:l=nt.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:u,delta:p,threshold:f}=t;const h=function(e){let{delta:t,disabled:n}=e;const r=z(t);return I(e=>{if(n||!r||!e)return at;const o={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[je.Backward]:e.x[je.Backward]||-1===o.x,[je.Forward]:e.x[je.Forward]||1===o.x},y:{[je.Backward]:e.y[je.Backward]||-1===o.y,[je.Forward]:e.y[je.Forward]||1===o.y}}},[n,t,r])}({delta:p,disabled:!i}),[g,m]=function(){const t=e.useRef(null);return[e.useCallback((e,n)=>{t.current=setInterval(e,n)},[]),e.useCallback(()=>{null!==t.current&&(clearInterval(t.current),t.current=null)},[])]}(),v=e.useRef({x:0,y:0}),b=e.useRef({x:0,y:0}),x=e.useMemo(()=>{switch(r){case et.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case et.DraggableRect:return a}},[r,a,c]),y=e.useRef(null),w=e.useCallback(()=>{const e=y.current;if(!e)return;const t=v.current.x*b.current.x,n=v.current.y*b.current.y;e.scrollBy(t,n)},[]),N=e.useMemo(()=>l===nt.TreeOrder?[...d].reverse():d,[l,d]);e.useEffect(()=>{if(i&&d.length&&x){for(const e of N){if(!1===(null==o?void 0:o(e)))continue;const t=d.indexOf(e),r=u[t];if(!r)continue;const{direction:a,speed:i}=Re(e,r,x,n,f);for(const e of["x","y"])h[e][a[e]]||(i[e]=0,a[e]=0);if(i.x>0||i.y>0)return m(),y.current=e,g(w,s),v.current=i,void(b.current=a)}v.current={x:0,y:0},b.current={x:0,y:0},m()}else m()},[n,w,o,m,i,s,JSON.stringify(x),JSON.stringify(h),g,d,N,u,JSON.stringify(f)])}(class extends Ue{constructor(e){super(e,Ze)}static setup(){return window.addEventListener(Ze.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Ze.move.name,e)};function e(){}}}).activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return!(o.length>1)&&(null==r||r({event:n}),!0)}}],(tt=et||(et={}))[tt.Pointer=0]="Pointer",tt[tt.DraggableRect=1]="DraggableRect",(rt=nt||(nt={}))[rt.TreeOrder=0]="TreeOrder",rt[rt.ReversedTreeOrder=1]="ReversedTreeOrder";const at={x:{[je.Backward]:!1,[je.Forward]:!1},y:{[je.Backward]:!1,[je.Forward]:!1}};var it,st,lt;(st=it||(it={}))[st.Always=0]="Always",st[st.BeforeDragging=1]="BeforeDragging",st[st.WhileDragging=2]="WhileDragging",(lt||(lt={})).Optimized="optimized";const ct=new Map;function dt(e,t){return I(n=>e?n||("function"==typeof t?t(e):e):null,[t,e])}function ut(t){let{callback:n,disabled:r}=t;const o=A(n),a=e.useMemo(()=>{if(r||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(o)},[r]);return e.useEffect(()=>()=>null==a?void 0:a.disconnect(),[a]),a}function pt(e){return new $e(ge(e),e)}function ft(t,n,r){void 0===n&&(n=pt);const[o,a]=e.useState(null);function i(){a(e=>{if(!t)return null;var o;if(!1===t.isConnected)return null!=(o=null!=e?e:r)?o:null;const a=n(t);return JSON.stringify(e)===JSON.stringify(a)?e:a})}const s=function(t){let{callback:n,disabled:r}=t;const o=A(n),a=e.useMemo(()=>{if(r||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(o)},[o,r]);return e.useEffect(()=>()=>null==a?void 0:a.disconnect(),[a]),a}({callback(e){if(t)for(const n of e){const{type:e,target:r}=n;if("childList"===e&&r instanceof HTMLElement&&r.contains(t)){i();break}}}}),l=ut({callback:i});return $(()=>{i(),t?(null==l||l.observe(t),null==s||s.observe(document.body,{childList:!0,subtree:!0})):(null==l||l.disconnect(),null==s||s.disconnect())},[t]),o}const ht=[];function gt(t,n){void 0===n&&(n=[]);const r=e.useRef(null);return e.useEffect(()=>{r.current=null},n),e.useEffect(()=>{const e=t!==ae;e&&!r.current&&(r.current=t),!e&&r.current&&(r.current=null)},[t]),r.current?F(t,r.current):ae}function mt(t){return e.useMemo(()=>t?function(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}(t):null,[t])}const vt=[];function bt(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return M(t)?t:e}const xt=[{sensor:Je,options:{}},{sensor:Xe,options:{}}],yt={current:{}},wt={draggable:{measure:me},droppable:{measure:me,strategy:it.WhileDragging,frequency:lt.Optimized},dragOverlay:{measure:ge}};class Nt extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const jt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Nt,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:oe},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:wt,measureDroppableContainers:oe,windowRect:null,measuringScheduled:!1},Ct={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:oe,draggableNodes:new Map,over:null,measureDroppableContainers:oe},kt=e.createContext(Ct),Et=e.createContext(jt);function Dt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Nt}}}function Rt(e,t){switch(t.type){case ne.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case ne.DragMove:return null==e.draggable.active?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case ne.DragEnd:case ne.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ne.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Nt(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case ne.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;const i=new Nt(e.droppable.containers);return i.set(n,{...a,disabled:o}),{...e,droppable:{...e.droppable,containers:i}}}case ne.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const a=new Nt(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function St(t){let{disabled:n}=t;const{active:r,activatorEvent:o,draggableNodes:a}=e.useContext(kt),i=z(o),s=z(null==r?void 0:r.id);return e.useEffect(()=>{if(!n&&!o&&i&&null!=s){if(!X(i))return;if(document.activeElement===i.target)return;const e=a.get(s);if(!e)return;const{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(const e of[t.current,n.current]){if(!e)continue;const t=q(e);if(t){t.focus();break}}})}},[o,n,a,s,i]),null}function Mt(e,t){let{transform:n,...r}=t;return null!=e&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}const Tt=e.createContext({...ae,scaleX:1,scaleY:1});var Ot,$t;($t=Ot||(Ot={}))[$t.Uninitialized=0]="Uninitialized",$t[$t.Initializing=1]="Initializing",$t[$t.Initialized=2]="Initialized";const At=e.memo(function(r){var o,a,i,s;let{id:l,accessibility:c,autoScroll:d=!0,children:u,sensors:p=xt,collisionDetection:f=ce,measuring:h,modifiers:g,...m}=r;const v=e.useReducer(Rt,void 0,Dt),[b,x]=v,[y,w]=function(){const[t]=e.useState(()=>new Set),n=e.useCallback(e=>(t.add(e),()=>t.delete(e)),[t]);return[e.useCallback(e=>{let{type:n,event:r}=e;t.forEach(e=>{var t;return null==(t=e[n])?void 0:t.call(e,r)})},[t]),n]}(),[N,j]=e.useState(Ot.Uninitialized),C=N===Ot.Initialized,{draggable:{active:E,nodes:D,translate:S},droppable:{containers:T}}=b,O=null!=E?D.get(E):null,A=e.useRef({initial:null,translated:null}),z=e.useMemo(()=>{var e;return null!=E?{id:E,data:null!=(e=null==O?void 0:O.data)?e:yt,rect:A}:null},[E,O]),B=e.useRef(null),[K,F]=e.useState(null),[X,W]=e.useState(null),U=L(m,Object.values(m)),q=_("DndDescribedBy",l),J=e.useMemo(()=>T.getEnabled(),[T]),H=(G=h,e.useMemo(()=>({draggable:{...wt.draggable,...null==G?void 0:G.draggable},droppable:{...wt.droppable,...null==G?void 0:G.droppable},dragOverlay:{...wt.dragOverlay,...null==G?void 0:G.dragOverlay}}),[null==G?void 0:G.draggable,null==G?void 0:G.droppable,null==G?void 0:G.dragOverlay]));var G;const{droppableRects:Z,measureDroppableContainers:ee,measuringScheduled:re}=function(t,n){let{dragging:r,dependencies:o,config:a}=n;const[i,s]=e.useState(null),{frequency:l,measure:c,strategy:d}=a,u=e.useRef(t),p=function(){switch(d){case it.Always:return!1;case it.BeforeDragging:return r;default:return!r}}(),f=L(p),h=e.useCallback(function(e){void 0===e&&(e=[]),f.current||s(t=>null===t?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),g=e.useRef(null),m=I(e=>{if(p&&!r)return ct;if(!e||e===ct||u.current!==t||null!=i){const e=new Map;for(let n of t){if(!n)continue;if(i&&i.length>0&&!i.includes(n.id)&&n.rect.current){e.set(n.id,n.rect.current);continue}const t=n.node.current,r=t?new $e(c(t),t):null;n.rect.current=r,r&&e.set(n.id,r)}return e}return e},[t,i,r,p,c]);return e.useEffect(()=>{u.current=t},[t]),e.useEffect(()=>{p||h()},[r,p]),e.useEffect(()=>{i&&i.length>0&&s(null)},[JSON.stringify(i)]),e.useEffect(()=>{p||"number"!=typeof l||null!==g.current||(g.current=setTimeout(()=>{h(),g.current=null},l))},[l,p,h,...o]),{droppableRects:m,measureDroppableContainers:h,measuringScheduled:null!=i}}(J,{dragging:C,dependencies:[S.x,S.y],config:H.droppable}),oe=function(e,t){const n=null!=t?e.get(t):void 0,r=n?n.node.current:null;return I(e=>{var n;return null==t?null:null!=(n=null!=r?r:e)?n:null},[r,t])}(D,E),ie=e.useMemo(()=>X?Y(X):null,[X]),se=function(){const e=!1===(null==K?void 0:K.autoScrollEnabled),t="object"==typeof d?!1===d.enabled:!1===d,n=C&&!e&&!t;if("object"==typeof d)return{...d,enabled:n};return{enabled:n}}(),le=function(e,t){return dt(e,t)}(oe,H.draggable.measure);!function(t){let{activeNode:n,measure:r,initialRect:o,config:a=!0}=t;const i=e.useRef(!1),{x:s,y:l}="boolean"==typeof a?{x:a,y:a}:a;$(()=>{if(!s&&!l||!n)return void(i.current=!1);if(i.current||!o)return;const e=null==n?void 0:n.node.current;if(!e||!1===e.isConnected)return;const t=de(r(e),o);if(s||(t.x=0),l||(t.y=0),i.current=!0,Math.abs(t.x)>0||Math.abs(t.y)>0){const n=be(e);n&&n.scrollBy({top:t.y,left:t.x})}},[n,s,l,o,r])}({activeNode:null!=E?D.get(E):null,config:se.layoutShiftCompensation,initialRect:le,measure:H.draggable.measure});const ue=ft(oe,H.draggable.measure,le),fe=ft(oe?oe.parentElement:null),he=e.useRef({activatorEvent:null,active:null,activeNode:oe,collisionRect:null,collisions:null,droppableRects:Z,draggableNodes:D,draggingNode:null,draggingNodeRect:null,droppableContainers:T,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),me=T.getNodeFor(null==(o=he.current.over)?void 0:o.id),ye=function(t){let{measure:n}=t;const[r,o]=e.useState(null),a=ut({callback:e.useCallback(e=>{for(const{target:t}of e)if(M(t)){o(e=>{const r=n(t);return e?{...e,width:r.width,height:r.height}:r});break}},[n])}),i=e.useCallback(e=>{const t=bt(e);null==a||a.disconnect(),t&&(null==a||a.observe(t)),o(t?n(t):null)},[n,a]),[s,l]=P(i);return e.useMemo(()=>({nodeRef:s,rect:r,setRef:l}),[r,s,l])}({measure:H.dragOverlay.measure}),we=null!=(a=ye.nodeRef.current)?a:oe,je=C?null!=(i=ye.rect)?i:ue:null,Ce=Boolean(ye.nodeRef.current&&ye.rect),Ee=de(De=Ce?null:ue,dt(De));var De;const Re=mt(we?R(we):null),Se=function(t){const n=e.useRef(t),r=I(e=>t?e&&e!==ht&&t&&n.current&&t.parentNode===n.current.parentNode?e:ve(t):ht,[t]);return e.useEffect(()=>{n.current=t},[t]),r}(C?null!=me?me:oe:null),Te=function(t,n){void 0===n&&(n=ge);const[r]=t,o=mt(r?R(r):null),[a,i]=e.useState(vt);function s(){i(()=>t.length?t.map(e=>ke(e)?o:new $e(n(e),e)):vt)}const l=ut({callback:s});return $(()=>{null==l||l.disconnect(),s(),t.forEach(e=>null==l?void 0:l.observe(e))},[t]),a}(Se),Oe=Mt(g,{transform:{x:S.x-Ee.x,y:S.y-Ee.y,scaleX:1,scaleY:1},activatorEvent:X,active:z,activeNodeRect:ue,containerNodeRect:fe,draggingNodeRect:je,over:he.current.over,overlayNodeRect:ye.rect,scrollableAncestors:Se,scrollableAncestorRects:Te,windowRect:Re}),Ae=ie?V(ie,S):null,Le=function(t){const[n,r]=e.useState(null),o=e.useRef(t),a=e.useCallback(e=>{const t=xe(e.target);t&&r(e=>e?(e.set(t,Ne(t)),new Map(e)):null)},[]);return e.useEffect(()=>{const e=o.current;if(t!==e){n(e);const i=t.map(e=>{const t=xe(e);return t?(t.addEventListener("scroll",a,{passive:!0}),[t,Ne(t)]):null}).filter(e=>null!=e);r(i.length?new Map(i):null),o.current=t}return()=>{n(t),n(e)};function n(e){e.forEach(e=>{const t=xe(e);null==t||t.removeEventListener("scroll",a)})}},[a,t]),e.useMemo(()=>t.length?n?Array.from(n.values()).reduce((e,t)=>V(e,t),ae):Me(t):ae,[t,n])}(Se),Ie=gt(Le),Pe=gt(Le,[ue]),ze=V(Oe,Ie),Be=je?pe(je,Oe):null,_e=z&&Be?f({active:z,collisionRect:Be,droppableRects:Z,droppableContainers:J,pointerCoordinates:Ae}):null,Ke=function(e,t){if(!e||0===e.length)return null;const[n]=e;return n[t]}(_e,"id"),[Ve,Fe]=e.useState(null),Xe=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(Ce?Oe:V(Oe,Pe),null!=(s=null==Ve?void 0:Ve.rect)?s:null,ue),Ye=e.useRef(null),We=e.useCallback((e,t)=>{let{sensor:r,options:o}=t;if(null==B.current)return;const a=D.get(B.current);if(!a)return;const i=e.nativeEvent,s=new r({active:B.current,activeNode:a,event:i,options:o,context:he,onAbort(e){if(!D.get(e))return;const{onDragAbort:t}=U.current,n={id:e};null==t||t(n),y({type:"onDragAbort",event:n})},onPending(e,t,n,r){if(!D.get(e))return;const{onDragPending:o}=U.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};null==o||o(a),y({type:"onDragPending",event:a})},onStart(e){const t=B.current;if(null==t)return;const r=D.get(t);if(!r)return;const{onDragStart:o}=U.current,a={activatorEvent:i,active:{id:t,data:r.data,rect:A}};n.unstable_batchedUpdates(()=>{null==o||o(a),j(Ot.Initializing),x({type:ne.DragStart,initialCoordinates:e,active:t}),y({type:"onDragStart",event:a}),F(Ye.current),W(i)})},onMove(e){x({type:ne.DragMove,coordinates:e})},onEnd:l(ne.DragEnd),onCancel:l(ne.DragCancel)});function l(e){return async function(){const{active:t,collisions:r,over:o,scrollAdjustedTranslate:a}=he.current;let s=null;if(t&&a){const{cancelDrop:n}=U.current;if(s={activatorEvent:i,active:t,collisions:r,delta:a,over:o},e===ne.DragEnd&&"function"==typeof n){await Promise.resolve(n(s))&&(e=ne.DragCancel)}}B.current=null,n.unstable_batchedUpdates(()=>{x({type:e}),j(Ot.Uninitialized),Fe(null),F(null),W(null),Ye.current=null;const t=e===ne.DragEnd?"onDragEnd":"onDragCancel";if(s){const e=U.current[t];null==e||e(s),y({type:t,event:s})}})}}Ye.current=s},[D]),Ue=function(t,n){return e.useMemo(()=>t.reduce((e,t)=>{const{sensor:r}=t;return[...e,...r.activators.map(e=>({eventName:e.eventName,handler:n(e.handler,t)}))]},[]),[t,n])}(p,e.useCallback((e,t)=>(n,r)=>{const o=n.nativeEvent,a=D.get(r);if(null!==B.current||!a||o.dndKit||o.defaultPrevented)return;const i={active:a};!0===e(n,t.options,i)&&(o.dndKit={capturedBy:t.sensor},B.current=r,We(n,t))},[D,We]));!function(t){e.useEffect(()=>{if(!k)return;const e=t.map(e=>{let{sensor:t}=e;return null==t.setup?void 0:t.setup()});return()=>{for(const t of e)null==t||t()}},t.map(e=>{let{sensor:t}=e;return t}))}(p),$(()=>{ue&&N===Ot.Initializing&&j(Ot.Initialized)},[ue,N]),e.useEffect(()=>{const{onDragMove:e}=U.current,{active:t,activatorEvent:r,collisions:o,over:a}=he.current;if(!t||!r)return;const i={active:t,activatorEvent:r,collisions:o,delta:{x:ze.x,y:ze.y},over:a};n.unstable_batchedUpdates(()=>{null==e||e(i),y({type:"onDragMove",event:i})})},[ze.x,ze.y]),e.useEffect(()=>{const{active:e,activatorEvent:t,collisions:r,droppableContainers:o,scrollAdjustedTranslate:a}=he.current;if(!e||null==B.current||!t||!a)return;const{onDragOver:i}=U.current,s=o.get(Ke),l=s&&s.rect.current?{id:s.id,rect:s.rect.current,data:s.data,disabled:s.disabled}:null,c={active:e,activatorEvent:t,collisions:r,delta:{x:a.x,y:a.y},over:l};n.unstable_batchedUpdates(()=>{Fe(l),null==i||i(c),y({type:"onDragOver",event:c})})},[Ke]),$(()=>{he.current={activatorEvent:X,active:z,activeNode:oe,collisionRect:Be,collisions:_e,droppableRects:Z,draggableNodes:D,draggingNode:we,draggingNodeRect:je,droppableContainers:T,over:Ve,scrollableAncestors:Se,scrollAdjustedTranslate:ze},A.current={initial:je,translated:Be}},[z,oe,_e,Be,D,we,je,Z,T,Ve,Se,ze]),ot({...se,delta:S,draggingRect:Be,pointerCoordinates:Ae,scrollableAncestors:Se,scrollableAncestorRects:Te});const qe=e.useMemo(()=>({active:z,activeNode:oe,activeNodeRect:ue,activatorEvent:X,collisions:_e,containerNodeRect:fe,dragOverlay:ye,draggableNodes:D,droppableContainers:T,droppableRects:Z,over:Ve,measureDroppableContainers:ee,scrollableAncestors:Se,scrollableAncestorRects:Te,measuringConfiguration:H,measuringScheduled:re,windowRect:Re}),[z,oe,ue,X,_e,fe,ye,D,T,Z,Ve,ee,Se,Te,H,re,Re]),Je=e.useMemo(()=>({activatorEvent:X,activators:Ue,active:z,activeNodeRect:ue,ariaDescribedById:{draggable:q},dispatch:x,draggableNodes:D,over:Ve,measureDroppableContainers:ee}),[X,Ue,z,ue,x,q,D,Ve,ee]);return t.createElement(Q.Provider,{value:w},t.createElement(kt.Provider,{value:Je},t.createElement(Et.Provider,{value:qe},t.createElement(Tt.Provider,{value:Xe},u)),t.createElement(St,{disabled:!1===(null==c?void 0:c.restoreFocus)})),t.createElement(te,{...c,hiddenTextDescribedById:q}))}),Lt=e.createContext(null),It="button";function Pt(t){let{id:n,data:r,disabled:o=!1,attributes:a}=t;const i=_("Draggable"),{activators:s,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:p,over:f}=e.useContext(kt),{role:h=It,roleDescription:g="draggable",tabIndex:m=0}=null!=a?a:{},v=(null==c?void 0:c.id)===n,b=e.useContext(v?Tt:Lt),[x,y]=P(),[w,N]=P(),j=function(t,n){return e.useMemo(()=>t.reduce((e,t)=>{let{eventName:r,handler:o}=t;return e[r]=e=>{o(e,n)},e},{}),[t,n])}(s,n),C=L(r);$(()=>(p.set(n,{id:n,key:i,node:x,activatorNode:w,data:C}),()=>{const e=p.get(n);e&&e.key===i&&p.delete(n)}),[p,n]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:e.useMemo(()=>({role:h,tabIndex:m,"aria-disabled":o,"aria-pressed":!(!v||h!==It)||void 0,"aria-roledescription":g,"aria-describedby":u.draggable}),[o,h,m,v,g,u.draggable]),isDragging:v,listeners:o?void 0:j,node:x,over:f,setNodeRef:y,setActivatorNodeRef:N,transform:b}}const zt={timeout:25};function Bt(t){let{data:n,disabled:r=!1,id:o,resizeObserverConfig:a}=t;const i=_("Droppable"),{active:s,dispatch:l,over:c,measureDroppableContainers:d}=e.useContext(kt),u=e.useRef({disabled:r}),p=e.useRef(!1),f=e.useRef(null),h=e.useRef(null),{disabled:g,updateMeasurementsFor:m,timeout:v}={...zt,...a},b=L(null!=m?m:o),x=ut({callback:e.useCallback(()=>{p.current?(null!=h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{d(Array.isArray(b.current)?b.current:[b.current]),h.current=null},v)):p.current=!0},[v]),disabled:g||!s}),y=e.useCallback((e,t)=>{x&&(t&&(x.unobserve(t),p.current=!1),e&&x.observe(e))},[x]),[w,N]=P(y),j=L(n);return e.useEffect(()=>{x&&w.current&&(x.disconnect(),p.current=!1,x.observe(w.current))},[w,x]),e.useEffect(()=>(l({type:ne.RegisterDroppable,element:{id:o,key:i,disabled:r,node:w,rect:f,data:j}}),()=>l({type:ne.UnregisterDroppable,key:i,id:o})),[o]),e.useEffect(()=>{r!==u.current.disabled&&(l({type:ne.SetDroppableDisabled,id:o,key:i,disabled:r}),u.current.disabled=r)},[o,i,r,l]),{active:s,rect:f,isOver:(null==c?void 0:c.id)===o,node:w,over:c,setNodeRef:N}}function _t(n){let{animation:r,children:o}=n;const[a,i]=e.useState(null),[s,l]=e.useState(null),c=z(o);return o||a||!c||i(c),$(()=>{if(!s)return;const e=null==a?void 0:a.key,t=null==a?void 0:a.props.id;null!=e&&null!=t?Promise.resolve(r(t,s)).then(()=>{i(null)}):i(null)},[r,a,s]),t.createElement(t.Fragment,null,o,a?e.cloneElement(a,{ref:l}):null)}const Kt={x:0,y:0,scaleX:1,scaleY:1};function Vt(e){let{children:n}=e;return t.createElement(kt.Provider,{value:Ct},t.createElement(Tt.Provider,{value:Kt},n))}const Ft={position:"fixed",touchAction:"none"},Xt=e=>X(e)?"transform 250ms ease":void 0,Yt=e.forwardRef((e,n)=>{let{as:r,activatorEvent:o,adjustScale:a,children:i,className:s,rect:l,style:c,transform:d,transition:u=Xt}=e;if(!l)return null;const p=a?d:{...d,scaleX:1,scaleY:1},f={...Ft,width:l.width,height:l.height,top:l.top,left:l.left,transform:W.Transform.toString(p),transformOrigin:a&&o?ie(o,l):void 0,transition:"function"==typeof u?u(o):u,...c};return t.createElement(r,{className:s,style:f,ref:n},i)}),Wt={duration:250,easing:"ease",keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:W.Transform.toString(t)},{transform:W.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:a,className:i}=e;if(null!=a&&a.active)for(const[e,s]of Object.entries(a.active))void 0!==s&&(o[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,s));if(null!=a&&a.dragOverlay)for(const[e,s]of Object.entries(a.dragOverlay))void 0!==s&&r.node.style.setProperty(e,s);return null!=i&&i.active&&n.node.classList.add(i.active),null!=i&&i.dragOverlay&&r.node.classList.add(i.dragOverlay),function(){for(const[e,t]of Object.entries(o))n.node.style.setProperty(e,t);null!=i&&i.active&&n.node.classList.remove(i.active)}})({styles:{active:{opacity:"0"}}})};function Ut(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return A((e,a)=>{if(null===t)return;const i=n.get(e);if(!i)return;const s=i.node.current;if(!s)return;const l=bt(a);if(!l)return;const{transform:c}=R(a).getComputedStyle(a),d=fe(c);if(!d)return;const u="function"==typeof t?t:function(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...Wt,...e};return e=>{let{active:a,dragOverlay:i,transform:s,...l}=e;if(!t)return;const c={x:i.rect.left-a.rect.left,y:i.rect.top-a.rect.top},d={scaleX:1!==s.scaleX?a.rect.width*s.scaleX/i.rect.width:1,scaleY:1!==s.scaleY?a.rect.height*s.scaleY/i.rect.height:1},u={x:s.x-c.x,y:s.y-c.y,...d},p=o({...l,active:a,dragOverlay:i,transform:{initial:s,final:u}}),[f]=p,h=p[p.length-1];if(JSON.stringify(f)===JSON.stringify(h))return;const g=null==r?void 0:r({active:a,dragOverlay:i,...l}),m=i.node.animate(p,{duration:t,easing:n,fill:"forwards"});return new Promise(e=>{m.onfinish=()=>{null==g||g(),e()}})}}(t);return Te(s,o.draggable.measure),u({active:{id:e,data:i.data,node:s,rect:o.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:o.dragOverlay.measure(l)},droppableContainers:r,measuringConfiguration:o,transform:d})})}let qt=0;const Jt=t.memo(n=>{let{adjustScale:r=!1,children:o,dropAnimation:a,style:i,transition:s,modifiers:l,wrapperElement:c="div",className:d,zIndex:u=999}=n;const{activatorEvent:p,active:f,activeNodeRect:h,containerNodeRect:g,draggableNodes:m,droppableContainers:v,dragOverlay:b,over:x,measuringConfiguration:y,scrollableAncestors:w,scrollableAncestorRects:N,windowRect:j}=e.useContext(Et),C=e.useContext(Tt),k=(E=null==f?void 0:f.id,e.useMemo(()=>{if(null!=E)return qt++,qt},[E]));var E;const D=Mt(l,{activatorEvent:p,active:f,activeNodeRect:h,containerNodeRect:g,draggingNodeRect:b.rect,over:x,overlayNodeRect:b.rect,scrollableAncestors:w,scrollableAncestorRects:N,transform:C,windowRect:j}),R=dt(h),S=Ut({config:a,draggableNodes:m,droppableContainers:v,measuringConfiguration:y}),M=R?b.setRef:void 0;return t.createElement(Vt,null,t.createElement(_t,{animation:S},f&&k?t.createElement(Yt,{key:k,id:f.id,ref:M,as:c,activatorEvent:p,adjustScale:r,className:d,transition:s,rect:R,style:{zIndex:u,...i},transform:D},o):null))}),Ht={ask_user:{icon:"💬",label:"问用户",color:"bg-pink-50 border-pink-300"},fai:{icon:"🤖",label:"AI 调用",color:"bg-orange-50 border-orange-300"},let:{icon:"📦",label:"命名变量",color:"bg-gray-50 border-gray-300"},return:{icon:"⬅️",label:"返回",color:"bg-purple-50 border-purple-300"}};function Gt(e){return"var"===e.kind?"@"+e.path.join("."):"lit"===e.kind?e.raw:"(triple)"}function Qt({node:e,index:t,selected:n,onSelect:o,onDuplicate:a,onRemove:i}){const s=Ht[e.type],{attributes:l,listeners:c,setNodeRef:d,isDragging:u}=Pt({id:`node:${e.id}`,data:{kind:"reorder",sourceIndex:t,nodeId:e.id}}),{setNodeRef:p,isOver:f}=Bt({id:`drop-before:${e.id}`,data:{kind:"drop-before",index:t}});let h="";return"ask_user"===e.type?h=`${e.outputVar} ← { ${e.fields.map(e=>e.key).join(", ")} }`:"fai"===e.type?h=`${e.outputVar} ← ${e.faiName}(${e.inputs.length} args)`:"let"===e.type?h=`${e.varName} = ${Gt(e.value)}`:"return"===e.type&&(h=`return ${Gt(e.value)}`),r.jsxs("div",{ref:p,className:"relative",children:[f&&r.jsx("div",{className:"absolute left-0 right-0 -top-1 h-0.5 bg-blue-500 z-10"}),r.jsxs("div",{ref:d,...l,...c,onClick:e=>{e.stopPropagation(),o()},className:["border rounded-lg p-3 cursor-pointer transition-all",s.color,n?"ring-2 ring-blue-500 shadow":"hover:shadow-sm",u?"opacity-50":""].join(" "),children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"text-xl",children:s.icon}),r.jsx("span",{className:"font-medium",children:s.label}),r.jsxs("div",{className:"ml-auto flex gap-1",children:[r.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),a()},className:"text-xs text-gray-500 hover:text-gray-800 px-1",children:"复制"}),r.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),i()},className:"text-xs text-red-500 hover:text-red-700 px-1",children:"删除"})]})]}),r.jsx("div",{className:"text-sm font-mono text-gray-700",children:h})]})]})}const Zt={ask_user:"💬 问用户",fai:"🤖 AI 调用",let:"📦 命名变量",return:"⬅️ 返回"};function en({graph:t,dispatch:n,selectedId:o,onSelect:a}){const[i,s]=e.useState(null),c=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.useMemo(()=>[...n].filter(e=>null!=e),[...n])}((d=Je,u={activationConstraint:{distance:8}},e.useMemo(()=>({sensor:d,options:null!=u?u:{}}),[d,u])));var d,u;return r.jsxs(At,{sensors:c,onDragStart:e=>{const t=e.active.data.current;"create"===(null==t?void 0:t.kind)&&t.nodeType?s({kind:"create",label:Zt[t.nodeType]}):"reorder"===(null==t?void 0:t.kind)&&s({kind:"reorder",label:"移动节点"})},onDragEnd:function(e){s(null);const{active:r,over:o}=e;if(!o)return;const a=r.data.current,i=o.data.current;if(a&&i){if("create"===a.kind&&"drop-before"===i.kind){const e=a.nodeType?l[a.nodeType]:void 0;e&&n({type:"add",node:e(),index:i.index??0})}if("create"===a.kind&&"drop-end"===i.kind){const e=a.nodeType?l[a.nodeType]:void 0;e&&n({type:"add",node:e(),index:t.body.length})}if("reorder"===a.kind&&"drop-before"===i.kind){const e=a.sourceIndex;if("number"!=typeof e)return;let t=i.index??0;e<t&&(t-=1),e!==t&&n({type:"move",from:e,to:t})}if("reorder"===a.kind&&"drop-end"===i.kind){const e=a.sourceIndex;if("number"!=typeof e)return;const r=t.body.length-1;e!==r&&n({type:"move",from:e,to:r})}}},onDragCancel:()=>s(null),children:[r.jsxs("main",{className:"ml-48 mr-96 p-6 min-h-screen",onClick:()=>a(null),children:[r.jsx("h1",{className:"text-xl font-semibold mb-4",children:t.trackName}),r.jsxs("div",{className:"flex flex-col gap-2",children:[0===t.body.length&&r.jsx(tn,{}),t.body.map((e,t)=>r.jsx(Qt,{node:e,index:t,selected:o===e.id,onSelect:()=>a(e.id),onDuplicate:()=>n({type:"duplicate",index:t}),onRemove:()=>n({type:"remove",index:t})},e.id)),t.body.length>0&&r.jsx(nn,{})]})]}),r.jsx(Jt,{children:i&&r.jsx("div",{className:"px-3 py-2 bg-white border-2 border-blue-400 rounded shadow text-sm",children:i.label})})]})}function tn(){const{setNodeRef:e,isOver:t}=Bt({id:"drop-end-empty",data:{kind:"drop-end"}});return r.jsx("div",{ref:e,className:["border-2 border-dashed rounded-lg p-12 text-center text-gray-400",t?"border-blue-500 bg-blue-50":"border-gray-300"].join(" "),children:"从左侧拖一个节点过来开始搭建"})}function nn(){const{setNodeRef:e,isOver:t}=Bt({id:"drop-end",data:{kind:"drop-end"}});return r.jsx("div",{ref:e,className:["border-2 border-dashed rounded-lg p-4 text-center text-gray-400 text-sm",t?"border-blue-500 bg-blue-50":"border-gray-200"].join(" "),children:"拖节点到这里追加"})}const rn=[{type:"ask_user",icon:"💬",label:"问用户"},{type:"fai",icon:"🤖",label:"AI 调用"},{type:"let",icon:"📦",label:"命名变量"},{type:"return",icon:"⬅️",label:"返回"}];function on({type:e,icon:t,label:n}){const{attributes:o,listeners:a,setNodeRef:i,isDragging:s}=Pt({id:`palette:${e}`,data:{kind:"create",nodeType:e}});return r.jsxs("div",{ref:i,...o,...a,className:["flex items-center gap-2 p-2 rounded border border-gray-300 bg-white cursor-grab","hover:border-blue-400 hover:shadow-sm transition-all select-none",s?"opacity-50":""].join(" "),children:[r.jsx("span",{className:"text-xl",children:t}),r.jsx("span",{className:"text-sm",children:n})]})}function an(){return r.jsxs("aside",{className:"fixed left-4 top-1/4 w-40 flex flex-col gap-2 z-20",children:[r.jsx("div",{className:"text-xs uppercase text-gray-500 mb-1 px-1",children:"节点"}),rn.map(e=>r.jsx(on,{...e},e.type))]})}function sn({node:e,onChange:t}){function n(n,r){const o=e.fields.map((e,t)=>t===n?{...e,...r}:e);t({fields:o})}return r.jsxs("div",{className:"p-4 flex flex-col gap-4",children:[r.jsxs("label",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-gray-600",children:"变量名:"}),r.jsx("input",{type:"text",value:e.outputVar,onChange:e=>t({outputVar:e.target.value}),className:"px-2 py-0.5 rounded border border-gray-300 text-sm font-mono"})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-sm text-gray-600 mb-1",children:"字段:"}),e.fields.map((o,a)=>r.jsxs("div",{className:"border border-gray-200 rounded p-2 mb-2 flex flex-col gap-1 text-sm",children:[r.jsxs("label",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-12 text-gray-500",children:"key"}),r.jsx("input",{value:o.key,onChange:e=>n(a,{key:e.target.value}),className:"px-2 py-0.5 rounded border border-gray-300 font-mono flex-1"})]}),r.jsxs("label",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-12 text-gray-500",children:"label"}),r.jsx("input",{value:o.label,onChange:e=>n(a,{label:e.target.value}),className:"px-2 py-0.5 rounded border border-gray-300 flex-1"})]}),r.jsxs("label",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-12 text-gray-500",children:"type"}),r.jsxs("select",{value:o.type,onChange:e=>{const t=e.target.value;n(a,"enum"===t?{type:t}:{type:t,variants:void 0})},className:"px-2 py-0.5 rounded border border-gray-300",children:[r.jsx("option",{value:"text",children:"text"}),r.jsx("option",{value:"number",children:"number"}),r.jsx("option",{value:"bool",children:"bool"}),r.jsx("option",{value:"enum",children:"enum"})]})]}),"enum"===o.type&&r.jsxs("label",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-12 text-gray-500",children:"variants"}),r.jsx("input",{value:(o.variants??[]).join(","),onChange:e=>n(a,{variants:e.target.value.split(",").map(e=>e.trim()).filter(Boolean)}),placeholder:"a,b,c",className:"px-2 py-0.5 rounded border border-gray-300 font-mono flex-1"})]}),r.jsxs("label",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-12 text-gray-500",children:"required"}),r.jsx("input",{type:"checkbox",checked:!1!==o.required,onChange:e=>n(a,{required:e.target.checked})})]}),r.jsx("button",{type:"button",onClick:()=>{return n=a,void t({fields:e.fields.filter((e,t)=>t!==n)});var n},className:"text-red-600 text-xs self-end",children:"删除该字段"})]},a)),r.jsx("button",{type:"button",onClick:function(){const n=new Set(e.fields.map(e=>e.key));let r=e.fields.length+1;for(;n.has("field_"+r);)r++;t({fields:[...e.fields,{key:"field_"+r,label:"",type:"text",required:!0}]})},className:"text-blue-600 text-sm",children:"+ 添加字段"})]})]})}function ln({value:t,candidates:n,placeholder:o,onChange:a}){const[i,s]=e.useState(!1),[l,c]=e.useState(""),[d,u]=e.useState(!1),p=e.useRef(null),f=e.useRef(!1);function h(e){if(f.current=!0,e.startsWith("@")){const t=e.slice(1).split(".").filter(e=>e.length>0);if(t.length>0)return a({kind:"var",path:t}),void s(!1)}a({kind:"lit",raw:e}),s(!1)}e.useEffect(()=>{i&&("var"===t.kind?c("@"+t.path.join(".")):c(t.raw),setTimeout(()=>{var e;return null==(e=p.current)?void 0:e.focus()},0))},[i,t]);const g=n.filter(e=>e.toLowerCase().includes(l.slice(1).toLowerCase()));return i?r.jsxs("div",{className:"relative inline-block",children:[r.jsx("input",{ref:p,type:"text",value:l,placeholder:o,onChange:e=>{c(e.target.value),u(e.target.value.startsWith("@"))},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),h(l)),"Escape"===e.key&&(e.preventDefault(),f.current=!0,s(!1))},onBlur:()=>setTimeout(()=>{f.current?f.current=!1:h(l)},100),className:"px-2 py-0.5 rounded border border-blue-400 text-sm font-mono outline-none w-48"}),d&&g.length>0&&r.jsx("ul",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow text-sm z-10 max-h-48 overflow-auto",children:g.slice(0,10).map(e=>r.jsxs("li",{className:"px-2 py-1 hover:bg-blue-50 cursor-pointer font-mono",onMouseDown:()=>h("@"+e),children:["@",e]},e))})]}):"var"===t.kind?r.jsxs("button",{type:"button",onClick:()=>s(!0),className:"inline-flex items-center gap-1 px-2 py-0.5 rounded bg-blue-100 text-blue-800 border border-blue-300 text-sm font-mono",children:["@",t.path.join(".")]}):r.jsx("button",{type:"button",onClick:()=>s(!0),className:"px-2 py-0.5 rounded border border-gray-300 text-sm font-mono text-gray-700 hover:bg-gray-50",children:t.raw||r.jsx("span",{className:"italic text-gray-400",children:o??"(空)"})})}function cn({node:e,candidates:t,onChange:n}){function o(t,r){n({inputs:e.inputs.map((e,n)=>n===t?{...e,...r}:e)})}function a(t,r){n({outputs:e.outputs.map((e,n)=>n===t?{...e,...r}:e)})}const i=e.promptTemplate.map(e=>"text"===e.kind?e.raw:`@{${e.path.join(".")}}`).join("");return r.jsxs("div",{className:"p-4 flex flex-col gap-4 text-sm",children:[r.jsxs("label",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-600 w-20",children:"fai 名:"}),r.jsx("input",{value:e.faiName,onChange:e=>n({faiName:e.target.value}),className:"px-2 py-0.5 rounded border border-gray-300 font-mono flex-1"})]}),r.jsxs("label",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-600 w-20",children:"输出变量名:"}),r.jsx("input",{value:e.outputVar,onChange:e=>n({outputVar:e.target.value}),className:"px-2 py-0.5 rounded border border-gray-300 font-mono flex-1"})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-gray-600 mb-1",children:"输入:"}),e.inputs.map((a,i)=>r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("input",{value:a.argName,onChange:e=>o(i,{argName:e.target.value}),className:"px-2 py-0.5 rounded border border-gray-300 font-mono w-28"}),r.jsxs("select",{value:a.argType,onChange:e=>o(i,{argType:e.target.value}),className:"px-2 py-0.5 rounded border border-gray-300",children:[r.jsx("option",{value:"string",children:"string"}),r.jsx("option",{value:"number",children:"number"}),r.jsx("option",{value:"bool",children:"bool"}),r.jsx("option",{value:"prompt",children:"prompt"})]}),r.jsx("span",{children:"="}),r.jsx(ln,{value:a.source,candidates:t,onChange:e=>o(i,{source:e})}),r.jsx("button",{type:"button",onClick:()=>{return t=i,void n({inputs:e.inputs.filter((e,n)=>n!==t)});var t},className:"text-red-600 text-xs ml-auto",children:"×"})]},i)),r.jsx("button",{type:"button",onClick:function(){const t=new Set(e.inputs.map(e=>e.argName));let r=e.inputs.length+1;for(;t.has("arg"+r);)r++;n({inputs:[...e.inputs,{argName:"arg"+r,argType:"string",source:{kind:"lit",raw:'""'}}]})},className:"text-blue-600 text-xs",children:"+ 添加输入"})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-gray-600 mb-1",children:"输出 (schema):"}),e.outputs.map((t,o)=>r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("input",{value:t.name,onChange:e=>a(o,{name:e.target.value}),className:"px-2 py-0.5 rounded border border-gray-300 font-mono w-28"}),r.jsxs("select",{value:t.type,onChange:e=>a(o,{type:e.target.value}),className:"px-2 py-0.5 rounded border border-gray-300",children:[r.jsx("option",{value:"string",children:"string"}),r.jsx("option",{value:"int",children:"int"}),r.jsx("option",{value:"number",children:"number"}),r.jsx("option",{value:"bool",children:"bool"}),r.jsx("option",{value:"array",children:"array"})]}),"array"===t.type&&r.jsxs("select",{value:t.innerType??"string",onChange:e=>a(o,{innerType:e.target.value}),className:"px-2 py-0.5 rounded border border-gray-300",children:[r.jsx("option",{value:"string",children:"array<string>"}),r.jsx("option",{value:"int",children:"array<int>"}),r.jsx("option",{value:"number",children:"array<number>"}),r.jsx("option",{value:"bool",children:"array<bool>"})]}),r.jsx("button",{type:"button",onClick:()=>{return t=o,void n({outputs:e.outputs.filter((e,n)=>n!==t)});var t},className:"text-red-600 text-xs ml-auto",children:"×"})]},o)),r.jsx("button",{type:"button",onClick:function(){const t=new Set(e.outputs.map(e=>e.name));let r=e.outputs.length+1;for(;t.has("out"+r);)r++;n({outputs:[...e.outputs,{name:"out"+r,type:"string"}]})},className:"text-blue-600 text-xs",children:"+ 添加输出"})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"text-gray-600 mb-1",children:["Prompt(用 @","{var.path}"," 引用上文变量):"]}),r.jsx("textarea",{value:i,onChange:e=>function(e){const t=[];let r=0;for(;r<e.length;){const n=e.indexOf("@{",r);if(-1===n){t.push({kind:"text",raw:e.slice(r)});break}n>r&&t.push({kind:"text",raw:e.slice(r,n)});const o=e.indexOf("}",n+2);if(-1===o){t.push({kind:"text",raw:e.slice(n)});break}const a=e.slice(n+2,o).split(".").filter(e=>e.length>0);a.length>0?t.push({kind:"ref",path:a}):t.push({kind:"text",raw:e.slice(n,o+1)}),r=o+1}n({promptTemplate:t})}(e.target.value),rows:5,className:"w-full px-2 py-1 rounded border border-gray-300 font-mono text-sm"}),r.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:["可用变量: ",t.slice(0,8).map(e=>`@{${e}}`).join(" · "),t.length>8?` 等 ${t.length} 个`:""]})]})]})}function dn({node:e,candidates:t,onChange:n}){const o=e.value;return"triple"===o.kind?r.jsx("div",{className:"p-4 text-sm text-red-600",children:"M1 不支持 TripleSlot 值。请等 M2 三格拼装器实装。"}):r.jsxs("div",{className:"p-4 flex flex-col gap-3 text-sm",children:[r.jsxs("label",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-600 w-16",children:"变量名:"}),r.jsx("input",{value:e.varName,onChange:e=>n({varName:e.target.value}),className:"px-2 py-0.5 rounded border border-gray-300 font-mono flex-1"})]}),r.jsxs("label",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-600 w-16",children:"值:"}),r.jsx(ln,{value:o,candidates:t,placeholder:'@变量 或字面量(如 "hello" / 42 / true)',onChange:e=>n({value:e})})]}),r.jsx("div",{className:"text-xs text-gray-500",children:"提示:M1 暂不支持 a + b 这种表达式。需要时先用 fai 节点中转,或等 M2 三格拼装器。"})]})}function un({node:e,candidates:t,onChange:n}){const o=e.value;return"triple"===o.kind?r.jsx("div",{className:"p-4 text-sm text-red-600",children:"M1 不支持 TripleSlot 值。等 M2 三格拼装器。"}):r.jsx("div",{className:"p-4 flex flex-col gap-3 text-sm",children:r.jsxs("label",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-600 w-16",children:"返回值:"}),r.jsx(ln,{value:o,candidates:t,placeholder:'@变量 或字面量(如 { foo: 1 } / "hello" / null)',onChange:e=>n({value:e})})]})})}function pn({node:e,candidates:t,onChange:n,onClose:o}){return e?r.jsxs("aside",{className:"fixed right-0 top-0 bottom-0 w-96 bg-white border-l border-gray-300 shadow-xl overflow-y-auto z-30",children:[r.jsxs("header",{className:"flex items-center justify-between p-3 border-b border-gray-200 bg-gray-50",children:[r.jsx("span",{className:"font-medium text-sm",children:"编辑节点"}),r.jsx("button",{type:"button",onClick:o,className:"text-gray-500 hover:text-gray-800 text-lg leading-none",children:"×"})]}),"ask_user"===e.type&&r.jsx(sn,{node:e,onChange:n}),"fai"===e.type&&r.jsx(cn,{node:e,candidates:t,onChange:n}),"let"===e.type&&r.jsx(dn,{node:e,candidates:t,onChange:n}),"return"===e.type&&r.jsx(un,{node:e,candidates:t,onChange:n})]}):null}const fn=e.lazy(async()=>{const[e,t]=await Promise.all([o(()=>import("./editor.main-DL1nkpnc.js").then(e=>e.e),__vite__mapDeps([0,1,2,3])),o(()=>import("./index-CfixATeo.js"),__vite__mapDeps([4,1,2]))]),n=e.default??e;return t.loader.config({monaco:n}),{default:t.default}});function hn({open:t,source:n,errors:o,onClose:a}){return t?r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:a,children:r.jsxs("div",{className:"bg-white rounded-lg w-3/4 h-3/4 flex flex-col",onClick:e=>e.stopPropagation(),children:[r.jsxs("header",{className:"flex items-center justify-between p-3 border-b border-gray-200",children:[r.jsx("span",{className:"font-medium",children:"预览 .tr(只读)"}),r.jsx("button",{onClick:a,className:"text-gray-500 hover:text-gray-800 text-lg leading-none",children:"×"})]}),o&&o.length>0&&r.jsxs("div",{className:"bg-red-50 border-b border-red-200 p-2 text-sm text-red-700",children:[r.jsxs("div",{className:"font-medium mb-1",children:["codegen 报错(",o.length,"):"]}),o.slice(0,5).map((e,t)=>r.jsxs("div",{className:"font-mono text-xs",children:["节点 #",e.nodeIndex,": ",e.message]},t))]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(e.Suspense,{fallback:r.jsx("div",{className:"p-4 text-sm text-gray-500",children:"加载预览中..."}),children:r.jsx(fn,{height:"100%",value:n,language:"javascript",options:{readOnly:!0,minimap:{enabled:!1},fontSize:13}})})})]})}):null}function gn(e,t){return function(e,t){switch(t.type){case"add":{const n=Math.max(0,Math.min(t.index,e.body.length)),r=[...e.body];return r.splice(n,0,t.node),{...e,body:r}}case"remove":{const n=e.body.filter((e,n)=>n!==t.index);return{...e,body:n}}case"move":{const n=[...e.body],[r]=n.splice(t.from,1);return r?(n.splice(t.to,0,r),{...e,body:n}):e}case"duplicate":{const n=e.body[t.index];if(!n)return e;const r=JSON.parse(JSON.stringify(n));r.id=s();const o=[...e.body];return o.splice(t.index+1,0,r),{...e,body:o}}case"update":{const n=e.body.map((e,n)=>n===t.index?{...e,...t.patch}:e);return{...e,body:n}}}}(e,t)}function mn({initialGraph:t,trackName:n,onSave:o}){const[a,i]=e.useReducer(gn,t??function(e){return{version:1,trackName:e,body:[]}}(n)),[s,l]=e.useState(null),[d,u]=e.useState(!1),[p,f]=e.useState(null),[h,g]=e.useState(!1),m=null===s?-1:a.body.findIndex(e=>e.id===s),v=m>=0?a.body[m]:null,b=e.useMemo(()=>c(a,m>=0?m:a.body.length),[a,m]);const x=e.useMemo(()=>j(a),[a]),y=x.ok?x.source:"// codegen 错误:\n"+(x.errors??[]).map(e=>`// #${e.nodeIndex}: ${e.message}`).join("\n");return r.jsxs("div",{className:"min-h-screen bg-gray-50",children:[r.jsxs("header",{className:"fixed top-0 left-0 right-0 bg-white border-b border-gray-200 p-3 flex items-center gap-3 z-40",children:[r.jsx("span",{className:"text-lg font-medium",children:n}),r.jsx("span",{className:"text-xs text-gray-400",children:"节点图模式"}),r.jsxs("div",{className:"ml-auto flex gap-2",children:[r.jsx("button",{onClick:()=>u(!0),className:"px-3 py-1 text-sm rounded border border-gray-300 hover:bg-gray-50",children:"预览代码"}),r.jsx("button",{onClick:async function(){var e;f(null);const t=j(a);if(!t.ok||!t.source){const n=(null==(e=t.errors)?void 0:e.length)??0;return f(`codegen 报 ${n} 个错。点"预览代码"查看详情。`),void u(!0)}g(!0);try{await o(t.source)}catch(n){f(n instanceof Error?n.message:String(n))}finally{g(!1)}},disabled:h,className:"px-3 py-1 text-sm rounded bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50",children:h?"保存中...":"保存"})]}),p&&r.jsx("div",{className:"ml-3 text-xs text-red-600 max-w-md truncate",title:p,children:p})]}),r.jsxs("div",{className:"pt-14",children:[r.jsx(an,{}),r.jsx(en,{graph:a,dispatch:i,selectedId:s,onSelect:l}),r.jsx(pn,{node:v,candidates:b,onChange:function(e){m<0||i({type:"update",index:m,patch:e})},onClose:()=>l(null)})]}),r.jsx(hn,{open:d,source:y,errors:x.ok?void 0:x.errors,onClose:()=>u(!1)})]})}export{mn as TrackVisualEditor};
@@ -1,4 +1,4 @@
1
- import{c as o}from"./index-P75DiJki.js";
1
+ import{c as o}from"./index-CoQOKlkh.js";
2
2
  /**
3
3
  * @license lucide-react v0.309.0 - ISC
4
4
  *
@@ -1,4 +1,4 @@
1
- import{m as e}from"./editor.main-DC8nTgWW.js";import"./index-P75DiJki.js";
1
+ import{m as e}from"./editor.main-DL1nkpnc.js";import"./index-CoQOKlkh.js";
2
2
  /*!-----------------------------------------------------------------------------
3
3
  * Copyright (c) Microsoft Corporation. All rights reserved.
4
4
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)