@reformer/builder 3.0.0-beta.4 → 3.0.0-beta.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.
- package/dist/assets/{App-BzMuBv1U.js → App-BupMDG_t.js} +6 -6
- package/dist/assets/{BootError-CH4BoW__.js → BootError-CWnToysV.js} +1 -1
- package/dist/assets/{ChatPanel-9qHpjmLO.js → ChatPanel-B4wt7hBH.js} +3 -3
- package/dist/assets/{CodeEditor-CuHAtGtB.js → CodeEditor-Cca8j3Z3.js} +1 -1
- package/dist/assets/{MarkdownPreview-DwyxNTbn.js → MarkdownPreview-CmqjlfzE.js} +3 -3
- package/dist/assets/{RawJsonEditor-jYY7XCW2.js → RawJsonEditor-D5mwkIJa.js} +1 -1
- package/dist/assets/{boot-DTWnczkO.js → boot-BCJd6Ujw.js} +1 -1
- package/dist/assets/{byok-BM21dMSQ.js → byok-B9mwOrn0.js} +1 -1
- package/dist/assets/{editor.api-B4g2PJYj.js → editor.api-BWDeQ8t4.js} +1 -1
- package/dist/assets/{freemarker2-BlPZHoyx.js → freemarker2-DQaxDgne.js} +1 -1
- package/dist/assets/{handlebars-Dd8yor3z.js → handlebars-e1hbsCFi.js} +1 -1
- package/dist/assets/{html-C3wl1HPz.js → html-QXilGQ4Y.js} +1 -1
- package/dist/assets/index-BwhW-Atz.js +3 -0
- package/dist/assets/{index-OZOUDUGD.js → index-CF7RI8Bt.js} +1 -1
- package/dist/assets/{index-CU07HM8S.js → index-CLTXPf4k.js} +1 -1
- package/dist/assets/{index-CY45QPm-.js → index-DhcNqNgT.js} +2 -2
- package/dist/assets/{index-DCa3wFwm.js → index-U9gpmElw.js} +3 -3
- package/dist/assets/{index-BmJVVkA_.js → index-eRs9yupj.js} +1 -1
- package/dist/assets/{javascript-BF-EEvQI.js → javascript-C7cOj8ds.js} +1 -1
- package/dist/assets/{jsonMode-DGlgsS1d.js → jsonMode-DEqS3I0B.js} +1 -1
- package/dist/assets/{liquid-C0Gfg9TY.js → liquid-grdNDW6i.js} +1 -1
- package/dist/assets/{load-FrEYc91y.js → load-QsSQTL2T.js} +3 -3
- package/dist/assets/{mdx-bIG0iFaA.js → mdx-BGpbXlZS.js} +1 -1
- package/dist/assets/{monaco-languages-D5Bh48hh.js → monaco-languages-BZWxuU3F.js} +2 -2
- package/dist/assets/{monaco-setup-CAOrXrMd.js → monaco-setup-1PbjxubL.js} +3 -3
- package/dist/assets/{python-CciOb-4N.js → python-D5X7CY5Y.js} +1 -1
- package/dist/assets/{razor-cbEBt-Vr.js → razor-B2pbhZKy.js} +1 -1
- package/dist/assets/{reformer-ui-kit-11-BhXMU01R.js → reformer-ui-kit-11-bLtlFFvp.js} +1 -1
- package/dist/assets/{reformer-ui-kit-D8fAdwPH.js → reformer-ui-kit-tUqYBSLv.js} +1 -1
- package/dist/assets/{typescript-4hiO_obL.js → typescript-Ccn-IGn9.js} +1 -1
- package/dist/assets/{typescript-CNVC9ZHk.js → typescript-DL3gRsAd.js} +1 -1
- package/dist/assets/useFormField-BLbvmpme-Dwz_jyMW.js +1 -0
- package/dist/assets/{xml-RU_PX54U.js → xml-NgTjWpvZ.js} +1 -1
- package/dist/assets/{yaml-DsXE0ah6.js → yaml-CboCRslW.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/index-BC3M-FCZ.js +0 -3
- package/dist/assets/useFormField-BLbvmpme-BASGgtAT.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{r as se,j as S,W as pt,_ as Pl}from"./index-CY45QPm-.js";import{y as n8,G as u3,O as zj,T as s8,I as qj,x as Jj,Z as Kj,z as Vj,P as Wj,b as Rr,A as i8,g as tu,B as a8,U as Hj,D as Gj,E as Xj,F as JA,H as Yj,J as Qj,K as l3,L as c3,N as p3,_ as sn,M as Kc,Q as S2,V as F2,W as ho,X as mo,Y as Mp,$ as Nl,a0 as Zj,a1 as eO,a2 as tO,a3 as rO,a4 as nO,a5 as sO,a6 as iO,a7 as aO,a8 as oO,a9 as o8,n as Bs,i as uO,s as lO,r as cO,aa as pO,ab as d3,d as f3,ac as dO,ad as u8,ae as KA,af as fO,ag as hO,ah as mO,ai as l8,aj as yO,ak as gO,al as DO,am as xO,h as c8,t as p8,j as d8,k as f8,l as Av,an as bO,ao as vO,ap as h8,aq as EO,ar as V1,as as W1,at as H1,au as Zn,av as xc,aw as Dn,ax as VA,ay as WA,az as bc,aA as Mo,aB as CO,aC as TO,aD as AO}from"./reformer-ui-kit-D8fAdwPH.js";import{R as SO,L as FO,C as m8,y as y8,b as wO,l as h3,j as gp,g as g8}from"./useFormField-BLbvmpme-BASGgtAT.js";import{bm as m3,ap as D8,X as w2,C as x8,bP as HA,a as Rp,bd as kO,c as _O,bE as PO}from"./index-OZOUDUGD.js";import{p as NO,G as $O,T as IO}from"./index-BmJVVkA_.js";import{e as Up,g as Ca,f as BO,t as jO,h as OO,s as LO,i as b8,I as v8,N as MO,O as RO,S as GA,D as UO,j as zO,k as qO}from"./load-FrEYc91y.js";import{g as E8,a as JO}from"./boot-DTWnczkO.js";function KO(e,t){const r=getComputedStyle(e),n=parseFloat(r.fontSize);return t*n}function VO(e,t){const r=getComputedStyle(e.ownerDocument.documentElement),n=parseFloat(r.fontSize);return t*n}function WO(e){return e/100*window.innerHeight}function HO(e){return e/100*window.innerWidth}function GO(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Bf({groupSize:e,panelElement:t,styleProp:r}){let n;const[s,i]=GO(r);switch(i){case"%":{n=s/100*e;break}case"px":{n=s;break}case"rem":{n=VO(t,s);break}case"em":{n=KO(t,s);break}case"vh":{n=WO(s);break}case"vw":{n=HO(s);break}}return n}function gs(e){return parseFloat(e.toFixed(3))}function Dp({group:e}){const{orientation:t,panels:r}=e;return r.reduce((n,s)=>(n+=t==="horizontal"?s.element.offsetWidth:s.element.offsetHeight,n),0)}function Sv(e){const{panels:t}=e,r=Dp({group:e});return r===0?t.map(n=>({groupResizeBehavior:n.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:n.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:n.panelConstraints.disabled,minSize:0,maxSize:100,panelId:n.id})):t.map(n=>{const{element:s,panelConstraints:i}=n;let a=0;if(i.collapsedSize!==void 0){const p=Bf({groupSize:r,panelElement:s,styleProp:i.collapsedSize});a=gs(p/r*100)}let u;if(i.defaultSize!==void 0){const p=Bf({groupSize:r,panelElement:s,styleProp:i.defaultSize});u=gs(p/r*100)}let o=0;if(i.minSize!==void 0){const p=Bf({groupSize:r,panelElement:s,styleProp:i.minSize});o=gs(p/r*100)}let c=100;if(i.maxSize!==void 0){const p=Bf({groupSize:r,panelElement:s,styleProp:i.maxSize});c=gs(p/r*100)}return{groupResizeBehavior:i.groupResizeBehavior,collapsedSize:a,collapsible:i.collapsible===!0,defaultSize:u,disabled:i.disabled,minSize:o,maxSize:c,panelId:n.id}})}function Mr(e,t="Assertion error"){if(!e)throw Error(t)}function Fv(e,t){return Array.from(t).sort(e==="horizontal"?XO:YO)}function XO(e,t){const r=e.element.offsetLeft-t.element.offsetLeft;return r!==0?r:e.element.offsetWidth-t.element.offsetWidth}function YO(e,t){const r=e.element.offsetTop-t.element.offsetTop;return r!==0?r:e.element.offsetHeight-t.element.offsetHeight}function C8(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function T8(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function QO({orientation:e,rects:t,targetRect:r}){const n={x:r.x+r.width/2,y:r.y+r.height/2};let s,i=Number.MAX_VALUE;for(const a of t){const{x:u,y:o}=T8(n,a),c=e==="horizontal"?u:o;c<i&&(i=c,s=a)}return Mr(s,"No rect found"),s}let G1;function ZO(){return G1===void 0&&(typeof matchMedia=="function"?G1=!!matchMedia("(pointer:coarse)").matches:G1=!1),G1}function A8(e){const{element:t,orientation:r,panels:n,separators:s}=e,i=Fv(r,Array.from(t.children).filter(C8).map(y=>({element:y}))).map(({element:y})=>y),a=[];let u=!1,o=!1,c=-1,p=-1,d=0,h,m=[];{let y=-1;for(const v of i)v.hasAttribute("data-panel")&&(y++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=y),p=y))}if(d>1){let y=-1;for(const v of i)if(v.hasAttribute("data-panel")){y++;const b=n.find(T=>T.element===v);if(b){if(h){const T=h.element.getBoundingClientRect(),D=v.getBoundingClientRect();let x;if(o){const E=r==="horizontal"?new DOMRect(T.right,T.top,0,T.height):new DOMRect(T.left,T.bottom,T.width,0),A=r==="horizontal"?new DOMRect(D.left,D.top,0,D.height):new DOMRect(D.left,D.top,D.width,0);switch(m.length){case 0:{x=[E,A];break}case 1:{const F=m[0],k=QO({orientation:r,rects:[T,D],targetRect:F.element.getBoundingClientRect()});x=[F,k===T?A:E];break}default:{x=m;break}}}else m.length?x=m:x=[r==="horizontal"?new DOMRect(T.right,D.top,D.left-T.right,D.height):new DOMRect(D.left,T.bottom,D.width,D.top-T.bottom)];for(const E of x){let A="width"in E?E:E.element.getBoundingClientRect();const F=ZO()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(A.width<F){const _=F-A.width;A=new DOMRect(A.x-_/2,A.y,A.width+_,A.height)}if(A.height<F){const _=F-A.height;A=new DOMRect(A.x,A.y-_/2,A.width,A.height+_)}const k=y<=c||y>p;!u&&!k&&a.push({group:e,groupSize:Dp({group:e}),panels:[h,b],separator:"width"in E?void 0:E,rect:A}),u=!1}}o=!1,h=b,m=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(u=!0);const b=s.find(T=>T.element===v);b?m.push(b):(h=void 0,m=[])}else o=!0}return a}let S8=class{#t={};addListener(t,r){const n=this.#t[t];return n===void 0?this.#t[t]=[r]:n.includes(r)||n.push(r),()=>{this.removeListener(t,r)}}emit(t,r){const n=this.#t[t];if(n!==void 0)if(n.length===1)n[0].call(null,r);else{let s=!1,i=null;const a=Array.from(n);for(let u=0;u<a.length;u++){const o=a[u];try{o.call(null,r)}catch(c){i===null&&(s=!0,i=c)}}if(s)throw i}}removeAllListeners(){this.#t={}}removeListener(t,r){const n=this.#t[t];if(n!==void 0){const s=n.indexOf(r);s>=0&&n.splice(s,1)}}},np={cursorFlags:0,state:"inactive"};const y3=new S8;function Cl(){return np}function eL(e){return y3.addListener("change",e)}function tL(e){const t=np,r={...np};r.cursorFlags=e,np=r,y3.emit("change",{prev:t,next:r})}function sp(e){const t=np;np=e,y3.emit("change",{prev:t,next:e})}const rL=e=>e,ab=()=>{},F8=1,w8=2,k8=4,_8=8,XA=3,YA=12;let X1;function QA(){return X1===void 0&&(X1=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(X1=!0)),X1}function nL({cursorFlags:e,groups:t,state:r}){let n=0,s=0;switch(r){case"active":case"hover":t.forEach(i=>{if(!i.mutableState.disableCursor)switch(i.orientation){case"horizontal":{n++;break}case"vertical":{s++;break}}})}if(!(n===0&&s===0)){switch(r){case"active":{if(e&&QA()){const i=(e&F8)!==0,a=(e&w8)!==0,u=(e&k8)!==0,o=(e&_8)!==0;if(i)return u?"se-resize":o?"ne-resize":"e-resize";if(a)return u?"sw-resize":o?"nw-resize":"w-resize";if(u)return"s-resize";if(o)return"n-resize"}break}}return QA()?n>0&&s>0?"move":n>0?"ew-resize":"ns-resize":n>0&&s>0?"grab":n>0?"col-resize":"row-resize"}}const ZA=new WeakMap;function g3(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:r}=ZA.get(e)??{};r===void 0&&(r=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(r):e.adoptedStyleSheets=[...e.adoptedStyleSheets,r]));const n=Cl();switch(n.state){case"active":case"hover":{const s=nL({cursorFlags:n.cursorFlags,groups:n.hitRegions.map(a=>a.group),state:n.state}),i=`*, *:hover {cursor: ${s} !important; }`;if(t===i)return;t=i,s?r.cssRules.length===0?r.insertRule(i):r.replaceSync(i):r.cssRules.length===1&&r.deleteRule(0);break}case"inactive":{t=void 0,r.cssRules.length===1&&r.deleteRule(0);break}}ZA.set(e,{prevStyle:t,styleSheet:r})}let da=new Map;const P8=new S8;function sL(e){da=new Map(da),da.delete(e)}function eS(e,t){for(const[r]of da)if(r.id===e)return r}function ru(e,t){for(const[r,n]of da)if(r.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function $l(){return da}function D3(e,t){return P8.addListener("groupChange",r=>{r.group.id===e&&t(r)})}function ao(e,t,r){const n=da.get(e);da=new Map(da),da.set(e,t),P8.emit("groupChange",{group:e,isUserInteraction:r?.isUserInteraction===!0,prev:n,next:t})}function N8(e){const t=Cl();let r=!1;switch(t.state){case"active":sp({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(g3(e),r=!0,t.hitRegions.forEach(n=>{const s=ru(n.group.id,!0);ao(n.group,s,{isUserInteraction:!0})}))}return r}function tS(e){e.defaultPrevented||N8(e.currentTarget)}function iL(e,t,r){let n,s={x:1/0,y:1/0};for(const i of t){const a=T8(r,i.rect);switch(e){case"horizontal":{a.x<=s.x&&(n=i,s=a);break}case"vertical":{a.y<=s.y&&(n=i,s=a);break}}}return n?{distance:s,hitRegion:n}:void 0}function aL(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function oL(e,t){if(e===t)throw new Error("Cannot compare node with itself");const r={a:sS(e),b:sS(t)};let n;for(;r.a.at(-1)===r.b.at(-1);)n=r.a.pop(),r.b.pop();Mr(n,"Stacking order can only be calculated for elements with a common ancestor");const s={a:nS(rS(r.a)),b:nS(rS(r.b))};if(s.a===s.b){const i=n.childNodes,a={a:r.a.at(-1),b:r.b.at(-1)};let u=i.length;for(;u--;){const o=i[u];if(o===a.a)return 1;if(o===a.b)return-1}}return Math.sign(s.a-s.b)}const uL=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function lL(e){const t=getComputedStyle($8(e)??e).display;return t==="flex"||t==="inline-flex"}function cL(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||lL(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||uL.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function rS(e){let t=e.length;for(;t--;){const r=e[t];if(Mr(r,"Missing node"),cL(r))return r}return null}function nS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function sS(e){const t=[];for(;e;)t.push(e),e=$8(e);return t}function $8(e){const{parentNode:t}=e;return aL(t)?t.host:t}function pL(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function dL({groupElement:e,hitRegion:t,pointerEventTarget:r}){if(!C8(r)||r.contains(e)||e.contains(r))return!0;if(oL(r,e)>0){let n=r;for(;n;){if(n.contains(e))return!0;if(pL(n.getBoundingClientRect(),t))return!1;n=n.parentElement}}return!0}function x3(e,t){const r=[];return t.forEach((n,s)=>{if(s.disabled)return;const i=A8(s),a=iL(s.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&dL({groupElement:s.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&r.push(a.hitRegion)}),r}function fL(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!=t[r])return!1;return!0}function ts(e,t,r=0){return Math.abs(gs(e)-gs(t))<=r}function aa(e,t){return ts(e,t)?0:e>t?1:-1}function Vc({overrideDisabledPanels:e,panelConstraints:t,prevSize:r,size:n}){const{collapsedSize:s=0,collapsible:i,disabled:a,maxSize:u=100,minSize:o=0}=t;if(a&&!e)return r;if(aa(n,o)<0)if(i){const c=(s+o)/2;aa(n,c)<0?n=s:n=o}else n=o;return n=Math.min(u,n),n=gs(n),n}function Eh({delta:e,initialLayout:t,panelConstraints:r,pivotIndices:n,prevLayout:s,trigger:i}){if(ts(e,0))return t;const a=i==="imperative-api",u=Object.values(t),o=Object.values(s),c=[...u],[p,d]=n;Mr(p!=null,"Invalid first pivot index"),Mr(d!=null,"Invalid second pivot index");let h=0;switch(i){case"keyboard":{{const v=e<0?d:p,b=r[v];Mr(b,`Panel constraints not found for index ${v}`);const{collapsedSize:T=0,collapsible:D,minSize:x=0}=b;if(D){const E=u[v];if(Mr(E!=null,`Previous layout not found for panel index ${v}`),ts(E,T)){const A=x-E;aa(A,Math.abs(e))>0&&(e=e<0?0-A:A)}}}{const v=e<0?p:d,b=r[v];Mr(b,`No panel constraints found for index ${v}`);const{collapsedSize:T=0,collapsible:D,minSize:x=0}=b;if(D){const E=u[v];if(Mr(E!=null,`Previous layout not found for panel index ${v}`),ts(E,x)){const A=E-T;aa(A,Math.abs(e))>0&&(e=e<0?0-A:A)}}}break}default:{const v=e<0?d:p,b=r[v];Mr(b,`Panel constraints not found for index ${v}`);const T=u[v],{collapsible:D,collapsedSize:x,minSize:E}=b;if(D&&aa(T,E)<0)if(e>0){const A=E-x,F=A/2,k=T+e;aa(k,E)<0&&(e=aa(e,F)<=0?0:A)}else{const A=E-x,F=100-A/2,k=T-e;aa(k,E)<0&&(e=aa(100+e,F)>0?0:-A)}break}}{const v=e<0?1:-1;let b=e<0?d:p,T=0;for(;;){const x=u[b];Mr(x!=null,`Previous layout not found for panel index ${b}`);const E=Vc({overrideDisabledPanels:a,panelConstraints:r[b],prevSize:x,size:100})-x;if(T+=E,b+=v,b<0||b>=r.length)break}const D=Math.min(Math.abs(e),Math.abs(T));e=e<0?0-D:D}{let v=e<0?p:d;for(;v>=0&&v<r.length;){const b=Math.abs(e)-Math.abs(h),T=u[v];Mr(T!=null,`Previous layout not found for panel index ${v}`);const D=T-b,x=Vc({overrideDisabledPanels:a,panelConstraints:r[v],prevSize:T,size:D});if(!ts(T,x)&&(h+=T-x,c[v]=x,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(fL(o,c))return s;{const v=e<0?d:p,b=u[v];Mr(b!=null,`Previous layout not found for panel index ${v}`);const T=b+h,D=Vc({overrideDisabledPanels:a,panelConstraints:r[v],prevSize:b,size:T});if(c[v]=D,!ts(D,T)){let x=T-D,E=e<0?d:p;for(;E>=0&&E<r.length;){const A=c[E];Mr(A!=null,`Previous layout not found for panel index ${E}`);const F=A+x,k=Vc({overrideDisabledPanels:a,panelConstraints:r[E],prevSize:A,size:F});if(ts(A,k)||(x-=k-A,c[E]=k),ts(x,0))break;e>0?E--:E++}}}const m=Object.values(c).reduce((v,b)=>b+v,0);if(!ts(m,100,.1))return s;const y=Object.keys(s);return c.reduce((v,b,T)=>(v[y[T]]=b,v),{})}function Tl(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(t[r]===void 0||aa(e[r],t[r])!==0)return!1;return!0}function Al({layout:e,panelConstraints:t}){const r=Object.values(e),n=[...r],s=n.reduce((u,o)=>u+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(u=>`${u}%`).join(", ")}`);if(!ts(s,100)&&n.length>0)for(let u=0;u<t.length;u++){const o=n[u];Mr(o!=null,`No layout data found for index ${u}`);const c=100/s*o;n[u]=c}let i=0;for(let u=0;u<t.length;u++){const o=r[u];Mr(o!=null,`No layout data found for index ${u}`);const c=n[u];Mr(c!=null,`No layout data found for index ${u}`);const p=Vc({overrideDisabledPanels:!0,panelConstraints:t[u],prevSize:o,size:c});c!=p&&(i+=c-p,n[u]=p)}if(!ts(i,0))for(let u=0;u<t.length;u++){const o=n[u];Mr(o!=null,`No layout data found for index ${u}`);const c=o+i,p=Vc({overrideDisabledPanels:!0,panelConstraints:t[u],prevSize:o,size:c});if(o!==p&&(i-=p-o,n[u]=p,ts(i,0)))break}const a=Object.keys(e);return n.reduce((u,o,c)=>(u[a[c]]=o,u),{})}function I8({groupId:e,panelId:t}){const r=()=>{const o=$l();for(const[c,{defaultLayoutDeferred:p,derivedPanelConstraints:d,layout:h,groupSize:m,separatorToPanels:y}]of o)if(c.id===e)return{defaultLayoutDeferred:p,derivedPanelConstraints:d,group:c,groupSize:m,layout:h,separatorToPanels:y};throw Error(`Group ${e} not found`)},n=()=>{const o=r().derivedPanelConstraints.find(c=>c.panelId===t);if(o!==void 0)return o;throw Error(`Panel constraints not found for Panel ${t}`)},s=()=>{const o=r().group.panels.find(c=>c.id===t);if(o!==void 0)return o;throw Error(`Layout not found for Panel ${t}`)},i=()=>{const o=r().layout[t];if(o!==void 0)return o;throw Error(`Layout not found for Panel ${t}`)},a=({nextSize:o,panels:c,prevLayout:p,derivedPanelConstraints:d})=>{const h=i(),m=c.findIndex(b=>b.id===t),y=m===0,v=m===c.length-1;if(v&&o<h&&(y||c.slice(0,m).every((b,T)=>{const D=d[T];return D?.collapsible&&ts(D.collapsedSize,p[D.panelId])}))){const b=c.slice(0,m).reduce((T,D)=>T+p[D.id],0);return{...p,[t]:gs(100-b)}}return Eh({delta:v?h-o:o-h,initialLayout:p,panelConstraints:d,pivotIndices:v?[m-1,m]:[m,m+1],prevLayout:p,trigger:"imperative-api"})},u=o=>{const c=i();if(o===c)return;const{defaultLayoutDeferred:p,derivedPanelConstraints:d,group:h,groupSize:m,layout:y,separatorToPanels:v}=r(),b=a({nextSize:o,panels:h.panels,prevLayout:y,derivedPanelConstraints:d}),T=Al({layout:b,panelConstraints:d});Tl(y,T)||ao(h,{defaultLayoutDeferred:p,derivedPanelConstraints:d,groupSize:m,layout:T,separatorToPanels:v})};return{collapse:()=>{const{collapsible:o,collapsedSize:c}=n(),{mutableValues:p}=s(),d=i();o&&d!==c&&(p.expandToSize=d,u(c))},expand:()=>{const{collapsible:o,collapsedSize:c,minSize:p}=n(),{mutableValues:d}=s(),h=i();if(o&&h===c){let m=d.expandToSize??p;m===0&&(m=1),u(m)}},getSize:()=>{const{group:o}=r(),c=i(),{element:p}=s(),d=o.orientation==="horizontal"?p.offsetWidth:p.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:o,collapsedSize:c}=n(),p=i();return o&&ts(c,p)},resize:o=>{const{group:c}=r(),{element:p}=s(),d=Dp({group:c}),h=Bf({groupSize:d,panelElement:p,styleProp:o}),m=gs(h/d*100);u(m)}}}function iS(e){if(e.defaultPrevented)return;const t=$l();x3(e,t).forEach(r=>{if(r.separator&&!r.separator.disableDoubleClick){const n=r.panels.find(s=>s.panelConstraints.defaultSize!==void 0);if(n){const s=n.panelConstraints.defaultSize,i=I8({groupId:r.group.id,panelId:n.id});i&&s!==void 0&&(i.resize(s),e.preventDefault())}}})}function lg(e){const t=$l();for(const[r]of t)if(r.separators.some(n=>n.element===e))return r;throw Error("Could not find parent Group for separator element")}function B8({groupId:e}){const t=()=>{const r=$l();for(const[n,s]of r)if(n.id===e)return{group:n,...s};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:r,layout:n}=t();return r?{}:n},setLayout(r){const{defaultLayoutDeferred:n,derivedPanelConstraints:s,group:i,groupSize:a,layout:u,separatorToPanels:o}=t(),c=Al({layout:r,panelConstraints:s});return n?u:(Tl(u,c)||ao(i,{defaultLayoutDeferred:n,derivedPanelConstraints:s,groupSize:a,layout:c,separatorToPanels:o}),c)}}}function Wu(e,t){const r=lg(e),n=ru(r.id,!0),s=r.separators.find(p=>p.element===e);Mr(s,"Matching separator not found");const i=n.separatorToPanels.get(s);Mr(i,"Matching panels not found");const a=i.map(p=>r.panels.indexOf(p)),u=B8({groupId:r.id}).getLayout(),o=Eh({delta:t,initialLayout:u,panelConstraints:n.derivedPanelConstraints,pivotIndices:a,prevLayout:u,trigger:"keyboard"}),c=Al({layout:o,panelConstraints:n.derivedPanelConstraints});Tl(u,c)||ao(r,{defaultLayoutDeferred:n.defaultLayoutDeferred,derivedPanelConstraints:n.derivedPanelConstraints,groupSize:n.groupSize,layout:c,separatorToPanels:n.separatorToPanels},{isUserInteraction:!0})}function aS(e){if(e.defaultPrevented)return;const t=e.currentTarget,r=lg(t);if(!r.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),r.orientation==="vertical"&&Wu(t,5);break}case"ArrowLeft":{e.preventDefault(),r.orientation==="horizontal"&&Wu(t,-5);break}case"ArrowRight":{e.preventDefault(),r.orientation==="horizontal"&&Wu(t,5);break}case"ArrowUp":{e.preventDefault(),r.orientation==="vertical"&&Wu(t,-5);break}case"End":{e.preventDefault(),Wu(t,100);break}case"Enter":{e.preventDefault();const n=lg(t),s=ru(n.id,!0),{derivedPanelConstraints:i,layout:a,separatorToPanels:u}=s,o=n.separators.find(h=>h.element===t);Mr(o,"Matching separator not found");const c=u.get(o);Mr(c,"Matching panels not found");const p=c[0],d=i.find(h=>h.panelId===p.id);if(Mr(d,"Panel metadata not found"),d.collapsible){const h=a[p.id],m=d.collapsedSize===h?n.mutableState.expandedPanelSizes[p.id]??d.minSize:d.collapsedSize;Wu(t,m-h)}break}case"F6":{e.preventDefault();const n=lg(t).separators.map(a=>a.element),s=Array.from(n).findIndex(a=>a===e.currentTarget);Mr(s!==null,"Index not found");const i=e.shiftKey?s>0?s-1:n.length-1:s+1<n.length?s+1:0;n[i].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Wu(t,-100);break}}}function oS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=$l(),r=x3(e,t),n=new Map;let s=!1;r.forEach(i=>{i.separator&&(s||(s=!0,i.separator.element.focus({focusVisible:!1,preventScroll:!0})));const a=t.get(i.group);a&&n.set(i.group,a.layout)}),sp({cursorFlags:0,hitRegions:r,initialLayoutMap:n,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),r.length&&e.preventDefault()}function j8({document:e,event:t,hitRegions:r,initialLayoutMap:n,mountedGroups:s,pointerDownAtPoint:i,prevCursorFlags:a}){let u=0;r.forEach(c=>{const{group:p,groupSize:d}=c,{orientation:h,panels:m}=p,{disableCursor:y}=p.mutableState;let v=0;i?h==="horizontal"?v=(t.clientX-i.x)/d*100:v=(t.clientY-i.y)/d*100:h==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const b=n.get(p),T=s.get(p);if(!b||!T)return;const{defaultLayoutDeferred:D,derivedPanelConstraints:x,groupSize:E,layout:A,separatorToPanels:F}=T;if(x&&A&&F){const k=Eh({delta:v,initialLayout:b,panelConstraints:x,pivotIndices:c.panels.map(_=>m.indexOf(_)),prevLayout:A,trigger:"mouse-or-touch"});if(Tl(k,A)){if(v!==0&&!y)switch(h){case"horizontal":{u|=v<0?F8:w8;break}case"vertical":{u|=v<0?k8:_8;break}}}else ao(c.group,{defaultLayoutDeferred:D,derivedPanelConstraints:x,groupSize:E,layout:k,separatorToPanels:F})}});let o=0;t.movementX===0?o|=a&XA:o|=u&XA,t.movementY===0?o|=a&YA:o|=u&YA,tL(o),g3(e)}function uS(e){const t=$l(),r=Cl();switch(r.state){case"active":j8({document:e.currentTarget,event:e,hitRegions:r.hitRegions,initialLayoutMap:r.initialLayoutMap,mountedGroups:t,prevCursorFlags:r.cursorFlags})}}function lS(e){if(e.defaultPrevented)return;const t=Cl(),r=$l();switch(t.state){case"active":{if(e.buttons===0){sp({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(n=>{const s=ru(n.group.id,!0);ao(n.group,s,{isUserInteraction:!0})});return}for(const n of t.hitRegions)if(n.separator){const{element:s}=n.separator;s.hasPointerCapture?.(e.pointerId)||s.setPointerCapture?.(e.pointerId)}j8({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:r,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const n=x3(e,r);n.length===0?t.state!=="inactive"&&sp({cursorFlags:0,state:"inactive"}):sp({cursorFlags:0,hitRegions:n,state:"hover"}),g3(e.currentTarget);break}}}function cS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Cl().state){case"hover":sp({cursorFlags:0,state:"inactive"})}}function pS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||N8(e.currentTarget)&&e.preventDefault()}function dS(e){let t=0,r=0;const n={};for(const i of e)if(i.defaultSize!==void 0){t++;const a=gs(i.defaultSize);r+=a,n[i.panelId]=a}else n[i.panelId]=void 0;const s=e.length-t;if(s!==0){const i=gs((100-r)/s);for(const a of e)a.defaultSize===void 0&&(n[a.panelId]=i)}return n}function hL(e,t,r){if(!r[0])return;const n=e.panels.find(o=>o.element===t);if(!n||!n.onResize)return;const s=Dp({group:e}),i=e.orientation==="horizontal"?n.element.offsetWidth:n.element.offsetHeight,a=n.mutableValues.prevSize,u={asPercentage:gs(i/s*100),inPixels:i};n.mutableValues.prevSize=u,n.onResize(u,n.id,a)}function mL(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function yL({group:e,nextGroupSize:t,prevGroupSize:r,prevLayout:n}){if(r<=0||t<=0||r===t)return n;let s=0,i=0,a=!1;const u=new Map,o=[];for(const d of e.panels){const h=n[d.id]??0;switch(d.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{a=!0;const m=h/100*r,y=gs(m/t*100);u.set(d.id,y),s+=y;break}case"preserve-relative-size":default:{o.push(d.id),i+=h;break}}}if(!a||o.length===0)return n;const c=100-s,p={...n};if(u.forEach((d,h)=>{p[h]=d}),i>0)for(const d of o){const h=n[d]??0;p[d]=gs(h/i*c)}else{const d=gs(c/o.length);for(const h of o)p[h]=d}return p}function gL(e,t){const r=e.map(s=>s.id),n=Object.keys(t);if(r.length!==n.length)return!1;for(const s of r)if(!n.includes(s))return!1;return!0}const vc=new Map;function DL(e){let t=!0;Mr(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const r=e.element.ownerDocument.defaultView.ResizeObserver,n=new Set,s=new Set,i=new r(y=>{for(const v of y){const{borderBoxSize:b,target:T}=v;if(T===e.element){if(t){const D=Dp({group:e});if(D===0)return;const x=ru(e.id);if(!x)return;const E=Sv(e),A=x.defaultLayoutDeferred?dS(E):x.layout,F=yL({group:e,nextGroupSize:D,prevGroupSize:x.groupSize,prevLayout:A}),k=Al({layout:F,panelConstraints:E});if(!x.defaultLayoutDeferred&&Tl(x.layout,k)&&mL(x.derivedPanelConstraints,E)&&x.groupSize===D)return;ao(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:E,groupSize:D,layout:k,separatorToPanels:x.separatorToPanels})}}else hL(e,T,b)}});i.observe(e.element),e.panels.forEach(y=>{Mr(!n.has(y.id),`Panel ids must be unique; id "${y.id}" was used more than once`),n.add(y.id),y.onResize&&i.observe(y.element)});const a=Dp({group:e}),u=Sv(e),o=e.panels.map(({id:y})=>y).join(",");let c=e.mutableState.defaultLayout;c&&(gL(e.panels,c)||(c=void 0));const p=e.mutableState.layouts[o]??c??dS(u),d=Al({layout:p,panelConstraints:u}),h=e.element.ownerDocument;vc.set(h,(vc.get(h)??0)+1);const m=new Map;return A8(e).forEach(y=>{y.separator&&m.set(y.separator,y.panels)}),ao(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:u,groupSize:a,layout:d,separatorToPanels:m}),e.separators.forEach(y=>{Mr(!s.has(y.id),`Separator ids must be unique; id "${y.id}" was used more than once`),s.add(y.id),y.element.addEventListener("keydown",aS)}),vc.get(h)===1&&(h.addEventListener("contextmenu",tS,!0),h.addEventListener("dblclick",iS,!0),h.addEventListener("pointerdown",oS,!0),h.addEventListener("pointerleave",uS),h.addEventListener("pointermove",lS),h.addEventListener("pointerout",cS),h.addEventListener("pointerup",pS,!0)),function(){t=!1,vc.set(h,Math.max(0,(vc.get(h)??0)-1)),sL(e),e.separators.forEach(y=>{y.element.removeEventListener("keydown",aS)}),vc.get(h)||(h.removeEventListener("contextmenu",tS,!0),h.removeEventListener("dblclick",iS,!0),h.removeEventListener("pointerdown",oS,!0),h.removeEventListener("pointerleave",uS),h.removeEventListener("pointermove",lS),h.removeEventListener("pointerout",cS),h.removeEventListener("pointerup",pS,!0)),i.disconnect()}}function xL(){const[e,t]=se.useState({}),r=se.useCallback(()=>t({}),[]);return[e,r]}function b3(e){const t=se.useId();return`${e??t}`}const Il=typeof window<"u"?se.useLayoutEffect:se.useEffect;function Qf(e){const t=se.useRef(e);return Il(()=>{t.current=e},[e]),se.useCallback((...r)=>t.current?.(...r),[t])}function v3(...e){return Qf(t=>{e.forEach(r=>{if(r)switch(typeof r){case"function":{r(t);break}case"object":{r.current=t;break}}})})}function E3(e){const t=se.useRef({...e});return Il(()=>{for(const r in e)t.current[r]=e[r]},[e]),t.current}const O8=se.createContext(null);function bL(e,t){const r=se.useRef({getLayout:()=>({}),setLayout:rL});se.useImperativeHandle(t,()=>r.current,[]),Il(()=>{Object.assign(r.current,B8({groupId:e}))})}function L8({children:e,className:t,defaultLayout:r,disableCursor:n,disabled:s,elementRef:i,groupRef:a,id:u,onLayoutChange:o,onLayoutChanged:c,orientation:p="horizontal",resizeTargetMinimumSize:d={coarse:20,fine:10},style:h,...m}){const y=se.useRef({onLayoutChange:{},onLayoutChanged:{}}),v=Qf(j=>{Tl(y.current.onLayoutChange,j)||(y.current.onLayoutChange=j,o?.(j))}),b=Qf((j,V)=>{Tl(y.current.onLayoutChanged,j)||(y.current.onLayoutChanged=j,c?.(j,{isUserInteraction:V}))}),T=b3(u),D=se.useRef(null),[x,E]=xL(),A=se.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),F=v3(D,i);bL(T,a);const k=Qf((j,V)=>{const z=Cl(),oe=eS(j),L=ru(j);if(L){let ne=!1;switch(z.state){case"active":{ne=z.hitRegions.some(Ee=>Ee.group===oe);break}}return{flexGrow:L.layout[V]??1,pointerEvents:ne?"none":void 0}}if(r?.[V])return{flexGrow:r?.[V]}}),_=E3({defaultLayout:r,disableCursor:n}),O=se.useMemo(()=>({get disableCursor(){return!!_.disableCursor},getPanelStyles:k,id:T,orientation:p,registerPanel:j=>{const V=A.current;return V.panels=Fv(p,[...V.panels,j]),E(),()=>{V.panels=V.panels.filter(z=>z!==j),E()}},registerSeparator:j=>{const V=A.current;return V.separators=Fv(p,[...V.separators,j]),E(),()=>{V.separators=V.separators.filter(z=>z!==j),E()}},updatePanelProps:(j,{disabled:V})=>{const z=A.current.panels.find(ne=>ne.id===j);z&&(z.panelConstraints.disabled=V);const oe=eS(T),L=ru(T);oe&&L&&ao(oe,{...L,derivedPanelConstraints:Sv(oe)})},updateSeparatorProps:(j,{disabled:V,disableDoubleClick:z})=>{const oe=A.current.separators.find(L=>L.id===j);oe&&(oe.disabled=V,oe.disableDoubleClick=z)}}),[k,T,E,p,_]),q=se.useRef(null);return Il(()=>{const j=D.current;if(j===null)return;const V=A.current;let z;if(_.defaultLayout!==void 0&&Object.keys(_.defaultLayout).length===V.panels.length){z={};for(const K of V.panels){const Q=_.defaultLayout[K.id];Q!==void 0&&(z[K.id]=Q)}}const oe={disabled:!!s,element:j,id:T,mutableState:{defaultLayout:z,disableCursor:!!_.disableCursor,expandedPanelSizes:A.current.lastExpandedPanelSizes,layouts:A.current.layouts},orientation:p,panels:V.panels,resizeTargetMinimumSize:V.resizeTargetMinimumSize,separators:V.separators};q.current=oe;const L=DL(oe),{defaultLayoutDeferred:ne,derivedPanelConstraints:Ee,layout:X}=ru(oe.id,!0);!ne&&Ee.length>0&&(v(X),b(X,!1));const je=D3(T,K=>{const{defaultLayoutDeferred:Q,derivedPanelConstraints:ie,layout:M}=K.next;if(Q||ie.length===0)return;const B=oe.panels.map(({id:J})=>J).join(",");oe.mutableState.layouts[B]=M,ie.forEach(J=>{if(J.collapsible){const{layout:de}=K.prev??{};if(de){const Ce=ts(J.collapsedSize,M[J.panelId]),Me=ts(J.collapsedSize,de[J.panelId]);Ce&&!Me&&(oe.mutableState.expandedPanelSizes[J.panelId]=de[J.panelId])}}});const U=Cl().state!=="active";v(M),U&&b(M,K.isUserInteraction)});return()=>{q.current=null,L(),je()}},[s,T,b,v,p,x,_]),se.useEffect(()=>{const j=q.current;j&&(j.mutableState.defaultLayout=r,j.mutableState.disableCursor=!!n)}),S.jsx(O8.Provider,{value:O,children:S.jsx("div",{...m,className:t,"data-group":!0,"data-testid":T,id:T,ref:F,style:{height:"100%",width:"100%",overflow:"hidden",...h,display:"flex",flexDirection:p==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:p==="horizontal"?"pan-y":"pan-x"},children:e})})}L8.displayName="Group";function cg(e,t){return`react-resizable-panels:${[e,...t].join(":")}`}function vL({id:e,panelIds:t,storage:r}){const n=cg(e,[]),s=r.getItem(n);if(s)try{const i=JSON.parse(s);if(t){const a=t.join(","),u=i[a];if(u&&Array.isArray(u.layout)&&t.length===u.layout.length){const o={};for(let c=0;c<t.length;c++)o[t[c]]=u.layout[c];return o}}else{const a=Object.keys(i);if(a.length===1){const u=i[a[0]];if(u&&Array.isArray(u.layout)){const o=a[0].split(",");if(o.length===u.layout.length){const c={};for(let p=0;p<o.length;p++)c[o[p]]=u.layout[p];return c}}}}}catch{}}function C3({debounceSaveMs:e=100,onlySaveAfterUserInteractions:t,panelIds:r,storage:n=localStorage,...s}){const i=r!==void 0,a="id"in s?s.id:s.groupId,u=cg(a,r??[]),o=se.useSyncExternalStore(EL,()=>n.getItem(u),()=>n.getItem(u)),c=se.useMemo(()=>{if(o){const b=JSON.parse(o),T=Object.values(b);if(Array.from(T).every(D=>typeof D=="number"))return b}},[o]),p=se.useMemo(()=>{if(!c)return vL({id:a,panelIds:r,storage:n})},[c,a,r,n]),d=c??p,h=se.useRef(null),m=se.useCallback(()=>{const b=h.current;b&&(h.current=null,clearTimeout(b))},[]);se.useLayoutEffect(()=>()=>{m()},[m]);const y=se.useCallback((b,T)=>{if(t&&!T.isUserInteraction)return;m();let D;i?D=cg(a,Object.keys(b)):D=cg(a,[]);try{n.setItem(D,JSON.stringify(b))}catch(x){console.error(x)}},[m,i,a,t,n]),v=se.useCallback(b=>{m(),e===0?y(b,{isUserInteraction:!1}):h.current=setTimeout(()=>{y(b,{isUserInteraction:!1})},e)},[m,e,y]);return{defaultLayout:d,onLayoutChange:v,onLayoutChanged:y}}function EL(){return function(){}}function T3(){const e=se.useContext(O8);return Mr(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function CL(e,t){const{id:r}=T3(),n=se.useRef({collapse:ab,expand:ab,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:ab});se.useImperativeHandle(t,()=>n.current,[]),Il(()=>{Object.assign(n.current,I8({groupId:r,panelId:e}))})}function M8({children:e,className:t,collapsedSize:r="0%",collapsible:n=!1,defaultSize:s,disabled:i,elementRef:a,groupResizeBehavior:u="preserve-relative-size",id:o,maxSize:c="100%",minSize:p="0%",onResize:d,panelRef:h,style:m,...y}){const v=!!o,b=b3(o),T=E3({disabled:i}),D=se.useRef(null),x=v3(D,a),{getPanelStyles:E,id:A,orientation:F,registerPanel:k,updatePanelProps:_}=T3(),O=d!==null,q=Qf((oe,L,ne)=>{d?.(oe,o,ne)});Il(()=>{const oe=D.current;if(oe!==null){const L={element:oe,id:b,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:O?q:void 0,panelConstraints:{groupResizeBehavior:u,collapsedSize:r,collapsible:n,defaultSize:s,disabled:T.disabled,maxSize:c,minSize:p}};return k(L)}},[u,r,n,s,O,b,v,c,p,q,k,T]),se.useEffect(()=>{_(b,{disabled:i})},[i,b,_]),CL(b,h);const j=()=>{const oe=E(A,b);if(oe)return JSON.stringify(oe)},V=se.useSyncExternalStore(oe=>D3(A,oe),j,j);let z;return V?z=JSON.parse(V):s!==void 0?z={flexGrow:void 0,flexShrink:void 0,flexBasis:s}:z={flexGrow:1},S.jsx("div",{...y,"data-disabled":i||void 0,"data-panel":!0,"data-testid":b,id:b,ref:x,style:{...TL,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...z},children:S.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...m,touchAction:F==="horizontal"?"pan-y":"pan-x"},children:e})})}M8.displayName="Panel";const TL={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function AL({layout:e,panelConstraints:t,panelId:r,panelIndex:n}){let s,i;const a=e[r],u=t.find(o=>o.panelId===r);if(u){const o=u.maxSize,c=u.collapsible?u.collapsedSize:u.minSize,p=[n,n+1];i=Al({layout:Eh({delta:c-a,initialLayout:e,panelConstraints:t,pivotIndices:p,prevLayout:e}),panelConstraints:t})[r],s=Al({layout:Eh({delta:o-a,initialLayout:e,panelConstraints:t,pivotIndices:p,prevLayout:e}),panelConstraints:t})[r]}return{valueControls:r,valueMax:s,valueMin:i,valueNow:a}}function R8({children:e,className:t,disabled:r,disableDoubleClick:n,elementRef:s,id:i,style:a,...u}){const o=b3(i),c=E3({disabled:r,disableDoubleClick:n}),[p,d]=se.useState({}),[h,m]=se.useState("inactive"),[y,v]=se.useState(!1),b=se.useRef(null),T=v3(b,s),{disableCursor:D,id:x,orientation:E,registerSeparator:A,updateSeparatorProps:F}=T3(),k=E==="horizontal"?"vertical":"horizontal";Il(()=>{const q=b.current;if(q!==null){const j={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:q,id:o},V=A(j),z=eL(L=>{m(L.next.state!=="inactive"&&L.next.hitRegions.some(ne=>ne.separator===j)?L.next.state:"inactive")}),oe=D3(x,L=>{const{derivedPanelConstraints:ne,layout:Ee,separatorToPanels:X}=L.next,je=X.get(j);if(je){const K=je[0],Q=je.indexOf(K);d(AL({layout:Ee,panelConstraints:ne,panelId:K.id,panelIndex:Q}))}});return()=>{z(),oe(),V()}}},[x,o,A,c]),se.useEffect(()=>{F(o,{disabled:r,disableDoubleClick:n})},[r,n,o,F]);let _;r&&!D&&(_="not-allowed");let O;if(r)O="disabled";else switch(h){case"active":{O="active";break}default:y?O="focus":O=h}return S.jsx("div",{...u,"aria-controls":p.valueControls,"aria-disabled":r||void 0,"aria-orientation":k,"aria-valuemax":p.valueMax,"aria-valuemin":p.valueMin,"aria-valuenow":p.valueNow,children:e,className:t,"data-separator":O,"data-testid":o,id:o,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:T,role:"separator",style:{flexBasis:"auto",cursor:_,...a,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:r?void 0:0})}R8.displayName="Separator";function A3({className:e,...t}){return S.jsx(L8,{"data-slot":"resizable-panel-group",className:n8("flex h-full w-full aria-[orientation=vertical]:flex-col",e),...t})}function hl({...e}){return S.jsx(M8,{"data-slot":"resizable-panel",...e})}function jg({withHandle:e,className:t,...r}){return S.jsx(R8,{"data-slot":"resizable-handle",className:n8("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),...r,children:e&&S.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-xs border bg-border",children:S.jsx(u3,{className:"size-2.5"})})})}function SL(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}const FL=e=>{switch(e){case"success":return _L;case"info":return NL;case"warning":return PL;case"error":return $L;default:return null}},wL=Array(12).fill(0),kL=({visible:e,className:t})=>pt.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},pt.createElement("div",{className:"sonner-spinner"},wL.map((r,n)=>pt.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),_L=pt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},pt.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),PL=pt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},pt.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),NL=pt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},pt.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),$L=pt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},pt.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),IL=pt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),pt.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),BL=()=>{const[e,t]=pt.useState(document.hidden);return pt.useEffect(()=>{const r=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),e};let wv=1;class jL{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const r=this.subscribers.indexOf(t);this.subscribers.splice(r,1)}),this.publish=t=>{this.subscribers.forEach(r=>r(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var r;const{message:n,...s}=t,i=typeof t?.id=="number"||((r=t.id)==null?void 0:r.length)>0?t.id:wv++,a=this.toasts.find(o=>o.id===i),u=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(i)&&this.dismissedToasts.delete(i),a?this.toasts=this.toasts.map(o=>o.id===i?(this.publish({...o,...t,id:i,title:n}),{...o,...t,id:i,dismissible:u,title:n}):o):this.addToast({title:n,...s,dismissible:u,id:i}),i},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(r=>r({id:t,dismiss:!0})))):this.toasts.forEach(r=>{this.subscribers.forEach(n=>n({id:r.id,dismiss:!0}))}),t),this.message=(t,r)=>this.create({...r,message:t}),this.error=(t,r)=>this.create({...r,message:t,type:"error"}),this.success=(t,r)=>this.create({...r,type:"success",message:t}),this.info=(t,r)=>this.create({...r,type:"info",message:t}),this.warning=(t,r)=>this.create({...r,type:"warning",message:t}),this.loading=(t,r)=>this.create({...r,type:"loading",message:t}),this.promise=(t,r)=>{if(!r)return;let n;r.loading!==void 0&&(n=this.create({...r,promise:t,type:"loading",message:r.loading,description:typeof r.description!="function"?r.description:void 0}));const s=Promise.resolve(t instanceof Function?t():t);let i=n!==void 0,a;const u=s.then(async c=>{if(a=["resolve",c],pt.isValidElement(c))i=!1,this.create({id:n,type:"default",message:c});else if(LL(c)&&!c.ok){i=!1;const d=typeof r.error=="function"?await r.error(`HTTP error! status: ${c.status}`):r.error,h=typeof r.description=="function"?await r.description(`HTTP error! status: ${c.status}`):r.description,y=typeof d=="object"&&!pt.isValidElement(d)?d:{message:d};this.create({id:n,type:"error",description:h,...y})}else if(c instanceof Error){i=!1;const d=typeof r.error=="function"?await r.error(c):r.error,h=typeof r.description=="function"?await r.description(c):r.description,y=typeof d=="object"&&!pt.isValidElement(d)?d:{message:d};this.create({id:n,type:"error",description:h,...y})}else if(r.success!==void 0){i=!1;const d=typeof r.success=="function"?await r.success(c):r.success,h=typeof r.description=="function"?await r.description(c):r.description,y=typeof d=="object"&&!pt.isValidElement(d)?d:{message:d};this.create({id:n,type:"success",description:h,...y})}}).catch(async c=>{if(a=["reject",c],r.error!==void 0){i=!1;const p=typeof r.error=="function"?await r.error(c):r.error,d=typeof r.description=="function"?await r.description(c):r.description,m=typeof p=="object"&&!pt.isValidElement(p)?p:{message:p};this.create({id:n,type:"error",description:d,...m})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),r.finally==null||r.finally.call(r)}),o=()=>new Promise((c,p)=>u.then(()=>a[0]==="reject"?p(a[1]):c(a[1])).catch(p));return typeof n!="string"&&typeof n!="number"?{unwrap:o}:Object.assign(n,{unwrap:o})},this.custom=(t,r)=>{const n=r?.id||wv++;return this.create({jsx:t(n),id:n,...r}),n},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const _s=new jL,OL=(e,t)=>{const r=t?.id||wv++;return _s.addToast({title:e,...t,id:r}),r},LL=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",ML=OL,RL=()=>_s.toasts,UL=()=>_s.getActiveToasts(),wt=Object.assign(ML,{success:_s.success,info:_s.info,warning:_s.warning,error:_s.error,custom:_s.custom,message:_s.message,promise:_s.promise,dismiss:_s.dismiss,loading:_s.loading},{getHistory:RL,getToasts:UL});SL("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Y1(e){return e.label!==void 0}const zL=3,qL="24px",JL="16px",fS=4e3,KL=356,VL=14,WL=45,HL=200;function ea(...e){return e.filter(Boolean).join(" ")}function GL(e){const[t,r]=e.split("-"),n=[];return t&&n.push(t),r&&n.push(r),n}const XL=e=>{var t,r,n,s,i,a,u,o,c;const{invert:p,toast:d,unstyled:h,interacting:m,setHeights:y,visibleToasts:v,heights:b,index:T,toasts:D,expanded:x,removeToast:E,defaultRichColors:A,closeButton:F,style:k,cancelButtonStyle:_,actionButtonStyle:O,className:q="",descriptionClassName:j="",duration:V,position:z,gap:oe,expandByDefault:L,classNames:ne,icons:Ee,closeButtonAriaLabel:X="Close toast"}=e,[je,K]=pt.useState(null),[Q,ie]=pt.useState(null),[M,B]=pt.useState(!1),[U,J]=pt.useState(!1),[de,Ce]=pt.useState(!1),[Me,Ue]=pt.useState(!1),[re,le]=pt.useState(!1),[xe,Ie]=pt.useState(0),[st,rt]=pt.useState(0),Ct=pt.useRef(d.duration||V||fS),dt=pt.useRef(null),bt=pt.useRef(null),tr=T===0,cr=T+1<=v,Vt=d.type,Gt=d.dismissible!==!1,vr=d.className||"",Sr=d.descriptionClassName||"",et=pt.useMemo(()=>b.findIndex(De=>De.toastId===d.id)||0,[b,d.id]),Wt=pt.useMemo(()=>{var De;return(De=d.closeButton)!=null?De:F},[d.closeButton,F]),me=pt.useMemo(()=>d.duration||V||fS,[d.duration,V]),Le=pt.useRef(0),ze=pt.useRef(0),lt=pt.useRef(0),Ot=pt.useRef(null),[Yt,ar]=z.split("-"),kr=pt.useMemo(()=>b.reduce((De,Ne,at)=>at>=et?De:De+Ne.height,0),[b,et]),xr=BL(),er=d.invert||p,is=Vt==="loading";ze.current=pt.useMemo(()=>et*oe+kr,[et,kr]),pt.useEffect(()=>{Ct.current=me},[me]),pt.useEffect(()=>{B(!0)},[]),pt.useEffect(()=>{const De=bt.current;if(De){const Ne=De.getBoundingClientRect().height;return rt(Ne),y(at=>[{toastId:d.id,height:Ne,position:d.position},...at]),()=>y(at=>at.filter(ut=>ut.toastId!==d.id))}},[y,d.id]),pt.useLayoutEffect(()=>{if(!M)return;const De=bt.current,Ne=De.style.height;De.style.height="auto";const at=De.getBoundingClientRect().height;De.style.height=Ne,rt(at),y(ut=>ut.find(Qe=>Qe.toastId===d.id)?ut.map(Qe=>Qe.toastId===d.id?{...Qe,height:at}:Qe):[{toastId:d.id,height:at,position:d.position},...ut])},[M,d.title,d.description,y,d.id,d.jsx,d.action,d.cancel]);const Ir=pt.useCallback(()=>{J(!0),Ie(ze.current),y(De=>De.filter(Ne=>Ne.toastId!==d.id)),setTimeout(()=>{E(d)},HL)},[d,E,y,ze]);pt.useEffect(()=>{if(d.promise&&Vt==="loading"||d.duration===1/0||d.type==="loading")return;let De;return x||m||xr?(()=>{if(lt.current<Le.current){const ut=new Date().getTime()-Le.current;Ct.current=Ct.current-ut}lt.current=new Date().getTime()})():(()=>{Ct.current!==1/0&&(Le.current=new Date().getTime(),De=setTimeout(()=>{d.onAutoClose==null||d.onAutoClose.call(d,d),Ir()},Ct.current))})(),()=>clearTimeout(De)},[x,m,d,Vt,xr,Ir]),pt.useEffect(()=>{d.delete&&(Ir(),d.onDismiss==null||d.onDismiss.call(d,d))},[Ir,d.delete]);function Wn(){var De;if(Ee?.loading){var Ne;return pt.createElement("div",{className:ea(ne?.loader,d==null||(Ne=d.classNames)==null?void 0:Ne.loader,"sonner-loader"),"data-visible":Vt==="loading"},Ee.loading)}return pt.createElement(kL,{className:ea(ne?.loader,d==null||(De=d.classNames)==null?void 0:De.loader),visible:Vt==="loading"})}const Xr=d.icon||Ee?.[Vt]||FL(Vt);var Br,be;return pt.createElement("li",{tabIndex:0,ref:bt,className:ea(q,vr,ne?.toast,d==null||(t=d.classNames)==null?void 0:t.toast,ne?.default,ne?.[Vt],d==null||(r=d.classNames)==null?void 0:r[Vt]),"data-sonner-toast":"","data-rich-colors":(Br=d.richColors)!=null?Br:A,"data-styled":!(d.jsx||d.unstyled||h),"data-mounted":M,"data-promise":!!d.promise,"data-swiped":re,"data-removed":U,"data-visible":cr,"data-y-position":Yt,"data-x-position":ar,"data-index":T,"data-front":tr,"data-swiping":de,"data-dismissible":Gt,"data-type":Vt,"data-invert":er,"data-swipe-out":Me,"data-swipe-direction":Q,"data-expanded":!!(x||L&&M),"data-testid":d.testId,style:{"--index":T,"--toasts-before":T,"--z-index":D.length-T,"--offset":`${U?xe:ze.current}px`,"--initial-height":L?"auto":`${st}px`,...k,...d.style},onDragEnd:()=>{Ce(!1),K(null),Ot.current=null},onPointerDown:De=>{De.button!==2&&(is||!Gt||(dt.current=new Date,Ie(ze.current),De.target.setPointerCapture(De.pointerId),De.target.tagName!=="BUTTON"&&(Ce(!0),Ot.current={x:De.clientX,y:De.clientY})))},onPointerUp:()=>{var De,Ne,at;if(Me||!Gt)return;Ot.current=null;const ut=Number(((De=bt.current)==null?void 0:De.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),yt=Number(((Ne=bt.current)==null?void 0:Ne.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Qe=new Date().getTime()-((at=dt.current)==null?void 0:at.getTime()),Nt=je==="x"?ut:yt,rr=Math.abs(Nt)/Qe;if(Math.abs(Nt)>=WL||rr>.11){Ie(ze.current),d.onDismiss==null||d.onDismiss.call(d,d),ie(je==="x"?ut>0?"right":"left":yt>0?"down":"up"),Ir(),Ue(!0);return}else{var jt,gt;(jt=bt.current)==null||jt.style.setProperty("--swipe-amount-x","0px"),(gt=bt.current)==null||gt.style.setProperty("--swipe-amount-y","0px")}le(!1),Ce(!1),K(null)},onPointerMove:De=>{var Ne,at,ut;if(!Ot.current||!Gt||((Ne=window.getSelection())==null?void 0:Ne.toString().length)>0)return;const Qe=De.clientY-Ot.current.y,Nt=De.clientX-Ot.current.x;var rr;const jt=(rr=e.swipeDirections)!=null?rr:GL(z);!je&&(Math.abs(Nt)>1||Math.abs(Qe)>1)&&K(Math.abs(Nt)>Math.abs(Qe)?"x":"y");let gt={x:0,y:0};const Hn=pr=>1/(1.5+Math.abs(pr)/20);if(je==="y"){if(jt.includes("top")||jt.includes("bottom"))if(jt.includes("top")&&Qe<0||jt.includes("bottom")&&Qe>0)gt.y=Qe;else{const pr=Qe*Hn(Qe);gt.y=Math.abs(pr)<Math.abs(Qe)?pr:Qe}}else if(je==="x"&&(jt.includes("left")||jt.includes("right")))if(jt.includes("left")&&Nt<0||jt.includes("right")&&Nt>0)gt.x=Nt;else{const pr=Nt*Hn(Nt);gt.x=Math.abs(pr)<Math.abs(Nt)?pr:Nt}(Math.abs(gt.x)>0||Math.abs(gt.y)>0)&&le(!0),(at=bt.current)==null||at.style.setProperty("--swipe-amount-x",`${gt.x}px`),(ut=bt.current)==null||ut.style.setProperty("--swipe-amount-y",`${gt.y}px`)}},Wt&&!d.jsx&&Vt!=="loading"?pt.createElement("button",{"aria-label":X,"data-disabled":is,"data-close-button":!0,onClick:is||!Gt?()=>{}:()=>{Ir(),d.onDismiss==null||d.onDismiss.call(d,d)},className:ea(ne?.closeButton,d==null||(n=d.classNames)==null?void 0:n.closeButton)},(be=Ee?.close)!=null?be:IL):null,(Vt||d.icon||d.promise)&&d.icon!==null&&(Ee?.[Vt]!==null||d.icon)?pt.createElement("div",{"data-icon":"",className:ea(ne?.icon,d==null||(s=d.classNames)==null?void 0:s.icon)},d.promise||d.type==="loading"&&!d.icon?d.icon||Wn():null,d.type!=="loading"?Xr:null):null,pt.createElement("div",{"data-content":"",className:ea(ne?.content,d==null||(i=d.classNames)==null?void 0:i.content)},pt.createElement("div",{"data-title":"",className:ea(ne?.title,d==null||(a=d.classNames)==null?void 0:a.title)},d.jsx?d.jsx:typeof d.title=="function"?d.title():d.title),d.description?pt.createElement("div",{"data-description":"",className:ea(j,Sr,ne?.description,d==null||(u=d.classNames)==null?void 0:u.description)},typeof d.description=="function"?d.description():d.description):null),pt.isValidElement(d.cancel)?d.cancel:d.cancel&&Y1(d.cancel)?pt.createElement("button",{"data-button":!0,"data-cancel":!0,style:d.cancelButtonStyle||_,onClick:De=>{Y1(d.cancel)&&Gt&&(d.cancel.onClick==null||d.cancel.onClick.call(d.cancel,De),Ir())},className:ea(ne?.cancelButton,d==null||(o=d.classNames)==null?void 0:o.cancelButton)},d.cancel.label):null,pt.isValidElement(d.action)?d.action:d.action&&Y1(d.action)?pt.createElement("button",{"data-button":!0,"data-action":!0,style:d.actionButtonStyle||O,onClick:De=>{Y1(d.action)&&(d.action.onClick==null||d.action.onClick.call(d.action,De),!De.defaultPrevented&&Ir())},className:ea(ne?.actionButton,d==null||(c=d.classNames)==null?void 0:c.actionButton)},d.action.label):null)};function hS(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function YL(e,t){const r={};return[e,t].forEach((n,s)=>{const i=s===1,a=i?"--mobile-offset":"--offset",u=i?JL:qL;function o(c){["top","right","bottom","left"].forEach(p=>{r[`${a}-${p}`]=typeof c=="number"?`${c}px`:c})}typeof n=="number"||typeof n=="string"?o(n):typeof n=="object"?["top","right","bottom","left"].forEach(c=>{n[c]===void 0?r[`${a}-${c}`]=u:r[`${a}-${c}`]=typeof n[c]=="number"?`${n[c]}px`:n[c]}):o(u)}),r}const QL=pt.forwardRef(function(t,r){const{id:n,invert:s,position:i="bottom-right",hotkey:a=["altKey","KeyT"],expand:u,closeButton:o,className:c,offset:p,mobileOffset:d,theme:h="light",richColors:m,duration:y,style:v,visibleToasts:b=zL,toastOptions:T,dir:D=hS(),gap:x=VL,icons:E,containerAriaLabel:A="Notifications"}=t,[F,k]=pt.useState([]),_=pt.useMemo(()=>n?F.filter(M=>M.toasterId===n):F.filter(M=>!M.toasterId),[F,n]),O=pt.useMemo(()=>Array.from(new Set([i].concat(_.filter(M=>M.position).map(M=>M.position)))),[_,i]),[q,j]=pt.useState([]),[V,z]=pt.useState(!1),[oe,L]=pt.useState(!1),[ne,Ee]=pt.useState(h!=="system"?h:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),X=pt.useRef(null),je=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),K=pt.useRef(null),Q=pt.useRef(!1),ie=pt.useCallback(M=>{k(B=>{var U;return(U=B.find(J=>J.id===M.id))!=null&&U.delete||_s.dismiss(M.id),B.filter(({id:J})=>J!==M.id)})},[]);return pt.useEffect(()=>_s.subscribe(M=>{if(M.dismiss){requestAnimationFrame(()=>{k(B=>B.map(U=>U.id===M.id?{...U,delete:!0}:U))});return}setTimeout(()=>{SO.flushSync(()=>{k(B=>{const U=B.findIndex(J=>J.id===M.id);return U!==-1?[...B.slice(0,U),{...B[U],...M},...B.slice(U+1)]:[M,...B]})})})}),[F]),pt.useEffect(()=>{if(h!=="system"){Ee(h);return}if(h==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Ee("dark"):Ee("light")),typeof window>"u")return;const M=window.matchMedia("(prefers-color-scheme: dark)");try{M.addEventListener("change",({matches:B})=>{Ee(B?"dark":"light")})}catch{M.addListener(({matches:U})=>{try{Ee(U?"dark":"light")}catch(J){console.error(J)}})}},[h]),pt.useEffect(()=>{F.length<=1&&z(!1)},[F]),pt.useEffect(()=>{const M=B=>{var U;if(a.every(Ce=>B[Ce]||B.code===Ce)){var de;z(!0),(de=X.current)==null||de.focus()}B.code==="Escape"&&(document.activeElement===X.current||(U=X.current)!=null&&U.contains(document.activeElement))&&z(!1)};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[a]),pt.useEffect(()=>{if(X.current)return()=>{K.current&&(K.current.focus({preventScroll:!0}),K.current=null,Q.current=!1)}},[X.current]),pt.createElement("section",{ref:r,"aria-label":`${A} ${je}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},O.map((M,B)=>{var U;const[J,de]=M.split("-");return _.length?pt.createElement("ol",{key:M,dir:D==="auto"?hS():D,tabIndex:-1,ref:X,className:c,"data-sonner-toaster":!0,"data-sonner-theme":ne,"data-y-position":J,"data-x-position":de,style:{"--front-toast-height":`${((U=q[0])==null?void 0:U.height)||0}px`,"--width":`${KL}px`,"--gap":`${x}px`,...v,...YL(p,d)},onBlur:Ce=>{Q.current&&!Ce.currentTarget.contains(Ce.relatedTarget)&&(Q.current=!1,K.current&&(K.current.focus({preventScroll:!0}),K.current=null))},onFocus:Ce=>{Ce.target instanceof HTMLElement&&Ce.target.dataset.dismissible==="false"||Q.current||(Q.current=!0,K.current=Ce.relatedTarget)},onMouseEnter:()=>z(!0),onMouseMove:()=>z(!0),onMouseLeave:()=>{oe||z(!1)},onDragEnd:()=>z(!1),onPointerDown:Ce=>{Ce.target instanceof HTMLElement&&Ce.target.dataset.dismissible==="false"||L(!0)},onPointerUp:()=>L(!1)},_.filter(Ce=>!Ce.position&&B===0||Ce.position===M).map((Ce,Me)=>{var Ue,re;return pt.createElement(XL,{key:Ce.id,icons:E,index:Me,toast:Ce,defaultRichColors:m,duration:(Ue=T?.duration)!=null?Ue:y,className:T?.className,descriptionClassName:T?.descriptionClassName,invert:s,visibleToasts:b,closeButton:(re=T?.closeButton)!=null?re:o,interacting:oe,position:M,style:T?.style,unstyled:T?.unstyled,classNames:T?.classNames,cancelButtonStyle:T?.cancelButtonStyle,actionButtonStyle:T?.actionButtonStyle,closeButtonAriaLabel:T?.closeButtonAriaLabel,removeToast:ie,toasts:_.filter(le=>le.position==Ce.position),heights:q.filter(le=>le.position==Ce.position),setHeights:j,expandByDefault:u,gap:x,expanded:V,swipeDirections:t.swipeDirections})})):null}))}),ZL=({...e})=>S.jsx(QL,{theme:"system",className:"toaster group",icons:{success:S.jsx(Jj,{className:"size-4"}),info:S.jsx(qj,{className:"size-4"}),warning:S.jsx(s8,{className:"size-4"}),error:S.jsx(zj,{className:"size-4"}),loading:S.jsx(m3,{className:"size-4 animate-spin"})},toastOptions:{classNames:{icon:"self-start mt-0.5"}},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...e});function Bl(e){let t=e;const r=new Set;return{getState:()=>t,setState:n=>{const s=typeof n=="function"?n(t):n;Object.is(s,t)||(t=s,r.forEach(i=>i()))},subscribe:n=>(r.add(n),()=>r.delete(n))}}const eM=/^\$(model|component|html|dataSource|fn|locale)\((.+)\)$/;function Mt(e){if(typeof e!="string")return null;const t=eM.exec(e);return t?{op:t[1],arg:t[2]}:null}const Li=e=>Mt(e)?.op==="model",Jh=e=>Mt(e)?.op==="component",zp=e=>Mt(e)?.op==="html",S3=e=>Mt(e)?.op==="dataSource",F3=e=>Mt(e)?.op==="fn",w3=e=>Mt(e)?.op==="locale",k3=new Set(["div","section","article","aside","header","footer","nav","main","figure","figcaption","details","summary","fieldset","legend","p","span","h1","h2","h3","h4","h5","h6","strong","b","em","i","u","s","small","mark","sub","sup","code","pre","kbd","samp","var","blockquote","cite","q","abbr","time","address","label","br","hr","a","ul","ol","li","dl","dt","dd","table","caption","colgroup","col","thead","tbody","tfoot","tr","th","td","img","picture","source","video","audio","track","progress","meter"]);function _3(e){return k3.has(e.toLowerCase())}const tM=new Set(["href","src","srcSet","srcset","poster","action","formAction","formaction","data","xlinkHref","cite","ping"]);function rM(e){const t=Array.from(e).filter(r=>r.charCodeAt(0)>32).join("").toLowerCase();return t.startsWith("javascript:")||t.startsWith("vbscript:")?!0:t.startsWith("data:")?!t.startsWith("data:image/"):!1}function U8(e,t){if(!e)return e;let r=null;const n={};for(const s of Object.keys(e)){const i=e[s],a=s.length>2&&s.startsWith("on")&&s[2]===s[2].toUpperCase(),u=tM.has(s)&&typeof i=="string"&&rM(i);if(s==="dangerouslySetInnerHTML"||a||u){(r??=[]).push(s);continue}n[s]=i}return r?(typeof console<"u"&&console.warn(`[JsonRenderer] $html(${t}): отброшены небезопасные props — ${r.join(", ")}. HTML-узлы предназначены для презентационной разметки: исполняемые обработчики, сырой innerHTML и javascript:/data:-URL в них не пропускаются.`),n):e}const nM="http://json-schema.org/draft-07/schema#",sM="https://reformer.dev/schemas/form-schema.schema.json",iM="ReFormer JSON form schema (M1, string-operator DSL)",aM="Base meta-schema: validates node structure + operator string syntax ($model/$component/$dataSource). Component-name enum is tightened per-app via buildFormSchemaMetaSchema; $dataSource names and $model paths are checked outside this schema.",oM="object",uM=["root"],lM=!1,cM={$schema:{type:"string"},id:{type:"string"},version:{type:"string"},meta:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}},root:{$ref:"#/definitions/node"}},pM={modelOp:{type:"string",pattern:"^\\$model\\(.+\\)$",description:'Model binding: "$model(path)" — path resolved at runtime (not validated here).'},componentOp:{type:"string",pattern:"^\\$component\\(.+\\)$",description:'Registry component: "$component(Name)". Name is tightened to a registry enum by buildFormSchemaMetaSchema.'},htmlOp:{type:"string",pattern:"^\\$html\\([a-zA-Z][a-zA-Z0-9]*\\)$",description:'Native HTML tag: "$html(div)". The tag is checked against the presentational whitelist (isAllowedHtmlTag) by validateFormSchema and by the converter; buildFormSchemaMetaSchema tightens it to an enum for IDE completion.'},textChild:{description:`Text part of a node's children: a literal, or an operator string ("$model(path)" for reactive model values, "$locale(key)" for localized strings). Adjacent parts are joined without a separator.`,$comment:`Types are listed as separate anyOf branches rather than a union "type": ["string","number"] — ajv's strict mode rejects union type keywords unless allowUnionTypes is on, and validateFormSchema compiles this schema without it.`,anyOf:[{type:"string"},{type:"number"}]},operatorOp:{type:"string",pattern:"^\\$(model|component|html|dataSource|fn|locale)\\(.+\\)$",description:'Any DSL operator string ("$model/$component/$dataSource/$fn/$locale(...)") used as an escape hatch on a componentProps value (e.g. "options": "$dataSource(LOAN_TYPES)"). The component-props validator wraps every prop in anyOf:[honest type, operatorOp] via allowOperatorStrings, so an operator string is accepted wherever a literal value is.'},node:{$comment:"Discriminated by which operator key is present (array→value→component), mirroring the isArrayNode/isFieldNode/isContainerNode runtime guards. Using oneOf here made ajv (allErrors) report failures against all three branches for any single mistake, burying the real cause; if/then/else surfaces only the relevant branch's errors.",if:{type:"object",required:["array"]},then:{$ref:"#/definitions/arrayNode"},else:{if:{type:"object",required:["value"]},then:{$ref:"#/definitions/fieldNode"},else:{$ref:"#/definitions/containerNode"}}},fieldNode:{type:"object",required:["value"],additionalProperties:!1,properties:{selector:{type:"string"},value:{$ref:"#/definitions/modelOp"},component:{$ref:"#/definitions/componentOp"},componentProps:{type:"object"},wrapper:{$ref:"#/definitions/node"}}},arrayNode:{type:"object",required:["array","item"],additionalProperties:!1,properties:{selector:{type:"string"},array:{$ref:"#/definitions/modelOp"},component:{$ref:"#/definitions/componentOp"},item:{type:"object",required:["$template"],additionalProperties:!1,properties:{$template:{$ref:"#/definitions/node"}}},initialValue:{type:"object"},componentProps:{type:"object"}}},containerNode:{type:"object",required:["component"],additionalProperties:!1,properties:{selector:{type:"string"},component:{anyOf:[{$ref:"#/definitions/componentOp"},{$ref:"#/definitions/htmlOp"}]},componentProps:{type:"object"},children:{$comment:'A child is either a nested node (object) or a text part (string/number). Dispatched with if/then/else rather than anyOf for the same reason as "node": with allErrors ajv would report failures from every branch, burying the real cause.',type:"array",items:{if:{type:"object"},then:{$ref:"#/definitions/node"},else:{$ref:"#/definitions/textChild"}}}}}},P3={$schema:nM,$id:sM,title:iM,description:aM,type:oM,required:uM,additionalProperties:lM,properties:cM,definitions:pM},z8=P3;function q8(e){return e.names().filter(t=>e.get(t)?.type==="component")}function J8(e){return e.names().filter(t=>e.get(t)?.type==="dataSource")}function K8(e){return e.names().filter(t=>e.get(t)?.type==="fn")}function V8(e){return e.getLocale?.()?.keys}function dM(){return P3.definitions.operatorOp}function W8(e){return kv(e)}function kv(e){if(Array.isArray(e))return e.map(kv);if(e!==null&&typeof e=="object"){const t={};for(const[r,n]of Object.entries(e))r.startsWith("x-")||(t[r]=kv(n));return t}return e}function H8(e){return pg(e)}function pg(e){if(Array.isArray(e))return e.map(pg);if(e===null||typeof e!="object")return e;const t=e,r={...t};if(t.properties!==null&&typeof t.properties=="object"&&!Array.isArray(t.properties)){const n={};for(const[s,i]of Object.entries(t.properties))n[s]={anyOf:[pg(i),{$ref:"#/definitions/operatorOp"}]};r.properties=n}return t.items!==void 0&&(r.items=pg(t.items)),r}function N3(e){const t=W8(e),r=H8(t),n=r.definitions??{};return{...r,definitions:{...n,operatorOp:dM()}}}function fM(e){const t=JSON.parse(JSON.stringify(P3)),r=e?.componentNames;if(r&&r.length>0){const i=t.definitions.componentOp;delete i.pattern,i.enum=r.map(a=>`$component(${a})`)}const n=t.definitions.htmlOp;delete n.pattern,n.enum=[...k3].map(i=>`$html(${i})`);const s=e?.propSchemas;if(s&&Object.keys(s).length>0){const i=Object.entries(s).map(([a,u])=>({if:{required:["component"],properties:{component:{const:`$component(${a})`}}},then:{properties:{componentProps:N3(u)}}}));for(const a of["fieldNode","containerNode"]){const u=t.definitions[a];u.allOf=[...u.allOf??[],...i]}}return t}const k2="$fieldWrapper",$3="$localeService";let Og=class _v{own=new Map;parent=null;get(t){return this.own.get(t)??this.parent?.get(t)}getDataSource(t){const r=this.get(t);if(!(!r||r.type!=="dataSource"))return r.component}getLocale(){const t=this.get($3);if(!(!t||t.type!=="locale"))return t.component}has(t){return this.own.has(t)||(this.parent?.has(t)??!1)}names(){const t=this.parent?.names()??[],r=Array.from(this.own.keys());return[...new Set([...t,...r])]}_set(t,r){this.own.has(t)&&console.warn(`[ComponentRegistry] Overwriting entry: ${t}`),this.own.set(t,r)}static withParent(t,r){const n=new _v,s=i=>{for(const a of i.names()){const u=i.get(a);u&&n.own.set(a,u)}};return t instanceof _v?n.parent=t:s(t),s(r),n}};function hM(...e){return e.length===0?new Og:e.reduce((t,r)=>Og.withParent(t,r))}function G8(e){const t=new Og;return e({component(r,n,s){t._set(r,{component:n,type:"component",description:s})},dataSource(r,n,s){t._set(r,{component:n,type:"dataSource",description:s})},fn(r,n,s){if(typeof n!="function")throw new Error(`reg.fn("${r}") expects a function, got ${typeof n}. Use reg.dataSource(...) for non-function values.`);t._set(r,{component:n,type:"fn",description:s})},locale(r,n){const s=typeof r=="function"?{resolve:r}:r;t._set($3,{component:s,type:"locale",description:n})}}),t}const Pv=se.createContext({});function X8({settings:e,children:t}){const r=se.useContext(Pv),n=se.useMemo(()=>r.registry&&e.registry?Og.withParent(r.registry,e.registry):e.registry??r.registry,[r.registry,e.registry]),s=se.useMemo(()=>{const i=n?.get(k2)?.component;return{...r,...e,registry:n,fieldWrapper:e.fieldWrapper??i??r.fieldWrapper}},[r,e,n]);return S.jsx(Pv.Provider,{value:s,children:t})}function mM(){return I3()}function I3(){return se.useContext(Pv)}function yM(e){return e}function Jn(e){const t=e;return Li(t.array)&&typeof t.item=="object"&&t.item!==null&&"$template"in t.item}function ni(e){return Li(e.value)}function ns(e){const t=e.component;return(Jh(t)||zp(t))&&!ni(e)&&!Jn(e)}function gM(e){const t=Mt(e)?.arg;if(!t)throw new Error(`Invalid $html operator: "${e}"`);if(!_3(t))throw new Error(`HTML tag "${t}" is not allowed in $html(...). Presentational tags only — script/style/iframe/form-controls are excluded by design.`);return t.toLowerCase()}function jf(e,t){if(!e)return;if(zp(e))return gM(e);const r=Mt(e)?.arg;if(!r)throw new Error(`Invalid $component operator: "${e}"`);const n=t.get(r);if(!n)throw new Error(`Component "${r}" not found in registry. Available: ${t.names().join(", ")}`);if(n.type!=="component")throw new Error(`Entry "${r}" is a '${n.type}' and cannot be used as $component(...)`);return n.component}function Y8(e,t){const r=t.get(e);if(!r)throw new Error(`Data source "${e}" not found in registry. Available: ${t.names().join(", ")}`);if(r.type!=="dataSource")throw new Error(`Entry "${e}" is a '${r.type}' and cannot be used as $dataSource(...)`);return r.component}function DM(e,t){const r=t.get(e);if(!r)throw new Error(`Function "${e}" not found in registry. Available: ${t.names().join(", ")}`);if(r.type!=="fn")throw new Error(`Entry "${e}" is a '${r.type}' and cannot be used as $fn(...)`);return r.component}function Nv(e,t,r){return t.getLocale?.()?.resolve(e,r)??e}function xM(e){return e!==null&&typeof e=="object"&&typeof e.$locale=="string"}function bM(e,t){if(!e)return e;let r=!1;const n={};for(const s of Object.keys(e)){const i=e[s];if(Li(i)){const a=t.signalAt(Mt(i).arg);n[s]=a?.peek?.(),r=!0}else n[s]=i}return r?n:e}function vM(e,t){if(!(!t||typeof console>"u"))for(const r of Object.keys(t))Li(t[r])&&console.warn(`[JsonRenderer] $locale("${e}"): параметр "${r}" (=${String(t[r])}) взят снимком значения на момент рендера и не обновляется при изменении модели. Для реактивного значения используй I18n: { component: "$component(I18n)", componentProps: { id: "${e}", values: { ${r}: "${String(t[r])}" } } }.`)}function EM(e,t){return t.split(".").reduce((r,n)=>r==null?r:r[n],e)}function CM(e){if(e===null||typeof e!="object")return!1;const t=e;return Li(t.value)||Li(t.array)||Jh(t.component)||zp(t.component)}function TM(e){return e==null?e:JSON.parse(JSON.stringify(e))}function $v(e,t,r){if(S3(e))return Y8(Mt(e).arg,r);if(Jh(e))return jf(e,r);if(F3(e))return DM(Mt(e).arg,r);if(w3(e))return Nv(Mt(e).arg,r);if(Li(e))return t.signalAt(Mt(e).arg);if(xM(e))return vM(e.$locale,e.params),Nv(e.$locale,r,bM(e.params,t));if(CM(e))return Ch(e,t,r);if(Array.isArray(e))return e.map(n=>$v(n,t,r));if(e!==null&&typeof e=="object"){const n=e,s={};for(const i of Object.keys(n))s[i]=$v(n[i],t,r);return s}return e}function ob(e,t,r){if(!e)return;const n={};for(const s of Object.keys(e))n[s]=$v(e[s],t,r);return n}function AM(e,t,r){if(typeof e=="number")return e;if(Li(e))return t.signalAt(Mt(e).arg);if(w3(e))return Nv(Mt(e).arg,r);if(S3(e)){const n=Y8(Mt(e).arg,r);if(!(n==null||typeof n=="string"||typeof n=="number"||n instanceof h3))throw new Error(mS(e,"resolves to a non-text value"));return n}if(Jh(e)||zp(e)||F3(e))throw new Error(mS(e,"resolves to a component or a function"));return e}function mS(e,t){return`Operator "${e}" cannot be a text child — it ${t}. Text children accept $model(...), $locale(...) and $dataSource(...) that yields a string, a number or a signal; use a nested node for components and componentProps for functions.`}function Ch(e,t,r){if(Jn(e)){const n=EM(t,Mt(e.array).arg),s=e.item.$template,i=e.initialValue,a=e.component?jf(e.component,r):void 0;return{...e.selector?{selector:e.selector}:{},array:n,...a?{component:a}:{},initialValue:()=>i?TM(i):{},item:u=>Ch(s,u,r),componentProps:ob(e.componentProps,t,r)}}if(ni(e)){const n=Mt(e.value).arg,s=t.signalAt(n);!s&&typeof console<"u"&&console.warn(`[JsonRenderer/M1] No model signal for "${n}".`);const i=ob(e.componentProps,t,r),a=e.wrapper?jf(e.wrapper.component,r):void 0;return{...e.selector?{selector:e.selector}:{},value:s,component:jf(e.component,r),componentProps:a?{...i??{},fieldWrapper:a}:i}}if(ns(e)){const n=zp(e.component),s=jf(e.component,r),i=ob(e.componentProps,t,r);return{...e.selector?{selector:e.selector}:{},component:s,componentProps:n?U8(i,s):i,children:e.children?.map(a=>typeof a=="object"&&a!==null?Ch(a,t,r):AM(a,t,r))}}throw new Error(`Invalid JSON node (M1): ${JSON.stringify(e)}`)}function B3(e,t,r){return Ch(e.root,r,t)}function Q8(e,t,r){return()=>Ch(e.root,r,t)}function dg(e){return e!==null&&typeof e=="object"}function SM(e){return"component"in e||"value"in e||"array"in e||"selector"in e||"children"in e}function Wc(e,t){if(dg(e)){if(Array.isArray(e)){for(const r of e)Wc(r,t);return}if(typeof e.selector=="string"&&t.add(e.selector),Wc(e.children,t),dg(e.item)&&Wc(e.item.$template,t),Wc(e.wrapper,t),dg(e.componentProps))for(const r of Object.values(e.componentProps))Z8(r,t)}}function Z8(e,t){if(dg(e)){if(Array.isArray(e)){for(const r of e)Z8(r,t);return}SM(e)&&Wc(e,t)}}function e_(e){const t=new Set;return Wc(e.root,t),t}function j3({errors:e}){return S.jsxs("div",{role:"alert","data-testid":"schema-error-panel",style:{border:"1px solid #f5a9a9",background:"#fff5f5",color:"#9b1c1c",borderRadius:8,padding:"16px 20px",font:"14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace"},children:[S.jsxs("strong",{style:{display:"block",marginBottom:8,fontSize:15},children:["Невалидная JSON-схема формы (",e.length,")"]}),S.jsx("ul",{style:{margin:0,paddingLeft:20},children:e.map((t,r)=>S.jsx("li",{style:{marginBottom:4},children:t},r))})]})}let t_=class extends se.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,r){typeof console<"u"&&console.error("[JsonFormRenderer] schema conversion/render failed:",t,r.componentStack)}componentDidUpdate(t){this.state.error&&t.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){const{error:t}=this.state;return t?this.props.fallback?.(t)??S.jsx(j3,{errors:[`Schema conversion/render failed: ${t.message}`]}):this.props.children}};function r_({form:e,schema:t,model:r,registry:n,renderBehavior:s,onSchemaReady:i,validateSchema:a=!1}){const{registry:u,...o}=I3(),c=e?.schema??t,p=e?.model??r,d=n??e?.registry??u,h=s??e?.renderBehavior,m=d&&d!==u?d.get(k2)?.component:void 0,y=m?{...o,fieldWrapper:m}:o,[v,b]=se.useState(a?void 0:null);se.useEffect(()=>{if(!a||!c){b(null);return}let x=!1;return b(void 0),Pl(async()=>{const{validateFormSchema:E}=await Promise.resolve().then(()=>BJ);return{validateFormSchema:E}},void 0).then(({validateFormSchema:E})=>{if(x)return;const{valid:A,errors:F}=E(c,{registry:d});b(A?null:F)}).catch(E=>{x||b([`Schema validator failed to load: ${String(E)}`])}),()=>{x=!0}},[a,c,d]);const T=se.useRef(h);se.useEffect(()=>{T.current=h},[h]);const D=se.useMemo(()=>{if(!c||!p)throw new Error("JsonFormRenderer: provide a `form` bundle (createJsonForm) or both `schema` and `model` props.");if(v!==null)return null;if(!d)throw new Error("JsonFormRenderer: settings.registry is required. Pass a ComponentRegistry via JsonRendererProvider.");const x=Q8(c,d,p),E=NO(x);return h&&h(E),E},[c,d,h,p,v]);return se.useMemo(()=>{D&&i&&i(D)},[D]),se.useEffect(()=>{if(!D||!c)return;const x=e_(c),E=D.__overrideMaps,A=[...new Set([...E.hiddenOverrides.keys(),...E.propsOverrides.keys(),...E.refRegistry.keys(),...E.conditionRegistry.keys(),...E.callbackRegistry.keys(),...E.lifecycleRegistry.keys()])].filter(F=>!x.has(F));A.length>0&&typeof console<"u"&&console.warn(`[JsonFormRenderer] schema.node(...) адресует неизвестный selector: ${A.join(", ")}. Известные селекторы: ${[...x].sort().join(", ")||"(нет)"}.`)},[D,c]),v&&v.length>0?S.jsx(j3,{errors:v}):D?S.jsx(t_,{resetKey:D,children:S.jsx($O,{render:D,settings:y})}):null}function FM(e){const{schema:t,registry:r,behavior:n}=e;if(!e.model&&e.initial===void 0)throw new Error("createJsonForm: provide either `initial` (to create a model) or `model`.");const s=e.model??m8(e.initial);e.seed?.(s);const i=y8({model:s,schema:B3(t,r,s),behavior:n}),a=wO(s,e.validation),u=e.renderBehavior?.(i,s,a),o={model:s,form:i,schema:t,registry:r,...a?{validation:a}:{},...u?{renderBehavior:u}:{}};return e.setup?.(o),o}const wM=FO;function kM(e){const t=new Set,r=new Set,n=new Set,s=new Set,i=a=>{if(typeof a=="string"){const u=Mt(a);if(!u)return;u.op==="component"?t.add(u.arg):u.op==="dataSource"?r.add(u.arg):u.op==="fn"?n.add(u.arg):u.op==="locale"&&s.add(u.arg);return}if(Array.isArray(a)){a.forEach(i);return}if(a&&typeof a=="object")for(const u of Object.values(a))i(u)};return i(e.root),{components:[...t],dataSources:[...r],fns:[...n],locales:[...s]}}const _M=e=>e;function PM(e){return{resolve:t=>e[t]??t,keys:Object.keys(e)}}function NM(e){return{resolve:(t,r)=>e[t]?.(r)??t,keys:Object.keys(e)}}const $M={resolve:e=>e},n_=se.createContext($M);function IM({service:e,children:t}){return S.jsx(n_.Provider,{value:e,children:t})}function s_(){return se.useContext(n_)}function i_(e){if(!e)return e;let t=!1;const r={};for(const n of Object.keys(e)){const s=e[n];s instanceof h3?(r[n]=s.value,t=!0):r[n]=s}return t?r:e}function BM(e){const t=[];if(e)for(const r of Object.keys(e)){const n=e[r];n instanceof h3&&t.push(n)}return t}function jM(e,t){if(e===t)return!0;if(!e||!t)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const s of r)if(e[s]!==t[s])return!1;return!0}function a_(e){const t=se.useRef(void 0),r=se.useCallback(s=>{const i=BM(e);if(i.length===0)return()=>{};let a=!0;return gp(()=>{for(const u of i)u.value;if(a){a=!1;return}s()})},[e]),n=se.useCallback(()=>{const s=i_(e);return jM(t.current,s)?t.current:(t.current=s,s)},[e]);return se.useSyncExternalStore(r,n,n)}function OM({id:e,values:t}){const r=s_(),n=a_(t);return r.render?r.render(e,n):r.resolve(e,n)}const Ube=Object.freeze(Object.defineProperty({__proto__:null,ALLOWED_HTML_TAGS:k3,FIELD_WRAPPER:k2,I18n:OM,JsonFormRenderer:r_,JsonRendererProvider:X8,LOCALE_SERVICE:$3,LocaleProvider:IM,SchemaErrorBoundary:t_,SchemaErrorPanel:j3,allowOperatorStrings:H8,buildFormSchemaMetaSchema:fM,collectOperatorNames:kM,collectSchemaSelectors:e_,composeRegistries:hM,convertJsonToM1Tree:B3,createJsonForm:FM,createLocaleResolver:PM,createLocaleService:NM,createRenderSchemaFromJsonM1:Q8,defaultLocaleResolver:_M,defineJsonSchema:yM,defineRegistry:G8,formSchemaMetaSchema:z8,getComponentNames:q8,getDataSourceNames:J8,getFnNames:K8,getLocaleKeys:V8,isAllowedHtmlTag:_3,isArrayNode:Jn,isComponentOp:Jh,isContainerNode:ns,isDataSourceOp:S3,isFieldNode:ni,isFnOp:F3,isHtmlOp:zp,isLocaleOp:w3,isModelOp:Li,parseOperator:Mt,sanitizeHtmlProps:U8,stripDocExtensions:W8,toComponentPropsValidatorSchema:N3,unwrapSignalValues:i_,useJsonForm:wM,useJsonRendererSettings:mM,useJsonRendererSettingsUnchecked:I3,useLocale:s_,useSignalValues:a_},Symbol.toStringTag,{value:"Module"}));function Pr(e,t){let r=e;for(const n of t){if(r==null||typeof r!="object")return;r=r[n]}return r}function In(e,t,r){if(t.length===0)return r(e);const[n,...s]=t,i=e?.[n],a=In(i,s,r);if(Array.isArray(e)){const o=e.slice();return o[n]=a,o}const u={...e};return u[n]=a,u}function O3(e,t){if(t.length===0)throw new Error("removeAt: нельзя удалить корень (пустой путь)");const r=t.slice(0,-1),n=t[t.length-1];return In(e,r,s=>{if(Array.isArray(s)){const a=typeof n=="number"?n:Number(n);return s.filter((u,o)=>o!==a)}const i={...s};return delete i[n],i})}function Bc(e){return e.map(t=>"/"+String(t).replace(/~/g,"~0").replace(/\//g,"~1")).join("")}function zbe(e){return e===""?[]:e.split("/").slice(1).map(t=>t.replace(/~1/g,"/").replace(/~0/g,"~"))}function Xs(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(String(e[r])!==String(t[r]))return!1;return!0}function ml(e,t){if(e.length>t.length)return!1;for(let r=0;r<e.length;r++)if(String(e[r])!==String(t[r]))return!1;return!0}function Sl(e){let t=0,r=0;for(let n=0;n<e.length;n++){const s=e[n];s==="["||s==="("?t++:s==="]"||s===")"?t=Math.max(0,t-1):s===":"&&t===0&&(r=n+1)}return e.slice(r)}function LM(e){const t=[];let r=0,n=0;for(let s=0;s<e.length;s++){const i=e[s];i==="["||i==="("?r++:i==="]"||i===")"?r=Math.max(0,r-1):i===":"&&r===0&&(t.push(e.slice(n,s)),n=s+1)}return t}function qbe(e){return Sl(e)!==e}function MM(e){const t=/^grid-cols-(\d+)$/.exec(Sl(e));return t?Number(t[1]):void 0}function o_(e){const t=Sl(e);return t==="flex"||t==="grid"||t==="inline-flex"||t==="inline-grid"||t==="flex-row"||t==="flex-row-reverse"||t==="flex-col"||t==="flex-col-reverse"||/^grid-(cols|rows)-/.test(t)}function Jbe(e){const t=Sl(e);return/^gap(-[xy])?-/.test(t)||/^space-[xy]-/.test(t)}function u_(e){return Jn(e)?"array":ni(e)?"field":"container"}function an(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;const t=e;return"value"in t||"array"in t||"component"in t}const RM=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),UM=new Set(["Wizard","FormWizard","RendererFormWizard"]);function zM(e){const t=Mt(e.component);return t?.op==="component"&&UM.has(t.arg)}function qM(e){const t=Mt(e);return t?t.op==="component"?Up().leafComponents.has(t.arg):t.op==="html"?RM.has(t.arg):!1:!1}function xp(e){return qM(e.component)}function Mi(e,t){const r=[];if(xp(e))return r;if(Jn(e)){const n=e;return r.push({kind:"template",path:[...t,"item","$template"],single:!0,entries:[{node:n.item.$template,index:0}],length:1}),r}if(ni(e))return e.wrapper&&r.push({kind:"wrapper",path:[...t,"wrapper"],single:!0,entries:[{node:e.wrapper,index:0}],length:1}),r;if(ns(e)){const n=e,s=n.componentProps?.steps;if(Array.isArray(s)&&s.some(an)||zM(e)){const a=Array.isArray(s)?s:[];r.push({kind:"steps",path:[...t,"componentProps","steps"],single:!1,entries:yS(a),length:a.length})}Array.isArray(n.children)&&r.push({kind:"children",path:[...t,"children"],single:!1,entries:yS(n.children),length:n.children.length})}return r}function yS(e){const t=[];return e.forEach((r,n)=>{an(r)&&t.push({node:r,index:n})}),t}function L3(e){return xp(e)?!1:!!(Jn(e)||ns(e))}const JM={sm:1,md:2,lg:3,xl:4,"2xl":5};function KM(e){let t=0;for(const r of LM(e))t=Math.max(t,JM[r]??0);return t}function Th(e){if(!ns(e))return"vertical";const t=e.componentProps?.className;if(typeof t!="string")return"vertical";const r=t.split(/\s+/).filter(Boolean).filter(o_).map((a,u)=>({base:Sl(a),rank:KM(a),i:u})).sort((a,u)=>a.rank-u.rank||a.i-u.i);let n,s=!1,i=0;for(const{base:a}of r)if(a==="flex"||a==="inline-flex")n="flex";else if(a==="grid"||a==="inline-grid")n="grid";else if(a==="flex-col"||a==="flex-col-reverse")s=!0;else if(a==="flex-row"||a==="flex-row-reverse")s=!1;else{const u=MM(a);u!==void 0&&(i=u)}return n==="grid"?i>=2?"horizontal":"vertical":n==="flex"?s?"vertical":"horizontal":"vertical"}function Lg(e){return ns(e)&&e.component==="$html(div)"}function VM(e){if(!ns(e))return!1;const t=e;if(t.component!=="$html(div)")return!1;const r=t.componentProps?.className;return typeof r=="string"&&r.split(/\s+/).includes("flex")}function Kh(e,t){const r=Pr(e,t);return an(r)?r:void 0}function Pn(e){const t=e.length;if(t===0)return null;const r=e[t-1],n=e[t-2],s=e[t-3];return n==="children"&&gS(r)?e.slice(0,t-2):s==="componentProps"&&n==="steps"&&gS(r)?e.slice(0,t-3):n==="item"&&r==="$template"?e.slice(0,t-2):r==="wrapper"?e.slice(0,t-1):null}function gS(e){return typeof e=="number"||/^\d+$/.test(String(e))}function Mg(e,t){const r=e.root;if(!an(r))return;const n=(s,i)=>{t(s,i);for(const a of Mi(s,i))for(const u of a.entries)n(u.node,a.single?a.path:[...a.path,u.index])};n(r,["root"])}function bp(e){const t=new Set,r=new Set,n=new Set,s=new Set,i=a=>{if(typeof a=="string"){const u=Mt(a);u&&(u.op==="component"?t.add(u.arg):u.op==="dataSource"?r.add(u.arg):u.op==="fn"?n.add(u.arg):u.op==="locale"&&s.add(u.arg));return}if(Array.isArray(a)){a.forEach(i);return}if(a&&typeof a=="object")for(const u of Object.values(a))i(u)};return i(e.root),{components:[...t],dataSources:[...r],fns:[...n],locales:[...s]}}function Ls(e,t){const r=Pn(t);if(!r)return null;const n=Pr(e,r);if(!an(n))return null;for(const s of Mi(n,r))if(!s.single&&ml(s.path,t)&&t.length===s.path.length+1)return{slotPath:s.path,index:Number(t[t.length-1]),siblings:s.entries.map(i=>i.index),count:s.length};return null}function WM(e,t){const r=Pr(e,t);if(!an(r))return null;for(const n of Mi(r,t))if(n.entries.length!==0)return n.single?n.path:[...n.path,n.entries[0].index];return null}function HM(e,t){if(t[t.length-2]!=="children")return"vertical";const r=Pn(t);if(!r)return"vertical";const n=Pr(e,r);return an(n)?Th(n):"vertical"}function GM(e,t){const r=t==="horizontal";switch(e){case"up":return r?"out":"prev";case"down":return r?"in":"next";case"left":return r?"prev":"out";default:return r?"next":"in"}}function _2(e,t,r){return GM(r,HM(e,t))}function M3(e,t,r){const n=Ls(e,t);if(!n)return null;const s=n.siblings.indexOf(n.index);if(s<0)return null;const i=r==="prev"?s-1:s+1;return i<0||i>=n.siblings.length?null:[...n.slotPath,n.siblings[i]]}function XM(e,t){let r=Pn(t);for(;r;){const n=M3(e,r,"next");if(n)return n;r=Pn(r)}return null}function YM(e,t,r){const n=_2(e,t,r);if(n==="out")return Pn(t);if(n==="in")return WM(e,t);const s=M3(e,t,n);return s||(n==="prev"?Pn(t):XM(e,t))}function R3(e){return{version:"1.0",root:{component:"$component(Box)",componentProps:{className:"space-y-4"},children:[]}}}function P2(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;const t=e.root;return an(t)}function l_(e){if(!P2(e))throw new Error("ensureSchema: JSON не похож на JsonFormSchema (нет узла в `root`)");return QM(e)}function QM(e){let t=!1;const r=s=>{if(Array.isArray(s)){const u=s.map(r);return t?u:s}if(s==null||typeof s!="object")return s;const i=s,a={};for(const u of Object.keys(i)){if(u==="text"&&an(i)){const o=Array.isArray(i.text)?i.text:[i.text],c=Array.isArray(i.children)?i.children.map(r):[];a.children=[...o,...c],t=!0;continue}u==="children"&&a.children!==void 0||(a[u]=r(i[u]))}return t?a:s},n=r(e);return t?n:e}const zn=e=>structuredClone(e),c_="flex gap-4",U3="flex flex-col gap-4";function p_(e){if(!e||!ns(e))return!1;const t=e;if(t.component!=="$html(div)")return!1;const r=t.children;if(!Array.isArray(r)||r.length!==1)return!1;const n=t.componentProps?.className;if(typeof n!="string")return!1;const s=n.split(/\s+/);return s.includes("flex")||s.includes("grid")}function N2(e,t,r,n){return{schema:In(e,[...t,"componentProps"],i=>{const a={...i};return n===void 0?delete a[r]:a[r]=n,a}),newPath:t}}function d_(e,t,r,n){return{schema:In(e,t,i=>{const a={...i};return n===void 0?delete a[r]:a[r]=n,a}),newPath:t}}function ZM(e,t,r){return{schema:In(e,t,s=>{const i={...s},a=Array.isArray(i.children)?[...i.children]:[],u=a.findIndex(o=>typeof o=="string"||typeof o=="number");return r===""?u>=0&&a.splice(u,1):u>=0?a[u]=r:a.unshift(r),a.length===0&&!Array.isArray(i.children)?delete i.children:i.children=a,i}),newPath:t}}function eR(e){const t=e.children;if(!Array.isArray(t))return-1;const r=t.reduce((n,s,i)=>((typeof s=="string"||typeof s=="number")&&n.push(i),n),[]);return r.length>1?null:r.length===1?r[0]:-1}function tR(e,t,r){return d_(e,t,"component",r)}function rR(e,t,r,n){const s=tR(e,t,`$component(${r})`),i=Pr(s.schema,[...t,"componentProps"]);return i==null||typeof i!="object"?s:{schema:In(s.schema,[...t,"componentProps"],u=>{const o={};for(const[c,p]of Object.entries(u))n.has(c)&&(o[c]=p);return o}),newPath:t}}function Vh(e,t,r,n){let s=r;return{schema:In(e,t,a=>{const u=Array.isArray(a)?a.slice():[],o=Math.max(0,Math.min(r,u.length));return s=o,u.splice(o,0,n),u}),newPath:[...t,s]}}function nR(e,t,r){const n=Pr(e,t),s=Array.isArray(n)?n.length:0;return Vh(e,t,s,r)}function Kbe(e,t){const r=O3(e,t),n=Pn(t)??["root"],s=Pr(r,n);if(p_(s)){const i=s.children[0];return{schema:In(r,n,()=>zn(i)),newPath:n}}return{schema:r,newPath:n}}function z3(e,t,r,n){const s=Pr(e,t);if(!s)return{schema:e,newPath:t};const i=zn(s);let a=O3(e,t);const u=Pn(t);if(u&&!ml(u,r)){const d=Pr(a,u);if(p_(d)){const h=d.children[0];a=In(a,u,()=>zn(h))}}const o=t.slice(0,-1),c=Number(t[t.length-1]);let p=n;return Xs(o,r)&&c<n&&(p=n-1),Vh(a,r,p,i)}function Vbe(e,t){const r=Pr(e,t),n=t.slice(0,-1),s=Number(t[t.length-1]),i=Pr(e,n);return!r||!Array.isArray(i)?{schema:e,newPath:t}:Vh(e,n,s+1,zn(r))}function sR(e,t,r,n,s){const i=Pr(e,t);if(!Array.isArray(i)||n<=0||r<0||r+n>i.length)return null;const a=s==="up"?r:r+n;return{schema:In(e,t,o=>{const c=o.slice(),p=c.slice(r,r+n).map(d=>zn(d));return c.splice(a,0,...p),c}),newStart:a}}function iR(e,t,r,n,s){const i=Pr(e,t);if(!Array.isArray(i))return null;const a=r+s;return a<0||a+n>i.length?null:{schema:In(e,t,o=>{const c=o.slice(),p=c.splice(r,n);return c.splice(a,0,...p),c}),newStart:a}}function aR(e,t,r,n){return In(e,t,s=>{const i=Array.isArray(s)?s.slice():[];return i.splice(r,n),i})}function oR(e,t,r){const n=[...new Set(r)].sort((i,a)=>a-i);let s=e;for(const i of n)s=aR(s,t,i,1);return s}function uR(e,t,r,n,s){const i=Pr(e,t);if(!Array.isArray(i)||n<1)return{schema:e,newPath:[...t,r]};const a=i.slice(r,r+n).map(zn),u={component:"$html(div)",componentProps:{className:s?.className??U3},children:a};return{schema:In(e,t,c=>{const p=c.slice();return p.splice(r,n,u),p}),newPath:[...t,r]}}function lR(e,t){const r=Pr(e,t);if(!r||!Lg(r))return{schema:e,newPath:t};const n=r.children,s=t.slice(0,-1),i=t[t.length-1];return!Array.isArray(n)||typeof i!="number"?{schema:e,newPath:t}:{schema:In(e,s,u=>{const o=u.slice();return o.splice(i,1,...n.map(zn)),o}),newPath:[...s,i]}}function f_(e,t,r,n,s){const i=Pr(e,t);if(!i)return{schema:e,newPath:t};const a=n==="before"?[zn(r),zn(i)]:[zn(i),zn(r)],u={component:"$html(div)",componentProps:{className:s?.className??c_},children:a};return{schema:In(e,t,()=>u),newPath:[...t,"children",n==="before"?0:1]}}function h_(e,t,r,n,s){if(ml(r,t)||ml(t,r))return{schema:e,newPath:t};const i=Pr(e,t),a=Pr(e,r);if(!i||!a)return{schema:e,newPath:t};const u=zn(i),o=zn(a),c=O3(e,r);let p=t;const d=r.slice(0,-1),h=t.slice(0,-1),m=r[r.length-1],y=t[t.length-1];Xs(d,h)&&typeof m=="number"&&typeof y=="number"&&m<y&&(p=[...h,y-1]);const v=n==="before"?[o,u]:[u,o],b={component:"$html(div)",componentProps:{className:s?.className??c_},children:v};return{schema:In(c,p,()=>b),newPath:[...p,"children",n==="before"?0:1]}}function cR(e,t,r,n,s){return f_(e,t,r,n,{className:s?.className??U3})}function pR(e,t,r,n,s){return h_(e,t,r,n,{className:s?.className??U3})}function dR(e,t){const r=(e??"").split(/\s+/).filter(Boolean).filter(n=>n==="flex"||!o_(n));return r.includes("flex")||r.unshift("flex"),t||r.splice(r.indexOf("flex")+1,0,"flex-col"),r.join(" ")}function fR(e){const t=e.split(/\s+/).filter(Boolean),r=i=>Sl(i).startsWith("flex-col"),n=i=>Sl(i).startsWith("flex-row");if(t.findIndex(r)>=0)for(let i=t.length-1;i>=0;i--)r(t[i])&&t.splice(i,1);else{for(let a=t.length-1;a>=0;a--)n(t[a])&&t.splice(a,1);const i=t.indexOf("flex");t.splice(i>=0?i+1:0,0,"flex-col")}return t.join(" ")}function m_(e,t){const r=Pr(e,t);if(!r||!ns(r))return{schema:e,newPath:t};const n=r.componentProps?.className,s=dR(typeof n=="string"?n:void 0,Th(r)!=="horizontal");return{schema:In(e,t,a=>{const u=a;return{...u,componentProps:{...u.componentProps??{},className:s}}}),newPath:t}}function hR(e,t,r,n,s){const i=Pr(e,t),a=Pr(e,r),u=Pr(e,n);if(!i||!a||!u)return{schema:e,newPath:r};const o=i.componentProps?.className,c=typeof o=="string"?fR(o):o,p=s==="before"?[zn(u),zn(a)]:[zn(a),zn(u)];return{schema:In(e,t,h=>{const m=h;return{...m,componentProps:{...m.componentProps??{},className:c},children:p}}),newPath:[...t,"children",s==="before"?0:1]}}function mR(){const e=Ca().ui,t=e?.leftPanel!==void 0?e.leftPanel:"files";return{preview:e?.preview??"wire",runtimeMode:e?.runtimeMode??"test",liveSchemas:!1,hideDivWrappers:e?.hideDivWrappers??!1,quickAddOpen:!1,rawJsonOpen:!1,bottomTab:e?.bottomTab??"raw",leftPanel:t,lastLeftPanel:t??"files",rightPanel:e?.rightOpen??!0?"inspector":null,lastRightPanel:"inspector",theme:e?.theme??"light",revealLine:null,revealNonce:0}}function yR(){return{tabs:{},order:[],activeTabId:null,ui:mR()}}function y_(e,t,r,n=!1){return{id:e,source:t,kind:"form",schema:r,savedSchema:r,past:[],future:[],selectionPath:["root"],selectionPaths:[["root"]],anchorPath:["root"],hoverPath:null,activeStep:0,touched:!1,preview:n,lastCoalesceKey:null}}function gR(e,t,r,n,s=!1,i="code"){const a=R3();return{id:e,source:t,kind:"code",schema:a,savedSchema:a,text:r,savedText:r,language:n,mdView:i,past:[],future:[],selectionPath:null,selectionPaths:[],anchorPath:null,hoverPath:null,activeStep:0,touched:!1,preview:s,lastCoalesceKey:null}}function DR(e){return e.order.find(t=>e.tabs[t]?.preview)??null}function g_(e,t){const r=t.preview?DR(e):null;if(r==null)return{...e,tabs:{...e.tabs,[t.id]:t},order:[...e.order,t.id],activeTabId:t.id};const n={...e.tabs,[t.id]:t};return delete n[r],{...e,tabs:n,order:e.order.map(s=>s===r?t.id:s),activeTabId:t.id}}function xR(e,t,r,n,s={}){const i=s.preview??!1;return e.tabs[t]?K3(i?e:q3(e,t),t):g_(e,y_(t,r,n,i))}function bR(e,t){const r=t.filter(s=>!e.tabs[s.id]);if(!r.length)return e;const n={...e.tabs};for(const s of r)n[s.id]=s;return{...e,tabs:n,order:[...e.order,...r.map(s=>s.id)],activeTabId:e.activeTabId??r[r.length-1].id}}function vR(e,t,r,n,s,i={}){const a=i.preview??!1;return e.tabs[t]?K3(a?e:q3(e,t),t):g_(e,gR(t,r,n,s,a,i.mdView))}function ER(e,t,r){const n=e.tabs[t];return!n||n.kind!=="code"||n.mdView===r?e:{...e,tabs:{...e.tabs,[t]:{...n,mdView:r}}}}function q3(e,t){const r=e.tabs[t];return!r||!r.preview?e:{...e,tabs:{...e.tabs,[t]:{...r,preview:!1}}}}function CR(e,t,r){const n=e.tabs[t];return!n||n.kind!=="code"||n.text===r?e:{...e,tabs:{...e.tabs,[t]:{...n,text:r,preview:!1}}}}function TR(e,t,r,n){const s=e.tabs[t];if(!s||s.mock?.[r]===n)return e;const i={...s.mock,[r]:n};return{...e,tabs:{...e.tabs,[t]:{...s,mock:i}}}}function AR(e,t,r){const n=e.tabs[t];if(!n||n.mock?.[r]===void 0)return e;const s={...n.mock};delete s[r];const i={...n,mock:s};return Object.keys(s).length===0&&delete i.mock,{...e,tabs:{...e.tabs,[t]:i}}}function SR(e){return mn(e,t=>t.kind==="code"?{...t,savedText:t.text}:t)}function FR(e,t){if(!e.tabs[t])return e;const r={...e.tabs};delete r[t];const n=e.order.filter(i=>i!==t);let s=e.activeTabId;if(s===t){const i=e.order.indexOf(t);s=n[Math.min(i,n.length-1)]??null}return{...e,tabs:r,order:n,activeTabId:s}}function J3(e,t,r){if(t.size===0)return e;const n={...e.tabs};for(const a of t)delete n[a];const s=e.order.filter(a=>!t.has(a)),i=e.activeTabId&&t.has(e.activeTabId)?r:e.activeTabId;return{...e,tabs:n,order:s,activeTabId:i}}function wR(e,t){return e.tabs[t]?J3(e,new Set(e.order.filter(r=>r!==t)),t):e}function kR(e,t){const r=e.order.indexOf(t);return r<=0?e:J3(e,new Set(e.order.slice(0,r)),t)}function _R(e,t){const r=e.order.indexOf(t);return r<0||r>=e.order.length-1?e:J3(e,new Set(e.order.slice(r+1)),t)}function K3(e,t){return e.tabs[t]?{...e,activeTabId:t}:e}function mn(e,t){const r=e.activeTabId;if(!r||!e.tabs[r])return e;const n=t(e.tabs[r]);return n===e.tabs[r]?e:{...e,tabs:{...e.tabs,[r]:n}}}function ga(e,t,r){const n=r!=null&&r===e.lastCoalesceKey,s={schema:e.schema,selectionPath:e.selectionPath},i=n?e.past:[...e.past,s].slice(-100),a=t.selectionPaths??(t.selectionPath?[t.selectionPath]:[]);return{...e,schema:t.schema,selectionPath:t.selectionPath,selectionPaths:a,anchorPath:t.anchorPath!==void 0?t.anchorPath:t.selectionPath,past:i,future:[],touched:!0,preview:!1,lastCoalesceKey:r??null}}function DS(e,t,r){return mn(e,n=>ga(n,{schema:t.schema,selectionPath:t.newPath},r?.coalesceKey))}function PR(e,t){return mn(e,r=>ga(r,{schema:t,selectionPath:r.selectionPath}))}function NR(e){return mn(e,t=>{if(!t.past.length)return t;const r=t.past[t.past.length-1],n={schema:t.schema,selectionPath:t.selectionPath};return{...t,schema:r.schema,selectionPath:r.selectionPath,selectionPaths:r.selectionPath?[r.selectionPath]:[],anchorPath:r.selectionPath,past:t.past.slice(0,-1),future:[n,...t.future],lastCoalesceKey:null}})}function $R(e){return mn(e,t=>{if(!t.future.length)return t;const r=t.future[0],n={schema:t.schema,selectionPath:t.selectionPath};return{...t,schema:r.schema,selectionPath:r.selectionPath,selectionPaths:r.selectionPath?[r.selectionPath]:[],anchorPath:r.selectionPath,past:[...t.past,n].slice(-100),future:t.future.slice(1),lastCoalesceKey:null}})}function IR(e){return mn(e,t=>({...t,savedSchema:t.schema}))}function BR(e,t,r){return mn(e,n=>({...n,savedSchema:n.schema,source:{...n.source,rawText:t,lastModified:r??n.source.lastModified}}))}function jR(e,t){return mn(e,r=>({...r,selectionPath:t,selectionPaths:t?[t]:[],anchorPath:t}))}function OR(e,t){return mn(e,r=>({...r,hoverPath:t}))}function LR(e,t){return mn(e,r=>({...r,activeStep:t}))}function V3(e){const t=e.selectionPaths.length?e.selectionPaths:e.selectionPath?[e.selectionPath]:[];if(!t.length)return null;const r=t.map(i=>Ls(e.schema,i));if(r.some(i=>i===null))return null;const n=r[0].slotPath;if(!r.every(i=>Xs(i.slotPath,n)))return null;const s=r.map(i=>i.index).sort((i,a)=>i-a);for(let i=1;i<s.length;i++)if(s[i]!==s[i-1]+1)return null;return{slotPath:n,start:s[0],count:s.length}}function MR(e){const t=e.selectionPaths.length?e.selectionPaths:e.selectionPath?[e.selectionPath]:[];if(!t.length)return null;const r=t.map(s=>Ls(e.schema,s));if(r.some(s=>s===null))return null;const n=r[0].slotPath;return r.every(s=>Xs(s.slotPath,n))?{slotPath:n,indices:r.map(s=>s.index)}:null}function ub(e,t){const r=Mi(e,t).find(n=>!n.single);return r?{slotPath:r.path,count:r.length}:!xp(e)&&ns(e)?{slotPath:[...t,"children"],count:0}:null}function RR(e,t,r=!1){return mn(e,n=>{const s=n.selectionPath??["root"],i=_2(n.schema,s,t);if(r&&(i==="prev"||i==="next")){const u=M3(n.schema,s,i);if(!u)return n;const o=n.anchorPath??s,c=Ls(n.schema,o),p=Ls(n.schema,u);if(c&&p&&Xs(c.slotPath,p.slotPath)){const d=Math.min(c.index,p.index),h=Math.max(c.index,p.index),m=[];for(let y=d;y<=h;y++)m.push([...c.slotPath,y]);return{...n,selectionPath:u,selectionPaths:m,anchorPath:o}}return{...n,selectionPath:u,selectionPaths:[u],anchorPath:u}}const a=YM(n.schema,s,t);return a?{...n,selectionPath:a,selectionPaths:[a],anchorPath:a}:n})}function UR(e){return mn(e,t=>{if(t.selectionPaths.length>1){const n=t.selectionPath;return{...t,selectionPaths:n?[n]:[],anchorPath:n}}const r=t.selectionPath?Pn(t.selectionPath):null;return{...t,selectionPath:r,selectionPaths:r?[r]:[],anchorPath:r}})}function zR(e,t){const r=Pn(t);if(!r)return null;const n=Ls(e,r);return n?z3(e,t,n.slotPath,n.index+1):null}function qR(e,t){const r=Ls(e,t);if(!r||r.index===0)return null;const n=[...r.slotPath,r.index-1],s=Pr(e,n);if(!s||!L3(s))return null;const i=Mi(s,n).find(a=>!a.single);return i?z3(e,t,i.path,i.length):null}function JR(e,t){return mn(e,r=>{const n=V3(r);if(!n)return r;const s=_2(r.schema,[...n.slotPath,n.start],t);if(s==="prev"||s==="next"){const u=iR(r.schema,n.slotPath,n.start,n.count,s==="prev"?-1:1);if(!u)return r;const o=[];for(let d=0;d<n.count;d++)o.push([...n.slotPath,u.newStart+d]);const c=r.selectionPath?Ls(r.schema,r.selectionPath):null,p=c?Math.max(0,Math.min(c.index-n.start,n.count-1)):n.count-1;return ga(r,{schema:u.schema,selectionPath:[...n.slotPath,u.newStart+p],selectionPaths:o,anchorPath:o[0]})}if(n.count!==1)return r;const i=[...n.slotPath,n.start],a=s==="out"?zR(r.schema,i):qR(r.schema,i);return a?ga(r,{schema:a.schema,selectionPath:a.newPath}):r})}function KR(e){return mn(e,t=>{const r=MR(t);if(!r)return t;const n=oR(t.schema,r.slotPath,r.indices),s=Pr(n,r.slotPath),i=Array.isArray(s)?s.length:0,a=Math.min(...r.indices),u=i>0?[...r.slotPath,Math.min(a,i-1)]:Pn([...r.slotPath,0])??["root"];return ga(t,{schema:n,selectionPath:u})})}function VR(e,t){return mn(e,r=>{const n=V3(r);if(!n)return r;const s=t?_2(r.schema,[...n.slotPath,n.start],t):"next";if(s!=="prev"&&s!=="next")return r;const i=sR(r.schema,n.slotPath,n.start,n.count,s==="prev"?"up":"down");if(!i)return r;const a=[];for(let c=0;c<n.count;c++)a.push([...n.slotPath,i.newStart+c]);const u=r.selectionPath?Ls(r.schema,r.selectionPath):null,o=u?Math.max(0,Math.min(u.index-n.start,n.count-1)):n.count-1;return ga(r,{schema:i.schema,selectionPath:[...n.slotPath,i.newStart+o],selectionPaths:a,anchorPath:a[0]})})}function WR(e,t){return mn(e,r=>{const n=r.selectionPath,s=n?Pr(r.schema,n):void 0;let i,a;const u=n&&s&&L3(s)?ub(s,n):null;if(n&&u)i=u.slotPath,a=u.count;else if(n){const c=Ls(r.schema,n);if(c)i=c.slotPath,a=c.index+1;else{const p=Pn(n)??["root"],d=Pr(r.schema,p),h=d?ub(d,p):null;if(!h)return r;i=h.slotPath,a=h.count}}else{const c=ub(r.schema.root,["root"]);if(!c)return r;i=c.slotPath,a=c.count}const o=Vh(r.schema,i,a,t);return ga(r,{schema:o.schema,selectionPath:o.newPath})})}function HR(e){return mn(e,t=>{const r=V3(t);if(!r)return t;const n=uR(t.schema,r.slotPath,r.start,r.count);return ga(t,{schema:n.schema,selectionPath:n.newPath})})}function GR(e){return mn(e,t=>{if(!t.selectionPath)return t;const r=lR(t.schema,t.selectionPath);return r.schema===t.schema?t:ga(t,{schema:r.schema,selectionPath:r.newPath})})}function XR(e){return mn(e,t=>{if(!t.selectionPath)return t;const r=Pr(t.schema,t.selectionPath);if(!r||!Lg(r))return t;const n=m_(t.schema,t.selectionPath);return ga(t,{schema:n.schema,selectionPath:t.selectionPath})})}function YR(e,t){return mn(e,r=>{const n=r.anchorPath??r.selectionPath??t,s=Ls(r.schema,n),i=Ls(r.schema,t);if(s&&i&&Xs(s.slotPath,i.slotPath)){const a=Math.min(s.index,i.index),u=Math.max(s.index,i.index),o=[];for(let c=a;c<=u;c++)o.push([...s.slotPath,c]);return{...r,selectionPath:t,selectionPaths:o,anchorPath:n}}return{...r,selectionPath:t,selectionPaths:[t],anchorPath:t}})}function QR(e,t){return mn(e,r=>{if(r.selectionPaths.some(a=>Xs(a,t))){const a=r.selectionPaths.filter(o=>!Xs(o,t)),u=a[a.length-1]??null;return{...r,selectionPaths:a,selectionPath:u,anchorPath:u}}const s=Ls(r.schema,t);return r.selectionPaths.length===0||s!=null&&r.selectionPaths.every(a=>{const u=Ls(r.schema,a);return u!=null&&Xs(u.slotPath,s.slotPath)})?{...r,selectionPath:t,selectionPaths:[...r.selectionPaths,t],anchorPath:t}:{...r,selectionPath:t,selectionPaths:[t],anchorPath:t}})}function ZR(e,t){return{...e,ui:{...e.ui,preview:t}}}function D_(e,t){return{...e,ui:{...e.ui,runtimeMode:t}}}function eU(e){return D_(e,e.ui.runtimeMode==="edit"?"test":"edit")}function tU(e,t){return{...e,ui:{...e.ui,liveSchemas:t}}}function rU(e){return{...e,ui:{...e.ui,rawJsonOpen:!e.ui.rawJsonOpen}}}function nU(e,t){return{...e,ui:{...e.ui,bottomTab:t}}}function sU(e){return{...e,ui:{...e.ui,hideDivWrappers:!e.ui.hideDivWrappers}}}function xS(e,t){return{...e,ui:{...e.ui,quickAddOpen:t}}}function iU(e,t){return{...e,ui:{...e.ui,rawJsonOpen:!0,revealLine:t,revealNonce:e.ui.revealNonce+1}}}function aU(e,t){return{...e,ui:{...e.ui,leftPanel:t,lastLeftPanel:t??e.ui.lastLeftPanel}}}function oU(e){const t=e.ui.leftPanel===null?e.ui.lastLeftPanel:null;return{...e,ui:{...e.ui,leftPanel:t}}}function x_(e,t){return{...e,ui:{...e.ui,rightPanel:t,lastRightPanel:t??e.ui.lastRightPanel}}}function uU(e){const t=e.ui.rightPanel===null?e.ui.lastRightPanel:null;return{...e,ui:{...e.ui,rightPanel:t}}}function lU(e,t){return x_(e,e.ui.rightPanel===t?null:t)}function cU(e,t){return{...e,ui:{...e.ui,theme:t}}}function $i(e){return e.activeTabId?e.tabs[e.activeTabId]??null:null}function b_(e){return e.kind==="code"?e.text!==e.savedText:e.schema!==e.savedSchema}function $2(e){return e.kind==="code"?!1:e.source.kind==="new"?!0:e.source.kind==="template"&&e.touched}const mt=Bl(yR()),Xe={openTab:(e,t,r,n)=>mt.setState(s=>xR(s,e,t,r,n)),restoreTabs:e=>mt.setState(t=>bR(t,e)),openCodeTab:(e,t,r,n,s)=>mt.setState(i=>vR(i,e,t,r,n,s)),pinTab:e=>mt.setState(t=>q3(t,e)),setTabText:(e,t)=>mt.setState(r=>CR(r,e,t)),setMdView:(e,t)=>mt.setState(r=>ER(r,e,t)),setMockText:(e,t,r)=>mt.setState(n=>TR(n,e,t,r)),resetMock:(e,t)=>mt.setState(r=>AR(r,e,t)),markCodeSaved:()=>mt.setState(SR),closeTab:e=>mt.setState(t=>FR(t,e)),closeOtherTabs:e=>mt.setState(t=>wR(t,e)),closeTabsToLeft:e=>mt.setState(t=>kR(t,e)),closeTabsToRight:e=>mt.setState(t=>_R(t,e)),setActiveTab:e=>mt.setState(t=>K3(t,e)),commit:(e,t)=>mt.setState(r=>DS(r,e,t)),apply:(e,t)=>mt.setState(r=>{const n=$i(r);return n?DS(r,e(n.schema),t):r}),replaceSchema:e=>mt.setState(t=>PR(t,e)),undo:()=>mt.setState(NR),redo:()=>mt.setState($R),markSaved:()=>mt.setState(IR),commitSaved:(e,t)=>mt.setState(r=>BR(r,e,t)),select:e=>mt.setState(t=>jR(t,e)),setHover:e=>mt.setState(t=>OR(t,e)),setActiveStep:e=>mt.setState(t=>LR(t,e)),navigate:(e,t)=>mt.setState(r=>RR(r,e,t)),moveSelection:e=>mt.setState(t=>JR(t,e)),deleteSelection:()=>mt.setState(KR),duplicateSelection:e=>mt.setState(t=>VR(t,e)),collapseSelection:()=>mt.setState(UR),groupSelection:()=>mt.setState(HR),ungroupSelection:()=>mt.setState(GR),flipSelection:()=>mt.setState(XR),extendSelectionTo:e=>mt.setState(t=>YR(t,e)),toggleSelectionAt:e=>mt.setState(t=>QR(t,e)),setPreview:e=>mt.setState(t=>ZR(t,e)),setRuntimeMode:e=>mt.setState(t=>D_(t,e)),toggleRuntimeMode:()=>mt.setState(eU),setLiveSchemas:e=>mt.setState(t=>tU(t,e)),toggleRawJson:()=>mt.setState(rU),setBottomTab:e=>mt.setState(t=>nU(t,e)),toggleHideDivWrappers:()=>mt.setState(sU),openQuickAdd:()=>mt.setState(e=>xS(e,!0)),closeQuickAdd:()=>mt.setState(e=>xS(e,!1)),addComponent:e=>mt.setState(t=>WR(t,e)),revealRawLine:e=>mt.setState(t=>iU(t,e)),setLeftPanel:e=>mt.setState(t=>aU(t,e)),toggleLeftPanel:()=>mt.setState(oU),setRightPanel:e=>mt.setState(t=>x_(t,e)),toggleRightPanel:()=>mt.setState(uU),toggleRightPanelTo:e=>mt.setState(t=>lU(t,e)),setTheme:e=>mt.setState(t=>cU(t,e))};function qp(e){return se.useSyncExternalStore(mt.subscribe,()=>e(mt.getState()),()=>e(mt.getState()))}function jl(){return qp($i)}function vi(){return qp(e=>e.ui)}function I2(){return qp(e=>$i(e)?.selectionPath??null)}function pU(){return qp(e=>e.order)}function v_(){return qp(e=>e.activeTabId)}function dU(e){return qp(t=>t.tabs[e])}const fU="reformer-builder",hU=3,Rg="handles",vp="templates",Ah="drafts";function mU(){return new Promise((e,t)=>{const r=indexedDB.open(fU,hU);r.onupgradeneeded=()=>{const n=r.result;n.objectStoreNames.contains(Rg)||n.createObjectStore(Rg),n.objectStoreNames.contains(vp)||n.createObjectStore(vp),n.objectStoreNames.contains(Ah)||n.createObjectStore(Ah)},r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)})}function yo(e,t,r){return mU().then(n=>new Promise((s,i)=>{const a=r(n.transaction(e,t).objectStore(e));a.onsuccess=()=>s(a.result),a.onerror=()=>i(a.error)}))}async function yU(){try{return(await yo(Ah,"readonly",t=>t.getAll())).sort((t,r)=>t.createdAt-r.createdAt)}catch(e){return console.warn("[reformer-builder] черновики недоступны:",e),[]}}async function gU(e){await yo(Ah,"readwrite",t=>t.put(e,e.id))}async function DU(e){await yo(Ah,"readwrite",t=>t.delete(e))}const xU=400;function E_(e){const t=new Map;for(const r of e.order){const n=e.tabs[r];n&&$2(n)&&t.set(r,n)}return t}function bU(e,t){return e.schema!==t.schema||e.savedSchema!==t.savedSchema||e.mock!==t.mock||e.source!==t.source||e.activeStep!==t.activeStep||e.touched!==t.touched}function vU(e,t){const r=e,n=E_(t),s=[];for(const[a,u]of n){const o=r.get(a);(!o||bU(o,u))&&s.push(u)}const i=[];for(const a of r.keys())n.has(a)||i.push(a);return{save:s,remove:i}}function EU(e,t,r){return{id:e.id,source:e.source,schema:e.schema,savedSchema:e.savedSchema,mock:e.mock,activeStep:e.activeStep,touched:e.touched,createdAt:t,updatedAt:r}}function CU(e){return{...y_(e.id,e.source,e.schema),savedSchema:e.savedSchema,mock:e.mock,activeStep:e.activeStep,touched:e.touched}}function TU(e=[]){const t=new Map(e.map(o=>[o.id,o.createdAt])),r=new Set(e.map(o=>o.id)),n=new Map;for(const[o,c]of E_(mt.getState()))r.has(o)&&n.set(o,c);let s=null;const i=()=>{s=null;const{save:o,remove:c}=vU(n,mt.getState()),p=Date.now();for(const d of o){const h=t.get(d.id)??p;t.set(d.id,h),n.set(d.id,d),gU(EU(d,h,p)).catch(m=>{console.warn("[reformer-builder] черновик не сохранён:",d.id,m)})}for(const d of c)t.delete(d),n.delete(d),C_(d)},a=()=>{s==null&&(s=setTimeout(i,xU))},u=mt.subscribe(a);return a(),()=>{s!=null&&clearTimeout(s),u()}}function C_(e){return DU(e).catch(t=>{console.warn("[reformer-builder] черновик не удалён:",e,t)})}const ip=Bl({plan:null,saving:!1}),Ga={open:e=>ip.setState({plan:e,saving:!1}),close:()=>ip.setState({plan:null,saving:!1}),setSaving:e=>ip.setState(t=>({...t,saving:e}))};function AU(){return se.useSyncExternalStore(ip.subscribe,()=>ip.getState(),()=>ip.getState())}function SU(){const e=BO(),t=jO(e);return LO(t),OO(e,t)}const FU=["Control","Options","Textfield","Behavior","State"];function wU(e){const t=e.properties??{},r=[];for(const[n,s]of Object.entries(t)){const i=s["x-doc"];r.push({key:n,label:NU(n),widget:n==="iconName"?"icon":n==="className"?"className":n==="testId"?"text":i?.group==="Options"&&s.type==="array"?"dataSource":i?.kind??PU(s),group:i?.group??"Control",description:typeof s.description=="string"?s.description:void 0,default:s.default,options:Array.isArray(s.enum)?s.enum:void 0,min:typeof s.minimum=="number"?s.minimum:void 0,max:typeof s.maximum=="number"?s.maximum:void 0,step:typeof s.multipleOf=="number"?s.multipleOf:void 0})}return r}function kU(e){const t=new Map;for(const r of e){const n=t.get(r.group)??[];n.push(r),t.set(r.group,n)}return FU.filter(r=>t.has(r)).map(r=>({group:r,props:t.get(r)}))}function _U(e){return kU(wU(e))}function PU(e){if(Array.isArray(e.enum))return"enum";const t=e.type;return t==="boolean"?"boolean":t==="number"||t==="integer"?"number":"text"}function NU(e){return e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase()).trim()}function B2(e){return Ta().filter(t=>t.compoundParent===e)}function $U(e){return B2(e).map(t=>t.name)}function W3(e){return e.compoundParent!==void 0}const Ug=new Map,bS="(all)";function IU(e){const t=Ug.get(e);if(t)return t;Ta();const{styles:r,classGroupPolicy:n}=Up(),s=n.get(e),i=s?r.classNames.filter(u=>s.has(u.id)):r.classNames,a=Array.from(new Set(i.flatMap(u=>u.classes)));return Ug.set(e,a),a}function BU(){const e=Ug.get(bS);if(e)return e;Ta();const t=Array.from(new Set(Up().styles.classNames.flatMap(r=>r.classes)));return Ug.set(bS,t),t}function jU(e,t){if(!e.length)return[];const r=new Set(e);return Array.from(new Set(t.split(/\s+/).filter(Boolean))).filter(n=>!r.has(n))}function OU(e,t,r,n){const s=t.toLowerCase();if(!s)return[];const i=[];for(const a of e)if(a.toLowerCase().includes(s)&&(a===t||!r.has(a))&&i.push(a),i.length===n)break;return i}const LU=["HTML","Типографика","Поля ввода","Выбор и переключатели","Контейнеры","Действия","Отображение","Массив","Оверлеи","Навигация","Чат","Прочее"],MU="Прочее";function RU(){const e=Ca().palette?.order;return e&&e.length?e:LU}function T_(e){return e.startsWith("$html(")&&e.endsWith(")")?e.slice(6,-1):null}function H3(e){return T_(e.name)??e.name}function A_(e){const t=new Map;for(const i of e){const a=i.category??MU,u=t.get(a)??[];u.push(i),t.set(a,u)}const r=RU(),n=r.filter(i=>t.has(i)).map(i=>[i,t.get(i)]),s=[...t.keys()].filter(i=>!r.includes(i)).map(i=>[i,t.get(i)]);return[...n,...s]}let UU=null;function Ta(){return UU??=SU()}function ll(e){return Ta().find(t=>t.name===e)}function zU(e){return typeof e=="function"||typeof e=="object"&&e!==null&&"$$typeof"in e}function S_(e){return e.role!=="array"&&!e.name.startsWith("$html(")}function qU(e,t){const r=t[b8(e)];return zU(r)?r:void 0}function JU(e,t,r=Up()){const{name:n,compoundParent:s}=e,i=r.previewPolicy.get(n)??(s?r.previewPolicy.get(s):void 0);if(i?.mode==="limited")return{policy:"limited",reason:i.reason??"предпросмотр ограничен"};const a=qU(e,t);return a?{policy:"live",component:a}:{policy:"limited",reason:r.unresolvedReason.get(n)??(s?r.unresolvedReason.get(s):void 0)??`не резолвится в ${r.package}`}}const KU=["__selfManagedChildren","reformerNeedsControl","reformerLayout"];class VU extends se.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}render(){const{error:t}=this.state;return t?S.jsxs("div",{className:`rounded-md border border-dashed border-destructive/50 bg-destructive/5 p-3 text-xs text-destructive ${this.props.className??""}`,children:[S.jsxs("span",{className:"font-mono font-semibold",children:["⚠ ",this.props.name]}),S.jsx("span",{className:"ml-2 opacity-80",children:"— компонент упал при рендере"}),S.jsx("div",{className:"mt-1 font-mono text-[11px] opacity-70",children:t.message})]}):this.props.children}}function vS(e,t){function r(n){return S.jsx(VU,{name:t,className:n.className,children:S.jsx(e,{...n})})}r.displayName=`Isolated(${t})`;for(const n of KU){const s=e[n];s!==void 0&&(r[n]=s)}return r}function F_(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(r=F_(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function WU(){for(var e,t,r=0,n="",s=arguments.length;r<s;r++)(e=arguments[r])&&(t=F_(e))&&(n&&(n+=" "),n+=t);return n}const HU=(e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r},GU=(e,t)=>({classGroupId:e,validator:t}),w_=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),zg="-",ES=[],XU="arbitrary..",YU=e=>{const t=ZU(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return QU(a);const u=a.split(zg),o=u[0]===""&&u.length>1?1:0;return k_(u,o,t)},getConflictingClassGroupIds:(a,u)=>{if(u){const o=n[a],c=r[a];return o?c?HU(c,o):o:c||ES}return r[a]||ES}}},k_=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const s=e[t],i=r.nextPart.get(s);if(i){const c=k_(e,t+1,i);if(c)return c}const a=r.validators;if(a===null)return;const u=t===0?e.join(zg):e.slice(t).join(zg),o=a.length;for(let c=0;c<o;c++){const p=a[c];if(p.validator(u))return p.classGroupId}},QU=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?XU+n:void 0})(),ZU=e=>{const{theme:t,classGroups:r}=e;return ez(r,t)},ez=(e,t)=>{const r=w_();for(const n in e){const s=e[n];G3(s,r,n,t)}return r},G3=(e,t,r,n)=>{const s=e.length;for(let i=0;i<s;i++){const a=e[i];tz(a,t,r,n)}},tz=(e,t,r,n)=>{if(typeof e=="string"){rz(e,t,r);return}if(typeof e=="function"){nz(e,t,r,n);return}sz(e,t,r,n)},rz=(e,t,r)=>{const n=e===""?t:__(t,e);n.classGroupId=r},nz=(e,t,r,n)=>{if(iz(e)){G3(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(GU(r,e))},sz=(e,t,r,n)=>{const s=Object.entries(e),i=s.length;for(let a=0;a<i;a++){const[u,o]=s[a];G3(o,__(t,u),r,n)}},__=(e,t)=>{let r=e;const n=t.split(zg),s=n.length;for(let i=0;i<s;i++){const a=n[i];let u=r.nextPart.get(a);u||(u=w_(),r.nextPart.set(a,u)),r=u}return r},iz=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,az=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const s=(i,a)=>{r[i]=a,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(i){let a=r[i];if(a!==void 0)return a;if((a=n[i])!==void 0)return s(i,a),a},set(i,a){i in r?r[i]=a:s(i,a)}}},Iv="!",CS=":",oz=[],TS=(e,t,r,n,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:s}),uz=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=s=>{const i=[];let a=0,u=0,o=0,c;const p=s.length;for(let v=0;v<p;v++){const b=s[v];if(a===0&&u===0){if(b===CS){i.push(s.slice(o,v)),o=v+1;continue}if(b==="/"){c=v;continue}}b==="["?a++:b==="]"?a--:b==="("?u++:b===")"&&u--}const d=i.length===0?s:s.slice(o);let h=d,m=!1;d.endsWith(Iv)?(h=d.slice(0,-1),m=!0):d.startsWith(Iv)&&(h=d.slice(1),m=!0);const y=c&&c>o?c-o:void 0;return TS(i,m,h,y)};if(t){const s=t+CS,i=n;n=a=>a.startsWith(s)?i(a.slice(s.length)):TS(oz,!1,a,void 0,!0)}if(r){const s=n;n=i=>r({className:i,parseClassName:s})}return n},lz=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let s=[];for(let i=0;i<r.length;i++){const a=r[i],u=a[0]==="[",o=t.has(a);u||o?(s.length>0&&(s.sort(),n.push(...s),s=[]),n.push(a)):s.push(a)}return s.length>0&&(s.sort(),n.push(...s)),n}},cz=e=>({cache:az(e.cacheSize),parseClassName:uz(e),sortModifiers:lz(e),...YU(e)}),pz=/\s+/,dz=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:s,sortModifiers:i}=t,a=[],u=e.trim().split(pz);let o="";for(let c=u.length-1;c>=0;c-=1){const p=u[c],{isExternal:d,modifiers:h,hasImportantModifier:m,baseClassName:y,maybePostfixModifierPosition:v}=r(p);if(d){o=p+(o.length>0?" "+o:o);continue}let b=!!v,T=n(b?y.substring(0,v):y);if(!T){if(!b){o=p+(o.length>0?" "+o:o);continue}if(T=n(y),!T){o=p+(o.length>0?" "+o:o);continue}b=!1}const D=h.length===0?"":h.length===1?h[0]:i(h).join(":"),x=m?D+Iv:D,E=x+T;if(a.indexOf(E)>-1)continue;a.push(E);const A=s(T,b);for(let F=0;F<A.length;++F){const k=A[F];a.push(x+k)}o=p+(o.length>0?" "+o:o)}return o},fz=(...e)=>{let t=0,r,n,s="";for(;t<e.length;)(r=e[t++])&&(n=P_(r))&&(s&&(s+=" "),s+=n);return s},P_=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=P_(e[n]))&&(r&&(r+=" "),r+=t);return r},hz=(e,...t)=>{let r,n,s,i;const a=o=>{const c=t.reduce((p,d)=>d(p),e());return r=cz(c),n=r.cache.get,s=r.cache.set,i=u,u(o)},u=o=>{const c=n(o);if(c)return c;const p=dz(o,r);return s(o,p),p};return i=a,(...o)=>i(fz(...o))},mz=[],vn=e=>{const t=r=>r[e]||mz;return t.isThemeGetter=!0,t},N_=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,$_=/^\((?:(\w[\w-]*):)?(.+)\)$/i,yz=/^\d+\/\d+$/,gz=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Dz=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,xz=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,bz=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,vz=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ec=e=>yz.test(e),hr=e=>!!e&&!Number.isNaN(Number(e)),Ro=e=>!!e&&Number.isInteger(Number(e)),lb=e=>e.endsWith("%")&&hr(e.slice(0,-1)),Ra=e=>gz.test(e),Ez=()=>!0,Cz=e=>Dz.test(e)&&!xz.test(e),I_=()=>!1,Tz=e=>bz.test(e),Az=e=>vz.test(e),Sz=e=>!At(e)&&!St(e),Fz=e=>Jp(e,O_,I_),At=e=>N_.test(e),Hu=e=>Jp(e,L_,Cz),cb=e=>Jp(e,Nz,hr),AS=e=>Jp(e,B_,I_),wz=e=>Jp(e,j_,Az),Q1=e=>Jp(e,M_,Tz),St=e=>$_.test(e),yf=e=>Kp(e,L_),kz=e=>Kp(e,$z),SS=e=>Kp(e,B_),_z=e=>Kp(e,O_),Pz=e=>Kp(e,j_),Z1=e=>Kp(e,M_,!0),Jp=(e,t,r)=>{const n=N_.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Kp=(e,t,r=!1)=>{const n=$_.exec(e);return n?n[1]?t(n[1]):r:!1},B_=e=>e==="position"||e==="percentage",j_=e=>e==="image"||e==="url",O_=e=>e==="length"||e==="size"||e==="bg-size",L_=e=>e==="length",Nz=e=>e==="number",$z=e=>e==="family-name",M_=e=>e==="shadow",Iz=()=>{const e=vn("color"),t=vn("font"),r=vn("text"),n=vn("font-weight"),s=vn("tracking"),i=vn("leading"),a=vn("breakpoint"),u=vn("container"),o=vn("spacing"),c=vn("radius"),p=vn("shadow"),d=vn("inset-shadow"),h=vn("text-shadow"),m=vn("drop-shadow"),y=vn("blur"),v=vn("perspective"),b=vn("aspect"),T=vn("ease"),D=vn("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],E=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...E(),St,At],F=()=>["auto","hidden","clip","visible","scroll"],k=()=>["auto","contain","none"],_=()=>[St,At,o],O=()=>[Ec,"full","auto",..._()],q=()=>[Ro,"none","subgrid",St,At],j=()=>["auto",{span:["full",Ro,St,At]},Ro,St,At],V=()=>[Ro,"auto",St,At],z=()=>["auto","min","max","fr",St,At],oe=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],L=()=>["start","end","center","stretch","center-safe","end-safe"],ne=()=>["auto",..._()],Ee=()=>[Ec,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],X=()=>[e,St,At],je=()=>[...E(),SS,AS,{position:[St,At]}],K=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Q=()=>["auto","cover","contain",_z,Fz,{size:[St,At]}],ie=()=>[lb,yf,Hu],M=()=>["","none","full",c,St,At],B=()=>["",hr,yf,Hu],U=()=>["solid","dashed","dotted","double"],J=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],de=()=>[hr,lb,SS,AS],Ce=()=>["","none",y,St,At],Me=()=>["none",hr,St,At],Ue=()=>["none",hr,St,At],re=()=>[hr,St,At],le=()=>[Ec,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ra],breakpoint:[Ra],color:[Ez],container:[Ra],"drop-shadow":[Ra],ease:["in","out","in-out"],font:[Sz],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ra],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ra],shadow:[Ra],spacing:["px",hr],text:[Ra],"text-shadow":[Ra],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ec,At,St,b]}],container:["container"],columns:[{columns:[hr,At,St,u]}],"break-after":[{"break-after":x()}],"break-before":[{"break-before":x()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:F()}],"overflow-x":[{"overflow-x":F()}],"overflow-y":[{"overflow-y":F()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{start:O()}],end:[{end:O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[Ro,"auto",St,At]}],basis:[{basis:[Ec,"full","auto",u,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[hr,Ec,"auto","initial","none",At]}],grow:[{grow:["",hr,St,At]}],shrink:[{shrink:["",hr,St,At]}],order:[{order:[Ro,"first","last","none",St,At]}],"grid-cols":[{"grid-cols":q()}],"col-start-end":[{col:j()}],"col-start":[{"col-start":V()}],"col-end":[{"col-end":V()}],"grid-rows":[{"grid-rows":q()}],"row-start-end":[{row:j()}],"row-start":[{"row-start":V()}],"row-end":[{"row-end":V()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":z()}],"auto-rows":[{"auto-rows":z()}],gap:[{gap:_()}],"gap-x":[{"gap-x":_()}],"gap-y":[{"gap-y":_()}],"justify-content":[{justify:[...oe(),"normal"]}],"justify-items":[{"justify-items":[...L(),"normal"]}],"justify-self":[{"justify-self":["auto",...L()]}],"align-content":[{content:["normal",...oe()]}],"align-items":[{items:[...L(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...L(),{baseline:["","last"]}]}],"place-content":[{"place-content":oe()}],"place-items":[{"place-items":[...L(),"baseline"]}],"place-self":[{"place-self":["auto",...L()]}],p:[{p:_()}],px:[{px:_()}],py:[{py:_()}],ps:[{ps:_()}],pe:[{pe:_()}],pt:[{pt:_()}],pr:[{pr:_()}],pb:[{pb:_()}],pl:[{pl:_()}],m:[{m:ne()}],mx:[{mx:ne()}],my:[{my:ne()}],ms:[{ms:ne()}],me:[{me:ne()}],mt:[{mt:ne()}],mr:[{mr:ne()}],mb:[{mb:ne()}],ml:[{ml:ne()}],"space-x":[{"space-x":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"space-y-reverse":["space-y-reverse"],size:[{size:Ee()}],w:[{w:[u,"screen",...Ee()]}],"min-w":[{"min-w":[u,"screen","none",...Ee()]}],"max-w":[{"max-w":[u,"screen","none","prose",{screen:[a]},...Ee()]}],h:[{h:["screen","lh",...Ee()]}],"min-h":[{"min-h":["screen","lh","none",...Ee()]}],"max-h":[{"max-h":["screen","lh",...Ee()]}],"font-size":[{text:["base",r,yf,Hu]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,St,cb]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",lb,At]}],"font-family":[{font:[kz,At,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,St,At]}],"line-clamp":[{"line-clamp":[hr,"none",St,cb]}],leading:[{leading:[i,..._()]}],"list-image":[{"list-image":["none",St,At]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",St,At]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:X()}],"text-color":[{text:X()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:[hr,"from-font","auto",St,Hu]}],"text-decoration-color":[{decoration:X()}],"underline-offset":[{"underline-offset":[hr,"auto",St,At]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",St,At]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",St,At]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:je()}],"bg-repeat":[{bg:K()}],"bg-size":[{bg:Q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ro,St,At],radial:["",St,At],conic:[Ro,St,At]},Pz,wz]}],"bg-color":[{bg:X()}],"gradient-from-pos":[{from:ie()}],"gradient-via-pos":[{via:ie()}],"gradient-to-pos":[{to:ie()}],"gradient-from":[{from:X()}],"gradient-via":[{via:X()}],"gradient-to":[{to:X()}],rounded:[{rounded:M()}],"rounded-s":[{"rounded-s":M()}],"rounded-e":[{"rounded-e":M()}],"rounded-t":[{"rounded-t":M()}],"rounded-r":[{"rounded-r":M()}],"rounded-b":[{"rounded-b":M()}],"rounded-l":[{"rounded-l":M()}],"rounded-ss":[{"rounded-ss":M()}],"rounded-se":[{"rounded-se":M()}],"rounded-ee":[{"rounded-ee":M()}],"rounded-es":[{"rounded-es":M()}],"rounded-tl":[{"rounded-tl":M()}],"rounded-tr":[{"rounded-tr":M()}],"rounded-br":[{"rounded-br":M()}],"rounded-bl":[{"rounded-bl":M()}],"border-w":[{border:B()}],"border-w-x":[{"border-x":B()}],"border-w-y":[{"border-y":B()}],"border-w-s":[{"border-s":B()}],"border-w-e":[{"border-e":B()}],"border-w-t":[{"border-t":B()}],"border-w-r":[{"border-r":B()}],"border-w-b":[{"border-b":B()}],"border-w-l":[{"border-l":B()}],"divide-x":[{"divide-x":B()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":B()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...U(),"hidden","none"]}],"divide-style":[{divide:[...U(),"hidden","none"]}],"border-color":[{border:X()}],"border-color-x":[{"border-x":X()}],"border-color-y":[{"border-y":X()}],"border-color-s":[{"border-s":X()}],"border-color-e":[{"border-e":X()}],"border-color-t":[{"border-t":X()}],"border-color-r":[{"border-r":X()}],"border-color-b":[{"border-b":X()}],"border-color-l":[{"border-l":X()}],"divide-color":[{divide:X()}],"outline-style":[{outline:[...U(),"none","hidden"]}],"outline-offset":[{"outline-offset":[hr,St,At]}],"outline-w":[{outline:["",hr,yf,Hu]}],"outline-color":[{outline:X()}],shadow:[{shadow:["","none",p,Z1,Q1]}],"shadow-color":[{shadow:X()}],"inset-shadow":[{"inset-shadow":["none",d,Z1,Q1]}],"inset-shadow-color":[{"inset-shadow":X()}],"ring-w":[{ring:B()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:X()}],"ring-offset-w":[{"ring-offset":[hr,Hu]}],"ring-offset-color":[{"ring-offset":X()}],"inset-ring-w":[{"inset-ring":B()}],"inset-ring-color":[{"inset-ring":X()}],"text-shadow":[{"text-shadow":["none",h,Z1,Q1]}],"text-shadow-color":[{"text-shadow":X()}],opacity:[{opacity:[hr,St,At]}],"mix-blend":[{"mix-blend":[...J(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":J()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[hr]}],"mask-image-linear-from-pos":[{"mask-linear-from":de()}],"mask-image-linear-to-pos":[{"mask-linear-to":de()}],"mask-image-linear-from-color":[{"mask-linear-from":X()}],"mask-image-linear-to-color":[{"mask-linear-to":X()}],"mask-image-t-from-pos":[{"mask-t-from":de()}],"mask-image-t-to-pos":[{"mask-t-to":de()}],"mask-image-t-from-color":[{"mask-t-from":X()}],"mask-image-t-to-color":[{"mask-t-to":X()}],"mask-image-r-from-pos":[{"mask-r-from":de()}],"mask-image-r-to-pos":[{"mask-r-to":de()}],"mask-image-r-from-color":[{"mask-r-from":X()}],"mask-image-r-to-color":[{"mask-r-to":X()}],"mask-image-b-from-pos":[{"mask-b-from":de()}],"mask-image-b-to-pos":[{"mask-b-to":de()}],"mask-image-b-from-color":[{"mask-b-from":X()}],"mask-image-b-to-color":[{"mask-b-to":X()}],"mask-image-l-from-pos":[{"mask-l-from":de()}],"mask-image-l-to-pos":[{"mask-l-to":de()}],"mask-image-l-from-color":[{"mask-l-from":X()}],"mask-image-l-to-color":[{"mask-l-to":X()}],"mask-image-x-from-pos":[{"mask-x-from":de()}],"mask-image-x-to-pos":[{"mask-x-to":de()}],"mask-image-x-from-color":[{"mask-x-from":X()}],"mask-image-x-to-color":[{"mask-x-to":X()}],"mask-image-y-from-pos":[{"mask-y-from":de()}],"mask-image-y-to-pos":[{"mask-y-to":de()}],"mask-image-y-from-color":[{"mask-y-from":X()}],"mask-image-y-to-color":[{"mask-y-to":X()}],"mask-image-radial":[{"mask-radial":[St,At]}],"mask-image-radial-from-pos":[{"mask-radial-from":de()}],"mask-image-radial-to-pos":[{"mask-radial-to":de()}],"mask-image-radial-from-color":[{"mask-radial-from":X()}],"mask-image-radial-to-color":[{"mask-radial-to":X()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":E()}],"mask-image-conic-pos":[{"mask-conic":[hr]}],"mask-image-conic-from-pos":[{"mask-conic-from":de()}],"mask-image-conic-to-pos":[{"mask-conic-to":de()}],"mask-image-conic-from-color":[{"mask-conic-from":X()}],"mask-image-conic-to-color":[{"mask-conic-to":X()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:je()}],"mask-repeat":[{mask:K()}],"mask-size":[{mask:Q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",St,At]}],filter:[{filter:["","none",St,At]}],blur:[{blur:Ce()}],brightness:[{brightness:[hr,St,At]}],contrast:[{contrast:[hr,St,At]}],"drop-shadow":[{"drop-shadow":["","none",m,Z1,Q1]}],"drop-shadow-color":[{"drop-shadow":X()}],grayscale:[{grayscale:["",hr,St,At]}],"hue-rotate":[{"hue-rotate":[hr,St,At]}],invert:[{invert:["",hr,St,At]}],saturate:[{saturate:[hr,St,At]}],sepia:[{sepia:["",hr,St,At]}],"backdrop-filter":[{"backdrop-filter":["","none",St,At]}],"backdrop-blur":[{"backdrop-blur":Ce()}],"backdrop-brightness":[{"backdrop-brightness":[hr,St,At]}],"backdrop-contrast":[{"backdrop-contrast":[hr,St,At]}],"backdrop-grayscale":[{"backdrop-grayscale":["",hr,St,At]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[hr,St,At]}],"backdrop-invert":[{"backdrop-invert":["",hr,St,At]}],"backdrop-opacity":[{"backdrop-opacity":[hr,St,At]}],"backdrop-saturate":[{"backdrop-saturate":[hr,St,At]}],"backdrop-sepia":[{"backdrop-sepia":["",hr,St,At]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":_()}],"border-spacing-x":[{"border-spacing-x":_()}],"border-spacing-y":[{"border-spacing-y":_()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",St,At]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[hr,"initial",St,At]}],ease:[{ease:["linear","initial",T,St,At]}],delay:[{delay:[hr,St,At]}],animate:[{animate:["none",D,St,At]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,St,At]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:Me()}],"rotate-x":[{"rotate-x":Me()}],"rotate-y":[{"rotate-y":Me()}],"rotate-z":[{"rotate-z":Me()}],scale:[{scale:Ue()}],"scale-x":[{"scale-x":Ue()}],"scale-y":[{"scale-y":Ue()}],"scale-z":[{"scale-z":Ue()}],"scale-3d":["scale-3d"],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[St,At,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:le()}],"translate-x":[{"translate-x":le()}],"translate-y":[{"translate-y":le()}],"translate-z":[{"translate-z":le()}],"translate-none":["translate-none"],accent:[{accent:X()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:X()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",St,At]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",St,At]}],fill:[{fill:["none",...X()]}],"stroke-w":[{stroke:[hr,yf,Hu,cb]}],stroke:[{stroke:["none",...X()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Bz=hz(Iz);function Xt(...e){return Bz(WU(e))}function jz(e){function t({children:r,className:n}){return S.jsxs("div",{className:Xt("rounded-md border border-dashed border-amber-400/60 bg-amber-50/40 p-3 text-xs dark:bg-amber-950/20",n),children:[S.jsxs("span",{className:"font-mono text-amber-700 dark:text-amber-400",children:["⚠ ",e]}),S.jsx("span",{className:"ml-2 text-muted-foreground",children:"— компонент не зарегистрирован в preview"}),r?S.jsx("div",{className:"mt-2",children:r}):null]})}return t.displayName=`Unknown(${e})`,t}function FS(e,t){function r({children:n,className:s}){return S.jsxs("div",{className:Xt("rounded-md border border-dashed border-border bg-muted/30 p-3 text-xs text-muted-foreground",s),children:[S.jsx("span",{className:"font-mono text-foreground",children:e}),S.jsxs("span",{className:"ml-2",children:["— предпросмотр ограничен",t?` (${t})`:""]}),n?S.jsx("div",{className:"mt-2",children:n}):null]})}return r.displayName=`PreviewLimited(${e})`,r}function Oz({className:e,children:t}){return S.jsx("div",{"data-slot":"preview-step",className:e,children:t})}const R_=se.createContext(void 0);function Lz({form:e,children:t}){return S.jsx(R_.Provider,{value:e,children:t})}function Mz(){return se.useContext(R_)}function Rz(e){function t(r){const n=Mz(),s=r.form??n,a=(r.steps??[]).map((u,o)=>({number:o+1,title:u.componentProps?.title??`Шаг ${o+1}`,icon:u.componentProps?.icon,body:u}));return S.jsx("div",{className:r.className,children:S.jsx(e,{form:s,steps:a,config:{},renderStepBody:(u,o)=>S.jsx(IO,{node:u,form:o}),onSubmit:()=>{}})})}return t.__selfManagedChildren=!0,t}function Uz(){return Ta().filter(S_).map(e=>e.name)}let zz=null,qz=null;function U_(){return zz??=[...Uz(),...v8]}function Jz(){return qz??=new Set(U_())}function Kz(e,t){const r=e.adapters.wizard?.symbol,n=r?t[r]:void 0;return n?{...t,Wizard:Rz(n),Step:Oz}:t}function Vz(e,t){return{FormField:t[e.infra.fieldWrapper],AsyncBoundary:t[e.infra.asyncBoundary],List:t[e.infra.list]}}function Wz(e=Up(),t=E8()){const r=Kz(e,t),n=Vz(e,r),s={};for(const i of v8){const a=n[i];s[i]=vS(a??FS(i,`нет в ${e.package}`),i)}for(const i of Ta()){if(!S_(i))continue;const a=JU(i,r,e);s[i.name]=vS(a.policy==="live"?a.component:FS(i.name,a.reason),i.name)}return s}function Hz(){const e=Up().adapters.provider?.symbol;if(!e)return;const t=E8()[e];return typeof t=="function"||typeof t=="object"&&t!==null?t:void 0}let Gz=null;function Xz(){return Gz??=Wz()}const X3=["options","items","data","dataSource","choices","list"],Yz=new Set(["Select","RadioGroup","Radio","RadioButtonGroup","Combobox","Autocomplete","MultiSelect"]),Qz=new Set(["Checkbox","Switch","Toggle"]),Zz=new Set(["Slider","InputNumber","NumberInput"]),eq=new Set(["DatePicker","DateInput","Calendar","DateRangePicker"]),tq=new Set(["FileUpload","FileUploadAvatar","Attachment"]);function Y3(e){const t=new Set(bp(e).dataSources),r=new Set,n=new Set;Mg(e,i=>{const a=i.componentProps;if(a){if(Jn(i)){const u=Mt(a.itemLabel);u?.op==="dataSource"&&r.add(u.arg)}for(const u of X3){const o=Mt(a[u]);o?.op==="dataSource"&&n.add(o.arg)}}});for(const i of r)n.delete(i);const s=new Set;for(const i of t)!r.has(i)&&!n.has(i)&&s.add(i);return{functionLike:r,optionLike:n,scalarLike:s}}function Q3(e){const t=dq(e);return[1,2,3].map(r=>({value:`option${r}`,label:`${t} ${r}`}))}function rq(e){const t={};for(const r of e.optionLike)t[r]=Q3(r);for(const r of e.scalarLike)t[r]="значение";return t}function z_(e){const t=Mt(e.component)?.arg,r=e.componentProps??{};return t&&tq.has(t)?"files":nq(r)||Array.isArray(r.options)||t&&Yz.has(t)?"select":t&&Qz.has(t)?"boolean":r.type==="number"||t&&Zz.has(t)?"number":r.type==="date"||t&&eq.has(t)||iq(e,sq)?"date":"string"}function nq(e){return X3.some(t=>Mt(e[t])?.op==="dataSource")}const sq=/(date|dob|birth|дата|рожд)/;function j2(e){const r=(Mt(e.value)?.arg??"").split(".").pop()??"",n=String(e.componentProps?.label??e.componentProps?.placeholder??"");return`${r} ${n}`.toLowerCase()}function iq(e,t){return t.test(j2(e))}function aq(e,t,r){switch(z_(e)){case"select":return oq(e,t);case"boolean":return!1;case"number":return uq(e,r);case"date":return lq(e,r);case"files":return null;default:return cq(e)}}function oq(e,t){const r=e.componentProps??{};for(const n of X3){const s=Mt(r[n]);if(s?.op==="dataSource"){const i=t[s.arg];if(Array.isArray(i)&&i.length)return i[0].value??"option1"}}if(Array.isArray(r.options)&&r.options.length){const n=r.options[0];if(n&&typeof n=="object"&&"value"in n)return n.value}return"option1"}function uq(e,t){const r=Mt(e.component)?.arg,n=e.componentProps??{};if(r==="Slider")return typeof n.min=="number"?n.min:0;const s=j2(e);return/\byear\b|год/.test(s)?t.getFullYear():/(amount|sum|price|salary|income|сумм|цен|доход|зарплат|стоим)/.test(s)?5e4:/(age|возраст)/.test(s)?30:/(count|qty|quantity|колич)/.test(s)?1:/(percent|rate|ставк|процент)/.test(s)?10:42}function lq(e,t){return/(dob|birth|рожд)/.test(j2(e))?"1990-01-01":t.toISOString().slice(0,10)}function cq(e){const t=j2(e);return/(e-?mail|почт)/.test(t)?"ivan@example.com":/(phone|tel|телефон)/.test(t)?"+7 999 123-45-67":/(lastname|surname|фамил)/.test(t)?"Иванов":/(firstname|имя)/.test(t)?"Иван":/(fullname|fio|фио|\bname\b)/.test(t)?"Иван Иванов":/(url|site|website|сайт)/.test(t)?"https://example.com":/(city|город)/.test(t)?"Москва":/(address|адрес)/.test(t)?"г. Москва, ул. Пример, 1":/(inn|инн)/.test(t)?"7712345678":/(password|пароль)/.test(t)?"Passw0rd!":/(comment|note|description|коммент|примечан|описан)/.test(t)?"Пример текста":String(e.componentProps?.label??"").trim()||"Пример"}function pq(e,t,r,n){const s=e.initialValue&&typeof e.initialValue=="object"?e.initialValue:{},i=e.item?.$template,a=[];for(let u=0;u<n;u++){const o=an(i)?q_(i,t,r,n):{};a.push(J_(o,s))}return a}function q_(e,t,r,n){const s={},i=a=>{if(Jn(a)){const u=Mt(a.array);u?.op==="model"&&wS(s,u.arg.split("."),pq(a,t,r,n));return}if(ni(a)){const u=Mt(a.value);u?.op==="model"&&wS(s,u.arg.split("."),aq(a,t,r));return}if(ns(a)){a.children?.forEach(o=>an(o)&&i(o));const u=a.componentProps?.steps;Array.isArray(u)&&u.forEach(o=>an(o)&&i(o))}};return i(e),s}function Ep(e,t={}){const r=t.now??new Date,n=t.arrayItems??1,s=Y3(e),i=rq(s);return{model:an(e.root)?q_(e.root,i,r,n):{},dataSources:i}}function wS(e,t,r){let n=e;for(let s=0;s<t.length-1;s++){const i=t[s];(typeof n[i]!="object"||n[i]===null||Array.isArray(n[i]))&&(n[i]={}),n=n[i]}n[t[t.length-1]]=r}function J_(e,t){const r={...e};for(const[n,s]of Object.entries(t)){const i=r[n];kS(i)&&kS(s)?r[n]=J_(i,s):r[n]=s}return r}function kS(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function dq(e){const t=e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):"Вариант"}function fq(e,t,r={}){const{functionLike:n,optionLike:s,scalarLike:i}=Y3(t);for(const o of n)e.dataSource(o,(c,p=0)=>`#${p+1}`);for(const o of s)e.dataSource(o,r[o]??Q3(o));for(const o of i)e.dataSource(o,r[o]??"значение");const{fns:a,locales:u}=bp(t);for(const o of a)e.fn(o,()=>"");u.length>0&&e.locale(o=>o)}function hq(e){const t=Jz();return bp(e).components.filter(r=>!t.has(r))}function mq(e,t){const r=Xz();return G8(n=>{for(const[s,i]of Object.entries(r))n.component(s,i);n.component(k2,r.FormField);for(const s of hq(e))n.component(s,jz(s));fq(n,e,t)})}function yq(e,t){const r=t??Ep(e),n=m8(r.model),s=mq(e,r.dataSources),i=y8({model:n,schema:B3(e,s,n)});return{registry:s,model:n,form:i}}let Bv=null;const jv=new Set;function _S(e){if(Bv!==e){Bv=e;for(const t of jv)t()}}function gq(){return Bv}function Dq(e){return jv.add(e),()=>jv.delete(e)}const Sh="rbnode-",K_="rb-empty",V_="__",xq=new RegExp(`(?:^|\\s)(${Sh}[A-Za-z0-9_-]+)(?:\\s|$)`),PS=e=>`-${e.codePointAt(0).toString(16)}-`;function bq(e){if(typeof e=="number")return String(e);let t="";for(const r of e)t+=/[A-Za-z0-9]/.test(r)?r:PS(r);return/^\d+$/.test(t)?PS(e[0])+t.slice(1):t}function vq(e){return/^\d+$/.test(e)?Number(e):e.replace(/-([0-9a-f]+)-/g,(t,r)=>String.fromCodePoint(parseInt(r,16)))}function O2(e){return Sh+e.map(bq).join(V_)}function Eq(e){if(!e.startsWith(Sh))return null;const t=e.slice(Sh.length);if(!t)return null;const r=t.split(V_);return r.some(n=>n==="")?null:r.map(vq)}function Cq(e){const t=xq.exec(e);return t?t[1]:null}const Tq="space-y-3 mt-2";function pb(e,t,r={}){const n=typeof e?.className=="string"?e.className:"",s=r.arrayDefault&&!n?Tq:"",i=[n,s,O2(t),r.empty?K_:""].filter(Boolean).join(" ");return{...e,className:i}}function Of(e,t){if(Jn(e)){const r=e;return{...r,componentProps:pb(r.componentProps,t,{arrayDefault:!r.component}),item:{$template:Of(r.item.$template,[...t,"item","$template"])}}}if(ni(e)){const r=e,n={...r,componentProps:pb(r.componentProps,t)};return r.wrapper&&(n.wrapper=Of(r.wrapper,[...t,"wrapper"])),n}if(ns(e)){const r=e,n=r.componentProps?.steps,s=Array.isArray(n)&&n.some(an),a=(Array.isArray(r.children)?r.children.length:0)+(s?1:0)===0,u={...r,componentProps:pb(r.componentProps,t,{empty:a})};if(s){const o=[...t,"componentProps","steps"];u.componentProps={...u.componentProps,steps:n.map((c,p)=>an(c)?Of(c,[...o,p]):c)}}return Array.isArray(r.children)&&(u.children=r.children.map((o,c)=>an(o)?Of(o,[...t,"children",c]):o)),u}return e}function Aq(e){return{...e,root:Of(e.root,["root"])}}function Sq(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var db={exports:{}},NS={},Ua={},Gu={},$S={},IS={},BS={},jS;function qg(){return jS||(jS=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor(D){if(super(),!e.IDENTIFIER.test(D))throw new Error("CodeGen: name must be a valid identifier");this.str=D}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(D){super(),this._items=typeof D=="string"?[D]:D}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const D=this._items[0];return D===""||D==='""'}get str(){var D;return(D=this._str)!==null&&D!==void 0?D:this._str=this._items.reduce((x,E)=>`${x}${E}`,"")}get names(){var D;return(D=this._names)!==null&&D!==void 0?D:this._names=this._items.reduce((x,E)=>(E instanceof r&&(x[E.str]=(x[E.str]||0)+1),x),{})}}e._Code=n,e.nil=new n("");function s(T,...D){const x=[T[0]];let E=0;for(;E<D.length;)u(x,D[E]),x.push(T[++E]);return new n(x)}e._=s;const i=new n("+");function a(T,...D){const x=[m(T[0])];let E=0;for(;E<D.length;)x.push(i),u(x,D[E]),x.push(i,m(T[++E]));return o(x),new n(x)}e.str=a;function u(T,D){D instanceof n?T.push(...D._items):D instanceof r?T.push(D):T.push(d(D))}e.addCodeArg=u;function o(T){let D=1;for(;D<T.length-1;){if(T[D]===i){const x=c(T[D-1],T[D+1]);if(x!==void 0){T.splice(D-1,3,x);continue}T[D++]="+"}D++}}function c(T,D){if(D==='""')return T;if(T==='""')return D;if(typeof T=="string")return D instanceof r||T[T.length-1]!=='"'?void 0:typeof D!="string"?`${T.slice(0,-1)}${D}"`:D[0]==='"'?T.slice(0,-1)+D.slice(1):void 0;if(typeof D=="string"&&D[0]==='"'&&!(T instanceof r))return`"${T}${D.slice(1)}`}function p(T,D){return D.emptyStr()?T:T.emptyStr()?D:a`${T}${D}`}e.strConcat=p;function d(T){return typeof T=="number"||typeof T=="boolean"||T===null?T:m(Array.isArray(T)?T.join(","):T)}function h(T){return new n(m(T))}e.stringify=h;function m(T){return JSON.stringify(T).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.safeStringify=m;function y(T){return typeof T=="string"&&e.IDENTIFIER.test(T)?new n(`.${T}`):s`[${T}]`}e.getProperty=y;function v(T){if(typeof T=="string"&&e.IDENTIFIER.test(T))return new n(`${T}`);throw new Error(`CodeGen: invalid export name: ${T}, use explicit $id name mapping`)}e.getEsmExportName=v;function b(T){return new n(T.toString())}e.regexpCode=b})(BS)),BS}var OS={},LS;function MS(){return LS||(LS=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=qg();class r extends Error{constructor(c){super(`CodeGen: "code" for ${c} not defined`),this.value=c.value}}var n;(function(o){o[o.Started=0]="Started",o[o.Completed=1]="Completed"})(n||(e.UsedValueState=n={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};class s{constructor({prefixes:c,parent:p}={}){this._names={},this._prefixes=c,this._parent=p}toName(c){return c instanceof t.Name?c:this.name(c)}name(c){return new t.Name(this._newName(c))}_newName(c){const p=this._names[c]||this._nameGroup(c);return`${c}${p.index++}`}_nameGroup(c){var p,d;if(!((d=(p=this._parent)===null||p===void 0?void 0:p._prefixes)===null||d===void 0)&&d.has(c)||this._prefixes&&!this._prefixes.has(c))throw new Error(`CodeGen: prefix "${c}" is not allowed in this scope`);return this._names[c]={prefix:c,index:0}}}e.Scope=s;class i extends t.Name{constructor(c,p){super(p),this.prefix=c}setValue(c,{property:p,itemIndex:d}){this.value=c,this.scopePath=(0,t._)`.${new t.Name(p)}[${d}]`}}e.ValueScopeName=i;const a=(0,t._)`\n`;class u extends s{constructor(c){super(c),this._values={},this._scope=c.scope,this.opts={...c,_n:c.lines?a:t.nil}}get(){return this._scope}name(c){return new i(c,this._newName(c))}value(c,p){var d;if(p.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const h=this.toName(c),{prefix:m}=h,y=(d=p.key)!==null&&d!==void 0?d:p.ref;let v=this._values[m];if(v){const D=v.get(y);if(D)return D}else v=this._values[m]=new Map;v.set(y,h);const b=this._scope[m]||(this._scope[m]=[]),T=b.length;return b[T]=p.ref,h.setValue(p,{property:m,itemIndex:T}),h}getValue(c,p){const d=this._values[c];if(d)return d.get(p)}scopeRefs(c,p=this._values){return this._reduceValues(p,d=>{if(d.scopePath===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return(0,t._)`${c}${d.scopePath}`})}scopeCode(c=this._values,p,d){return this._reduceValues(c,h=>{if(h.value===void 0)throw new Error(`CodeGen: name "${h}" has no value`);return h.value.code},p,d)}_reduceValues(c,p,d={},h){let m=t.nil;for(const y in c){const v=c[y];if(!v)continue;const b=d[y]=d[y]||new Map;v.forEach(T=>{if(b.has(T))return;b.set(T,n.Started);let D=p(T);if(D){const x=this.opts.es5?e.varKinds.var:e.varKinds.const;m=(0,t._)`${m}${x} ${T} = ${D};${this.opts._n}`}else if(D=h?.(T))m=(0,t._)`${m}${D}${this.opts._n}`;else throw new r(T);b.set(T,n.Completed)})}return m}}e.ValueScope=u})(OS)),OS}var RS;function Dr(){return RS||(RS=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=qg(),r=MS();var n=qg();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=MS();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class i{optimizeNodes(){return this}optimizeNames(B,U){return this}}class a extends i{constructor(B,U,J){super(),this.varKind=B,this.name=U,this.rhs=J}render({es5:B,_n:U}){const J=B?r.varKinds.var:this.varKind,de=this.rhs===void 0?"":` = ${this.rhs}`;return`${J} ${this.name}${de};`+U}optimizeNames(B,U){if(B[this.name.str])return this.rhs&&(this.rhs=oe(this.rhs,B,U)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class u extends i{constructor(B,U,J){super(),this.lhs=B,this.rhs=U,this.sideEffects=J}render({_n:B}){return`${this.lhs} = ${this.rhs};`+B}optimizeNames(B,U){if(!(this.lhs instanceof t.Name&&!B[this.lhs.str]&&!this.sideEffects))return this.rhs=oe(this.rhs,B,U),this}get names(){const B=this.lhs instanceof t.Name?{}:{...this.lhs.names};return z(B,this.rhs)}}class o extends u{constructor(B,U,J,de){super(B,J,de),this.op=U}render({_n:B}){return`${this.lhs} ${this.op}= ${this.rhs};`+B}}class c extends i{constructor(B){super(),this.label=B,this.names={}}render({_n:B}){return`${this.label}:`+B}}class p extends i{constructor(B){super(),this.label=B,this.names={}}render({_n:B}){return`break${this.label?` ${this.label}`:""};`+B}}class d extends i{constructor(B){super(),this.error=B}render({_n:B}){return`throw ${this.error};`+B}get names(){return this.error.names}}class h extends i{constructor(B){super(),this.code=B}render({_n:B}){return`${this.code};`+B}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(B,U){return this.code=oe(this.code,B,U),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class m extends i{constructor(B=[]){super(),this.nodes=B}render(B){return this.nodes.reduce((U,J)=>U+J.render(B),"")}optimizeNodes(){const{nodes:B}=this;let U=B.length;for(;U--;){const J=B[U].optimizeNodes();Array.isArray(J)?B.splice(U,1,...J):J?B[U]=J:B.splice(U,1)}return B.length>0?this:void 0}optimizeNames(B,U){const{nodes:J}=this;let de=J.length;for(;de--;){const Ce=J[de];Ce.optimizeNames(B,U)||(L(B,Ce.names),J.splice(de,1))}return J.length>0?this:void 0}get names(){return this.nodes.reduce((B,U)=>V(B,U.names),{})}}class y extends m{render(B){return"{"+B._n+super.render(B)+"}"+B._n}}class v extends m{}class b extends y{}b.kind="else";class T extends y{constructor(B,U){super(U),this.condition=B}render(B){let U=`if(${this.condition})`+super.render(B);return this.else&&(U+="else "+this.else.render(B)),U}optimizeNodes(){super.optimizeNodes();const B=this.condition;if(B===!0)return this.nodes;let U=this.else;if(U){const J=U.optimizeNodes();U=this.else=Array.isArray(J)?new b(J):J}if(U)return B===!1?U instanceof T?U:U.nodes:this.nodes.length?this:new T(ne(B),U instanceof T?[U]:U.nodes);if(!(B===!1||!this.nodes.length))return this}optimizeNames(B,U){var J;if(this.else=(J=this.else)===null||J===void 0?void 0:J.optimizeNames(B,U),!!(super.optimizeNames(B,U)||this.else))return this.condition=oe(this.condition,B,U),this}get names(){const B=super.names;return z(B,this.condition),this.else&&V(B,this.else.names),B}}T.kind="if";class D extends y{}D.kind="for";class x extends D{constructor(B){super(),this.iteration=B}render(B){return`for(${this.iteration})`+super.render(B)}optimizeNames(B,U){if(super.optimizeNames(B,U))return this.iteration=oe(this.iteration,B,U),this}get names(){return V(super.names,this.iteration.names)}}class E extends D{constructor(B,U,J,de){super(),this.varKind=B,this.name=U,this.from=J,this.to=de}render(B){const U=B.es5?r.varKinds.var:this.varKind,{name:J,from:de,to:Ce}=this;return`for(${U} ${J}=${de}; ${J}<${Ce}; ${J}++)`+super.render(B)}get names(){const B=z(super.names,this.from);return z(B,this.to)}}class A extends D{constructor(B,U,J,de){super(),this.loop=B,this.varKind=U,this.name=J,this.iterable=de}render(B){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(B)}optimizeNames(B,U){if(super.optimizeNames(B,U))return this.iterable=oe(this.iterable,B,U),this}get names(){return V(super.names,this.iterable.names)}}class F extends y{constructor(B,U,J){super(),this.name=B,this.args=U,this.async=J}render(B){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(B)}}F.kind="func";class k extends m{render(B){return"return "+super.render(B)}}k.kind="return";class _ extends y{render(B){let U="try"+super.render(B);return this.catch&&(U+=this.catch.render(B)),this.finally&&(U+=this.finally.render(B)),U}optimizeNodes(){var B,U;return super.optimizeNodes(),(B=this.catch)===null||B===void 0||B.optimizeNodes(),(U=this.finally)===null||U===void 0||U.optimizeNodes(),this}optimizeNames(B,U){var J,de;return super.optimizeNames(B,U),(J=this.catch)===null||J===void 0||J.optimizeNames(B,U),(de=this.finally)===null||de===void 0||de.optimizeNames(B,U),this}get names(){const B=super.names;return this.catch&&V(B,this.catch.names),this.finally&&V(B,this.finally.names),B}}class O extends y{constructor(B){super(),this.error=B}render(B){return`catch(${this.error})`+super.render(B)}}O.kind="catch";class q extends y{render(B){return"finally"+super.render(B)}}q.kind="finally";class j{constructor(B,U={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...U,_n:U.lines?`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BwhW-Atz.js","assets/useFormField-BLbvmpme-Dwz_jyMW.js","assets/index-DhcNqNgT.js","assets/index-BxUg93Np.css","assets/reformer-ui-kit-tUqYBSLv.js","assets/index-CF7RI8Bt.js","assets/index-eRs9yupj.js","assets/boot-BCJd6Ujw.js","assets/load-QsSQTL2T.js","assets/RawJsonEditor-D5mwkIJa.js","assets/monaco-setup-1PbjxubL.js","assets/editor.api-BWDeQ8t4.js","assets/editor-BzOv8av-.css","assets/CodeEditor-Cca8j3Z3.js","assets/monaco-languages-BZWxuU3F.js","assets/MarkdownPreview-CmqjlfzE.js","assets/ChatPanel-B4wt7hBH.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as se,j as S,W as pt,_ as Pl}from"./index-DhcNqNgT.js";import{y as n8,G as u3,O as zj,T as s8,I as qj,x as Jj,Z as Kj,z as Vj,P as Wj,b as Rr,A as i8,g as tu,B as a8,U as Hj,D as Gj,E as Xj,F as JA,H as Yj,J as Qj,K as l3,L as c3,N as p3,_ as sn,M as Kc,Q as S2,V as F2,W as ho,X as mo,Y as Mp,$ as Nl,a0 as Zj,a1 as eO,a2 as tO,a3 as rO,a4 as nO,a5 as sO,a6 as iO,a7 as aO,a8 as oO,a9 as o8,n as Bs,i as uO,s as lO,r as cO,aa as pO,ab as d3,d as f3,ac as dO,ad as u8,ae as KA,af as fO,ag as hO,ah as mO,ai as l8,aj as yO,ak as gO,al as DO,am as xO,h as c8,t as p8,j as d8,k as f8,l as Av,an as bO,ao as vO,ap as h8,aq as EO,ar as V1,as as W1,at as H1,au as Zn,av as xc,aw as Dn,ax as VA,ay as WA,az as bc,aA as Mo,aB as CO,aC as TO,aD as AO}from"./reformer-ui-kit-tUqYBSLv.js";import{K as SO,B as FO,_ as m8,y as y8,b as wO,l as h3,j as gp,g as g8}from"./useFormField-BLbvmpme-Dwz_jyMW.js";import{bm as m3,ap as D8,X as w2,C as x8,bP as HA,a as Rp,bd as kO,c as _O,bE as PO}from"./index-CF7RI8Bt.js";import{p as NO,G as $O,T as IO}from"./index-eRs9yupj.js";import{e as Up,g as Ca,f as BO,t as jO,h as OO,s as LO,i as b8,I as v8,N as MO,O as RO,S as GA,D as UO,j as zO,k as qO}from"./load-QsSQTL2T.js";import{g as E8,a as JO}from"./boot-BCJd6Ujw.js";function KO(e,t){const r=getComputedStyle(e),n=parseFloat(r.fontSize);return t*n}function VO(e,t){const r=getComputedStyle(e.ownerDocument.documentElement),n=parseFloat(r.fontSize);return t*n}function WO(e){return e/100*window.innerHeight}function HO(e){return e/100*window.innerWidth}function GO(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Bf({groupSize:e,panelElement:t,styleProp:r}){let n;const[s,i]=GO(r);switch(i){case"%":{n=s/100*e;break}case"px":{n=s;break}case"rem":{n=VO(t,s);break}case"em":{n=KO(t,s);break}case"vh":{n=WO(s);break}case"vw":{n=HO(s);break}}return n}function gs(e){return parseFloat(e.toFixed(3))}function Dp({group:e}){const{orientation:t,panels:r}=e;return r.reduce((n,s)=>(n+=t==="horizontal"?s.element.offsetWidth:s.element.offsetHeight,n),0)}function Sv(e){const{panels:t}=e,r=Dp({group:e});return r===0?t.map(n=>({groupResizeBehavior:n.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:n.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:n.panelConstraints.disabled,minSize:0,maxSize:100,panelId:n.id})):t.map(n=>{const{element:s,panelConstraints:i}=n;let a=0;if(i.collapsedSize!==void 0){const p=Bf({groupSize:r,panelElement:s,styleProp:i.collapsedSize});a=gs(p/r*100)}let u;if(i.defaultSize!==void 0){const p=Bf({groupSize:r,panelElement:s,styleProp:i.defaultSize});u=gs(p/r*100)}let o=0;if(i.minSize!==void 0){const p=Bf({groupSize:r,panelElement:s,styleProp:i.minSize});o=gs(p/r*100)}let c=100;if(i.maxSize!==void 0){const p=Bf({groupSize:r,panelElement:s,styleProp:i.maxSize});c=gs(p/r*100)}return{groupResizeBehavior:i.groupResizeBehavior,collapsedSize:a,collapsible:i.collapsible===!0,defaultSize:u,disabled:i.disabled,minSize:o,maxSize:c,panelId:n.id}})}function Mr(e,t="Assertion error"){if(!e)throw Error(t)}function Fv(e,t){return Array.from(t).sort(e==="horizontal"?XO:YO)}function XO(e,t){const r=e.element.offsetLeft-t.element.offsetLeft;return r!==0?r:e.element.offsetWidth-t.element.offsetWidth}function YO(e,t){const r=e.element.offsetTop-t.element.offsetTop;return r!==0?r:e.element.offsetHeight-t.element.offsetHeight}function C8(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function T8(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function QO({orientation:e,rects:t,targetRect:r}){const n={x:r.x+r.width/2,y:r.y+r.height/2};let s,i=Number.MAX_VALUE;for(const a of t){const{x:u,y:o}=T8(n,a),c=e==="horizontal"?u:o;c<i&&(i=c,s=a)}return Mr(s,"No rect found"),s}let G1;function ZO(){return G1===void 0&&(typeof matchMedia=="function"?G1=!!matchMedia("(pointer:coarse)").matches:G1=!1),G1}function A8(e){const{element:t,orientation:r,panels:n,separators:s}=e,i=Fv(r,Array.from(t.children).filter(C8).map(y=>({element:y}))).map(({element:y})=>y),a=[];let u=!1,o=!1,c=-1,p=-1,d=0,h,m=[];{let y=-1;for(const v of i)v.hasAttribute("data-panel")&&(y++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=y),p=y))}if(d>1){let y=-1;for(const v of i)if(v.hasAttribute("data-panel")){y++;const b=n.find(T=>T.element===v);if(b){if(h){const T=h.element.getBoundingClientRect(),D=v.getBoundingClientRect();let x;if(o){const E=r==="horizontal"?new DOMRect(T.right,T.top,0,T.height):new DOMRect(T.left,T.bottom,T.width,0),A=r==="horizontal"?new DOMRect(D.left,D.top,0,D.height):new DOMRect(D.left,D.top,D.width,0);switch(m.length){case 0:{x=[E,A];break}case 1:{const F=m[0],k=QO({orientation:r,rects:[T,D],targetRect:F.element.getBoundingClientRect()});x=[F,k===T?A:E];break}default:{x=m;break}}}else m.length?x=m:x=[r==="horizontal"?new DOMRect(T.right,D.top,D.left-T.right,D.height):new DOMRect(D.left,T.bottom,D.width,D.top-T.bottom)];for(const E of x){let A="width"in E?E:E.element.getBoundingClientRect();const F=ZO()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(A.width<F){const _=F-A.width;A=new DOMRect(A.x-_/2,A.y,A.width+_,A.height)}if(A.height<F){const _=F-A.height;A=new DOMRect(A.x,A.y-_/2,A.width,A.height+_)}const k=y<=c||y>p;!u&&!k&&a.push({group:e,groupSize:Dp({group:e}),panels:[h,b],separator:"width"in E?void 0:E,rect:A}),u=!1}}o=!1,h=b,m=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(u=!0);const b=s.find(T=>T.element===v);b?m.push(b):(h=void 0,m=[])}else o=!0}return a}let S8=class{#t={};addListener(t,r){const n=this.#t[t];return n===void 0?this.#t[t]=[r]:n.includes(r)||n.push(r),()=>{this.removeListener(t,r)}}emit(t,r){const n=this.#t[t];if(n!==void 0)if(n.length===1)n[0].call(null,r);else{let s=!1,i=null;const a=Array.from(n);for(let u=0;u<a.length;u++){const o=a[u];try{o.call(null,r)}catch(c){i===null&&(s=!0,i=c)}}if(s)throw i}}removeAllListeners(){this.#t={}}removeListener(t,r){const n=this.#t[t];if(n!==void 0){const s=n.indexOf(r);s>=0&&n.splice(s,1)}}},np={cursorFlags:0,state:"inactive"};const y3=new S8;function Cl(){return np}function eL(e){return y3.addListener("change",e)}function tL(e){const t=np,r={...np};r.cursorFlags=e,np=r,y3.emit("change",{prev:t,next:r})}function sp(e){const t=np;np=e,y3.emit("change",{prev:t,next:e})}const rL=e=>e,ab=()=>{},F8=1,w8=2,k8=4,_8=8,XA=3,YA=12;let X1;function QA(){return X1===void 0&&(X1=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(X1=!0)),X1}function nL({cursorFlags:e,groups:t,state:r}){let n=0,s=0;switch(r){case"active":case"hover":t.forEach(i=>{if(!i.mutableState.disableCursor)switch(i.orientation){case"horizontal":{n++;break}case"vertical":{s++;break}}})}if(!(n===0&&s===0)){switch(r){case"active":{if(e&&QA()){const i=(e&F8)!==0,a=(e&w8)!==0,u=(e&k8)!==0,o=(e&_8)!==0;if(i)return u?"se-resize":o?"ne-resize":"e-resize";if(a)return u?"sw-resize":o?"nw-resize":"w-resize";if(u)return"s-resize";if(o)return"n-resize"}break}}return QA()?n>0&&s>0?"move":n>0?"ew-resize":"ns-resize":n>0&&s>0?"grab":n>0?"col-resize":"row-resize"}}const ZA=new WeakMap;function g3(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:r}=ZA.get(e)??{};r===void 0&&(r=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(r):e.adoptedStyleSheets=[...e.adoptedStyleSheets,r]));const n=Cl();switch(n.state){case"active":case"hover":{const s=nL({cursorFlags:n.cursorFlags,groups:n.hitRegions.map(a=>a.group),state:n.state}),i=`*, *:hover {cursor: ${s} !important; }`;if(t===i)return;t=i,s?r.cssRules.length===0?r.insertRule(i):r.replaceSync(i):r.cssRules.length===1&&r.deleteRule(0);break}case"inactive":{t=void 0,r.cssRules.length===1&&r.deleteRule(0);break}}ZA.set(e,{prevStyle:t,styleSheet:r})}let da=new Map;const P8=new S8;function sL(e){da=new Map(da),da.delete(e)}function eS(e,t){for(const[r]of da)if(r.id===e)return r}function ru(e,t){for(const[r,n]of da)if(r.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function $l(){return da}function D3(e,t){return P8.addListener("groupChange",r=>{r.group.id===e&&t(r)})}function ao(e,t,r){const n=da.get(e);da=new Map(da),da.set(e,t),P8.emit("groupChange",{group:e,isUserInteraction:r?.isUserInteraction===!0,prev:n,next:t})}function N8(e){const t=Cl();let r=!1;switch(t.state){case"active":sp({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(g3(e),r=!0,t.hitRegions.forEach(n=>{const s=ru(n.group.id,!0);ao(n.group,s,{isUserInteraction:!0})}))}return r}function tS(e){e.defaultPrevented||N8(e.currentTarget)}function iL(e,t,r){let n,s={x:1/0,y:1/0};for(const i of t){const a=T8(r,i.rect);switch(e){case"horizontal":{a.x<=s.x&&(n=i,s=a);break}case"vertical":{a.y<=s.y&&(n=i,s=a);break}}}return n?{distance:s,hitRegion:n}:void 0}function aL(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function oL(e,t){if(e===t)throw new Error("Cannot compare node with itself");const r={a:sS(e),b:sS(t)};let n;for(;r.a.at(-1)===r.b.at(-1);)n=r.a.pop(),r.b.pop();Mr(n,"Stacking order can only be calculated for elements with a common ancestor");const s={a:nS(rS(r.a)),b:nS(rS(r.b))};if(s.a===s.b){const i=n.childNodes,a={a:r.a.at(-1),b:r.b.at(-1)};let u=i.length;for(;u--;){const o=i[u];if(o===a.a)return 1;if(o===a.b)return-1}}return Math.sign(s.a-s.b)}const uL=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function lL(e){const t=getComputedStyle($8(e)??e).display;return t==="flex"||t==="inline-flex"}function cL(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||lL(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||uL.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function rS(e){let t=e.length;for(;t--;){const r=e[t];if(Mr(r,"Missing node"),cL(r))return r}return null}function nS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function sS(e){const t=[];for(;e;)t.push(e),e=$8(e);return t}function $8(e){const{parentNode:t}=e;return aL(t)?t.host:t}function pL(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function dL({groupElement:e,hitRegion:t,pointerEventTarget:r}){if(!C8(r)||r.contains(e)||e.contains(r))return!0;if(oL(r,e)>0){let n=r;for(;n;){if(n.contains(e))return!0;if(pL(n.getBoundingClientRect(),t))return!1;n=n.parentElement}}return!0}function x3(e,t){const r=[];return t.forEach((n,s)=>{if(s.disabled)return;const i=A8(s),a=iL(s.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&dL({groupElement:s.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&r.push(a.hitRegion)}),r}function fL(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!=t[r])return!1;return!0}function ts(e,t,r=0){return Math.abs(gs(e)-gs(t))<=r}function aa(e,t){return ts(e,t)?0:e>t?1:-1}function Vc({overrideDisabledPanels:e,panelConstraints:t,prevSize:r,size:n}){const{collapsedSize:s=0,collapsible:i,disabled:a,maxSize:u=100,minSize:o=0}=t;if(a&&!e)return r;if(aa(n,o)<0)if(i){const c=(s+o)/2;aa(n,c)<0?n=s:n=o}else n=o;return n=Math.min(u,n),n=gs(n),n}function Eh({delta:e,initialLayout:t,panelConstraints:r,pivotIndices:n,prevLayout:s,trigger:i}){if(ts(e,0))return t;const a=i==="imperative-api",u=Object.values(t),o=Object.values(s),c=[...u],[p,d]=n;Mr(p!=null,"Invalid first pivot index"),Mr(d!=null,"Invalid second pivot index");let h=0;switch(i){case"keyboard":{{const v=e<0?d:p,b=r[v];Mr(b,`Panel constraints not found for index ${v}`);const{collapsedSize:T=0,collapsible:D,minSize:x=0}=b;if(D){const E=u[v];if(Mr(E!=null,`Previous layout not found for panel index ${v}`),ts(E,T)){const A=x-E;aa(A,Math.abs(e))>0&&(e=e<0?0-A:A)}}}{const v=e<0?p:d,b=r[v];Mr(b,`No panel constraints found for index ${v}`);const{collapsedSize:T=0,collapsible:D,minSize:x=0}=b;if(D){const E=u[v];if(Mr(E!=null,`Previous layout not found for panel index ${v}`),ts(E,x)){const A=E-T;aa(A,Math.abs(e))>0&&(e=e<0?0-A:A)}}}break}default:{const v=e<0?d:p,b=r[v];Mr(b,`Panel constraints not found for index ${v}`);const T=u[v],{collapsible:D,collapsedSize:x,minSize:E}=b;if(D&&aa(T,E)<0)if(e>0){const A=E-x,F=A/2,k=T+e;aa(k,E)<0&&(e=aa(e,F)<=0?0:A)}else{const A=E-x,F=100-A/2,k=T-e;aa(k,E)<0&&(e=aa(100+e,F)>0?0:-A)}break}}{const v=e<0?1:-1;let b=e<0?d:p,T=0;for(;;){const x=u[b];Mr(x!=null,`Previous layout not found for panel index ${b}`);const E=Vc({overrideDisabledPanels:a,panelConstraints:r[b],prevSize:x,size:100})-x;if(T+=E,b+=v,b<0||b>=r.length)break}const D=Math.min(Math.abs(e),Math.abs(T));e=e<0?0-D:D}{let v=e<0?p:d;for(;v>=0&&v<r.length;){const b=Math.abs(e)-Math.abs(h),T=u[v];Mr(T!=null,`Previous layout not found for panel index ${v}`);const D=T-b,x=Vc({overrideDisabledPanels:a,panelConstraints:r[v],prevSize:T,size:D});if(!ts(T,x)&&(h+=T-x,c[v]=x,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(fL(o,c))return s;{const v=e<0?d:p,b=u[v];Mr(b!=null,`Previous layout not found for panel index ${v}`);const T=b+h,D=Vc({overrideDisabledPanels:a,panelConstraints:r[v],prevSize:b,size:T});if(c[v]=D,!ts(D,T)){let x=T-D,E=e<0?d:p;for(;E>=0&&E<r.length;){const A=c[E];Mr(A!=null,`Previous layout not found for panel index ${E}`);const F=A+x,k=Vc({overrideDisabledPanels:a,panelConstraints:r[E],prevSize:A,size:F});if(ts(A,k)||(x-=k-A,c[E]=k),ts(x,0))break;e>0?E--:E++}}}const m=Object.values(c).reduce((v,b)=>b+v,0);if(!ts(m,100,.1))return s;const y=Object.keys(s);return c.reduce((v,b,T)=>(v[y[T]]=b,v),{})}function Tl(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(t[r]===void 0||aa(e[r],t[r])!==0)return!1;return!0}function Al({layout:e,panelConstraints:t}){const r=Object.values(e),n=[...r],s=n.reduce((u,o)=>u+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(u=>`${u}%`).join(", ")}`);if(!ts(s,100)&&n.length>0)for(let u=0;u<t.length;u++){const o=n[u];Mr(o!=null,`No layout data found for index ${u}`);const c=100/s*o;n[u]=c}let i=0;for(let u=0;u<t.length;u++){const o=r[u];Mr(o!=null,`No layout data found for index ${u}`);const c=n[u];Mr(c!=null,`No layout data found for index ${u}`);const p=Vc({overrideDisabledPanels:!0,panelConstraints:t[u],prevSize:o,size:c});c!=p&&(i+=c-p,n[u]=p)}if(!ts(i,0))for(let u=0;u<t.length;u++){const o=n[u];Mr(o!=null,`No layout data found for index ${u}`);const c=o+i,p=Vc({overrideDisabledPanels:!0,panelConstraints:t[u],prevSize:o,size:c});if(o!==p&&(i-=p-o,n[u]=p,ts(i,0)))break}const a=Object.keys(e);return n.reduce((u,o,c)=>(u[a[c]]=o,u),{})}function I8({groupId:e,panelId:t}){const r=()=>{const o=$l();for(const[c,{defaultLayoutDeferred:p,derivedPanelConstraints:d,layout:h,groupSize:m,separatorToPanels:y}]of o)if(c.id===e)return{defaultLayoutDeferred:p,derivedPanelConstraints:d,group:c,groupSize:m,layout:h,separatorToPanels:y};throw Error(`Group ${e} not found`)},n=()=>{const o=r().derivedPanelConstraints.find(c=>c.panelId===t);if(o!==void 0)return o;throw Error(`Panel constraints not found for Panel ${t}`)},s=()=>{const o=r().group.panels.find(c=>c.id===t);if(o!==void 0)return o;throw Error(`Layout not found for Panel ${t}`)},i=()=>{const o=r().layout[t];if(o!==void 0)return o;throw Error(`Layout not found for Panel ${t}`)},a=({nextSize:o,panels:c,prevLayout:p,derivedPanelConstraints:d})=>{const h=i(),m=c.findIndex(b=>b.id===t),y=m===0,v=m===c.length-1;if(v&&o<h&&(y||c.slice(0,m).every((b,T)=>{const D=d[T];return D?.collapsible&&ts(D.collapsedSize,p[D.panelId])}))){const b=c.slice(0,m).reduce((T,D)=>T+p[D.id],0);return{...p,[t]:gs(100-b)}}return Eh({delta:v?h-o:o-h,initialLayout:p,panelConstraints:d,pivotIndices:v?[m-1,m]:[m,m+1],prevLayout:p,trigger:"imperative-api"})},u=o=>{const c=i();if(o===c)return;const{defaultLayoutDeferred:p,derivedPanelConstraints:d,group:h,groupSize:m,layout:y,separatorToPanels:v}=r(),b=a({nextSize:o,panels:h.panels,prevLayout:y,derivedPanelConstraints:d}),T=Al({layout:b,panelConstraints:d});Tl(y,T)||ao(h,{defaultLayoutDeferred:p,derivedPanelConstraints:d,groupSize:m,layout:T,separatorToPanels:v})};return{collapse:()=>{const{collapsible:o,collapsedSize:c}=n(),{mutableValues:p}=s(),d=i();o&&d!==c&&(p.expandToSize=d,u(c))},expand:()=>{const{collapsible:o,collapsedSize:c,minSize:p}=n(),{mutableValues:d}=s(),h=i();if(o&&h===c){let m=d.expandToSize??p;m===0&&(m=1),u(m)}},getSize:()=>{const{group:o}=r(),c=i(),{element:p}=s(),d=o.orientation==="horizontal"?p.offsetWidth:p.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:o,collapsedSize:c}=n(),p=i();return o&&ts(c,p)},resize:o=>{const{group:c}=r(),{element:p}=s(),d=Dp({group:c}),h=Bf({groupSize:d,panelElement:p,styleProp:o}),m=gs(h/d*100);u(m)}}}function iS(e){if(e.defaultPrevented)return;const t=$l();x3(e,t).forEach(r=>{if(r.separator&&!r.separator.disableDoubleClick){const n=r.panels.find(s=>s.panelConstraints.defaultSize!==void 0);if(n){const s=n.panelConstraints.defaultSize,i=I8({groupId:r.group.id,panelId:n.id});i&&s!==void 0&&(i.resize(s),e.preventDefault())}}})}function lg(e){const t=$l();for(const[r]of t)if(r.separators.some(n=>n.element===e))return r;throw Error("Could not find parent Group for separator element")}function B8({groupId:e}){const t=()=>{const r=$l();for(const[n,s]of r)if(n.id===e)return{group:n,...s};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:r,layout:n}=t();return r?{}:n},setLayout(r){const{defaultLayoutDeferred:n,derivedPanelConstraints:s,group:i,groupSize:a,layout:u,separatorToPanels:o}=t(),c=Al({layout:r,panelConstraints:s});return n?u:(Tl(u,c)||ao(i,{defaultLayoutDeferred:n,derivedPanelConstraints:s,groupSize:a,layout:c,separatorToPanels:o}),c)}}}function Wu(e,t){const r=lg(e),n=ru(r.id,!0),s=r.separators.find(p=>p.element===e);Mr(s,"Matching separator not found");const i=n.separatorToPanels.get(s);Mr(i,"Matching panels not found");const a=i.map(p=>r.panels.indexOf(p)),u=B8({groupId:r.id}).getLayout(),o=Eh({delta:t,initialLayout:u,panelConstraints:n.derivedPanelConstraints,pivotIndices:a,prevLayout:u,trigger:"keyboard"}),c=Al({layout:o,panelConstraints:n.derivedPanelConstraints});Tl(u,c)||ao(r,{defaultLayoutDeferred:n.defaultLayoutDeferred,derivedPanelConstraints:n.derivedPanelConstraints,groupSize:n.groupSize,layout:c,separatorToPanels:n.separatorToPanels},{isUserInteraction:!0})}function aS(e){if(e.defaultPrevented)return;const t=e.currentTarget,r=lg(t);if(!r.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),r.orientation==="vertical"&&Wu(t,5);break}case"ArrowLeft":{e.preventDefault(),r.orientation==="horizontal"&&Wu(t,-5);break}case"ArrowRight":{e.preventDefault(),r.orientation==="horizontal"&&Wu(t,5);break}case"ArrowUp":{e.preventDefault(),r.orientation==="vertical"&&Wu(t,-5);break}case"End":{e.preventDefault(),Wu(t,100);break}case"Enter":{e.preventDefault();const n=lg(t),s=ru(n.id,!0),{derivedPanelConstraints:i,layout:a,separatorToPanels:u}=s,o=n.separators.find(h=>h.element===t);Mr(o,"Matching separator not found");const c=u.get(o);Mr(c,"Matching panels not found");const p=c[0],d=i.find(h=>h.panelId===p.id);if(Mr(d,"Panel metadata not found"),d.collapsible){const h=a[p.id],m=d.collapsedSize===h?n.mutableState.expandedPanelSizes[p.id]??d.minSize:d.collapsedSize;Wu(t,m-h)}break}case"F6":{e.preventDefault();const n=lg(t).separators.map(a=>a.element),s=Array.from(n).findIndex(a=>a===e.currentTarget);Mr(s!==null,"Index not found");const i=e.shiftKey?s>0?s-1:n.length-1:s+1<n.length?s+1:0;n[i].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Wu(t,-100);break}}}function oS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=$l(),r=x3(e,t),n=new Map;let s=!1;r.forEach(i=>{i.separator&&(s||(s=!0,i.separator.element.focus({focusVisible:!1,preventScroll:!0})));const a=t.get(i.group);a&&n.set(i.group,a.layout)}),sp({cursorFlags:0,hitRegions:r,initialLayoutMap:n,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),r.length&&e.preventDefault()}function j8({document:e,event:t,hitRegions:r,initialLayoutMap:n,mountedGroups:s,pointerDownAtPoint:i,prevCursorFlags:a}){let u=0;r.forEach(c=>{const{group:p,groupSize:d}=c,{orientation:h,panels:m}=p,{disableCursor:y}=p.mutableState;let v=0;i?h==="horizontal"?v=(t.clientX-i.x)/d*100:v=(t.clientY-i.y)/d*100:h==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const b=n.get(p),T=s.get(p);if(!b||!T)return;const{defaultLayoutDeferred:D,derivedPanelConstraints:x,groupSize:E,layout:A,separatorToPanels:F}=T;if(x&&A&&F){const k=Eh({delta:v,initialLayout:b,panelConstraints:x,pivotIndices:c.panels.map(_=>m.indexOf(_)),prevLayout:A,trigger:"mouse-or-touch"});if(Tl(k,A)){if(v!==0&&!y)switch(h){case"horizontal":{u|=v<0?F8:w8;break}case"vertical":{u|=v<0?k8:_8;break}}}else ao(c.group,{defaultLayoutDeferred:D,derivedPanelConstraints:x,groupSize:E,layout:k,separatorToPanels:F})}});let o=0;t.movementX===0?o|=a&XA:o|=u&XA,t.movementY===0?o|=a&YA:o|=u&YA,tL(o),g3(e)}function uS(e){const t=$l(),r=Cl();switch(r.state){case"active":j8({document:e.currentTarget,event:e,hitRegions:r.hitRegions,initialLayoutMap:r.initialLayoutMap,mountedGroups:t,prevCursorFlags:r.cursorFlags})}}function lS(e){if(e.defaultPrevented)return;const t=Cl(),r=$l();switch(t.state){case"active":{if(e.buttons===0){sp({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(n=>{const s=ru(n.group.id,!0);ao(n.group,s,{isUserInteraction:!0})});return}for(const n of t.hitRegions)if(n.separator){const{element:s}=n.separator;s.hasPointerCapture?.(e.pointerId)||s.setPointerCapture?.(e.pointerId)}j8({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:r,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const n=x3(e,r);n.length===0?t.state!=="inactive"&&sp({cursorFlags:0,state:"inactive"}):sp({cursorFlags:0,hitRegions:n,state:"hover"}),g3(e.currentTarget);break}}}function cS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Cl().state){case"hover":sp({cursorFlags:0,state:"inactive"})}}function pS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||N8(e.currentTarget)&&e.preventDefault()}function dS(e){let t=0,r=0;const n={};for(const i of e)if(i.defaultSize!==void 0){t++;const a=gs(i.defaultSize);r+=a,n[i.panelId]=a}else n[i.panelId]=void 0;const s=e.length-t;if(s!==0){const i=gs((100-r)/s);for(const a of e)a.defaultSize===void 0&&(n[a.panelId]=i)}return n}function hL(e,t,r){if(!r[0])return;const n=e.panels.find(o=>o.element===t);if(!n||!n.onResize)return;const s=Dp({group:e}),i=e.orientation==="horizontal"?n.element.offsetWidth:n.element.offsetHeight,a=n.mutableValues.prevSize,u={asPercentage:gs(i/s*100),inPixels:i};n.mutableValues.prevSize=u,n.onResize(u,n.id,a)}function mL(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function yL({group:e,nextGroupSize:t,prevGroupSize:r,prevLayout:n}){if(r<=0||t<=0||r===t)return n;let s=0,i=0,a=!1;const u=new Map,o=[];for(const d of e.panels){const h=n[d.id]??0;switch(d.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{a=!0;const m=h/100*r,y=gs(m/t*100);u.set(d.id,y),s+=y;break}case"preserve-relative-size":default:{o.push(d.id),i+=h;break}}}if(!a||o.length===0)return n;const c=100-s,p={...n};if(u.forEach((d,h)=>{p[h]=d}),i>0)for(const d of o){const h=n[d]??0;p[d]=gs(h/i*c)}else{const d=gs(c/o.length);for(const h of o)p[h]=d}return p}function gL(e,t){const r=e.map(s=>s.id),n=Object.keys(t);if(r.length!==n.length)return!1;for(const s of r)if(!n.includes(s))return!1;return!0}const vc=new Map;function DL(e){let t=!0;Mr(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const r=e.element.ownerDocument.defaultView.ResizeObserver,n=new Set,s=new Set,i=new r(y=>{for(const v of y){const{borderBoxSize:b,target:T}=v;if(T===e.element){if(t){const D=Dp({group:e});if(D===0)return;const x=ru(e.id);if(!x)return;const E=Sv(e),A=x.defaultLayoutDeferred?dS(E):x.layout,F=yL({group:e,nextGroupSize:D,prevGroupSize:x.groupSize,prevLayout:A}),k=Al({layout:F,panelConstraints:E});if(!x.defaultLayoutDeferred&&Tl(x.layout,k)&&mL(x.derivedPanelConstraints,E)&&x.groupSize===D)return;ao(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:E,groupSize:D,layout:k,separatorToPanels:x.separatorToPanels})}}else hL(e,T,b)}});i.observe(e.element),e.panels.forEach(y=>{Mr(!n.has(y.id),`Panel ids must be unique; id "${y.id}" was used more than once`),n.add(y.id),y.onResize&&i.observe(y.element)});const a=Dp({group:e}),u=Sv(e),o=e.panels.map(({id:y})=>y).join(",");let c=e.mutableState.defaultLayout;c&&(gL(e.panels,c)||(c=void 0));const p=e.mutableState.layouts[o]??c??dS(u),d=Al({layout:p,panelConstraints:u}),h=e.element.ownerDocument;vc.set(h,(vc.get(h)??0)+1);const m=new Map;return A8(e).forEach(y=>{y.separator&&m.set(y.separator,y.panels)}),ao(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:u,groupSize:a,layout:d,separatorToPanels:m}),e.separators.forEach(y=>{Mr(!s.has(y.id),`Separator ids must be unique; id "${y.id}" was used more than once`),s.add(y.id),y.element.addEventListener("keydown",aS)}),vc.get(h)===1&&(h.addEventListener("contextmenu",tS,!0),h.addEventListener("dblclick",iS,!0),h.addEventListener("pointerdown",oS,!0),h.addEventListener("pointerleave",uS),h.addEventListener("pointermove",lS),h.addEventListener("pointerout",cS),h.addEventListener("pointerup",pS,!0)),function(){t=!1,vc.set(h,Math.max(0,(vc.get(h)??0)-1)),sL(e),e.separators.forEach(y=>{y.element.removeEventListener("keydown",aS)}),vc.get(h)||(h.removeEventListener("contextmenu",tS,!0),h.removeEventListener("dblclick",iS,!0),h.removeEventListener("pointerdown",oS,!0),h.removeEventListener("pointerleave",uS),h.removeEventListener("pointermove",lS),h.removeEventListener("pointerout",cS),h.removeEventListener("pointerup",pS,!0)),i.disconnect()}}function xL(){const[e,t]=se.useState({}),r=se.useCallback(()=>t({}),[]);return[e,r]}function b3(e){const t=se.useId();return`${e??t}`}const Il=typeof window<"u"?se.useLayoutEffect:se.useEffect;function Qf(e){const t=se.useRef(e);return Il(()=>{t.current=e},[e]),se.useCallback((...r)=>t.current?.(...r),[t])}function v3(...e){return Qf(t=>{e.forEach(r=>{if(r)switch(typeof r){case"function":{r(t);break}case"object":{r.current=t;break}}})})}function E3(e){const t=se.useRef({...e});return Il(()=>{for(const r in e)t.current[r]=e[r]},[e]),t.current}const O8=se.createContext(null);function bL(e,t){const r=se.useRef({getLayout:()=>({}),setLayout:rL});se.useImperativeHandle(t,()=>r.current,[]),Il(()=>{Object.assign(r.current,B8({groupId:e}))})}function L8({children:e,className:t,defaultLayout:r,disableCursor:n,disabled:s,elementRef:i,groupRef:a,id:u,onLayoutChange:o,onLayoutChanged:c,orientation:p="horizontal",resizeTargetMinimumSize:d={coarse:20,fine:10},style:h,...m}){const y=se.useRef({onLayoutChange:{},onLayoutChanged:{}}),v=Qf(j=>{Tl(y.current.onLayoutChange,j)||(y.current.onLayoutChange=j,o?.(j))}),b=Qf((j,V)=>{Tl(y.current.onLayoutChanged,j)||(y.current.onLayoutChanged=j,c?.(j,{isUserInteraction:V}))}),T=b3(u),D=se.useRef(null),[x,E]=xL(),A=se.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),F=v3(D,i);bL(T,a);const k=Qf((j,V)=>{const z=Cl(),oe=eS(j),L=ru(j);if(L){let ne=!1;switch(z.state){case"active":{ne=z.hitRegions.some(Ee=>Ee.group===oe);break}}return{flexGrow:L.layout[V]??1,pointerEvents:ne?"none":void 0}}if(r?.[V])return{flexGrow:r?.[V]}}),_=E3({defaultLayout:r,disableCursor:n}),O=se.useMemo(()=>({get disableCursor(){return!!_.disableCursor},getPanelStyles:k,id:T,orientation:p,registerPanel:j=>{const V=A.current;return V.panels=Fv(p,[...V.panels,j]),E(),()=>{V.panels=V.panels.filter(z=>z!==j),E()}},registerSeparator:j=>{const V=A.current;return V.separators=Fv(p,[...V.separators,j]),E(),()=>{V.separators=V.separators.filter(z=>z!==j),E()}},updatePanelProps:(j,{disabled:V})=>{const z=A.current.panels.find(ne=>ne.id===j);z&&(z.panelConstraints.disabled=V);const oe=eS(T),L=ru(T);oe&&L&&ao(oe,{...L,derivedPanelConstraints:Sv(oe)})},updateSeparatorProps:(j,{disabled:V,disableDoubleClick:z})=>{const oe=A.current.separators.find(L=>L.id===j);oe&&(oe.disabled=V,oe.disableDoubleClick=z)}}),[k,T,E,p,_]),q=se.useRef(null);return Il(()=>{const j=D.current;if(j===null)return;const V=A.current;let z;if(_.defaultLayout!==void 0&&Object.keys(_.defaultLayout).length===V.panels.length){z={};for(const K of V.panels){const Q=_.defaultLayout[K.id];Q!==void 0&&(z[K.id]=Q)}}const oe={disabled:!!s,element:j,id:T,mutableState:{defaultLayout:z,disableCursor:!!_.disableCursor,expandedPanelSizes:A.current.lastExpandedPanelSizes,layouts:A.current.layouts},orientation:p,panels:V.panels,resizeTargetMinimumSize:V.resizeTargetMinimumSize,separators:V.separators};q.current=oe;const L=DL(oe),{defaultLayoutDeferred:ne,derivedPanelConstraints:Ee,layout:X}=ru(oe.id,!0);!ne&&Ee.length>0&&(v(X),b(X,!1));const je=D3(T,K=>{const{defaultLayoutDeferred:Q,derivedPanelConstraints:ie,layout:M}=K.next;if(Q||ie.length===0)return;const B=oe.panels.map(({id:J})=>J).join(",");oe.mutableState.layouts[B]=M,ie.forEach(J=>{if(J.collapsible){const{layout:de}=K.prev??{};if(de){const Ce=ts(J.collapsedSize,M[J.panelId]),Me=ts(J.collapsedSize,de[J.panelId]);Ce&&!Me&&(oe.mutableState.expandedPanelSizes[J.panelId]=de[J.panelId])}}});const U=Cl().state!=="active";v(M),U&&b(M,K.isUserInteraction)});return()=>{q.current=null,L(),je()}},[s,T,b,v,p,x,_]),se.useEffect(()=>{const j=q.current;j&&(j.mutableState.defaultLayout=r,j.mutableState.disableCursor=!!n)}),S.jsx(O8.Provider,{value:O,children:S.jsx("div",{...m,className:t,"data-group":!0,"data-testid":T,id:T,ref:F,style:{height:"100%",width:"100%",overflow:"hidden",...h,display:"flex",flexDirection:p==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:p==="horizontal"?"pan-y":"pan-x"},children:e})})}L8.displayName="Group";function cg(e,t){return`react-resizable-panels:${[e,...t].join(":")}`}function vL({id:e,panelIds:t,storage:r}){const n=cg(e,[]),s=r.getItem(n);if(s)try{const i=JSON.parse(s);if(t){const a=t.join(","),u=i[a];if(u&&Array.isArray(u.layout)&&t.length===u.layout.length){const o={};for(let c=0;c<t.length;c++)o[t[c]]=u.layout[c];return o}}else{const a=Object.keys(i);if(a.length===1){const u=i[a[0]];if(u&&Array.isArray(u.layout)){const o=a[0].split(",");if(o.length===u.layout.length){const c={};for(let p=0;p<o.length;p++)c[o[p]]=u.layout[p];return c}}}}}catch{}}function C3({debounceSaveMs:e=100,onlySaveAfterUserInteractions:t,panelIds:r,storage:n=localStorage,...s}){const i=r!==void 0,a="id"in s?s.id:s.groupId,u=cg(a,r??[]),o=se.useSyncExternalStore(EL,()=>n.getItem(u),()=>n.getItem(u)),c=se.useMemo(()=>{if(o){const b=JSON.parse(o),T=Object.values(b);if(Array.from(T).every(D=>typeof D=="number"))return b}},[o]),p=se.useMemo(()=>{if(!c)return vL({id:a,panelIds:r,storage:n})},[c,a,r,n]),d=c??p,h=se.useRef(null),m=se.useCallback(()=>{const b=h.current;b&&(h.current=null,clearTimeout(b))},[]);se.useLayoutEffect(()=>()=>{m()},[m]);const y=se.useCallback((b,T)=>{if(t&&!T.isUserInteraction)return;m();let D;i?D=cg(a,Object.keys(b)):D=cg(a,[]);try{n.setItem(D,JSON.stringify(b))}catch(x){console.error(x)}},[m,i,a,t,n]),v=se.useCallback(b=>{m(),e===0?y(b,{isUserInteraction:!1}):h.current=setTimeout(()=>{y(b,{isUserInteraction:!1})},e)},[m,e,y]);return{defaultLayout:d,onLayoutChange:v,onLayoutChanged:y}}function EL(){return function(){}}function T3(){const e=se.useContext(O8);return Mr(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function CL(e,t){const{id:r}=T3(),n=se.useRef({collapse:ab,expand:ab,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:ab});se.useImperativeHandle(t,()=>n.current,[]),Il(()=>{Object.assign(n.current,I8({groupId:r,panelId:e}))})}function M8({children:e,className:t,collapsedSize:r="0%",collapsible:n=!1,defaultSize:s,disabled:i,elementRef:a,groupResizeBehavior:u="preserve-relative-size",id:o,maxSize:c="100%",minSize:p="0%",onResize:d,panelRef:h,style:m,...y}){const v=!!o,b=b3(o),T=E3({disabled:i}),D=se.useRef(null),x=v3(D,a),{getPanelStyles:E,id:A,orientation:F,registerPanel:k,updatePanelProps:_}=T3(),O=d!==null,q=Qf((oe,L,ne)=>{d?.(oe,o,ne)});Il(()=>{const oe=D.current;if(oe!==null){const L={element:oe,id:b,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:O?q:void 0,panelConstraints:{groupResizeBehavior:u,collapsedSize:r,collapsible:n,defaultSize:s,disabled:T.disabled,maxSize:c,minSize:p}};return k(L)}},[u,r,n,s,O,b,v,c,p,q,k,T]),se.useEffect(()=>{_(b,{disabled:i})},[i,b,_]),CL(b,h);const j=()=>{const oe=E(A,b);if(oe)return JSON.stringify(oe)},V=se.useSyncExternalStore(oe=>D3(A,oe),j,j);let z;return V?z=JSON.parse(V):s!==void 0?z={flexGrow:void 0,flexShrink:void 0,flexBasis:s}:z={flexGrow:1},S.jsx("div",{...y,"data-disabled":i||void 0,"data-panel":!0,"data-testid":b,id:b,ref:x,style:{...TL,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...z},children:S.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...m,touchAction:F==="horizontal"?"pan-y":"pan-x"},children:e})})}M8.displayName="Panel";const TL={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function AL({layout:e,panelConstraints:t,panelId:r,panelIndex:n}){let s,i;const a=e[r],u=t.find(o=>o.panelId===r);if(u){const o=u.maxSize,c=u.collapsible?u.collapsedSize:u.minSize,p=[n,n+1];i=Al({layout:Eh({delta:c-a,initialLayout:e,panelConstraints:t,pivotIndices:p,prevLayout:e}),panelConstraints:t})[r],s=Al({layout:Eh({delta:o-a,initialLayout:e,panelConstraints:t,pivotIndices:p,prevLayout:e}),panelConstraints:t})[r]}return{valueControls:r,valueMax:s,valueMin:i,valueNow:a}}function R8({children:e,className:t,disabled:r,disableDoubleClick:n,elementRef:s,id:i,style:a,...u}){const o=b3(i),c=E3({disabled:r,disableDoubleClick:n}),[p,d]=se.useState({}),[h,m]=se.useState("inactive"),[y,v]=se.useState(!1),b=se.useRef(null),T=v3(b,s),{disableCursor:D,id:x,orientation:E,registerSeparator:A,updateSeparatorProps:F}=T3(),k=E==="horizontal"?"vertical":"horizontal";Il(()=>{const q=b.current;if(q!==null){const j={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:q,id:o},V=A(j),z=eL(L=>{m(L.next.state!=="inactive"&&L.next.hitRegions.some(ne=>ne.separator===j)?L.next.state:"inactive")}),oe=D3(x,L=>{const{derivedPanelConstraints:ne,layout:Ee,separatorToPanels:X}=L.next,je=X.get(j);if(je){const K=je[0],Q=je.indexOf(K);d(AL({layout:Ee,panelConstraints:ne,panelId:K.id,panelIndex:Q}))}});return()=>{z(),oe(),V()}}},[x,o,A,c]),se.useEffect(()=>{F(o,{disabled:r,disableDoubleClick:n})},[r,n,o,F]);let _;r&&!D&&(_="not-allowed");let O;if(r)O="disabled";else switch(h){case"active":{O="active";break}default:y?O="focus":O=h}return S.jsx("div",{...u,"aria-controls":p.valueControls,"aria-disabled":r||void 0,"aria-orientation":k,"aria-valuemax":p.valueMax,"aria-valuemin":p.valueMin,"aria-valuenow":p.valueNow,children:e,className:t,"data-separator":O,"data-testid":o,id:o,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:T,role:"separator",style:{flexBasis:"auto",cursor:_,...a,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:r?void 0:0})}R8.displayName="Separator";function A3({className:e,...t}){return S.jsx(L8,{"data-slot":"resizable-panel-group",className:n8("flex h-full w-full aria-[orientation=vertical]:flex-col",e),...t})}function hl({...e}){return S.jsx(M8,{"data-slot":"resizable-panel",...e})}function jg({withHandle:e,className:t,...r}){return S.jsx(R8,{"data-slot":"resizable-handle",className:n8("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),...r,children:e&&S.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-xs border bg-border",children:S.jsx(u3,{className:"size-2.5"})})})}function SL(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}const FL=e=>{switch(e){case"success":return _L;case"info":return NL;case"warning":return PL;case"error":return $L;default:return null}},wL=Array(12).fill(0),kL=({visible:e,className:t})=>pt.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},pt.createElement("div",{className:"sonner-spinner"},wL.map((r,n)=>pt.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),_L=pt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},pt.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),PL=pt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},pt.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),NL=pt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},pt.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),$L=pt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},pt.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),IL=pt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},pt.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),pt.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),BL=()=>{const[e,t]=pt.useState(document.hidden);return pt.useEffect(()=>{const r=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),e};let wv=1;class jL{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const r=this.subscribers.indexOf(t);this.subscribers.splice(r,1)}),this.publish=t=>{this.subscribers.forEach(r=>r(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var r;const{message:n,...s}=t,i=typeof t?.id=="number"||((r=t.id)==null?void 0:r.length)>0?t.id:wv++,a=this.toasts.find(o=>o.id===i),u=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(i)&&this.dismissedToasts.delete(i),a?this.toasts=this.toasts.map(o=>o.id===i?(this.publish({...o,...t,id:i,title:n}),{...o,...t,id:i,dismissible:u,title:n}):o):this.addToast({title:n,...s,dismissible:u,id:i}),i},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(r=>r({id:t,dismiss:!0})))):this.toasts.forEach(r=>{this.subscribers.forEach(n=>n({id:r.id,dismiss:!0}))}),t),this.message=(t,r)=>this.create({...r,message:t}),this.error=(t,r)=>this.create({...r,message:t,type:"error"}),this.success=(t,r)=>this.create({...r,type:"success",message:t}),this.info=(t,r)=>this.create({...r,type:"info",message:t}),this.warning=(t,r)=>this.create({...r,type:"warning",message:t}),this.loading=(t,r)=>this.create({...r,type:"loading",message:t}),this.promise=(t,r)=>{if(!r)return;let n;r.loading!==void 0&&(n=this.create({...r,promise:t,type:"loading",message:r.loading,description:typeof r.description!="function"?r.description:void 0}));const s=Promise.resolve(t instanceof Function?t():t);let i=n!==void 0,a;const u=s.then(async c=>{if(a=["resolve",c],pt.isValidElement(c))i=!1,this.create({id:n,type:"default",message:c});else if(LL(c)&&!c.ok){i=!1;const d=typeof r.error=="function"?await r.error(`HTTP error! status: ${c.status}`):r.error,h=typeof r.description=="function"?await r.description(`HTTP error! status: ${c.status}`):r.description,y=typeof d=="object"&&!pt.isValidElement(d)?d:{message:d};this.create({id:n,type:"error",description:h,...y})}else if(c instanceof Error){i=!1;const d=typeof r.error=="function"?await r.error(c):r.error,h=typeof r.description=="function"?await r.description(c):r.description,y=typeof d=="object"&&!pt.isValidElement(d)?d:{message:d};this.create({id:n,type:"error",description:h,...y})}else if(r.success!==void 0){i=!1;const d=typeof r.success=="function"?await r.success(c):r.success,h=typeof r.description=="function"?await r.description(c):r.description,y=typeof d=="object"&&!pt.isValidElement(d)?d:{message:d};this.create({id:n,type:"success",description:h,...y})}}).catch(async c=>{if(a=["reject",c],r.error!==void 0){i=!1;const p=typeof r.error=="function"?await r.error(c):r.error,d=typeof r.description=="function"?await r.description(c):r.description,m=typeof p=="object"&&!pt.isValidElement(p)?p:{message:p};this.create({id:n,type:"error",description:d,...m})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),r.finally==null||r.finally.call(r)}),o=()=>new Promise((c,p)=>u.then(()=>a[0]==="reject"?p(a[1]):c(a[1])).catch(p));return typeof n!="string"&&typeof n!="number"?{unwrap:o}:Object.assign(n,{unwrap:o})},this.custom=(t,r)=>{const n=r?.id||wv++;return this.create({jsx:t(n),id:n,...r}),n},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const _s=new jL,OL=(e,t)=>{const r=t?.id||wv++;return _s.addToast({title:e,...t,id:r}),r},LL=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",ML=OL,RL=()=>_s.toasts,UL=()=>_s.getActiveToasts(),wt=Object.assign(ML,{success:_s.success,info:_s.info,warning:_s.warning,error:_s.error,custom:_s.custom,message:_s.message,promise:_s.promise,dismiss:_s.dismiss,loading:_s.loading},{getHistory:RL,getToasts:UL});SL("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Y1(e){return e.label!==void 0}const zL=3,qL="24px",JL="16px",fS=4e3,KL=356,VL=14,WL=45,HL=200;function ea(...e){return e.filter(Boolean).join(" ")}function GL(e){const[t,r]=e.split("-"),n=[];return t&&n.push(t),r&&n.push(r),n}const XL=e=>{var t,r,n,s,i,a,u,o,c;const{invert:p,toast:d,unstyled:h,interacting:m,setHeights:y,visibleToasts:v,heights:b,index:T,toasts:D,expanded:x,removeToast:E,defaultRichColors:A,closeButton:F,style:k,cancelButtonStyle:_,actionButtonStyle:O,className:q="",descriptionClassName:j="",duration:V,position:z,gap:oe,expandByDefault:L,classNames:ne,icons:Ee,closeButtonAriaLabel:X="Close toast"}=e,[je,K]=pt.useState(null),[Q,ie]=pt.useState(null),[M,B]=pt.useState(!1),[U,J]=pt.useState(!1),[de,Ce]=pt.useState(!1),[Me,Ue]=pt.useState(!1),[re,le]=pt.useState(!1),[xe,Ie]=pt.useState(0),[st,rt]=pt.useState(0),Ct=pt.useRef(d.duration||V||fS),dt=pt.useRef(null),bt=pt.useRef(null),tr=T===0,cr=T+1<=v,Vt=d.type,Gt=d.dismissible!==!1,vr=d.className||"",Sr=d.descriptionClassName||"",et=pt.useMemo(()=>b.findIndex(De=>De.toastId===d.id)||0,[b,d.id]),Wt=pt.useMemo(()=>{var De;return(De=d.closeButton)!=null?De:F},[d.closeButton,F]),me=pt.useMemo(()=>d.duration||V||fS,[d.duration,V]),Le=pt.useRef(0),ze=pt.useRef(0),lt=pt.useRef(0),Ot=pt.useRef(null),[Yt,ar]=z.split("-"),kr=pt.useMemo(()=>b.reduce((De,Ne,at)=>at>=et?De:De+Ne.height,0),[b,et]),xr=BL(),er=d.invert||p,is=Vt==="loading";ze.current=pt.useMemo(()=>et*oe+kr,[et,kr]),pt.useEffect(()=>{Ct.current=me},[me]),pt.useEffect(()=>{B(!0)},[]),pt.useEffect(()=>{const De=bt.current;if(De){const Ne=De.getBoundingClientRect().height;return rt(Ne),y(at=>[{toastId:d.id,height:Ne,position:d.position},...at]),()=>y(at=>at.filter(ut=>ut.toastId!==d.id))}},[y,d.id]),pt.useLayoutEffect(()=>{if(!M)return;const De=bt.current,Ne=De.style.height;De.style.height="auto";const at=De.getBoundingClientRect().height;De.style.height=Ne,rt(at),y(ut=>ut.find(Qe=>Qe.toastId===d.id)?ut.map(Qe=>Qe.toastId===d.id?{...Qe,height:at}:Qe):[{toastId:d.id,height:at,position:d.position},...ut])},[M,d.title,d.description,y,d.id,d.jsx,d.action,d.cancel]);const Ir=pt.useCallback(()=>{J(!0),Ie(ze.current),y(De=>De.filter(Ne=>Ne.toastId!==d.id)),setTimeout(()=>{E(d)},HL)},[d,E,y,ze]);pt.useEffect(()=>{if(d.promise&&Vt==="loading"||d.duration===1/0||d.type==="loading")return;let De;return x||m||xr?(()=>{if(lt.current<Le.current){const ut=new Date().getTime()-Le.current;Ct.current=Ct.current-ut}lt.current=new Date().getTime()})():(()=>{Ct.current!==1/0&&(Le.current=new Date().getTime(),De=setTimeout(()=>{d.onAutoClose==null||d.onAutoClose.call(d,d),Ir()},Ct.current))})(),()=>clearTimeout(De)},[x,m,d,Vt,xr,Ir]),pt.useEffect(()=>{d.delete&&(Ir(),d.onDismiss==null||d.onDismiss.call(d,d))},[Ir,d.delete]);function Wn(){var De;if(Ee?.loading){var Ne;return pt.createElement("div",{className:ea(ne?.loader,d==null||(Ne=d.classNames)==null?void 0:Ne.loader,"sonner-loader"),"data-visible":Vt==="loading"},Ee.loading)}return pt.createElement(kL,{className:ea(ne?.loader,d==null||(De=d.classNames)==null?void 0:De.loader),visible:Vt==="loading"})}const Xr=d.icon||Ee?.[Vt]||FL(Vt);var Br,be;return pt.createElement("li",{tabIndex:0,ref:bt,className:ea(q,vr,ne?.toast,d==null||(t=d.classNames)==null?void 0:t.toast,ne?.default,ne?.[Vt],d==null||(r=d.classNames)==null?void 0:r[Vt]),"data-sonner-toast":"","data-rich-colors":(Br=d.richColors)!=null?Br:A,"data-styled":!(d.jsx||d.unstyled||h),"data-mounted":M,"data-promise":!!d.promise,"data-swiped":re,"data-removed":U,"data-visible":cr,"data-y-position":Yt,"data-x-position":ar,"data-index":T,"data-front":tr,"data-swiping":de,"data-dismissible":Gt,"data-type":Vt,"data-invert":er,"data-swipe-out":Me,"data-swipe-direction":Q,"data-expanded":!!(x||L&&M),"data-testid":d.testId,style:{"--index":T,"--toasts-before":T,"--z-index":D.length-T,"--offset":`${U?xe:ze.current}px`,"--initial-height":L?"auto":`${st}px`,...k,...d.style},onDragEnd:()=>{Ce(!1),K(null),Ot.current=null},onPointerDown:De=>{De.button!==2&&(is||!Gt||(dt.current=new Date,Ie(ze.current),De.target.setPointerCapture(De.pointerId),De.target.tagName!=="BUTTON"&&(Ce(!0),Ot.current={x:De.clientX,y:De.clientY})))},onPointerUp:()=>{var De,Ne,at;if(Me||!Gt)return;Ot.current=null;const ut=Number(((De=bt.current)==null?void 0:De.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),yt=Number(((Ne=bt.current)==null?void 0:Ne.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Qe=new Date().getTime()-((at=dt.current)==null?void 0:at.getTime()),Nt=je==="x"?ut:yt,rr=Math.abs(Nt)/Qe;if(Math.abs(Nt)>=WL||rr>.11){Ie(ze.current),d.onDismiss==null||d.onDismiss.call(d,d),ie(je==="x"?ut>0?"right":"left":yt>0?"down":"up"),Ir(),Ue(!0);return}else{var jt,gt;(jt=bt.current)==null||jt.style.setProperty("--swipe-amount-x","0px"),(gt=bt.current)==null||gt.style.setProperty("--swipe-amount-y","0px")}le(!1),Ce(!1),K(null)},onPointerMove:De=>{var Ne,at,ut;if(!Ot.current||!Gt||((Ne=window.getSelection())==null?void 0:Ne.toString().length)>0)return;const Qe=De.clientY-Ot.current.y,Nt=De.clientX-Ot.current.x;var rr;const jt=(rr=e.swipeDirections)!=null?rr:GL(z);!je&&(Math.abs(Nt)>1||Math.abs(Qe)>1)&&K(Math.abs(Nt)>Math.abs(Qe)?"x":"y");let gt={x:0,y:0};const Hn=pr=>1/(1.5+Math.abs(pr)/20);if(je==="y"){if(jt.includes("top")||jt.includes("bottom"))if(jt.includes("top")&&Qe<0||jt.includes("bottom")&&Qe>0)gt.y=Qe;else{const pr=Qe*Hn(Qe);gt.y=Math.abs(pr)<Math.abs(Qe)?pr:Qe}}else if(je==="x"&&(jt.includes("left")||jt.includes("right")))if(jt.includes("left")&&Nt<0||jt.includes("right")&&Nt>0)gt.x=Nt;else{const pr=Nt*Hn(Nt);gt.x=Math.abs(pr)<Math.abs(Nt)?pr:Nt}(Math.abs(gt.x)>0||Math.abs(gt.y)>0)&&le(!0),(at=bt.current)==null||at.style.setProperty("--swipe-amount-x",`${gt.x}px`),(ut=bt.current)==null||ut.style.setProperty("--swipe-amount-y",`${gt.y}px`)}},Wt&&!d.jsx&&Vt!=="loading"?pt.createElement("button",{"aria-label":X,"data-disabled":is,"data-close-button":!0,onClick:is||!Gt?()=>{}:()=>{Ir(),d.onDismiss==null||d.onDismiss.call(d,d)},className:ea(ne?.closeButton,d==null||(n=d.classNames)==null?void 0:n.closeButton)},(be=Ee?.close)!=null?be:IL):null,(Vt||d.icon||d.promise)&&d.icon!==null&&(Ee?.[Vt]!==null||d.icon)?pt.createElement("div",{"data-icon":"",className:ea(ne?.icon,d==null||(s=d.classNames)==null?void 0:s.icon)},d.promise||d.type==="loading"&&!d.icon?d.icon||Wn():null,d.type!=="loading"?Xr:null):null,pt.createElement("div",{"data-content":"",className:ea(ne?.content,d==null||(i=d.classNames)==null?void 0:i.content)},pt.createElement("div",{"data-title":"",className:ea(ne?.title,d==null||(a=d.classNames)==null?void 0:a.title)},d.jsx?d.jsx:typeof d.title=="function"?d.title():d.title),d.description?pt.createElement("div",{"data-description":"",className:ea(j,Sr,ne?.description,d==null||(u=d.classNames)==null?void 0:u.description)},typeof d.description=="function"?d.description():d.description):null),pt.isValidElement(d.cancel)?d.cancel:d.cancel&&Y1(d.cancel)?pt.createElement("button",{"data-button":!0,"data-cancel":!0,style:d.cancelButtonStyle||_,onClick:De=>{Y1(d.cancel)&&Gt&&(d.cancel.onClick==null||d.cancel.onClick.call(d.cancel,De),Ir())},className:ea(ne?.cancelButton,d==null||(o=d.classNames)==null?void 0:o.cancelButton)},d.cancel.label):null,pt.isValidElement(d.action)?d.action:d.action&&Y1(d.action)?pt.createElement("button",{"data-button":!0,"data-action":!0,style:d.actionButtonStyle||O,onClick:De=>{Y1(d.action)&&(d.action.onClick==null||d.action.onClick.call(d.action,De),!De.defaultPrevented&&Ir())},className:ea(ne?.actionButton,d==null||(c=d.classNames)==null?void 0:c.actionButton)},d.action.label):null)};function hS(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function YL(e,t){const r={};return[e,t].forEach((n,s)=>{const i=s===1,a=i?"--mobile-offset":"--offset",u=i?JL:qL;function o(c){["top","right","bottom","left"].forEach(p=>{r[`${a}-${p}`]=typeof c=="number"?`${c}px`:c})}typeof n=="number"||typeof n=="string"?o(n):typeof n=="object"?["top","right","bottom","left"].forEach(c=>{n[c]===void 0?r[`${a}-${c}`]=u:r[`${a}-${c}`]=typeof n[c]=="number"?`${n[c]}px`:n[c]}):o(u)}),r}const QL=pt.forwardRef(function(t,r){const{id:n,invert:s,position:i="bottom-right",hotkey:a=["altKey","KeyT"],expand:u,closeButton:o,className:c,offset:p,mobileOffset:d,theme:h="light",richColors:m,duration:y,style:v,visibleToasts:b=zL,toastOptions:T,dir:D=hS(),gap:x=VL,icons:E,containerAriaLabel:A="Notifications"}=t,[F,k]=pt.useState([]),_=pt.useMemo(()=>n?F.filter(M=>M.toasterId===n):F.filter(M=>!M.toasterId),[F,n]),O=pt.useMemo(()=>Array.from(new Set([i].concat(_.filter(M=>M.position).map(M=>M.position)))),[_,i]),[q,j]=pt.useState([]),[V,z]=pt.useState(!1),[oe,L]=pt.useState(!1),[ne,Ee]=pt.useState(h!=="system"?h:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),X=pt.useRef(null),je=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),K=pt.useRef(null),Q=pt.useRef(!1),ie=pt.useCallback(M=>{k(B=>{var U;return(U=B.find(J=>J.id===M.id))!=null&&U.delete||_s.dismiss(M.id),B.filter(({id:J})=>J!==M.id)})},[]);return pt.useEffect(()=>_s.subscribe(M=>{if(M.dismiss){requestAnimationFrame(()=>{k(B=>B.map(U=>U.id===M.id?{...U,delete:!0}:U))});return}setTimeout(()=>{SO.flushSync(()=>{k(B=>{const U=B.findIndex(J=>J.id===M.id);return U!==-1?[...B.slice(0,U),{...B[U],...M},...B.slice(U+1)]:[M,...B]})})})}),[F]),pt.useEffect(()=>{if(h!=="system"){Ee(h);return}if(h==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Ee("dark"):Ee("light")),typeof window>"u")return;const M=window.matchMedia("(prefers-color-scheme: dark)");try{M.addEventListener("change",({matches:B})=>{Ee(B?"dark":"light")})}catch{M.addListener(({matches:U})=>{try{Ee(U?"dark":"light")}catch(J){console.error(J)}})}},[h]),pt.useEffect(()=>{F.length<=1&&z(!1)},[F]),pt.useEffect(()=>{const M=B=>{var U;if(a.every(Ce=>B[Ce]||B.code===Ce)){var de;z(!0),(de=X.current)==null||de.focus()}B.code==="Escape"&&(document.activeElement===X.current||(U=X.current)!=null&&U.contains(document.activeElement))&&z(!1)};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[a]),pt.useEffect(()=>{if(X.current)return()=>{K.current&&(K.current.focus({preventScroll:!0}),K.current=null,Q.current=!1)}},[X.current]),pt.createElement("section",{ref:r,"aria-label":`${A} ${je}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},O.map((M,B)=>{var U;const[J,de]=M.split("-");return _.length?pt.createElement("ol",{key:M,dir:D==="auto"?hS():D,tabIndex:-1,ref:X,className:c,"data-sonner-toaster":!0,"data-sonner-theme":ne,"data-y-position":J,"data-x-position":de,style:{"--front-toast-height":`${((U=q[0])==null?void 0:U.height)||0}px`,"--width":`${KL}px`,"--gap":`${x}px`,...v,...YL(p,d)},onBlur:Ce=>{Q.current&&!Ce.currentTarget.contains(Ce.relatedTarget)&&(Q.current=!1,K.current&&(K.current.focus({preventScroll:!0}),K.current=null))},onFocus:Ce=>{Ce.target instanceof HTMLElement&&Ce.target.dataset.dismissible==="false"||Q.current||(Q.current=!0,K.current=Ce.relatedTarget)},onMouseEnter:()=>z(!0),onMouseMove:()=>z(!0),onMouseLeave:()=>{oe||z(!1)},onDragEnd:()=>z(!1),onPointerDown:Ce=>{Ce.target instanceof HTMLElement&&Ce.target.dataset.dismissible==="false"||L(!0)},onPointerUp:()=>L(!1)},_.filter(Ce=>!Ce.position&&B===0||Ce.position===M).map((Ce,Me)=>{var Ue,re;return pt.createElement(XL,{key:Ce.id,icons:E,index:Me,toast:Ce,defaultRichColors:m,duration:(Ue=T?.duration)!=null?Ue:y,className:T?.className,descriptionClassName:T?.descriptionClassName,invert:s,visibleToasts:b,closeButton:(re=T?.closeButton)!=null?re:o,interacting:oe,position:M,style:T?.style,unstyled:T?.unstyled,classNames:T?.classNames,cancelButtonStyle:T?.cancelButtonStyle,actionButtonStyle:T?.actionButtonStyle,closeButtonAriaLabel:T?.closeButtonAriaLabel,removeToast:ie,toasts:_.filter(le=>le.position==Ce.position),heights:q.filter(le=>le.position==Ce.position),setHeights:j,expandByDefault:u,gap:x,expanded:V,swipeDirections:t.swipeDirections})})):null}))}),ZL=({...e})=>S.jsx(QL,{theme:"system",className:"toaster group",icons:{success:S.jsx(Jj,{className:"size-4"}),info:S.jsx(qj,{className:"size-4"}),warning:S.jsx(s8,{className:"size-4"}),error:S.jsx(zj,{className:"size-4"}),loading:S.jsx(m3,{className:"size-4 animate-spin"})},toastOptions:{classNames:{icon:"self-start mt-0.5"}},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...e});function Bl(e){let t=e;const r=new Set;return{getState:()=>t,setState:n=>{const s=typeof n=="function"?n(t):n;Object.is(s,t)||(t=s,r.forEach(i=>i()))},subscribe:n=>(r.add(n),()=>r.delete(n))}}const eM=/^\$(model|component|html|dataSource|fn|locale)\((.+)\)$/;function Mt(e){if(typeof e!="string")return null;const t=eM.exec(e);return t?{op:t[1],arg:t[2]}:null}const Li=e=>Mt(e)?.op==="model",Jh=e=>Mt(e)?.op==="component",zp=e=>Mt(e)?.op==="html",S3=e=>Mt(e)?.op==="dataSource",F3=e=>Mt(e)?.op==="fn",w3=e=>Mt(e)?.op==="locale",k3=new Set(["div","section","article","aside","header","footer","nav","main","figure","figcaption","details","summary","fieldset","legend","p","span","h1","h2","h3","h4","h5","h6","strong","b","em","i","u","s","small","mark","sub","sup","code","pre","kbd","samp","var","blockquote","cite","q","abbr","time","address","label","br","hr","a","ul","ol","li","dl","dt","dd","table","caption","colgroup","col","thead","tbody","tfoot","tr","th","td","img","picture","source","video","audio","track","progress","meter"]);function _3(e){return k3.has(e.toLowerCase())}const tM=new Set(["href","src","srcSet","srcset","poster","action","formAction","formaction","data","xlinkHref","cite","ping"]);function rM(e){const t=Array.from(e).filter(r=>r.charCodeAt(0)>32).join("").toLowerCase();return t.startsWith("javascript:")||t.startsWith("vbscript:")?!0:t.startsWith("data:")?!t.startsWith("data:image/"):!1}function U8(e,t){if(!e)return e;let r=null;const n={};for(const s of Object.keys(e)){const i=e[s],a=s.length>2&&s.startsWith("on")&&s[2]===s[2].toUpperCase(),u=tM.has(s)&&typeof i=="string"&&rM(i);if(s==="dangerouslySetInnerHTML"||a||u){(r??=[]).push(s);continue}n[s]=i}return r?(typeof console<"u"&&console.warn(`[JsonRenderer] $html(${t}): отброшены небезопасные props — ${r.join(", ")}. HTML-узлы предназначены для презентационной разметки: исполняемые обработчики, сырой innerHTML и javascript:/data:-URL в них не пропускаются.`),n):e}const nM="http://json-schema.org/draft-07/schema#",sM="https://reformer.dev/schemas/form-schema.schema.json",iM="ReFormer JSON form schema (M1, string-operator DSL)",aM="Base meta-schema: validates node structure + operator string syntax ($model/$component/$dataSource). Component-name enum is tightened per-app via buildFormSchemaMetaSchema; $dataSource names and $model paths are checked outside this schema.",oM="object",uM=["root"],lM=!1,cM={$schema:{type:"string"},id:{type:"string"},version:{type:"string"},meta:{type:"object",additionalProperties:!1,properties:{name:{type:"string"},description:{type:"string"}}},root:{$ref:"#/definitions/node"}},pM={modelOp:{type:"string",pattern:"^\\$model\\(.+\\)$",description:'Model binding: "$model(path)" — path resolved at runtime (not validated here).'},componentOp:{type:"string",pattern:"^\\$component\\(.+\\)$",description:'Registry component: "$component(Name)". Name is tightened to a registry enum by buildFormSchemaMetaSchema.'},htmlOp:{type:"string",pattern:"^\\$html\\([a-zA-Z][a-zA-Z0-9]*\\)$",description:'Native HTML tag: "$html(div)". The tag is checked against the presentational whitelist (isAllowedHtmlTag) by validateFormSchema and by the converter; buildFormSchemaMetaSchema tightens it to an enum for IDE completion.'},textChild:{description:`Text part of a node's children: a literal, or an operator string ("$model(path)" for reactive model values, "$locale(key)" for localized strings). Adjacent parts are joined without a separator.`,$comment:`Types are listed as separate anyOf branches rather than a union "type": ["string","number"] — ajv's strict mode rejects union type keywords unless allowUnionTypes is on, and validateFormSchema compiles this schema without it.`,anyOf:[{type:"string"},{type:"number"}]},operatorOp:{type:"string",pattern:"^\\$(model|component|html|dataSource|fn|locale)\\(.+\\)$",description:'Any DSL operator string ("$model/$component/$dataSource/$fn/$locale(...)") used as an escape hatch on a componentProps value (e.g. "options": "$dataSource(LOAN_TYPES)"). The component-props validator wraps every prop in anyOf:[honest type, operatorOp] via allowOperatorStrings, so an operator string is accepted wherever a literal value is.'},node:{$comment:"Discriminated by which operator key is present (array→value→component), mirroring the isArrayNode/isFieldNode/isContainerNode runtime guards. Using oneOf here made ajv (allErrors) report failures against all three branches for any single mistake, burying the real cause; if/then/else surfaces only the relevant branch's errors.",if:{type:"object",required:["array"]},then:{$ref:"#/definitions/arrayNode"},else:{if:{type:"object",required:["value"]},then:{$ref:"#/definitions/fieldNode"},else:{$ref:"#/definitions/containerNode"}}},fieldNode:{type:"object",required:["value"],additionalProperties:!1,properties:{selector:{type:"string"},value:{$ref:"#/definitions/modelOp"},component:{$ref:"#/definitions/componentOp"},componentProps:{type:"object"},wrapper:{$ref:"#/definitions/node"}}},arrayNode:{type:"object",required:["array","item"],additionalProperties:!1,properties:{selector:{type:"string"},array:{$ref:"#/definitions/modelOp"},component:{$ref:"#/definitions/componentOp"},item:{type:"object",required:["$template"],additionalProperties:!1,properties:{$template:{$ref:"#/definitions/node"}}},initialValue:{type:"object"},componentProps:{type:"object"}}},containerNode:{type:"object",required:["component"],additionalProperties:!1,properties:{selector:{type:"string"},component:{anyOf:[{$ref:"#/definitions/componentOp"},{$ref:"#/definitions/htmlOp"}]},componentProps:{type:"object"},children:{$comment:'A child is either a nested node (object) or a text part (string/number). Dispatched with if/then/else rather than anyOf for the same reason as "node": with allErrors ajv would report failures from every branch, burying the real cause.',type:"array",items:{if:{type:"object"},then:{$ref:"#/definitions/node"},else:{$ref:"#/definitions/textChild"}}}}}},P3={$schema:nM,$id:sM,title:iM,description:aM,type:oM,required:uM,additionalProperties:lM,properties:cM,definitions:pM},z8=P3;function q8(e){return e.names().filter(t=>e.get(t)?.type==="component")}function J8(e){return e.names().filter(t=>e.get(t)?.type==="dataSource")}function K8(e){return e.names().filter(t=>e.get(t)?.type==="fn")}function V8(e){return e.getLocale?.()?.keys}function dM(){return P3.definitions.operatorOp}function W8(e){return kv(e)}function kv(e){if(Array.isArray(e))return e.map(kv);if(e!==null&&typeof e=="object"){const t={};for(const[r,n]of Object.entries(e))r.startsWith("x-")||(t[r]=kv(n));return t}return e}function H8(e){return pg(e)}function pg(e){if(Array.isArray(e))return e.map(pg);if(e===null||typeof e!="object")return e;const t=e,r={...t};if(t.properties!==null&&typeof t.properties=="object"&&!Array.isArray(t.properties)){const n={};for(const[s,i]of Object.entries(t.properties))n[s]={anyOf:[pg(i),{$ref:"#/definitions/operatorOp"}]};r.properties=n}return t.items!==void 0&&(r.items=pg(t.items)),r}function N3(e){const t=W8(e),r=H8(t),n=r.definitions??{};return{...r,definitions:{...n,operatorOp:dM()}}}function fM(e){const t=JSON.parse(JSON.stringify(P3)),r=e?.componentNames;if(r&&r.length>0){const i=t.definitions.componentOp;delete i.pattern,i.enum=r.map(a=>`$component(${a})`)}const n=t.definitions.htmlOp;delete n.pattern,n.enum=[...k3].map(i=>`$html(${i})`);const s=e?.propSchemas;if(s&&Object.keys(s).length>0){const i=Object.entries(s).map(([a,u])=>({if:{required:["component"],properties:{component:{const:`$component(${a})`}}},then:{properties:{componentProps:N3(u)}}}));for(const a of["fieldNode","containerNode"]){const u=t.definitions[a];u.allOf=[...u.allOf??[],...i]}}return t}const k2="$fieldWrapper",$3="$localeService";let Og=class _v{own=new Map;parent=null;get(t){return this.own.get(t)??this.parent?.get(t)}getDataSource(t){const r=this.get(t);if(!(!r||r.type!=="dataSource"))return r.component}getLocale(){const t=this.get($3);if(!(!t||t.type!=="locale"))return t.component}has(t){return this.own.has(t)||(this.parent?.has(t)??!1)}names(){const t=this.parent?.names()??[],r=Array.from(this.own.keys());return[...new Set([...t,...r])]}_set(t,r){this.own.has(t)&&console.warn(`[ComponentRegistry] Overwriting entry: ${t}`),this.own.set(t,r)}static withParent(t,r){const n=new _v,s=i=>{for(const a of i.names()){const u=i.get(a);u&&n.own.set(a,u)}};return t instanceof _v?n.parent=t:s(t),s(r),n}};function hM(...e){return e.length===0?new Og:e.reduce((t,r)=>Og.withParent(t,r))}function G8(e){const t=new Og;return e({component(r,n,s){t._set(r,{component:n,type:"component",description:s})},dataSource(r,n,s){t._set(r,{component:n,type:"dataSource",description:s})},fn(r,n,s){if(typeof n!="function")throw new Error(`reg.fn("${r}") expects a function, got ${typeof n}. Use reg.dataSource(...) for non-function values.`);t._set(r,{component:n,type:"fn",description:s})},locale(r,n){const s=typeof r=="function"?{resolve:r}:r;t._set($3,{component:s,type:"locale",description:n})}}),t}const Pv=se.createContext({});function X8({settings:e,children:t}){const r=se.useContext(Pv),n=se.useMemo(()=>r.registry&&e.registry?Og.withParent(r.registry,e.registry):e.registry??r.registry,[r.registry,e.registry]),s=se.useMemo(()=>{const i=n?.get(k2)?.component;return{...r,...e,registry:n,fieldWrapper:e.fieldWrapper??i??r.fieldWrapper}},[r,e,n]);return S.jsx(Pv.Provider,{value:s,children:t})}function mM(){return I3()}function I3(){return se.useContext(Pv)}function yM(e){return e}function Jn(e){const t=e;return Li(t.array)&&typeof t.item=="object"&&t.item!==null&&"$template"in t.item}function ni(e){return Li(e.value)}function ns(e){const t=e.component;return(Jh(t)||zp(t))&&!ni(e)&&!Jn(e)}function gM(e){const t=Mt(e)?.arg;if(!t)throw new Error(`Invalid $html operator: "${e}"`);if(!_3(t))throw new Error(`HTML tag "${t}" is not allowed in $html(...). Presentational tags only — script/style/iframe/form-controls are excluded by design.`);return t.toLowerCase()}function jf(e,t){if(!e)return;if(zp(e))return gM(e);const r=Mt(e)?.arg;if(!r)throw new Error(`Invalid $component operator: "${e}"`);const n=t.get(r);if(!n)throw new Error(`Component "${r}" not found in registry. Available: ${t.names().join(", ")}`);if(n.type!=="component")throw new Error(`Entry "${r}" is a '${n.type}' and cannot be used as $component(...)`);return n.component}function Y8(e,t){const r=t.get(e);if(!r)throw new Error(`Data source "${e}" not found in registry. Available: ${t.names().join(", ")}`);if(r.type!=="dataSource")throw new Error(`Entry "${e}" is a '${r.type}' and cannot be used as $dataSource(...)`);return r.component}function DM(e,t){const r=t.get(e);if(!r)throw new Error(`Function "${e}" not found in registry. Available: ${t.names().join(", ")}`);if(r.type!=="fn")throw new Error(`Entry "${e}" is a '${r.type}' and cannot be used as $fn(...)`);return r.component}function Nv(e,t,r){return t.getLocale?.()?.resolve(e,r)??e}function xM(e){return e!==null&&typeof e=="object"&&typeof e.$locale=="string"}function bM(e,t){if(!e)return e;let r=!1;const n={};for(const s of Object.keys(e)){const i=e[s];if(Li(i)){const a=t.signalAt(Mt(i).arg);n[s]=a?.peek?.(),r=!0}else n[s]=i}return r?n:e}function vM(e,t){if(!(!t||typeof console>"u"))for(const r of Object.keys(t))Li(t[r])&&console.warn(`[JsonRenderer] $locale("${e}"): параметр "${r}" (=${String(t[r])}) взят снимком значения на момент рендера и не обновляется при изменении модели. Для реактивного значения используй I18n: { component: "$component(I18n)", componentProps: { id: "${e}", values: { ${r}: "${String(t[r])}" } } }.`)}function EM(e,t){return t.split(".").reduce((r,n)=>r==null?r:r[n],e)}function CM(e){if(e===null||typeof e!="object")return!1;const t=e;return Li(t.value)||Li(t.array)||Jh(t.component)||zp(t.component)}function TM(e){return e==null?e:JSON.parse(JSON.stringify(e))}function $v(e,t,r){if(S3(e))return Y8(Mt(e).arg,r);if(Jh(e))return jf(e,r);if(F3(e))return DM(Mt(e).arg,r);if(w3(e))return Nv(Mt(e).arg,r);if(Li(e))return t.signalAt(Mt(e).arg);if(xM(e))return vM(e.$locale,e.params),Nv(e.$locale,r,bM(e.params,t));if(CM(e))return Ch(e,t,r);if(Array.isArray(e))return e.map(n=>$v(n,t,r));if(e!==null&&typeof e=="object"){const n=e,s={};for(const i of Object.keys(n))s[i]=$v(n[i],t,r);return s}return e}function ob(e,t,r){if(!e)return;const n={};for(const s of Object.keys(e))n[s]=$v(e[s],t,r);return n}function AM(e,t,r){if(typeof e=="number")return e;if(Li(e))return t.signalAt(Mt(e).arg);if(w3(e))return Nv(Mt(e).arg,r);if(S3(e)){const n=Y8(Mt(e).arg,r);if(!(n==null||typeof n=="string"||typeof n=="number"||n instanceof h3))throw new Error(mS(e,"resolves to a non-text value"));return n}if(Jh(e)||zp(e)||F3(e))throw new Error(mS(e,"resolves to a component or a function"));return e}function mS(e,t){return`Operator "${e}" cannot be a text child — it ${t}. Text children accept $model(...), $locale(...) and $dataSource(...) that yields a string, a number or a signal; use a nested node for components and componentProps for functions.`}function Ch(e,t,r){if(Jn(e)){const n=EM(t,Mt(e.array).arg),s=e.item.$template,i=e.initialValue,a=e.component?jf(e.component,r):void 0;return{...e.selector?{selector:e.selector}:{},array:n,...a?{component:a}:{},initialValue:()=>i?TM(i):{},item:u=>Ch(s,u,r),componentProps:ob(e.componentProps,t,r)}}if(ni(e)){const n=Mt(e.value).arg,s=t.signalAt(n);!s&&typeof console<"u"&&console.warn(`[JsonRenderer/M1] No model signal for "${n}".`);const i=ob(e.componentProps,t,r),a=e.wrapper?jf(e.wrapper.component,r):void 0;return{...e.selector?{selector:e.selector}:{},value:s,component:jf(e.component,r),componentProps:a?{...i??{},fieldWrapper:a}:i}}if(ns(e)){const n=zp(e.component),s=jf(e.component,r),i=ob(e.componentProps,t,r);return{...e.selector?{selector:e.selector}:{},component:s,componentProps:n?U8(i,s):i,children:e.children?.map(a=>typeof a=="object"&&a!==null?Ch(a,t,r):AM(a,t,r))}}throw new Error(`Invalid JSON node (M1): ${JSON.stringify(e)}`)}function B3(e,t,r){return Ch(e.root,r,t)}function Q8(e,t,r){return()=>Ch(e.root,r,t)}function dg(e){return e!==null&&typeof e=="object"}function SM(e){return"component"in e||"value"in e||"array"in e||"selector"in e||"children"in e}function Wc(e,t){if(dg(e)){if(Array.isArray(e)){for(const r of e)Wc(r,t);return}if(typeof e.selector=="string"&&t.add(e.selector),Wc(e.children,t),dg(e.item)&&Wc(e.item.$template,t),Wc(e.wrapper,t),dg(e.componentProps))for(const r of Object.values(e.componentProps))Z8(r,t)}}function Z8(e,t){if(dg(e)){if(Array.isArray(e)){for(const r of e)Z8(r,t);return}SM(e)&&Wc(e,t)}}function e_(e){const t=new Set;return Wc(e.root,t),t}function j3({errors:e}){return S.jsxs("div",{role:"alert","data-testid":"schema-error-panel",style:{border:"1px solid #f5a9a9",background:"#fff5f5",color:"#9b1c1c",borderRadius:8,padding:"16px 20px",font:"14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace"},children:[S.jsxs("strong",{style:{display:"block",marginBottom:8,fontSize:15},children:["Невалидная JSON-схема формы (",e.length,")"]}),S.jsx("ul",{style:{margin:0,paddingLeft:20},children:e.map((t,r)=>S.jsx("li",{style:{marginBottom:4},children:t},r))})]})}let t_=class extends se.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,r){typeof console<"u"&&console.error("[JsonFormRenderer] schema conversion/render failed:",t,r.componentStack)}componentDidUpdate(t){this.state.error&&t.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){const{error:t}=this.state;return t?this.props.fallback?.(t)??S.jsx(j3,{errors:[`Schema conversion/render failed: ${t.message}`]}):this.props.children}};function r_({form:e,schema:t,model:r,registry:n,renderBehavior:s,onSchemaReady:i,validateSchema:a=!1}){const{registry:u,...o}=I3(),c=e?.schema??t,p=e?.model??r,d=n??e?.registry??u,h=s??e?.renderBehavior,m=d&&d!==u?d.get(k2)?.component:void 0,y=m?{...o,fieldWrapper:m}:o,[v,b]=se.useState(a?void 0:null);se.useEffect(()=>{if(!a||!c){b(null);return}let x=!1;return b(void 0),Pl(async()=>{const{validateFormSchema:E}=await Promise.resolve().then(()=>BJ);return{validateFormSchema:E}},void 0).then(({validateFormSchema:E})=>{if(x)return;const{valid:A,errors:F}=E(c,{registry:d});b(A?null:F)}).catch(E=>{x||b([`Schema validator failed to load: ${String(E)}`])}),()=>{x=!0}},[a,c,d]);const T=se.useRef(h);se.useEffect(()=>{T.current=h},[h]);const D=se.useMemo(()=>{if(!c||!p)throw new Error("JsonFormRenderer: provide a `form` bundle (createJsonForm) or both `schema` and `model` props.");if(v!==null)return null;if(!d)throw new Error("JsonFormRenderer: settings.registry is required. Pass a ComponentRegistry via JsonRendererProvider.");const x=Q8(c,d,p),E=NO(x);return h&&h(E),E},[c,d,h,p,v]);return se.useMemo(()=>{D&&i&&i(D)},[D]),se.useEffect(()=>{if(!D||!c)return;const x=e_(c),E=D.__overrideMaps,A=[...new Set([...E.hiddenOverrides.keys(),...E.propsOverrides.keys(),...E.refRegistry.keys(),...E.conditionRegistry.keys(),...E.callbackRegistry.keys(),...E.lifecycleRegistry.keys()])].filter(F=>!x.has(F));A.length>0&&typeof console<"u"&&console.warn(`[JsonFormRenderer] schema.node(...) адресует неизвестный selector: ${A.join(", ")}. Известные селекторы: ${[...x].sort().join(", ")||"(нет)"}.`)},[D,c]),v&&v.length>0?S.jsx(j3,{errors:v}):D?S.jsx(t_,{resetKey:D,children:S.jsx($O,{render:D,settings:y})}):null}function FM(e){const{schema:t,registry:r,behavior:n}=e;if(!e.model&&e.initial===void 0)throw new Error("createJsonForm: provide either `initial` (to create a model) or `model`.");const s=e.model??m8(e.initial);e.seed?.(s);const i=y8({model:s,schema:B3(t,r,s),behavior:n}),a=wO(s,e.validation),u=e.renderBehavior?.(i,s,a),o={model:s,form:i,schema:t,registry:r,...a?{validation:a}:{},...u?{renderBehavior:u}:{}};return e.setup?.(o),o}const wM=FO;function kM(e){const t=new Set,r=new Set,n=new Set,s=new Set,i=a=>{if(typeof a=="string"){const u=Mt(a);if(!u)return;u.op==="component"?t.add(u.arg):u.op==="dataSource"?r.add(u.arg):u.op==="fn"?n.add(u.arg):u.op==="locale"&&s.add(u.arg);return}if(Array.isArray(a)){a.forEach(i);return}if(a&&typeof a=="object")for(const u of Object.values(a))i(u)};return i(e.root),{components:[...t],dataSources:[...r],fns:[...n],locales:[...s]}}const _M=e=>e;function PM(e){return{resolve:t=>e[t]??t,keys:Object.keys(e)}}function NM(e){return{resolve:(t,r)=>e[t]?.(r)??t,keys:Object.keys(e)}}const $M={resolve:e=>e},n_=se.createContext($M);function IM({service:e,children:t}){return S.jsx(n_.Provider,{value:e,children:t})}function s_(){return se.useContext(n_)}function i_(e){if(!e)return e;let t=!1;const r={};for(const n of Object.keys(e)){const s=e[n];s instanceof h3?(r[n]=s.value,t=!0):r[n]=s}return t?r:e}function BM(e){const t=[];if(e)for(const r of Object.keys(e)){const n=e[r];n instanceof h3&&t.push(n)}return t}function jM(e,t){if(e===t)return!0;if(!e||!t)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const s of r)if(e[s]!==t[s])return!1;return!0}function a_(e){const t=se.useRef(void 0),r=se.useCallback(s=>{const i=BM(e);if(i.length===0)return()=>{};let a=!0;return gp(()=>{for(const u of i)u.value;if(a){a=!1;return}s()})},[e]),n=se.useCallback(()=>{const s=i_(e);return jM(t.current,s)?t.current:(t.current=s,s)},[e]);return se.useSyncExternalStore(r,n,n)}function OM({id:e,values:t}){const r=s_(),n=a_(t);return r.render?r.render(e,n):r.resolve(e,n)}const Ube=Object.freeze(Object.defineProperty({__proto__:null,ALLOWED_HTML_TAGS:k3,FIELD_WRAPPER:k2,I18n:OM,JsonFormRenderer:r_,JsonRendererProvider:X8,LOCALE_SERVICE:$3,LocaleProvider:IM,SchemaErrorBoundary:t_,SchemaErrorPanel:j3,allowOperatorStrings:H8,buildFormSchemaMetaSchema:fM,collectOperatorNames:kM,collectSchemaSelectors:e_,composeRegistries:hM,convertJsonToM1Tree:B3,createJsonForm:FM,createLocaleResolver:PM,createLocaleService:NM,createRenderSchemaFromJsonM1:Q8,defaultLocaleResolver:_M,defineJsonSchema:yM,defineRegistry:G8,formSchemaMetaSchema:z8,getComponentNames:q8,getDataSourceNames:J8,getFnNames:K8,getLocaleKeys:V8,isAllowedHtmlTag:_3,isArrayNode:Jn,isComponentOp:Jh,isContainerNode:ns,isDataSourceOp:S3,isFieldNode:ni,isFnOp:F3,isHtmlOp:zp,isLocaleOp:w3,isModelOp:Li,parseOperator:Mt,sanitizeHtmlProps:U8,stripDocExtensions:W8,toComponentPropsValidatorSchema:N3,unwrapSignalValues:i_,useJsonForm:wM,useJsonRendererSettings:mM,useJsonRendererSettingsUnchecked:I3,useLocale:s_,useSignalValues:a_},Symbol.toStringTag,{value:"Module"}));function Pr(e,t){let r=e;for(const n of t){if(r==null||typeof r!="object")return;r=r[n]}return r}function In(e,t,r){if(t.length===0)return r(e);const[n,...s]=t,i=e?.[n],a=In(i,s,r);if(Array.isArray(e)){const o=e.slice();return o[n]=a,o}const u={...e};return u[n]=a,u}function O3(e,t){if(t.length===0)throw new Error("removeAt: нельзя удалить корень (пустой путь)");const r=t.slice(0,-1),n=t[t.length-1];return In(e,r,s=>{if(Array.isArray(s)){const a=typeof n=="number"?n:Number(n);return s.filter((u,o)=>o!==a)}const i={...s};return delete i[n],i})}function Bc(e){return e.map(t=>"/"+String(t).replace(/~/g,"~0").replace(/\//g,"~1")).join("")}function zbe(e){return e===""?[]:e.split("/").slice(1).map(t=>t.replace(/~1/g,"/").replace(/~0/g,"~"))}function Xs(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(String(e[r])!==String(t[r]))return!1;return!0}function ml(e,t){if(e.length>t.length)return!1;for(let r=0;r<e.length;r++)if(String(e[r])!==String(t[r]))return!1;return!0}function Sl(e){let t=0,r=0;for(let n=0;n<e.length;n++){const s=e[n];s==="["||s==="("?t++:s==="]"||s===")"?t=Math.max(0,t-1):s===":"&&t===0&&(r=n+1)}return e.slice(r)}function LM(e){const t=[];let r=0,n=0;for(let s=0;s<e.length;s++){const i=e[s];i==="["||i==="("?r++:i==="]"||i===")"?r=Math.max(0,r-1):i===":"&&r===0&&(t.push(e.slice(n,s)),n=s+1)}return t}function qbe(e){return Sl(e)!==e}function MM(e){const t=/^grid-cols-(\d+)$/.exec(Sl(e));return t?Number(t[1]):void 0}function o_(e){const t=Sl(e);return t==="flex"||t==="grid"||t==="inline-flex"||t==="inline-grid"||t==="flex-row"||t==="flex-row-reverse"||t==="flex-col"||t==="flex-col-reverse"||/^grid-(cols|rows)-/.test(t)}function Jbe(e){const t=Sl(e);return/^gap(-[xy])?-/.test(t)||/^space-[xy]-/.test(t)}function u_(e){return Jn(e)?"array":ni(e)?"field":"container"}function an(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;const t=e;return"value"in t||"array"in t||"component"in t}const RM=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),UM=new Set(["Wizard","FormWizard","RendererFormWizard"]);function zM(e){const t=Mt(e.component);return t?.op==="component"&&UM.has(t.arg)}function qM(e){const t=Mt(e);return t?t.op==="component"?Up().leafComponents.has(t.arg):t.op==="html"?RM.has(t.arg):!1:!1}function xp(e){return qM(e.component)}function Mi(e,t){const r=[];if(xp(e))return r;if(Jn(e)){const n=e;return r.push({kind:"template",path:[...t,"item","$template"],single:!0,entries:[{node:n.item.$template,index:0}],length:1}),r}if(ni(e))return e.wrapper&&r.push({kind:"wrapper",path:[...t,"wrapper"],single:!0,entries:[{node:e.wrapper,index:0}],length:1}),r;if(ns(e)){const n=e,s=n.componentProps?.steps;if(Array.isArray(s)&&s.some(an)||zM(e)){const a=Array.isArray(s)?s:[];r.push({kind:"steps",path:[...t,"componentProps","steps"],single:!1,entries:yS(a),length:a.length})}Array.isArray(n.children)&&r.push({kind:"children",path:[...t,"children"],single:!1,entries:yS(n.children),length:n.children.length})}return r}function yS(e){const t=[];return e.forEach((r,n)=>{an(r)&&t.push({node:r,index:n})}),t}function L3(e){return xp(e)?!1:!!(Jn(e)||ns(e))}const JM={sm:1,md:2,lg:3,xl:4,"2xl":5};function KM(e){let t=0;for(const r of LM(e))t=Math.max(t,JM[r]??0);return t}function Th(e){if(!ns(e))return"vertical";const t=e.componentProps?.className;if(typeof t!="string")return"vertical";const r=t.split(/\s+/).filter(Boolean).filter(o_).map((a,u)=>({base:Sl(a),rank:KM(a),i:u})).sort((a,u)=>a.rank-u.rank||a.i-u.i);let n,s=!1,i=0;for(const{base:a}of r)if(a==="flex"||a==="inline-flex")n="flex";else if(a==="grid"||a==="inline-grid")n="grid";else if(a==="flex-col"||a==="flex-col-reverse")s=!0;else if(a==="flex-row"||a==="flex-row-reverse")s=!1;else{const u=MM(a);u!==void 0&&(i=u)}return n==="grid"?i>=2?"horizontal":"vertical":n==="flex"?s?"vertical":"horizontal":"vertical"}function Lg(e){return ns(e)&&e.component==="$html(div)"}function VM(e){if(!ns(e))return!1;const t=e;if(t.component!=="$html(div)")return!1;const r=t.componentProps?.className;return typeof r=="string"&&r.split(/\s+/).includes("flex")}function Kh(e,t){const r=Pr(e,t);return an(r)?r:void 0}function Pn(e){const t=e.length;if(t===0)return null;const r=e[t-1],n=e[t-2],s=e[t-3];return n==="children"&&gS(r)?e.slice(0,t-2):s==="componentProps"&&n==="steps"&&gS(r)?e.slice(0,t-3):n==="item"&&r==="$template"?e.slice(0,t-2):r==="wrapper"?e.slice(0,t-1):null}function gS(e){return typeof e=="number"||/^\d+$/.test(String(e))}function Mg(e,t){const r=e.root;if(!an(r))return;const n=(s,i)=>{t(s,i);for(const a of Mi(s,i))for(const u of a.entries)n(u.node,a.single?a.path:[...a.path,u.index])};n(r,["root"])}function bp(e){const t=new Set,r=new Set,n=new Set,s=new Set,i=a=>{if(typeof a=="string"){const u=Mt(a);u&&(u.op==="component"?t.add(u.arg):u.op==="dataSource"?r.add(u.arg):u.op==="fn"?n.add(u.arg):u.op==="locale"&&s.add(u.arg));return}if(Array.isArray(a)){a.forEach(i);return}if(a&&typeof a=="object")for(const u of Object.values(a))i(u)};return i(e.root),{components:[...t],dataSources:[...r],fns:[...n],locales:[...s]}}function Ls(e,t){const r=Pn(t);if(!r)return null;const n=Pr(e,r);if(!an(n))return null;for(const s of Mi(n,r))if(!s.single&&ml(s.path,t)&&t.length===s.path.length+1)return{slotPath:s.path,index:Number(t[t.length-1]),siblings:s.entries.map(i=>i.index),count:s.length};return null}function WM(e,t){const r=Pr(e,t);if(!an(r))return null;for(const n of Mi(r,t))if(n.entries.length!==0)return n.single?n.path:[...n.path,n.entries[0].index];return null}function HM(e,t){if(t[t.length-2]!=="children")return"vertical";const r=Pn(t);if(!r)return"vertical";const n=Pr(e,r);return an(n)?Th(n):"vertical"}function GM(e,t){const r=t==="horizontal";switch(e){case"up":return r?"out":"prev";case"down":return r?"in":"next";case"left":return r?"prev":"out";default:return r?"next":"in"}}function _2(e,t,r){return GM(r,HM(e,t))}function M3(e,t,r){const n=Ls(e,t);if(!n)return null;const s=n.siblings.indexOf(n.index);if(s<0)return null;const i=r==="prev"?s-1:s+1;return i<0||i>=n.siblings.length?null:[...n.slotPath,n.siblings[i]]}function XM(e,t){let r=Pn(t);for(;r;){const n=M3(e,r,"next");if(n)return n;r=Pn(r)}return null}function YM(e,t,r){const n=_2(e,t,r);if(n==="out")return Pn(t);if(n==="in")return WM(e,t);const s=M3(e,t,n);return s||(n==="prev"?Pn(t):XM(e,t))}function R3(e){return{version:"1.0",root:{component:"$component(Box)",componentProps:{className:"space-y-4"},children:[]}}}function P2(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;const t=e.root;return an(t)}function l_(e){if(!P2(e))throw new Error("ensureSchema: JSON не похож на JsonFormSchema (нет узла в `root`)");return QM(e)}function QM(e){let t=!1;const r=s=>{if(Array.isArray(s)){const u=s.map(r);return t?u:s}if(s==null||typeof s!="object")return s;const i=s,a={};for(const u of Object.keys(i)){if(u==="text"&&an(i)){const o=Array.isArray(i.text)?i.text:[i.text],c=Array.isArray(i.children)?i.children.map(r):[];a.children=[...o,...c],t=!0;continue}u==="children"&&a.children!==void 0||(a[u]=r(i[u]))}return t?a:s},n=r(e);return t?n:e}const zn=e=>structuredClone(e),c_="flex gap-4",U3="flex flex-col gap-4";function p_(e){if(!e||!ns(e))return!1;const t=e;if(t.component!=="$html(div)")return!1;const r=t.children;if(!Array.isArray(r)||r.length!==1)return!1;const n=t.componentProps?.className;if(typeof n!="string")return!1;const s=n.split(/\s+/);return s.includes("flex")||s.includes("grid")}function N2(e,t,r,n){return{schema:In(e,[...t,"componentProps"],i=>{const a={...i};return n===void 0?delete a[r]:a[r]=n,a}),newPath:t}}function d_(e,t,r,n){return{schema:In(e,t,i=>{const a={...i};return n===void 0?delete a[r]:a[r]=n,a}),newPath:t}}function ZM(e,t,r){return{schema:In(e,t,s=>{const i={...s},a=Array.isArray(i.children)?[...i.children]:[],u=a.findIndex(o=>typeof o=="string"||typeof o=="number");return r===""?u>=0&&a.splice(u,1):u>=0?a[u]=r:a.unshift(r),a.length===0&&!Array.isArray(i.children)?delete i.children:i.children=a,i}),newPath:t}}function eR(e){const t=e.children;if(!Array.isArray(t))return-1;const r=t.reduce((n,s,i)=>((typeof s=="string"||typeof s=="number")&&n.push(i),n),[]);return r.length>1?null:r.length===1?r[0]:-1}function tR(e,t,r){return d_(e,t,"component",r)}function rR(e,t,r,n){const s=tR(e,t,`$component(${r})`),i=Pr(s.schema,[...t,"componentProps"]);return i==null||typeof i!="object"?s:{schema:In(s.schema,[...t,"componentProps"],u=>{const o={};for(const[c,p]of Object.entries(u))n.has(c)&&(o[c]=p);return o}),newPath:t}}function Vh(e,t,r,n){let s=r;return{schema:In(e,t,a=>{const u=Array.isArray(a)?a.slice():[],o=Math.max(0,Math.min(r,u.length));return s=o,u.splice(o,0,n),u}),newPath:[...t,s]}}function nR(e,t,r){const n=Pr(e,t),s=Array.isArray(n)?n.length:0;return Vh(e,t,s,r)}function Kbe(e,t){const r=O3(e,t),n=Pn(t)??["root"],s=Pr(r,n);if(p_(s)){const i=s.children[0];return{schema:In(r,n,()=>zn(i)),newPath:n}}return{schema:r,newPath:n}}function z3(e,t,r,n){const s=Pr(e,t);if(!s)return{schema:e,newPath:t};const i=zn(s);let a=O3(e,t);const u=Pn(t);if(u&&!ml(u,r)){const d=Pr(a,u);if(p_(d)){const h=d.children[0];a=In(a,u,()=>zn(h))}}const o=t.slice(0,-1),c=Number(t[t.length-1]);let p=n;return Xs(o,r)&&c<n&&(p=n-1),Vh(a,r,p,i)}function Vbe(e,t){const r=Pr(e,t),n=t.slice(0,-1),s=Number(t[t.length-1]),i=Pr(e,n);return!r||!Array.isArray(i)?{schema:e,newPath:t}:Vh(e,n,s+1,zn(r))}function sR(e,t,r,n,s){const i=Pr(e,t);if(!Array.isArray(i)||n<=0||r<0||r+n>i.length)return null;const a=s==="up"?r:r+n;return{schema:In(e,t,o=>{const c=o.slice(),p=c.slice(r,r+n).map(d=>zn(d));return c.splice(a,0,...p),c}),newStart:a}}function iR(e,t,r,n,s){const i=Pr(e,t);if(!Array.isArray(i))return null;const a=r+s;return a<0||a+n>i.length?null:{schema:In(e,t,o=>{const c=o.slice(),p=c.splice(r,n);return c.splice(a,0,...p),c}),newStart:a}}function aR(e,t,r,n){return In(e,t,s=>{const i=Array.isArray(s)?s.slice():[];return i.splice(r,n),i})}function oR(e,t,r){const n=[...new Set(r)].sort((i,a)=>a-i);let s=e;for(const i of n)s=aR(s,t,i,1);return s}function uR(e,t,r,n,s){const i=Pr(e,t);if(!Array.isArray(i)||n<1)return{schema:e,newPath:[...t,r]};const a=i.slice(r,r+n).map(zn),u={component:"$html(div)",componentProps:{className:s?.className??U3},children:a};return{schema:In(e,t,c=>{const p=c.slice();return p.splice(r,n,u),p}),newPath:[...t,r]}}function lR(e,t){const r=Pr(e,t);if(!r||!Lg(r))return{schema:e,newPath:t};const n=r.children,s=t.slice(0,-1),i=t[t.length-1];return!Array.isArray(n)||typeof i!="number"?{schema:e,newPath:t}:{schema:In(e,s,u=>{const o=u.slice();return o.splice(i,1,...n.map(zn)),o}),newPath:[...s,i]}}function f_(e,t,r,n,s){const i=Pr(e,t);if(!i)return{schema:e,newPath:t};const a=n==="before"?[zn(r),zn(i)]:[zn(i),zn(r)],u={component:"$html(div)",componentProps:{className:s?.className??c_},children:a};return{schema:In(e,t,()=>u),newPath:[...t,"children",n==="before"?0:1]}}function h_(e,t,r,n,s){if(ml(r,t)||ml(t,r))return{schema:e,newPath:t};const i=Pr(e,t),a=Pr(e,r);if(!i||!a)return{schema:e,newPath:t};const u=zn(i),o=zn(a),c=O3(e,r);let p=t;const d=r.slice(0,-1),h=t.slice(0,-1),m=r[r.length-1],y=t[t.length-1];Xs(d,h)&&typeof m=="number"&&typeof y=="number"&&m<y&&(p=[...h,y-1]);const v=n==="before"?[o,u]:[u,o],b={component:"$html(div)",componentProps:{className:s?.className??c_},children:v};return{schema:In(c,p,()=>b),newPath:[...p,"children",n==="before"?0:1]}}function cR(e,t,r,n,s){return f_(e,t,r,n,{className:s?.className??U3})}function pR(e,t,r,n,s){return h_(e,t,r,n,{className:s?.className??U3})}function dR(e,t){const r=(e??"").split(/\s+/).filter(Boolean).filter(n=>n==="flex"||!o_(n));return r.includes("flex")||r.unshift("flex"),t||r.splice(r.indexOf("flex")+1,0,"flex-col"),r.join(" ")}function fR(e){const t=e.split(/\s+/).filter(Boolean),r=i=>Sl(i).startsWith("flex-col"),n=i=>Sl(i).startsWith("flex-row");if(t.findIndex(r)>=0)for(let i=t.length-1;i>=0;i--)r(t[i])&&t.splice(i,1);else{for(let a=t.length-1;a>=0;a--)n(t[a])&&t.splice(a,1);const i=t.indexOf("flex");t.splice(i>=0?i+1:0,0,"flex-col")}return t.join(" ")}function m_(e,t){const r=Pr(e,t);if(!r||!ns(r))return{schema:e,newPath:t};const n=r.componentProps?.className,s=dR(typeof n=="string"?n:void 0,Th(r)!=="horizontal");return{schema:In(e,t,a=>{const u=a;return{...u,componentProps:{...u.componentProps??{},className:s}}}),newPath:t}}function hR(e,t,r,n,s){const i=Pr(e,t),a=Pr(e,r),u=Pr(e,n);if(!i||!a||!u)return{schema:e,newPath:r};const o=i.componentProps?.className,c=typeof o=="string"?fR(o):o,p=s==="before"?[zn(u),zn(a)]:[zn(a),zn(u)];return{schema:In(e,t,h=>{const m=h;return{...m,componentProps:{...m.componentProps??{},className:c},children:p}}),newPath:[...t,"children",s==="before"?0:1]}}function mR(){const e=Ca().ui,t=e?.leftPanel!==void 0?e.leftPanel:"files";return{preview:e?.preview??"wire",runtimeMode:e?.runtimeMode??"test",liveSchemas:!1,hideDivWrappers:e?.hideDivWrappers??!1,quickAddOpen:!1,rawJsonOpen:!1,bottomTab:e?.bottomTab??"raw",leftPanel:t,lastLeftPanel:t??"files",rightPanel:e?.rightOpen??!0?"inspector":null,lastRightPanel:"inspector",theme:e?.theme??"light",revealLine:null,revealNonce:0}}function yR(){return{tabs:{},order:[],activeTabId:null,ui:mR()}}function y_(e,t,r,n=!1){return{id:e,source:t,kind:"form",schema:r,savedSchema:r,past:[],future:[],selectionPath:["root"],selectionPaths:[["root"]],anchorPath:["root"],hoverPath:null,activeStep:0,touched:!1,preview:n,lastCoalesceKey:null}}function gR(e,t,r,n,s=!1,i="code"){const a=R3();return{id:e,source:t,kind:"code",schema:a,savedSchema:a,text:r,savedText:r,language:n,mdView:i,past:[],future:[],selectionPath:null,selectionPaths:[],anchorPath:null,hoverPath:null,activeStep:0,touched:!1,preview:s,lastCoalesceKey:null}}function DR(e){return e.order.find(t=>e.tabs[t]?.preview)??null}function g_(e,t){const r=t.preview?DR(e):null;if(r==null)return{...e,tabs:{...e.tabs,[t.id]:t},order:[...e.order,t.id],activeTabId:t.id};const n={...e.tabs,[t.id]:t};return delete n[r],{...e,tabs:n,order:e.order.map(s=>s===r?t.id:s),activeTabId:t.id}}function xR(e,t,r,n,s={}){const i=s.preview??!1;return e.tabs[t]?K3(i?e:q3(e,t),t):g_(e,y_(t,r,n,i))}function bR(e,t){const r=t.filter(s=>!e.tabs[s.id]);if(!r.length)return e;const n={...e.tabs};for(const s of r)n[s.id]=s;return{...e,tabs:n,order:[...e.order,...r.map(s=>s.id)],activeTabId:e.activeTabId??r[r.length-1].id}}function vR(e,t,r,n,s,i={}){const a=i.preview??!1;return e.tabs[t]?K3(a?e:q3(e,t),t):g_(e,gR(t,r,n,s,a,i.mdView))}function ER(e,t,r){const n=e.tabs[t];return!n||n.kind!=="code"||n.mdView===r?e:{...e,tabs:{...e.tabs,[t]:{...n,mdView:r}}}}function q3(e,t){const r=e.tabs[t];return!r||!r.preview?e:{...e,tabs:{...e.tabs,[t]:{...r,preview:!1}}}}function CR(e,t,r){const n=e.tabs[t];return!n||n.kind!=="code"||n.text===r?e:{...e,tabs:{...e.tabs,[t]:{...n,text:r,preview:!1}}}}function TR(e,t,r,n){const s=e.tabs[t];if(!s||s.mock?.[r]===n)return e;const i={...s.mock,[r]:n};return{...e,tabs:{...e.tabs,[t]:{...s,mock:i}}}}function AR(e,t,r){const n=e.tabs[t];if(!n||n.mock?.[r]===void 0)return e;const s={...n.mock};delete s[r];const i={...n,mock:s};return Object.keys(s).length===0&&delete i.mock,{...e,tabs:{...e.tabs,[t]:i}}}function SR(e){return mn(e,t=>t.kind==="code"?{...t,savedText:t.text}:t)}function FR(e,t){if(!e.tabs[t])return e;const r={...e.tabs};delete r[t];const n=e.order.filter(i=>i!==t);let s=e.activeTabId;if(s===t){const i=e.order.indexOf(t);s=n[Math.min(i,n.length-1)]??null}return{...e,tabs:r,order:n,activeTabId:s}}function J3(e,t,r){if(t.size===0)return e;const n={...e.tabs};for(const a of t)delete n[a];const s=e.order.filter(a=>!t.has(a)),i=e.activeTabId&&t.has(e.activeTabId)?r:e.activeTabId;return{...e,tabs:n,order:s,activeTabId:i}}function wR(e,t){return e.tabs[t]?J3(e,new Set(e.order.filter(r=>r!==t)),t):e}function kR(e,t){const r=e.order.indexOf(t);return r<=0?e:J3(e,new Set(e.order.slice(0,r)),t)}function _R(e,t){const r=e.order.indexOf(t);return r<0||r>=e.order.length-1?e:J3(e,new Set(e.order.slice(r+1)),t)}function K3(e,t){return e.tabs[t]?{...e,activeTabId:t}:e}function mn(e,t){const r=e.activeTabId;if(!r||!e.tabs[r])return e;const n=t(e.tabs[r]);return n===e.tabs[r]?e:{...e,tabs:{...e.tabs,[r]:n}}}function ga(e,t,r){const n=r!=null&&r===e.lastCoalesceKey,s={schema:e.schema,selectionPath:e.selectionPath},i=n?e.past:[...e.past,s].slice(-100),a=t.selectionPaths??(t.selectionPath?[t.selectionPath]:[]);return{...e,schema:t.schema,selectionPath:t.selectionPath,selectionPaths:a,anchorPath:t.anchorPath!==void 0?t.anchorPath:t.selectionPath,past:i,future:[],touched:!0,preview:!1,lastCoalesceKey:r??null}}function DS(e,t,r){return mn(e,n=>ga(n,{schema:t.schema,selectionPath:t.newPath},r?.coalesceKey))}function PR(e,t){return mn(e,r=>ga(r,{schema:t,selectionPath:r.selectionPath}))}function NR(e){return mn(e,t=>{if(!t.past.length)return t;const r=t.past[t.past.length-1],n={schema:t.schema,selectionPath:t.selectionPath};return{...t,schema:r.schema,selectionPath:r.selectionPath,selectionPaths:r.selectionPath?[r.selectionPath]:[],anchorPath:r.selectionPath,past:t.past.slice(0,-1),future:[n,...t.future],lastCoalesceKey:null}})}function $R(e){return mn(e,t=>{if(!t.future.length)return t;const r=t.future[0],n={schema:t.schema,selectionPath:t.selectionPath};return{...t,schema:r.schema,selectionPath:r.selectionPath,selectionPaths:r.selectionPath?[r.selectionPath]:[],anchorPath:r.selectionPath,past:[...t.past,n].slice(-100),future:t.future.slice(1),lastCoalesceKey:null}})}function IR(e){return mn(e,t=>({...t,savedSchema:t.schema}))}function BR(e,t,r){return mn(e,n=>({...n,savedSchema:n.schema,source:{...n.source,rawText:t,lastModified:r??n.source.lastModified}}))}function jR(e,t){return mn(e,r=>({...r,selectionPath:t,selectionPaths:t?[t]:[],anchorPath:t}))}function OR(e,t){return mn(e,r=>({...r,hoverPath:t}))}function LR(e,t){return mn(e,r=>({...r,activeStep:t}))}function V3(e){const t=e.selectionPaths.length?e.selectionPaths:e.selectionPath?[e.selectionPath]:[];if(!t.length)return null;const r=t.map(i=>Ls(e.schema,i));if(r.some(i=>i===null))return null;const n=r[0].slotPath;if(!r.every(i=>Xs(i.slotPath,n)))return null;const s=r.map(i=>i.index).sort((i,a)=>i-a);for(let i=1;i<s.length;i++)if(s[i]!==s[i-1]+1)return null;return{slotPath:n,start:s[0],count:s.length}}function MR(e){const t=e.selectionPaths.length?e.selectionPaths:e.selectionPath?[e.selectionPath]:[];if(!t.length)return null;const r=t.map(s=>Ls(e.schema,s));if(r.some(s=>s===null))return null;const n=r[0].slotPath;return r.every(s=>Xs(s.slotPath,n))?{slotPath:n,indices:r.map(s=>s.index)}:null}function ub(e,t){const r=Mi(e,t).find(n=>!n.single);return r?{slotPath:r.path,count:r.length}:!xp(e)&&ns(e)?{slotPath:[...t,"children"],count:0}:null}function RR(e,t,r=!1){return mn(e,n=>{const s=n.selectionPath??["root"],i=_2(n.schema,s,t);if(r&&(i==="prev"||i==="next")){const u=M3(n.schema,s,i);if(!u)return n;const o=n.anchorPath??s,c=Ls(n.schema,o),p=Ls(n.schema,u);if(c&&p&&Xs(c.slotPath,p.slotPath)){const d=Math.min(c.index,p.index),h=Math.max(c.index,p.index),m=[];for(let y=d;y<=h;y++)m.push([...c.slotPath,y]);return{...n,selectionPath:u,selectionPaths:m,anchorPath:o}}return{...n,selectionPath:u,selectionPaths:[u],anchorPath:u}}const a=YM(n.schema,s,t);return a?{...n,selectionPath:a,selectionPaths:[a],anchorPath:a}:n})}function UR(e){return mn(e,t=>{if(t.selectionPaths.length>1){const n=t.selectionPath;return{...t,selectionPaths:n?[n]:[],anchorPath:n}}const r=t.selectionPath?Pn(t.selectionPath):null;return{...t,selectionPath:r,selectionPaths:r?[r]:[],anchorPath:r}})}function zR(e,t){const r=Pn(t);if(!r)return null;const n=Ls(e,r);return n?z3(e,t,n.slotPath,n.index+1):null}function qR(e,t){const r=Ls(e,t);if(!r||r.index===0)return null;const n=[...r.slotPath,r.index-1],s=Pr(e,n);if(!s||!L3(s))return null;const i=Mi(s,n).find(a=>!a.single);return i?z3(e,t,i.path,i.length):null}function JR(e,t){return mn(e,r=>{const n=V3(r);if(!n)return r;const s=_2(r.schema,[...n.slotPath,n.start],t);if(s==="prev"||s==="next"){const u=iR(r.schema,n.slotPath,n.start,n.count,s==="prev"?-1:1);if(!u)return r;const o=[];for(let d=0;d<n.count;d++)o.push([...n.slotPath,u.newStart+d]);const c=r.selectionPath?Ls(r.schema,r.selectionPath):null,p=c?Math.max(0,Math.min(c.index-n.start,n.count-1)):n.count-1;return ga(r,{schema:u.schema,selectionPath:[...n.slotPath,u.newStart+p],selectionPaths:o,anchorPath:o[0]})}if(n.count!==1)return r;const i=[...n.slotPath,n.start],a=s==="out"?zR(r.schema,i):qR(r.schema,i);return a?ga(r,{schema:a.schema,selectionPath:a.newPath}):r})}function KR(e){return mn(e,t=>{const r=MR(t);if(!r)return t;const n=oR(t.schema,r.slotPath,r.indices),s=Pr(n,r.slotPath),i=Array.isArray(s)?s.length:0,a=Math.min(...r.indices),u=i>0?[...r.slotPath,Math.min(a,i-1)]:Pn([...r.slotPath,0])??["root"];return ga(t,{schema:n,selectionPath:u})})}function VR(e,t){return mn(e,r=>{const n=V3(r);if(!n)return r;const s=t?_2(r.schema,[...n.slotPath,n.start],t):"next";if(s!=="prev"&&s!=="next")return r;const i=sR(r.schema,n.slotPath,n.start,n.count,s==="prev"?"up":"down");if(!i)return r;const a=[];for(let c=0;c<n.count;c++)a.push([...n.slotPath,i.newStart+c]);const u=r.selectionPath?Ls(r.schema,r.selectionPath):null,o=u?Math.max(0,Math.min(u.index-n.start,n.count-1)):n.count-1;return ga(r,{schema:i.schema,selectionPath:[...n.slotPath,i.newStart+o],selectionPaths:a,anchorPath:a[0]})})}function WR(e,t){return mn(e,r=>{const n=r.selectionPath,s=n?Pr(r.schema,n):void 0;let i,a;const u=n&&s&&L3(s)?ub(s,n):null;if(n&&u)i=u.slotPath,a=u.count;else if(n){const c=Ls(r.schema,n);if(c)i=c.slotPath,a=c.index+1;else{const p=Pn(n)??["root"],d=Pr(r.schema,p),h=d?ub(d,p):null;if(!h)return r;i=h.slotPath,a=h.count}}else{const c=ub(r.schema.root,["root"]);if(!c)return r;i=c.slotPath,a=c.count}const o=Vh(r.schema,i,a,t);return ga(r,{schema:o.schema,selectionPath:o.newPath})})}function HR(e){return mn(e,t=>{const r=V3(t);if(!r)return t;const n=uR(t.schema,r.slotPath,r.start,r.count);return ga(t,{schema:n.schema,selectionPath:n.newPath})})}function GR(e){return mn(e,t=>{if(!t.selectionPath)return t;const r=lR(t.schema,t.selectionPath);return r.schema===t.schema?t:ga(t,{schema:r.schema,selectionPath:r.newPath})})}function XR(e){return mn(e,t=>{if(!t.selectionPath)return t;const r=Pr(t.schema,t.selectionPath);if(!r||!Lg(r))return t;const n=m_(t.schema,t.selectionPath);return ga(t,{schema:n.schema,selectionPath:t.selectionPath})})}function YR(e,t){return mn(e,r=>{const n=r.anchorPath??r.selectionPath??t,s=Ls(r.schema,n),i=Ls(r.schema,t);if(s&&i&&Xs(s.slotPath,i.slotPath)){const a=Math.min(s.index,i.index),u=Math.max(s.index,i.index),o=[];for(let c=a;c<=u;c++)o.push([...s.slotPath,c]);return{...r,selectionPath:t,selectionPaths:o,anchorPath:n}}return{...r,selectionPath:t,selectionPaths:[t],anchorPath:t}})}function QR(e,t){return mn(e,r=>{if(r.selectionPaths.some(a=>Xs(a,t))){const a=r.selectionPaths.filter(o=>!Xs(o,t)),u=a[a.length-1]??null;return{...r,selectionPaths:a,selectionPath:u,anchorPath:u}}const s=Ls(r.schema,t);return r.selectionPaths.length===0||s!=null&&r.selectionPaths.every(a=>{const u=Ls(r.schema,a);return u!=null&&Xs(u.slotPath,s.slotPath)})?{...r,selectionPath:t,selectionPaths:[...r.selectionPaths,t],anchorPath:t}:{...r,selectionPath:t,selectionPaths:[t],anchorPath:t}})}function ZR(e,t){return{...e,ui:{...e.ui,preview:t}}}function D_(e,t){return{...e,ui:{...e.ui,runtimeMode:t}}}function eU(e){return D_(e,e.ui.runtimeMode==="edit"?"test":"edit")}function tU(e,t){return{...e,ui:{...e.ui,liveSchemas:t}}}function rU(e){return{...e,ui:{...e.ui,rawJsonOpen:!e.ui.rawJsonOpen}}}function nU(e,t){return{...e,ui:{...e.ui,bottomTab:t}}}function sU(e){return{...e,ui:{...e.ui,hideDivWrappers:!e.ui.hideDivWrappers}}}function xS(e,t){return{...e,ui:{...e.ui,quickAddOpen:t}}}function iU(e,t){return{...e,ui:{...e.ui,rawJsonOpen:!0,revealLine:t,revealNonce:e.ui.revealNonce+1}}}function aU(e,t){return{...e,ui:{...e.ui,leftPanel:t,lastLeftPanel:t??e.ui.lastLeftPanel}}}function oU(e){const t=e.ui.leftPanel===null?e.ui.lastLeftPanel:null;return{...e,ui:{...e.ui,leftPanel:t}}}function x_(e,t){return{...e,ui:{...e.ui,rightPanel:t,lastRightPanel:t??e.ui.lastRightPanel}}}function uU(e){const t=e.ui.rightPanel===null?e.ui.lastRightPanel:null;return{...e,ui:{...e.ui,rightPanel:t}}}function lU(e,t){return x_(e,e.ui.rightPanel===t?null:t)}function cU(e,t){return{...e,ui:{...e.ui,theme:t}}}function $i(e){return e.activeTabId?e.tabs[e.activeTabId]??null:null}function b_(e){return e.kind==="code"?e.text!==e.savedText:e.schema!==e.savedSchema}function $2(e){return e.kind==="code"?!1:e.source.kind==="new"?!0:e.source.kind==="template"&&e.touched}const mt=Bl(yR()),Xe={openTab:(e,t,r,n)=>mt.setState(s=>xR(s,e,t,r,n)),restoreTabs:e=>mt.setState(t=>bR(t,e)),openCodeTab:(e,t,r,n,s)=>mt.setState(i=>vR(i,e,t,r,n,s)),pinTab:e=>mt.setState(t=>q3(t,e)),setTabText:(e,t)=>mt.setState(r=>CR(r,e,t)),setMdView:(e,t)=>mt.setState(r=>ER(r,e,t)),setMockText:(e,t,r)=>mt.setState(n=>TR(n,e,t,r)),resetMock:(e,t)=>mt.setState(r=>AR(r,e,t)),markCodeSaved:()=>mt.setState(SR),closeTab:e=>mt.setState(t=>FR(t,e)),closeOtherTabs:e=>mt.setState(t=>wR(t,e)),closeTabsToLeft:e=>mt.setState(t=>kR(t,e)),closeTabsToRight:e=>mt.setState(t=>_R(t,e)),setActiveTab:e=>mt.setState(t=>K3(t,e)),commit:(e,t)=>mt.setState(r=>DS(r,e,t)),apply:(e,t)=>mt.setState(r=>{const n=$i(r);return n?DS(r,e(n.schema),t):r}),replaceSchema:e=>mt.setState(t=>PR(t,e)),undo:()=>mt.setState(NR),redo:()=>mt.setState($R),markSaved:()=>mt.setState(IR),commitSaved:(e,t)=>mt.setState(r=>BR(r,e,t)),select:e=>mt.setState(t=>jR(t,e)),setHover:e=>mt.setState(t=>OR(t,e)),setActiveStep:e=>mt.setState(t=>LR(t,e)),navigate:(e,t)=>mt.setState(r=>RR(r,e,t)),moveSelection:e=>mt.setState(t=>JR(t,e)),deleteSelection:()=>mt.setState(KR),duplicateSelection:e=>mt.setState(t=>VR(t,e)),collapseSelection:()=>mt.setState(UR),groupSelection:()=>mt.setState(HR),ungroupSelection:()=>mt.setState(GR),flipSelection:()=>mt.setState(XR),extendSelectionTo:e=>mt.setState(t=>YR(t,e)),toggleSelectionAt:e=>mt.setState(t=>QR(t,e)),setPreview:e=>mt.setState(t=>ZR(t,e)),setRuntimeMode:e=>mt.setState(t=>D_(t,e)),toggleRuntimeMode:()=>mt.setState(eU),setLiveSchemas:e=>mt.setState(t=>tU(t,e)),toggleRawJson:()=>mt.setState(rU),setBottomTab:e=>mt.setState(t=>nU(t,e)),toggleHideDivWrappers:()=>mt.setState(sU),openQuickAdd:()=>mt.setState(e=>xS(e,!0)),closeQuickAdd:()=>mt.setState(e=>xS(e,!1)),addComponent:e=>mt.setState(t=>WR(t,e)),revealRawLine:e=>mt.setState(t=>iU(t,e)),setLeftPanel:e=>mt.setState(t=>aU(t,e)),toggleLeftPanel:()=>mt.setState(oU),setRightPanel:e=>mt.setState(t=>x_(t,e)),toggleRightPanel:()=>mt.setState(uU),toggleRightPanelTo:e=>mt.setState(t=>lU(t,e)),setTheme:e=>mt.setState(t=>cU(t,e))};function qp(e){return se.useSyncExternalStore(mt.subscribe,()=>e(mt.getState()),()=>e(mt.getState()))}function jl(){return qp($i)}function vi(){return qp(e=>e.ui)}function I2(){return qp(e=>$i(e)?.selectionPath??null)}function pU(){return qp(e=>e.order)}function v_(){return qp(e=>e.activeTabId)}function dU(e){return qp(t=>t.tabs[e])}const fU="reformer-builder",hU=3,Rg="handles",vp="templates",Ah="drafts";function mU(){return new Promise((e,t)=>{const r=indexedDB.open(fU,hU);r.onupgradeneeded=()=>{const n=r.result;n.objectStoreNames.contains(Rg)||n.createObjectStore(Rg),n.objectStoreNames.contains(vp)||n.createObjectStore(vp),n.objectStoreNames.contains(Ah)||n.createObjectStore(Ah)},r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)})}function yo(e,t,r){return mU().then(n=>new Promise((s,i)=>{const a=r(n.transaction(e,t).objectStore(e));a.onsuccess=()=>s(a.result),a.onerror=()=>i(a.error)}))}async function yU(){try{return(await yo(Ah,"readonly",t=>t.getAll())).sort((t,r)=>t.createdAt-r.createdAt)}catch(e){return console.warn("[reformer-builder] черновики недоступны:",e),[]}}async function gU(e){await yo(Ah,"readwrite",t=>t.put(e,e.id))}async function DU(e){await yo(Ah,"readwrite",t=>t.delete(e))}const xU=400;function E_(e){const t=new Map;for(const r of e.order){const n=e.tabs[r];n&&$2(n)&&t.set(r,n)}return t}function bU(e,t){return e.schema!==t.schema||e.savedSchema!==t.savedSchema||e.mock!==t.mock||e.source!==t.source||e.activeStep!==t.activeStep||e.touched!==t.touched}function vU(e,t){const r=e,n=E_(t),s=[];for(const[a,u]of n){const o=r.get(a);(!o||bU(o,u))&&s.push(u)}const i=[];for(const a of r.keys())n.has(a)||i.push(a);return{save:s,remove:i}}function EU(e,t,r){return{id:e.id,source:e.source,schema:e.schema,savedSchema:e.savedSchema,mock:e.mock,activeStep:e.activeStep,touched:e.touched,createdAt:t,updatedAt:r}}function CU(e){return{...y_(e.id,e.source,e.schema),savedSchema:e.savedSchema,mock:e.mock,activeStep:e.activeStep,touched:e.touched}}function TU(e=[]){const t=new Map(e.map(o=>[o.id,o.createdAt])),r=new Set(e.map(o=>o.id)),n=new Map;for(const[o,c]of E_(mt.getState()))r.has(o)&&n.set(o,c);let s=null;const i=()=>{s=null;const{save:o,remove:c}=vU(n,mt.getState()),p=Date.now();for(const d of o){const h=t.get(d.id)??p;t.set(d.id,h),n.set(d.id,d),gU(EU(d,h,p)).catch(m=>{console.warn("[reformer-builder] черновик не сохранён:",d.id,m)})}for(const d of c)t.delete(d),n.delete(d),C_(d)},a=()=>{s==null&&(s=setTimeout(i,xU))},u=mt.subscribe(a);return a(),()=>{s!=null&&clearTimeout(s),u()}}function C_(e){return DU(e).catch(t=>{console.warn("[reformer-builder] черновик не удалён:",e,t)})}const ip=Bl({plan:null,saving:!1}),Ga={open:e=>ip.setState({plan:e,saving:!1}),close:()=>ip.setState({plan:null,saving:!1}),setSaving:e=>ip.setState(t=>({...t,saving:e}))};function AU(){return se.useSyncExternalStore(ip.subscribe,()=>ip.getState(),()=>ip.getState())}function SU(){const e=BO(),t=jO(e);return LO(t),OO(e,t)}const FU=["Control","Options","Textfield","Behavior","State"];function wU(e){const t=e.properties??{},r=[];for(const[n,s]of Object.entries(t)){const i=s["x-doc"];r.push({key:n,label:NU(n),widget:n==="iconName"?"icon":n==="className"?"className":n==="testId"?"text":i?.group==="Options"&&s.type==="array"?"dataSource":i?.kind??PU(s),group:i?.group??"Control",description:typeof s.description=="string"?s.description:void 0,default:s.default,options:Array.isArray(s.enum)?s.enum:void 0,min:typeof s.minimum=="number"?s.minimum:void 0,max:typeof s.maximum=="number"?s.maximum:void 0,step:typeof s.multipleOf=="number"?s.multipleOf:void 0})}return r}function kU(e){const t=new Map;for(const r of e){const n=t.get(r.group)??[];n.push(r),t.set(r.group,n)}return FU.filter(r=>t.has(r)).map(r=>({group:r,props:t.get(r)}))}function _U(e){return kU(wU(e))}function PU(e){if(Array.isArray(e.enum))return"enum";const t=e.type;return t==="boolean"?"boolean":t==="number"||t==="integer"?"number":"text"}function NU(e){return e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase()).trim()}function B2(e){return Ta().filter(t=>t.compoundParent===e)}function $U(e){return B2(e).map(t=>t.name)}function W3(e){return e.compoundParent!==void 0}const Ug=new Map,bS="(all)";function IU(e){const t=Ug.get(e);if(t)return t;Ta();const{styles:r,classGroupPolicy:n}=Up(),s=n.get(e),i=s?r.classNames.filter(u=>s.has(u.id)):r.classNames,a=Array.from(new Set(i.flatMap(u=>u.classes)));return Ug.set(e,a),a}function BU(){const e=Ug.get(bS);if(e)return e;Ta();const t=Array.from(new Set(Up().styles.classNames.flatMap(r=>r.classes)));return Ug.set(bS,t),t}function jU(e,t){if(!e.length)return[];const r=new Set(e);return Array.from(new Set(t.split(/\s+/).filter(Boolean))).filter(n=>!r.has(n))}function OU(e,t,r,n){const s=t.toLowerCase();if(!s)return[];const i=[];for(const a of e)if(a.toLowerCase().includes(s)&&(a===t||!r.has(a))&&i.push(a),i.length===n)break;return i}const LU=["HTML","Типографика","Поля ввода","Выбор и переключатели","Контейнеры","Действия","Отображение","Массив","Оверлеи","Навигация","Чат","Прочее"],MU="Прочее";function RU(){const e=Ca().palette?.order;return e&&e.length?e:LU}function T_(e){return e.startsWith("$html(")&&e.endsWith(")")?e.slice(6,-1):null}function H3(e){return T_(e.name)??e.name}function A_(e){const t=new Map;for(const i of e){const a=i.category??MU,u=t.get(a)??[];u.push(i),t.set(a,u)}const r=RU(),n=r.filter(i=>t.has(i)).map(i=>[i,t.get(i)]),s=[...t.keys()].filter(i=>!r.includes(i)).map(i=>[i,t.get(i)]);return[...n,...s]}let UU=null;function Ta(){return UU??=SU()}function ll(e){return Ta().find(t=>t.name===e)}function zU(e){return typeof e=="function"||typeof e=="object"&&e!==null&&"$$typeof"in e}function S_(e){return e.role!=="array"&&!e.name.startsWith("$html(")}function qU(e,t){const r=t[b8(e)];return zU(r)?r:void 0}function JU(e,t,r=Up()){const{name:n,compoundParent:s}=e,i=r.previewPolicy.get(n)??(s?r.previewPolicy.get(s):void 0);if(i?.mode==="limited")return{policy:"limited",reason:i.reason??"предпросмотр ограничен"};const a=qU(e,t);return a?{policy:"live",component:a}:{policy:"limited",reason:r.unresolvedReason.get(n)??(s?r.unresolvedReason.get(s):void 0)??`не резолвится в ${r.package}`}}const KU=["__selfManagedChildren","reformerNeedsControl","reformerLayout"];class VU extends se.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}render(){const{error:t}=this.state;return t?S.jsxs("div",{className:`rounded-md border border-dashed border-destructive/50 bg-destructive/5 p-3 text-xs text-destructive ${this.props.className??""}`,children:[S.jsxs("span",{className:"font-mono font-semibold",children:["⚠ ",this.props.name]}),S.jsx("span",{className:"ml-2 opacity-80",children:"— компонент упал при рендере"}),S.jsx("div",{className:"mt-1 font-mono text-[11px] opacity-70",children:t.message})]}):this.props.children}}function vS(e,t){function r(n){return S.jsx(VU,{name:t,className:n.className,children:S.jsx(e,{...n})})}r.displayName=`Isolated(${t})`;for(const n of KU){const s=e[n];s!==void 0&&(r[n]=s)}return r}function F_(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(r=F_(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function WU(){for(var e,t,r=0,n="",s=arguments.length;r<s;r++)(e=arguments[r])&&(t=F_(e))&&(n&&(n+=" "),n+=t);return n}const HU=(e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r},GU=(e,t)=>({classGroupId:e,validator:t}),w_=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),zg="-",ES=[],XU="arbitrary..",YU=e=>{const t=ZU(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return QU(a);const u=a.split(zg),o=u[0]===""&&u.length>1?1:0;return k_(u,o,t)},getConflictingClassGroupIds:(a,u)=>{if(u){const o=n[a],c=r[a];return o?c?HU(c,o):o:c||ES}return r[a]||ES}}},k_=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const s=e[t],i=r.nextPart.get(s);if(i){const c=k_(e,t+1,i);if(c)return c}const a=r.validators;if(a===null)return;const u=t===0?e.join(zg):e.slice(t).join(zg),o=a.length;for(let c=0;c<o;c++){const p=a[c];if(p.validator(u))return p.classGroupId}},QU=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?XU+n:void 0})(),ZU=e=>{const{theme:t,classGroups:r}=e;return ez(r,t)},ez=(e,t)=>{const r=w_();for(const n in e){const s=e[n];G3(s,r,n,t)}return r},G3=(e,t,r,n)=>{const s=e.length;for(let i=0;i<s;i++){const a=e[i];tz(a,t,r,n)}},tz=(e,t,r,n)=>{if(typeof e=="string"){rz(e,t,r);return}if(typeof e=="function"){nz(e,t,r,n);return}sz(e,t,r,n)},rz=(e,t,r)=>{const n=e===""?t:__(t,e);n.classGroupId=r},nz=(e,t,r,n)=>{if(iz(e)){G3(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(GU(r,e))},sz=(e,t,r,n)=>{const s=Object.entries(e),i=s.length;for(let a=0;a<i;a++){const[u,o]=s[a];G3(o,__(t,u),r,n)}},__=(e,t)=>{let r=e;const n=t.split(zg),s=n.length;for(let i=0;i<s;i++){const a=n[i];let u=r.nextPart.get(a);u||(u=w_(),r.nextPart.set(a,u)),r=u}return r},iz=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,az=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const s=(i,a)=>{r[i]=a,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(i){let a=r[i];if(a!==void 0)return a;if((a=n[i])!==void 0)return s(i,a),a},set(i,a){i in r?r[i]=a:s(i,a)}}},Iv="!",CS=":",oz=[],TS=(e,t,r,n,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:s}),uz=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=s=>{const i=[];let a=0,u=0,o=0,c;const p=s.length;for(let v=0;v<p;v++){const b=s[v];if(a===0&&u===0){if(b===CS){i.push(s.slice(o,v)),o=v+1;continue}if(b==="/"){c=v;continue}}b==="["?a++:b==="]"?a--:b==="("?u++:b===")"&&u--}const d=i.length===0?s:s.slice(o);let h=d,m=!1;d.endsWith(Iv)?(h=d.slice(0,-1),m=!0):d.startsWith(Iv)&&(h=d.slice(1),m=!0);const y=c&&c>o?c-o:void 0;return TS(i,m,h,y)};if(t){const s=t+CS,i=n;n=a=>a.startsWith(s)?i(a.slice(s.length)):TS(oz,!1,a,void 0,!0)}if(r){const s=n;n=i=>r({className:i,parseClassName:s})}return n},lz=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let s=[];for(let i=0;i<r.length;i++){const a=r[i],u=a[0]==="[",o=t.has(a);u||o?(s.length>0&&(s.sort(),n.push(...s),s=[]),n.push(a)):s.push(a)}return s.length>0&&(s.sort(),n.push(...s)),n}},cz=e=>({cache:az(e.cacheSize),parseClassName:uz(e),sortModifiers:lz(e),...YU(e)}),pz=/\s+/,dz=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:s,sortModifiers:i}=t,a=[],u=e.trim().split(pz);let o="";for(let c=u.length-1;c>=0;c-=1){const p=u[c],{isExternal:d,modifiers:h,hasImportantModifier:m,baseClassName:y,maybePostfixModifierPosition:v}=r(p);if(d){o=p+(o.length>0?" "+o:o);continue}let b=!!v,T=n(b?y.substring(0,v):y);if(!T){if(!b){o=p+(o.length>0?" "+o:o);continue}if(T=n(y),!T){o=p+(o.length>0?" "+o:o);continue}b=!1}const D=h.length===0?"":h.length===1?h[0]:i(h).join(":"),x=m?D+Iv:D,E=x+T;if(a.indexOf(E)>-1)continue;a.push(E);const A=s(T,b);for(let F=0;F<A.length;++F){const k=A[F];a.push(x+k)}o=p+(o.length>0?" "+o:o)}return o},fz=(...e)=>{let t=0,r,n,s="";for(;t<e.length;)(r=e[t++])&&(n=P_(r))&&(s&&(s+=" "),s+=n);return s},P_=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=P_(e[n]))&&(r&&(r+=" "),r+=t);return r},hz=(e,...t)=>{let r,n,s,i;const a=o=>{const c=t.reduce((p,d)=>d(p),e());return r=cz(c),n=r.cache.get,s=r.cache.set,i=u,u(o)},u=o=>{const c=n(o);if(c)return c;const p=dz(o,r);return s(o,p),p};return i=a,(...o)=>i(fz(...o))},mz=[],vn=e=>{const t=r=>r[e]||mz;return t.isThemeGetter=!0,t},N_=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,$_=/^\((?:(\w[\w-]*):)?(.+)\)$/i,yz=/^\d+\/\d+$/,gz=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Dz=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,xz=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,bz=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,vz=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ec=e=>yz.test(e),hr=e=>!!e&&!Number.isNaN(Number(e)),Ro=e=>!!e&&Number.isInteger(Number(e)),lb=e=>e.endsWith("%")&&hr(e.slice(0,-1)),Ra=e=>gz.test(e),Ez=()=>!0,Cz=e=>Dz.test(e)&&!xz.test(e),I_=()=>!1,Tz=e=>bz.test(e),Az=e=>vz.test(e),Sz=e=>!At(e)&&!St(e),Fz=e=>Jp(e,O_,I_),At=e=>N_.test(e),Hu=e=>Jp(e,L_,Cz),cb=e=>Jp(e,Nz,hr),AS=e=>Jp(e,B_,I_),wz=e=>Jp(e,j_,Az),Q1=e=>Jp(e,M_,Tz),St=e=>$_.test(e),yf=e=>Kp(e,L_),kz=e=>Kp(e,$z),SS=e=>Kp(e,B_),_z=e=>Kp(e,O_),Pz=e=>Kp(e,j_),Z1=e=>Kp(e,M_,!0),Jp=(e,t,r)=>{const n=N_.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Kp=(e,t,r=!1)=>{const n=$_.exec(e);return n?n[1]?t(n[1]):r:!1},B_=e=>e==="position"||e==="percentage",j_=e=>e==="image"||e==="url",O_=e=>e==="length"||e==="size"||e==="bg-size",L_=e=>e==="length",Nz=e=>e==="number",$z=e=>e==="family-name",M_=e=>e==="shadow",Iz=()=>{const e=vn("color"),t=vn("font"),r=vn("text"),n=vn("font-weight"),s=vn("tracking"),i=vn("leading"),a=vn("breakpoint"),u=vn("container"),o=vn("spacing"),c=vn("radius"),p=vn("shadow"),d=vn("inset-shadow"),h=vn("text-shadow"),m=vn("drop-shadow"),y=vn("blur"),v=vn("perspective"),b=vn("aspect"),T=vn("ease"),D=vn("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],E=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...E(),St,At],F=()=>["auto","hidden","clip","visible","scroll"],k=()=>["auto","contain","none"],_=()=>[St,At,o],O=()=>[Ec,"full","auto",..._()],q=()=>[Ro,"none","subgrid",St,At],j=()=>["auto",{span:["full",Ro,St,At]},Ro,St,At],V=()=>[Ro,"auto",St,At],z=()=>["auto","min","max","fr",St,At],oe=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],L=()=>["start","end","center","stretch","center-safe","end-safe"],ne=()=>["auto",..._()],Ee=()=>[Ec,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],X=()=>[e,St,At],je=()=>[...E(),SS,AS,{position:[St,At]}],K=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Q=()=>["auto","cover","contain",_z,Fz,{size:[St,At]}],ie=()=>[lb,yf,Hu],M=()=>["","none","full",c,St,At],B=()=>["",hr,yf,Hu],U=()=>["solid","dashed","dotted","double"],J=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],de=()=>[hr,lb,SS,AS],Ce=()=>["","none",y,St,At],Me=()=>["none",hr,St,At],Ue=()=>["none",hr,St,At],re=()=>[hr,St,At],le=()=>[Ec,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ra],breakpoint:[Ra],color:[Ez],container:[Ra],"drop-shadow":[Ra],ease:["in","out","in-out"],font:[Sz],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ra],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ra],shadow:[Ra],spacing:["px",hr],text:[Ra],"text-shadow":[Ra],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ec,At,St,b]}],container:["container"],columns:[{columns:[hr,At,St,u]}],"break-after":[{"break-after":x()}],"break-before":[{"break-before":x()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:F()}],"overflow-x":[{"overflow-x":F()}],"overflow-y":[{"overflow-y":F()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{start:O()}],end:[{end:O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[Ro,"auto",St,At]}],basis:[{basis:[Ec,"full","auto",u,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[hr,Ec,"auto","initial","none",At]}],grow:[{grow:["",hr,St,At]}],shrink:[{shrink:["",hr,St,At]}],order:[{order:[Ro,"first","last","none",St,At]}],"grid-cols":[{"grid-cols":q()}],"col-start-end":[{col:j()}],"col-start":[{"col-start":V()}],"col-end":[{"col-end":V()}],"grid-rows":[{"grid-rows":q()}],"row-start-end":[{row:j()}],"row-start":[{"row-start":V()}],"row-end":[{"row-end":V()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":z()}],"auto-rows":[{"auto-rows":z()}],gap:[{gap:_()}],"gap-x":[{"gap-x":_()}],"gap-y":[{"gap-y":_()}],"justify-content":[{justify:[...oe(),"normal"]}],"justify-items":[{"justify-items":[...L(),"normal"]}],"justify-self":[{"justify-self":["auto",...L()]}],"align-content":[{content:["normal",...oe()]}],"align-items":[{items:[...L(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...L(),{baseline:["","last"]}]}],"place-content":[{"place-content":oe()}],"place-items":[{"place-items":[...L(),"baseline"]}],"place-self":[{"place-self":["auto",...L()]}],p:[{p:_()}],px:[{px:_()}],py:[{py:_()}],ps:[{ps:_()}],pe:[{pe:_()}],pt:[{pt:_()}],pr:[{pr:_()}],pb:[{pb:_()}],pl:[{pl:_()}],m:[{m:ne()}],mx:[{mx:ne()}],my:[{my:ne()}],ms:[{ms:ne()}],me:[{me:ne()}],mt:[{mt:ne()}],mr:[{mr:ne()}],mb:[{mb:ne()}],ml:[{ml:ne()}],"space-x":[{"space-x":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"space-y-reverse":["space-y-reverse"],size:[{size:Ee()}],w:[{w:[u,"screen",...Ee()]}],"min-w":[{"min-w":[u,"screen","none",...Ee()]}],"max-w":[{"max-w":[u,"screen","none","prose",{screen:[a]},...Ee()]}],h:[{h:["screen","lh",...Ee()]}],"min-h":[{"min-h":["screen","lh","none",...Ee()]}],"max-h":[{"max-h":["screen","lh",...Ee()]}],"font-size":[{text:["base",r,yf,Hu]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,St,cb]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",lb,At]}],"font-family":[{font:[kz,At,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,St,At]}],"line-clamp":[{"line-clamp":[hr,"none",St,cb]}],leading:[{leading:[i,..._()]}],"list-image":[{"list-image":["none",St,At]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",St,At]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:X()}],"text-color":[{text:X()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:[hr,"from-font","auto",St,Hu]}],"text-decoration-color":[{decoration:X()}],"underline-offset":[{"underline-offset":[hr,"auto",St,At]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",St,At]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",St,At]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:je()}],"bg-repeat":[{bg:K()}],"bg-size":[{bg:Q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ro,St,At],radial:["",St,At],conic:[Ro,St,At]},Pz,wz]}],"bg-color":[{bg:X()}],"gradient-from-pos":[{from:ie()}],"gradient-via-pos":[{via:ie()}],"gradient-to-pos":[{to:ie()}],"gradient-from":[{from:X()}],"gradient-via":[{via:X()}],"gradient-to":[{to:X()}],rounded:[{rounded:M()}],"rounded-s":[{"rounded-s":M()}],"rounded-e":[{"rounded-e":M()}],"rounded-t":[{"rounded-t":M()}],"rounded-r":[{"rounded-r":M()}],"rounded-b":[{"rounded-b":M()}],"rounded-l":[{"rounded-l":M()}],"rounded-ss":[{"rounded-ss":M()}],"rounded-se":[{"rounded-se":M()}],"rounded-ee":[{"rounded-ee":M()}],"rounded-es":[{"rounded-es":M()}],"rounded-tl":[{"rounded-tl":M()}],"rounded-tr":[{"rounded-tr":M()}],"rounded-br":[{"rounded-br":M()}],"rounded-bl":[{"rounded-bl":M()}],"border-w":[{border:B()}],"border-w-x":[{"border-x":B()}],"border-w-y":[{"border-y":B()}],"border-w-s":[{"border-s":B()}],"border-w-e":[{"border-e":B()}],"border-w-t":[{"border-t":B()}],"border-w-r":[{"border-r":B()}],"border-w-b":[{"border-b":B()}],"border-w-l":[{"border-l":B()}],"divide-x":[{"divide-x":B()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":B()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...U(),"hidden","none"]}],"divide-style":[{divide:[...U(),"hidden","none"]}],"border-color":[{border:X()}],"border-color-x":[{"border-x":X()}],"border-color-y":[{"border-y":X()}],"border-color-s":[{"border-s":X()}],"border-color-e":[{"border-e":X()}],"border-color-t":[{"border-t":X()}],"border-color-r":[{"border-r":X()}],"border-color-b":[{"border-b":X()}],"border-color-l":[{"border-l":X()}],"divide-color":[{divide:X()}],"outline-style":[{outline:[...U(),"none","hidden"]}],"outline-offset":[{"outline-offset":[hr,St,At]}],"outline-w":[{outline:["",hr,yf,Hu]}],"outline-color":[{outline:X()}],shadow:[{shadow:["","none",p,Z1,Q1]}],"shadow-color":[{shadow:X()}],"inset-shadow":[{"inset-shadow":["none",d,Z1,Q1]}],"inset-shadow-color":[{"inset-shadow":X()}],"ring-w":[{ring:B()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:X()}],"ring-offset-w":[{"ring-offset":[hr,Hu]}],"ring-offset-color":[{"ring-offset":X()}],"inset-ring-w":[{"inset-ring":B()}],"inset-ring-color":[{"inset-ring":X()}],"text-shadow":[{"text-shadow":["none",h,Z1,Q1]}],"text-shadow-color":[{"text-shadow":X()}],opacity:[{opacity:[hr,St,At]}],"mix-blend":[{"mix-blend":[...J(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":J()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[hr]}],"mask-image-linear-from-pos":[{"mask-linear-from":de()}],"mask-image-linear-to-pos":[{"mask-linear-to":de()}],"mask-image-linear-from-color":[{"mask-linear-from":X()}],"mask-image-linear-to-color":[{"mask-linear-to":X()}],"mask-image-t-from-pos":[{"mask-t-from":de()}],"mask-image-t-to-pos":[{"mask-t-to":de()}],"mask-image-t-from-color":[{"mask-t-from":X()}],"mask-image-t-to-color":[{"mask-t-to":X()}],"mask-image-r-from-pos":[{"mask-r-from":de()}],"mask-image-r-to-pos":[{"mask-r-to":de()}],"mask-image-r-from-color":[{"mask-r-from":X()}],"mask-image-r-to-color":[{"mask-r-to":X()}],"mask-image-b-from-pos":[{"mask-b-from":de()}],"mask-image-b-to-pos":[{"mask-b-to":de()}],"mask-image-b-from-color":[{"mask-b-from":X()}],"mask-image-b-to-color":[{"mask-b-to":X()}],"mask-image-l-from-pos":[{"mask-l-from":de()}],"mask-image-l-to-pos":[{"mask-l-to":de()}],"mask-image-l-from-color":[{"mask-l-from":X()}],"mask-image-l-to-color":[{"mask-l-to":X()}],"mask-image-x-from-pos":[{"mask-x-from":de()}],"mask-image-x-to-pos":[{"mask-x-to":de()}],"mask-image-x-from-color":[{"mask-x-from":X()}],"mask-image-x-to-color":[{"mask-x-to":X()}],"mask-image-y-from-pos":[{"mask-y-from":de()}],"mask-image-y-to-pos":[{"mask-y-to":de()}],"mask-image-y-from-color":[{"mask-y-from":X()}],"mask-image-y-to-color":[{"mask-y-to":X()}],"mask-image-radial":[{"mask-radial":[St,At]}],"mask-image-radial-from-pos":[{"mask-radial-from":de()}],"mask-image-radial-to-pos":[{"mask-radial-to":de()}],"mask-image-radial-from-color":[{"mask-radial-from":X()}],"mask-image-radial-to-color":[{"mask-radial-to":X()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":E()}],"mask-image-conic-pos":[{"mask-conic":[hr]}],"mask-image-conic-from-pos":[{"mask-conic-from":de()}],"mask-image-conic-to-pos":[{"mask-conic-to":de()}],"mask-image-conic-from-color":[{"mask-conic-from":X()}],"mask-image-conic-to-color":[{"mask-conic-to":X()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:je()}],"mask-repeat":[{mask:K()}],"mask-size":[{mask:Q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",St,At]}],filter:[{filter:["","none",St,At]}],blur:[{blur:Ce()}],brightness:[{brightness:[hr,St,At]}],contrast:[{contrast:[hr,St,At]}],"drop-shadow":[{"drop-shadow":["","none",m,Z1,Q1]}],"drop-shadow-color":[{"drop-shadow":X()}],grayscale:[{grayscale:["",hr,St,At]}],"hue-rotate":[{"hue-rotate":[hr,St,At]}],invert:[{invert:["",hr,St,At]}],saturate:[{saturate:[hr,St,At]}],sepia:[{sepia:["",hr,St,At]}],"backdrop-filter":[{"backdrop-filter":["","none",St,At]}],"backdrop-blur":[{"backdrop-blur":Ce()}],"backdrop-brightness":[{"backdrop-brightness":[hr,St,At]}],"backdrop-contrast":[{"backdrop-contrast":[hr,St,At]}],"backdrop-grayscale":[{"backdrop-grayscale":["",hr,St,At]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[hr,St,At]}],"backdrop-invert":[{"backdrop-invert":["",hr,St,At]}],"backdrop-opacity":[{"backdrop-opacity":[hr,St,At]}],"backdrop-saturate":[{"backdrop-saturate":[hr,St,At]}],"backdrop-sepia":[{"backdrop-sepia":["",hr,St,At]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":_()}],"border-spacing-x":[{"border-spacing-x":_()}],"border-spacing-y":[{"border-spacing-y":_()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",St,At]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[hr,"initial",St,At]}],ease:[{ease:["linear","initial",T,St,At]}],delay:[{delay:[hr,St,At]}],animate:[{animate:["none",D,St,At]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,St,At]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:Me()}],"rotate-x":[{"rotate-x":Me()}],"rotate-y":[{"rotate-y":Me()}],"rotate-z":[{"rotate-z":Me()}],scale:[{scale:Ue()}],"scale-x":[{"scale-x":Ue()}],"scale-y":[{"scale-y":Ue()}],"scale-z":[{"scale-z":Ue()}],"scale-3d":["scale-3d"],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[St,At,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:le()}],"translate-x":[{"translate-x":le()}],"translate-y":[{"translate-y":le()}],"translate-z":[{"translate-z":le()}],"translate-none":["translate-none"],accent:[{accent:X()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:X()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",St,At]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",St,At]}],fill:[{fill:["none",...X()]}],"stroke-w":[{stroke:[hr,yf,Hu,cb]}],stroke:[{stroke:["none",...X()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Bz=hz(Iz);function Xt(...e){return Bz(WU(e))}function jz(e){function t({children:r,className:n}){return S.jsxs("div",{className:Xt("rounded-md border border-dashed border-amber-400/60 bg-amber-50/40 p-3 text-xs dark:bg-amber-950/20",n),children:[S.jsxs("span",{className:"font-mono text-amber-700 dark:text-amber-400",children:["⚠ ",e]}),S.jsx("span",{className:"ml-2 text-muted-foreground",children:"— компонент не зарегистрирован в preview"}),r?S.jsx("div",{className:"mt-2",children:r}):null]})}return t.displayName=`Unknown(${e})`,t}function FS(e,t){function r({children:n,className:s}){return S.jsxs("div",{className:Xt("rounded-md border border-dashed border-border bg-muted/30 p-3 text-xs text-muted-foreground",s),children:[S.jsx("span",{className:"font-mono text-foreground",children:e}),S.jsxs("span",{className:"ml-2",children:["— предпросмотр ограничен",t?` (${t})`:""]}),n?S.jsx("div",{className:"mt-2",children:n}):null]})}return r.displayName=`PreviewLimited(${e})`,r}function Oz({className:e,children:t}){return S.jsx("div",{"data-slot":"preview-step",className:e,children:t})}const R_=se.createContext(void 0);function Lz({form:e,children:t}){return S.jsx(R_.Provider,{value:e,children:t})}function Mz(){return se.useContext(R_)}function Rz(e){function t(r){const n=Mz(),s=r.form??n,a=(r.steps??[]).map((u,o)=>({number:o+1,title:u.componentProps?.title??`Шаг ${o+1}`,icon:u.componentProps?.icon,body:u}));return S.jsx("div",{className:r.className,children:S.jsx(e,{form:s,steps:a,config:{},renderStepBody:(u,o)=>S.jsx(IO,{node:u,form:o}),onSubmit:()=>{}})})}return t.__selfManagedChildren=!0,t}function Uz(){return Ta().filter(S_).map(e=>e.name)}let zz=null,qz=null;function U_(){return zz??=[...Uz(),...v8]}function Jz(){return qz??=new Set(U_())}function Kz(e,t){const r=e.adapters.wizard?.symbol,n=r?t[r]:void 0;return n?{...t,Wizard:Rz(n),Step:Oz}:t}function Vz(e,t){return{FormField:t[e.infra.fieldWrapper],AsyncBoundary:t[e.infra.asyncBoundary],List:t[e.infra.list]}}function Wz(e=Up(),t=E8()){const r=Kz(e,t),n=Vz(e,r),s={};for(const i of v8){const a=n[i];s[i]=vS(a??FS(i,`нет в ${e.package}`),i)}for(const i of Ta()){if(!S_(i))continue;const a=JU(i,r,e);s[i.name]=vS(a.policy==="live"?a.component:FS(i.name,a.reason),i.name)}return s}function Hz(){const e=Up().adapters.provider?.symbol;if(!e)return;const t=E8()[e];return typeof t=="function"||typeof t=="object"&&t!==null?t:void 0}let Gz=null;function Xz(){return Gz??=Wz()}const X3=["options","items","data","dataSource","choices","list"],Yz=new Set(["Select","RadioGroup","Radio","RadioButtonGroup","Combobox","Autocomplete","MultiSelect"]),Qz=new Set(["Checkbox","Switch","Toggle"]),Zz=new Set(["Slider","InputNumber","NumberInput"]),eq=new Set(["DatePicker","DateInput","Calendar","DateRangePicker"]),tq=new Set(["FileUpload","FileUploadAvatar","Attachment"]);function Y3(e){const t=new Set(bp(e).dataSources),r=new Set,n=new Set;Mg(e,i=>{const a=i.componentProps;if(a){if(Jn(i)){const u=Mt(a.itemLabel);u?.op==="dataSource"&&r.add(u.arg)}for(const u of X3){const o=Mt(a[u]);o?.op==="dataSource"&&n.add(o.arg)}}});for(const i of r)n.delete(i);const s=new Set;for(const i of t)!r.has(i)&&!n.has(i)&&s.add(i);return{functionLike:r,optionLike:n,scalarLike:s}}function Q3(e){const t=dq(e);return[1,2,3].map(r=>({value:`option${r}`,label:`${t} ${r}`}))}function rq(e){const t={};for(const r of e.optionLike)t[r]=Q3(r);for(const r of e.scalarLike)t[r]="значение";return t}function z_(e){const t=Mt(e.component)?.arg,r=e.componentProps??{};return t&&tq.has(t)?"files":nq(r)||Array.isArray(r.options)||t&&Yz.has(t)?"select":t&&Qz.has(t)?"boolean":r.type==="number"||t&&Zz.has(t)?"number":r.type==="date"||t&&eq.has(t)||iq(e,sq)?"date":"string"}function nq(e){return X3.some(t=>Mt(e[t])?.op==="dataSource")}const sq=/(date|dob|birth|дата|рожд)/;function j2(e){const r=(Mt(e.value)?.arg??"").split(".").pop()??"",n=String(e.componentProps?.label??e.componentProps?.placeholder??"");return`${r} ${n}`.toLowerCase()}function iq(e,t){return t.test(j2(e))}function aq(e,t,r){switch(z_(e)){case"select":return oq(e,t);case"boolean":return!1;case"number":return uq(e,r);case"date":return lq(e,r);case"files":return null;default:return cq(e)}}function oq(e,t){const r=e.componentProps??{};for(const n of X3){const s=Mt(r[n]);if(s?.op==="dataSource"){const i=t[s.arg];if(Array.isArray(i)&&i.length)return i[0].value??"option1"}}if(Array.isArray(r.options)&&r.options.length){const n=r.options[0];if(n&&typeof n=="object"&&"value"in n)return n.value}return"option1"}function uq(e,t){const r=Mt(e.component)?.arg,n=e.componentProps??{};if(r==="Slider")return typeof n.min=="number"?n.min:0;const s=j2(e);return/\byear\b|год/.test(s)?t.getFullYear():/(amount|sum|price|salary|income|сумм|цен|доход|зарплат|стоим)/.test(s)?5e4:/(age|возраст)/.test(s)?30:/(count|qty|quantity|колич)/.test(s)?1:/(percent|rate|ставк|процент)/.test(s)?10:42}function lq(e,t){return/(dob|birth|рожд)/.test(j2(e))?"1990-01-01":t.toISOString().slice(0,10)}function cq(e){const t=j2(e);return/(e-?mail|почт)/.test(t)?"ivan@example.com":/(phone|tel|телефон)/.test(t)?"+7 999 123-45-67":/(lastname|surname|фамил)/.test(t)?"Иванов":/(firstname|имя)/.test(t)?"Иван":/(fullname|fio|фио|\bname\b)/.test(t)?"Иван Иванов":/(url|site|website|сайт)/.test(t)?"https://example.com":/(city|город)/.test(t)?"Москва":/(address|адрес)/.test(t)?"г. Москва, ул. Пример, 1":/(inn|инн)/.test(t)?"7712345678":/(password|пароль)/.test(t)?"Passw0rd!":/(comment|note|description|коммент|примечан|описан)/.test(t)?"Пример текста":String(e.componentProps?.label??"").trim()||"Пример"}function pq(e,t,r,n){const s=e.initialValue&&typeof e.initialValue=="object"?e.initialValue:{},i=e.item?.$template,a=[];for(let u=0;u<n;u++){const o=an(i)?q_(i,t,r,n):{};a.push(J_(o,s))}return a}function q_(e,t,r,n){const s={},i=a=>{if(Jn(a)){const u=Mt(a.array);u?.op==="model"&&wS(s,u.arg.split("."),pq(a,t,r,n));return}if(ni(a)){const u=Mt(a.value);u?.op==="model"&&wS(s,u.arg.split("."),aq(a,t,r));return}if(ns(a)){a.children?.forEach(o=>an(o)&&i(o));const u=a.componentProps?.steps;Array.isArray(u)&&u.forEach(o=>an(o)&&i(o))}};return i(e),s}function Ep(e,t={}){const r=t.now??new Date,n=t.arrayItems??1,s=Y3(e),i=rq(s);return{model:an(e.root)?q_(e.root,i,r,n):{},dataSources:i}}function wS(e,t,r){let n=e;for(let s=0;s<t.length-1;s++){const i=t[s];(typeof n[i]!="object"||n[i]===null||Array.isArray(n[i]))&&(n[i]={}),n=n[i]}n[t[t.length-1]]=r}function J_(e,t){const r={...e};for(const[n,s]of Object.entries(t)){const i=r[n];kS(i)&&kS(s)?r[n]=J_(i,s):r[n]=s}return r}function kS(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function dq(e){const t=e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):"Вариант"}function fq(e,t,r={}){const{functionLike:n,optionLike:s,scalarLike:i}=Y3(t);for(const o of n)e.dataSource(o,(c,p=0)=>`#${p+1}`);for(const o of s)e.dataSource(o,r[o]??Q3(o));for(const o of i)e.dataSource(o,r[o]??"значение");const{fns:a,locales:u}=bp(t);for(const o of a)e.fn(o,()=>"");u.length>0&&e.locale(o=>o)}function hq(e){const t=Jz();return bp(e).components.filter(r=>!t.has(r))}function mq(e,t){const r=Xz();return G8(n=>{for(const[s,i]of Object.entries(r))n.component(s,i);n.component(k2,r.FormField);for(const s of hq(e))n.component(s,jz(s));fq(n,e,t)})}function yq(e,t){const r=t??Ep(e),n=m8(r.model),s=mq(e,r.dataSources),i=y8({model:n,schema:B3(e,s,n)});return{registry:s,model:n,form:i}}let Bv=null;const jv=new Set;function _S(e){if(Bv!==e){Bv=e;for(const t of jv)t()}}function gq(){return Bv}function Dq(e){return jv.add(e),()=>jv.delete(e)}const Sh="rbnode-",K_="rb-empty",V_="__",xq=new RegExp(`(?:^|\\s)(${Sh}[A-Za-z0-9_-]+)(?:\\s|$)`),PS=e=>`-${e.codePointAt(0).toString(16)}-`;function bq(e){if(typeof e=="number")return String(e);let t="";for(const r of e)t+=/[A-Za-z0-9]/.test(r)?r:PS(r);return/^\d+$/.test(t)?PS(e[0])+t.slice(1):t}function vq(e){return/^\d+$/.test(e)?Number(e):e.replace(/-([0-9a-f]+)-/g,(t,r)=>String.fromCodePoint(parseInt(r,16)))}function O2(e){return Sh+e.map(bq).join(V_)}function Eq(e){if(!e.startsWith(Sh))return null;const t=e.slice(Sh.length);if(!t)return null;const r=t.split(V_);return r.some(n=>n==="")?null:r.map(vq)}function Cq(e){const t=xq.exec(e);return t?t[1]:null}const Tq="space-y-3 mt-2";function pb(e,t,r={}){const n=typeof e?.className=="string"?e.className:"",s=r.arrayDefault&&!n?Tq:"",i=[n,s,O2(t),r.empty?K_:""].filter(Boolean).join(" ");return{...e,className:i}}function Of(e,t){if(Jn(e)){const r=e;return{...r,componentProps:pb(r.componentProps,t,{arrayDefault:!r.component}),item:{$template:Of(r.item.$template,[...t,"item","$template"])}}}if(ni(e)){const r=e,n={...r,componentProps:pb(r.componentProps,t)};return r.wrapper&&(n.wrapper=Of(r.wrapper,[...t,"wrapper"])),n}if(ns(e)){const r=e,n=r.componentProps?.steps,s=Array.isArray(n)&&n.some(an),a=(Array.isArray(r.children)?r.children.length:0)+(s?1:0)===0,u={...r,componentProps:pb(r.componentProps,t,{empty:a})};if(s){const o=[...t,"componentProps","steps"];u.componentProps={...u.componentProps,steps:n.map((c,p)=>an(c)?Of(c,[...o,p]):c)}}return Array.isArray(r.children)&&(u.children=r.children.map((o,c)=>an(o)?Of(o,[...t,"children",c]):o)),u}return e}function Aq(e){return{...e,root:Of(e.root,["root"])}}function Sq(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var db={exports:{}},NS={},Ua={},Gu={},$S={},IS={},BS={},jS;function qg(){return jS||(jS=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor(D){if(super(),!e.IDENTIFIER.test(D))throw new Error("CodeGen: name must be a valid identifier");this.str=D}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(D){super(),this._items=typeof D=="string"?[D]:D}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const D=this._items[0];return D===""||D==='""'}get str(){var D;return(D=this._str)!==null&&D!==void 0?D:this._str=this._items.reduce((x,E)=>`${x}${E}`,"")}get names(){var D;return(D=this._names)!==null&&D!==void 0?D:this._names=this._items.reduce((x,E)=>(E instanceof r&&(x[E.str]=(x[E.str]||0)+1),x),{})}}e._Code=n,e.nil=new n("");function s(T,...D){const x=[T[0]];let E=0;for(;E<D.length;)u(x,D[E]),x.push(T[++E]);return new n(x)}e._=s;const i=new n("+");function a(T,...D){const x=[m(T[0])];let E=0;for(;E<D.length;)x.push(i),u(x,D[E]),x.push(i,m(T[++E]));return o(x),new n(x)}e.str=a;function u(T,D){D instanceof n?T.push(...D._items):D instanceof r?T.push(D):T.push(d(D))}e.addCodeArg=u;function o(T){let D=1;for(;D<T.length-1;){if(T[D]===i){const x=c(T[D-1],T[D+1]);if(x!==void 0){T.splice(D-1,3,x);continue}T[D++]="+"}D++}}function c(T,D){if(D==='""')return T;if(T==='""')return D;if(typeof T=="string")return D instanceof r||T[T.length-1]!=='"'?void 0:typeof D!="string"?`${T.slice(0,-1)}${D}"`:D[0]==='"'?T.slice(0,-1)+D.slice(1):void 0;if(typeof D=="string"&&D[0]==='"'&&!(T instanceof r))return`"${T}${D.slice(1)}`}function p(T,D){return D.emptyStr()?T:T.emptyStr()?D:a`${T}${D}`}e.strConcat=p;function d(T){return typeof T=="number"||typeof T=="boolean"||T===null?T:m(Array.isArray(T)?T.join(","):T)}function h(T){return new n(m(T))}e.stringify=h;function m(T){return JSON.stringify(T).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.safeStringify=m;function y(T){return typeof T=="string"&&e.IDENTIFIER.test(T)?new n(`.${T}`):s`[${T}]`}e.getProperty=y;function v(T){if(typeof T=="string"&&e.IDENTIFIER.test(T))return new n(`${T}`);throw new Error(`CodeGen: invalid export name: ${T}, use explicit $id name mapping`)}e.getEsmExportName=v;function b(T){return new n(T.toString())}e.regexpCode=b})(BS)),BS}var OS={},LS;function MS(){return LS||(LS=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=qg();class r extends Error{constructor(c){super(`CodeGen: "code" for ${c} not defined`),this.value=c.value}}var n;(function(o){o[o.Started=0]="Started",o[o.Completed=1]="Completed"})(n||(e.UsedValueState=n={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};class s{constructor({prefixes:c,parent:p}={}){this._names={},this._prefixes=c,this._parent=p}toName(c){return c instanceof t.Name?c:this.name(c)}name(c){return new t.Name(this._newName(c))}_newName(c){const p=this._names[c]||this._nameGroup(c);return`${c}${p.index++}`}_nameGroup(c){var p,d;if(!((d=(p=this._parent)===null||p===void 0?void 0:p._prefixes)===null||d===void 0)&&d.has(c)||this._prefixes&&!this._prefixes.has(c))throw new Error(`CodeGen: prefix "${c}" is not allowed in this scope`);return this._names[c]={prefix:c,index:0}}}e.Scope=s;class i extends t.Name{constructor(c,p){super(p),this.prefix=c}setValue(c,{property:p,itemIndex:d}){this.value=c,this.scopePath=(0,t._)`.${new t.Name(p)}[${d}]`}}e.ValueScopeName=i;const a=(0,t._)`\n`;class u extends s{constructor(c){super(c),this._values={},this._scope=c.scope,this.opts={...c,_n:c.lines?a:t.nil}}get(){return this._scope}name(c){return new i(c,this._newName(c))}value(c,p){var d;if(p.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const h=this.toName(c),{prefix:m}=h,y=(d=p.key)!==null&&d!==void 0?d:p.ref;let v=this._values[m];if(v){const D=v.get(y);if(D)return D}else v=this._values[m]=new Map;v.set(y,h);const b=this._scope[m]||(this._scope[m]=[]),T=b.length;return b[T]=p.ref,h.setValue(p,{property:m,itemIndex:T}),h}getValue(c,p){const d=this._values[c];if(d)return d.get(p)}scopeRefs(c,p=this._values){return this._reduceValues(p,d=>{if(d.scopePath===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return(0,t._)`${c}${d.scopePath}`})}scopeCode(c=this._values,p,d){return this._reduceValues(c,h=>{if(h.value===void 0)throw new Error(`CodeGen: name "${h}" has no value`);return h.value.code},p,d)}_reduceValues(c,p,d={},h){let m=t.nil;for(const y in c){const v=c[y];if(!v)continue;const b=d[y]=d[y]||new Map;v.forEach(T=>{if(b.has(T))return;b.set(T,n.Started);let D=p(T);if(D){const x=this.opts.es5?e.varKinds.var:e.varKinds.const;m=(0,t._)`${m}${x} ${T} = ${D};${this.opts._n}`}else if(D=h?.(T))m=(0,t._)`${m}${D}${this.opts._n}`;else throw new r(T);b.set(T,n.Completed)})}return m}}e.ValueScope=u})(OS)),OS}var RS;function Dr(){return RS||(RS=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=qg(),r=MS();var n=qg();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=MS();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class i{optimizeNodes(){return this}optimizeNames(B,U){return this}}class a extends i{constructor(B,U,J){super(),this.varKind=B,this.name=U,this.rhs=J}render({es5:B,_n:U}){const J=B?r.varKinds.var:this.varKind,de=this.rhs===void 0?"":` = ${this.rhs}`;return`${J} ${this.name}${de};`+U}optimizeNames(B,U){if(B[this.name.str])return this.rhs&&(this.rhs=oe(this.rhs,B,U)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class u extends i{constructor(B,U,J){super(),this.lhs=B,this.rhs=U,this.sideEffects=J}render({_n:B}){return`${this.lhs} = ${this.rhs};`+B}optimizeNames(B,U){if(!(this.lhs instanceof t.Name&&!B[this.lhs.str]&&!this.sideEffects))return this.rhs=oe(this.rhs,B,U),this}get names(){const B=this.lhs instanceof t.Name?{}:{...this.lhs.names};return z(B,this.rhs)}}class o extends u{constructor(B,U,J,de){super(B,J,de),this.op=U}render({_n:B}){return`${this.lhs} ${this.op}= ${this.rhs};`+B}}class c extends i{constructor(B){super(),this.label=B,this.names={}}render({_n:B}){return`${this.label}:`+B}}class p extends i{constructor(B){super(),this.label=B,this.names={}}render({_n:B}){return`break${this.label?` ${this.label}`:""};`+B}}class d extends i{constructor(B){super(),this.error=B}render({_n:B}){return`throw ${this.error};`+B}get names(){return this.error.names}}class h extends i{constructor(B){super(),this.code=B}render({_n:B}){return`${this.code};`+B}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(B,U){return this.code=oe(this.code,B,U),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class m extends i{constructor(B=[]){super(),this.nodes=B}render(B){return this.nodes.reduce((U,J)=>U+J.render(B),"")}optimizeNodes(){const{nodes:B}=this;let U=B.length;for(;U--;){const J=B[U].optimizeNodes();Array.isArray(J)?B.splice(U,1,...J):J?B[U]=J:B.splice(U,1)}return B.length>0?this:void 0}optimizeNames(B,U){const{nodes:J}=this;let de=J.length;for(;de--;){const Ce=J[de];Ce.optimizeNames(B,U)||(L(B,Ce.names),J.splice(de,1))}return J.length>0?this:void 0}get names(){return this.nodes.reduce((B,U)=>V(B,U.names),{})}}class y extends m{render(B){return"{"+B._n+super.render(B)+"}"+B._n}}class v extends m{}class b extends y{}b.kind="else";class T extends y{constructor(B,U){super(U),this.condition=B}render(B){let U=`if(${this.condition})`+super.render(B);return this.else&&(U+="else "+this.else.render(B)),U}optimizeNodes(){super.optimizeNodes();const B=this.condition;if(B===!0)return this.nodes;let U=this.else;if(U){const J=U.optimizeNodes();U=this.else=Array.isArray(J)?new b(J):J}if(U)return B===!1?U instanceof T?U:U.nodes:this.nodes.length?this:new T(ne(B),U instanceof T?[U]:U.nodes);if(!(B===!1||!this.nodes.length))return this}optimizeNames(B,U){var J;if(this.else=(J=this.else)===null||J===void 0?void 0:J.optimizeNames(B,U),!!(super.optimizeNames(B,U)||this.else))return this.condition=oe(this.condition,B,U),this}get names(){const B=super.names;return z(B,this.condition),this.else&&V(B,this.else.names),B}}T.kind="if";class D extends y{}D.kind="for";class x extends D{constructor(B){super(),this.iteration=B}render(B){return`for(${this.iteration})`+super.render(B)}optimizeNames(B,U){if(super.optimizeNames(B,U))return this.iteration=oe(this.iteration,B,U),this}get names(){return V(super.names,this.iteration.names)}}class E extends D{constructor(B,U,J,de){super(),this.varKind=B,this.name=U,this.from=J,this.to=de}render(B){const U=B.es5?r.varKinds.var:this.varKind,{name:J,from:de,to:Ce}=this;return`for(${U} ${J}=${de}; ${J}<${Ce}; ${J}++)`+super.render(B)}get names(){const B=z(super.names,this.from);return z(B,this.to)}}class A extends D{constructor(B,U,J,de){super(),this.loop=B,this.varKind=U,this.name=J,this.iterable=de}render(B){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(B)}optimizeNames(B,U){if(super.optimizeNames(B,U))return this.iterable=oe(this.iterable,B,U),this}get names(){return V(super.names,this.iterable.names)}}class F extends y{constructor(B,U,J){super(),this.name=B,this.args=U,this.async=J}render(B){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(B)}}F.kind="func";class k extends m{render(B){return"return "+super.render(B)}}k.kind="return";class _ extends y{render(B){let U="try"+super.render(B);return this.catch&&(U+=this.catch.render(B)),this.finally&&(U+=this.finally.render(B)),U}optimizeNodes(){var B,U;return super.optimizeNodes(),(B=this.catch)===null||B===void 0||B.optimizeNodes(),(U=this.finally)===null||U===void 0||U.optimizeNodes(),this}optimizeNames(B,U){var J,de;return super.optimizeNames(B,U),(J=this.catch)===null||J===void 0||J.optimizeNames(B,U),(de=this.finally)===null||de===void 0||de.optimizeNames(B,U),this}get names(){const B=super.names;return this.catch&&V(B,this.catch.names),this.finally&&V(B,this.finally.names),B}}class O extends y{constructor(B){super(),this.error=B}render(B){return`catch(${this.error})`+super.render(B)}}O.kind="catch";class q extends y{render(B){return"finally"+super.render(B)}}q.kind="finally";class j{constructor(B,U={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...U,_n:U.lines?`
|
|
3
3
|
`:""},this._extScope=B,this._scope=new r.Scope({parent:B}),this._nodes=[new v]}toString(){return this._root.render(this.opts)}name(B){return this._scope.name(B)}scopeName(B){return this._extScope.name(B)}scopeValue(B,U){const J=this._extScope.value(B,U);return(this._values[J.prefix]||(this._values[J.prefix]=new Set)).add(J),J}getScopeValue(B,U){return this._extScope.getValue(B,U)}scopeRefs(B){return this._extScope.scopeRefs(B,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(B,U,J,de){const Ce=this._scope.toName(U);return J!==void 0&&de&&(this._constants[Ce.str]=J),this._leafNode(new a(B,Ce,J)),Ce}const(B,U,J){return this._def(r.varKinds.const,B,U,J)}let(B,U,J){return this._def(r.varKinds.let,B,U,J)}var(B,U,J){return this._def(r.varKinds.var,B,U,J)}assign(B,U,J){return this._leafNode(new u(B,U,J))}add(B,U){return this._leafNode(new o(B,e.operators.ADD,U))}code(B){return typeof B=="function"?B():B!==t.nil&&this._leafNode(new h(B)),this}object(...B){const U=["{"];for(const[J,de]of B)U.length>1&&U.push(","),U.push(J),(J!==de||this.opts.es5)&&(U.push(":"),(0,t.addCodeArg)(U,de));return U.push("}"),new t._Code(U)}if(B,U,J){if(this._blockNode(new T(B)),U&&J)this.code(U).else().code(J).endIf();else if(U)this.code(U).endIf();else if(J)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(B){return this._elseNode(new T(B))}else(){return this._elseNode(new b)}endIf(){return this._endBlockNode(T,b)}_for(B,U){return this._blockNode(B),U&&this.code(U).endFor(),this}for(B,U){return this._for(new x(B),U)}forRange(B,U,J,de,Ce=this.opts.es5?r.varKinds.var:r.varKinds.let){const Me=this._scope.toName(B);return this._for(new E(Ce,Me,U,J),()=>de(Me))}forOf(B,U,J,de=r.varKinds.const){const Ce=this._scope.toName(B);if(this.opts.es5){const Me=U instanceof t.Name?U:this.var("_arr",U);return this.forRange("_i",0,(0,t._)`${Me}.length`,Ue=>{this.var(Ce,(0,t._)`${Me}[${Ue}]`),J(Ce)})}return this._for(new A("of",de,Ce,U),()=>J(Ce))}forIn(B,U,J,de=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(B,(0,t._)`Object.keys(${U})`,J);const Ce=this._scope.toName(B);return this._for(new A("in",de,Ce,U),()=>J(Ce))}endFor(){return this._endBlockNode(D)}label(B){return this._leafNode(new c(B))}break(B){return this._leafNode(new p(B))}return(B){const U=new k;if(this._blockNode(U),this.code(B),U.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(k)}try(B,U,J){if(!U&&!J)throw new Error('CodeGen: "try" without "catch" and "finally"');const de=new _;if(this._blockNode(de),this.code(B),U){const Ce=this.name("e");this._currNode=de.catch=new O(Ce),U(Ce)}return J&&(this._currNode=de.finally=new q,this.code(J)),this._endBlockNode(O,q)}throw(B){return this._leafNode(new d(B))}block(B,U){return this._blockStarts.push(this._nodes.length),B&&this.code(B).endBlock(U),this}endBlock(B){const U=this._blockStarts.pop();if(U===void 0)throw new Error("CodeGen: not in self-balancing block");const J=this._nodes.length-U;if(J<0||B!==void 0&&J!==B)throw new Error(`CodeGen: wrong number of nodes: ${J} vs ${B} expected`);return this._nodes.length=U,this}func(B,U=t.nil,J,de){return this._blockNode(new F(B,U,J)),de&&this.code(de).endFunc(),this}endFunc(){return this._endBlockNode(F)}optimize(B=1){for(;B-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(B){return this._currNode.nodes.push(B),this}_blockNode(B){this._currNode.nodes.push(B),this._nodes.push(B)}_endBlockNode(B,U){const J=this._currNode;if(J instanceof B||U&&J instanceof U)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${U?`${B.kind}/${U.kind}`:B.kind}"`)}_elseNode(B){const U=this._currNode;if(!(U instanceof T))throw new Error('CodeGen: "else" without "if"');return this._currNode=U.else=B,this}get _root(){return this._nodes[0]}get _currNode(){const B=this._nodes;return B[B.length-1]}set _currNode(B){const U=this._nodes;U[U.length-1]=B}}e.CodeGen=j;function V(M,B){for(const U in B)M[U]=(M[U]||0)+(B[U]||0);return M}function z(M,B){return B instanceof t._CodeOrName?V(M,B.names):M}function oe(M,B,U){if(M instanceof t.Name)return J(M);if(!de(M))return M;return new t._Code(M._items.reduce((Ce,Me)=>(Me instanceof t.Name&&(Me=J(Me)),Me instanceof t._Code?Ce.push(...Me._items):Ce.push(Me),Ce),[]));function J(Ce){const Me=U[Ce.str];return Me===void 0||B[Ce.str]!==1?Ce:(delete B[Ce.str],Me)}function de(Ce){return Ce instanceof t._Code&&Ce._items.some(Me=>Me instanceof t.Name&&B[Me.str]===1&&U[Me.str]!==void 0)}}function L(M,B){for(const U in B)M[U]=(M[U]||0)-(B[U]||0)}function ne(M){return typeof M=="boolean"||typeof M=="number"||M===null?!M:(0,t._)`!${ie(M)}`}e.not=ne;const Ee=Q(e.operators.AND);function X(...M){return M.reduce(Ee)}e.and=X;const je=Q(e.operators.OR);function K(...M){return M.reduce(je)}e.or=K;function Q(M){return(B,U)=>B===t.nil?U:U===t.nil?B:(0,t._)`${ie(B)} ${M} ${ie(U)}`}function ie(M){return M instanceof t.Name?M:(0,t._)`(${M})`}})(IS)),IS}var dr={},US;function wr(){if(US)return dr;US=1,Object.defineProperty(dr,"__esModule",{value:!0}),dr.checkStrictMode=dr.getErrorPath=dr.Type=dr.useFunc=dr.setEvaluated=dr.evaluatedPropsToName=dr.mergeEvaluated=dr.eachItem=dr.unescapeJsonPointer=dr.escapeJsonPointer=dr.escapeFragment=dr.unescapeFragment=dr.schemaRefOrVal=dr.schemaHasRulesButRef=dr.schemaHasRules=dr.checkUnknownRules=dr.alwaysValidSchema=dr.toHash=void 0;const e=Dr(),t=qg();function r(A){const F={};for(const k of A)F[k]=!0;return F}dr.toHash=r;function n(A,F){return typeof F=="boolean"?F:Object.keys(F).length===0?!0:(s(A,F),!i(F,A.self.RULES.all))}dr.alwaysValidSchema=n;function s(A,F=A.schema){const{opts:k,self:_}=A;if(!k.strictSchema||typeof F=="boolean")return;const O=_.RULES.keywords;for(const q in F)O[q]||E(A,`unknown keyword: "${q}"`)}dr.checkUnknownRules=s;function i(A,F){if(typeof A=="boolean")return!A;for(const k in A)if(F[k])return!0;return!1}dr.schemaHasRules=i;function a(A,F){if(typeof A=="boolean")return!A;for(const k in A)if(k!=="$ref"&&F.all[k])return!0;return!1}dr.schemaHasRulesButRef=a;function u({topSchemaRef:A,schemaPath:F},k,_,O){if(!O){if(typeof k=="number"||typeof k=="boolean")return k;if(typeof k=="string")return(0,e._)`${k}`}return(0,e._)`${A}${F}${(0,e.getProperty)(_)}`}dr.schemaRefOrVal=u;function o(A){return d(decodeURIComponent(A))}dr.unescapeFragment=o;function c(A){return encodeURIComponent(p(A))}dr.escapeFragment=c;function p(A){return typeof A=="number"?`${A}`:A.replace(/~/g,"~0").replace(/\//g,"~1")}dr.escapeJsonPointer=p;function d(A){return A.replace(/~1/g,"/").replace(/~0/g,"~")}dr.unescapeJsonPointer=d;function h(A,F){if(Array.isArray(A))for(const k of A)F(k);else F(A)}dr.eachItem=h;function m({mergeNames:A,mergeToName:F,mergeValues:k,resultToName:_}){return(O,q,j,V)=>{const z=j===void 0?q:j instanceof e.Name?(q instanceof e.Name?A(O,q,j):F(O,q,j),j):q instanceof e.Name?(F(O,j,q),q):k(q,j);return V===e.Name&&!(z instanceof e.Name)?_(O,z):z}}dr.mergeEvaluated={props:m({mergeNames:(A,F,k)=>A.if((0,e._)`${k} !== true && ${F} !== undefined`,()=>{A.if((0,e._)`${F} === true`,()=>A.assign(k,!0),()=>A.assign(k,(0,e._)`${k} || {}`).code((0,e._)`Object.assign(${k}, ${F})`))}),mergeToName:(A,F,k)=>A.if((0,e._)`${k} !== true`,()=>{F===!0?A.assign(k,!0):(A.assign(k,(0,e._)`${k} || {}`),v(A,k,F))}),mergeValues:(A,F)=>A===!0?!0:{...A,...F},resultToName:y}),items:m({mergeNames:(A,F,k)=>A.if((0,e._)`${k} !== true && ${F} !== undefined`,()=>A.assign(k,(0,e._)`${F} === true ? true : ${k} > ${F} ? ${k} : ${F}`)),mergeToName:(A,F,k)=>A.if((0,e._)`${k} !== true`,()=>A.assign(k,F===!0?!0:(0,e._)`${k} > ${F} ? ${k} : ${F}`)),mergeValues:(A,F)=>A===!0?!0:Math.max(A,F),resultToName:(A,F)=>A.var("items",F)})};function y(A,F){if(F===!0)return A.var("props",!0);const k=A.var("props",(0,e._)`{}`);return F!==void 0&&v(A,k,F),k}dr.evaluatedPropsToName=y;function v(A,F,k){Object.keys(k).forEach(_=>A.assign((0,e._)`${F}${(0,e.getProperty)(_)}`,!0))}dr.setEvaluated=v;const b={};function T(A,F){return A.scopeValue("func",{ref:F,code:b[F.code]||(b[F.code]=new t._Code(F.code))})}dr.useFunc=T;var D;(function(A){A[A.Num=0]="Num",A[A.Str=1]="Str"})(D||(dr.Type=D={}));function x(A,F,k){if(A instanceof e.Name){const _=F===D.Num;return k?_?(0,e._)`"[" + ${A} + "]"`:(0,e._)`"['" + ${A} + "']"`:_?(0,e._)`"/" + ${A}`:(0,e._)`"/" + ${A}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return k?(0,e.getProperty)(A).toString():"/"+p(A)}dr.getErrorPath=x;function E(A,F,k=A.opts.strictSchema){if(k){if(F=`strict mode: ${F}`,k===!0)throw new Error(F);A.self.logger.warn(F)}}return dr.checkStrictMode=E,dr}var e0={},zS;function mu(){if(zS)return e0;zS=1,Object.defineProperty(e0,"__esModule",{value:!0});const e=Dr(),t={data:new e.Name("data"),valCxt:new e.Name("valCxt"),instancePath:new e.Name("instancePath"),parentData:new e.Name("parentData"),parentDataProperty:new e.Name("parentDataProperty"),rootData:new e.Name("rootData"),dynamicAnchors:new e.Name("dynamicAnchors"),vErrors:new e.Name("vErrors"),errors:new e.Name("errors"),this:new e.Name("this"),self:new e.Name("self"),scope:new e.Name("scope"),json:new e.Name("json"),jsonPos:new e.Name("jsonPos"),jsonLen:new e.Name("jsonLen"),jsonPart:new e.Name("jsonPart")};return e0.default=t,e0}var qS;function L2(){return qS||(qS=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=Dr(),r=wr(),n=mu();e.keywordError={message:({keyword:b})=>(0,t.str)`must pass "${b}" keyword validation`},e.keyword$DataError={message:({keyword:b,schemaType:T})=>T?(0,t.str)`"${b}" keyword must be ${T} ($data)`:(0,t.str)`"${b}" keyword is invalid ($data)`};function s(b,T=e.keywordError,D,x){const{it:E}=b,{gen:A,compositeRule:F,allErrors:k}=E,_=d(b,T,D);x??(F||k)?o(A,_):c(E,(0,t._)`[${_}]`)}e.reportError=s;function i(b,T=e.keywordError,D){const{it:x}=b,{gen:E,compositeRule:A,allErrors:F}=x,k=d(b,T,D);o(E,k),A||F||c(x,n.default.vErrors)}e.reportExtraError=i;function a(b,T){b.assign(n.default.errors,T),b.if((0,t._)`${n.default.vErrors} !== null`,()=>b.if(T,()=>b.assign((0,t._)`${n.default.vErrors}.length`,T),()=>b.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function u({gen:b,keyword:T,schemaValue:D,data:x,errsCount:E,it:A}){if(E===void 0)throw new Error("ajv implementation error");const F=b.name("err");b.forRange("i",E,n.default.errors,k=>{b.const(F,(0,t._)`${n.default.vErrors}[${k}]`),b.if((0,t._)`${F}.instancePath === undefined`,()=>b.assign((0,t._)`${F}.instancePath`,(0,t.strConcat)(n.default.instancePath,A.errorPath))),b.assign((0,t._)`${F}.schemaPath`,(0,t.str)`${A.errSchemaPath}/${T}`),A.opts.verbose&&(b.assign((0,t._)`${F}.schema`,D),b.assign((0,t._)`${F}.data`,x))})}e.extendErrors=u;function o(b,T){const D=b.const("err",T);b.if((0,t._)`${n.default.vErrors} === null`,()=>b.assign(n.default.vErrors,(0,t._)`[${D}]`),(0,t._)`${n.default.vErrors}.push(${D})`),b.code((0,t._)`${n.default.errors}++`)}function c(b,T){const{gen:D,validateName:x,schemaEnv:E}=b;E.$async?D.throw((0,t._)`new ${b.ValidationError}(${T})`):(D.assign((0,t._)`${x}.errors`,T),D.return(!1))}const p={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function d(b,T,D){const{createErrors:x}=b.it;return x===!1?(0,t._)`{}`:h(b,T,D)}function h(b,T,D={}){const{gen:x,it:E}=b,A=[m(E,D),y(b,D)];return v(b,T,A),x.object(...A)}function m({errorPath:b},{instancePath:T}){const D=T?(0,t.str)`${b}${(0,r.getErrorPath)(T,r.Type.Str)}`:b;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,D)]}function y({keyword:b,it:{errSchemaPath:T}},{schemaPath:D,parentSchema:x}){let E=x?T:(0,t.str)`${T}/${b}`;return D&&(E=(0,t.str)`${E}${(0,r.getErrorPath)(D,r.Type.Str)}`),[p.schemaPath,E]}function v(b,{params:T,message:D},x){const{keyword:E,data:A,schemaValue:F,it:k}=b,{opts:_,propertyName:O,topSchemaRef:q,schemaPath:j}=k;x.push([p.keyword,E],[p.params,typeof T=="function"?T(b):T||(0,t._)`{}`]),_.messages&&x.push([p.message,typeof D=="function"?D(b):D]),_.verbose&&x.push([p.schema,F],[p.parentSchema,(0,t._)`${q}${j}`],[n.default.data,A]),O&&x.push([p.propertyName,O])}})($S)),$S}var JS;function Fq(){if(JS)return Gu;JS=1,Object.defineProperty(Gu,"__esModule",{value:!0}),Gu.boolOrEmptySchema=Gu.topBoolOrEmptySchema=void 0;const e=L2(),t=Dr(),r=mu(),n={message:"boolean schema is false"};function s(u){const{gen:o,schema:c,validateName:p}=u;c===!1?a(u,!1):typeof c=="object"&&c.$async===!0?o.return(r.default.data):(o.assign((0,t._)`${p}.errors`,null),o.return(!0))}Gu.topBoolOrEmptySchema=s;function i(u,o){const{gen:c,schema:p}=u;p===!1?(c.var(o,!1),a(u)):c.var(o,!0)}Gu.boolOrEmptySchema=i;function a(u,o){const{gen:c,data:p}=u,d={gen:c,keyword:"false schema",data:p,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:u};(0,e.reportError)(d,n,void 0,o)}return Gu}var Ln={},Xu={},KS;function W_(){if(KS)return Xu;KS=1,Object.defineProperty(Xu,"__esModule",{value:!0}),Xu.getRules=Xu.isJSONType=void 0;const e=["string","number","integer","boolean","null","object","array"],t=new Set(e);function r(s){return typeof s=="string"&&t.has(s)}Xu.isJSONType=r;function n(){const s={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...s,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},s.number,s.string,s.array,s.object],post:{rules:[]},all:{},keywords:{}}}return Xu.getRules=n,Xu}var za={},VS;function H_(){if(VS)return za;VS=1,Object.defineProperty(za,"__esModule",{value:!0}),za.shouldUseRule=za.shouldUseGroup=za.schemaHasRulesForType=void 0;function e({schema:n,self:s},i){const a=s.RULES.types[i];return a&&a!==!0&&t(n,a)}za.schemaHasRulesForType=e;function t(n,s){return s.rules.some(i=>r(n,i))}za.shouldUseGroup=t;function r(n,s){var i;return n[s.keyword]!==void 0||((i=s.definition.implements)===null||i===void 0?void 0:i.some(a=>n[a]!==void 0))}return za.shouldUseRule=r,za}var WS;function Jg(){if(WS)return Ln;WS=1,Object.defineProperty(Ln,"__esModule",{value:!0}),Ln.reportTypeError=Ln.checkDataTypes=Ln.checkDataType=Ln.coerceAndCheckDataType=Ln.getJSONTypes=Ln.getSchemaTypes=Ln.DataType=void 0;const e=W_(),t=H_(),r=L2(),n=Dr(),s=wr();var i;(function(D){D[D.Correct=0]="Correct",D[D.Wrong=1]="Wrong"})(i||(Ln.DataType=i={}));function a(D){const x=u(D.type);if(x.includes("null")){if(D.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!x.length&&D.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');D.nullable===!0&&x.push("null")}return x}Ln.getSchemaTypes=a;function u(D){const x=Array.isArray(D)?D:D?[D]:[];if(x.every(e.isJSONType))return x;throw new Error("type must be JSONType or JSONType[]: "+x.join(","))}Ln.getJSONTypes=u;function o(D,x){const{gen:E,data:A,opts:F}=D,k=p(x,F.coerceTypes),_=x.length>0&&!(k.length===0&&x.length===1&&(0,t.schemaHasRulesForType)(D,x[0]));if(_){const O=y(x,A,F.strictNumbers,i.Wrong);E.if(O,()=>{k.length?d(D,x,k):b(D)})}return _}Ln.coerceAndCheckDataType=o;const c=new Set(["string","number","integer","boolean","null"]);function p(D,x){return x?D.filter(E=>c.has(E)||x==="array"&&E==="array"):[]}function d(D,x,E){const{gen:A,data:F,opts:k}=D,_=A.let("dataType",(0,n._)`typeof ${F}`),O=A.let("coerced",(0,n._)`undefined`);k.coerceTypes==="array"&&A.if((0,n._)`${_} == 'object' && Array.isArray(${F}) && ${F}.length == 1`,()=>A.assign(F,(0,n._)`${F}[0]`).assign(_,(0,n._)`typeof ${F}`).if(y(x,F,k.strictNumbers),()=>A.assign(O,F))),A.if((0,n._)`${O} !== undefined`);for(const j of E)(c.has(j)||j==="array"&&k.coerceTypes==="array")&&q(j);A.else(),b(D),A.endIf(),A.if((0,n._)`${O} !== undefined`,()=>{A.assign(F,O),h(D,O)});function q(j){switch(j){case"string":A.elseIf((0,n._)`${_} == "number" || ${_} == "boolean"`).assign(O,(0,n._)`"" + ${F}`).elseIf((0,n._)`${F} === null`).assign(O,(0,n._)`""`);return;case"number":A.elseIf((0,n._)`${_} == "boolean" || ${F} === null
|
|
4
4
|
|| (${_} == "string" && ${F} && ${F} == +${F})`).assign(O,(0,n._)`+${F}`);return;case"integer":A.elseIf((0,n._)`${_} === "boolean" || ${F} === null
|
|
5
5
|
|| (${_} === "string" && ${F} && ${F} == +${F} && !(${F} % 1))`).assign(O,(0,n._)`+${F}`);return;case"boolean":A.elseIf((0,n._)`${F} === "false" || ${F} === 0 || ${F} === null`).assign(O,!1).elseIf((0,n._)`${F} === "true" || ${F} === 1`).assign(O,!0);return;case"null":A.elseIf((0,n._)`${F} === "" || ${F} === 0 || ${F} === false`),A.assign(O,null);return;case"array":A.elseIf((0,n._)`${_} === "string" || ${_} === "number"
|
|
@@ -1125,13 +1125,13 @@ export default function ${t}() {
|
|
|
1125
1125
|
}
|
|
1126
1126
|
`}const $s="sample",r2e="builtin-simple-form",n2e="builtin-wizard-form",gv=[{path:"index.tsx",label:"Компонент-страница (index.tsx) — рендерит форму",render:()=>rK($s)},{path:"registry.ts",label:"Реестр компонентов (registry.ts)",render:()=>tK($s)},{path:"model.ts",label:"Модель (model.ts)",render:()=>p5($s)},{path:"renderer.schema.json",label:"Схема формы (renderer.schema.json)",render:()=>c5()},{path:"validation.ts",label:"Схема валидации (validation.ts)",render:()=>d5($s)},{path:"form.behavior.ts",label:"Поведение формы (form.behavior.ts)",render:()=>f5($s)},{path:"renderer.behavior.ts",label:"Поведение UI (renderer.behavior.ts)",render:()=>h5($s)}],Dv=[{path:"index.tsx",label:"Компонент-страница (index.tsx) — рендерит визард",render:()=>t2e($s)},{path:"wizard.tsx",label:"Адаптер визарда (wizard.tsx) — шаги схемы → ui-kit FormWizard",render:()=>Xge($s)},{path:"registry.ts",label:"Реестр компонентов (registry.ts)",render:()=>Yge($s)},{path:"model.ts",label:"Модель (model.ts) — поля всех шагов",render:()=>Gge($s)},{path:"renderer.schema.json",label:"Схема формы (renderer.schema.json) — визард с двумя шагами",render:()=>Hge()},{path:"validation.ts",label:"Схема валидации (validation.ts)",render:()=>Qge($s)},{path:"form.behavior.ts",label:"Поведение формы (form.behavior.ts)",render:()=>Zge($s)},{path:"renderer.behavior.ts",label:"Поведение UI (renderer.behavior.ts) — submit визарда",render:()=>e2e($s)}];function QB(e){return e.map(t=>({path:t.path,content:GE(t.render(),$s)}))}function ZB(e){return Object.fromEntries(e.map(t=>[t.path,t.label]))}function ej(e){return{"index.tsx":e.filter(t=>t.path!=="index.tsx").map(t=>t.path)}}function s2e(){return{id:r2e,name:"Простая форма",description:"Одна страница: модель, схема, валидация, поведение, реестр, страница.",source:"builtin",files:QB(gv),requires:ej(gv),labels:ZB(gv)}}function i2e(){return{id:n2e,name:"Пошаговая форма",description:"Визард: два шага, общая модель, валидация и submit на последнем шаге.",source:"builtin",files:QB(Dv),requires:ej(Dv),labels:ZB(Dv)}}function tj(){return[s2e(),i2e()]}const a2e=".reformer/templates";function Op(){const e=Ca().project?.templatesDir?.trim();return e?e.replace(/^\/+|\/+$/g,""):a2e}function o2e(e){try{const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}async function u2e(e,t){const r=`${Op()}/${t}`,n=await o5(e,r);if(!n.length)return null;let s={};n.includes(Dh)&&(s=o2e(await qv(e,`${r}/${Dh}`)));const i=[];for(const a of n)a===Dh||!WB(a)||i.push({path:a,content:await qv(e,`${r}/${a}`)});return i.length?{id:t,name:s.name?.trim()||t,description:s.description,source:"project",files:i,requires:s.requires,createdAt:s.createdAt}:null}async function l2e(e){const t=await HJ(e,Op()),r=[];for(const n of t)try{const s=await u2e(e,n);s&&r.push(s)}catch(s){console.warn("[reformer-builder] шаблон не прочитан:",n,s)}return r}async function c2e(e,t,r){const n=await q2(e,Op(),t.id),s=`${Op()}/${n}`,i={version:zB,name:t.name,description:t.description,baseName:r,createdAt:t.createdAt,requires:t.requires};await Vg(e,s,Dh,JSON.stringify(i,null,2)+`
|
|
1127
1127
|
`);for(const a of t.files)await Vg(e,s,a.path,a.content);return{...t,id:n,source:"project"}}async function p2e(e,t){const r=`${Op()}/${t.id}`,n={version:zB,name:t.name,description:t.description,createdAt:t.createdAt,requires:t.requires};await Vg(e,r,Dh,JSON.stringify(n,null,2)+`
|
|
1128
|
-
`)}async function d2e(e,t){await u5(e,`${Op()}/${t}`)}async function rj(){try{return(await yo(vp,"readonly",t=>t.getAll())).map(t=>({...t,source:"local"}))}catch(e){return console.warn("[reformer-builder] локальные шаблоны недоступны:",e),[]}}async function f2e(e){const t=new Set((await rj()).map(s=>s.id));let r=e.id;for(let s=2;t.has(r);s++)r=`${e.id}-${s}`;const n={...e,id:r,source:"local"};return await yo(vp,"readwrite",s=>s.put(n,r)),n}async function h2e(e){await yo(vp,"readwrite",t=>t.put(e,e.id))}async function m2e(e){await yo(vp,"readwrite",t=>t.delete(e))}const y2e={items:tj(),loading:!1,error:null},yp=Bl(y2e),bk=(e,t)=>e.name.localeCompare(t.name);async function Lp(){yp.setState(t=>({...t,loading:!0}));const e=kn.getState().dirHandle;try{const[t,r]=await Promise.all([rj(),e?l2e(e):Promise.resolve([])]);yp.setState({items:[...tj(),...r.sort(bk),...t.sort(bk)],loading:!1,error:null})}catch(t){yp.setState(r=>({...r,loading:!1,error:t instanceof Error?t.message:String(t)}))}}function Bg(e){return se.useSyncExternalStore(yp.subscribe,()=>e(yp.getState()),()=>e(yp.getState()))}const $n=e=>e instanceof Error?e.message:String(e),g2e=e=>e instanceof DOMException&&e.name==="AbortError";async function nj(e){io.set({dirHandle:e,dirName:e.name,scanning:!0,error:null,tree:[],loadedDirs:new Set,loadingDirs:new Set});try{const[t,r]=await Promise.all([nC(e),KJ(e)]),n=Sae(r);io.set({tree:t,loadedDirs:new Set([""]),printer:n,scanning:!1,canReopen:!0,error:null}),Lp();const s=cK(t).length;console.debug("[reformer-builder] scan",e.name,"→ записей в корне:",t.length,"схем:",s),n.notice&&wt(n.notice),wt(s>0?`Открыт проект «${e.name}»: в корне ${t.length} записей, схем: ${s}`:`Открыт проект «${e.name}»: в корне ${t.length} записей`)}catch(t){console.error("[reformer-builder] scan failed:",t),io.set({scanning:!1,error:$n(t)}),wt("Ошибка сканирования: "+$n(t))}}function vk(e,t){const r=new Set(e);return r.delete(t),r}async function D2e(e){const t=kn.getState();if(t.loadedDirs.has(e)||t.loadingDirs.has(e))return;const r=t.tree.find(s=>s.path===e&&s.kind==="directory"),n=r?.dirHandle;if(!(!r||!n)){io.set({loadingDirs:new Set(t.loadingDirs).add(e)});try{const s=await nC(n,`${e}/`,r.depth+1),i=kn.getState();io.set({tree:dK(i.tree,e,s),loadedDirs:new Set(i.loadedDirs).add(e),loadingDirs:vk(i.loadingDirs,e)})}catch(s){console.error("[reformer-builder] loadDirectory failed:",e,s),io.set({loadingDirs:vk(kn.getState().loadingDirs,e)}),wt("Не удалось прочитать каталог: "+$n(s))}}}async function x2e(){if(console.debug("[reformer-builder] openProject, FS Access поддержка =",zv()),!zv()){wt("Нужен Chromium (File System Access API)");return}let e;try{console.debug("[reformer-builder] вызываю showDirectoryPicker…"),e=await zJ(),console.debug("[reformer-builder] выбран каталог:",e.name)}catch(t){if(console.warn("[reformer-builder] pickDirectory прервано/ошибка:",t),g2e(t))return;wt("Не удалось открыть проект: "+$n(t));return}await nj(e),VJ(e).catch(t=>{console.warn("[reformer-builder] persist handle failed:",t)})}async function b2e(){const e=await i5();if(!e)return;if(!await qJ(e)){wt("Доступ к каталогу не подтверждён");return}await nj(e)}async function v2e(){const e=await i5();io.setCanReopen(e!=null)}async function sj(e,t){if(!e.handle)return;const r=e.handle;try{const{text:n,lastModified:s}=await z2(r),i=JSON.parse(n),a=l_(i);Xe.openTab(e.path,{kind:"file",name:e.name,path:e.path,handle:r,rawText:n,lastModified:s},a,t),a!==i&&wt("Схема обновлена под новый формат: текст узлов переехал в children. Сохраните файл.")}catch(n){wt("Не удалось открыть схему: "+$n(n))}}function E2e(e){const t=e.slice(e.lastIndexOf(".")+1).toLowerCase();return{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",css:"css",scss:"scss",less:"less",html:"html",htm:"html",xml:"xml",svg:"xml",md:"markdown",mdx:"markdown",yml:"yaml",yaml:"yaml",sh:"shell",bash:"shell",py:"python",sql:"sql",toml:"ini",ini:"ini"}[t]??"plaintext"}async function _A(e,t){if(!e.handle)return;const r=e.handle;try{const{text:n,lastModified:s}=await z2(r),i=E2e(e.name);Xe.openCodeTab(e.path,{kind:"file",name:e.name,path:e.path,handle:r,rawText:n,lastModified:s},n,i,i==="markdown"?{...t,mdView:Iae()}:t)}catch(n){wt("Не удалось открыть файл: "+$n(n))}}async function PA(e,t){if(!t?.preview&&mt.getState().tabs[e.path]){Xe.pinTab(e.path);return}e.isForm?await sj(e,t):await _A(e,t)}async function Ek(e,t){await PA(e),mt.getState().tabs[e.path]&&(Xe.setActiveTab(e.path),sd(e.path,t))}async function Uve(e){const t=kn.getState().tree.find(n=>n.path===e&&n.kind==="file");if(t){await PA(t),Xe.setActiveTab(e);return}const r=kn.getState().dirHandle;if(!r){wt("Каталог проекта не открыт");return}try{const n=await XJ(r,e),s=e.slice(e.lastIndexOf("/")+1);await _A({path:e,name:s,kind:"file",depth:0,handle:n})}catch{wt(`Файла нет в проекте: ${e}`)}}async function C2e(e){if(e.source.kind!=="file"||!e.source.handle||e.text==null){wt("Файл нельзя сохранить (нет доступа к файлу)");return}try{await n5(e.source.handle,e.text),Xe.markCodeSaved(),wt("Файл сохранён")}catch(t){wt("Ошибка сохранения: "+$n(t))}}function hd(){return kn.getState().dirHandle}async function ka(){const{dirHandle:e,loadedDirs:t}=kn.getState();if(e)try{const r=await pK(e,t);io.set({tree:r,error:null})}catch(r){console.error("[reformer-builder] rescan failed:",r),io.set({error:$n(r)}),wt("Ошибка обновления дерева: "+$n(r))}}async function NA(e,t,r,n){const s={path:e,name:t,kind:"file",depth:0,handle:r};n?await sj(s):await _A(s)}async function T2e(e,t){const r=hd();if(!r){wt("Проект не открыт");return}try{const n=await rC(r,e,t,"");await ka(),await NA(Cp(e,t),t,n,!1)}catch(n){wt("Не удалось создать файл: "+$n(n))}}function Ck(e){e.length&&(Oge.copy(e),wt(e.length===1?`Скопировано: ${e[0]}`:`Скопировано записей: ${e.length}`))}async function Tk(e){const t=hd();if(!t){wt("Проект не открыт");return}const r=mp.getState().paths;if(!r.length)return;let n=0;for(const s of r)try{await QJ(t,s,e),n++}catch(i){console.error("[reformer-builder] paste failed:",s,i),wt(`Не удалось вставить «${s}»: `+$n(i))}n&&(await ka(),wt(n===1?"Вставлено":`Вставлено записей: ${n}`))}async function A2e(e,t){const r=hd();if(!r){wt("Проект не открыт");return}try{await a5(r,e,t),await ka()}catch(n){wt("Не удалось создать папку: "+$n(n))}}async function S2e(e){const t=hd();if(!t){wt("Проект не открыт");return}try{await u5(t,e),await ka(),wt("Удалено")}catch(r){wt("Не удалось удалить: "+$n(r))}}async function F2e(e,t,r){const n=hd();if(!n){wt("Проект не открыт");return}try{await ZJ(n,e,t,r),await ka()}catch(s){wt("Не удалось переименовать: "+$n(s))}}function SD(e){return e.split("/").filter(Boolean).pop()??"форма"}function w2e(e,t){const r=e.replace(/\.json$/i,"").replace(/(^|\.)(renderer\.schema|form)$/i,"");return r||((t?Da(t).dirPath:"").split("/").filter(Boolean).pop()??"form")}async function ym(e,t,r,n){const s=hd();if(!s){wt("Проект не открыт");return}try{const i=await q2(s,e,t),a=await rC(s,e,i,r);await ka(),await NA(Cp(e,i),i,a,n)}catch(i){wt("Не удалось сгенерировать: "+$n(i))}}function k2e(e){return ym(e,"model.ts",p5(SD(e)),!1)}function _2e(e){return ym(e,"renderer.schema.json",c5(),!0)}function P2e(e){return ym(e,"validation.ts",d5(SD(e)),!1)}function N2e(e){return ym(e,"form.behavior.ts",f5(SD(e)),!1)}function $2e(e){return ym(e,"renderer.behavior.ts",h5(SD(e)),!1)}async function $A(e){const t=r5(e.schema);if(!t.valid){RB(t.errors,e.schema);return}if(e.source.kind==="file"&&e.source.handle)try{const r=kn.getState().printer?.options??{},n=await kae(e,r);Ga.open(n)}catch(r){wt("Ошибка подготовки сохранения: "+$n(r))}else Pae(e.schema,e.source.name),Xe.markSaved(),wt("Схема экспортирована")}async function I2e(e){if(!e.handle){Ga.close();return}Ga.setSaving(!0);try{const t=await _ae(e.handle,e.newText);Xe.commitSaved(e.newText,t),Ga.close(),wt("Сохранено в файл")}catch(t){Ga.setSaving(!1),wt("Ошибка записи: "+$n(t))}}async function B2e(e){if(e.kind==="code"){wt("Экспорт примера доступен только для формы");return}if(!kge()){wt("Экспорт примера требует Chromium-браузера (File System Access API)");return}const t=w2e(e.source.name,e.source.path),r=Bh(e.schema,e.mock);try{const n=await _ge(e.schema,r,t);try{await navigator.clipboard.writeText(n.snippet)}catch{}const s=n.skipped.length?`, пропущено ${n.skipped.length} (ваши файлы)`:"";wt(`Пример «${n.dir}»: записано ${n.written.length} файлов${s}. Сниппет для App.tsx — в буфере и README.md.`)}catch(n){if(n.name==="AbortError")return;wt("Не удалось создать пример: "+$n(n))}}const ij={status:"off",bundle:null,errors:[],applied:[],files:[],fromEditor:[]};let XE=ij;const YE=new Set;function Yf(e){if(XE!==e){XE=e;for(const t of YE)t()}}function j2e(){Yf(ij)}function md(){return XE}function yd(e){return YE.add(e),()=>YE.delete(e)}const O2e=400;function Ak(e){if(!e)return"";const t=Da(e).dirPath,r=[];for(const n of Object.values(mt.getState().tabs)){const s=n.source.path;n.kind!=="code"||typeof n.text!="string"||!s||Da(s).dirPath===t&&r.push(`${s}:${n.text.length}:${L2e(n.text)}`)}return r.sort().join("|")}function L2e(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0}function M2e({tab:e,annotated:t,dataSources:r,modelOverride:n,enabled:s}){const[i,a]=se.useState(null),[u,o]=se.useState(0),c=e.source.kind==="file"?e.source.path:void 0,[p,d]=se.useState(()=>Ak(c)),h=se.useRef(null);return se.useEffect(()=>{if(!s||!c)return;let m=0;const y=mt.subscribe(()=>{const v=Ak(c);window.clearTimeout(m),m=window.setTimeout(()=>d(b=>b===v?b:v),O2e)});return()=>{window.clearTimeout(m),y()}},[s,c]),se.useEffect(()=>{if(!s||!c){a(null),Yf({status:s?"unavailable":"off",bundle:null,errors:[],applied:[],files:[],fromEditor:[]});return}let m=!1;return Yf({status:"loading",bundle:null,errors:[],applied:[],files:[],fromEditor:[]}),(async()=>{try{const y=await Pl(()=>import("./index-BC3M-FCZ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])),v=await y.readFormSources(c),b=await y.compileForm(v);if(m)return;const T=y.buildLivePreview({schema:t,compiled:b,dataSources:r,modelOverride:n});h.current=T.validation?.start()??null,a(T),Yf({status:"ready",bundle:T,errors:T.errors,applied:T.applied,files:Object.keys(v.files),fromEditor:v.fromEditor})}catch(y){if(m)return;a(null),Yf({status:"error",bundle:null,errors:[{file:"",phase:"evaluate",message:y instanceof Error?y.message:String(y)}],applied:[],files:[],fromEditor:[]})}})(),()=>{m=!0,h.current?.(),h.current=null}},[s,c,t,r,n,p,u]),se.useEffect(()=>j2e,[]),se.useEffect(()=>(QE=()=>o(m=>m+1),()=>{QE=null}),[]),i}let QE=null;function R2e(){QE?.()}let Sk=!1;function U2e({tab:e}){const t=vi(),r=se.useSyncExternalStore(yd,md),n=e?.source.kind==="file"&&!!e.source.path,s=()=>{if(t.liveSchemas){Xe.setLiveSchemas(!1);return}!Sk&&!window.confirm(`Выполнить TS-код из папки формы?
|
|
1128
|
+
`)}async function d2e(e,t){await u5(e,`${Op()}/${t}`)}async function rj(){try{return(await yo(vp,"readonly",t=>t.getAll())).map(t=>({...t,source:"local"}))}catch(e){return console.warn("[reformer-builder] локальные шаблоны недоступны:",e),[]}}async function f2e(e){const t=new Set((await rj()).map(s=>s.id));let r=e.id;for(let s=2;t.has(r);s++)r=`${e.id}-${s}`;const n={...e,id:r,source:"local"};return await yo(vp,"readwrite",s=>s.put(n,r)),n}async function h2e(e){await yo(vp,"readwrite",t=>t.put(e,e.id))}async function m2e(e){await yo(vp,"readwrite",t=>t.delete(e))}const y2e={items:tj(),loading:!1,error:null},yp=Bl(y2e),bk=(e,t)=>e.name.localeCompare(t.name);async function Lp(){yp.setState(t=>({...t,loading:!0}));const e=kn.getState().dirHandle;try{const[t,r]=await Promise.all([rj(),e?l2e(e):Promise.resolve([])]);yp.setState({items:[...tj(),...r.sort(bk),...t.sort(bk)],loading:!1,error:null})}catch(t){yp.setState(r=>({...r,loading:!1,error:t instanceof Error?t.message:String(t)}))}}function Bg(e){return se.useSyncExternalStore(yp.subscribe,()=>e(yp.getState()),()=>e(yp.getState()))}const $n=e=>e instanceof Error?e.message:String(e),g2e=e=>e instanceof DOMException&&e.name==="AbortError";async function nj(e){io.set({dirHandle:e,dirName:e.name,scanning:!0,error:null,tree:[],loadedDirs:new Set,loadingDirs:new Set});try{const[t,r]=await Promise.all([nC(e),KJ(e)]),n=Sae(r);io.set({tree:t,loadedDirs:new Set([""]),printer:n,scanning:!1,canReopen:!0,error:null}),Lp();const s=cK(t).length;console.debug("[reformer-builder] scan",e.name,"→ записей в корне:",t.length,"схем:",s),n.notice&&wt(n.notice),wt(s>0?`Открыт проект «${e.name}»: в корне ${t.length} записей, схем: ${s}`:`Открыт проект «${e.name}»: в корне ${t.length} записей`)}catch(t){console.error("[reformer-builder] scan failed:",t),io.set({scanning:!1,error:$n(t)}),wt("Ошибка сканирования: "+$n(t))}}function vk(e,t){const r=new Set(e);return r.delete(t),r}async function D2e(e){const t=kn.getState();if(t.loadedDirs.has(e)||t.loadingDirs.has(e))return;const r=t.tree.find(s=>s.path===e&&s.kind==="directory"),n=r?.dirHandle;if(!(!r||!n)){io.set({loadingDirs:new Set(t.loadingDirs).add(e)});try{const s=await nC(n,`${e}/`,r.depth+1),i=kn.getState();io.set({tree:dK(i.tree,e,s),loadedDirs:new Set(i.loadedDirs).add(e),loadingDirs:vk(i.loadingDirs,e)})}catch(s){console.error("[reformer-builder] loadDirectory failed:",e,s),io.set({loadingDirs:vk(kn.getState().loadingDirs,e)}),wt("Не удалось прочитать каталог: "+$n(s))}}}async function x2e(){if(console.debug("[reformer-builder] openProject, FS Access поддержка =",zv()),!zv()){wt("Нужен Chromium (File System Access API)");return}let e;try{console.debug("[reformer-builder] вызываю showDirectoryPicker…"),e=await zJ(),console.debug("[reformer-builder] выбран каталог:",e.name)}catch(t){if(console.warn("[reformer-builder] pickDirectory прервано/ошибка:",t),g2e(t))return;wt("Не удалось открыть проект: "+$n(t));return}await nj(e),VJ(e).catch(t=>{console.warn("[reformer-builder] persist handle failed:",t)})}async function b2e(){const e=await i5();if(!e)return;if(!await qJ(e)){wt("Доступ к каталогу не подтверждён");return}await nj(e)}async function v2e(){const e=await i5();io.setCanReopen(e!=null)}async function sj(e,t){if(!e.handle)return;const r=e.handle;try{const{text:n,lastModified:s}=await z2(r),i=JSON.parse(n),a=l_(i);Xe.openTab(e.path,{kind:"file",name:e.name,path:e.path,handle:r,rawText:n,lastModified:s},a,t),a!==i&&wt("Схема обновлена под новый формат: текст узлов переехал в children. Сохраните файл.")}catch(n){wt("Не удалось открыть схему: "+$n(n))}}function E2e(e){const t=e.slice(e.lastIndexOf(".")+1).toLowerCase();return{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",css:"css",scss:"scss",less:"less",html:"html",htm:"html",xml:"xml",svg:"xml",md:"markdown",mdx:"markdown",yml:"yaml",yaml:"yaml",sh:"shell",bash:"shell",py:"python",sql:"sql",toml:"ini",ini:"ini"}[t]??"plaintext"}async function _A(e,t){if(!e.handle)return;const r=e.handle;try{const{text:n,lastModified:s}=await z2(r),i=E2e(e.name);Xe.openCodeTab(e.path,{kind:"file",name:e.name,path:e.path,handle:r,rawText:n,lastModified:s},n,i,i==="markdown"?{...t,mdView:Iae()}:t)}catch(n){wt("Не удалось открыть файл: "+$n(n))}}async function PA(e,t){if(!t?.preview&&mt.getState().tabs[e.path]){Xe.pinTab(e.path);return}e.isForm?await sj(e,t):await _A(e,t)}async function Ek(e,t){await PA(e),mt.getState().tabs[e.path]&&(Xe.setActiveTab(e.path),sd(e.path,t))}async function Uve(e){const t=kn.getState().tree.find(n=>n.path===e&&n.kind==="file");if(t){await PA(t),Xe.setActiveTab(e);return}const r=kn.getState().dirHandle;if(!r){wt("Каталог проекта не открыт");return}try{const n=await XJ(r,e),s=e.slice(e.lastIndexOf("/")+1);await _A({path:e,name:s,kind:"file",depth:0,handle:n})}catch{wt(`Файла нет в проекте: ${e}`)}}async function C2e(e){if(e.source.kind!=="file"||!e.source.handle||e.text==null){wt("Файл нельзя сохранить (нет доступа к файлу)");return}try{await n5(e.source.handle,e.text),Xe.markCodeSaved(),wt("Файл сохранён")}catch(t){wt("Ошибка сохранения: "+$n(t))}}function hd(){return kn.getState().dirHandle}async function ka(){const{dirHandle:e,loadedDirs:t}=kn.getState();if(e)try{const r=await pK(e,t);io.set({tree:r,error:null})}catch(r){console.error("[reformer-builder] rescan failed:",r),io.set({error:$n(r)}),wt("Ошибка обновления дерева: "+$n(r))}}async function NA(e,t,r,n){const s={path:e,name:t,kind:"file",depth:0,handle:r};n?await sj(s):await _A(s)}async function T2e(e,t){const r=hd();if(!r){wt("Проект не открыт");return}try{const n=await rC(r,e,t,"");await ka(),await NA(Cp(e,t),t,n,!1)}catch(n){wt("Не удалось создать файл: "+$n(n))}}function Ck(e){e.length&&(Oge.copy(e),wt(e.length===1?`Скопировано: ${e[0]}`:`Скопировано записей: ${e.length}`))}async function Tk(e){const t=hd();if(!t){wt("Проект не открыт");return}const r=mp.getState().paths;if(!r.length)return;let n=0;for(const s of r)try{await QJ(t,s,e),n++}catch(i){console.error("[reformer-builder] paste failed:",s,i),wt(`Не удалось вставить «${s}»: `+$n(i))}n&&(await ka(),wt(n===1?"Вставлено":`Вставлено записей: ${n}`))}async function A2e(e,t){const r=hd();if(!r){wt("Проект не открыт");return}try{await a5(r,e,t),await ka()}catch(n){wt("Не удалось создать папку: "+$n(n))}}async function S2e(e){const t=hd();if(!t){wt("Проект не открыт");return}try{await u5(t,e),await ka(),wt("Удалено")}catch(r){wt("Не удалось удалить: "+$n(r))}}async function F2e(e,t,r){const n=hd();if(!n){wt("Проект не открыт");return}try{await ZJ(n,e,t,r),await ka()}catch(s){wt("Не удалось переименовать: "+$n(s))}}function SD(e){return e.split("/").filter(Boolean).pop()??"форма"}function w2e(e,t){const r=e.replace(/\.json$/i,"").replace(/(^|\.)(renderer\.schema|form)$/i,"");return r||((t?Da(t).dirPath:"").split("/").filter(Boolean).pop()??"form")}async function ym(e,t,r,n){const s=hd();if(!s){wt("Проект не открыт");return}try{const i=await q2(s,e,t),a=await rC(s,e,i,r);await ka(),await NA(Cp(e,i),i,a,n)}catch(i){wt("Не удалось сгенерировать: "+$n(i))}}function k2e(e){return ym(e,"model.ts",p5(SD(e)),!1)}function _2e(e){return ym(e,"renderer.schema.json",c5(),!0)}function P2e(e){return ym(e,"validation.ts",d5(SD(e)),!1)}function N2e(e){return ym(e,"form.behavior.ts",f5(SD(e)),!1)}function $2e(e){return ym(e,"renderer.behavior.ts",h5(SD(e)),!1)}async function $A(e){const t=r5(e.schema);if(!t.valid){RB(t.errors,e.schema);return}if(e.source.kind==="file"&&e.source.handle)try{const r=kn.getState().printer?.options??{},n=await kae(e,r);Ga.open(n)}catch(r){wt("Ошибка подготовки сохранения: "+$n(r))}else Pae(e.schema,e.source.name),Xe.markSaved(),wt("Схема экспортирована")}async function I2e(e){if(!e.handle){Ga.close();return}Ga.setSaving(!0);try{const t=await _ae(e.handle,e.newText);Xe.commitSaved(e.newText,t),Ga.close(),wt("Сохранено в файл")}catch(t){Ga.setSaving(!1),wt("Ошибка записи: "+$n(t))}}async function B2e(e){if(e.kind==="code"){wt("Экспорт примера доступен только для формы");return}if(!kge()){wt("Экспорт примера требует Chromium-браузера (File System Access API)");return}const t=w2e(e.source.name,e.source.path),r=Bh(e.schema,e.mock);try{const n=await _ge(e.schema,r,t);try{await navigator.clipboard.writeText(n.snippet)}catch{}const s=n.skipped.length?`, пропущено ${n.skipped.length} (ваши файлы)`:"";wt(`Пример «${n.dir}»: записано ${n.written.length} файлов${s}. Сниппет для App.tsx — в буфере и README.md.`)}catch(n){if(n.name==="AbortError")return;wt("Не удалось создать пример: "+$n(n))}}const ij={status:"off",bundle:null,errors:[],applied:[],files:[],fromEditor:[]};let XE=ij;const YE=new Set;function Yf(e){if(XE!==e){XE=e;for(const t of YE)t()}}function j2e(){Yf(ij)}function md(){return XE}function yd(e){return YE.add(e),()=>YE.delete(e)}const O2e=400;function Ak(e){if(!e)return"";const t=Da(e).dirPath,r=[];for(const n of Object.values(mt.getState().tabs)){const s=n.source.path;n.kind!=="code"||typeof n.text!="string"||!s||Da(s).dirPath===t&&r.push(`${s}:${n.text.length}:${L2e(n.text)}`)}return r.sort().join("|")}function L2e(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0}function M2e({tab:e,annotated:t,dataSources:r,modelOverride:n,enabled:s}){const[i,a]=se.useState(null),[u,o]=se.useState(0),c=e.source.kind==="file"?e.source.path:void 0,[p,d]=se.useState(()=>Ak(c)),h=se.useRef(null);return se.useEffect(()=>{if(!s||!c)return;let m=0;const y=mt.subscribe(()=>{const v=Ak(c);window.clearTimeout(m),m=window.setTimeout(()=>d(b=>b===v?b:v),O2e)});return()=>{window.clearTimeout(m),y()}},[s,c]),se.useEffect(()=>{if(!s||!c){a(null),Yf({status:s?"unavailable":"off",bundle:null,errors:[],applied:[],files:[],fromEditor:[]});return}let m=!1;return Yf({status:"loading",bundle:null,errors:[],applied:[],files:[],fromEditor:[]}),(async()=>{try{const y=await Pl(()=>import("./index-BwhW-Atz.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])),v=await y.readFormSources(c),b=await y.compileForm(v);if(m)return;const T=y.buildLivePreview({schema:t,compiled:b,dataSources:r,modelOverride:n});h.current=T.validation?.start()??null,a(T),Yf({status:"ready",bundle:T,errors:T.errors,applied:T.applied,files:Object.keys(v.files),fromEditor:v.fromEditor})}catch(y){if(m)return;a(null),Yf({status:"error",bundle:null,errors:[{file:"",phase:"evaluate",message:y instanceof Error?y.message:String(y)}],applied:[],files:[],fromEditor:[]})}})(),()=>{m=!0,h.current?.(),h.current=null}},[s,c,t,r,n,p,u]),se.useEffect(()=>j2e,[]),se.useEffect(()=>(QE=()=>o(m=>m+1),()=>{QE=null}),[]),i}let QE=null;function R2e(){QE?.()}let Sk=!1;function U2e({tab:e}){const t=vi(),r=se.useSyncExternalStore(yd,md),n=e?.source.kind==="file"&&!!e.source.path,s=()=>{if(t.liveSchemas){Xe.setLiveSchemas(!1);return}!Sk&&!window.confirm(`Выполнить TS-код из папки формы?
|
|
1129
1129
|
|
|
1130
1130
|
validation.ts, form.behavior.ts, renderer.behavior.ts и registry.ts будут исполнены в этой вкладке браузера, чтобы форма в превью работала как в приложении.`)||(Sk=!0,Xe.setLiveSchemas(!0))},i=t.liveSchemas?r.status==="error"?-1:r.errors.length:0,a=i!==0,u=()=>n?t.liveSchemas?i===-1?"Схемы не собрались — подробности во вкладке «Форма» → Сборка":i>0?`Схемы исполняются, ${i} файл(ов) с ошибкой — вкладка «Форма» → Сборка`:"Схемы формы исполняются. Что подключилось — во вкладке «Форма»":"Исполнять схемы формы из каталога: валидация, поведение, реестр":"Доступно для формы, открытой из проекта: рядом со схемой должны лежать .ts";return S.jsxs("div",{className:"flex flex-none items-center gap-1",children:[S.jsxs("button",{onClick:n?s:void 0,disabled:!n,"aria-pressed":t.liveSchemas,title:u(),className:Xt("flex h-6 items-center gap-1 rounded-md border px-2 text-[11.5px]",!n&&"cursor-not-allowed opacity-50",!t.liveSchemas&&"border-border text-muted-foreground hover:bg-muted",t.liveSchemas&&!a&&"border-emerald-500/50 bg-emerald-500/10 text-emerald-700",t.liveSchemas&&a&&"border-destructive/50 bg-destructive/10 text-destructive"),children:[r.status==="loading"?S.jsx(m3,{className:"h-3.5 w-3.5 animate-spin"}):S.jsx(Kj,{className:"h-3.5 w-3.5"}),"Схемы формы"]}),t.liveSchemas&&S.jsx("button",{onClick:()=>{R2e(),wt.info("Схемы перечитаны")},title:"Перечитать .ts каталога и пересобрать форму",className:"grid h-6 w-6 flex-none place-items-center rounded-md border border-border text-muted-foreground hover:bg-muted",children:S.jsx(Vj,{className:"h-3.5 w-3.5"})})]})}function z2e(e=typeof navigator>"u"?void 0:navigator){const t=e?.userAgentData?.platform||e?.platform||e?.userAgent||"";return/mac|iphone|ipad|ipod/i.test(t)?"mac":"other"}const IA=z2e(),q2e={mod:"Mod",cmd:"Mod",command:"Mod",meta:"Mod",ctrl:"Ctrl",control:"Ctrl",alt:"Alt",opt:"Alt",option:"Alt",shift:"Shift"},J2e={Mod:["⌘","Ctrl"],Ctrl:["⌃","Ctrl"],Alt:["⌥","Alt"],Shift:["⇧","Shift"]},K2e={mac:["Ctrl","Alt","Shift","Mod"],other:["Mod","Ctrl","Alt","Shift"]},V2e={enter:["↵","Enter"],return:["↵","Enter"],backspace:["⌫","Backspace"],delete:"Delete",escape:"Esc",esc:"Esc",space:"Space",arrowup:"↑",arrowdown:"↓",arrowleft:"←",arrowright:"→",arrows:"↑↓←→"};function Fk(e,t){return typeof e=="string"?e:e[t==="mac"?0:1]}function aj(e,t=IA){const r=e.split("+").map(a=>a.trim()).filter(Boolean),n=new Set,s=[];for(const a of r){const u=q2e[a.toLowerCase()];u?n.add(u):s.push(a)}const i=[];for(const a of K2e[t]){if(!n.has(a))continue;const u=Fk(J2e[a],t);i.includes(u)||i.push(u)}for(const a of s){const u=V2e[a.toLowerCase()];i.push(u?Fk(u,t):a.length===1?a.toUpperCase():a)}return i}function gr(e,t=IA){return aj(e,t).join(t==="mac"?"":"+")}function wk(){const e=vi(),t=jl(),r=(t?.past.length??0)>0,n=(t?.future.length??0)>0,[s,i]=se.useState("idle"),[a,u]=se.useState([]),[o,c]=se.useState(!1),p=se.useRef(null),[d,h]=se.useState(t?.schema);t?.schema!==d&&(h(t?.schema),i("idle"),u([])),se.useEffect(()=>{if(!o)return;const y=v=>{p.current&&!p.current.contains(v.target)&&c(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[o]);const m=()=>{if(!t)return!1;const y=r5(t.schema);return i(y.valid?"ok":"error"),u(y.errors),y.valid?wt.success("Схема валидна"):RB(y.errors,t.schema),y.valid};return S.jsxs("div",{className:"absolute right-4 top-2 z-30 flex flex-wrap items-center justify-end gap-1.5",children:[e.preview==="runtime"&&S.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5 rounded-lg border border-border bg-background/95 p-1 shadow-sm backdrop-blur",children:[S.jsxs("div",{className:"flex flex-none gap-0.5 rounded-md border border-border bg-muted p-0.5",children:[S.jsx("button",{onClick:()=>Xe.setRuntimeMode("test"),title:`Тест: форма интерактивна, редактирование схемы выключено (${gr("Mod+Alt+E")})`,"aria-label":"Тест","aria-pressed":e.runtimeMode==="test",className:Xt("flex h-6 w-6 items-center justify-center rounded",e.runtimeMode==="test"?"bg-background shadow-sm":"text-muted-foreground"),children:S.jsx(D8,{className:"h-3.5 w-3.5"})}),S.jsx("button",{onClick:()=>Xe.setRuntimeMode("edit"),title:`Редактирование: клик выделяет узел, работают хоткеи и drag-drop (${gr("Mod+Alt+E")})`,"aria-label":"Редактирование","aria-pressed":e.runtimeMode==="edit",className:Xt("flex h-6 w-6 items-center justify-center rounded",e.runtimeMode==="edit"?"bg-background shadow-sm":"text-muted-foreground"),children:S.jsx(Wj,{className:"h-3.5 w-3.5"})})]}),S.jsx(U2e,{tab:t})]}),S.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5 rounded-lg border border-border bg-background/95 p-1 shadow-sm backdrop-blur",children:[S.jsxs("div",{className:"flex flex-none gap-0.5 rounded-md border border-border bg-muted p-0.5",children:[S.jsx("button",{onClick:()=>Xe.setPreview("wire"),title:`Схематичный (${gr("Mod+Alt+1")} · цикл ${gr("Mod+Alt+V")})`,className:Xt("h-6 rounded px-2 text-[11.5px]",e.preview==="wire"?"bg-background shadow-sm":"text-muted-foreground"),children:"Схематичный"}),S.jsx("button",{onClick:()=>Xe.setPreview("runtime"),title:`Renderer (${gr("Mod+Alt+2")} · цикл ${gr("Mod+Alt+V")})`,className:Xt("h-6 rounded px-2 text-[11.5px]",e.preview==="runtime"?"bg-background shadow-sm":"text-muted-foreground"),children:"Renderer"}),S.jsx("button",{onClick:()=>Xe.setPreview("code"),title:`Код (${gr("Mod+Alt+3")} · цикл ${gr("Mod+Alt+V")})`,className:Xt("h-6 rounded px-2 text-[11.5px]",e.preview==="code"?"bg-background shadow-sm":"text-muted-foreground"),children:"Код"})]}),S.jsxs("div",{ref:p,className:"relative flex-none",children:[S.jsx(Rr,{variant:"outline",size:"icon",className:"h-6 w-6",title:"Настройки вида",onClick:()=>c(y=>!y),children:S.jsx(i8,{className:"h-3.5 w-3.5"})}),o&&S.jsxs("div",{className:"absolute right-0 top-7 z-20 w-56 rounded-md border border-border bg-background p-1 text-foreground shadow-md",children:[S.jsx("div",{className:"px-2 py-1 text-[10px] font-semibold tracking-wide text-muted-foreground uppercase",children:"Вид схемы"}),S.jsxs("div",{className:"flex w-full items-center justify-between gap-2 rounded px-2 py-1.5 hover:bg-muted",children:[S.jsx(tu,{htmlFor:"hide-div-wrappers",className:"cursor-pointer text-[12px] font-normal",children:"Скрывать div-контейнеры"}),S.jsx(a8,{id:"hide-div-wrappers",checked:e.hideDivWrappers,onCheckedChange:()=>Xe.toggleHideDivWrappers(),className:"flex-none"})]})]})]}),S.jsx(Rr,{variant:"outline",size:"icon",className:"h-6 w-6",disabled:!r,onClick:Xe.undo,children:S.jsx(Hj,{className:"h-3.5 w-3.5"})}),S.jsx(Rr,{variant:"outline",size:"icon",className:"h-6 w-6",disabled:!n,onClick:Xe.redo,children:S.jsx(Gj,{className:"h-3.5 w-3.5"})}),S.jsx(Rr,{variant:"outline",size:"icon",title:a.length?a.join(`
|
|
1131
1131
|
`):"Проверить схему",className:Xt("h-6 w-6",s==="ok"&&"border-emerald-500/50 text-emerald-600",s==="error"&&"border-destructive/50 text-destructive"),onClick:m,children:s==="error"?S.jsx(w2,{className:"h-3.5 w-3.5"}):S.jsx(x8,{className:"h-3.5 w-3.5"})}),S.jsx(Rr,{size:"icon",className:"h-6 w-6",title:t?.source.kind==="file"?`Сохранить (${gr("Mod+S")})`:"Экспорт JSON",onClick:()=>t&&void $A(t),children:S.jsx(Xj,{className:"h-3.5 w-3.5"})})]})]})}let BA=null;function jA(e){BA=e}function ZE(){return BA}function OA(){BA=null}function W2e(e,t,r){const n=Kh(e,t);if(!n)return null;if(r==="into"){const a=Mi(n,t).find(u=>!u.single);return a?{slotPath:a.path,index:a.length}:null}if(t.length===0)return null;const s=t[t.length-1],i=typeof s=="number"?s:Number(s);return Number.isNaN(i)?null:{slotPath:t.slice(0,-1),index:r==="before"?i:i+1}}function H2e(e,t,r,n){if(r!=="before"&&r!=="after"&&r!=="into"){const i=r==="beside-before"||r==="stack-before"?"before":"after",a=r==="stack-before"||r==="stack-after";if(n.kind==="new"){const c=ll(n.entryName);return c?(a?cR:f_)(e,t,c.makeNode(),i):null}if(ml(n.path,t)||ml(t,n.path))return null;const u=Pn(n.path),o=Pn(t);if(u&&o&&Xs(u,o)){const c=Pr(e,u);if(c&&VM(c)){const p=c.children;if(Array.isArray(p)&&p.length===2)return hR(e,u,t,n.path,i)}}return(a?pR:h_)(e,t,n.path,i)}const s=W2e(e,t,r);if(!s)return null;if(n.kind==="new"){const i=ll(n.entryName);return i?Vh(e,s.slotPath,s.index,i.makeNode()):null}return ml(n.path,t)?null:z3(e,n.path,s.slotPath,s.index)}function e3(e,t,r){const n=ZE();if(OA(),!n)return;const s=H2e(e,t,r,n);s&&Xe.commit(s)}const oj=new Set(["beside-before","beside-after","stack-before","stack-after"]);function kk(e,t,r){return r>0?(e-t)/r:.5}function uj(e,t,r,n,s){const i=kk(e.x,t.left,t.width),a=kk(e.y,t.top,t.height),u=n==="horizontal",o=u?i:a,c=u?a:i;if(s){if(c<.25)return u?"stack-before":"beside-before";if(c>.75)return u?"stack-after":"beside-after"}return L3(r)?o<.28?"before":o>.72?"after":"into":o<.5?"before":"after"}function lj(e,t){switch(e){case"before":return t?"left":"top";case"after":return t?"right":"bottom";case"beside-before":return"left";case"beside-after":return"right";case"stack-before":return"top";case"stack-after":return"bottom";default:return null}}function FD(e){if(Jn(e))return"Array";const t=e.component,r=Mt(t);return r?.op==="component"||r?.op==="html"?r.arg:ni(e)?"Input":"Node"}function G2e(e){const t=e.componentProps;return t?.label!=null?String(t.label):t?.title!=null?String(t.title):ni(e)?Mt(e.value)?.arg??"поле":Jn(e)?Mt(e.array)?.arg??"массив":Mt(e.component)?.arg??"узел"}const cj=se.createContext({drop:null,setDrop:()=>{},schema:{root:{component:"$html(div)"}},hideDivWrappers:!1,selectionPaths:[]});function _k(e,t,r,n){const s=e.currentTarget.getBoundingClientRect();return uj({x:e.clientX,y:e.clientY},s,t,r,n)}const X2e={top:"-top-1 right-0 left-0 h-0.5",bottom:"right-0 -bottom-1 left-0 h-0.5",left:"top-0 bottom-0 -left-1 w-0.5",right:"top-0 bottom-0 -right-1 w-0.5"};function Y2e(e,t){const r=lj(e,t);return r?X2e[r]:null}function Q2e(e){switch(e){case"beside-before":return"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2";case"beside-after":return"top-1/2 right-0 translate-x-1/2 -translate-y-1/2";case"stack-before":return"left-1/2 top-0 -translate-x-1/2 -translate-y-1/2";case"stack-after":return"left-1/2 bottom-0 -translate-x-1/2 translate-y-1/2";default:return""}}function t3({node:e,path:t,selectionPath:r}){const{drop:n,setDrop:s,schema:i,hideDivWrappers:a,selectionPaths:u}=se.useContext(cj),o=t.length===1&&t[0]==="root",c=r!=null&&Xs(t,r),p=c||u.some(E=>Xs(E,t)),d=Mi(e,t),h=u_(e)==="field",m=Pn(t),y=m?Pr(i,m):void 0,v=y?Th(y):"vertical",b=!o&&t[t.length-2]==="children",T=Th(e)==="horizontal";if(a&&!o&&Lg(e)){const E=d.find(A=>A.kind==="children");return E?S.jsx("div",{className:Xt("flex gap-2",T?"flex-row items-start":"flex-col",v==="horizontal"&&"min-w-0 flex-1"),children:E.entries.map(A=>S.jsx(t3,{node:A.node,path:[...E.path,A.index],selectionPath:r},A.index))}):null}const D=n&&Xs(n.path,t)?n.zone:null,x=D!=null&&oj.has(D);return S.jsxs("div",{className:Xt("relative",v==="horizontal"&&"min-w-0 flex-1"),children:[D!=null&&D!=="into"&&S.jsx("div",{className:Xt("pointer-events-none absolute z-10 rounded bg-primary",Y2e(D,v==="horizontal"))}),x&&S.jsx("div",{className:Xt("pointer-events-none absolute z-20 flex items-center gap-0.5 rounded-full bg-primary px-1.5 py-px text-[9px] font-semibold whitespace-nowrap text-primary-foreground shadow-sm",Q2e(D)),children:D==="stack-before"||D==="stack-after"?S.jsxs(S.Fragment,{children:[S.jsx(HA,{className:"size-2.5"}),"столбец"]}):S.jsxs(S.Fragment,{children:[S.jsx(JA,{className:"size-2.5"}),"ряд"]})}),S.jsxs("div",{draggable:!o,onClick:E=>{E.stopPropagation(),E.shiftKey?Xe.extendSelectionTo(t):E.metaKey||E.ctrlKey?Xe.toggleSelectionAt(t):Xe.select(t)},onDoubleClick:E=>{E.stopPropagation(),Xe.revealRawLine(v2(i,[...t])??1)},onDragStart:E=>{E.stopPropagation(),jA({kind:"move",path:t}),E.dataTransfer.effectAllowed="move"},onDragEnd:()=>s(null),onDragOver:E=>{E.preventDefault(),E.stopPropagation(),s({path:t,zone:_k(E,e,v,b)})},onDrop:E=>{E.preventDefault(),E.stopPropagation();const A=_k(E,e,v,b);s(null),e3(i,t,A)},className:Xt("rounded-lg border border-dashed p-2.5 transition-colors",o?"cursor-default":"cursor-grab",p?c?"border-primary bg-primary/5 ring-2 ring-primary/40":"border-primary bg-primary/5 ring-2 ring-primary/15":"border-border hover:border-muted-foreground/40",(D==="into"||x)&&"border-primary bg-primary/5 ring-2 ring-primary/40"),children:[S.jsxs("div",{className:"flex items-center gap-2",children:[!o&&S.jsx(u3,{className:"h-3.5 w-3.5 select-none text-muted-foreground/50"}),S.jsx("span",{className:"min-w-0 flex-1 truncate text-[12.5px] font-medium",children:G2e(e)}),Lg(e)&&S.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),Xe.apply(A=>m_(A,t))},title:`Направление: ${T?"ряд":"столбец"} (клик — перевернуть)`,className:"flex-none rounded border border-border p-0.5 text-muted-foreground transition-colors hover:border-primary hover:text-primary",children:T?S.jsx(JA,{className:"size-3"}):S.jsx(HA,{className:"size-3"})}),S.jsx("span",{className:"flex-none rounded-full border border-border bg-muted px-2 py-0.5 font-mono text-[9.5px] font-semibold text-muted-foreground",children:FD(e)})]}),!h&&d.map(E=>S.jsxs("div",{className:Xt("mt-2 flex gap-2 border-dashed border-border/60",E.kind==="children"&&T?"flex-row items-start border-t pt-3":"flex-col border-l pl-3"),children:[E.entries.length===0&&S.jsx("div",{onDragOver:A=>{A.preventDefault(),A.stopPropagation(),s({path:t,zone:"into"})},onDrop:A=>{A.preventDefault(),A.stopPropagation(),s(null),e3(i,t,"into")},className:Xt("rounded-md border border-dashed px-2 py-1.5 text-[11px]",D==="into"?"border-primary bg-primary/5 text-primary":"border-border/60 text-muted-foreground"),children:"перетащите компонент сюда"}),E.entries.map(A=>S.jsx(t3,{node:A.node,path:E.single?E.path:[...E.path,A.index],selectionPath:r},A.index))]},E.kind))]})]})}function Z2e({schema:e,selectionPath:t,selectionPaths:r=[]}){const[n,s]=se.useState(null),i=vi().hideDivWrappers;return S.jsx(cj.Provider,{value:{drop:n,setDrop:s,schema:e,hideDivWrappers:i,selectionPaths:r},children:S.jsx(t3,{node:e.root,path:["root"],selectionPath:t})})}class eDe extends se.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){t.resetKey!==this.props.resetKey&&this.state.error&&this.setState({error:null})}render(){return this.state.error?S.jsxs("div",{className:"rounded-lg border border-destructive/40 bg-destructive/5 p-4 text-sm text-destructive",children:[S.jsx("div",{className:"font-medium",children:"Не удалось отрендерить форму"}),S.jsx("div",{className:"mt-1 font-mono text-xs opacity-80",children:this.state.error.message})]}):this.props.children}}const tDe="-4px",rDe="6px",nDe={border:"2px solid var(--rb-select)",z:10},sDe={border:"2px solid var(--rb-select-weak)",z:9},iDe={border:"1px dashed var(--rb-select-weak)",z:8};function r3(e,t,r){const n=O2(t);return`${e} .${n} { position: relative; }
|
|
1132
1132
|
${e} .${n}::after { content: ''; position: absolute; inset: ${tDe}; border: ${r.border}; border-radius: ${rDe}; pointer-events: none; z-index: ${r.z}; }`}function aDe(e,t,r){return[...r.map(n=>r3(e,n,sDe)),...t?[r3(e,t,nDe)]:[]].join(`
|
|
1133
|
-
`)}function oDe(e){const t=se.useRef(null),r=se.useRef(""),n=s=>{const i=s?r3(e,s,iDe):"";i!==r.current&&(r.current=i,t.current&&(t.current.textContent=i))};return se.useEffect(()=>()=>{r.current="",t.current&&(t.current.textContent="")},[]),{hoverRef:t,setHoverPath:n}}function uDe({scope:e,selectionPath:t,selectionPaths:r,hoverRef:n}){return S.jsxs(S.Fragment,{children:[S.jsx("style",{children:aDe(e,t,r)}),S.jsx("style",{ref:n})]})}function lDe({overlayRef:e}){return S.jsxs("div",{ref:e,className:"pointer-events-none absolute inset-0 z-20 hidden",children:[S.jsx("div",{"data-part":"box",className:"absolute rounded-[3px]",style:{display:"none"}}),S.jsx("div",{"data-part":"chip",className:"absolute rounded-full bg-[var(--rb-select)] px-1.5 py-px text-[9px] font-semibold whitespace-nowrap text-[var(--rb-select-fg)] shadow-sm",style:{display:"none"}})]})}const Ic=3;function Pk(e,t,r){if(!e||!t)return;const n=e.querySelector('[data-part="box"]'),s=e.querySelector('[data-part="chip"]');if(!n||!s)return;if(!r){e.classList.add("hidden"),n.style.display="none",s.style.display="none";return}const i=t.getBoundingClientRect(),a=r.rect.left-i.left,u=r.rect.top-i.top,{width:o,height:c}=r.rect;e.classList.remove("hidden"),n.style.display="block";const p=lj(r.zone,r.horizontalParent);if(p===null)Object.assign(n.style,{left:`${a}px`,top:`${u}px`,width:`${o}px`,height:`${c}px`,background:"color-mix(in oklab, var(--rb-select) 8%, transparent)",outline:"2px solid var(--rb-select)",outlineOffset:"-1px"});else{const y=p==="top"||p==="bottom";Object.assign(n.style,{left:`${p==="right"?a+o-Ic/2:a-(y?0:Ic/2)}px`,top:`${p==="bottom"?u+c-Ic/2:u-(y?Ic/2:0)}px`,width:`${y?o:Ic}px`,height:`${y?Ic:c}px`,background:"var(--rb-select)",outline:"none"})}if(!oj.has(r.zone)){s.style.display="none";return}const d=r.zone==="stack-before"||r.zone==="stack-after";s.textContent=d?"↓ столбец":"→ ряд",s.style.display="block",s.style.transform="translate(-50%, -50%)";const h=a+o/2,m=u+c/2;switch(r.zone){case"beside-before":Object.assign(s.style,{left:`${a}px`,top:`${m}px`});break;case"beside-after":Object.assign(s.style,{left:`${a+o}px`,top:`${m}px`});break;case"stack-before":Object.assign(s.style,{left:`${h}px`,top:`${u}px`});break;default:Object.assign(s.style,{left:`${h}px`,top:`${u+c}px`})}}const E2=`[class*="${Sh}"]`;function ul(e,t){let r=e instanceof Element?e.closest(E2):null;for(;r instanceof HTMLElement;){const n=Cq(r.getAttribute("class")??""),s=n?Eq(n):null,i=s?Pr(t,s):void 0;if(s&&an(i))return{path:s,node:i,element:r};r=r.parentElement?.closest(E2)??null}return null}function cDe(e,t){return e.querySelector(`.${CSS.escape(O2(t))}`)}function Nk(e,t,r,n){const s=ul(t,e);if(!s)return null;const i=s.path.length===1&&s.path[0]==="root",a=Pn(s.path),u=a?Pr(e,a):void 0,o=u?Th(u):"vertical",c=!i&&s.path[s.path.length-2]==="children",p=s.element.getBoundingClientRect(),d=uj({x:r,y:n},p,s.node,o,c);return{path:s.path,zone:d,rect:p,horizontalParent:o==="horizontal"}}const pDe=O2(["root"]),dDe=se.memo(function({schema:t,registry:r,model:n,form:s,renderBehavior:i}){const a=Hz(),u=S.jsx(X8,{settings:{registry:r},children:S.jsx(Lz,{form:s,children:S.jsx(r_,{schema:t,model:n,renderBehavior:i,validateSchema:!1})})});return S.jsx(eDe,{resetKey:t,children:a?se.createElement(a,null,u):u})});function fDe({schema:e,annotated:t,mock:r,mode:n,selectionPath:s,selectionPaths:i=[],live:a}){const u=se.useRef(null),o=se.useRef(null),c=se.useId().replace(/[^a-zA-Z0-9_-]/g,""),p=`[data-rb-scope="${c}"]`,{hoverRef:d,setHoverPath:h}=oDe(p),m=se.useMemo(()=>{if(a)return{bundle:a,error:null};try{return{bundle:yq(t,r),error:null}}catch(k){return{bundle:null,error:k instanceof Error?k.message:String(k)}}},[t,r,a]);se.useEffect(()=>(_S(m.bundle?.model??null),()=>_S(null)),[m.bundle]);const y=n==="edit";se.useEffect(()=>{y||h(null)},[y,h]),se.useEffect(()=>{!y||!s||!u.current||cDe(u.current,s)?.scrollIntoView({block:"nearest",inline:"nearest"})},[y,s]),se.useEffect(()=>{},[e,y,m]);const v=se.useCallback(k=>{if(!y)return;const _=ul(k.target,e);_&&(k.shiftKey?Xe.extendSelectionTo(_.path):k.metaKey||k.ctrlKey?Xe.toggleSelectionAt(_.path):Xe.select(_.path),u.current?.focus({preventScroll:!0}))},[y,e]),b=se.useCallback(k=>{if(!y)return;const _=ul(k.target,e);_&&Xe.revealRawLine(v2(e,[..._.path])??1)},[y,e]),T=se.useCallback(k=>{y&&h(ul(k.target,e)?.path??null)},[y,e,h]),D=se.useCallback(()=>{Pk(o.current,u.current,null)},[]),x=se.useCallback(k=>{if(!y)return;const _=ul(k.target,e);if(!_||_.path.length===1&&_.path[0]==="root"){k.preventDefault();return}jA({kind:"move",path:_.path}),k.dataTransfer.effectAllowed="move",h(null)},[y,e,h]),E=se.useCallback(k=>{const _=y?ZE():null;if(!_)return;const O=Nk(e,k.target,k.clientX,k.clientY);O&&(k.preventDefault(),k.dataTransfer.dropEffect=_.kind==="move"?"move":"copy",Pk(o.current,u.current,O))},[y,e]),A=se.useCallback(k=>{if(!y||!ZE())return;const _=Nk(e,k.target,k.clientX,k.clientY);D(),_&&(k.preventDefault(),k.stopPropagation(),e3(e,_.path,_.zone))},[y,e,D]),F=se.useCallback(k=>{const _=k.relatedTarget;_ instanceof Node&&u.current?.contains(_)||D()},[D]);return se.useEffect(()=>{const k=u.current;if(!k)return;if(!y){k.querySelectorAll(E2).forEach(j=>j.draggable=!1);return}let _=0;const O=()=>{_=0,k.querySelectorAll(E2).forEach(j=>{if(j.draggable=!j.classList.contains(pDe),j.classList.contains(K_)&&!j.dataset.rbLabel){const V=ul(j,e);V&&(j.dataset.rbLabel=FD(V.node))}})};O();const q=new MutationObserver(()=>{_===0&&(_=requestAnimationFrame(O))});return q.observe(k,{childList:!0,subtree:!0}),()=>{q.disconnect(),_!==0&&cancelAnimationFrame(_)}},[y,m]),m.error!==null?S.jsxs("div",{className:"rounded-lg border border-destructive/40 bg-destructive/5 p-4 text-sm text-destructive",children:[S.jsx("div",{className:"font-medium",children:"Схема не сконвертировалась"}),S.jsx("div",{className:"mt-1 font-mono text-xs opacity-80",children:m.error})]}):S.jsxs("div",{ref:u,"data-rb-preview":n,"data-rb-scope":c,tabIndex:-1,className:"relative outline-none",onClick:v,onDoubleClick:b,onMouseMove:T,onMouseLeave:()=>h(null),onDragStart:x,onDragEnd:()=>{OA(),D()},onDragOver:E,onDragLeave:F,onDrop:A,children:[y&&S.jsxs(S.Fragment,{children:[S.jsx(uDe,{scope:p,selectionPath:s,selectionPaths:i,hoverRef:d}),S.jsx(lDe,{overlayRef:o})]}),S.jsx(dDe,{schema:t,registry:m.bundle.registry,model:m.bundle.model,form:m.bundle.form,renderBehavior:a?.renderBehavior})]})}const hDe=se.lazy(()=>Pl(()=>import("./RawJsonEditor-jYY7XCW2.js"),__vite__mapDeps([9,2,3,10,11,12,4,5,1,6,8,7])));function pj({schema:e}){const{theme:t,revealLine:r,revealNonce:n}=vi(),[s,i]=se.useState(()=>ch(e)),a=se.useRef(!1),u=se.useRef(e);u.current=e,se.useEffect(()=>{a.current||i(ch(e))},[e]),se.useEffect(()=>{if(!a.current)return;const c=setTimeout(()=>{try{const p=JSON.parse(s);P2(p)&&Xe.replaceSchema(p)}catch{}},500);return()=>clearTimeout(c)},[s]);const o=c=>{a.current=c,c||i(ch(u.current))};return S.jsx(se.Suspense,{fallback:S.jsx("div",{className:"grid h-full place-items-center text-xs text-muted-foreground",children:"Загрузка редактора…"}),children:S.jsx(hDe,{value:s,theme:t,onChange:i,onFocusChange:o,revealLine:r,revealNonce:n})})}const mDe=se.lazy(()=>Pl(()=>import("./RawJsonEditor-jYY7XCW2.js"),__vite__mapDeps([9,2,3,10,11,12,4,5,1,6,8,7])));function yDe({tab:e,section:t}){const{theme:r}=vi(),n=se.useMemo(()=>gD(Ep(e.schema),t),[e.schema,t]),s=e.mock?.[t],[i,a]=se.useState(s??n),u=se.useRef(!1),[o,c]=se.useState({text:s,synthDoc:n});!u.current&&(o.text!==s||o.synthDoc!==n)&&(c({text:s,synthDoc:n}),a(s??n)),se.useEffect(()=>{if(!u.current)return;const d=setTimeout(()=>{try{JSON.parse(i),Xe.setMockText(e.id,t,i)}catch{}},500);return()=>clearTimeout(d)},[i,e.id,t]);const p=d=>{u.current=d};return S.jsx(se.Suspense,{fallback:S.jsx("div",{className:"grid h-full place-items-center text-xs text-muted-foreground",children:"Загрузка редактора…"}),children:S.jsx(mDe,{value:i,theme:r,onChange:a,onFocusChange:p})})}function gDe(e){return typeof e=="object"&&e!==null&&"value"in e}function dj(e,t,r){const n=r.reduce((s,i)=>s==null?s:s[i],e);return gDe(n)?n.value:t!==null&&typeof t=="object"&&!Array.isArray(t)?Object.fromEntries(Object.keys(t).map(s=>[s,dj(e,t[s],[...r,s])])):n??t}function DDe(e,t){if(e)try{return JSON.parse(e)}catch{}return Ep(t).model}function xDe({tab:e}){const t=se.useSyncExternalStore(Dq,gq),r=e.mock?.model,n=e.schema,s=se.useMemo(()=>DDe(r,n),[r,n]),[i,a]=se.useState(""),u=se.useRef(0);return se.useEffect(()=>{if(!t)return;const o=gp(()=>{const c=JSON.stringify(dj(t,s,[]),null,2);cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>a(c))});return()=>{cancelAnimationFrame(u.current),o()}},[t,s]),t?S.jsx("pre",{className:"h-full overflow-auto px-3 py-2 font-mono text-[12px] leading-[1.5] text-foreground",children:i}):S.jsx("div",{className:"grid h-full place-items-center px-4 text-center text-[12px] text-muted-foreground",children:"Живые значения появятся, когда превью запущено: переключите режим на «Renderer»."})}function $k(e){return typeof e=="object"&&e!==null&&"value"in e}function LA(e,t=""){if(e===null||typeof e!="object"||Array.isArray(e))return t?[t]:[];const r=[];for(const[n,s]of Object.entries(e))r.push(...LA(s,t?`${t}.${n}`:n));return r}function bDe(e){return e===""||e===null||e===void 0?"—":typeof e=="string"?e.length>60?`${e.slice(0,57)}…`:e:typeof e=="number"||typeof e=="boolean"?String(e):Array.isArray(e)?`[${e.length}]`:e instanceof Date?e.toISOString().slice(0,10):"{…}"}function vDe(e,t){const r=t.split(".").reduce((u,o)=>u==null?u:u[o],e),n=$k(r)?r.value:void 0,s=$k(r)?g8(r):void 0,i=[];let a=[];return s?(s.invalid.value&&i.push("invalid"),s.touched.value&&i.push("touched"),s.dirty.value&&i.push("dirty"),s.disabled.value&&i.push("disabled"),s.pending.value&&i.push("pending"),a=s.errors.value.map(u=>({code:String(u.code??"error"),message:String(u.message??"")}))):i.push("нет form-node"),{path:t,display:bDe(n),flags:i,errors:a}}const Ik=200,EDe=()=>new Date().toTimeString().slice(0,8);function CDe(e,t){const r=t.split(".").reduce((n,s)=>n==null?n:n[s],e);return r&&typeof r=="object"&&"value"in r?r.value:void 0}function TDe(e,t){const r=t.split(".").reduce((s,i)=>s==null?s:s[i],e),n=r&&typeof r=="object"&&"value"in r?g8(r):void 0;return n?n.errors.value.map(s=>`${String(s.code??"")}: ${String(s.message??"")}`).join(" | "):""}function ADe(e){if(!e)return null;const t=document.activeElement;if(!(t instanceof Element)||!t.closest("[data-rb-preview]"))return null;const r=ul(t,e);if(!r||!ni(r.node))return null;const n=Mt(r.node.value);return n?.op==="model"?n.arg:null}function SDe(){const t=se.useSyncExternalStore(yd,md).bundle,[r,n]=se.useState([]),s=se.useRef(0),i=se.useCallback(u=>{if(u.length===0)return;const o=EDe();n(c=>{const p=[...u.map(d=>({...d,id:++s.current,at:o})),...c];return p.length>Ik?p.slice(0,Ik):p})},[]);se.useEffect(()=>{if(!t)return;n([]);const u=LA(t.model.get()),o={values:new Map,errors:new Map};let c=!1;return gp(()=>{const d=new Map,h=new Map;for(const v of u)d.set(v,CDe(t.model,v)),h.set(v,TDe(t.model,v));if(!c){c=!0,o.values=d,o.errors=h;return}const m=ADe($i(mt.getState())?.schema),y=[];for(const v of u){const b=o.values.get(v),T=d.get(v);Object.is(b,T)||y.push({kind:v===m?"input":"derived",path:v,detail:`${Bk(b)} → ${Bk(T)}`});const D=o.errors.get(v)??"",x=h.get(v)??"";D!==x&&y.push(x?{kind:"error",path:v,detail:x}:{kind:"resolved",path:v,detail:D})}o.values=d,o.errors=h,i(y)})},[t,i]),se.useEffect(()=>{const u=t?.validation;if(!t||!u)return;let o=!1;return gp(()=>{const p=u.validating.value,d=t.form.errors.value.length;o&&!p&&i([{kind:"validation",path:"",detail:d>0?`завершена, ошибок: ${d}`:"завершена, форма валидна"}]),o=p})},[t,i]);const a=se.useCallback(()=>n([]),[]);return{entries:r,clear:a}}function Bk(e){return e===""||e===null||e===void 0?"∅":typeof e=="string"?e.length>24?`"${e.slice(0,21)}…"`:`"${e}"`:Array.isArray(e)?`[${e.length}]`:typeof e=="object"?"{…}":String(e)}function FDe(){const e=se.useSyncExternalStore(yd,md),[t,r]=se.useState("fields");return e.status==="off"?S.jsx(xh,{children:"Схемы формы не исполняются. Включите «Схемы формы» в панели Renderer — валидация, поведение и реестр из каталога заработают на живой форме."}):e.status==="unavailable"?S.jsx(xh,{children:"Каталог формы недоступен: исполнять нечего. Откройте форму из проекта — рядом со схемой должны лежать model.ts / validation.ts / form.behavior.ts."}):e.status==="loading"?S.jsx(xh,{children:"Собираем схемы формы…"}):S.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[S.jsx(wDe,{}),S.jsxs("div",{className:"flex flex-none gap-0.5 border-b border-border px-2 py-1 text-[11.5px]",children:[S.jsx(xv,{active:t,value:"fields",onSelect:r,children:"Поля"}),S.jsx(xv,{active:t,value:"log",onSelect:r,children:"Лог"}),S.jsxs(xv,{active:t,value:"build",onSelect:r,children:["Сборка",e.errors.length>0?` · ${e.errors.length}`:""]})]}),S.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[t==="fields"&&S.jsx(kDe,{}),t==="log"&&S.jsx(_De,{}),t==="build"&&S.jsx(NDe,{})]})]})}function xh({children:e}){return S.jsx("div",{className:"grid h-full place-items-center px-6 text-center text-[12px] text-muted-foreground",children:S.jsx("p",{className:"max-w-md",children:e})})}function xv({active:e,value:t,onSelect:r,children:n}){return S.jsx("button",{onClick:()=>r(t),className:Xt("rounded px-2 py-0.5",e===t?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted"),children:n})}function wDe(){const t=se.useSyncExternalStore(yd,md).bundle,[r,n]=se.useState({valid:!0,errors:0,validating:!1}),s=se.useRef(0);return se.useEffect(()=>{if(!t)return;const i=gp(()=>{const a={valid:t.form.valid.value,errors:t.form.errors.value.length,validating:t.validation?.validating.value??!1};cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>n(a))});return()=>{cancelAnimationFrame(s.current),i()}},[t]),t?S.jsxs("div",{className:"flex flex-none flex-wrap items-center gap-2 border-b border-border px-2 py-1.5 text-[11.5px]",children:[S.jsx("span",{className:Xt("rounded px-1.5 py-0.5 font-medium",r.valid?"bg-emerald-500/10 text-emerald-700":"bg-destructive/10 text-destructive"),children:r.valid?"форма валидна":`ошибок: ${r.errors}`}),S.jsxs("span",{className:"text-muted-foreground",children:["стратегия:"," ",t.strategy??(t.validateAll?"только ручной прогон":"валидации нет")]}),r.validating&&S.jsx("span",{className:"text-muted-foreground",children:"идёт проверка…"}),S.jsx("span",{className:"flex-1"}),t.validateAll&&S.jsx("button",{onClick:()=>void t.validateAll?.(),className:"rounded border border-border px-2 py-0.5 hover:bg-muted",children:"Прогнать валидацию"})]}):null}function kDe(){const t=se.useSyncExternalStore(yd,md).bundle,r=se.useMemo(()=>t?LA(t.model.get()):[],[t]),[n,s]=se.useState([]),i=se.useRef(0);return se.useEffect(()=>{if(!t)return;const a=gp(()=>{const u=r.map(o=>vDe(t.model,o));cancelAnimationFrame(i.current),i.current=requestAnimationFrame(()=>s(u))});return()=>{cancelAnimationFrame(i.current),a()}},[t,r]),t?n.length===0?S.jsx(xh,{children:"В модели нет полей — проверьте `$model`-пути схемы и model.ts."}):S.jsxs("table",{className:"w-full border-collapse text-[11.5px]",children:[S.jsx("thead",{className:"sticky top-0 bg-sidebar text-muted-foreground",children:S.jsxs("tr",{children:[S.jsx("th",{className:"px-2 py-1 text-left font-normal",children:"Поле"}),S.jsx("th",{className:"px-2 py-1 text-left font-normal",children:"Значение"}),S.jsx("th",{className:"px-2 py-1 text-left font-normal",children:"Состояние"}),S.jsx("th",{className:"px-2 py-1 text-left font-normal",children:"Ошибки"})]})}),S.jsx("tbody",{children:n.map(a=>S.jsxs("tr",{className:"border-t border-border/60 align-top",children:[S.jsx("td",{className:"px-2 py-1 font-mono text-foreground",children:a.path}),S.jsx("td",{className:"max-w-[16rem] truncate px-2 py-1 font-mono text-muted-foreground",children:a.display}),S.jsx("td",{className:"px-2 py-1",children:S.jsx("div",{className:"flex flex-wrap gap-1",children:a.flags.map(u=>S.jsx("span",{className:"rounded bg-muted px-1 text-[10.5px]",children:u},u))})}),S.jsx("td",{className:"px-2 py-1 text-destructive",children:a.errors.map(u=>S.jsxs("div",{children:[u.message," ",S.jsxs("span",{className:"opacity-60",children:["(",u.code,")"]})]},`${u.code}:${u.message}`))})]},a.path))})]}):null}function _De(){const{entries:e,clear:t}=SDe();return e.length===0?S.jsx(xh,{children:"Пока тихо. Введите что-нибудь в форму — здесь появятся изменения и ошибки."}):S.jsxs("div",{className:"text-[11.5px]",children:[S.jsxs("div",{className:"sticky top-0 flex items-center gap-2 bg-sidebar px-2 py-1 text-muted-foreground",children:[S.jsxs("span",{className:"flex-1",children:[e.length," событий"]}),S.jsx("button",{onClick:t,className:"rounded px-1.5 hover:bg-muted hover:text-foreground",children:"Очистить"})]}),S.jsx("ul",{children:e.map(r=>S.jsxs("li",{className:"flex gap-2 border-t border-border/60 px-2 py-1",children:[S.jsx("span",{className:"w-14 flex-none font-mono text-muted-foreground",children:r.at}),S.jsx("span",{className:Xt("w-24 flex-none",r.kind==="error"&&"text-destructive",r.kind==="resolved"&&"text-emerald-700",r.kind==="derived"&&"text-sky-700",r.kind==="input"&&"text-muted-foreground"),children:PDe[r.kind]}),S.jsx("span",{className:"font-mono text-foreground",children:r.path}),S.jsx("span",{className:"text-muted-foreground",children:r.detail})]},r.id))})]})}const PDe={input:"ввод",derived:"пересчёт",error:"ошибка",resolved:"исправлено",validation:"валидация"};function NDe(){const e=se.useSyncExternalStore(yd,md),t=new Set(e.errors.map(r=>r.file));return S.jsxs("div",{className:"space-y-2 px-2 py-1.5 text-[11.5px]",children:[S.jsxs("div",{children:[S.jsx("div",{className:"text-muted-foreground",children:"Файлы каталога"}),S.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[e.files.length===0&&S.jsx("span",{className:"text-muted-foreground",children:"не найдены"}),e.files.map(r=>S.jsxs("span",{title:e.fromEditor.includes(r)?"Взят из открытой вкладки (несохранённые правки)":"Прочитан с диска",className:Xt("rounded px-1.5 py-0.5 font-mono",t.has(r)?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"),children:[r,e.fromEditor.includes(r)?" •":""]},r))]})]}),e.errors.length>0&&S.jsxs("div",{children:[S.jsx("div",{className:"text-muted-foreground",children:"Ошибки"}),S.jsx("ul",{className:"mt-1 space-y-1",children:e.errors.map((r,n)=>S.jsxs("li",{className:"rounded border border-destructive/40 p-1.5",children:[S.jsxs("div",{className:"font-mono text-destructive",children:[r.file||"сборка"," · ",r.phase==="transpile"?"компиляция":"исполнение"]}),S.jsx("div",{className:"mt-0.5 whitespace-pre-wrap text-foreground",children:r.message})]},`${r.file}:${n}`))})]}),e.applied.length>0&&S.jsxs("div",{children:[S.jsx("div",{className:"text-muted-foreground",children:"Подключено"}),S.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:e.applied.map(r=>S.jsx("span",{className:"rounded bg-emerald-500/10 px-1.5 py-0.5 text-emerald-700",children:r},r))})]})]})}const $De={raw:null,model:"model",registry:"dataSources",form:null};function IDe({tab:e}){const{rawJsonOpen:t,bottomTab:r}=vi(),[n,s]=se.useState(0),[i,a]=se.useState("seed"),u=$De[r],o=r==="model"&&i==="live",c=r==="form",p=se.useMemo(()=>c?0:(u==null?ch(e.schema):e.mock?.[u]??gD(Ep(e.schema),u)).split(`
|
|
1134
|
-
`).length,[c,u,e.schema,e.mock]),d=y=>{Xe.setBottomTab(y),t||Xe.toggleRawJson()},h=()=>{u!=null&&(Xe.resetMock(e.id,u),s(y=>y+1))},m=y=>Xt("h-full rounded px-2.5 text-[11.5px]",r===y?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted");return S.jsxs("div",{className:t?"flex min-h-0 flex-1 flex-col bg-sidebar":"flex-none border-t border-border bg-sidebar",children:[S.jsxs("div",{className:"flex h-[30px] w-full flex-none items-center gap-1 px-1.5 text-[11.5px] text-muted-foreground",children:[S.jsx("button",{onClick:Xe.toggleRawJson,title:t?"Свернуть":"Развернуть",className:"grid h-full w-5 flex-none place-items-center rounded hover:bg-muted",children:S.jsx(Rp,{className:Xt("h-3.5 w-3.5 transition-transform",t&&"rotate-90")})}),S.jsx("button",{onClick:()=>d("raw"),className:m("raw"),children:"JSON"}),S.jsx("button",{onClick:()=>d("model"),title:"Модель формы: засев (редактируется) или живые значения",className:m("model"),children:"Модель"}),S.jsx("button",{onClick:()=>d("registry"),title:"Значения источников $dataSource в превью",className:m("registry"),children:"Registry"}),S.jsx("button",{onClick:()=>d("form"),title:"Состояние живой формы: валидность полей, ошибки, лог поведения, сборка схем",className:m("form"),children:"Форма"}),S.jsx("span",{className:"flex-1"}),r==="model"&&t&&S.jsxs("div",{className:"flex flex-none gap-0.5 rounded border border-border p-0.5",children:[S.jsx("button",{onClick:()=>a("seed"),title:"Значения, которыми форма инициализируется. Редактируются.",className:Xt("rounded px-1.5",i==="seed"?"bg-muted text-foreground":""),children:"Засев"}),S.jsx("button",{onClick:()=>a("live"),title:"Что в модели сейчас — с учётом ввода в поля превью. Только чтение.",className:Xt("rounded px-1.5",i==="live"?"bg-muted text-foreground":""),children:"Живые"})]}),u!=null&&t&&!o&&!c&&S.jsx("button",{onClick:h,title:"Сбросить к синтезу из схемы",className:"flex-none rounded px-2 py-0.5 hover:bg-muted hover:text-foreground",children:"Сбросить"}),!o&&!c&&S.jsxs("span",{className:"flex-none pr-1.5",children:[p," строк"]})]}),t&&S.jsx("div",{className:"min-h-0 flex-1 border-t border-border",children:c?S.jsx(FDe,{}):u==null?S.jsx(pj,{schema:e.schema}):o?S.jsx(xDe,{tab:e}):S.jsx(yDe,{tab:e,section:u},`${u}:${n}`)})]})}function BDe(e){if(e!=null)try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:void 0}catch{return}}function jDe({tab:e}){const t=vi(),r=C3({id:"rb.layout.v",storage:localStorage,panelIds:["canvas","raw"]}),n=se.useMemo(()=>Bh(e.schema,e.mock),[e.schema,e.mock]),s=se.useMemo(()=>Aq(e.schema),[e.schema]),i=se.useMemo(()=>BDe(e.mock?.model),[e.mock?.model]),a=M2e({tab:e,annotated:s,dataSources:n.dataSources,modelOverride:i,enabled:t.preview==="runtime"&&t.liveSchemas}),u=S.jsx(IDe,{tab:e});if(t.preview==="code")return S.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col overflow-hidden bg-muted/40",children:[S.jsx(wk,{}),S.jsx("div",{className:"min-h-0 flex-1",children:S.jsx(pj,{schema:e.schema})})]});const o=S.jsx(S.Fragment,{children:S.jsx("div",{className:"mx-auto w-full",children:S.jsx("div",{className:"rounded-xl border border-border bg-background p-4 shadow-sm",children:t.preview==="runtime"?S.jsx(fDe,{schema:e.schema,annotated:s,mock:n,mode:t.runtimeMode,selectionPath:e.selectionPath,selectionPaths:e.selectionPaths,live:a}):S.jsx(Z2e,{schema:e.schema,selectionPath:e.selectionPath,selectionPaths:e.selectionPaths})})})});return S.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col overflow-hidden bg-muted/40",children:[S.jsx(wk,{}),t.rawJsonOpen?S.jsxs(A3,{orientation:"vertical",className:"min-h-0 flex-1",defaultLayout:r.defaultLayout,onLayoutChanged:r.onLayoutChanged,children:[S.jsx(hl,{id:"canvas",minSize:200,className:"relative p-14",children:o}),S.jsx(jg,{withHandle:!0}),S.jsx(hl,{id:"raw",defaultSize:216,minSize:120,maxSize:560,className:"flex flex-col",children:u})]}):S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"relative flex-1 overflow-auto p-14",children:o}),u]})]})}const jk=gr("Mod+Shift+V"),ODe=[{view:"code",label:"Код",hint:`Исходник в редакторе (цикл ${jk})`,Icon:Yj},{view:"preview",label:"Предпросмотр",hint:`Рендер файла (цикл ${jk})`,Icon:D8},{view:"split",label:"Рядом",hint:`Редактор и рендер с синхроскроллом (${gr("Mod+K")} ${gr("V")})`,Icon:Qj}];function LDe({tab:e}){const t=e.mdView??"code";return S.jsx("div",{className:"flex h-[30px] flex-none items-center justify-end gap-1.5 border-b border-border bg-sidebar px-1.5",children:S.jsx("div",{className:"flex flex-none gap-0.5 rounded-md border border-border bg-muted p-0.5",children:ODe.map(({view:r,label:n,hint:s,Icon:i})=>S.jsxs("button",{onClick:()=>sd(e.id,r),title:s,"aria-pressed":t===r,className:Xt("flex h-5 items-center gap-1 rounded px-2 text-[11.5px]",t===r?"bg-background shadow-sm":"text-muted-foreground hover:bg-muted"),children:[S.jsx(i,{className:"h-3 w-3"}),n]},r))})})}function C2(e,t,r,n,s){return r===t?n:n+(e-t)*(s-n)/(r-t)}function fj(e,t,r){let n=0,s=e.length-1,i=-1;for(;n<=s;){const a=n+s>>1;r(e[a])<=t?(i=a,n=a+1):s=a-1}return i}function Ok(e,t){if(!e.length)return 0;const r=fj(e,t,n=>n.line);return r===-1?C2(t,1,e[0].line,0,e[0].top):r===e.length-1?e[r].top:C2(t,e[r].line,e[r+1].line,e[r].top,e[r+1].top)}function MDe(e,t){if(!e.length)return 1;const r=fj(e,t,n=>n.top);return r===-1?C2(t,0,e[0].top,1,e[0].line):r===e.length-1?e[r].line:C2(t,e[r].top,e[r+1].top,e[r].line,e[r+1].line)}function RDe(e,t){const r=(t??e).querySelectorAll("[data-line]"),n=e.getBoundingClientRect().top-e.scrollTop,s=[];for(const i of r){const a=Number(i.dataset.line);if(!Number.isFinite(a))continue;const u=i.getBoundingClientRect().top-n,o=s[s.length-1];o&&o.line===a||s.push({line:a,top:u})}return s.sort((i,a)=>i.line-a.line),s}const UDe=150;function zDe(e,t){const r=se.useRef(null),n=se.useRef(null),s=se.useRef([]),i=se.useRef(null),[a,u]=se.useState(null),o=se.useCallback(c=>u(c),[]);return se.useEffect(()=>{const c=r.current;if(!e||!a||!c)return;const p=x=>{const E=performance.now(),A=i.current;return A&&A.who!==x&&E<A.until?!1:(i.current={who:x,until:E+UDe},!0)},d=()=>{s.current=RDe(c,n.current??void 0)},h=()=>{const x=a.getVisibleRanges()[0]?.startLineNumber??1,E=a.getTopForLineNumber(x),A=a.getBottomForLineNumber(x),F=A>E?(a.getScrollTop()-E)/(A-E):0;return x+Math.min(1,Math.max(0,F))};let m=0;const y=x=>{cancelAnimationFrame(m),m=requestAnimationFrame(x)},v=()=>{p("editor")&&y(()=>{c.scrollTop=Ok(s.current,h())})},b=()=>{p("preview")&&y(()=>{const x=MDe(s.current,c.scrollTop),E=Math.max(1,Math.floor(x)),A=a.getTopForLineNumber(E),F=a.getBottomForLineNumber(E);a.setScrollTop(A+(x-E)*(F-A))})};d(),c.scrollTop=Ok(s.current,h());const T=a.onDidScrollChange(v);c.addEventListener("scroll",b,{passive:!0});const D=new ResizeObserver(d);return n.current&&D.observe(n.current),()=>{cancelAnimationFrame(m),T.dispose(),c.removeEventListener("scroll",b),D.disconnect()}},[e,a,t]),{onEditorMount:o,previewRef:r,contentRef:n}}const qDe=se.lazy(()=>Pl(()=>import("./CodeEditor-CuHAtGtB.js"),__vite__mapDeps([13,2,3,10,11,12,14,4,5,1,6,8,7]))),JDe=se.lazy(()=>Pl(()=>import("./MarkdownPreview-DwyxNTbn.js"),__vite__mapDeps([15,2,3,4,5,1,6,8,7])));function Lk({label:e}){return S.jsx("div",{className:"grid h-full place-items-center text-xs text-muted-foreground",children:e})}function KDe({tab:e}){const{theme:t}=vi(),r=DD(e),n=r?e.mdView??"code":"code",s=e.text??"",i=C3({id:"rb.layout.md",storage:localStorage,panelIds:["md-code","md-preview"]}),a=zDe(r&&n==="split",s),u=S.jsx(se.Suspense,{fallback:S.jsx(Lk,{label:"Загрузка редактора…"}),children:S.jsx(qDe,{value:s,language:e.language??"plaintext",theme:t,onChange:c=>Xe.setTabText(e.id,c),onMount:(c,p)=>{c.addCommand(p.KeyMod.CtrlCmd|p.KeyMod.Shift|p.KeyCode.KeyK,()=>Xe.toggleRightPanelTo("agent")),r&&(a.onEditorMount(c),c.addCommand(p.KeyMod.CtrlCmd|p.KeyMod.Shift|p.KeyCode.KeyV,()=>GN(1)),c.addCommand(p.KeyMod.chord(p.KeyMod.CtrlCmd|p.KeyCode.KeyK,p.KeyCode.KeyV),()=>sd(e.id,"split")))}})}),o=S.jsx(se.Suspense,{fallback:S.jsx(Lk,{label:"Загрузка предпросмотра…"}),children:S.jsx(JDe,{text:s,docPath:e.source.path,dark:t==="dark",containerRef:a.previewRef,contentRef:a.contentRef})});return S.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background",children:[r&&S.jsx(LDe,{tab:e}),S.jsxs("div",{className:"min-h-0 flex-1",children:[n==="code"&&u,n==="preview"&&o,n==="split"&&S.jsxs(A3,{orientation:"horizontal",className:"min-h-0 flex-1",defaultLayout:i.defaultLayout,onLayoutChanged:i.onLayoutChanged,children:[S.jsx(hl,{id:"md-code",minSize:240,className:"flex min-h-0 flex-col overflow-hidden",children:u}),S.jsx(jg,{withHandle:!0}),S.jsx(hl,{id:"md-preview",minSize:240,className:"flex min-h-0 flex-col overflow-hidden",children:o})]})]})]})}const bh=Bl({pending:null}),T2={open:e=>bh.setState({pending:e}),close:()=>bh.setState({pending:null})};function VDe(){return se.useSyncExternalStore(bh.subscribe,()=>bh.getState(),()=>bh.getState())}function hj(e,t){const r=e.order.indexOf(t.id);if(r<0)return[];switch(t.kind){case"one":return[t.id];case"others":return e.order.filter(n=>n!==t.id);case"left":return e.order.slice(0,r);case"right":return e.order.slice(r+1)}}function WDe(e,t){const r=[];for(const n of t){const s=e.tabs[n];s&&$2(s)&&b_(s)&&r.push({id:n,name:s.source.name})}return r}function mj(e,t){for(const r of hj(e,t)){const n=e.tabs[r];n&&$2(n)&&C_(r)}switch(t.kind){case"one":Xe.closeTab(t.id);return;case"others":Xe.closeOtherTabs(t.id);return;case"left":Xe.closeTabsToLeft(t.id);return;case"right":Xe.closeTabsToRight(t.id)}}function Jc(e){const t=mt.getState(),r=hj(t,e);if(!r.length)return;const n=WDe(t,r);if(!n.length){mj(t,e);return}T2.open({intent:e,total:r.length,drafts:n})}function HDe(e){mj(mt.getState(),e),T2.close()}function GDe({id:e,index:t,count:r}){const n=dU(e),s=v_();if(!n)return null;const i=e===s,a=t>0,u=t<r-1,o=r>1,c=$2(n);return S.jsxs(l3,{children:[S.jsx(c3,{asChild:!0,children:S.jsxs("div",{onClick:()=>Xe.setActiveTab(e),onDoubleClick:()=>Xe.pinTab(e),className:Xt("flex cursor-pointer items-center gap-2 whitespace-nowrap border-r border-border px-3 font-mono text-[11px]",i?"bg-background text-foreground":"bg-sidebar text-muted-foreground"),children:[S.jsx("span",{className:"text-muted-foreground",children:"{}"}),S.jsx("span",{className:Xt(n.preview&&"italic"),title:n.preview?`${n.source.path||n.source.name} — предпросмотр: двойной клик закрепит вкладку`:c?`${n.source.name} — черновик: файла в проекте нет, копия хранится локально`:n.source.path||n.source.name,children:n.source.name}),b_(n)&&S.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500"}),S.jsx("button",{onClick:p=>{p.stopPropagation(),Jc({kind:"one",id:e})},className:"ml-1 grid h-4 w-4 place-items-center rounded text-muted-foreground hover:bg-muted hover:text-foreground",children:S.jsx(w2,{className:"h-3.5 w-3.5"})})]})}),S.jsxs(p3,{className:"w-52",children:[S.jsx(sn,{onClick:()=>Jc({kind:"one",id:e}),children:"Закрыть"}),S.jsx(sn,{disabled:!a,onClick:()=>Jc({kind:"left",id:e}),children:"Закрыть слева"}),S.jsx(sn,{disabled:!u,onClick:()=>Jc({kind:"right",id:e}),children:"Закрыть справа"}),S.jsx(Kc,{}),S.jsx(sn,{disabled:!o,onClick:()=>Jc({kind:"others",id:e}),children:"Закрыть остальные"})]})]})}function XDe(){const e=pU();return S.jsx("div",{className:"flex h-[34px] flex-none items-stretch overflow-x-auto border-b border-border bg-sidebar",children:e.map((t,r)=>S.jsx(GDe,{id:t,index:r,count:e.length},t))})}function Mk({title:e,ops:t,side:r,scrollRef:n}){const s=t.map((i,a)=>({op:i,idx:a})).filter(({op:i})=>r==="old"?i.type!=="add":i.type!=="del");return S.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[S.jsx("div",{className:"flex-none border-b border-border bg-sidebar px-3.5 py-2 text-[10.5px] font-semibold uppercase tracking-wider text-muted-foreground",children:e}),S.jsx("div",{ref:n,className:"relative flex-1 overflow-auto py-2 font-mono text-[10.5px] leading-relaxed",children:s.map(({op:i,idx:a},u)=>{const o=u+1,c=i.type==="del"?"-":i.type==="add"?"+":" ";return S.jsxs("div",{"data-op-index":a,className:Xt("flex whitespace-pre",i.type==="del"&&"bg-red-500/15",i.type==="add"&&"bg-green-500/15"),children:[S.jsx("span",{className:"w-9 flex-none select-none pr-2 text-right text-muted-foreground/40",children:o}),S.jsx("span",{className:Xt("w-3 flex-none select-none text-center",i.type==="del"&&"text-red-600",i.type==="add"&&"text-green-600",i.type==="same"&&"text-transparent"),children:c}),S.jsx("span",{className:"min-w-0 flex-1 pr-3",children:i.text||" "})]},a)})})]})}function YDe(e){const t=[];let r=!1;return e.forEach((n,s)=>{n.type!=="same"?(r||t.push(s),r=!0):r=!1}),t}function Rk(e,t){if(!e)return;const r=Array.from(e.querySelectorAll("[data-op-index]")),n=r.find(i=>Number(i.dataset.opIndex)>=t)??r[r.length-1];if(!n)return;const s=n.offsetTop-e.clientHeight/2+n.clientHeight/2;e.scrollTo({top:Math.max(0,s),behavior:"smooth"})}function QDe(){const{plan:e,saving:t}=AU(),r=se.useRef(null),n=se.useRef(null),[s,i]=se.useState(-1),a=se.useMemo(()=>e?YDe(e.diff):[],[e]);if(!e)return null;const u=o=>{if(a.length===0)return;const c=Math.max(0,Math.min(a.length-1,o));i(c),Rk(r.current,a[c]),Rk(n.current,a[c])};return S.jsx("div",{onClick:Ga.close,className:"fixed inset-0 z-50 grid place-items-center bg-black/50 p-4",children:S.jsxs("div",{onClick:o=>o.stopPropagation(),className:"flex h-[72vh] w-[1280px] max-w-[95vw] flex-col overflow-hidden rounded-xl border border-border bg-background shadow-2xl",children:[S.jsxs("div",{className:"flex flex-none items-center gap-3 border-b border-border p-4",children:[S.jsxs("div",{className:"min-w-0",children:[S.jsx("div",{className:"text-sm font-semibold",children:"Сохранить изменения?"}),S.jsx("div",{className:"mt-0.5 truncate font-mono text-[11px] text-muted-foreground",children:e.tabId})]}),S.jsx("span",{className:"flex-1"}),a.length>0&&S.jsxs("div",{className:"flex flex-none items-center gap-1",children:[S.jsx(Rr,{variant:"outline",size:"icon-xs","aria-label":"Предыдущее изменение",title:"Предыдущее изменение",disabled:s<=0,onClick:()=>u(s-1),children:S.jsx(kO,{})}),S.jsxs("span",{className:"w-9 select-none text-center font-mono text-[11px] tabular-nums text-muted-foreground",children:[s<0?"–":s+1,"/",a.length]}),S.jsx(Rr,{variant:"outline",size:"icon-xs","aria-label":"Следующее изменение",title:"Следующее изменение",disabled:s>=a.length-1,onClick:()=>u(s+1),children:S.jsx(_O,{})})]}),S.jsxs("span",{className:"flex-none rounded-full border border-border bg-muted px-2.5 py-1 font-mono text-[11.5px]",children:["+",e.added," -",e.removed]})]}),e.conflict&&S.jsx("div",{className:"flex-none border-b border-amber-500/40 bg-amber-500/10 px-4 py-2 text-xs text-amber-700 dark:text-amber-400",children:"⚠ Файл изменился на диске после открытия. Сохранение перезапишет внешние правки."}),S.jsxs("div",{className:"flex min-h-0 flex-1",children:[S.jsx(Mk,{title:"Текущий файл",ops:e.diff,side:"old",scrollRef:r}),S.jsx("div",{className:"w-px flex-none bg-border"}),S.jsx(Mk,{title:"После сохранения",ops:e.diff,side:"new",scrollRef:n})]}),S.jsxs("div",{className:"flex flex-none justify-end gap-2 border-t border-border p-3",children:[S.jsx(Rr,{variant:"outline",size:"sm",onClick:Ga.close,children:"Отмена"}),S.jsx(Rr,{size:"sm",disabled:t,onClick:()=>void I2e(e),children:t?"Сохранение…":"Сохранить"})]})]})})}function ZDe(){const{pending:e}=VDe();if(!e)return null;const{drafts:t,total:r}=e,n=t.length>1;return S.jsx(S2,{open:!0,onOpenChange:s=>{s||T2.close()},children:S.jsxs(F2,{className:"max-w-md",children:[S.jsxs(ho,{children:[S.jsx(mo,{children:n?"Закрыть вкладки?":"Закрыть вкладку?"}),S.jsx(Mp,{children:n?`Из ${r} закрываемых вкладок ${t.length} — черновики без файла в проекте. Вместе с ними удалятся и локальные копии, восстановить их будет нельзя.`:"Эта схема — черновик: файла в проекте за ней нет. Вместе со вкладкой удалится и локальная копия, восстановить её будет нельзя."})]}),S.jsx("ul",{className:"max-h-40 overflow-auto rounded-md border border-border bg-muted/40 px-3 py-2 font-mono text-[11.5px]",children:t.map(s=>S.jsx("li",{className:"truncate py-0.5",children:s.name},s.id))}),S.jsxs("p",{className:"text-[11.5px] text-muted-foreground",children:["Чтобы сохранить работу, отмените закрытие и выгрузите схему через «Сохранить» (",gr("Mod+S"),") — она скачается файлом."]}),S.jsxs(Nl,{children:[S.jsx(Rr,{variant:"outline",onClick:T2.close,children:"Отмена"}),S.jsx(Rr,{variant:"destructive",onClick:()=>HDe(e.intent),children:"Закрыть и удалить"})]})]})})}function exe(e){return!e.variantGroup||e.name===e.variantGroup}function txe(e){const t=Ta(),r=t.find(i=>i.name===e)?.variantGroup;if(!r)return null;const n=t.filter(i=>i.variantGroup===r);if(n.length<2)return null;const s=n.find(i=>i.name===r)??n[0];return{group:r,members:n,default:s}}function n3(e){const t=new Set,r=[];for(const n of e){if(!n.variantGroup){r.push(n);continue}t.has(n.variantGroup)||(t.add(n.variantGroup),r.push(e.find(s=>s.name===n.variantGroup&&s.variantGroup===n.variantGroup)??n))}return r}const rxe=210,Uk=20,bv=2,nxe=3,sxe=8;function ixe(e){return n3(e.filter(r=>!W3(r))).flatMap(r=>[r,...n3(B2(r.name))])}function axe(e,t){const r=t.trim().toLowerCase();return r?e.filter(n=>H3(n).toLowerCase().includes(r)||n.name.toLowerCase().includes(r)):ixe(e)}function oxe(e){const t=[];return{sections:A_(e).map(([n,s])=>({category:n,items:s.map(i=>({entry:i,index:t.push(i)-1}))})),flat:t}}function uxe(e,t){const r=e.reduce((o,c)=>o+c.items.length+bv,0),n=Math.max(1,Math.min(t,Math.ceil(r/sxe))),s=Math.ceil(r/n),i=Array.from({length:n},()=>[]);let a=0,u=0;for(const o of e){let c=o.items,p=!1;for(;c.length;){const d=a===n-1,h=s-u-bv;if(!d&&h<nxe){a+=1,u=0;continue}const m=d?c.length:Math.min(c.length,h);i[a].push({key:`${o.category}#${a}`,category:o.category,total:o.items.length,continued:p,items:c.slice(0,m)}),u+=m+bv,c=c.slice(m),p=!0,c.length&&(a+=1,u=0)}}return i}function lxe(e,t){const[r,n]=se.useState(1);return se.useEffect(()=>{const s=e.current;if(!t||!s)return;const i=u=>n(Math.max(1,Math.floor((u+Uk)/(rxe+Uk))));i(s.clientWidth);const a=new ResizeObserver(([u])=>i(u.contentRect.width));return a.observe(s),()=>a.disconnect()},[e,t]),r}function cxe(){const e=vi().quickAddOpen,[t,r]=se.useState(""),[n,s]=se.useState(0),i=se.useRef(null),a=se.useRef(null),u=Ta(),o=lxe(a,e),{sections:c,flat:p}=se.useMemo(()=>oxe(axe(u,t)),[u,t]),d=se.useMemo(()=>uxe(c,o),[c,o]),[h,m]=se.useState(e);e!==h&&(m(e),e&&(r(""),s(0)));const y=Math.max(0,p.length-1);if(n>y&&s(y),se.useEffect(()=>{e&&i.current?.focus()},[e]),se.useEffect(()=>{a.current?.querySelector('[data-active="true"]')?.scrollIntoView({block:"nearest"})},[n]),!e)return null;const v=D=>{D&&(Xe.addComponent(D.makeNode()),Xe.closeQuickAdd())},b=D=>{const x=a.current,E=x?[...x.querySelectorAll("[data-idx]")]:[],A=E[n];if(!A)return;const F=A.getBoundingClientRect();let k=null;for(const _ of E){const O=_.getBoundingClientRect(),q=(O.left-F.left)*D;if(q<8)continue;const j=Math.abs(O.top-F.top),V=k&&Math.abs(q-k.dx)<8;(!k||q<k.dx-8||V&&j<k.dy)&&(k={index:Number(_.dataset.idx),dx:q,dy:j})}k&&s(k.index)},T=D=>{D.key==="ArrowDown"?(D.preventDefault(),D.stopPropagation(),s(x=>Math.min(x+1,p.length-1))):D.key==="ArrowUp"?(D.preventDefault(),D.stopPropagation(),s(x=>Math.max(x-1,0))):D.key==="ArrowRight"||D.key==="ArrowLeft"?(D.preventDefault(),D.stopPropagation(),b(D.key==="ArrowRight"?1:-1)):D.key==="Enter"?(D.preventDefault(),D.stopPropagation(),v(p[n])):D.key==="Escape"&&(D.preventDefault(),D.stopPropagation(),Xe.closeQuickAdd())};return S.jsx("div",{onClick:()=>Xe.closeQuickAdd(),className:"fixed inset-0 z-50 grid items-start justify-center overflow-auto bg-black/50 p-4 pt-[5vh]",children:S.jsxs("div",{onClick:D=>D.stopPropagation(),className:"flex max-h-[88vh] w-[min(1400px,94vw)] flex-col overflow-hidden rounded-xl border border-border bg-background shadow-2xl",children:[S.jsx("input",{ref:i,value:t,onChange:D=>{r(D.target.value),s(0)},onKeyDown:T,placeholder:"Добавить компонент…",className:"flex-none border-b border-border bg-transparent px-4 py-3 text-sm outline-none placeholder:text-muted-foreground"}),S.jsx("div",{ref:a,className:"min-h-0 flex-1 overflow-auto px-3 py-3",children:p.length===0?S.jsx("div",{className:"px-3 py-10 text-center text-xs text-muted-foreground",children:"Ничего не найдено"}):S.jsx("div",{className:"flex items-start gap-5",children:d.map((D,x)=>S.jsx("div",{className:"min-w-0 flex-1",children:D.map(E=>S.jsxs("section",{className:"mb-4",children:[S.jsxs("div",{className:Xt("mb-1.5 flex items-baseline gap-1.5 px-2 text-[14px] font-semibold",E.continued?"text-muted-foreground":"text-foreground"),children:[S.jsx("span",{className:"min-w-0 truncate",children:E.category}),S.jsx("span",{className:"font-mono text-[10.5px] font-normal text-muted-foreground/50",children:E.continued?"…":E.total})]}),E.items.map(({entry:A,index:F})=>S.jsxs("button",{type:"button","data-idx":F,"data-active":F===n,onMouseMove:()=>s(F),onClick:()=>v(A),className:Xt("flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-[12.5px]",W3(A)&&"pl-5 text-muted-foreground",F===n?"bg-primary/10 text-foreground":"hover:bg-muted"),children:[S.jsx("span",{className:"min-w-0 flex-1 truncate",children:H3(A)}),A.variantGroup&&!exe(A)&&S.jsx("span",{className:"flex-none rounded bg-primary/15 px-1 py-px text-[9.5px] font-medium text-primary",children:A.variant})]},A.name))]},E.key))},x))})}),S.jsx("div",{className:"flex-none border-t border-border px-3 py-1.5 text-[10.5px] text-muted-foreground",children:"↑↓ по колонке · ←→ между колонками · Enter вставить · Esc закрыть"})]})})}const gm=e=>e instanceof Error?e.message:String(e),pxe="sample-form";function wD(){return kn.getState().dirHandle}async function dxe(e,t){const r=new Map(kn.getState().tree.map(s=>[s.path,s.kind])),n=[];for(const s of t)if(r.get(s)==="directory"){const i=await o5(e,s);n.push(...i.map(a=>Cp(s,a)))}else n.push(s);return[...new Set(n)]}async function fxe(e,t){const r=wD();if(!r){wt("Проект не открыт");return}const n=t.name.trim();if(!n){wt("Укажите имя шаблона");return}try{const s=await dxe(r,e),i=s.filter(WB),a=s.length-i.length;if(!i.length){wt("Нечего сохранять: выбраны только бинарные файлы");return}const u=[];for(const p of i)u.push({path:p,content:await qv(r,p)});const o={id:Wge(n),name:n,description:t.description?.trim()||void 0,source:t.target,files:Vge(u,t.baseName.trim()),createdAt:new Date().toISOString()},c=t.target==="project"?await c2e(r,o,t.baseName.trim()||void 0):await f2e(o);t.target==="project"&&await ka(),await Lp(),wt(`Шаблон «${c.name}» сохранён (файлов: ${c.files.length}`+(a?`, пропущено бинарных: ${a})`:")"))}catch(s){wt("Не удалось создать шаблон: "+gm(s))}}async function hxe(e,t,r,n){const s=wD();if(!s){wt("Проект не открыт");return}const i=t.trim(),a=XB(r,n,i);if(!a.length){wt("Не выбрано ни одного файла");return}try{const u=await q2(s,e,i),o=Cp(e,u),c=YB(a);let p=null;for(const d of a){const h=await Vg(s,o,d.path,d.content);c&&d.path===c.path&&(p=h)}if(await ka(),c&&p){const d=Cp(o,c.path);await NA(d,d.slice(d.lastIndexOf("/")+1),p,!0)}wt(`Форма «${u}» создана по шаблону «${r.name}»`)}catch(u){wt("Не удалось создать форму: "+gm(u))}}function zk(e){const t=XB(e,e.files.map(n=>n.path),pxe),r=YB(t);if(!r){wt(`В шаблоне «${e.name}» нет схемы формы`);return}try{const n=l_(JSON.parse(r.content));Xe.openTab(`template:${e.source}:${e.id}`,{kind:"template",name:e.name},n,{preview:!0})}catch(n){wt("Не удалось открыть шаблон: "+gm(n))}}async function mxe(e){if(e.source==="builtin")return;const t=wD();try{if(e.source==="project"){if(!t){wt("Проект не открыт");return}await d2e(t,e.id),await ka()}else await m2e(e.id);await Lp(),wt(`Шаблон «${e.name}» удалён`)}catch(r){wt("Не удалось удалить шаблон: "+gm(r))}}async function yxe(e,t){if(e.source==="builtin")return;const r=t.trim();if(!r)return;const n=wD();try{const s={...e,name:r};if(e.source==="project"){if(!n){wt("Проект не открыт");return}await p2e(n,s),await ka()}else await h2e(s);await Lp()}catch(s){wt("Не удалось переименовать шаблон: "+gm(s))}}function qk({template:e,compact:t}){return S.jsxs(S.Fragment,{children:[S.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[S.jsx("span",{className:"block truncate font-medium",children:e.name}),e.description&&!t&&S.jsx("span",{className:"block truncate text-[11px] font-normal text-muted-foreground",children:e.description})]}),S.jsx(o8,{variant:"secondary",className:"h-4 flex-none px-1.5 text-[9px]",children:Mge[e.source]})]})}function gxe({templates:e,value:t,onChange:r,id:n}){const[s,i]=se.useState(!1),a=e.find(u=>u.id===t);return S.jsxs(Zj,{open:s,onOpenChange:i,children:[S.jsx(eO,{asChild:!0,children:S.jsxs(Rr,{id:n,type:"button",variant:"outline",role:"combobox","aria-expanded":s,className:"h-auto w-full justify-between gap-2 py-1.5 font-normal",children:[a?S.jsx(qk,{template:a,compact:!0}):S.jsx("span",{className:"flex-1 truncate text-left text-muted-foreground",children:"Выберите шаблон…"}),S.jsx(PO,{className:"size-4 flex-none opacity-50"})]})}),S.jsx(tO,{align:"start",className:"w-(--radix-popover-trigger-width) p-0",children:S.jsxs(rO,{children:[S.jsx(nO,{placeholder:"Поиск шаблона…"}),S.jsxs(sO,{children:[S.jsx(iO,{children:"Шаблоны не найдены."}),S.jsx(aO,{children:e.map(u=>S.jsxs(oO,{value:`${u.name} ${u.description??""}`,onSelect:()=>{r(u.id),i(!1)},className:"items-start gap-2",children:[S.jsx(x8,{className:Xt("mt-0.5 size-4 flex-none",u.id===t?"opacity-100":"opacity-0")}),S.jsx(qk,{template:u})]},u.id))})]})]})})]})}function Dxe(e){return e.kind==="newTemplate"?"newTemplate:"+e.paths.join("|"):e.kind+":"+("dirPath"in e?e.dirPath:e.path)}function yj({dialog:e,onClose:t}){if(!e)return null;const r=e.kind==="template"||e.kind==="newTemplate";return S.jsx(S2,{open:!0,onOpenChange:n=>{n||t()},children:S.jsx(F2,{className:r?"max-w-lg":"max-w-md",children:S.jsx(xxe,{dialog:e,onClose:t},Dxe(e))})})}function xxe({dialog:e,onClose:t}){return e.kind==="template"?S.jsx(Cxe,{dirPath:e.dirPath,onClose:t}):e.kind==="newTemplate"?S.jsx(Txe,{paths:e.paths,onClose:t}):e.kind==="delete"?S.jsx(vxe,{path:e.path,name:e.name,onClose:t}):S.jsx(bxe,{dialog:e,onClose:t})}function bxe({dialog:e,onClose:t}){const[r,n]=se.useState(e.kind==="rename"?e.currentName:""),s=e.kind==="newFile"?"Новый файл":e.kind==="newFolder"?"Новая папка":"Переименовать",i=()=>{const a=r.trim();a&&(e.kind==="newFile"?T2e(e.dirPath,a):e.kind==="newFolder"?A2e(e.dirPath,a):F2e(e.path,e.entryKind,a),t())};return S.jsxs(S.Fragment,{children:[S.jsx(ho,{children:S.jsx(mo,{children:s})}),S.jsx(Bs,{autoFocus:!0,value:r,onChange:a=>n(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),i())},placeholder:e.kind==="newFolder"?"имя-папки":"имя-файла.ext"}),S.jsxs(Nl,{children:[S.jsx(Rr,{variant:"outline",onClick:t,children:"Отмена"}),S.jsx(Rr,{onClick:i,disabled:!r.trim(),children:e.kind==="rename"?"Переименовать":"Создать"})]})]})}function vxe({path:e,name:t,onClose:r}){return S.jsxs(S.Fragment,{children:[S.jsxs(ho,{children:[S.jsx(mo,{children:"Удалить?"}),S.jsxs(Mp,{children:[S.jsx("span",{className:"font-mono",children:t})," будет удалён безвозвратно (папки — со всем содержимым)."]})]}),S.jsxs(Nl,{children:[S.jsx(Rr,{variant:"outline",onClick:r,children:"Отмена"}),S.jsx(Rr,{variant:"destructive",onClick:()=>{S2e(e),r()},children:"Удалить"})]})]})}function Exe(e){return/^[A-Za-z][A-Za-z0-9]*([-_ ][A-Za-z0-9]+)*$/.test(e.trim())}function Cxe({dirPath:e,onClose:t}){const r=Bg(D=>D.items),[n,s]=se.useState(r[0]?.id??""),i=r.find(D=>D.id===n)??r[0],[a,u]=se.useState(""),[o,c]=se.useState(!1),[p,d]=se.useState({}),h=se.useMemo(()=>p[i?.id??""]??new Set(i?.files.map(D=>D.path)??[]),[p,i]),m=D=>d(x=>({...x,[i.id]:D})),y=D=>{const x=new Set(h);if(x.has(D)){x.delete(D);for(const[E,A]of Object.entries(i.requires??{}))A.includes(D)&&x.delete(E)}else x.add(D);m(GB(x,i.requires))},v=Exe(a),b=v&&h.size>0&&i!=null,T=()=>{b&&(hxe(e,a.trim(),i,h),t())};return S.jsxs(S.Fragment,{children:[S.jsx(ho,{children:S.jsx(mo,{children:"Выбрать шаблон"})}),S.jsxs("div",{className:"min-w-0 space-y-3 py-1",children:[S.jsxs("div",{className:"space-y-1.5",children:[S.jsx(tu,{htmlFor:"tpl-name",children:"Имя формы"}),S.jsx(Bs,{id:"tpl-name",autoFocus:!0,value:a,onChange:D=>u(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),T())},placeholder:"например: user-profile"}),a.trim()&&!v&&S.jsx("p",{className:"text-[11px] text-destructive",children:"Латиница, цифры и дефис: имя попадает в названия компонентов и импорты."})]}),S.jsxs("div",{className:"min-w-0 space-y-1.5",children:[S.jsx(tu,{htmlFor:"tpl-pick",children:"Шаблон"}),S.jsx(gxe,{id:"tpl-pick",templates:r,value:i?.id??"",onChange:s})]}),i&&S.jsxs(uO,{open:o,onOpenChange:c,className:"min-w-0 space-y-1.5",children:[S.jsxs(lO,{className:"flex w-full items-center gap-1 text-left",children:[S.jsx(Rp,{className:Xt("size-3.5 flex-none text-muted-foreground transition-transform",o&&"rotate-90")}),S.jsxs(tu,{className:"cursor-pointer",children:["Файлы (",h.size," из ",i.files.length,")"]})]}),S.jsx(cO,{children:S.jsx("div",{className:"max-h-52 space-y-2 overflow-y-auto rounded-md border border-border p-2",children:i.files.map(D=>S.jsxs("label",{className:"flex min-w-0 cursor-pointer items-center gap-2 text-sm",children:[S.jsx(pO,{className:"flex-none",checked:h.has(D.path),onCheckedChange:()=>y(D.path)}),S.jsx("span",{className:"min-w-0 truncate",children:i.labels?.[D.path]??D.path})]},D.path))})})]})]}),S.jsxs(Nl,{children:[S.jsx(Rr,{variant:"outline",onClick:t,children:"Отмена"}),S.jsx(Rr,{onClick:T,disabled:!b,children:"Создать"})]})]})}function Txe({paths:e,onClose:t}){const[r,n]=se.useState(""),[s,i]=se.useState(""),[a,u]=se.useState(()=>Kge(e)),[o,c]=se.useState("project"),p=()=>{r.trim()&&(fxe(e,{name:r,description:s,baseName:a,target:o}),t())};return S.jsxs(S.Fragment,{children:[S.jsx(ho,{children:S.jsx(mo,{children:"Создать шаблон"})}),S.jsxs("div",{className:"min-w-0 space-y-3 py-1",children:[S.jsxs("div",{className:"space-y-1.5",children:[S.jsx(tu,{htmlFor:"nt-name",children:"Имя шаблона"}),S.jsx(Bs,{id:"nt-name",autoFocus:!0,value:r,onChange:d=>n(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),p())},placeholder:"например: Форма заявки"})]}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsx(tu,{htmlFor:"nt-desc",children:"Описание"}),S.jsx(Bs,{id:"nt-desc",value:s,onChange:d=>i(d.target.value),placeholder:"необязательно"})]}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsx(tu,{htmlFor:"nt-base",children:"Базовое имя (заменяется плейсхолдерами)"}),S.jsx(Bs,{id:"nt-base",value:a,onChange:d=>u(d.target.value),placeholder:"пусто — не заменять"}),a.trim().length>0&&a.trim().length<4&&S.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Короткое имя может совпасть со случайными словами в коде — проверьте результат."})]}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsx(tu,{children:"Где хранить"}),S.jsx("div",{className:"flex gap-2",children:[["project","В проекте (.reformer/templates)"],["local","Локально в браузере"]].map(([d,h])=>S.jsx("button",{type:"button",onClick:()=>c(d),className:Xt("flex-1 rounded-md border px-2 py-1.5 text-left text-xs",o===d?"border-primary bg-accent":"border-border text-muted-foreground hover:bg-muted"),children:h},d))})]}),S.jsx("div",{className:"max-h-32 overflow-y-auto rounded-md border border-border p-2",children:S.jsx("ul",{className:"min-w-0 space-y-0.5 text-[11px] text-muted-foreground",children:e.map(d=>S.jsx("li",{className:"truncate font-mono",children:d},d))})})]}),S.jsxs(Nl,{children:[S.jsx(Rr,{variant:"outline",onClick:t,children:"Отмена"}),S.jsx(Rr,{onClick:p,disabled:!r.trim()||!e.length,children:"Сохранить"})]})]})}function Axe(e,t,r,n,s){if(n<=0||r<=0)return{start:0,end:0};const i=Math.floor(Math.max(e,0)/r),a=Math.ceil(Math.max(t,0)/r)+1,u=Math.max(0,Math.min(i-s,Math.max(0,n-1))),o=Math.min(n,i+a+s);return{start:u,end:Math.max(o,u)}}function Jk(e){return e?e.querySelector('[data-slot="scroll-area-viewport"]')??e:null}function Sxe(e,t,r=8){const n=se.useRef(null),[s,i]=se.useState({scrollTop:0,viewportHeight:0});se.useEffect(()=>{const c=Jk(n.current);if(!c)return;const p=()=>i(h=>h.scrollTop===c.scrollTop&&h.viewportHeight===c.clientHeight?h:{scrollTop:c.scrollTop,viewportHeight:c.clientHeight});p(),c.addEventListener("scroll",p,{passive:!0});const d=new ResizeObserver(p);return d.observe(c),()=>{c.removeEventListener("scroll",p),d.disconnect()}},[]);const a=se.useCallback(c=>{const p=Jk(n.current);if(!p||c<0)return;const d=c*t,h=d+t;d<p.scrollTop?p.scrollTop=d:h>p.scrollTop+p.clientHeight&&(p.scrollTop=h-p.clientHeight)},[t]),{start:u,end:o}=Axe(s.scrollTop,s.viewportHeight,t,e,r);return{scrollRef:n,start:u,end:o,totalHeight:e*t,offsetTop:u*t,scrollToRow:a}}const Ws="",Fxe=24;function vh(e){return{paddingLeft:`${e*12+8}px`}}function vv(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function wxe(e,t){const r=[];let n=1/0;for(const s of e)s.depth>n||(n=1/0,r.push(s),s.kind==="directory"&&!t.has(s.path)&&(n=s.depth));return r}function kxe({entry:e,expanded:t,loading:r,onActivate:n,depthOffset:s=0}){return e.kind==="directory"?S.jsxs("button",{onClick:i=>n(e,i),style:vh(e.depth+s),className:"flex h-6 w-full items-center gap-1 pr-2 text-left text-[11.5px] font-medium text-muted-foreground hover:text-foreground",children:[r?S.jsx(m3,{className:"h-3 w-3 flex-none animate-spin"}):S.jsx(Rp,{className:Xt("h-3 w-3 flex-none transition-transform",t&&"rotate-90")}),S.jsx(u8,{className:"h-3.5 w-3.5 flex-none opacity-70"}),S.jsx("span",{className:"min-w-0 truncate",children:e.name})]}):e.isForm?S.jsxs("button",{onClick:i=>n(e,i),title:e.path,style:vh(e.depth+1+s),className:"flex h-6 w-full items-center gap-1.5 pr-2 text-left text-xs hover:bg-muted",children:[S.jsx(l8,{className:"h-3.5 w-3.5 flex-none text-primary"}),S.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.name}),S.jsx(o8,{variant:e.confidence==="high"?"default":"secondary",className:"h-4 flex-none px-1.5 text-[9px]",children:e.confidence==="high"?"High":"Med"})]}):S.jsxs("button",{onClick:i=>n(e,i),title:`${e.path} — открыть в редакторе (${gr("Mod")}+клик — добавить к выбору)`,style:vh(e.depth+1+s),className:"flex h-6 w-full items-center gap-1.5 pr-2 text-left text-xs text-muted-foreground hover:bg-muted",children:[S.jsx(yO,{className:"h-3.5 w-3.5 flex-none opacity-70"}),S.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.name})]})}function _xe(){const e=Go(L=>L.dirName),t=Go(L=>L.tree),r=Go(L=>L.loadedDirs),n=Go(L=>L.loadingDirs),s=Go(L=>L.scanning),i=Go(L=>L.error),a=Go(L=>L.canReopen),u=Lge(),[o,c]=se.useState(()=>new Set([Ws])),p=L=>{const ne=!o.has(L);c(Ee=>{const X=new Set(Ee);return ne?X.add(L):X.delete(L),X}),ne&&L!==Ws&&D2e(L)},d=se.useMemo(()=>wxe(t,o),[t,o]),h=o.has(Ws),[m,y]=se.useState(null),v=se.useRef(null),[b,T]=se.useState(null),D=se.useMemo(()=>e?h?[Ws,...d.map(L=>L.path)]:[Ws]:[],[e,h,d]),x=se.useMemo(()=>new Map(d.map(L=>[L.path,L])),[d]),E=Sxe(D.length,Fxe),[A,F]=se.useState(null);se.useEffect(()=>{if(A==null)return;const L=v.current?.querySelector(`[data-tree-path="${CSS.escape(A)}"] button`);L&&(L.focus(),F(null))},[A,E.start,E.end]);const k=L=>{T(L),E.scrollToRow(D.indexOf(L)),F(L)},_=L=>{const ne=L.target.closest("[data-tree-path]");ne&&T(ne.dataset.treePath??null)},[O,q]=se.useState(()=>new Set);se.useEffect(()=>{c(new Set([Ws])),q(new Set),T(null)},[e]);const j=(L,ne)=>{const Ee=L.path;if(ne.metaKey||ne.ctrlKey){ne.preventDefault(),q(X=>{const je=new Set(X);return je.has(Ee)?je.delete(Ee):je.add(Ee),je}),T(Ee);return}if(ne.shiftKey){ne.preventDefault();const X=D.indexOf(b??Ee),je=D.indexOf(Ee);if(X!==-1&&je!==-1){const[K,Q]=X<=je?[X,je]:[je,X];q(new Set(D.slice(K,Q+1).filter(ie=>ie!==Ws)))}T(Ee);return}if(q(new Set([Ee])),T(Ee),L.kind==="directory"){p(Ee);return}PA(L,{preview:ne.detail<2})},V=L=>O.has(L.path)&&O.size>1?[...O]:[L.path],z=L=>{const ne=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","F2","Delete","Backspace"],X=(L.metaKey||L.ctrlKey)&&(L.code==="KeyC"||L.code==="KeyV");if(!ne.includes(L.key)&&!X)return;const je=b??D[0];if(je==null)return;L.preventDefault(),L.stopPropagation();const K=je===Ws,Q=K?null:x.get(je),ie=K||Q?.kind==="directory",M=K?h:Q?o.has(Q.path):!1,B=D.indexOf(je);if(X){L.code==="KeyV"?Tk(ie?je:vv(je)):Q&&Ck(V(Q));return}const U=J=>{const de=D[Math.min(Math.max(B+J,0),D.length-1)];de!=null&&k(de)};L.key==="ArrowDown"?U(1):L.key==="ArrowUp"?U(-1):L.key==="ArrowRight"?ie&&!M?p(je):ie&&M&&U(1):L.key==="ArrowLeft"?ie&&M?p(je):k(K?Ws:vv(je)):L.key==="F2"&&Q?y({kind:"rename",path:Q.path,entryKind:Q.kind,currentName:Q.name}):(L.key==="Delete"||L.key==="Backspace")&&Q&&y({kind:"delete",path:Q.path,name:Q.name})};se.useEffect(()=>{v2e()},[]);const oe=(L,ne,Ee)=>{const X=Ee==="root"?null:Ee,je=Ee==="root"?Ws:Ee.path,K=X?X.kind==="directory"?X.path:vv(X.path):"";return S.jsxs(l3,{children:[S.jsx(c3,{asChild:!0,children:S.jsx("div",{"data-tree-path":je,className:Xt("h-6 focus-within:ring-1 focus-within:ring-ring",(b===je||O.has(je))&&"bg-accent"),children:ne})}),S.jsxs(p3,{className:"w-56",children:[X?.kind==="file"&&WN(X.name)&&S.jsxs(S.Fragment,{children:[S.jsx(sn,{onClick:()=>void Ek(X,"preview"),children:"Открыть предпросмотр"}),S.jsx(sn,{onClick:()=>void Ek(X,"split"),children:"Открыть предпросмотр рядом"}),S.jsx(Kc,{})]}),X&&S.jsxs(sn,{onClick:()=>Ck(V(X)),children:[O.has(X.path)&&O.size>1?`Копировать (${O.size})`:"Копировать",S.jsx(KA,{children:gr("Mod+C")})]}),S.jsxs(sn,{disabled:!u.length,onClick:()=>void Tk(K),children:[u.length>1?`Вставить (${u.length})`:"Вставить",S.jsx(KA,{children:gr("Mod+V")})]}),S.jsx(Kc,{}),S.jsx(sn,{onClick:()=>y({kind:"newFile",dirPath:K}),children:"Новый файл…"}),S.jsx(sn,{onClick:()=>y({kind:"newFolder",dirPath:K}),children:"Новая папка…"}),X&&S.jsx(sn,{onClick:()=>y({kind:"newTemplate",paths:V(X)}),children:O.has(X.path)&&O.size>1?`Создать шаблон (${O.size})…`:"Создать шаблон…"}),S.jsxs(fO,{children:[S.jsx(hO,{children:"Сгенерировать"}),S.jsxs(mO,{children:[S.jsx(sn,{onClick:()=>y({kind:"template",dirPath:K}),children:"Выбрать шаблон…"}),S.jsx(Kc,{}),S.jsx(sn,{onClick:()=>void k2e(K),children:"Модель"}),S.jsx(sn,{onClick:()=>void _2e(K),children:"Схема формы"}),S.jsx(sn,{onClick:()=>void P2e(K),children:"Схема валидации"}),S.jsx(sn,{onClick:()=>void N2e(K),children:"Поведение формы"}),S.jsx(sn,{onClick:()=>void $2e(K),children:"Поведение UI"})]})]}),X&&S.jsxs(S.Fragment,{children:[S.jsx(Kc,{}),S.jsx(sn,{onClick:()=>y({kind:"rename",path:X.path,entryKind:X.kind,currentName:X.name}),children:"Переименовать…"}),S.jsx(sn,{className:"text-destructive focus:text-destructive",onClick:()=>y({kind:"delete",path:X.path,name:X.name}),children:"Удалить"})]})]})]},L)};return S.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[a&&!e&&S.jsx("div",{className:"flex flex-col gap-1.5 border-b border-border p-2",children:S.jsxs(Rr,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-xs",onClick:()=>void b2e(),children:[S.jsx(d3,{className:"h-3.5 w-3.5"})," Переоткрыть проект"]})}),S.jsxs(f3,{ref:E.scrollRef,className:"min-h-0 flex-1 py-1.5",children:[S.jsxs("div",{ref:v,onKeyDown:z,onFocus:_,className:"outline-none",children:[e&&S.jsx("div",{style:{height:E.totalHeight},children:S.jsx("div",{style:{transform:`translateY(${E.offsetTop}px)`},children:D.slice(E.start,E.end).map(L=>{if(L===Ws)return oe("root",S.jsxs("button",{onClick:()=>p(Ws),title:e,style:vh(0),className:"flex h-6 w-full items-center gap-1 pr-2 text-left text-[11.5px] font-semibold text-foreground hover:bg-muted",children:[S.jsx(Rp,{className:Xt("h-3 w-3 flex-none transition-transform",h&&"rotate-90")}),h?S.jsx(dO,{className:"h-3.5 w-3.5 flex-none opacity-80"}):S.jsx(u8,{className:"h-3.5 w-3.5 flex-none opacity-80"}),S.jsx("span",{className:"min-w-0 truncate",children:e}),s&&S.jsx("span",{className:"flex-none text-[10px] font-normal text-muted-foreground",children:"· сканирую…"})]}),"root");const ne=x.get(L);return ne?oe(ne.path,S.jsx(kxe,{entry:ne,depthOffset:1,expanded:o.has(ne.path),loading:n.has(ne.path),onActivate:j}),ne):null})})}),e&&h&&i&&S.jsxs("div",{className:"mx-1 rounded-md border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[11px] text-destructive",children:["Ошибка сканирования: ",i]}),e&&h&&!s&&!i&&r.has(Ws)&&!t.length&&S.jsx("div",{style:vh(1),className:"py-1 text-[11px] text-muted-foreground",children:"Каталог пуст."})]}),!zv()&&S.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-muted-foreground",children:"Открытие проекта требует Chromium (File System Access API). Создать форму — меню «Файл → Новая форма»."})]}),S.jsx(yj,{dialog:m,onClose:()=>y(null)})]})}const Pxe=["HTML","Типографика","Оверлеи","Навигация","Чат"],Kk="Части",Nxe={div:"div",section:"sec",article:"art",aside:"as",header:"hd",footer:"ft",nav:"nav",main:"mn",fieldset:"fs",ul:"ul",ol:"ol",li:"li",hr:"hr",img:"img",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",p:"p",span:"sp",strong:"b",em:"i",small:"sm",blockquote:"bq",code:"cd",pre:"pre",a:"a",label:"lb",br:"br"},$xe={Input:"In",InputPassword:"Ip",InputMask:"Im",InputOTP:"Io",Textarea:"Tx",DatePicker:"Dt",Calendar:"Ca",FileUpload:"Up",FileUploadAvatar:"Av",Select:"Se",NativeSelect:"Ns",Combobox:"Cb",RadioGroup:"Rg",Checkbox:"Ck",Switch:"Sw",Slider:"Sl",Toggle:"Tg",ToggleGroup:"Tg",Box:"Bx",Section:"Sc",FormArray:"Fa"};function Ixe(e){const t=Ca().palette?.glyphs?.[e.name];if(t)return t;const r=T_(e.name);return r?Nxe[r]??r.slice(0,3):$xe[e.name]??(e.name[0]?.toUpperCase()??"")+(e.name[1]?.toLowerCase()??"")}function Bxe(e,t){const r=t.trim().toLowerCase(),n=r?e.filter(s=>s.name.toLowerCase().includes(r)):e.filter(s=>!W3(s));return A_(n3(n))}function jxe(e,t){let r=t;for(;r&&r.length;){const n=Kh(e,r),s=Mt(n?.component);if(s?.op==="component"&&B2(s.arg).length)return s.arg;r=Pn(r)}return null}function Oxe(e,t){let r=t;for(;r&&r.length;){const n=Kh(e,r);if(n&&!xp(n)&&ns(n))return[...r,"children"];r=Pn(r)}return!xp(e.root)&&ns(e.root)?["root","children"]:null}function Vk({title:e,items:t,open:r,onToggle:n,onPick:s}){return S.jsxs("div",{className:"border-b border-border",children:[S.jsxs("button",{type:"button",onClick:n,className:"flex w-full items-center gap-1.5 px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",children:[S.jsx(Rp,{className:`h-3 w-3 flex-none transition-transform ${r?"rotate-90":""}`}),S.jsx("span",{className:"min-w-0 flex-1 truncate",children:e}),S.jsx("span",{className:"flex-none font-mono text-[10px] font-normal text-muted-foreground/50",children:t.length})]}),r&&S.jsx("div",{className:"flex flex-col gap-0.5 px-2 pb-2",children:t.map(i=>S.jsxs("button",{draggable:!0,onDragStart:a=>{jA({kind:"new",entryName:i.name}),a.dataTransfer.effectAllowed="copy"},onDragEnd:()=>OA(),onClick:()=>s(i),className:"flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-[12.5px] hover:bg-muted",children:[S.jsx("span",{className:"grid h-5 min-w-5 flex-none place-items-center rounded border border-border bg-background px-1 font-mono text-[9px] font-semibold text-muted-foreground",children:Ixe(i)}),S.jsx("span",{className:"min-w-0 flex-1 truncate",children:H3(i)}),S.jsx(u3,{className:"h-3.5 w-3.5 flex-none text-muted-foreground/40"})]},i.name))})]})}function Lxe(){const[e,t]=se.useState(""),r=Ta(),n=se.useMemo(()=>Bxe(r,e),[r,e]),s=I2(),i=jl(),a=se.useMemo(()=>i?jxe(i.schema,s):null,[i,s]),u=se.useMemo(()=>a&&!e.trim()?B2(a):[],[a,e]),[o,c]=se.useState(()=>{const m=Ca().palette?.collapsedByDefault??Pxe;return Object.fromEntries(m.map(y=>[y,!0]))}),p=m=>c(y=>({...y,[m]:!y[m]})),d=m=>e.trim()?!0:!o[m],h=m=>{const y=mt.getState(),v=y.activeTabId?y.tabs[y.activeTabId]:null;if(!v)return;const b=Oxe(v.schema,v.selectionPath)??["root","children"];Xe.apply(T=>nR(T,b,m.makeNode()))};return S.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[S.jsx("div",{className:"border-b border-border p-2",children:S.jsx(Bs,{value:e,onChange:m=>t(m.target.value),placeholder:"Поиск компонента…",className:"h-8 text-xs"})}),S.jsxs(f3,{className:"flex-1",children:[u.length>0&&a&&S.jsx(Vk,{title:`Части: ${a}`,items:u,open:d(Kk),onToggle:()=>p(Kk),onPick:h}),n.map(([m,y])=>S.jsx(Vk,{title:m,items:y,open:d(m),onToggle:()=>p(m),onPick:h},m))]})]})}function Mxe(){const e=Bg(h=>h.items),t=Bg(h=>h.loading),r=Bg(h=>h.error),n=Go(h=>h.dirName),[s,i]=se.useState(null),[a,u]=se.useState(null),[o,c]=se.useState({}),p=h=>c(m=>({...m,[h]:!m[h]})),d=se.useMemo(()=>Rge.map(h=>[h,e.filter(m=>m.source===h.source)]).filter(([,h])=>h.length>0),[e]);return se.useEffect(()=>{Lp()},[]),S.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[S.jsxs("div",{className:"flex flex-none items-center justify-between gap-2 border-b border-border px-2 py-1.5",children:[S.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:n?`Проект: ${n}`:"Проект не открыт — только локальные"}),S.jsxs(Rr,{variant:"ghost",size:"sm",className:"h-6 gap-1 px-1.5 text-[11px]",onClick:()=>void Lp(),disabled:t,children:[S.jsx(d3,{className:"h-3 w-3"})," Обновить"]})]}),S.jsxs(f3,{className:"flex-1 py-1.5",children:[r&&S.jsxs("div",{className:"mx-1 rounded-md border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[11px] text-destructive",children:["Ошибка чтения шаблонов: ",r]}),d.map(([{source:h,title:m},y])=>{const v=!o[h];return S.jsxs("div",{className:"border-b border-border last:border-b-0",children:[S.jsxs("button",{type:"button",onClick:()=>p(h),className:"flex w-full items-center gap-1.5 px-3 py-2 text-left text-[10px] font-semibold tracking-wider text-muted-foreground uppercase hover:text-foreground",children:[S.jsx(Rp,{className:Xt("h-3 w-3 flex-none transition-transform",v&&"rotate-90")}),S.jsx("span",{className:"min-w-0 flex-1 truncate",children:m}),S.jsx("span",{className:"flex-none font-mono text-[10px] font-normal text-muted-foreground/50",children:y.length})]}),v&&S.jsx("div",{className:"flex flex-col gap-0.5 px-2 pb-2",children:y.map(b=>S.jsxs(l3,{children:[S.jsx(c3,{asChild:!0,children:S.jsxs("button",{onClick:()=>zk(b),title:`${b.description??b.name} · ${b.files.length} файлов — клик открывает предпросмотр`,className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-xs hover:bg-muted",children:[S.jsx(l8,{className:"h-3.5 w-3.5 flex-none text-primary"}),S.jsx("span",{className:"min-w-0 flex-1 truncate",children:b.name})]})}),S.jsxs(p3,{className:"w-52",children:[S.jsx(sn,{onClick:()=>zk(b),children:"Открыть предпросмотр"}),S.jsx(sn,{onClick:()=>u({kind:"template",dirPath:""}),children:"Создать форму…"}),b.source!=="builtin"&&S.jsxs(S.Fragment,{children:[S.jsx(Kc,{}),S.jsx(sn,{onClick:()=>i({kind:"rename",template:b}),children:"Переименовать…"}),S.jsx(sn,{className:"text-destructive focus:text-destructive",onClick:()=>i({kind:"delete",template:b}),children:"Удалить"})]})]})]},`${b.source}:${b.id}`))})]},h)}),!e.length&&!t&&S.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-muted-foreground",children:"Шаблонов нет. Выделите файлы формы в дереве и выберите «Создать шаблон…»."})]}),S.jsx(Rxe,{dialog:s,onClose:()=>i(null)}),S.jsx(yj,{dialog:a,onClose:()=>u(null)})]})}function Rxe({dialog:e,onClose:t}){return e?S.jsx(S2,{open:!0,onOpenChange:r=>{r||t()},children:S.jsx(F2,{className:"max-w-md",children:e.kind==="rename"?S.jsx(Uxe,{template:e.template,onClose:t},e.template.id):S.jsx(zxe,{template:e.template,onClose:t})})}):null}function Uxe({template:e,onClose:t}){const[r,n]=se.useState(e.name),s=()=>{r.trim()&&(yxe(e,r),t())};return S.jsxs(S.Fragment,{children:[S.jsxs(ho,{children:[S.jsx(mo,{children:"Переименовать шаблон"}),S.jsx(Mp,{children:"Меняется только отображаемое имя — папка шаблона остаётся прежней."})]}),S.jsx(Bs,{autoFocus:!0,value:r,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),s())}}),S.jsxs(Nl,{children:[S.jsx(Rr,{variant:"outline",onClick:t,children:"Отмена"}),S.jsx(Rr,{onClick:s,disabled:!r.trim(),children:"Переименовать"})]})]})}function zxe({template:e,onClose:t}){return S.jsxs(S.Fragment,{children:[S.jsxs(ho,{children:[S.jsx(mo,{children:"Удалить шаблон?"}),S.jsxs(Mp,{children:["«",e.name,"»"," ",e.source==="project"?"будет удалён вместе с папкой в проекте.":"будет удалён из локального хранилища браузера."]})]}),S.jsxs(Nl,{children:[S.jsx(Rr,{variant:"outline",onClick:t,children:"Отмена"}),S.jsx(Rr,{variant:"destructive",onClick:()=>{mxe(e),t()},children:"Удалить"})]})]})}function qxe(e){const t=e.trim();if(t==="")return;const r=Number(t);return Number.isFinite(r)?r:void 0}function Jxe(e){return e===""?void 0:e}const Kxe=24;function Vxe({node:e,path:t,prop:r,classes:n}){const i=(e.componentProps??{})[r.key],a=typeof i=="string"?i:"",u=se.useRef(null),[o,c]=se.useState(!1),[p,d]=se.useState(a.length),[h,m]=se.useState(0),y=j=>Xe.apply(V=>N2(V,t,r.key,j.trim()?j:void 0),{coalesceKey:`${r.key}@${t.join(".")}`}),v=Math.min(p,a.length),b=a.slice(0,v).search(/\S*$/),T=v+(a.slice(v).match(/^\S*/)?.[0].length??0),D=a.slice(b,v),x=new Set(a.split(/\s+/).filter(Boolean)),E=OU(n,D,x,Kxe),A=o&&E.length>0,F=jU(BU(),a),k=E.length?Math.min(h,E.length-1):0,_=()=>d(u.current?.selectionStart??a.length),O=j=>{const V=a.slice(0,b),z=a.slice(T),oe=j+(z.startsWith(" ")?"":" "),L=V+oe+z,ne=V.length+oe.length;y(L),d(ne),m(0),requestAnimationFrame(()=>{const Ee=u.current;Ee&&(Ee.focus(),Ee.setSelectionRange(ne,ne))})},q=j=>{j.key==="ArrowDown"&&A?(j.preventDefault(),j.stopPropagation(),m(V=>Math.min(V+1,E.length-1))):j.key==="ArrowUp"&&A?(j.preventDefault(),j.stopPropagation(),m(V=>Math.max(V-1,0))):(j.key==="Enter"||j.key==="Tab")&&A?(j.preventDefault(),j.stopPropagation(),O(E[k])):j.key==="Escape"&&o&&(j.preventDefault(),j.stopPropagation(),c(!1))};return S.jsxs("div",{className:"flex min-h-6 items-center gap-2.5",children:[S.jsx("span",{className:"w-24 flex-none truncate text-xs",title:r.description,children:r.label}),S.jsxs("div",{className:"relative min-w-0 flex-1",children:[S.jsx("input",{ref:u,value:a,spellCheck:!1,autoComplete:"off",placeholder:"flex gap-4 …",onChange:j=>{y(j.target.value),d(j.target.selectionStart??j.target.value.length),c(!0),m(0)},onKeyDown:q,onSelect:_,onFocus:()=>c(!0),onBlur:()=>c(!1),className:Xt("h-[26px] w-full rounded-md border border-input bg-background px-2 font-mono text-[11px] outline-none focus:border-ring",F.length&&"pr-6")}),F.length>0&&S.jsx("span",{className:"absolute top-1/2 right-1.5 -translate-y-1/2",title:`Нет в словаре кита: ${F.join(", ")}.
|
|
1133
|
+
`)}function oDe(e){const t=se.useRef(null),r=se.useRef(""),n=s=>{const i=s?r3(e,s,iDe):"";i!==r.current&&(r.current=i,t.current&&(t.current.textContent=i))};return se.useEffect(()=>()=>{r.current="",t.current&&(t.current.textContent="")},[]),{hoverRef:t,setHoverPath:n}}function uDe({scope:e,selectionPath:t,selectionPaths:r,hoverRef:n}){return S.jsxs(S.Fragment,{children:[S.jsx("style",{children:aDe(e,t,r)}),S.jsx("style",{ref:n})]})}function lDe({overlayRef:e}){return S.jsxs("div",{ref:e,className:"pointer-events-none absolute inset-0 z-20 hidden",children:[S.jsx("div",{"data-part":"box",className:"absolute rounded-[3px]",style:{display:"none"}}),S.jsx("div",{"data-part":"chip",className:"absolute rounded-full bg-[var(--rb-select)] px-1.5 py-px text-[9px] font-semibold whitespace-nowrap text-[var(--rb-select-fg)] shadow-sm",style:{display:"none"}})]})}const Ic=3;function Pk(e,t,r){if(!e||!t)return;const n=e.querySelector('[data-part="box"]'),s=e.querySelector('[data-part="chip"]');if(!n||!s)return;if(!r){e.classList.add("hidden"),n.style.display="none",s.style.display="none";return}const i=t.getBoundingClientRect(),a=r.rect.left-i.left,u=r.rect.top-i.top,{width:o,height:c}=r.rect;e.classList.remove("hidden"),n.style.display="block";const p=lj(r.zone,r.horizontalParent);if(p===null)Object.assign(n.style,{left:`${a}px`,top:`${u}px`,width:`${o}px`,height:`${c}px`,background:"color-mix(in oklab, var(--rb-select) 8%, transparent)",outline:"2px solid var(--rb-select)",outlineOffset:"-1px"});else{const y=p==="top"||p==="bottom";Object.assign(n.style,{left:`${p==="right"?a+o-Ic/2:a-(y?0:Ic/2)}px`,top:`${p==="bottom"?u+c-Ic/2:u-(y?Ic/2:0)}px`,width:`${y?o:Ic}px`,height:`${y?Ic:c}px`,background:"var(--rb-select)",outline:"none"})}if(!oj.has(r.zone)){s.style.display="none";return}const d=r.zone==="stack-before"||r.zone==="stack-after";s.textContent=d?"↓ столбец":"→ ряд",s.style.display="block",s.style.transform="translate(-50%, -50%)";const h=a+o/2,m=u+c/2;switch(r.zone){case"beside-before":Object.assign(s.style,{left:`${a}px`,top:`${m}px`});break;case"beside-after":Object.assign(s.style,{left:`${a+o}px`,top:`${m}px`});break;case"stack-before":Object.assign(s.style,{left:`${h}px`,top:`${u}px`});break;default:Object.assign(s.style,{left:`${h}px`,top:`${u+c}px`})}}const E2=`[class*="${Sh}"]`;function ul(e,t){let r=e instanceof Element?e.closest(E2):null;for(;r instanceof HTMLElement;){const n=Cq(r.getAttribute("class")??""),s=n?Eq(n):null,i=s?Pr(t,s):void 0;if(s&&an(i))return{path:s,node:i,element:r};r=r.parentElement?.closest(E2)??null}return null}function cDe(e,t){return e.querySelector(`.${CSS.escape(O2(t))}`)}function Nk(e,t,r,n){const s=ul(t,e);if(!s)return null;const i=s.path.length===1&&s.path[0]==="root",a=Pn(s.path),u=a?Pr(e,a):void 0,o=u?Th(u):"vertical",c=!i&&s.path[s.path.length-2]==="children",p=s.element.getBoundingClientRect(),d=uj({x:r,y:n},p,s.node,o,c);return{path:s.path,zone:d,rect:p,horizontalParent:o==="horizontal"}}const pDe=O2(["root"]),dDe=se.memo(function({schema:t,registry:r,model:n,form:s,renderBehavior:i}){const a=Hz(),u=S.jsx(X8,{settings:{registry:r},children:S.jsx(Lz,{form:s,children:S.jsx(r_,{schema:t,model:n,renderBehavior:i,validateSchema:!1})})});return S.jsx(eDe,{resetKey:t,children:a?se.createElement(a,null,u):u})});function fDe({schema:e,annotated:t,mock:r,mode:n,selectionPath:s,selectionPaths:i=[],live:a}){const u=se.useRef(null),o=se.useRef(null),c=se.useId().replace(/[^a-zA-Z0-9_-]/g,""),p=`[data-rb-scope="${c}"]`,{hoverRef:d,setHoverPath:h}=oDe(p),m=se.useMemo(()=>{if(a)return{bundle:a,error:null};try{return{bundle:yq(t,r),error:null}}catch(k){return{bundle:null,error:k instanceof Error?k.message:String(k)}}},[t,r,a]);se.useEffect(()=>(_S(m.bundle?.model??null),()=>_S(null)),[m.bundle]);const y=n==="edit";se.useEffect(()=>{y||h(null)},[y,h]),se.useEffect(()=>{!y||!s||!u.current||cDe(u.current,s)?.scrollIntoView({block:"nearest",inline:"nearest"})},[y,s]),se.useEffect(()=>{},[e,y,m]);const v=se.useCallback(k=>{if(!y)return;const _=ul(k.target,e);_&&(k.shiftKey?Xe.extendSelectionTo(_.path):k.metaKey||k.ctrlKey?Xe.toggleSelectionAt(_.path):Xe.select(_.path),u.current?.focus({preventScroll:!0}))},[y,e]),b=se.useCallback(k=>{if(!y)return;const _=ul(k.target,e);_&&Xe.revealRawLine(v2(e,[..._.path])??1)},[y,e]),T=se.useCallback(k=>{y&&h(ul(k.target,e)?.path??null)},[y,e,h]),D=se.useCallback(()=>{Pk(o.current,u.current,null)},[]),x=se.useCallback(k=>{if(!y)return;const _=ul(k.target,e);if(!_||_.path.length===1&&_.path[0]==="root"){k.preventDefault();return}jA({kind:"move",path:_.path}),k.dataTransfer.effectAllowed="move",h(null)},[y,e,h]),E=se.useCallback(k=>{const _=y?ZE():null;if(!_)return;const O=Nk(e,k.target,k.clientX,k.clientY);O&&(k.preventDefault(),k.dataTransfer.dropEffect=_.kind==="move"?"move":"copy",Pk(o.current,u.current,O))},[y,e]),A=se.useCallback(k=>{if(!y||!ZE())return;const _=Nk(e,k.target,k.clientX,k.clientY);D(),_&&(k.preventDefault(),k.stopPropagation(),e3(e,_.path,_.zone))},[y,e,D]),F=se.useCallback(k=>{const _=k.relatedTarget;_ instanceof Node&&u.current?.contains(_)||D()},[D]);return se.useEffect(()=>{const k=u.current;if(!k)return;if(!y){k.querySelectorAll(E2).forEach(j=>j.draggable=!1);return}let _=0;const O=()=>{_=0,k.querySelectorAll(E2).forEach(j=>{if(j.draggable=!j.classList.contains(pDe),j.classList.contains(K_)&&!j.dataset.rbLabel){const V=ul(j,e);V&&(j.dataset.rbLabel=FD(V.node))}})};O();const q=new MutationObserver(()=>{_===0&&(_=requestAnimationFrame(O))});return q.observe(k,{childList:!0,subtree:!0}),()=>{q.disconnect(),_!==0&&cancelAnimationFrame(_)}},[y,m]),m.error!==null?S.jsxs("div",{className:"rounded-lg border border-destructive/40 bg-destructive/5 p-4 text-sm text-destructive",children:[S.jsx("div",{className:"font-medium",children:"Схема не сконвертировалась"}),S.jsx("div",{className:"mt-1 font-mono text-xs opacity-80",children:m.error})]}):S.jsxs("div",{ref:u,"data-rb-preview":n,"data-rb-scope":c,tabIndex:-1,className:"relative outline-none",onClick:v,onDoubleClick:b,onMouseMove:T,onMouseLeave:()=>h(null),onDragStart:x,onDragEnd:()=>{OA(),D()},onDragOver:E,onDragLeave:F,onDrop:A,children:[y&&S.jsxs(S.Fragment,{children:[S.jsx(uDe,{scope:p,selectionPath:s,selectionPaths:i,hoverRef:d}),S.jsx(lDe,{overlayRef:o})]}),S.jsx(dDe,{schema:t,registry:m.bundle.registry,model:m.bundle.model,form:m.bundle.form,renderBehavior:a?.renderBehavior})]})}const hDe=se.lazy(()=>Pl(()=>import("./RawJsonEditor-D5mwkIJa.js"),__vite__mapDeps([9,2,3,10,11,12,4,5,1,6,8,7])));function pj({schema:e}){const{theme:t,revealLine:r,revealNonce:n}=vi(),[s,i]=se.useState(()=>ch(e)),a=se.useRef(!1),u=se.useRef(e);u.current=e,se.useEffect(()=>{a.current||i(ch(e))},[e]),se.useEffect(()=>{if(!a.current)return;const c=setTimeout(()=>{try{const p=JSON.parse(s);P2(p)&&Xe.replaceSchema(p)}catch{}},500);return()=>clearTimeout(c)},[s]);const o=c=>{a.current=c,c||i(ch(u.current))};return S.jsx(se.Suspense,{fallback:S.jsx("div",{className:"grid h-full place-items-center text-xs text-muted-foreground",children:"Загрузка редактора…"}),children:S.jsx(hDe,{value:s,theme:t,onChange:i,onFocusChange:o,revealLine:r,revealNonce:n})})}const mDe=se.lazy(()=>Pl(()=>import("./RawJsonEditor-D5mwkIJa.js"),__vite__mapDeps([9,2,3,10,11,12,4,5,1,6,8,7])));function yDe({tab:e,section:t}){const{theme:r}=vi(),n=se.useMemo(()=>gD(Ep(e.schema),t),[e.schema,t]),s=e.mock?.[t],[i,a]=se.useState(s??n),u=se.useRef(!1),[o,c]=se.useState({text:s,synthDoc:n});!u.current&&(o.text!==s||o.synthDoc!==n)&&(c({text:s,synthDoc:n}),a(s??n)),se.useEffect(()=>{if(!u.current)return;const d=setTimeout(()=>{try{JSON.parse(i),Xe.setMockText(e.id,t,i)}catch{}},500);return()=>clearTimeout(d)},[i,e.id,t]);const p=d=>{u.current=d};return S.jsx(se.Suspense,{fallback:S.jsx("div",{className:"grid h-full place-items-center text-xs text-muted-foreground",children:"Загрузка редактора…"}),children:S.jsx(mDe,{value:i,theme:r,onChange:a,onFocusChange:p})})}function gDe(e){return typeof e=="object"&&e!==null&&"value"in e}function dj(e,t,r){const n=r.reduce((s,i)=>s==null?s:s[i],e);return gDe(n)?n.value:t!==null&&typeof t=="object"&&!Array.isArray(t)?Object.fromEntries(Object.keys(t).map(s=>[s,dj(e,t[s],[...r,s])])):n??t}function DDe(e,t){if(e)try{return JSON.parse(e)}catch{}return Ep(t).model}function xDe({tab:e}){const t=se.useSyncExternalStore(Dq,gq),r=e.mock?.model,n=e.schema,s=se.useMemo(()=>DDe(r,n),[r,n]),[i,a]=se.useState(""),u=se.useRef(0);return se.useEffect(()=>{if(!t)return;const o=gp(()=>{const c=JSON.stringify(dj(t,s,[]),null,2);cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>a(c))});return()=>{cancelAnimationFrame(u.current),o()}},[t,s]),t?S.jsx("pre",{className:"h-full overflow-auto px-3 py-2 font-mono text-[12px] leading-[1.5] text-foreground",children:i}):S.jsx("div",{className:"grid h-full place-items-center px-4 text-center text-[12px] text-muted-foreground",children:"Живые значения появятся, когда превью запущено: переключите режим на «Renderer»."})}function $k(e){return typeof e=="object"&&e!==null&&"value"in e}function LA(e,t=""){if(e===null||typeof e!="object"||Array.isArray(e))return t?[t]:[];const r=[];for(const[n,s]of Object.entries(e))r.push(...LA(s,t?`${t}.${n}`:n));return r}function bDe(e){return e===""||e===null||e===void 0?"—":typeof e=="string"?e.length>60?`${e.slice(0,57)}…`:e:typeof e=="number"||typeof e=="boolean"?String(e):Array.isArray(e)?`[${e.length}]`:e instanceof Date?e.toISOString().slice(0,10):"{…}"}function vDe(e,t){const r=t.split(".").reduce((u,o)=>u==null?u:u[o],e),n=$k(r)?r.value:void 0,s=$k(r)?g8(r):void 0,i=[];let a=[];return s?(s.invalid.value&&i.push("invalid"),s.touched.value&&i.push("touched"),s.dirty.value&&i.push("dirty"),s.disabled.value&&i.push("disabled"),s.pending.value&&i.push("pending"),a=s.errors.value.map(u=>({code:String(u.code??"error"),message:String(u.message??"")}))):i.push("нет form-node"),{path:t,display:bDe(n),flags:i,errors:a}}const Ik=200,EDe=()=>new Date().toTimeString().slice(0,8);function CDe(e,t){const r=t.split(".").reduce((n,s)=>n==null?n:n[s],e);return r&&typeof r=="object"&&"value"in r?r.value:void 0}function TDe(e,t){const r=t.split(".").reduce((s,i)=>s==null?s:s[i],e),n=r&&typeof r=="object"&&"value"in r?g8(r):void 0;return n?n.errors.value.map(s=>`${String(s.code??"")}: ${String(s.message??"")}`).join(" | "):""}function ADe(e){if(!e)return null;const t=document.activeElement;if(!(t instanceof Element)||!t.closest("[data-rb-preview]"))return null;const r=ul(t,e);if(!r||!ni(r.node))return null;const n=Mt(r.node.value);return n?.op==="model"?n.arg:null}function SDe(){const t=se.useSyncExternalStore(yd,md).bundle,[r,n]=se.useState([]),s=se.useRef(0),i=se.useCallback(u=>{if(u.length===0)return;const o=EDe();n(c=>{const p=[...u.map(d=>({...d,id:++s.current,at:o})),...c];return p.length>Ik?p.slice(0,Ik):p})},[]);se.useEffect(()=>{if(!t)return;n([]);const u=LA(t.model.get()),o={values:new Map,errors:new Map};let c=!1;return gp(()=>{const d=new Map,h=new Map;for(const v of u)d.set(v,CDe(t.model,v)),h.set(v,TDe(t.model,v));if(!c){c=!0,o.values=d,o.errors=h;return}const m=ADe($i(mt.getState())?.schema),y=[];for(const v of u){const b=o.values.get(v),T=d.get(v);Object.is(b,T)||y.push({kind:v===m?"input":"derived",path:v,detail:`${Bk(b)} → ${Bk(T)}`});const D=o.errors.get(v)??"",x=h.get(v)??"";D!==x&&y.push(x?{kind:"error",path:v,detail:x}:{kind:"resolved",path:v,detail:D})}o.values=d,o.errors=h,i(y)})},[t,i]),se.useEffect(()=>{const u=t?.validation;if(!t||!u)return;let o=!1;return gp(()=>{const p=u.validating.value,d=t.form.errors.value.length;o&&!p&&i([{kind:"validation",path:"",detail:d>0?`завершена, ошибок: ${d}`:"завершена, форма валидна"}]),o=p})},[t,i]);const a=se.useCallback(()=>n([]),[]);return{entries:r,clear:a}}function Bk(e){return e===""||e===null||e===void 0?"∅":typeof e=="string"?e.length>24?`"${e.slice(0,21)}…"`:`"${e}"`:Array.isArray(e)?`[${e.length}]`:typeof e=="object"?"{…}":String(e)}function FDe(){const e=se.useSyncExternalStore(yd,md),[t,r]=se.useState("fields");return e.status==="off"?S.jsx(xh,{children:"Схемы формы не исполняются. Включите «Схемы формы» в панели Renderer — валидация, поведение и реестр из каталога заработают на живой форме."}):e.status==="unavailable"?S.jsx(xh,{children:"Каталог формы недоступен: исполнять нечего. Откройте форму из проекта — рядом со схемой должны лежать model.ts / validation.ts / form.behavior.ts."}):e.status==="loading"?S.jsx(xh,{children:"Собираем схемы формы…"}):S.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[S.jsx(wDe,{}),S.jsxs("div",{className:"flex flex-none gap-0.5 border-b border-border px-2 py-1 text-[11.5px]",children:[S.jsx(xv,{active:t,value:"fields",onSelect:r,children:"Поля"}),S.jsx(xv,{active:t,value:"log",onSelect:r,children:"Лог"}),S.jsxs(xv,{active:t,value:"build",onSelect:r,children:["Сборка",e.errors.length>0?` · ${e.errors.length}`:""]})]}),S.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[t==="fields"&&S.jsx(kDe,{}),t==="log"&&S.jsx(_De,{}),t==="build"&&S.jsx(NDe,{})]})]})}function xh({children:e}){return S.jsx("div",{className:"grid h-full place-items-center px-6 text-center text-[12px] text-muted-foreground",children:S.jsx("p",{className:"max-w-md",children:e})})}function xv({active:e,value:t,onSelect:r,children:n}){return S.jsx("button",{onClick:()=>r(t),className:Xt("rounded px-2 py-0.5",e===t?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted"),children:n})}function wDe(){const t=se.useSyncExternalStore(yd,md).bundle,[r,n]=se.useState({valid:!0,errors:0,validating:!1}),s=se.useRef(0);return se.useEffect(()=>{if(!t)return;const i=gp(()=>{const a={valid:t.form.valid.value,errors:t.form.errors.value.length,validating:t.validation?.validating.value??!1};cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>n(a))});return()=>{cancelAnimationFrame(s.current),i()}},[t]),t?S.jsxs("div",{className:"flex flex-none flex-wrap items-center gap-2 border-b border-border px-2 py-1.5 text-[11.5px]",children:[S.jsx("span",{className:Xt("rounded px-1.5 py-0.5 font-medium",r.valid?"bg-emerald-500/10 text-emerald-700":"bg-destructive/10 text-destructive"),children:r.valid?"форма валидна":`ошибок: ${r.errors}`}),S.jsxs("span",{className:"text-muted-foreground",children:["стратегия:"," ",t.strategy??(t.validateAll?"только ручной прогон":"валидации нет")]}),r.validating&&S.jsx("span",{className:"text-muted-foreground",children:"идёт проверка…"}),S.jsx("span",{className:"flex-1"}),t.validateAll&&S.jsx("button",{onClick:()=>void t.validateAll?.(),className:"rounded border border-border px-2 py-0.5 hover:bg-muted",children:"Прогнать валидацию"})]}):null}function kDe(){const t=se.useSyncExternalStore(yd,md).bundle,r=se.useMemo(()=>t?LA(t.model.get()):[],[t]),[n,s]=se.useState([]),i=se.useRef(0);return se.useEffect(()=>{if(!t)return;const a=gp(()=>{const u=r.map(o=>vDe(t.model,o));cancelAnimationFrame(i.current),i.current=requestAnimationFrame(()=>s(u))});return()=>{cancelAnimationFrame(i.current),a()}},[t,r]),t?n.length===0?S.jsx(xh,{children:"В модели нет полей — проверьте `$model`-пути схемы и model.ts."}):S.jsxs("table",{className:"w-full border-collapse text-[11.5px]",children:[S.jsx("thead",{className:"sticky top-0 bg-sidebar text-muted-foreground",children:S.jsxs("tr",{children:[S.jsx("th",{className:"px-2 py-1 text-left font-normal",children:"Поле"}),S.jsx("th",{className:"px-2 py-1 text-left font-normal",children:"Значение"}),S.jsx("th",{className:"px-2 py-1 text-left font-normal",children:"Состояние"}),S.jsx("th",{className:"px-2 py-1 text-left font-normal",children:"Ошибки"})]})}),S.jsx("tbody",{children:n.map(a=>S.jsxs("tr",{className:"border-t border-border/60 align-top",children:[S.jsx("td",{className:"px-2 py-1 font-mono text-foreground",children:a.path}),S.jsx("td",{className:"max-w-[16rem] truncate px-2 py-1 font-mono text-muted-foreground",children:a.display}),S.jsx("td",{className:"px-2 py-1",children:S.jsx("div",{className:"flex flex-wrap gap-1",children:a.flags.map(u=>S.jsx("span",{className:"rounded bg-muted px-1 text-[10.5px]",children:u},u))})}),S.jsx("td",{className:"px-2 py-1 text-destructive",children:a.errors.map(u=>S.jsxs("div",{children:[u.message," ",S.jsxs("span",{className:"opacity-60",children:["(",u.code,")"]})]},`${u.code}:${u.message}`))})]},a.path))})]}):null}function _De(){const{entries:e,clear:t}=SDe();return e.length===0?S.jsx(xh,{children:"Пока тихо. Введите что-нибудь в форму — здесь появятся изменения и ошибки."}):S.jsxs("div",{className:"text-[11.5px]",children:[S.jsxs("div",{className:"sticky top-0 flex items-center gap-2 bg-sidebar px-2 py-1 text-muted-foreground",children:[S.jsxs("span",{className:"flex-1",children:[e.length," событий"]}),S.jsx("button",{onClick:t,className:"rounded px-1.5 hover:bg-muted hover:text-foreground",children:"Очистить"})]}),S.jsx("ul",{children:e.map(r=>S.jsxs("li",{className:"flex gap-2 border-t border-border/60 px-2 py-1",children:[S.jsx("span",{className:"w-14 flex-none font-mono text-muted-foreground",children:r.at}),S.jsx("span",{className:Xt("w-24 flex-none",r.kind==="error"&&"text-destructive",r.kind==="resolved"&&"text-emerald-700",r.kind==="derived"&&"text-sky-700",r.kind==="input"&&"text-muted-foreground"),children:PDe[r.kind]}),S.jsx("span",{className:"font-mono text-foreground",children:r.path}),S.jsx("span",{className:"text-muted-foreground",children:r.detail})]},r.id))})]})}const PDe={input:"ввод",derived:"пересчёт",error:"ошибка",resolved:"исправлено",validation:"валидация"};function NDe(){const e=se.useSyncExternalStore(yd,md),t=new Set(e.errors.map(r=>r.file));return S.jsxs("div",{className:"space-y-2 px-2 py-1.5 text-[11.5px]",children:[S.jsxs("div",{children:[S.jsx("div",{className:"text-muted-foreground",children:"Файлы каталога"}),S.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[e.files.length===0&&S.jsx("span",{className:"text-muted-foreground",children:"не найдены"}),e.files.map(r=>S.jsxs("span",{title:e.fromEditor.includes(r)?"Взят из открытой вкладки (несохранённые правки)":"Прочитан с диска",className:Xt("rounded px-1.5 py-0.5 font-mono",t.has(r)?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"),children:[r,e.fromEditor.includes(r)?" •":""]},r))]})]}),e.errors.length>0&&S.jsxs("div",{children:[S.jsx("div",{className:"text-muted-foreground",children:"Ошибки"}),S.jsx("ul",{className:"mt-1 space-y-1",children:e.errors.map((r,n)=>S.jsxs("li",{className:"rounded border border-destructive/40 p-1.5",children:[S.jsxs("div",{className:"font-mono text-destructive",children:[r.file||"сборка"," · ",r.phase==="transpile"?"компиляция":"исполнение"]}),S.jsx("div",{className:"mt-0.5 whitespace-pre-wrap text-foreground",children:r.message})]},`${r.file}:${n}`))})]}),e.applied.length>0&&S.jsxs("div",{children:[S.jsx("div",{className:"text-muted-foreground",children:"Подключено"}),S.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:e.applied.map(r=>S.jsx("span",{className:"rounded bg-emerald-500/10 px-1.5 py-0.5 text-emerald-700",children:r},r))})]})]})}const $De={raw:null,model:"model",registry:"dataSources",form:null};function IDe({tab:e}){const{rawJsonOpen:t,bottomTab:r}=vi(),[n,s]=se.useState(0),[i,a]=se.useState("seed"),u=$De[r],o=r==="model"&&i==="live",c=r==="form",p=se.useMemo(()=>c?0:(u==null?ch(e.schema):e.mock?.[u]??gD(Ep(e.schema),u)).split(`
|
|
1134
|
+
`).length,[c,u,e.schema,e.mock]),d=y=>{Xe.setBottomTab(y),t||Xe.toggleRawJson()},h=()=>{u!=null&&(Xe.resetMock(e.id,u),s(y=>y+1))},m=y=>Xt("h-full rounded px-2.5 text-[11.5px]",r===y?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted");return S.jsxs("div",{className:t?"flex min-h-0 flex-1 flex-col bg-sidebar":"flex-none border-t border-border bg-sidebar",children:[S.jsxs("div",{className:"flex h-[30px] w-full flex-none items-center gap-1 px-1.5 text-[11.5px] text-muted-foreground",children:[S.jsx("button",{onClick:Xe.toggleRawJson,title:t?"Свернуть":"Развернуть",className:"grid h-full w-5 flex-none place-items-center rounded hover:bg-muted",children:S.jsx(Rp,{className:Xt("h-3.5 w-3.5 transition-transform",t&&"rotate-90")})}),S.jsx("button",{onClick:()=>d("raw"),className:m("raw"),children:"JSON"}),S.jsx("button",{onClick:()=>d("model"),title:"Модель формы: засев (редактируется) или живые значения",className:m("model"),children:"Модель"}),S.jsx("button",{onClick:()=>d("registry"),title:"Значения источников $dataSource в превью",className:m("registry"),children:"Registry"}),S.jsx("button",{onClick:()=>d("form"),title:"Состояние живой формы: валидность полей, ошибки, лог поведения, сборка схем",className:m("form"),children:"Форма"}),S.jsx("span",{className:"flex-1"}),r==="model"&&t&&S.jsxs("div",{className:"flex flex-none gap-0.5 rounded border border-border p-0.5",children:[S.jsx("button",{onClick:()=>a("seed"),title:"Значения, которыми форма инициализируется. Редактируются.",className:Xt("rounded px-1.5",i==="seed"?"bg-muted text-foreground":""),children:"Засев"}),S.jsx("button",{onClick:()=>a("live"),title:"Что в модели сейчас — с учётом ввода в поля превью. Только чтение.",className:Xt("rounded px-1.5",i==="live"?"bg-muted text-foreground":""),children:"Живые"})]}),u!=null&&t&&!o&&!c&&S.jsx("button",{onClick:h,title:"Сбросить к синтезу из схемы",className:"flex-none rounded px-2 py-0.5 hover:bg-muted hover:text-foreground",children:"Сбросить"}),!o&&!c&&S.jsxs("span",{className:"flex-none pr-1.5",children:[p," строк"]})]}),t&&S.jsx("div",{className:"min-h-0 flex-1 border-t border-border",children:c?S.jsx(FDe,{}):u==null?S.jsx(pj,{schema:e.schema}):o?S.jsx(xDe,{tab:e}):S.jsx(yDe,{tab:e,section:u},`${u}:${n}`)})]})}function BDe(e){if(e!=null)try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:void 0}catch{return}}function jDe({tab:e}){const t=vi(),r=C3({id:"rb.layout.v",storage:localStorage,panelIds:["canvas","raw"]}),n=se.useMemo(()=>Bh(e.schema,e.mock),[e.schema,e.mock]),s=se.useMemo(()=>Aq(e.schema),[e.schema]),i=se.useMemo(()=>BDe(e.mock?.model),[e.mock?.model]),a=M2e({tab:e,annotated:s,dataSources:n.dataSources,modelOverride:i,enabled:t.preview==="runtime"&&t.liveSchemas}),u=S.jsx(IDe,{tab:e});if(t.preview==="code")return S.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col overflow-hidden bg-muted/40",children:[S.jsx(wk,{}),S.jsx("div",{className:"min-h-0 flex-1",children:S.jsx(pj,{schema:e.schema})})]});const o=S.jsx(S.Fragment,{children:S.jsx("div",{className:"mx-auto w-full",children:S.jsx("div",{className:"rounded-xl border border-border bg-background p-4 shadow-sm",children:t.preview==="runtime"?S.jsx(fDe,{schema:e.schema,annotated:s,mock:n,mode:t.runtimeMode,selectionPath:e.selectionPath,selectionPaths:e.selectionPaths,live:a}):S.jsx(Z2e,{schema:e.schema,selectionPath:e.selectionPath,selectionPaths:e.selectionPaths})})})});return S.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col overflow-hidden bg-muted/40",children:[S.jsx(wk,{}),t.rawJsonOpen?S.jsxs(A3,{orientation:"vertical",className:"min-h-0 flex-1",defaultLayout:r.defaultLayout,onLayoutChanged:r.onLayoutChanged,children:[S.jsx(hl,{id:"canvas",minSize:200,className:"relative p-14",children:o}),S.jsx(jg,{withHandle:!0}),S.jsx(hl,{id:"raw",defaultSize:216,minSize:120,maxSize:560,className:"flex flex-col",children:u})]}):S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"relative flex-1 overflow-auto p-14",children:o}),u]})]})}const jk=gr("Mod+Shift+V"),ODe=[{view:"code",label:"Код",hint:`Исходник в редакторе (цикл ${jk})`,Icon:Yj},{view:"preview",label:"Предпросмотр",hint:`Рендер файла (цикл ${jk})`,Icon:D8},{view:"split",label:"Рядом",hint:`Редактор и рендер с синхроскроллом (${gr("Mod+K")} ${gr("V")})`,Icon:Qj}];function LDe({tab:e}){const t=e.mdView??"code";return S.jsx("div",{className:"flex h-[30px] flex-none items-center justify-end gap-1.5 border-b border-border bg-sidebar px-1.5",children:S.jsx("div",{className:"flex flex-none gap-0.5 rounded-md border border-border bg-muted p-0.5",children:ODe.map(({view:r,label:n,hint:s,Icon:i})=>S.jsxs("button",{onClick:()=>sd(e.id,r),title:s,"aria-pressed":t===r,className:Xt("flex h-5 items-center gap-1 rounded px-2 text-[11.5px]",t===r?"bg-background shadow-sm":"text-muted-foreground hover:bg-muted"),children:[S.jsx(i,{className:"h-3 w-3"}),n]},r))})})}function C2(e,t,r,n,s){return r===t?n:n+(e-t)*(s-n)/(r-t)}function fj(e,t,r){let n=0,s=e.length-1,i=-1;for(;n<=s;){const a=n+s>>1;r(e[a])<=t?(i=a,n=a+1):s=a-1}return i}function Ok(e,t){if(!e.length)return 0;const r=fj(e,t,n=>n.line);return r===-1?C2(t,1,e[0].line,0,e[0].top):r===e.length-1?e[r].top:C2(t,e[r].line,e[r+1].line,e[r].top,e[r+1].top)}function MDe(e,t){if(!e.length)return 1;const r=fj(e,t,n=>n.top);return r===-1?C2(t,0,e[0].top,1,e[0].line):r===e.length-1?e[r].line:C2(t,e[r].top,e[r+1].top,e[r].line,e[r+1].line)}function RDe(e,t){const r=(t??e).querySelectorAll("[data-line]"),n=e.getBoundingClientRect().top-e.scrollTop,s=[];for(const i of r){const a=Number(i.dataset.line);if(!Number.isFinite(a))continue;const u=i.getBoundingClientRect().top-n,o=s[s.length-1];o&&o.line===a||s.push({line:a,top:u})}return s.sort((i,a)=>i.line-a.line),s}const UDe=150;function zDe(e,t){const r=se.useRef(null),n=se.useRef(null),s=se.useRef([]),i=se.useRef(null),[a,u]=se.useState(null),o=se.useCallback(c=>u(c),[]);return se.useEffect(()=>{const c=r.current;if(!e||!a||!c)return;const p=x=>{const E=performance.now(),A=i.current;return A&&A.who!==x&&E<A.until?!1:(i.current={who:x,until:E+UDe},!0)},d=()=>{s.current=RDe(c,n.current??void 0)},h=()=>{const x=a.getVisibleRanges()[0]?.startLineNumber??1,E=a.getTopForLineNumber(x),A=a.getBottomForLineNumber(x),F=A>E?(a.getScrollTop()-E)/(A-E):0;return x+Math.min(1,Math.max(0,F))};let m=0;const y=x=>{cancelAnimationFrame(m),m=requestAnimationFrame(x)},v=()=>{p("editor")&&y(()=>{c.scrollTop=Ok(s.current,h())})},b=()=>{p("preview")&&y(()=>{const x=MDe(s.current,c.scrollTop),E=Math.max(1,Math.floor(x)),A=a.getTopForLineNumber(E),F=a.getBottomForLineNumber(E);a.setScrollTop(A+(x-E)*(F-A))})};d(),c.scrollTop=Ok(s.current,h());const T=a.onDidScrollChange(v);c.addEventListener("scroll",b,{passive:!0});const D=new ResizeObserver(d);return n.current&&D.observe(n.current),()=>{cancelAnimationFrame(m),T.dispose(),c.removeEventListener("scroll",b),D.disconnect()}},[e,a,t]),{onEditorMount:o,previewRef:r,contentRef:n}}const qDe=se.lazy(()=>Pl(()=>import("./CodeEditor-Cca8j3Z3.js"),__vite__mapDeps([13,2,3,10,11,12,14,4,5,1,6,8,7]))),JDe=se.lazy(()=>Pl(()=>import("./MarkdownPreview-CmqjlfzE.js"),__vite__mapDeps([15,2,3,4,5,1,6,8,7])));function Lk({label:e}){return S.jsx("div",{className:"grid h-full place-items-center text-xs text-muted-foreground",children:e})}function KDe({tab:e}){const{theme:t}=vi(),r=DD(e),n=r?e.mdView??"code":"code",s=e.text??"",i=C3({id:"rb.layout.md",storage:localStorage,panelIds:["md-code","md-preview"]}),a=zDe(r&&n==="split",s),u=S.jsx(se.Suspense,{fallback:S.jsx(Lk,{label:"Загрузка редактора…"}),children:S.jsx(qDe,{value:s,language:e.language??"plaintext",theme:t,onChange:c=>Xe.setTabText(e.id,c),onMount:(c,p)=>{c.addCommand(p.KeyMod.CtrlCmd|p.KeyMod.Shift|p.KeyCode.KeyK,()=>Xe.toggleRightPanelTo("agent")),r&&(a.onEditorMount(c),c.addCommand(p.KeyMod.CtrlCmd|p.KeyMod.Shift|p.KeyCode.KeyV,()=>GN(1)),c.addCommand(p.KeyMod.chord(p.KeyMod.CtrlCmd|p.KeyCode.KeyK,p.KeyCode.KeyV),()=>sd(e.id,"split")))}})}),o=S.jsx(se.Suspense,{fallback:S.jsx(Lk,{label:"Загрузка предпросмотра…"}),children:S.jsx(JDe,{text:s,docPath:e.source.path,dark:t==="dark",containerRef:a.previewRef,contentRef:a.contentRef})});return S.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background",children:[r&&S.jsx(LDe,{tab:e}),S.jsxs("div",{className:"min-h-0 flex-1",children:[n==="code"&&u,n==="preview"&&o,n==="split"&&S.jsxs(A3,{orientation:"horizontal",className:"min-h-0 flex-1",defaultLayout:i.defaultLayout,onLayoutChanged:i.onLayoutChanged,children:[S.jsx(hl,{id:"md-code",minSize:240,className:"flex min-h-0 flex-col overflow-hidden",children:u}),S.jsx(jg,{withHandle:!0}),S.jsx(hl,{id:"md-preview",minSize:240,className:"flex min-h-0 flex-col overflow-hidden",children:o})]})]})]})}const bh=Bl({pending:null}),T2={open:e=>bh.setState({pending:e}),close:()=>bh.setState({pending:null})};function VDe(){return se.useSyncExternalStore(bh.subscribe,()=>bh.getState(),()=>bh.getState())}function hj(e,t){const r=e.order.indexOf(t.id);if(r<0)return[];switch(t.kind){case"one":return[t.id];case"others":return e.order.filter(n=>n!==t.id);case"left":return e.order.slice(0,r);case"right":return e.order.slice(r+1)}}function WDe(e,t){const r=[];for(const n of t){const s=e.tabs[n];s&&$2(s)&&b_(s)&&r.push({id:n,name:s.source.name})}return r}function mj(e,t){for(const r of hj(e,t)){const n=e.tabs[r];n&&$2(n)&&C_(r)}switch(t.kind){case"one":Xe.closeTab(t.id);return;case"others":Xe.closeOtherTabs(t.id);return;case"left":Xe.closeTabsToLeft(t.id);return;case"right":Xe.closeTabsToRight(t.id)}}function Jc(e){const t=mt.getState(),r=hj(t,e);if(!r.length)return;const n=WDe(t,r);if(!n.length){mj(t,e);return}T2.open({intent:e,total:r.length,drafts:n})}function HDe(e){mj(mt.getState(),e),T2.close()}function GDe({id:e,index:t,count:r}){const n=dU(e),s=v_();if(!n)return null;const i=e===s,a=t>0,u=t<r-1,o=r>1,c=$2(n);return S.jsxs(l3,{children:[S.jsx(c3,{asChild:!0,children:S.jsxs("div",{onClick:()=>Xe.setActiveTab(e),onDoubleClick:()=>Xe.pinTab(e),className:Xt("flex cursor-pointer items-center gap-2 whitespace-nowrap border-r border-border px-3 font-mono text-[11px]",i?"bg-background text-foreground":"bg-sidebar text-muted-foreground"),children:[S.jsx("span",{className:"text-muted-foreground",children:"{}"}),S.jsx("span",{className:Xt(n.preview&&"italic"),title:n.preview?`${n.source.path||n.source.name} — предпросмотр: двойной клик закрепит вкладку`:c?`${n.source.name} — черновик: файла в проекте нет, копия хранится локально`:n.source.path||n.source.name,children:n.source.name}),b_(n)&&S.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500"}),S.jsx("button",{onClick:p=>{p.stopPropagation(),Jc({kind:"one",id:e})},className:"ml-1 grid h-4 w-4 place-items-center rounded text-muted-foreground hover:bg-muted hover:text-foreground",children:S.jsx(w2,{className:"h-3.5 w-3.5"})})]})}),S.jsxs(p3,{className:"w-52",children:[S.jsx(sn,{onClick:()=>Jc({kind:"one",id:e}),children:"Закрыть"}),S.jsx(sn,{disabled:!a,onClick:()=>Jc({kind:"left",id:e}),children:"Закрыть слева"}),S.jsx(sn,{disabled:!u,onClick:()=>Jc({kind:"right",id:e}),children:"Закрыть справа"}),S.jsx(Kc,{}),S.jsx(sn,{disabled:!o,onClick:()=>Jc({kind:"others",id:e}),children:"Закрыть остальные"})]})]})}function XDe(){const e=pU();return S.jsx("div",{className:"flex h-[34px] flex-none items-stretch overflow-x-auto border-b border-border bg-sidebar",children:e.map((t,r)=>S.jsx(GDe,{id:t,index:r,count:e.length},t))})}function Mk({title:e,ops:t,side:r,scrollRef:n}){const s=t.map((i,a)=>({op:i,idx:a})).filter(({op:i})=>r==="old"?i.type!=="add":i.type!=="del");return S.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[S.jsx("div",{className:"flex-none border-b border-border bg-sidebar px-3.5 py-2 text-[10.5px] font-semibold uppercase tracking-wider text-muted-foreground",children:e}),S.jsx("div",{ref:n,className:"relative flex-1 overflow-auto py-2 font-mono text-[10.5px] leading-relaxed",children:s.map(({op:i,idx:a},u)=>{const o=u+1,c=i.type==="del"?"-":i.type==="add"?"+":" ";return S.jsxs("div",{"data-op-index":a,className:Xt("flex whitespace-pre",i.type==="del"&&"bg-red-500/15",i.type==="add"&&"bg-green-500/15"),children:[S.jsx("span",{className:"w-9 flex-none select-none pr-2 text-right text-muted-foreground/40",children:o}),S.jsx("span",{className:Xt("w-3 flex-none select-none text-center",i.type==="del"&&"text-red-600",i.type==="add"&&"text-green-600",i.type==="same"&&"text-transparent"),children:c}),S.jsx("span",{className:"min-w-0 flex-1 pr-3",children:i.text||" "})]},a)})})]})}function YDe(e){const t=[];let r=!1;return e.forEach((n,s)=>{n.type!=="same"?(r||t.push(s),r=!0):r=!1}),t}function Rk(e,t){if(!e)return;const r=Array.from(e.querySelectorAll("[data-op-index]")),n=r.find(i=>Number(i.dataset.opIndex)>=t)??r[r.length-1];if(!n)return;const s=n.offsetTop-e.clientHeight/2+n.clientHeight/2;e.scrollTo({top:Math.max(0,s),behavior:"smooth"})}function QDe(){const{plan:e,saving:t}=AU(),r=se.useRef(null),n=se.useRef(null),[s,i]=se.useState(-1),a=se.useMemo(()=>e?YDe(e.diff):[],[e]);if(!e)return null;const u=o=>{if(a.length===0)return;const c=Math.max(0,Math.min(a.length-1,o));i(c),Rk(r.current,a[c]),Rk(n.current,a[c])};return S.jsx("div",{onClick:Ga.close,className:"fixed inset-0 z-50 grid place-items-center bg-black/50 p-4",children:S.jsxs("div",{onClick:o=>o.stopPropagation(),className:"flex h-[72vh] w-[1280px] max-w-[95vw] flex-col overflow-hidden rounded-xl border border-border bg-background shadow-2xl",children:[S.jsxs("div",{className:"flex flex-none items-center gap-3 border-b border-border p-4",children:[S.jsxs("div",{className:"min-w-0",children:[S.jsx("div",{className:"text-sm font-semibold",children:"Сохранить изменения?"}),S.jsx("div",{className:"mt-0.5 truncate font-mono text-[11px] text-muted-foreground",children:e.tabId})]}),S.jsx("span",{className:"flex-1"}),a.length>0&&S.jsxs("div",{className:"flex flex-none items-center gap-1",children:[S.jsx(Rr,{variant:"outline",size:"icon-xs","aria-label":"Предыдущее изменение",title:"Предыдущее изменение",disabled:s<=0,onClick:()=>u(s-1),children:S.jsx(kO,{})}),S.jsxs("span",{className:"w-9 select-none text-center font-mono text-[11px] tabular-nums text-muted-foreground",children:[s<0?"–":s+1,"/",a.length]}),S.jsx(Rr,{variant:"outline",size:"icon-xs","aria-label":"Следующее изменение",title:"Следующее изменение",disabled:s>=a.length-1,onClick:()=>u(s+1),children:S.jsx(_O,{})})]}),S.jsxs("span",{className:"flex-none rounded-full border border-border bg-muted px-2.5 py-1 font-mono text-[11.5px]",children:["+",e.added," -",e.removed]})]}),e.conflict&&S.jsx("div",{className:"flex-none border-b border-amber-500/40 bg-amber-500/10 px-4 py-2 text-xs text-amber-700 dark:text-amber-400",children:"⚠ Файл изменился на диске после открытия. Сохранение перезапишет внешние правки."}),S.jsxs("div",{className:"flex min-h-0 flex-1",children:[S.jsx(Mk,{title:"Текущий файл",ops:e.diff,side:"old",scrollRef:r}),S.jsx("div",{className:"w-px flex-none bg-border"}),S.jsx(Mk,{title:"После сохранения",ops:e.diff,side:"new",scrollRef:n})]}),S.jsxs("div",{className:"flex flex-none justify-end gap-2 border-t border-border p-3",children:[S.jsx(Rr,{variant:"outline",size:"sm",onClick:Ga.close,children:"Отмена"}),S.jsx(Rr,{size:"sm",disabled:t,onClick:()=>void I2e(e),children:t?"Сохранение…":"Сохранить"})]})]})})}function ZDe(){const{pending:e}=VDe();if(!e)return null;const{drafts:t,total:r}=e,n=t.length>1;return S.jsx(S2,{open:!0,onOpenChange:s=>{s||T2.close()},children:S.jsxs(F2,{className:"max-w-md",children:[S.jsxs(ho,{children:[S.jsx(mo,{children:n?"Закрыть вкладки?":"Закрыть вкладку?"}),S.jsx(Mp,{children:n?`Из ${r} закрываемых вкладок ${t.length} — черновики без файла в проекте. Вместе с ними удалятся и локальные копии, восстановить их будет нельзя.`:"Эта схема — черновик: файла в проекте за ней нет. Вместе со вкладкой удалится и локальная копия, восстановить её будет нельзя."})]}),S.jsx("ul",{className:"max-h-40 overflow-auto rounded-md border border-border bg-muted/40 px-3 py-2 font-mono text-[11.5px]",children:t.map(s=>S.jsx("li",{className:"truncate py-0.5",children:s.name},s.id))}),S.jsxs("p",{className:"text-[11.5px] text-muted-foreground",children:["Чтобы сохранить работу, отмените закрытие и выгрузите схему через «Сохранить» (",gr("Mod+S"),") — она скачается файлом."]}),S.jsxs(Nl,{children:[S.jsx(Rr,{variant:"outline",onClick:T2.close,children:"Отмена"}),S.jsx(Rr,{variant:"destructive",onClick:()=>HDe(e.intent),children:"Закрыть и удалить"})]})]})})}function exe(e){return!e.variantGroup||e.name===e.variantGroup}function txe(e){const t=Ta(),r=t.find(i=>i.name===e)?.variantGroup;if(!r)return null;const n=t.filter(i=>i.variantGroup===r);if(n.length<2)return null;const s=n.find(i=>i.name===r)??n[0];return{group:r,members:n,default:s}}function n3(e){const t=new Set,r=[];for(const n of e){if(!n.variantGroup){r.push(n);continue}t.has(n.variantGroup)||(t.add(n.variantGroup),r.push(e.find(s=>s.name===n.variantGroup&&s.variantGroup===n.variantGroup)??n))}return r}const rxe=210,Uk=20,bv=2,nxe=3,sxe=8;function ixe(e){return n3(e.filter(r=>!W3(r))).flatMap(r=>[r,...n3(B2(r.name))])}function axe(e,t){const r=t.trim().toLowerCase();return r?e.filter(n=>H3(n).toLowerCase().includes(r)||n.name.toLowerCase().includes(r)):ixe(e)}function oxe(e){const t=[];return{sections:A_(e).map(([n,s])=>({category:n,items:s.map(i=>({entry:i,index:t.push(i)-1}))})),flat:t}}function uxe(e,t){const r=e.reduce((o,c)=>o+c.items.length+bv,0),n=Math.max(1,Math.min(t,Math.ceil(r/sxe))),s=Math.ceil(r/n),i=Array.from({length:n},()=>[]);let a=0,u=0;for(const o of e){let c=o.items,p=!1;for(;c.length;){const d=a===n-1,h=s-u-bv;if(!d&&h<nxe){a+=1,u=0;continue}const m=d?c.length:Math.min(c.length,h);i[a].push({key:`${o.category}#${a}`,category:o.category,total:o.items.length,continued:p,items:c.slice(0,m)}),u+=m+bv,c=c.slice(m),p=!0,c.length&&(a+=1,u=0)}}return i}function lxe(e,t){const[r,n]=se.useState(1);return se.useEffect(()=>{const s=e.current;if(!t||!s)return;const i=u=>n(Math.max(1,Math.floor((u+Uk)/(rxe+Uk))));i(s.clientWidth);const a=new ResizeObserver(([u])=>i(u.contentRect.width));return a.observe(s),()=>a.disconnect()},[e,t]),r}function cxe(){const e=vi().quickAddOpen,[t,r]=se.useState(""),[n,s]=se.useState(0),i=se.useRef(null),a=se.useRef(null),u=Ta(),o=lxe(a,e),{sections:c,flat:p}=se.useMemo(()=>oxe(axe(u,t)),[u,t]),d=se.useMemo(()=>uxe(c,o),[c,o]),[h,m]=se.useState(e);e!==h&&(m(e),e&&(r(""),s(0)));const y=Math.max(0,p.length-1);if(n>y&&s(y),se.useEffect(()=>{e&&i.current?.focus()},[e]),se.useEffect(()=>{a.current?.querySelector('[data-active="true"]')?.scrollIntoView({block:"nearest"})},[n]),!e)return null;const v=D=>{D&&(Xe.addComponent(D.makeNode()),Xe.closeQuickAdd())},b=D=>{const x=a.current,E=x?[...x.querySelectorAll("[data-idx]")]:[],A=E[n];if(!A)return;const F=A.getBoundingClientRect();let k=null;for(const _ of E){const O=_.getBoundingClientRect(),q=(O.left-F.left)*D;if(q<8)continue;const j=Math.abs(O.top-F.top),V=k&&Math.abs(q-k.dx)<8;(!k||q<k.dx-8||V&&j<k.dy)&&(k={index:Number(_.dataset.idx),dx:q,dy:j})}k&&s(k.index)},T=D=>{D.key==="ArrowDown"?(D.preventDefault(),D.stopPropagation(),s(x=>Math.min(x+1,p.length-1))):D.key==="ArrowUp"?(D.preventDefault(),D.stopPropagation(),s(x=>Math.max(x-1,0))):D.key==="ArrowRight"||D.key==="ArrowLeft"?(D.preventDefault(),D.stopPropagation(),b(D.key==="ArrowRight"?1:-1)):D.key==="Enter"?(D.preventDefault(),D.stopPropagation(),v(p[n])):D.key==="Escape"&&(D.preventDefault(),D.stopPropagation(),Xe.closeQuickAdd())};return S.jsx("div",{onClick:()=>Xe.closeQuickAdd(),className:"fixed inset-0 z-50 grid items-start justify-center overflow-auto bg-black/50 p-4 pt-[5vh]",children:S.jsxs("div",{onClick:D=>D.stopPropagation(),className:"flex max-h-[88vh] w-[min(1400px,94vw)] flex-col overflow-hidden rounded-xl border border-border bg-background shadow-2xl",children:[S.jsx("input",{ref:i,value:t,onChange:D=>{r(D.target.value),s(0)},onKeyDown:T,placeholder:"Добавить компонент…",className:"flex-none border-b border-border bg-transparent px-4 py-3 text-sm outline-none placeholder:text-muted-foreground"}),S.jsx("div",{ref:a,className:"min-h-0 flex-1 overflow-auto px-3 py-3",children:p.length===0?S.jsx("div",{className:"px-3 py-10 text-center text-xs text-muted-foreground",children:"Ничего не найдено"}):S.jsx("div",{className:"flex items-start gap-5",children:d.map((D,x)=>S.jsx("div",{className:"min-w-0 flex-1",children:D.map(E=>S.jsxs("section",{className:"mb-4",children:[S.jsxs("div",{className:Xt("mb-1.5 flex items-baseline gap-1.5 px-2 text-[14px] font-semibold",E.continued?"text-muted-foreground":"text-foreground"),children:[S.jsx("span",{className:"min-w-0 truncate",children:E.category}),S.jsx("span",{className:"font-mono text-[10.5px] font-normal text-muted-foreground/50",children:E.continued?"…":E.total})]}),E.items.map(({entry:A,index:F})=>S.jsxs("button",{type:"button","data-idx":F,"data-active":F===n,onMouseMove:()=>s(F),onClick:()=>v(A),className:Xt("flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-[12.5px]",W3(A)&&"pl-5 text-muted-foreground",F===n?"bg-primary/10 text-foreground":"hover:bg-muted"),children:[S.jsx("span",{className:"min-w-0 flex-1 truncate",children:H3(A)}),A.variantGroup&&!exe(A)&&S.jsx("span",{className:"flex-none rounded bg-primary/15 px-1 py-px text-[9.5px] font-medium text-primary",children:A.variant})]},A.name))]},E.key))},x))})}),S.jsx("div",{className:"flex-none border-t border-border px-3 py-1.5 text-[10.5px] text-muted-foreground",children:"↑↓ по колонке · ←→ между колонками · Enter вставить · Esc закрыть"})]})})}const gm=e=>e instanceof Error?e.message:String(e),pxe="sample-form";function wD(){return kn.getState().dirHandle}async function dxe(e,t){const r=new Map(kn.getState().tree.map(s=>[s.path,s.kind])),n=[];for(const s of t)if(r.get(s)==="directory"){const i=await o5(e,s);n.push(...i.map(a=>Cp(s,a)))}else n.push(s);return[...new Set(n)]}async function fxe(e,t){const r=wD();if(!r){wt("Проект не открыт");return}const n=t.name.trim();if(!n){wt("Укажите имя шаблона");return}try{const s=await dxe(r,e),i=s.filter(WB),a=s.length-i.length;if(!i.length){wt("Нечего сохранять: выбраны только бинарные файлы");return}const u=[];for(const p of i)u.push({path:p,content:await qv(r,p)});const o={id:Wge(n),name:n,description:t.description?.trim()||void 0,source:t.target,files:Vge(u,t.baseName.trim()),createdAt:new Date().toISOString()},c=t.target==="project"?await c2e(r,o,t.baseName.trim()||void 0):await f2e(o);t.target==="project"&&await ka(),await Lp(),wt(`Шаблон «${c.name}» сохранён (файлов: ${c.files.length}`+(a?`, пропущено бинарных: ${a})`:")"))}catch(s){wt("Не удалось создать шаблон: "+gm(s))}}async function hxe(e,t,r,n){const s=wD();if(!s){wt("Проект не открыт");return}const i=t.trim(),a=XB(r,n,i);if(!a.length){wt("Не выбрано ни одного файла");return}try{const u=await q2(s,e,i),o=Cp(e,u),c=YB(a);let p=null;for(const d of a){const h=await Vg(s,o,d.path,d.content);c&&d.path===c.path&&(p=h)}if(await ka(),c&&p){const d=Cp(o,c.path);await NA(d,d.slice(d.lastIndexOf("/")+1),p,!0)}wt(`Форма «${u}» создана по шаблону «${r.name}»`)}catch(u){wt("Не удалось создать форму: "+gm(u))}}function zk(e){const t=XB(e,e.files.map(n=>n.path),pxe),r=YB(t);if(!r){wt(`В шаблоне «${e.name}» нет схемы формы`);return}try{const n=l_(JSON.parse(r.content));Xe.openTab(`template:${e.source}:${e.id}`,{kind:"template",name:e.name},n,{preview:!0})}catch(n){wt("Не удалось открыть шаблон: "+gm(n))}}async function mxe(e){if(e.source==="builtin")return;const t=wD();try{if(e.source==="project"){if(!t){wt("Проект не открыт");return}await d2e(t,e.id),await ka()}else await m2e(e.id);await Lp(),wt(`Шаблон «${e.name}» удалён`)}catch(r){wt("Не удалось удалить шаблон: "+gm(r))}}async function yxe(e,t){if(e.source==="builtin")return;const r=t.trim();if(!r)return;const n=wD();try{const s={...e,name:r};if(e.source==="project"){if(!n){wt("Проект не открыт");return}await p2e(n,s),await ka()}else await h2e(s);await Lp()}catch(s){wt("Не удалось переименовать шаблон: "+gm(s))}}function qk({template:e,compact:t}){return S.jsxs(S.Fragment,{children:[S.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[S.jsx("span",{className:"block truncate font-medium",children:e.name}),e.description&&!t&&S.jsx("span",{className:"block truncate text-[11px] font-normal text-muted-foreground",children:e.description})]}),S.jsx(o8,{variant:"secondary",className:"h-4 flex-none px-1.5 text-[9px]",children:Mge[e.source]})]})}function gxe({templates:e,value:t,onChange:r,id:n}){const[s,i]=se.useState(!1),a=e.find(u=>u.id===t);return S.jsxs(Zj,{open:s,onOpenChange:i,children:[S.jsx(eO,{asChild:!0,children:S.jsxs(Rr,{id:n,type:"button",variant:"outline",role:"combobox","aria-expanded":s,className:"h-auto w-full justify-between gap-2 py-1.5 font-normal",children:[a?S.jsx(qk,{template:a,compact:!0}):S.jsx("span",{className:"flex-1 truncate text-left text-muted-foreground",children:"Выберите шаблон…"}),S.jsx(PO,{className:"size-4 flex-none opacity-50"})]})}),S.jsx(tO,{align:"start",className:"w-(--radix-popover-trigger-width) p-0",children:S.jsxs(rO,{children:[S.jsx(nO,{placeholder:"Поиск шаблона…"}),S.jsxs(sO,{children:[S.jsx(iO,{children:"Шаблоны не найдены."}),S.jsx(aO,{children:e.map(u=>S.jsxs(oO,{value:`${u.name} ${u.description??""}`,onSelect:()=>{r(u.id),i(!1)},className:"items-start gap-2",children:[S.jsx(x8,{className:Xt("mt-0.5 size-4 flex-none",u.id===t?"opacity-100":"opacity-0")}),S.jsx(qk,{template:u})]},u.id))})]})]})})]})}function Dxe(e){return e.kind==="newTemplate"?"newTemplate:"+e.paths.join("|"):e.kind+":"+("dirPath"in e?e.dirPath:e.path)}function yj({dialog:e,onClose:t}){if(!e)return null;const r=e.kind==="template"||e.kind==="newTemplate";return S.jsx(S2,{open:!0,onOpenChange:n=>{n||t()},children:S.jsx(F2,{className:r?"max-w-lg":"max-w-md",children:S.jsx(xxe,{dialog:e,onClose:t},Dxe(e))})})}function xxe({dialog:e,onClose:t}){return e.kind==="template"?S.jsx(Cxe,{dirPath:e.dirPath,onClose:t}):e.kind==="newTemplate"?S.jsx(Txe,{paths:e.paths,onClose:t}):e.kind==="delete"?S.jsx(vxe,{path:e.path,name:e.name,onClose:t}):S.jsx(bxe,{dialog:e,onClose:t})}function bxe({dialog:e,onClose:t}){const[r,n]=se.useState(e.kind==="rename"?e.currentName:""),s=e.kind==="newFile"?"Новый файл":e.kind==="newFolder"?"Новая папка":"Переименовать",i=()=>{const a=r.trim();a&&(e.kind==="newFile"?T2e(e.dirPath,a):e.kind==="newFolder"?A2e(e.dirPath,a):F2e(e.path,e.entryKind,a),t())};return S.jsxs(S.Fragment,{children:[S.jsx(ho,{children:S.jsx(mo,{children:s})}),S.jsx(Bs,{autoFocus:!0,value:r,onChange:a=>n(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),i())},placeholder:e.kind==="newFolder"?"имя-папки":"имя-файла.ext"}),S.jsxs(Nl,{children:[S.jsx(Rr,{variant:"outline",onClick:t,children:"Отмена"}),S.jsx(Rr,{onClick:i,disabled:!r.trim(),children:e.kind==="rename"?"Переименовать":"Создать"})]})]})}function vxe({path:e,name:t,onClose:r}){return S.jsxs(S.Fragment,{children:[S.jsxs(ho,{children:[S.jsx(mo,{children:"Удалить?"}),S.jsxs(Mp,{children:[S.jsx("span",{className:"font-mono",children:t})," будет удалён безвозвратно (папки — со всем содержимым)."]})]}),S.jsxs(Nl,{children:[S.jsx(Rr,{variant:"outline",onClick:r,children:"Отмена"}),S.jsx(Rr,{variant:"destructive",onClick:()=>{S2e(e),r()},children:"Удалить"})]})]})}function Exe(e){return/^[A-Za-z][A-Za-z0-9]*([-_ ][A-Za-z0-9]+)*$/.test(e.trim())}function Cxe({dirPath:e,onClose:t}){const r=Bg(D=>D.items),[n,s]=se.useState(r[0]?.id??""),i=r.find(D=>D.id===n)??r[0],[a,u]=se.useState(""),[o,c]=se.useState(!1),[p,d]=se.useState({}),h=se.useMemo(()=>p[i?.id??""]??new Set(i?.files.map(D=>D.path)??[]),[p,i]),m=D=>d(x=>({...x,[i.id]:D})),y=D=>{const x=new Set(h);if(x.has(D)){x.delete(D);for(const[E,A]of Object.entries(i.requires??{}))A.includes(D)&&x.delete(E)}else x.add(D);m(GB(x,i.requires))},v=Exe(a),b=v&&h.size>0&&i!=null,T=()=>{b&&(hxe(e,a.trim(),i,h),t())};return S.jsxs(S.Fragment,{children:[S.jsx(ho,{children:S.jsx(mo,{children:"Выбрать шаблон"})}),S.jsxs("div",{className:"min-w-0 space-y-3 py-1",children:[S.jsxs("div",{className:"space-y-1.5",children:[S.jsx(tu,{htmlFor:"tpl-name",children:"Имя формы"}),S.jsx(Bs,{id:"tpl-name",autoFocus:!0,value:a,onChange:D=>u(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),T())},placeholder:"например: user-profile"}),a.trim()&&!v&&S.jsx("p",{className:"text-[11px] text-destructive",children:"Латиница, цифры и дефис: имя попадает в названия компонентов и импорты."})]}),S.jsxs("div",{className:"min-w-0 space-y-1.5",children:[S.jsx(tu,{htmlFor:"tpl-pick",children:"Шаблон"}),S.jsx(gxe,{id:"tpl-pick",templates:r,value:i?.id??"",onChange:s})]}),i&&S.jsxs(uO,{open:o,onOpenChange:c,className:"min-w-0 space-y-1.5",children:[S.jsxs(lO,{className:"flex w-full items-center gap-1 text-left",children:[S.jsx(Rp,{className:Xt("size-3.5 flex-none text-muted-foreground transition-transform",o&&"rotate-90")}),S.jsxs(tu,{className:"cursor-pointer",children:["Файлы (",h.size," из ",i.files.length,")"]})]}),S.jsx(cO,{children:S.jsx("div",{className:"max-h-52 space-y-2 overflow-y-auto rounded-md border border-border p-2",children:i.files.map(D=>S.jsxs("label",{className:"flex min-w-0 cursor-pointer items-center gap-2 text-sm",children:[S.jsx(pO,{className:"flex-none",checked:h.has(D.path),onCheckedChange:()=>y(D.path)}),S.jsx("span",{className:"min-w-0 truncate",children:i.labels?.[D.path]??D.path})]},D.path))})})]})]}),S.jsxs(Nl,{children:[S.jsx(Rr,{variant:"outline",onClick:t,children:"Отмена"}),S.jsx(Rr,{onClick:T,disabled:!b,children:"Создать"})]})]})}function Txe({paths:e,onClose:t}){const[r,n]=se.useState(""),[s,i]=se.useState(""),[a,u]=se.useState(()=>Kge(e)),[o,c]=se.useState("project"),p=()=>{r.trim()&&(fxe(e,{name:r,description:s,baseName:a,target:o}),t())};return S.jsxs(S.Fragment,{children:[S.jsx(ho,{children:S.jsx(mo,{children:"Создать шаблон"})}),S.jsxs("div",{className:"min-w-0 space-y-3 py-1",children:[S.jsxs("div",{className:"space-y-1.5",children:[S.jsx(tu,{htmlFor:"nt-name",children:"Имя шаблона"}),S.jsx(Bs,{id:"nt-name",autoFocus:!0,value:r,onChange:d=>n(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),p())},placeholder:"например: Форма заявки"})]}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsx(tu,{htmlFor:"nt-desc",children:"Описание"}),S.jsx(Bs,{id:"nt-desc",value:s,onChange:d=>i(d.target.value),placeholder:"необязательно"})]}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsx(tu,{htmlFor:"nt-base",children:"Базовое имя (заменяется плейсхолдерами)"}),S.jsx(Bs,{id:"nt-base",value:a,onChange:d=>u(d.target.value),placeholder:"пусто — не заменять"}),a.trim().length>0&&a.trim().length<4&&S.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Короткое имя может совпасть со случайными словами в коде — проверьте результат."})]}),S.jsxs("div",{className:"space-y-1.5",children:[S.jsx(tu,{children:"Где хранить"}),S.jsx("div",{className:"flex gap-2",children:[["project","В проекте (.reformer/templates)"],["local","Локально в браузере"]].map(([d,h])=>S.jsx("button",{type:"button",onClick:()=>c(d),className:Xt("flex-1 rounded-md border px-2 py-1.5 text-left text-xs",o===d?"border-primary bg-accent":"border-border text-muted-foreground hover:bg-muted"),children:h},d))})]}),S.jsx("div",{className:"max-h-32 overflow-y-auto rounded-md border border-border p-2",children:S.jsx("ul",{className:"min-w-0 space-y-0.5 text-[11px] text-muted-foreground",children:e.map(d=>S.jsx("li",{className:"truncate font-mono",children:d},d))})})]}),S.jsxs(Nl,{children:[S.jsx(Rr,{variant:"outline",onClick:t,children:"Отмена"}),S.jsx(Rr,{onClick:p,disabled:!r.trim()||!e.length,children:"Сохранить"})]})]})}function Axe(e,t,r,n,s){if(n<=0||r<=0)return{start:0,end:0};const i=Math.floor(Math.max(e,0)/r),a=Math.ceil(Math.max(t,0)/r)+1,u=Math.max(0,Math.min(i-s,Math.max(0,n-1))),o=Math.min(n,i+a+s);return{start:u,end:Math.max(o,u)}}function Jk(e){return e?e.querySelector('[data-slot="scroll-area-viewport"]')??e:null}function Sxe(e,t,r=8){const n=se.useRef(null),[s,i]=se.useState({scrollTop:0,viewportHeight:0});se.useEffect(()=>{const c=Jk(n.current);if(!c)return;const p=()=>i(h=>h.scrollTop===c.scrollTop&&h.viewportHeight===c.clientHeight?h:{scrollTop:c.scrollTop,viewportHeight:c.clientHeight});p(),c.addEventListener("scroll",p,{passive:!0});const d=new ResizeObserver(p);return d.observe(c),()=>{c.removeEventListener("scroll",p),d.disconnect()}},[]);const a=se.useCallback(c=>{const p=Jk(n.current);if(!p||c<0)return;const d=c*t,h=d+t;d<p.scrollTop?p.scrollTop=d:h>p.scrollTop+p.clientHeight&&(p.scrollTop=h-p.clientHeight)},[t]),{start:u,end:o}=Axe(s.scrollTop,s.viewportHeight,t,e,r);return{scrollRef:n,start:u,end:o,totalHeight:e*t,offsetTop:u*t,scrollToRow:a}}const Ws="",Fxe=24;function vh(e){return{paddingLeft:`${e*12+8}px`}}function vv(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function wxe(e,t){const r=[];let n=1/0;for(const s of e)s.depth>n||(n=1/0,r.push(s),s.kind==="directory"&&!t.has(s.path)&&(n=s.depth));return r}function kxe({entry:e,expanded:t,loading:r,onActivate:n,depthOffset:s=0}){return e.kind==="directory"?S.jsxs("button",{onClick:i=>n(e,i),style:vh(e.depth+s),className:"flex h-6 w-full items-center gap-1 pr-2 text-left text-[11.5px] font-medium text-muted-foreground hover:text-foreground",children:[r?S.jsx(m3,{className:"h-3 w-3 flex-none animate-spin"}):S.jsx(Rp,{className:Xt("h-3 w-3 flex-none transition-transform",t&&"rotate-90")}),S.jsx(u8,{className:"h-3.5 w-3.5 flex-none opacity-70"}),S.jsx("span",{className:"min-w-0 truncate",children:e.name})]}):e.isForm?S.jsxs("button",{onClick:i=>n(e,i),title:e.path,style:vh(e.depth+1+s),className:"flex h-6 w-full items-center gap-1.5 pr-2 text-left text-xs hover:bg-muted",children:[S.jsx(l8,{className:"h-3.5 w-3.5 flex-none text-primary"}),S.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.name}),S.jsx(o8,{variant:e.confidence==="high"?"default":"secondary",className:"h-4 flex-none px-1.5 text-[9px]",children:e.confidence==="high"?"High":"Med"})]}):S.jsxs("button",{onClick:i=>n(e,i),title:`${e.path} — открыть в редакторе (${gr("Mod")}+клик — добавить к выбору)`,style:vh(e.depth+1+s),className:"flex h-6 w-full items-center gap-1.5 pr-2 text-left text-xs text-muted-foreground hover:bg-muted",children:[S.jsx(yO,{className:"h-3.5 w-3.5 flex-none opacity-70"}),S.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.name})]})}function _xe(){const e=Go(L=>L.dirName),t=Go(L=>L.tree),r=Go(L=>L.loadedDirs),n=Go(L=>L.loadingDirs),s=Go(L=>L.scanning),i=Go(L=>L.error),a=Go(L=>L.canReopen),u=Lge(),[o,c]=se.useState(()=>new Set([Ws])),p=L=>{const ne=!o.has(L);c(Ee=>{const X=new Set(Ee);return ne?X.add(L):X.delete(L),X}),ne&&L!==Ws&&D2e(L)},d=se.useMemo(()=>wxe(t,o),[t,o]),h=o.has(Ws),[m,y]=se.useState(null),v=se.useRef(null),[b,T]=se.useState(null),D=se.useMemo(()=>e?h?[Ws,...d.map(L=>L.path)]:[Ws]:[],[e,h,d]),x=se.useMemo(()=>new Map(d.map(L=>[L.path,L])),[d]),E=Sxe(D.length,Fxe),[A,F]=se.useState(null);se.useEffect(()=>{if(A==null)return;const L=v.current?.querySelector(`[data-tree-path="${CSS.escape(A)}"] button`);L&&(L.focus(),F(null))},[A,E.start,E.end]);const k=L=>{T(L),E.scrollToRow(D.indexOf(L)),F(L)},_=L=>{const ne=L.target.closest("[data-tree-path]");ne&&T(ne.dataset.treePath??null)},[O,q]=se.useState(()=>new Set);se.useEffect(()=>{c(new Set([Ws])),q(new Set),T(null)},[e]);const j=(L,ne)=>{const Ee=L.path;if(ne.metaKey||ne.ctrlKey){ne.preventDefault(),q(X=>{const je=new Set(X);return je.has(Ee)?je.delete(Ee):je.add(Ee),je}),T(Ee);return}if(ne.shiftKey){ne.preventDefault();const X=D.indexOf(b??Ee),je=D.indexOf(Ee);if(X!==-1&&je!==-1){const[K,Q]=X<=je?[X,je]:[je,X];q(new Set(D.slice(K,Q+1).filter(ie=>ie!==Ws)))}T(Ee);return}if(q(new Set([Ee])),T(Ee),L.kind==="directory"){p(Ee);return}PA(L,{preview:ne.detail<2})},V=L=>O.has(L.path)&&O.size>1?[...O]:[L.path],z=L=>{const ne=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","F2","Delete","Backspace"],X=(L.metaKey||L.ctrlKey)&&(L.code==="KeyC"||L.code==="KeyV");if(!ne.includes(L.key)&&!X)return;const je=b??D[0];if(je==null)return;L.preventDefault(),L.stopPropagation();const K=je===Ws,Q=K?null:x.get(je),ie=K||Q?.kind==="directory",M=K?h:Q?o.has(Q.path):!1,B=D.indexOf(je);if(X){L.code==="KeyV"?Tk(ie?je:vv(je)):Q&&Ck(V(Q));return}const U=J=>{const de=D[Math.min(Math.max(B+J,0),D.length-1)];de!=null&&k(de)};L.key==="ArrowDown"?U(1):L.key==="ArrowUp"?U(-1):L.key==="ArrowRight"?ie&&!M?p(je):ie&&M&&U(1):L.key==="ArrowLeft"?ie&&M?p(je):k(K?Ws:vv(je)):L.key==="F2"&&Q?y({kind:"rename",path:Q.path,entryKind:Q.kind,currentName:Q.name}):(L.key==="Delete"||L.key==="Backspace")&&Q&&y({kind:"delete",path:Q.path,name:Q.name})};se.useEffect(()=>{v2e()},[]);const oe=(L,ne,Ee)=>{const X=Ee==="root"?null:Ee,je=Ee==="root"?Ws:Ee.path,K=X?X.kind==="directory"?X.path:vv(X.path):"";return S.jsxs(l3,{children:[S.jsx(c3,{asChild:!0,children:S.jsx("div",{"data-tree-path":je,className:Xt("h-6 focus-within:ring-1 focus-within:ring-ring",(b===je||O.has(je))&&"bg-accent"),children:ne})}),S.jsxs(p3,{className:"w-56",children:[X?.kind==="file"&&WN(X.name)&&S.jsxs(S.Fragment,{children:[S.jsx(sn,{onClick:()=>void Ek(X,"preview"),children:"Открыть предпросмотр"}),S.jsx(sn,{onClick:()=>void Ek(X,"split"),children:"Открыть предпросмотр рядом"}),S.jsx(Kc,{})]}),X&&S.jsxs(sn,{onClick:()=>Ck(V(X)),children:[O.has(X.path)&&O.size>1?`Копировать (${O.size})`:"Копировать",S.jsx(KA,{children:gr("Mod+C")})]}),S.jsxs(sn,{disabled:!u.length,onClick:()=>void Tk(K),children:[u.length>1?`Вставить (${u.length})`:"Вставить",S.jsx(KA,{children:gr("Mod+V")})]}),S.jsx(Kc,{}),S.jsx(sn,{onClick:()=>y({kind:"newFile",dirPath:K}),children:"Новый файл…"}),S.jsx(sn,{onClick:()=>y({kind:"newFolder",dirPath:K}),children:"Новая папка…"}),X&&S.jsx(sn,{onClick:()=>y({kind:"newTemplate",paths:V(X)}),children:O.has(X.path)&&O.size>1?`Создать шаблон (${O.size})…`:"Создать шаблон…"}),S.jsxs(fO,{children:[S.jsx(hO,{children:"Сгенерировать"}),S.jsxs(mO,{children:[S.jsx(sn,{onClick:()=>y({kind:"template",dirPath:K}),children:"Выбрать шаблон…"}),S.jsx(Kc,{}),S.jsx(sn,{onClick:()=>void k2e(K),children:"Модель"}),S.jsx(sn,{onClick:()=>void _2e(K),children:"Схема формы"}),S.jsx(sn,{onClick:()=>void P2e(K),children:"Схема валидации"}),S.jsx(sn,{onClick:()=>void N2e(K),children:"Поведение формы"}),S.jsx(sn,{onClick:()=>void $2e(K),children:"Поведение UI"})]})]}),X&&S.jsxs(S.Fragment,{children:[S.jsx(Kc,{}),S.jsx(sn,{onClick:()=>y({kind:"rename",path:X.path,entryKind:X.kind,currentName:X.name}),children:"Переименовать…"}),S.jsx(sn,{className:"text-destructive focus:text-destructive",onClick:()=>y({kind:"delete",path:X.path,name:X.name}),children:"Удалить"})]})]})]},L)};return S.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[a&&!e&&S.jsx("div",{className:"flex flex-col gap-1.5 border-b border-border p-2",children:S.jsxs(Rr,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-xs",onClick:()=>void b2e(),children:[S.jsx(d3,{className:"h-3.5 w-3.5"})," Переоткрыть проект"]})}),S.jsxs(f3,{ref:E.scrollRef,className:"min-h-0 flex-1 py-1.5",children:[S.jsxs("div",{ref:v,onKeyDown:z,onFocus:_,className:"outline-none",children:[e&&S.jsx("div",{style:{height:E.totalHeight},children:S.jsx("div",{style:{transform:`translateY(${E.offsetTop}px)`},children:D.slice(E.start,E.end).map(L=>{if(L===Ws)return oe("root",S.jsxs("button",{onClick:()=>p(Ws),title:e,style:vh(0),className:"flex h-6 w-full items-center gap-1 pr-2 text-left text-[11.5px] font-semibold text-foreground hover:bg-muted",children:[S.jsx(Rp,{className:Xt("h-3 w-3 flex-none transition-transform",h&&"rotate-90")}),h?S.jsx(dO,{className:"h-3.5 w-3.5 flex-none opacity-80"}):S.jsx(u8,{className:"h-3.5 w-3.5 flex-none opacity-80"}),S.jsx("span",{className:"min-w-0 truncate",children:e}),s&&S.jsx("span",{className:"flex-none text-[10px] font-normal text-muted-foreground",children:"· сканирую…"})]}),"root");const ne=x.get(L);return ne?oe(ne.path,S.jsx(kxe,{entry:ne,depthOffset:1,expanded:o.has(ne.path),loading:n.has(ne.path),onActivate:j}),ne):null})})}),e&&h&&i&&S.jsxs("div",{className:"mx-1 rounded-md border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[11px] text-destructive",children:["Ошибка сканирования: ",i]}),e&&h&&!s&&!i&&r.has(Ws)&&!t.length&&S.jsx("div",{style:vh(1),className:"py-1 text-[11px] text-muted-foreground",children:"Каталог пуст."})]}),!zv()&&S.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-muted-foreground",children:"Открытие проекта требует Chromium (File System Access API). Создать форму — меню «Файл → Новая форма»."})]}),S.jsx(yj,{dialog:m,onClose:()=>y(null)})]})}const Pxe=["HTML","Типографика","Оверлеи","Навигация","Чат"],Kk="Части",Nxe={div:"div",section:"sec",article:"art",aside:"as",header:"hd",footer:"ft",nav:"nav",main:"mn",fieldset:"fs",ul:"ul",ol:"ol",li:"li",hr:"hr",img:"img",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",p:"p",span:"sp",strong:"b",em:"i",small:"sm",blockquote:"bq",code:"cd",pre:"pre",a:"a",label:"lb",br:"br"},$xe={Input:"In",InputPassword:"Ip",InputMask:"Im",InputOTP:"Io",Textarea:"Tx",DatePicker:"Dt",Calendar:"Ca",FileUpload:"Up",FileUploadAvatar:"Av",Select:"Se",NativeSelect:"Ns",Combobox:"Cb",RadioGroup:"Rg",Checkbox:"Ck",Switch:"Sw",Slider:"Sl",Toggle:"Tg",ToggleGroup:"Tg",Box:"Bx",Section:"Sc",FormArray:"Fa"};function Ixe(e){const t=Ca().palette?.glyphs?.[e.name];if(t)return t;const r=T_(e.name);return r?Nxe[r]??r.slice(0,3):$xe[e.name]??(e.name[0]?.toUpperCase()??"")+(e.name[1]?.toLowerCase()??"")}function Bxe(e,t){const r=t.trim().toLowerCase(),n=r?e.filter(s=>s.name.toLowerCase().includes(r)):e.filter(s=>!W3(s));return A_(n3(n))}function jxe(e,t){let r=t;for(;r&&r.length;){const n=Kh(e,r),s=Mt(n?.component);if(s?.op==="component"&&B2(s.arg).length)return s.arg;r=Pn(r)}return null}function Oxe(e,t){let r=t;for(;r&&r.length;){const n=Kh(e,r);if(n&&!xp(n)&&ns(n))return[...r,"children"];r=Pn(r)}return!xp(e.root)&&ns(e.root)?["root","children"]:null}function Vk({title:e,items:t,open:r,onToggle:n,onPick:s}){return S.jsxs("div",{className:"border-b border-border",children:[S.jsxs("button",{type:"button",onClick:n,className:"flex w-full items-center gap-1.5 px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",children:[S.jsx(Rp,{className:`h-3 w-3 flex-none transition-transform ${r?"rotate-90":""}`}),S.jsx("span",{className:"min-w-0 flex-1 truncate",children:e}),S.jsx("span",{className:"flex-none font-mono text-[10px] font-normal text-muted-foreground/50",children:t.length})]}),r&&S.jsx("div",{className:"flex flex-col gap-0.5 px-2 pb-2",children:t.map(i=>S.jsxs("button",{draggable:!0,onDragStart:a=>{jA({kind:"new",entryName:i.name}),a.dataTransfer.effectAllowed="copy"},onDragEnd:()=>OA(),onClick:()=>s(i),className:"flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-[12.5px] hover:bg-muted",children:[S.jsx("span",{className:"grid h-5 min-w-5 flex-none place-items-center rounded border border-border bg-background px-1 font-mono text-[9px] font-semibold text-muted-foreground",children:Ixe(i)}),S.jsx("span",{className:"min-w-0 flex-1 truncate",children:H3(i)}),S.jsx(u3,{className:"h-3.5 w-3.5 flex-none text-muted-foreground/40"})]},i.name))})]})}function Lxe(){const[e,t]=se.useState(""),r=Ta(),n=se.useMemo(()=>Bxe(r,e),[r,e]),s=I2(),i=jl(),a=se.useMemo(()=>i?jxe(i.schema,s):null,[i,s]),u=se.useMemo(()=>a&&!e.trim()?B2(a):[],[a,e]),[o,c]=se.useState(()=>{const m=Ca().palette?.collapsedByDefault??Pxe;return Object.fromEntries(m.map(y=>[y,!0]))}),p=m=>c(y=>({...y,[m]:!y[m]})),d=m=>e.trim()?!0:!o[m],h=m=>{const y=mt.getState(),v=y.activeTabId?y.tabs[y.activeTabId]:null;if(!v)return;const b=Oxe(v.schema,v.selectionPath)??["root","children"];Xe.apply(T=>nR(T,b,m.makeNode()))};return S.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[S.jsx("div",{className:"border-b border-border p-2",children:S.jsx(Bs,{value:e,onChange:m=>t(m.target.value),placeholder:"Поиск компонента…",className:"h-8 text-xs"})}),S.jsxs(f3,{className:"flex-1",children:[u.length>0&&a&&S.jsx(Vk,{title:`Части: ${a}`,items:u,open:d(Kk),onToggle:()=>p(Kk),onPick:h}),n.map(([m,y])=>S.jsx(Vk,{title:m,items:y,open:d(m),onToggle:()=>p(m),onPick:h},m))]})]})}function Mxe(){const e=Bg(h=>h.items),t=Bg(h=>h.loading),r=Bg(h=>h.error),n=Go(h=>h.dirName),[s,i]=se.useState(null),[a,u]=se.useState(null),[o,c]=se.useState({}),p=h=>c(m=>({...m,[h]:!m[h]})),d=se.useMemo(()=>Rge.map(h=>[h,e.filter(m=>m.source===h.source)]).filter(([,h])=>h.length>0),[e]);return se.useEffect(()=>{Lp()},[]),S.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[S.jsxs("div",{className:"flex flex-none items-center justify-between gap-2 border-b border-border px-2 py-1.5",children:[S.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:n?`Проект: ${n}`:"Проект не открыт — только локальные"}),S.jsxs(Rr,{variant:"ghost",size:"sm",className:"h-6 gap-1 px-1.5 text-[11px]",onClick:()=>void Lp(),disabled:t,children:[S.jsx(d3,{className:"h-3 w-3"})," Обновить"]})]}),S.jsxs(f3,{className:"flex-1 py-1.5",children:[r&&S.jsxs("div",{className:"mx-1 rounded-md border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[11px] text-destructive",children:["Ошибка чтения шаблонов: ",r]}),d.map(([{source:h,title:m},y])=>{const v=!o[h];return S.jsxs("div",{className:"border-b border-border last:border-b-0",children:[S.jsxs("button",{type:"button",onClick:()=>p(h),className:"flex w-full items-center gap-1.5 px-3 py-2 text-left text-[10px] font-semibold tracking-wider text-muted-foreground uppercase hover:text-foreground",children:[S.jsx(Rp,{className:Xt("h-3 w-3 flex-none transition-transform",v&&"rotate-90")}),S.jsx("span",{className:"min-w-0 flex-1 truncate",children:m}),S.jsx("span",{className:"flex-none font-mono text-[10px] font-normal text-muted-foreground/50",children:y.length})]}),v&&S.jsx("div",{className:"flex flex-col gap-0.5 px-2 pb-2",children:y.map(b=>S.jsxs(l3,{children:[S.jsx(c3,{asChild:!0,children:S.jsxs("button",{onClick:()=>zk(b),title:`${b.description??b.name} · ${b.files.length} файлов — клик открывает предпросмотр`,className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-xs hover:bg-muted",children:[S.jsx(l8,{className:"h-3.5 w-3.5 flex-none text-primary"}),S.jsx("span",{className:"min-w-0 flex-1 truncate",children:b.name})]})}),S.jsxs(p3,{className:"w-52",children:[S.jsx(sn,{onClick:()=>zk(b),children:"Открыть предпросмотр"}),S.jsx(sn,{onClick:()=>u({kind:"template",dirPath:""}),children:"Создать форму…"}),b.source!=="builtin"&&S.jsxs(S.Fragment,{children:[S.jsx(Kc,{}),S.jsx(sn,{onClick:()=>i({kind:"rename",template:b}),children:"Переименовать…"}),S.jsx(sn,{className:"text-destructive focus:text-destructive",onClick:()=>i({kind:"delete",template:b}),children:"Удалить"})]})]})]},`${b.source}:${b.id}`))})]},h)}),!e.length&&!t&&S.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-muted-foreground",children:"Шаблонов нет. Выделите файлы формы в дереве и выберите «Создать шаблон…»."})]}),S.jsx(Rxe,{dialog:s,onClose:()=>i(null)}),S.jsx(yj,{dialog:a,onClose:()=>u(null)})]})}function Rxe({dialog:e,onClose:t}){return e?S.jsx(S2,{open:!0,onOpenChange:r=>{r||t()},children:S.jsx(F2,{className:"max-w-md",children:e.kind==="rename"?S.jsx(Uxe,{template:e.template,onClose:t},e.template.id):S.jsx(zxe,{template:e.template,onClose:t})})}):null}function Uxe({template:e,onClose:t}){const[r,n]=se.useState(e.name),s=()=>{r.trim()&&(yxe(e,r),t())};return S.jsxs(S.Fragment,{children:[S.jsxs(ho,{children:[S.jsx(mo,{children:"Переименовать шаблон"}),S.jsx(Mp,{children:"Меняется только отображаемое имя — папка шаблона остаётся прежней."})]}),S.jsx(Bs,{autoFocus:!0,value:r,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),s())}}),S.jsxs(Nl,{children:[S.jsx(Rr,{variant:"outline",onClick:t,children:"Отмена"}),S.jsx(Rr,{onClick:s,disabled:!r.trim(),children:"Переименовать"})]})]})}function zxe({template:e,onClose:t}){return S.jsxs(S.Fragment,{children:[S.jsxs(ho,{children:[S.jsx(mo,{children:"Удалить шаблон?"}),S.jsxs(Mp,{children:["«",e.name,"»"," ",e.source==="project"?"будет удалён вместе с папкой в проекте.":"будет удалён из локального хранилища браузера."]})]}),S.jsxs(Nl,{children:[S.jsx(Rr,{variant:"outline",onClick:t,children:"Отмена"}),S.jsx(Rr,{variant:"destructive",onClick:()=>{mxe(e),t()},children:"Удалить"})]})]})}function qxe(e){const t=e.trim();if(t==="")return;const r=Number(t);return Number.isFinite(r)?r:void 0}function Jxe(e){return e===""?void 0:e}const Kxe=24;function Vxe({node:e,path:t,prop:r,classes:n}){const i=(e.componentProps??{})[r.key],a=typeof i=="string"?i:"",u=se.useRef(null),[o,c]=se.useState(!1),[p,d]=se.useState(a.length),[h,m]=se.useState(0),y=j=>Xe.apply(V=>N2(V,t,r.key,j.trim()?j:void 0),{coalesceKey:`${r.key}@${t.join(".")}`}),v=Math.min(p,a.length),b=a.slice(0,v).search(/\S*$/),T=v+(a.slice(v).match(/^\S*/)?.[0].length??0),D=a.slice(b,v),x=new Set(a.split(/\s+/).filter(Boolean)),E=OU(n,D,x,Kxe),A=o&&E.length>0,F=jU(BU(),a),k=E.length?Math.min(h,E.length-1):0,_=()=>d(u.current?.selectionStart??a.length),O=j=>{const V=a.slice(0,b),z=a.slice(T),oe=j+(z.startsWith(" ")?"":" "),L=V+oe+z,ne=V.length+oe.length;y(L),d(ne),m(0),requestAnimationFrame(()=>{const Ee=u.current;Ee&&(Ee.focus(),Ee.setSelectionRange(ne,ne))})},q=j=>{j.key==="ArrowDown"&&A?(j.preventDefault(),j.stopPropagation(),m(V=>Math.min(V+1,E.length-1))):j.key==="ArrowUp"&&A?(j.preventDefault(),j.stopPropagation(),m(V=>Math.max(V-1,0))):(j.key==="Enter"||j.key==="Tab")&&A?(j.preventDefault(),j.stopPropagation(),O(E[k])):j.key==="Escape"&&o&&(j.preventDefault(),j.stopPropagation(),c(!1))};return S.jsxs("div",{className:"flex min-h-6 items-center gap-2.5",children:[S.jsx("span",{className:"w-24 flex-none truncate text-xs",title:r.description,children:r.label}),S.jsxs("div",{className:"relative min-w-0 flex-1",children:[S.jsx("input",{ref:u,value:a,spellCheck:!1,autoComplete:"off",placeholder:"flex gap-4 …",onChange:j=>{y(j.target.value),d(j.target.selectionStart??j.target.value.length),c(!0),m(0)},onKeyDown:q,onSelect:_,onFocus:()=>c(!0),onBlur:()=>c(!1),className:Xt("h-[26px] w-full rounded-md border border-input bg-background px-2 font-mono text-[11px] outline-none focus:border-ring",F.length&&"pr-6")}),F.length>0&&S.jsx("span",{className:"absolute top-1/2 right-1.5 -translate-y-1/2",title:`Нет в словаре кита: ${F.join(", ")}.
|
|
1135
1135
|
Такой класс отрисуется, только если встречается в коде билдера или кита — проверьте результат в превью.`,children:S.jsx(s8,{className:"size-3.5 text-amber-600 dark:text-amber-400"})}),A&&S.jsx("div",{className:"absolute inset-x-0 top-[30px] z-50 max-h-[240px] overflow-auto rounded-md border border-border bg-background p-1 shadow-md",children:E.map((j,V)=>S.jsx("button",{type:"button",onMouseDown:z=>z.preventDefault(),onClick:()=>O(j),className:Xt("block w-full truncate rounded px-2 py-1 text-left font-mono text-[11px]",V===k?"bg-primary/10 text-foreground":"hover:bg-muted"),children:j},j))})]})]})}const Wxe="h-[26px] min-w-0 flex-1 rounded-md border border-input bg-background px-2 text-xs outline-none focus:border-ring";function Hxe({node:e,path:t,prop:r}){const n=jl(),{rawJsonOpen:s}=vi(),a=(e.componentProps??{})[r.key],u=Mt(a),o=u?.op==="dataSource"?u.arg:null,c=Array.isArray(a)?a:null,p=se.useMemo(()=>{const A=new Set(n?Object.keys(Bh(n.schema,n.mock).dataSources):[]);return o&&A.add(o),[...A].sort()},[n,o]),[d,h]=se.useState(!1),[m,y]=se.useState(""),v=A=>Xe.apply(F=>N2(F,t,r.key,A),{coalesceKey:`${r.key}@${t.join(".")}`}),b=A=>v(`$dataSource(${A})`),T=()=>{Xe.setBottomTab("registry"),s||Xe.toggleRawJson()},D=()=>{const A=m.trim();if(!A||!n)return;const F=Bh(n.schema,n.mock);A in F.dataSources||(F.dataSources={...F.dataSources,[A]:Q3(A)},Xe.setMockText(n.id,"dataSources",gD(F,"dataSources"))),b(A),h(!1),y(""),T()},x=A=>{A==="__inline__"?(h(!1),v(c??[])):A==="__new__"?h(!0):(h(!1),b(A))},E=d?"__new__":o??"__inline__";return S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("div",{className:"flex min-h-6 items-center gap-1.5",children:[S.jsx("span",{className:"flex-none text-xs",title:r.description,children:r.label}),o&&!d&&S.jsx("button",{onClick:T,title:`Опции источника «${o}» — во вкладке «Registry»`,className:"flex-none rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",children:S.jsx(gO,{className:"h-3 w-3"})}),S.jsxs("select",{value:E,onChange:A=>x(A.target.value),className:Wxe,children:[S.jsx("option",{value:"__inline__",children:"Инлайн-опции"}),p.map(A=>S.jsxs("option",{value:A,children:["$dataSource(",A,")"]},A)),S.jsx("option",{value:"__new__",children:"+ Новый источник…"})]})]}),d&&S.jsxs("div",{className:"flex items-center gap-1.5",children:[S.jsx(Bs,{autoFocus:!0,value:m,onChange:A=>y(A.target.value),onKeyDown:A=>{A.key==="Enter"&&D(),A.key==="Escape"&&(h(!1),y(""))},placeholder:"ИМЯ_ИСТОЧНИКА",className:"h-[26px] flex-1 bg-background text-xs"}),S.jsx("button",{onClick:D,disabled:!m.trim(),className:"flex-none rounded-md bg-primary px-2 py-1 text-[11px] text-primary-foreground disabled:opacity-50",children:"Создать"}),S.jsx("button",{onClick:()=>{h(!1),y("")},className:"flex-none rounded-md px-1.5 py-1 text-muted-foreground hover:bg-muted",children:S.jsx(w2,{className:"h-3.5 w-3.5"})})]}),!o&&!d&&S.jsx(Gxe,{value:c??[],onChange:v})]})}function Gxe({value:e,onChange:t}){const r=(i,a)=>t(e.map((u,o)=>o===i?{...u,...a}:u)),n=()=>t([...e,{value:`option${e.length+1}`,label:`Вариант ${e.length+1}`}]),s=i=>t(e.filter((a,u)=>u!==i));return S.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.map((i,a)=>S.jsxs("div",{className:"flex items-center gap-1.5",children:[S.jsx(Bs,{value:i.value==null?"":String(i.value),onChange:u=>r(a,{value:u.target.value}),placeholder:"value",className:"h-[24px] w-[64px] flex-none bg-background text-[11px]"}),S.jsx(Bs,{value:i.label??"",onChange:u=>r(a,{label:u.target.value}),placeholder:"label",className:"h-[24px] min-w-0 flex-1 bg-background text-[11px]"}),S.jsx("button",{onClick:()=>s(a),title:"Удалить опцию",className:Xt("flex-none rounded px-1 py-0.5 text-muted-foreground hover:bg-muted"),children:S.jsx(w2,{className:"h-3.5 w-3.5"})})]},a)),S.jsxs("button",{onClick:n,className:"inline-flex items-center gap-1 self-start text-[11px] text-muted-foreground hover:text-foreground",children:[S.jsx(DO,{className:"h-3 w-3"})," Опция"]})]})}const s3=xO,Wk=Object.keys(s3),Xxe=60;function Yxe({node:e,path:t,prop:r}){const s=(e.componentProps??{})[r.key],i=typeof s=="string"?s:"",[a,u]=se.useState(""),[o,c]=se.useState(!1),p=se.useMemo(()=>{const m=a.trim().toLowerCase();return(m?Wk.filter(v=>v.toLowerCase().includes(m)):Wk).slice(0,Xxe)},[a]),d=m=>Xe.apply(y=>N2(y,t,r.key,m),{coalesceKey:`${r.key}@${t.join(".")}`}),h=i?s3[i]:void 0;return S.jsxs("div",{className:"flex min-h-6 items-start gap-2.5",children:[S.jsx("span",{className:"w-24 flex-none truncate pt-1 text-xs",title:r.description,children:r.label}),S.jsxs("div",{className:"relative min-w-0 flex-1",children:[S.jsxs("button",{type:"button",onClick:()=>c(m=>!m),className:"flex h-[26px] w-full items-center gap-2 rounded-md border border-input bg-background px-2 text-xs outline-none focus:border-ring",children:[h?S.jsx(h,{size:14,className:"flex-none"}):S.jsx("span",{className:"flex-none text-muted-foreground",children:"—"}),S.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:i||"Выбрать иконку"})]}),o&&S.jsxs("div",{className:"absolute inset-x-0 top-[30px] z-50 rounded-md border border-border bg-background p-2 shadow-md",children:[S.jsx("input",{autoFocus:!0,value:a,onChange:m=>u(m.target.value),onKeyDown:m=>{m.key==="Escape"&&(m.stopPropagation(),c(!1))},placeholder:"Поиск иконки…",className:"mb-2 h-[26px] w-full rounded border border-input bg-background px-2 text-xs outline-none focus:border-ring"}),S.jsxs("div",{className:"grid max-h-[220px] grid-cols-6 gap-1 overflow-auto",children:[p.map(m=>{const y=s3[m];return S.jsx("button",{type:"button",title:m,onMouseDown:v=>v.preventDefault(),onClick:()=>{d(m),c(!1)},className:Xt("grid aspect-square place-items-center rounded hover:bg-muted",m===i&&"bg-primary/10 text-primary"),children:S.jsx(y,{size:16})},m)}),p.length===0&&S.jsx("div",{className:"col-span-6 py-4 text-center text-xs text-muted-foreground",children:"Ничего не найдено"})]})]})]})]})}const Ev="__unset__",gj="h-[26px] min-w-0 flex-1 bg-background px-2 text-xs data-[size=default]:h-[26px]";function Qxe(e){return e.default==null?"— не задано":`по умолчанию (${String(e.default)})`}function Zxe(e){if(Jn(e))return ll("FormArray");const t=e.component,r=Mt(t);return r?.op==="component"?ll(r.arg):r?.op==="html"?ll(`$html(${r.arg})`):ni(e)?ll("Input"):void 0}function ebe(e){const t=[],r=e.componentProps??{};for(const n of Object.values(r)){const s=Mt(n);s?.op==="dataSource"&&t.push(`$dataSource(${s.arg})`)}return t}function tbe({node:e,path:t,tab:r}){const n=Jn(e)?"array":"value",s=Mt(Jn(e)?e.array:e.value)?.arg??"",[i,a]=se.useState(s),[u,o]=se.useState(s);u!==s&&(o(s),a(s));const c=()=>{const p=i.trim();if(!p||p===s){a(s);return}if(r.mock?.model!=null&&!s.includes(".")&&!p.includes(".")){const d=Bh(r.schema,r.mock);if(s in d.model){const h={...d.model};h[p]=h[s],delete h[s],Xe.setMockText(r.id,"model",gD({...d,model:h},"model"))}}Xe.apply(d=>d_(d,t,n,`$model(${p})`))};return S.jsxs("div",{className:"border-b border-border p-3.5",children:[S.jsx("div",{className:"mb-2.5 text-[10.5px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Свойство модели"}),S.jsxs("div",{className:"flex min-h-6 items-center gap-2.5",children:[S.jsx("span",{className:"w-24 flex-none truncate text-xs",children:"Путь ($model)"}),S.jsx(Bs,{value:i,onChange:p=>a(p.target.value),onBlur:c,onKeyDown:p=>{p.key==="Enter"&&p.currentTarget.blur(),p.key==="Escape"&&(a(s),p.currentTarget.blur())},placeholder:"имя_свойства",className:"h-[26px] min-w-0 flex-1 bg-background font-mono text-xs"})]})]})}function rbe({node:e,path:t,parts:r}){const n=eR(e),s=n===null,i=e.children,a=n!=null&&n>=0?i?.[n]:void 0,u=a==null?"":String(a),o=r.length>0,c=p=>Xe.apply(d=>ZM(d,t,p),{coalesceKey:`text@${t.join(".")}`});return S.jsxs("div",{className:"border-b border-border p-3.5",children:[S.jsx("div",{className:"mb-2.5 text-[10.5px] font-semibold tracking-wider text-muted-foreground uppercase",children:"Содержимое"}),o&&S.jsxs("p",{className:"mb-2.5 text-[11px] leading-snug text-muted-foreground",children:["Содержимое — в частях: ",r.join(" / "),".",a!=null&&" Текст в самом узле ломает раскладку — перенесите его в часть."]}),(!o||a!=null)&&S.jsxs("div",{className:"flex min-h-6 items-center gap-2.5",children:[S.jsx("span",{className:"w-24 flex-none truncate text-xs",title:"Текстовое содержимое узла (text)",children:"Текст"}),s?S.jsx("span",{className:"min-w-0 flex-1 truncate rounded-md bg-muted px-2 py-1 font-mono text-[11px] text-muted-foreground",children:"список фрагментов — правьте в JSON"}):S.jsx(Bs,{value:u,onChange:p=>c(p.target.value),placeholder:"без текста",className:"h-[26px] min-w-0 flex-1 bg-background text-xs"})]})]})}function nbe({node:e,path:t}){const r=Mt(e.component)?.arg,n=r?txe(r):null;if(!n||!r)return null;const s=i=>{const a=n.members.find(o=>o.name===i);if(!a||a.name===r)return;const u=new Set(Object.keys(a.propsSchema.properties??{}));Xe.apply(o=>rR(o,t,a.name,u))};return S.jsxs("div",{className:"flex min-h-6 items-center gap-2.5",children:[S.jsx("span",{className:"w-24 flex-none truncate text-xs",children:"Вариант"}),S.jsxs(c8,{value:r,onValueChange:s,children:[S.jsx(p8,{className:gj,children:S.jsx(d8,{})}),S.jsx(f8,{children:n.members.map(i=>S.jsx(Av,{value:i.name,className:"text-xs",children:i.variant??i.name},i.name))})]})]})}function sbe({node:e,path:t,prop:r,classNames:n}){if(r.widget==="className")return S.jsx(Vxe,{node:e,path:t,prop:r,classes:n});if(r.widget==="dataSource")return S.jsx(Hxe,{node:e,path:t,prop:r});if(r.widget==="icon")return S.jsx(Yxe,{node:e,path:t,prop:r});const i=(e.componentProps??{})[r.key],a=u=>Xe.apply(o=>N2(o,t,r.key,u),{coalesceKey:`${r.key}@${t.join(".")}`});return S.jsxs("div",{className:"flex min-h-6 items-center gap-2.5",children:[S.jsx("span",{className:"w-24 flex-none truncate text-xs",title:r.description,children:r.label}),r.widget==="boolean"&&S.jsx(a8,{className:"ml-auto",checked:i===!0,onCheckedChange:u=>a(u)}),r.widget==="text"&&S.jsx(Bs,{value:i==null?"":String(i),onChange:u=>a(Jxe(u.target.value)),placeholder:r.default==null?void 0:String(r.default),className:"h-[26px] min-w-0 flex-1 bg-background text-xs"}),r.widget==="number"&&S.jsx(Bs,{type:"number",min:r.min,max:r.max,step:r.step,value:i==null?"":String(i),onChange:u=>a(qxe(u.target.value)),placeholder:r.default==null?void 0:String(r.default),className:"h-[26px] min-w-0 flex-1 bg-background text-xs"}),r.widget==="enum"&&S.jsxs(c8,{value:i==null?Ev:String(i),onValueChange:u=>a(u===Ev?void 0:u),children:[S.jsx(p8,{className:gj,children:S.jsx(d8,{})}),S.jsxs(f8,{children:[S.jsx(Av,{value:Ev,className:"text-xs",children:Qxe(r)}),r.options?.map(u=>S.jsx(Av,{value:String(u),className:"text-xs",children:String(u)},String(u)))]})]}),r.widget==="readonly"&&S.jsx("span",{className:"min-w-0 flex-1 truncate rounded-md bg-muted px-2 py-1 font-mono text-[11px] text-muted-foreground",children:i==null?"—":String(i)})]})}function ibe(){const e=jl(),t=I2(),r=e&&t?Kh(e.schema,t):void 0;return r?S.jsx("span",{className:"flex-none rounded-full bg-foreground px-2 py-0.5 font-mono text-[9.5px] font-semibold text-background",children:FD(r)}):null}function abe(){const e=jl(),t=I2(),r=e&&t?Kh(e.schema,t):void 0;if(e?.kind==="code")return S.jsx("div",{id:"rb-properties",className:"grid flex-1 place-items-center p-6 text-center text-xs text-muted-foreground",children:"Свойства недоступны для файла кода — правьте текст в редакторе (Monaco)."});if(!r||!t)return S.jsx("div",{id:"rb-properties",className:"grid flex-1 place-items-center p-6 text-center text-xs text-muted-foreground",children:"Выберите узел в дереве или preview, чтобы редактировать его свойства"});const n=Zxe(r),s=Mi(r,t).some(d=>d.kind==="steps"),i=u_(r)==="container"&&!xp(r)&&!s,a=n?$U(n.name):[],u=n?_U(n.propsSchema):[],o=n?IU(n.name):[],c=i?u.map(d=>({...d,props:d.props.filter(h=>h.key!=="text")})).filter(d=>d.props.length>0||d.group==="Control"):u,p=ebe(r);return S.jsxs("div",{id:"rb-properties",className:"flex-1 overflow-auto",children:[e&&(ni(r)||Jn(r))&&S.jsx(tbe,{node:r,path:t,tab:e}),i&&S.jsx(rbe,{node:r,path:t,parts:a}),c.map(d=>S.jsxs("div",{className:"border-b border-border p-3.5",children:[S.jsx("div",{className:"mb-2.5 text-[10.5px] font-semibold uppercase tracking-wider text-muted-foreground",children:d.group}),S.jsxs("div",{className:"flex flex-col gap-2.5",children:[d.group==="Control"&&S.jsx(nbe,{node:r,path:t}),d.props.map(h=>S.jsx(sbe,{node:r,path:t,prop:h,classNames:o},h.key))]})]},d.group)),!n&&S.jsxs("div",{className:"border-b border-border p-3.5 text-xs text-muted-foreground",children:["Нет props-схемы для ",S.jsx("span",{className:"font-mono",children:FD(r)}),"."]}),p.length>0&&S.jsxs("div",{className:"p-3.5",children:[S.jsx("div",{className:"mb-2.5 text-[10.5px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Привязки"}),S.jsx("div",{className:Xt("flex flex-wrap gap-1.5"),children:p.map(d=>S.jsx("span",{className:"rounded-full border border-border bg-muted px-2.5 py-1 font-mono text-[10.5px]",children:d},d))})]})]})}const Dj={settingsOpen:!1,status:"idle",entries:[],pending:null,conflict:!1,error:null},Ss=Bl(Dj);let Hk=0;function Gk(){return Hk+=1,`m${Hk}`}function Cv(e,t){const r=e.entries.at(-1);return!r||r.role!=="assistant"?e:{...e,entries:[...e.entries.slice(0,-1),t(r)]}}const Xk={toggleSettings:()=>Ss.setState(e=>({...e,settingsOpen:!e.settingsOpen})),setSettings:e=>Ss.setState(t=>({...t,settingsOpen:e})),startTurn:(e,t)=>Ss.setState(r=>({...r,status:"running",error:null,conflict:!1,entries:[...r.entries,{id:Gk(),role:"user",text:e,reasoning:"",tools:[],...t?{snapshot:t}:{}},{id:Gk(),role:"assistant",text:"",reasoning:"",tools:[]}]})),restoreTo:e=>Ss.setState(t=>{const r=t.entries.findIndex(n=>n.id===e);return r<0?t:{...t,entries:t.entries.slice(0,r),pending:null,conflict:!1,error:null}}),appendText:e=>Ss.setState(t=>Cv(t,r=>({...r,text:r.text+e}))),appendReasoning:e=>Ss.setState(t=>Cv(t,r=>({...r,reasoning:r.reasoning+e}))),logTool:e=>Ss.setState(t=>Cv(t,r=>({...r,tools:[...r.tools,e]}))),finishTurn:(e,t)=>Ss.setState(r=>({...r,status:t?"error":e?"review":"idle",pending:e,error:t??null})),setConflict:e=>Ss.setState(t=>({...t,conflict:e})),resolvePending:()=>Ss.setState(e=>({...e,pending:null,conflict:!1,status:"idle"})),reset:()=>Ss.setState({...Dj})};function zve(){return se.useSyncExternalStore(Ss.subscribe,()=>Ss.getState(),()=>Ss.getState())}function obe({keys:e,className:t}){return S.jsx(bO,{className:t,children:aj(e).map((r,n)=>S.jsx(vO,{children:r},n))})}const ube=[{title:"Общие",items:[{label:"Сохранить / Экспорт",combos:["Mod+S"]},{label:"Закрыть модалку / снять выделение",combos:["Escape"]},{label:"Цикл фокуса по зонам (вперёд / назад)",combos:["F6","Shift+F6"]}]},{title:"Панели и вид",items:[{label:"Боковая панель",combos:["Mod+B"]},{label:"Файлы",combos:["Shift+Mod+E"]},{label:"Палитра",combos:["Shift+Mod+B"]},{label:"Свойства",combos:["Alt+Mod+B"]},{label:"Режим отображения (вперёд / назад)",combos:["Mod+Alt+V","Shift+Mod+Alt+V"]},{label:"Схематичный / Renderer / Код",combos:["Mod+Alt+1","Mod+Alt+2","Mod+Alt+3"]},{label:"Renderer: Редактирование ⇄ Тест",combos:["Mod+Alt+E"]}]},{title:"Markdown (.md вкладка)",items:[{label:"Код / Предпросмотр / Рядом (цикл)",combos:["Mod+Shift+V"]},{label:"Открыть предпросмотр рядом",combos:["Mod+K","V"]}]},{title:"Редактирование (холст: Схематичный и Renderer)",items:[{label:"Навигация по узлам (в ряду — ←→ по соседям)",combos:["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]},{label:"Расширить выделение (вдоль ряда / столбца)",combos:["Shift+Arrows"]},{label:"Переместить узел",combos:["Mod+Arrows"]},{label:"Дублировать до / после (вдоль ряда / столбца)",combos:["Shift+Alt+ArrowUp","Shift+Alt+ArrowDown"]},{label:"Добавить компонент",combos:["Enter"]},{label:"Перейти к свойствам",combos:["Space"]},{label:"Дублировать",combos:["Mod+D"]},{label:"Удалить",combos:["Delete","Backspace"]},{label:"Сгруппировать / Разгруппировать",combos:["Mod+G","Shift+Mod+G"]},{label:"Сменить раскладку",combos:["Shift+Mod+L"]},{label:"Отменить / Вернуть",combos:["Mod+Z","Shift+Mod+Z"]}]}];function lbe(){return S.jsxs(S.Fragment,{children:[S.jsxs(ho,{children:[S.jsx(mo,{children:"Горячие клавиши"}),S.jsx(Mp,{children:IA==="mac"?"Комбинации показаны для macOS; на Windows/Linux те же аккорды набираются на Ctrl/Alt.":"Комбинации показаны для Windows/Linux; на macOS те же аккорды набираются на ⌘/⌥."})]}),S.jsx("div",{className:"-mr-2 max-h-[60vh] space-y-5 overflow-y-auto pr-2 py-1",children:ube.map(e=>S.jsxs("section",{className:"space-y-1",children:[S.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e.title}),S.jsx("dl",{className:"divide-y divide-border/60",children:e.items.map(t=>S.jsxs("div",{className:"flex items-center justify-between gap-4 py-1.5",children:[S.jsx("dt",{className:"text-[13px] text-foreground",children:t.label}),S.jsx("dd",{className:"flex flex-none items-center gap-1.5",children:t.combos.map((r,n)=>S.jsxs(se.Fragment,{children:[n>0&&S.jsx("span",{className:"text-xs text-muted-foreground",children:"/"}),S.jsx(obe,{keys:r})]},r))})]},t.label))})]},e.title))})]})}function cbe(){return S.jsxs(S.Fragment,{children:[S.jsx(ho,{children:S.jsxs("div",{className:"flex items-center gap-3",children:[S.jsx("span",{className:"grid h-10 w-10 flex-none place-items-center rounded-lg bg-primary text-primary-foreground shadow-sm",children:S.jsx(h8,{className:"h-5 w-5"})}),S.jsxs("div",{children:[S.jsx(mo,{children:"ReFormer Builder"}),S.jsx(Mp,{children:"Визуальный конструктор форм"})]})]})}),S.jsxs("div",{className:"space-y-3 py-1 text-[13px] leading-relaxed text-muted-foreground",children:[S.jsxs("p",{children:["Собирает схему формы из компонентов"," ",S.jsx("span",{className:"font-medium text-foreground",children:"@reformer/ui-kit"})," и экспортирует её для рендеринга через renderer-react и renderer-json."]}),S.jsx("p",{children:"Схематичный предпросмотр, живой Renderer и генерация кода — в одном окне. Полный список горячих клавиш — в меню «Справка → Горячие клавиши»."})]})]})}function pbe({dialog:e,onClose:t}){return e?S.jsx(S2,{open:!0,onOpenChange:r=>{r||t()},children:S.jsx(F2,{className:e==="shortcuts"?"max-w-lg":"max-w-md",children:e==="shortcuts"?S.jsx(lbe,{}):S.jsx(cbe,{})})}):null}function dbe(){const e=new Set(mt.getState().order);let t=1,r=`new-form-${t}.json`;for(;e.has(r);)r=`new-form-${++t}.json`;Xe.openTab(r,{kind:"new",name:r},R3())}const og="px-2 py-1 text-[12.5px] font-normal";function fbe(){const e=vi(),t=jl(),r=v_(),n=I2()!=null,s=(t?.past.length??0)>0,i=(t?.future.length??0)>0,[a,u]=se.useState(null);return S.jsxs(S.Fragment,{children:[S.jsxs(EO,{className:"h-7 gap-0.5 border-0 bg-transparent p-0 shadow-none",children:[S.jsxs(V1,{children:[S.jsx(W1,{className:og,children:"Файл"}),S.jsxs(H1,{align:"start",children:[S.jsx(Zn,{onClick:dbe,children:"Новая форма"}),S.jsx(Zn,{onClick:()=>void x2e(),children:"Открыть проект…"}),S.jsx(xc,{}),S.jsxs(Zn,{disabled:!t,onClick:()=>t&&void $A(t),children:["Сохранить / Экспорт",S.jsx(Dn,{children:gr("Mod+S")})]}),S.jsx(Zn,{disabled:!t||t.kind==="code",onClick:()=>t&&void B2e(t),children:"Экспортировать как пример…"}),S.jsx(Zn,{disabled:!r,onClick:()=>r&&Jc({kind:"one",id:r}),children:"Закрыть вкладку"})]})]}),S.jsxs(V1,{children:[S.jsx(W1,{className:og,children:"Правка"}),S.jsxs(H1,{align:"start",children:[S.jsxs(Zn,{disabled:!s,onClick:()=>Xe.undo(),children:["Отменить",S.jsx(Dn,{children:gr("Mod+Z")})]}),S.jsxs(Zn,{disabled:!i,onClick:()=>Xe.redo(),children:["Вернуть",S.jsx(Dn,{children:gr("Shift+Mod+Z")})]}),S.jsx(xc,{}),S.jsxs(Zn,{disabled:!t,onClick:()=>Xe.openQuickAdd(),children:["Добавить компонент…",S.jsx(Dn,{children:gr("Enter")})]}),S.jsxs(Zn,{disabled:!n,onClick:()=>Xe.duplicateSelection(),children:["Дублировать",S.jsx(Dn,{children:gr("Mod+D")})]}),S.jsxs(Zn,{disabled:!n,onClick:()=>Xe.deleteSelection(),children:["Удалить",S.jsx(Dn,{children:gr("Backspace")})]}),S.jsx(xc,{}),S.jsxs(Zn,{disabled:!n,onClick:()=>Xe.groupSelection(),children:["Сгруппировать",S.jsx(Dn,{children:gr("Mod+G")})]}),S.jsxs(Zn,{disabled:!n,onClick:()=>Xe.ungroupSelection(),children:["Разгруппировать",S.jsx(Dn,{children:gr("Shift+Mod+G")})]}),S.jsxs(Zn,{disabled:!n,onClick:()=>Xe.flipSelection(),children:["Сменить раскладку",S.jsx(Dn,{children:gr("Shift+Mod+L")})]})]})]}),S.jsxs(V1,{children:[S.jsx(W1,{className:og,children:"Вид"}),S.jsxs(H1,{align:"start",children:[S.jsx(VA,{children:"Предпросмотр"}),S.jsxs(WA,{value:e.preview,onValueChange:o=>Xe.setPreview(o),children:[S.jsxs(bc,{value:"wire",children:["Схематичный",S.jsx(Dn,{children:gr("Mod+Alt+1")})]}),S.jsxs(bc,{value:"runtime",children:["Renderer",S.jsx(Dn,{children:gr("Mod+Alt+2")})]}),S.jsxs(bc,{value:"code",children:["Код",S.jsx(Dn,{children:gr("Mod+Alt+3")})]})]}),DD(t)&&S.jsxs(S.Fragment,{children:[S.jsx(xc,{}),S.jsx(VA,{children:"Markdown"}),S.jsxs(WA,{value:t?.mdView??"code",onValueChange:o=>t&&sd(t.id,o),children:[S.jsxs(bc,{value:"code",children:["Код",S.jsx(Dn,{children:gr("Mod+Shift+V")})]}),S.jsxs(bc,{value:"preview",children:["Предпросмотр",S.jsx(Dn,{children:gr("Mod+Shift+V")})]}),S.jsxs(bc,{value:"split",children:["Рядом",S.jsx(Dn,{children:`${gr("Mod+K")} ${gr("V")}`})]})]})]}),S.jsx(xc,{}),S.jsxs(Zn,{onClick:()=>Xe.toggleLeftPanel(),children:["Боковая панель",S.jsx(Dn,{children:gr("Mod+B")})]}),S.jsxs(Mo,{checked:e.leftPanel==="files",onCheckedChange:()=>Xe.setLeftPanel(e.leftPanel==="files"?null:"files"),children:["Файлы",S.jsx(Dn,{children:gr("Shift+Mod+E")})]}),S.jsxs(Mo,{checked:e.leftPanel==="palette",onCheckedChange:()=>Xe.setLeftPanel(e.leftPanel==="palette"?null:"palette"),children:["Палитра",S.jsx(Dn,{children:gr("Shift+Mod+B")})]}),S.jsx(Mo,{checked:e.leftPanel==="templates",onCheckedChange:()=>Xe.setLeftPanel(e.leftPanel==="templates"?null:"templates"),children:"Шаблоны"}),S.jsxs(Mo,{checked:e.rightPanel==="inspector",onCheckedChange:()=>Xe.setRightPanel(e.rightPanel==="inspector"?null:"inspector"),children:["Свойства",S.jsx(Dn,{children:gr("Alt+Mod+B")})]}),S.jsxs(Mo,{checked:e.rightPanel==="agent",onCheckedChange:()=>Xe.setRightPanel(e.rightPanel==="agent"?null:"agent"),children:["Ассистент",S.jsx(Dn,{children:gr("Mod+Shift+K")})]}),S.jsx(Mo,{checked:e.rawJsonOpen,onCheckedChange:()=>Xe.toggleRawJson(),children:"Нижняя панель"}),S.jsx(Mo,{checked:e.hideDivWrappers,onCheckedChange:()=>Xe.toggleHideDivWrappers(),children:"Скрывать div-контейнеры"}),S.jsx(xc,{}),S.jsx(Mo,{checked:e.theme==="dark",onCheckedChange:()=>Xe.setTheme(e.theme==="dark"?"light":"dark"),children:"Тёмная тема"})]})]}),S.jsxs(V1,{children:[S.jsx(W1,{className:og,children:"Справка"}),S.jsxs(H1,{align:"start",children:[S.jsx(Zn,{onClick:()=>u("shortcuts"),children:"Горячие клавиши"}),S.jsx(Zn,{onClick:()=>u("about"),children:"О программе"})]})]})]}),S.jsx(pbe,{dialog:a,onClose:()=>u(null)})]})}const hbe=500;function mbe(){const e=zO(),t=JO(),r=t?.kit.id??UO;if(se.useEffect(()=>{t&&(t.fallbackReason?wt.error("Кит не активирован",{description:`${t.fallbackReason}. Работаем на ките по умолчанию.`,duration:12e3}):t.missingInfra.length&&wt.warning(`${t.kit.label} ${t.kit.version}`,{description:`Кит не поставляет: ${t.missingInfra.join(", ")}. Эти узлы в превью — заглушки.`,duration:8e3}))},[t]),e.length<2)return null;const n=s=>{if(s===r)return;const i=e.find(u=>u.id===s);window.confirm(`Переключить UI-kit на «${i?.label} ${i?.version}»?
|
|
1136
1136
|
|
|
1137
|
-
Страница перезагрузится. Черновики вкладок сохранятся, вкладки открытых файлов проекта придётся открыть заново.`)&&(qO(s),setTimeout(()=>location.reload(),hbe))};return S.jsxs("label",{className:"flex items-center gap-1.5",title:"Активный UI-kit для палитры и превью",children:[S.jsx("span",{className:"sr-only",children:"UI-kit"}),S.jsx("select",{value:r,onChange:s=>n(s.target.value),className:"h-7 rounded-md border border-border bg-background px-1.5 text-[12px] text-muted-foreground hover:text-foreground",children:e.map(s=>S.jsxs("option",{value:s.id,children:[s.label," ",s.version]},s.id))})]})}function ybe(){const e=Ca().branding,t=e?.productName??"ReFormer Builder";return S.jsxs("header",{className:"flex h-9 flex-none items-center gap-2 border-b border-border bg-sidebar px-2.5",children:[S.jsxs("div",{className:"flex select-none items-center gap-2",children:[S.jsx("span",{className:"grid h-[22px] w-[22px] place-items-center overflow-hidden rounded-md bg-primary text-primary-foreground shadow-sm",children:e?.logoUrl?S.jsx("img",{src:e.logoUrl,alt:"",className:"h-full w-full object-contain"}):S.jsx(h8,{className:"h-3.5 w-3.5"})}),S.jsx("span",{className:"text-[13px] font-semibold tracking-tight text-foreground",children:t})]}),S.jsx(fbe,{}),S.jsx("div",{className:"flex-1"}),S.jsx(mbe,{})]})}function gbe(){return{$schema:"./form-schema.schema.json",version:"1.0",root:{component:"$html(div)",componentProps:{className:"space-y-6"},children:[{component:"$component(Section)",componentProps:{title:"Заявка на кредит",titleClassName:"text-lg font-semibold",className:"space-y-4"},children:[{value:"$model(loanType)",component:"$component(Select)",componentProps:{label:"Тип кредита",placeholder:"Выберите тип",options:"$dataSource(LOAN_TYPES)"}},{value:"$model(loanAmount)",component:"$component(Input)",componentProps:{label:"Сумма кредита, ₽",type:"number",placeholder:"0"}},{value:"$model(comment)",component:"$component(Textarea)",componentProps:{label:"Комментарий",placeholder:"Необязательно",rows:3}},{value:"$model(agree)",component:"$component(Checkbox)",componentProps:{label:"Согласие на обработку персональных данных"}}]}]}}}const xj="rb.seeded";function Dbe(){try{return localStorage.getItem(xj)!=null}catch{return!1}}function xbe(){try{localStorage.setItem(xj,"1")}catch{}}function bbe(){const e=Ca().project?.seedSchema,t=e===void 0?gbe():e??R3(),r=e===void 0?"credit-application.renderer.schema.json":"untitled.renderer.schema.json";Xe.openTab(r,{kind:"new",name:r},t)}async function vbe(){const e=await yU();e.length&&Xe.restoreTabs(e.map(CU));const t=TU(e);return!mt.getState().activeTabId&&!Dbe()&&(xbe(),bbe()),t}const Ebe=se.lazy(()=>Pl(()=>import("./ChatPanel-9qHpjmLO.js").then(e=>e.C),__vite__mapDeps([16,2,3,4,5,1,8])).then(e=>({default:e.ChatPanel}))),Yk="rounded-md px-1.5 py-2.5 text-[11.5px] font-medium [writing-mode:vertical-rl] rotate-180 cursor-pointer",i3=[{kind:"files",title:"Файлы",heading:"Файлы проекта",render:()=>S.jsx(_xe,{})},{kind:"palette",title:"Палитра",heading:"Палитра компонентов",render:()=>S.jsx(Lxe,{})},{kind:"templates",title:"Шаблоны",heading:"Шаблоны форм",render:()=>S.jsx(Mxe,{})}];function Qk(e){return i3.find(t=>t.kind===e)??i3[0]}const a3=[{kind:"inspector",title:"Свойства",heading:"Свойства",actions:()=>S.jsx(ibe,{}),render:()=>S.jsx(abe,{})},{kind:"agent",title:"Ассистент",heading:"Ассистент",actions:()=>S.jsx(Cbe,{}),render:()=>S.jsx(se.Suspense,{fallback:null,children:S.jsx(Ebe,{})})}];function Cbe(){return S.jsxs("div",{className:"flex items-center gap-0.5",children:[S.jsx(Rr,{variant:"ghost",size:"icon-xs",title:"Канал к модели",onClick:Xk.toggleSettings,children:S.jsx(i8,{})}),S.jsx(Rr,{variant:"ghost",size:"icon-xs",title:"Новый разговор",onClick:Xk.reset,children:S.jsx(d3,{})})]})}function Tv(e){return a3.find(t=>t.kind===e)??a3[0]}function Tbe(e){const t=e;if(!t||!t.tagName)return!1;const r=t.tagName;return r==="INPUT"||r==="TEXTAREA"||r==="SELECT"||t.isContentEditable?!0:typeof t.closest=="function"&&t.closest(".monaco-editor")!=null}function Zk(e){switch(e){case"ArrowUp":return"up";case"ArrowDown":return"down";case"ArrowLeft":return"left";case"ArrowRight":return"right";default:return null}}function e8(){const e=document.getElementById("rb-properties");(e?.querySelector("input, textarea, select")??e?.querySelector("button, [tabindex]"))?.focus()}const o3="data-rb-zone";function Abe(e){const t=[];return e.leftPanel&&t.push("left"),t.push("center"),e.rightPanel&&t.push("right"),t}function Sbe(){const t=document.activeElement?.closest?.(`[${o3}]`)?.getAttribute(o3);return t==="left"||t==="center"||t==="right"?t:null}function A2(e){const t=document.querySelector(`[${o3}="${e}"]`);if(!t)return;if(e==="center"){t.focus();return}(t.querySelector('input, textarea, select, button, a[href], [tabindex]:not([tabindex="-1"])')??t).focus()}function Fbe(e,t){const r=Abe(e);if(!r.length)return;const n=r.indexOf(Sbe()??"");if(n===-1){A2(t===1?r[0]:r[r.length-1]);return}A2(r[(n+t+r.length)%r.length])}function t8(e){const t=mt.getState().ui.leftPanel===e;Xe.setLeftPanel(t?null:e),t||requestAnimationFrame(()=>A2("left"))}function r8(e){const t=mt.getState().ui.rightPanel===e;Xe.toggleRightPanelTo(e),t||requestAnimationFrame(()=>A2("right"))}const wbe=1500,ug=["wire","runtime","code"];function kbe(e){const t=mt.getState().ui.preview,r=ug.indexOf(t),n=ug[(r+e+ug.length)%ug.length];Xe.setPreview(n)}function _be(){const e=vi(),t=jl(),r=C3({id:"rb.layout.h",storage:localStorage,panelIds:["left","center","right"]});return se.useEffect(()=>{let n,s=!1;return vbe().then(i=>{s?i():n=i}),()=>{s=!0,n?.()}},[]),se.useEffect(()=>{document.documentElement.classList.toggle("dark",e.theme==="dark")},[e.theme]),se.useEffect(()=>{let n=0;const s=i=>{const a=i.metaKey||i.ctrlKey;if(a&&i.key.toLowerCase()==="s"){i.preventDefault();const h=$i(mt.getState());h&&(h.kind==="code"?C2e(h):$A(h));return}const u=i.key.toLowerCase();if(a&&u==="b"){i.preventDefault(),i.altKey?Xe.toggleRightPanel():i.shiftKey?t8("palette"):Xe.toggleLeftPanel();return}if(a&&i.shiftKey&&u==="e"){i.preventDefault(),t8("files");return}if(a&&i.shiftKey&&i.code==="KeyK"){i.preventDefault(),r8("agent");return}if(i.key==="F6"){i.preventDefault(),Fbe(mt.getState().ui,i.shiftKey?-1:1);return}if(DD($i(mt.getState()))){if(a&&i.shiftKey&&i.code==="KeyV"){i.preventDefault(),GN(1);return}if(a&&!i.shiftKey&&i.code==="KeyK"){i.preventDefault(),n=performance.now();return}if(i.code==="KeyV"&&performance.now()-n<wbe){i.preventDefault(),n=0;const h=$i(mt.getState());h&&sd(h.id,"split");return}}if(a&&i.altKey&&i.code==="KeyV"){i.preventDefault(),kbe(i.shiftKey?-1:1);return}if(a&&i.altKey&&i.code==="KeyE"){i.preventDefault(),Xe.toggleRuntimeMode();return}if(a&&i.altKey&&(i.code==="Digit1"||i.code==="Digit2"||i.code==="Digit3")){i.preventDefault();const h={Digit1:"wire",Digit2:"runtime",Digit3:"code"};Xe.setPreview(h[i.code]);return}if(Tbe(i.target)){if(i.key==="Escape"){Ga.close();const h=i.target;(h.tagName==="INPUT"||h.tagName==="TEXTAREA"||h.tagName==="SELECT")&&h.blur()}return}const o=mt.getState();if($i(o)?.kind==="code")return;const c=(o.ui.preview==="wire"||o.ui.preview==="runtime"&&o.ui.runtimeMode==="edit")&&$i(o)!=null;if(i.key==="Escape"){Ga.close(),c&&Xe.collapseSelection();return}if(!c)return;if(i.key===" "){const h=i.target;if(h&&(h.tagName==="BUTTON"||h.closest?.('button, a, [role="button"]'))||!$i(o)?.selectionPath)return;i.preventDefault(),o.ui.rightPanel!=="inspector"?(Xe.setRightPanel("inspector"),requestAnimationFrame(e8)):e8();return}if(i.key==="Enter"){const h=i.target;if(h&&(h.tagName==="BUTTON"||h.closest?.('button, a, [role="button"]')))return;i.preventDefault(),Xe.openQuickAdd();return}const p=i.altKey&&i.shiftKey?Zk(i.key):null;if(p){i.preventDefault(),Xe.duplicateSelection(p);return}const d=Zk(i.key);if(d){i.preventDefault(),a?Xe.moveSelection(d):Xe.navigate(d,i.shiftKey);return}if(i.key==="Delete"||i.key==="Backspace"){i.preventDefault(),Xe.deleteSelection();return}if(a&&i.key.toLowerCase()==="d"){i.preventDefault(),Xe.duplicateSelection();return}if(a&&i.key.toLowerCase()==="g"){i.preventDefault(),i.shiftKey?Xe.ungroupSelection():Xe.groupSelection();return}if(a&&i.shiftKey&&i.key.toLowerCase()==="l"){i.preventDefault(),Xe.flipSelection();return}a&&i.key.toLowerCase()==="z"&&(i.preventDefault(),i.shiftKey?Xe.redo():Xe.undo())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[]),S.jsxs(CO,{children:[S.jsxs("div",{className:"flex h-screen flex-col overflow-hidden bg-background text-[13px] text-foreground",children:[S.jsx(ybe,{}),S.jsxs("div",{className:"flex min-h-0 flex-1",children:[S.jsxs("div",{className:"flex w-[38px] flex-none flex-col items-center gap-1 border-r border-border bg-sidebar py-1.5",children:[i3.map(({kind:n,title:s})=>S.jsx("button",{onClick:()=>Xe.setLeftPanel(e.leftPanel===n?null:n),className:Xt(Yk,e.leftPanel===n?"bg-muted":"text-muted-foreground hover:bg-muted"),children:s},n)),S.jsx("div",{className:"flex-1"}),S.jsx("button",{title:e.theme==="dark"?"Светлая тема":"Тёмная тема",onClick:()=>Xe.setTheme(e.theme==="dark"?"light":"dark"),className:"grid h-7 w-7 flex-none place-items-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground",children:e.theme==="dark"?S.jsx(TO,{className:"h-4 w-4"}):S.jsx(AO,{className:"h-4 w-4"})})]}),S.jsxs(A3,{orientation:"horizontal",className:"min-w-0 flex-1",defaultLayout:r.defaultLayout,onLayoutChanged:r.onLayoutChanged,children:[e.leftPanel&&S.jsxs(S.Fragment,{children:[S.jsxs(hl,{id:"left","data-rb-zone":"left",tabIndex:-1,defaultSize:250,minSize:180,maxSize:520,className:"flex flex-col bg-sidebar outline-none",children:[S.jsx("div",{className:"flex h-[34px] flex-none items-center border-b border-border px-3 text-[11.5px] font-semibold text-muted-foreground",children:Qk(e.leftPanel).heading}),Qk(e.leftPanel).render()]}),S.jsx(jg,{withHandle:!0})]}),S.jsxs(hl,{id:"center","data-rb-zone":"center",tabIndex:-1,minSize:360,className:"flex flex-col outline-none",children:[S.jsx(XDe,{}),t?t.kind==="code"?S.jsx(KDe,{tab:t}):S.jsx(jDe,{tab:t}):S.jsx("div",{className:"grid flex-1 place-items-center text-muted-foreground",children:"Нет открытой схемы"})]}),e.rightPanel&&S.jsxs(S.Fragment,{children:[S.jsx(jg,{withHandle:!0}),S.jsxs(hl,{id:"right","data-rb-zone":"right",tabIndex:-1,defaultSize:300,minSize:220,maxSize:640,className:"flex flex-col bg-sidebar outline-none",children:[S.jsxs("div",{className:"flex h-[34px] flex-none items-center justify-between border-b border-border px-3 text-[11.5px] font-semibold text-muted-foreground",children:[S.jsx("span",{children:Tv(e.rightPanel).heading}),Tv(e.rightPanel).actions?.()]}),Tv(e.rightPanel).render()]})]})]}),S.jsx("div",{className:"flex w-[34px] flex-none flex-col items-center gap-1 border-l border-border bg-sidebar pt-2",children:a3.map(({kind:n,title:s})=>S.jsx("button",{onClick:()=>r8(n),className:Xt(Yk,e.rightPanel===n?"bg-muted":"text-muted-foreground hover:bg-muted"),children:s},n))})]})]}),S.jsx(QDe,{}),S.jsx(ZDe,{}),S.jsx(cxe,{}),S.jsx(ZL,{})]})}function Pbe(){return S.jsx(_be,{})}const qve=Object.freeze(Object.defineProperty({__proto__:null,default:Pbe},Symbol.toStringTag,{value:"Module"}));export{Uve as $,Jbe as A,qbe as B,L3 as C,bp as D,z8 as E,Vbe as F,Ls as G,hM as H,uR as I,Vh as J,ml as K,z3 as L,Kbe as M,N2 as N,d_ as O,xp as P,Jn as Q,eR as R,ZM as S,Nge as T,LB as U,Xk as V,Ss as W,ni as X,Xt as Y,zve as Z,Wbe as _,ns as a,qve as a0,mq as b,FM as c,kn as d,qv as e,mt as f,Ta as g,$i as h,an as i,Xe as j,Pr as k,o5 as l,zbe as m,u_ as n,Mi as o,Mt as p,W3 as q,Ube as r,Da as s,Bc as t,wU as u,r5 as v,ll as w,$U as x,o_ as y,fM as z};
|
|
1137
|
+
Страница перезагрузится. Черновики вкладок сохранятся, вкладки открытых файлов проекта придётся открыть заново.`)&&(qO(s),setTimeout(()=>location.reload(),hbe))};return S.jsxs("label",{className:"flex items-center gap-1.5",title:"Активный UI-kit для палитры и превью",children:[S.jsx("span",{className:"sr-only",children:"UI-kit"}),S.jsx("select",{value:r,onChange:s=>n(s.target.value),className:"h-7 rounded-md border border-border bg-background px-1.5 text-[12px] text-muted-foreground hover:text-foreground",children:e.map(s=>S.jsxs("option",{value:s.id,children:[s.label," ",s.version]},s.id))})]})}function ybe(){const e=Ca().branding,t=e?.productName??"ReFormer Builder";return S.jsxs("header",{className:"flex h-9 flex-none items-center gap-2 border-b border-border bg-sidebar px-2.5",children:[S.jsxs("div",{className:"flex select-none items-center gap-2",children:[S.jsx("span",{className:"grid h-[22px] w-[22px] place-items-center overflow-hidden rounded-md bg-primary text-primary-foreground shadow-sm",children:e?.logoUrl?S.jsx("img",{src:e.logoUrl,alt:"",className:"h-full w-full object-contain"}):S.jsx(h8,{className:"h-3.5 w-3.5"})}),S.jsx("span",{className:"text-[13px] font-semibold tracking-tight text-foreground",children:t})]}),S.jsx(fbe,{}),S.jsx("div",{className:"flex-1"}),S.jsx(mbe,{})]})}function gbe(){return{$schema:"./form-schema.schema.json",version:"1.0",root:{component:"$html(div)",componentProps:{className:"space-y-6"},children:[{component:"$component(Section)",componentProps:{title:"Заявка на кредит",titleClassName:"text-lg font-semibold",className:"space-y-4"},children:[{value:"$model(loanType)",component:"$component(Select)",componentProps:{label:"Тип кредита",placeholder:"Выберите тип",options:"$dataSource(LOAN_TYPES)"}},{value:"$model(loanAmount)",component:"$component(Input)",componentProps:{label:"Сумма кредита, ₽",type:"number",placeholder:"0"}},{value:"$model(comment)",component:"$component(Textarea)",componentProps:{label:"Комментарий",placeholder:"Необязательно",rows:3}},{value:"$model(agree)",component:"$component(Checkbox)",componentProps:{label:"Согласие на обработку персональных данных"}}]}]}}}const xj="rb.seeded";function Dbe(){try{return localStorage.getItem(xj)!=null}catch{return!1}}function xbe(){try{localStorage.setItem(xj,"1")}catch{}}function bbe(){const e=Ca().project?.seedSchema,t=e===void 0?gbe():e??R3(),r=e===void 0?"credit-application.renderer.schema.json":"untitled.renderer.schema.json";Xe.openTab(r,{kind:"new",name:r},t)}async function vbe(){const e=await yU();e.length&&Xe.restoreTabs(e.map(CU));const t=TU(e);return!mt.getState().activeTabId&&!Dbe()&&(xbe(),bbe()),t}const Ebe=se.lazy(()=>Pl(()=>import("./ChatPanel-B4wt7hBH.js").then(e=>e.C),__vite__mapDeps([16,2,3,4,5,1,8])).then(e=>({default:e.ChatPanel}))),Yk="rounded-md px-1.5 py-2.5 text-[11.5px] font-medium [writing-mode:vertical-rl] rotate-180 cursor-pointer",i3=[{kind:"files",title:"Файлы",heading:"Файлы проекта",render:()=>S.jsx(_xe,{})},{kind:"palette",title:"Палитра",heading:"Палитра компонентов",render:()=>S.jsx(Lxe,{})},{kind:"templates",title:"Шаблоны",heading:"Шаблоны форм",render:()=>S.jsx(Mxe,{})}];function Qk(e){return i3.find(t=>t.kind===e)??i3[0]}const a3=[{kind:"inspector",title:"Свойства",heading:"Свойства",actions:()=>S.jsx(ibe,{}),render:()=>S.jsx(abe,{})},{kind:"agent",title:"Ассистент",heading:"Ассистент",actions:()=>S.jsx(Cbe,{}),render:()=>S.jsx(se.Suspense,{fallback:null,children:S.jsx(Ebe,{})})}];function Cbe(){return S.jsxs("div",{className:"flex items-center gap-0.5",children:[S.jsx(Rr,{variant:"ghost",size:"icon-xs",title:"Канал к модели",onClick:Xk.toggleSettings,children:S.jsx(i8,{})}),S.jsx(Rr,{variant:"ghost",size:"icon-xs",title:"Новый разговор",onClick:Xk.reset,children:S.jsx(d3,{})})]})}function Tv(e){return a3.find(t=>t.kind===e)??a3[0]}function Tbe(e){const t=e;if(!t||!t.tagName)return!1;const r=t.tagName;return r==="INPUT"||r==="TEXTAREA"||r==="SELECT"||t.isContentEditable?!0:typeof t.closest=="function"&&t.closest(".monaco-editor")!=null}function Zk(e){switch(e){case"ArrowUp":return"up";case"ArrowDown":return"down";case"ArrowLeft":return"left";case"ArrowRight":return"right";default:return null}}function e8(){const e=document.getElementById("rb-properties");(e?.querySelector("input, textarea, select")??e?.querySelector("button, [tabindex]"))?.focus()}const o3="data-rb-zone";function Abe(e){const t=[];return e.leftPanel&&t.push("left"),t.push("center"),e.rightPanel&&t.push("right"),t}function Sbe(){const t=document.activeElement?.closest?.(`[${o3}]`)?.getAttribute(o3);return t==="left"||t==="center"||t==="right"?t:null}function A2(e){const t=document.querySelector(`[${o3}="${e}"]`);if(!t)return;if(e==="center"){t.focus();return}(t.querySelector('input, textarea, select, button, a[href], [tabindex]:not([tabindex="-1"])')??t).focus()}function Fbe(e,t){const r=Abe(e);if(!r.length)return;const n=r.indexOf(Sbe()??"");if(n===-1){A2(t===1?r[0]:r[r.length-1]);return}A2(r[(n+t+r.length)%r.length])}function t8(e){const t=mt.getState().ui.leftPanel===e;Xe.setLeftPanel(t?null:e),t||requestAnimationFrame(()=>A2("left"))}function r8(e){const t=mt.getState().ui.rightPanel===e;Xe.toggleRightPanelTo(e),t||requestAnimationFrame(()=>A2("right"))}const wbe=1500,ug=["wire","runtime","code"];function kbe(e){const t=mt.getState().ui.preview,r=ug.indexOf(t),n=ug[(r+e+ug.length)%ug.length];Xe.setPreview(n)}function _be(){const e=vi(),t=jl(),r=C3({id:"rb.layout.h",storage:localStorage,panelIds:["left","center","right"]});return se.useEffect(()=>{let n,s=!1;return vbe().then(i=>{s?i():n=i}),()=>{s=!0,n?.()}},[]),se.useEffect(()=>{document.documentElement.classList.toggle("dark",e.theme==="dark")},[e.theme]),se.useEffect(()=>{let n=0;const s=i=>{const a=i.metaKey||i.ctrlKey;if(a&&i.key.toLowerCase()==="s"){i.preventDefault();const h=$i(mt.getState());h&&(h.kind==="code"?C2e(h):$A(h));return}const u=i.key.toLowerCase();if(a&&u==="b"){i.preventDefault(),i.altKey?Xe.toggleRightPanel():i.shiftKey?t8("palette"):Xe.toggleLeftPanel();return}if(a&&i.shiftKey&&u==="e"){i.preventDefault(),t8("files");return}if(a&&i.shiftKey&&i.code==="KeyK"){i.preventDefault(),r8("agent");return}if(i.key==="F6"){i.preventDefault(),Fbe(mt.getState().ui,i.shiftKey?-1:1);return}if(DD($i(mt.getState()))){if(a&&i.shiftKey&&i.code==="KeyV"){i.preventDefault(),GN(1);return}if(a&&!i.shiftKey&&i.code==="KeyK"){i.preventDefault(),n=performance.now();return}if(i.code==="KeyV"&&performance.now()-n<wbe){i.preventDefault(),n=0;const h=$i(mt.getState());h&&sd(h.id,"split");return}}if(a&&i.altKey&&i.code==="KeyV"){i.preventDefault(),kbe(i.shiftKey?-1:1);return}if(a&&i.altKey&&i.code==="KeyE"){i.preventDefault(),Xe.toggleRuntimeMode();return}if(a&&i.altKey&&(i.code==="Digit1"||i.code==="Digit2"||i.code==="Digit3")){i.preventDefault();const h={Digit1:"wire",Digit2:"runtime",Digit3:"code"};Xe.setPreview(h[i.code]);return}if(Tbe(i.target)){if(i.key==="Escape"){Ga.close();const h=i.target;(h.tagName==="INPUT"||h.tagName==="TEXTAREA"||h.tagName==="SELECT")&&h.blur()}return}const o=mt.getState();if($i(o)?.kind==="code")return;const c=(o.ui.preview==="wire"||o.ui.preview==="runtime"&&o.ui.runtimeMode==="edit")&&$i(o)!=null;if(i.key==="Escape"){Ga.close(),c&&Xe.collapseSelection();return}if(!c)return;if(i.key===" "){const h=i.target;if(h&&(h.tagName==="BUTTON"||h.closest?.('button, a, [role="button"]'))||!$i(o)?.selectionPath)return;i.preventDefault(),o.ui.rightPanel!=="inspector"?(Xe.setRightPanel("inspector"),requestAnimationFrame(e8)):e8();return}if(i.key==="Enter"){const h=i.target;if(h&&(h.tagName==="BUTTON"||h.closest?.('button, a, [role="button"]')))return;i.preventDefault(),Xe.openQuickAdd();return}const p=i.altKey&&i.shiftKey?Zk(i.key):null;if(p){i.preventDefault(),Xe.duplicateSelection(p);return}const d=Zk(i.key);if(d){i.preventDefault(),a?Xe.moveSelection(d):Xe.navigate(d,i.shiftKey);return}if(i.key==="Delete"||i.key==="Backspace"){i.preventDefault(),Xe.deleteSelection();return}if(a&&i.key.toLowerCase()==="d"){i.preventDefault(),Xe.duplicateSelection();return}if(a&&i.key.toLowerCase()==="g"){i.preventDefault(),i.shiftKey?Xe.ungroupSelection():Xe.groupSelection();return}if(a&&i.shiftKey&&i.key.toLowerCase()==="l"){i.preventDefault(),Xe.flipSelection();return}a&&i.key.toLowerCase()==="z"&&(i.preventDefault(),i.shiftKey?Xe.redo():Xe.undo())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[]),S.jsxs(CO,{children:[S.jsxs("div",{className:"flex h-screen flex-col overflow-hidden bg-background text-[13px] text-foreground",children:[S.jsx(ybe,{}),S.jsxs("div",{className:"flex min-h-0 flex-1",children:[S.jsxs("div",{className:"flex w-[38px] flex-none flex-col items-center gap-1 border-r border-border bg-sidebar py-1.5",children:[i3.map(({kind:n,title:s})=>S.jsx("button",{onClick:()=>Xe.setLeftPanel(e.leftPanel===n?null:n),className:Xt(Yk,e.leftPanel===n?"bg-muted":"text-muted-foreground hover:bg-muted"),children:s},n)),S.jsx("div",{className:"flex-1"}),S.jsx("button",{title:e.theme==="dark"?"Светлая тема":"Тёмная тема",onClick:()=>Xe.setTheme(e.theme==="dark"?"light":"dark"),className:"grid h-7 w-7 flex-none place-items-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground",children:e.theme==="dark"?S.jsx(TO,{className:"h-4 w-4"}):S.jsx(AO,{className:"h-4 w-4"})})]}),S.jsxs(A3,{orientation:"horizontal",className:"min-w-0 flex-1",defaultLayout:r.defaultLayout,onLayoutChanged:r.onLayoutChanged,children:[e.leftPanel&&S.jsxs(S.Fragment,{children:[S.jsxs(hl,{id:"left","data-rb-zone":"left",tabIndex:-1,defaultSize:250,minSize:180,maxSize:520,className:"flex flex-col bg-sidebar outline-none",children:[S.jsx("div",{className:"flex h-[34px] flex-none items-center border-b border-border px-3 text-[11.5px] font-semibold text-muted-foreground",children:Qk(e.leftPanel).heading}),Qk(e.leftPanel).render()]}),S.jsx(jg,{withHandle:!0})]}),S.jsxs(hl,{id:"center","data-rb-zone":"center",tabIndex:-1,minSize:360,className:"flex flex-col outline-none",children:[S.jsx(XDe,{}),t?t.kind==="code"?S.jsx(KDe,{tab:t}):S.jsx(jDe,{tab:t}):S.jsx("div",{className:"grid flex-1 place-items-center text-muted-foreground",children:"Нет открытой схемы"})]}),e.rightPanel&&S.jsxs(S.Fragment,{children:[S.jsx(jg,{withHandle:!0}),S.jsxs(hl,{id:"right","data-rb-zone":"right",tabIndex:-1,defaultSize:300,minSize:220,maxSize:640,className:"flex flex-col bg-sidebar outline-none",children:[S.jsxs("div",{className:"flex h-[34px] flex-none items-center justify-between border-b border-border px-3 text-[11.5px] font-semibold text-muted-foreground",children:[S.jsx("span",{children:Tv(e.rightPanel).heading}),Tv(e.rightPanel).actions?.()]}),Tv(e.rightPanel).render()]})]})]}),S.jsx("div",{className:"flex w-[34px] flex-none flex-col items-center gap-1 border-l border-border bg-sidebar pt-2",children:a3.map(({kind:n,title:s})=>S.jsx("button",{onClick:()=>r8(n),className:Xt(Yk,e.rightPanel===n?"bg-muted":"text-muted-foreground hover:bg-muted"),children:s},n))})]})]}),S.jsx(QDe,{}),S.jsx(ZDe,{}),S.jsx(cxe,{}),S.jsx(ZL,{})]})}function Pbe(){return S.jsx(_be,{})}const qve=Object.freeze(Object.defineProperty({__proto__:null,default:Pbe},Symbol.toStringTag,{value:"Module"}));export{Uve as $,Jbe as A,qbe as B,L3 as C,bp as D,z8 as E,Vbe as F,Ls as G,hM as H,uR as I,Vh as J,ml as K,z3 as L,Kbe as M,N2 as N,d_ as O,xp as P,Jn as Q,eR as R,ZM as S,Nge as T,LB as U,Xk as V,Ss as W,ni as X,Xt as Y,zve as Z,Wbe as _,ns as a,qve as a0,mq as b,FM as c,kn as d,qv as e,mt as f,Ta as g,$i as h,an as i,Xe as j,Pr as k,o5 as l,zbe as m,u_ as n,Mi as o,Mt as p,W3 as q,Ube as r,Da as s,Bc as t,wU as u,r5 as v,ll as w,$U as x,o_ as y,fM as z};
|