@nice2dev/ui 1.3.14 → 1.3.15

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/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@nice2dev/ui-core"),Lt=require("./core-lBFqvT0V.cjs"),s=require("react"),Ye=require("./no-code-BQqK8mvU.cjs"),it=require("./NiceForm-Cl5syDvY.cjs"),Ut=require("./NiceSelect-BNPXs6FQ.cjs"),Ht=require("./pickerCommons-BWglYl6J.cjs"),Hn=require("./NiceColorPicker-BLwYNSXJ.cjs"),Qe=require("./NiceMention-CUl3myJg.cjs"),Dc=require("./NiceHtmlEditor-C1OVtLQ6.cjs"),Ua=require("./NiceCodeEditor-D0QZW88r.cjs"),Be=require("./NiceModuleLifecyclePanel-DZHj2xTn.cjs"),Le=require("./NiceButton-DzCqkG5a.cjs"),At=require("./NiceScheduler-Dwym4RVa.cjs"),Mt=require("./NicePivotGrid-Cnkr9WkC.cjs"),e=require("react/jsx-runtime"),Pc=require("react-dom"),yt=require("./NiceSavedQueryPanel-CpGjsyhc.cjs"),xt=require("./devops-cgRBnZVX.cjs"),Ct=require("./NiceLoginForm-FGf32sro.cjs"),Xi=require("./NiceModal-BRVzjuUN.cjs"),Ws=require("./NicePagination-CKsAP38Q.cjs"),Dn=require("./NiceDataGrid-BTtrpB6P.cjs"),Ze=require("./charts-B0tHOpJ7.cjs"),Nt=require("./NiceWindow-pgR4c-kQ.cjs"),Ac=require("./NiceGantt-BygumlaY.cjs"),fn=require("./injectStyleOnce-DeWaxcdf.cjs"),Dp=require("@nice2dev/i18n"),Pp=require("./NiceDocumentViewer-CDXAmPp7.cjs"),bn=require("./core-lazy-Bwdr6Kcl.cjs"),xi=require("./data-branching-7rpktFJ-.cjs");function Rc({className:t="",size:n="md",showTooltip:i=!0,showLabel:a=!0,onClick:r,label:o,tooltipPosition:l="bottom"}){const{t:d}=c.useNiceTranslation(),{badgeInfo:u,isLoading:m}=Lt.useTracelessPolicySafe(),[h,p]=s.useState(!1),y={sm:"nice-traceless-badge--sm",md:"nice-traceless-badge--md",lg:"nice-traceless-badge--lg"},x=o||u.label;return s.createElement("div",{className:`nice-traceless-badge ${u.cssClass} ${y[n]} ${t}`.trim(),onClick:r,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),role:r?"button":"status",tabIndex:r?0:void 0,onKeyDown:r?b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),r())}:void 0,"aria-label":d("traceless.badgeAria","Privacy mode: {mode}").replace("{mode}",x),style:{display:"inline-flex",alignItems:"center",gap:"0.375rem",padding:n==="sm"?"0.25rem 0.5rem":n==="lg"?"0.5rem 1rem":"0.375rem 0.75rem",borderRadius:"9999px",fontSize:n==="sm"?"0.75rem":n==="lg"?"1rem":"0.875rem",fontWeight:500,backgroundColor:`${u.color}20`,color:u.color,border:`1px solid ${u.color}40`,cursor:r?"pointer":"default",transition:"all 0.2s ease",position:"relative",userSelect:"none"}},s.createElement("span",{"aria-hidden":!0},s.createElement(c.NiceIcon,{name:m?"clock":u.icon,size:14})),a&&s.createElement("span",null,x),i&&h&&s.createElement("div",{role:"tooltip",style:{position:"absolute",[l==="top"?"bottom":l==="bottom"?"top":l==="left"?"right":"left"]:"100%",[l==="top"||l==="bottom"?"left":"top"]:"50%",transform:l==="top"||l==="bottom"?"translateX(-50%)":"translateY(-50%)",marginTop:l==="bottom"?"0.5rem":void 0,marginBottom:l==="top"?"0.5rem":void 0,marginLeft:l==="right"?"0.5rem":void 0,marginRight:l==="left"?"0.5rem":void 0,padding:"0.5rem 0.75rem",backgroundColor:"var(--nice-text-primary, #1f2937)",color:"var(--nice-text-inverse, #fff)",borderRadius:"0.375rem",fontSize:"0.75rem",whiteSpace:"nowrap",zIndex:50,boxShadow:"0 4px 6px -1px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",maxWidth:"280px",textAlign:"left"}},u.tooltip))}function Ap({className:t="",showReport:n=!0,showAudit:i=!0,showModeSelector:a=!0,availableModes:r=["traceless","ephemeral","private"],onModeChange:o}){const{t:l}=c.useNiceTranslation(),{policy:d,badgeInfo:u,setUserPreference:m,generateReport:h}=Lt.useTracelessPolicySafe(),{result:p,run:y}=Lt.useStorageAudit(),[x,b]=s.useState(null),g=s.useCallback(_=>{m({preferredMode:_}),o?.(_)},[m,o]),v=s.useCallback(()=>{b(h())},[h]),f={traceless:l("traceless.mode.traceless","Traceless"),ephemeral:l("traceless.mode.ephemeral","Ephemeral"),private:l("traceless.mode.private","Private"),balanced:l("traceless.mode.balanced","Balanced"),full:l("traceless.mode.full","Full"),custom:l("traceless.mode.custom","Custom")},C={traceless:l("traceless.modeDesc.traceless","Zero storage. Maximum privacy. Data resets on every page load."),ephemeral:l("traceless.modeDesc.ephemeral","Session-only. Data clears when you close the tab."),private:l("traceless.modeDesc.private","Minimal storage with secure authentication."),balanced:l("traceless.modeDesc.balanced","Local preferences saved. No tracking cookies."),full:l("traceless.modeDesc.full","All storage enabled with consent controls."),custom:l("traceless.modeDesc.custom","Custom configuration.")};return s.createElement("div",{className:`nice-traceless-panel ${t}`.trim(),style:{padding:"1.5rem",backgroundColor:"var(--nice-bg-secondary, #f9fafb)",borderRadius:"0.75rem",border:"1px solid var(--nice-border-color, #e5e7eb)"}},s.createElement("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"1.5rem"}},s.createElement(Rc,{size:"lg",showTooltip:!1}),s.createElement("div",null,s.createElement("h3",{style:{margin:0,fontSize:"1.125rem",fontWeight:600}},l("traceless.title","Privacy Settings")),s.createElement("p",{style:{margin:0,fontSize:"0.875rem",color:"var(--nice-text-muted, #6b7280)"}},C[d.effectiveMode]))),a&&s.createElement("div",{style:{marginBottom:"1.5rem"}},s.createElement("label",{style:{display:"block",marginBottom:"0.5rem",fontWeight:500}},l("traceless.level","Privacy Level")),s.createElement("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"}},r.map(_=>s.createElement("button",{key:_,onClick:()=>g(_),style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:d.effectiveMode===_?"2px solid var(--nice-primary, #3b82f6)":"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:d.effectiveMode===_?"var(--nice-info-bg, #eff6ff)":"var(--nice-bg-primary, #fff)",cursor:"pointer",fontWeight:d.effectiveMode===_?600:400}},f[_])))),s.createElement("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"1rem",marginBottom:"1.5rem"}},s.createElement(Xa,{title:l("traceless.cookies","Cookies"),allowed:d.cookiesAllowed,icon:s.createElement(c.NiceIcon,{name:"file",size:24})}),s.createElement(Xa,{title:"localStorage",allowed:d.localStorageAllowed,icon:s.createElement(c.NiceIcon,{name:"save",size:24})}),s.createElement(Xa,{title:"sessionStorage",allowed:d.sessionStorageAllowed,icon:s.createElement(c.NiceIcon,{name:"clipboard",size:24})})),s.createElement("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap"}},i&&s.createElement("button",{onClick:y,style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"0.375rem"}},s.createElement(c.NiceIcon,{name:"search",size:16}),l("traceless.runAudit","Run Audit")),n&&s.createElement("button",{onClick:v,style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"0.375rem"}},s.createElement(c.NiceIcon,{name:"file",size:16}),l("traceless.generateReport","Generate Report"))),p&&s.createElement("div",{style:{marginTop:"1rem",padding:"1rem",backgroundColor:p.compliant?"var(--nice-success-bg, #ecfdf5)":"var(--nice-danger-bg, #fef2f2)",borderRadius:"0.5rem",border:`1px solid ${p.compliant?"var(--nice-color-success, #10b981)":"var(--nice-color-error, #ef4444)"}`}},s.createElement("p",{style:{margin:0,fontWeight:500,color:p.compliant?"var(--nice-success, #059669)":"var(--nice-color-error, #dc2626)",display:"inline-flex",alignItems:"center",gap:"0.375rem"}},s.createElement(c.NiceIcon,{name:p.compliant?"check":"close",size:16}),p.compliant?l("traceless.compliant","Compliant"):l("traceless.violations","Violations Found")),!p.compliant&&p.violations.map((_,T)=>s.createElement("p",{key:T,style:{margin:"0.5rem 0 0",fontSize:"0.875rem"}},`• ${_.message}`))),x&&s.createElement("div",{style:{marginTop:"1rem",padding:"1rem",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #d1d5db)"}},s.createElement("h4",{style:{margin:"0 0 0.5rem",fontSize:"0.875rem",fontWeight:600}},l("traceless.statement","Compliance Statement")),s.createElement("p",{style:{margin:0,fontSize:"0.875rem",color:"var(--nice-text-secondary, #4b5563)"}},x.statement)))}function Xa({title:t,allowed:n,icon:i}){const{t:a}=c.useNiceTranslation();return s.createElement("div",{style:{padding:"0.75rem",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #e5e7eb)",textAlign:"center"}},s.createElement("div",{style:{fontSize:"1.5rem",marginBottom:"0.25rem"}},i),s.createElement("div",{style:{fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem"}},t),s.createElement("div",{style:{fontSize:"0.75rem",color:n?"var(--nice-color-success, #10b981)":"var(--nice-text-muted, #6b7280)",fontWeight:500,display:"inline-flex",alignItems:"center",gap:"0.25rem"}},s.createElement(c.NiceIcon,{name:n?"check":"close",size:12}),n?a("enabled","Enabled"):a("disabled","Disabled")))}function Rp({className:t="",position:n="bottom",onAccept:i,onDecline:a,onCustomize:r,privacyPolicyUrl:o,acceptText:l,declineText:d}){const{t:u}=c.useNiceTranslation(),{shouldShow:m,mode:h,dismiss:p}=Lt.useCookieBannerVisibility(),y=s.useCallback(()=>{i?.(),p()},[i,p]),x=s.useCallback(()=>{a?.(),p()},[a,p]);if(!m)return null;const b=n==="top"?{top:0,borderBottom:"1px solid var(--nice-border-color, #e5e7eb)"}:{bottom:0,borderTop:"1px solid var(--nice-border-color, #e5e7eb)"};return s.createElement("div",{className:`nice-consent-banner ${t}`.trim(),role:"dialog","aria-label":u("cookie.title","Cookie consent"),style:{position:"fixed",left:0,right:0,padding:"1rem 1.5rem",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",boxShadow:"0 -4px 6px -1px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem",flexWrap:"wrap",...b}},s.createElement("div",{style:{flex:1,minWidth:"200px"}},s.createElement("p",{style:{margin:0,fontSize:"0.875rem"}},`${u("cookie.message","This site uses cookies to improve your experience.")} `,o&&s.createElement("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--nice-color-primary, #3b82f6)"}},u("cookie.learnMore","Learn more")))),s.createElement("div",{style:{display:"flex",gap:"0.5rem",flexShrink:0}},r&&s.createElement("button",{onClick:r,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"}},u("cookie.customize","Customize")),s.createElement("button",{onClick:x,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"}},d??u("cookie.reject","Reject all")),s.createElement("button",{onClick:y,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"none",backgroundColor:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontWeight:500}},l??u("cookie.accept","Accept all"))))}function $p({useCase:t,className:n="",message:i,variant:a="inline",dismissible:r=!1,onDismiss:o}){const{t:l}=c.useNiceTranslation(),{warningMessage:d}=Lt.useTracelessPolicySafe().policy.effectiveMode==="traceless"?{warningMessage:i||l("traceless.limitedFeature","This feature has limited functionality in Traceless mode.")}:{warningMessage:void 0},[u,m]=s.useState(!1),h=s.useCallback(()=>{m(!0),o?.()},[o]);if(!d||u)return null;const p={inline:{padding:"0.5rem 0.75rem",backgroundColor:"var(--nice-warning-bg, #fef3c7)",border:"1px solid var(--nice-warning-light, #fbbf24)",borderRadius:"0.375rem",fontSize:"0.875rem"},banner:{padding:"0.75rem 1rem",backgroundColor:"var(--nice-warning-bg, #fef3c7)",borderBottom:"1px solid var(--nice-warning-light, #fbbf24)",fontSize:"0.875rem"},toast:{padding:"0.75rem 1rem",backgroundColor:"var(--nice-text-primary, #1f2937)",color:"var(--nice-text-inverse, #fff)",borderRadius:"0.5rem",boxShadow:"0 4px 6px -1px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",fontSize:"0.875rem"}};return s.createElement("div",{className:`nice-traceless-warning nice-traceless-warning--${a} ${n}`.trim(),role:"alert",style:{display:"flex",alignItems:"center",gap:"0.5rem",...p[a]}},s.createElement("span",{"aria-hidden":!0},s.createElement(c.NiceIcon,{name:"warning",size:16})),s.createElement("span",{style:{flex:1}},d),r&&s.createElement("button",{onClick:h,"aria-label":l("traceless.dismissWarning","Dismiss warning"),style:{background:"none",border:"none",cursor:"pointer",padding:"0.25rem",opacity:.7}},s.createElement(c.NiceIcon,{name:"close",size:14})))}const $c=s.createContext(null);function Mp(){const t=s.useContext($c);return t||{isActive:!1,trackEvent:()=>{},trackPageView:()=>{},setUserProperties:()=>{},mode:"traceless",provider:"custom"}}function Op({children:t,provider:n,trackingId:i,endpoint:a,customHandler:r,cookies:o=!0,localStorage:l=!1,minMode:d="balanced",autoTrackPageViews:u=!0,respectDoNotTrack:m=!0,debug:h=!1,domain:p,scriptUrl:y,anonymizeIp:x=!0,cookieless:b=!1}){const{policy:g,mode:v}=Lt.useTracelessPolicySafe(),f=s.useMemo(()=>{if(m&&typeof navigator<"u"){const k=navigator.doNotTrack||window.doNotTrack;if(k==="1"||k==="yes")return h&&Nn("Disabled: Do Not Track is set"),!1}const N=["traceless","ephemeral","private","balanced","full"],j=N.indexOf(v),w=N.indexOf(d);return j<w?(h&&Nn(`Disabled: mode ${v} < minMode ${d}`),!1):o&&!g.cookiesAllowed&&!b?(h&&Nn("Disabled: cookies required but not allowed"),!1):l&&!g.localStorageAllowed?(h&&Nn("Disabled: localStorage required but not allowed"),!1):!0},[v,d,g,o,l,b,m,h]);s.useEffect(()=>{if(f){if(n==="custom"&&r){r.init();return}switch(n){case"plausible":Pi(y||"https://plausible.io/js/script.js",{"data-domain":i||p});break;case"simple-analytics":Pi(y||"https://scripts.simpleanalyticscdn.com/latest.js");break;case"umami":Pi(y||a||"",{"data-website-id":i});break;case"fathom":Pi(y||"https://cdn.usefathom.com/script.js",{"data-site":i});break;case"matomo":Bp(a||"",i||"",x);break;case"google-analytics":b||(Pi(`https://www.googletagmanager.com/gtag/js?id=${i}`),zp(i||"",x));break;case"google-tag-manager":b||Lp(i||"");break;default:h&&console.warn(`[NiceAnalyticsTracker] Unknown provider: ${n}`)}h&&Nn(`Initialized: ${n}`)}},[f,n,i,a,y,p,x,b,r,h]);const C=s.useCallback(N=>{if(f){if(h&&Nn("trackPageView:",N),n==="custom"&&r){r.trackPageView(N);return}switch(n){case"plausible":window.plausible?.("pageview");break;case"umami":window.umami?.track();break;case"fathom":window.fathom?.trackPageview();break;case"matomo":window._paq?.push(["trackPageView"]);break;case"google-analytics":window.gtag?.("event","page_view",{page_path:N.path,page_title:N.title});break}}},[f,n,r,h]);s.useEffect(()=>{if(!f||!u)return;C({path:typeof window<"u"?window.location.pathname:"/",title:typeof document<"u"?document.title:""});const N=()=>{C({path:window.location.pathname,title:document.title})};return window.addEventListener("popstate",N),()=>window.removeEventListener("popstate",N)},[f,u,C]);const _=s.useCallback(N=>{if(f){if(h&&Nn("trackEvent:",N),n==="custom"&&r){r.trackEvent(N);return}switch(n){case"plausible":window.plausible?.(N.name,{props:N.properties});break;case"umami":window.umami?.track(N.name,N.properties);break;case"fathom":window.fathom?.trackGoal(N.name,N.value??0);break;case"matomo":window._paq?.push(["trackEvent",N.category,N.name,N.label,N.value]);break;case"google-analytics":window.gtag?.("event",N.name,{event_category:N.category,event_label:N.label,value:N.value,...N.properties});break}}},[f,n,r,h]),T=s.useCallback(N=>{if(f){if(h&&Nn("setUserProperties:",N),n==="custom"&&r?.setUserProperties){r.setUserProperties(N);return}switch(n){case"google-analytics":window.gtag?.("set","user_properties",N);break;case"matomo":Object.entries(N).forEach(([j,w])=>{window._paq?.push(["setCustomVariable",j,String(w)])});break}}},[f,n,r,h]),S=s.useMemo(()=>({isActive:f,trackEvent:_,trackPageView:C,setUserProperties:T,mode:v,provider:n}),[f,_,C,T,v,n]);return s.createElement($c.Provider,{value:S},t)}function Nn(...t){console.log("[NiceAnalyticsTracker]",...t)}function Pi(t,n){if(typeof document>"u"||!t||document.querySelector(`script[src="${t}"]`))return;const a=document.createElement("script");a.src=t,a.async=!0,a.defer=!0,n&&Object.entries(n).forEach(([r,o])=>{o!==void 0&&a.setAttribute(r,o)}),document.head.appendChild(a)}function zp(t,n){if(typeof window>"u")return;window.dataLayer=window.dataLayer||[];function i(...a){window.dataLayer.push(arguments)}window.gtag=i,i("js",new Date),i("config",t,{anonymize_ip:n})}function Lp(t){if(typeof window>"u")return;window.dataLayer=window.dataLayer||[],window.dataLayer.push({"gtm.start":new Date().getTime(),event:"gtm.js"});const n=document.createElement("script");n.async=!0,n.src=`https://www.googletagmanager.com/gtm.js?id=${t}`,document.head.appendChild(n)}function Bp(t,n,i){if(typeof window>"u"||!t)return;window._paq=window._paq||[];const a=window._paq;i&&a.push(["setAnonymizeIp",!0]),a.push(["trackPageView"]),a.push(["enableLinkTracking"]),a.push(["setTrackerUrl",`${t}/matomo.php`]),a.push(["setSiteId",n]);const r=document.createElement("script");r.async=!0,r.src=`${t}/matomo.js`,document.head.appendChild(r)}function pn(t,n=2){return String(t).padStart(n,"0")}function Za(t){return pn(t.getUTCFullYear(),4)+pn(t.getUTCMonth()+1)+pn(t.getUTCDate())+"T"+pn(t.getUTCHours())+pn(t.getUTCMinutes())+pn(t.getUTCSeconds())+"Z"}function Xr(t){return pn(t.getFullYear(),4)+pn(t.getMonth()+1)+pn(t.getDate())}function Ai(t){return t.replace(/\\/g,"\\\\").replace(/;/g,"\\;").replace(/,/g,"\\,").replace(/\r?\n/g,"\\n")}function Fp(t){if(t.length<=75)return t;const n=[];let i=0;for(;i<t.length;)n.push(t.slice(i,i+75)),i+=75;return n.join(`\r
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@nice2dev/ui-core"),Lt=require("./core-lBFqvT0V.cjs"),s=require("react"),Ye=require("./no-code-BQqK8mvU.cjs"),it=require("./NiceForm-Cxvh2O6y.cjs"),Ut=require("./NiceSelect-BNPXs6FQ.cjs"),Ht=require("./pickerCommons-BWglYl6J.cjs"),Hn=require("./NiceColorPicker-BLwYNSXJ.cjs"),Qe=require("./NiceMention-CYTx04JY.cjs"),Dc=require("./NiceHtmlEditor-C1OVtLQ6.cjs"),Ua=require("./NiceCodeEditor-D0QZW88r.cjs"),Be=require("./NiceModuleLifecyclePanel-DHHAjwQx.cjs"),Le=require("./NiceButton-DzCqkG5a.cjs"),At=require("./NiceScheduler-K8ZAqFCQ.cjs"),Mt=require("./NicePivotGrid-Cnkr9WkC.cjs"),e=require("react/jsx-runtime"),Pc=require("react-dom"),yt=require("./NiceSavedQueryPanel-CN1rCPFs.cjs"),xt=require("./devops-cgRBnZVX.cjs"),Ct=require("./NiceLoginForm-FGf32sro.cjs"),Xi=require("./NiceModal-BRVzjuUN.cjs"),Ws=require("./NicePagination-CKsAP38Q.cjs"),Dn=require("./NiceDataGrid-BwiBkE3u.cjs"),Ze=require("./charts-B0tHOpJ7.cjs"),Nt=require("./NiceWindow-pgR4c-kQ.cjs"),Ac=require("./NiceGantt-BygumlaY.cjs"),fn=require("./injectStyleOnce-DeWaxcdf.cjs"),Dp=require("@nice2dev/i18n"),Pp=require("./NiceDocumentViewer-CDXAmPp7.cjs"),bn=require("./core-lazy-DfNWyf__.cjs"),xi=require("./data-branching-7rpktFJ-.cjs");function Rc({className:t="",size:n="md",showTooltip:i=!0,showLabel:a=!0,onClick:r,label:o,tooltipPosition:l="bottom"}){const{t:d}=c.useNiceTranslation(),{badgeInfo:u,isLoading:m}=Lt.useTracelessPolicySafe(),[h,p]=s.useState(!1),y={sm:"nice-traceless-badge--sm",md:"nice-traceless-badge--md",lg:"nice-traceless-badge--lg"},x=o||u.label;return s.createElement("div",{className:`nice-traceless-badge ${u.cssClass} ${y[n]} ${t}`.trim(),onClick:r,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),role:r?"button":"status",tabIndex:r?0:void 0,onKeyDown:r?b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),r())}:void 0,"aria-label":d("traceless.badgeAria","Privacy mode: {mode}").replace("{mode}",x),style:{display:"inline-flex",alignItems:"center",gap:"0.375rem",padding:n==="sm"?"0.25rem 0.5rem":n==="lg"?"0.5rem 1rem":"0.375rem 0.75rem",borderRadius:"9999px",fontSize:n==="sm"?"0.75rem":n==="lg"?"1rem":"0.875rem",fontWeight:500,backgroundColor:`${u.color}20`,color:u.color,border:`1px solid ${u.color}40`,cursor:r?"pointer":"default",transition:"all 0.2s ease",position:"relative",userSelect:"none"}},s.createElement("span",{"aria-hidden":!0},s.createElement(c.NiceIcon,{name:m?"clock":u.icon,size:14})),a&&s.createElement("span",null,x),i&&h&&s.createElement("div",{role:"tooltip",style:{position:"absolute",[l==="top"?"bottom":l==="bottom"?"top":l==="left"?"right":"left"]:"100%",[l==="top"||l==="bottom"?"left":"top"]:"50%",transform:l==="top"||l==="bottom"?"translateX(-50%)":"translateY(-50%)",marginTop:l==="bottom"?"0.5rem":void 0,marginBottom:l==="top"?"0.5rem":void 0,marginLeft:l==="right"?"0.5rem":void 0,marginRight:l==="left"?"0.5rem":void 0,padding:"0.5rem 0.75rem",backgroundColor:"var(--nice-text-primary, #1f2937)",color:"var(--nice-text-inverse, #fff)",borderRadius:"0.375rem",fontSize:"0.75rem",whiteSpace:"nowrap",zIndex:50,boxShadow:"0 4px 6px -1px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",maxWidth:"280px",textAlign:"left"}},u.tooltip))}function Ap({className:t="",showReport:n=!0,showAudit:i=!0,showModeSelector:a=!0,availableModes:r=["traceless","ephemeral","private"],onModeChange:o}){const{t:l}=c.useNiceTranslation(),{policy:d,badgeInfo:u,setUserPreference:m,generateReport:h}=Lt.useTracelessPolicySafe(),{result:p,run:y}=Lt.useStorageAudit(),[x,b]=s.useState(null),g=s.useCallback(_=>{m({preferredMode:_}),o?.(_)},[m,o]),v=s.useCallback(()=>{b(h())},[h]),f={traceless:l("traceless.mode.traceless","Traceless"),ephemeral:l("traceless.mode.ephemeral","Ephemeral"),private:l("traceless.mode.private","Private"),balanced:l("traceless.mode.balanced","Balanced"),full:l("traceless.mode.full","Full"),custom:l("traceless.mode.custom","Custom")},C={traceless:l("traceless.modeDesc.traceless","Zero storage. Maximum privacy. Data resets on every page load."),ephemeral:l("traceless.modeDesc.ephemeral","Session-only. Data clears when you close the tab."),private:l("traceless.modeDesc.private","Minimal storage with secure authentication."),balanced:l("traceless.modeDesc.balanced","Local preferences saved. No tracking cookies."),full:l("traceless.modeDesc.full","All storage enabled with consent controls."),custom:l("traceless.modeDesc.custom","Custom configuration.")};return s.createElement("div",{className:`nice-traceless-panel ${t}`.trim(),style:{padding:"1.5rem",backgroundColor:"var(--nice-bg-secondary, #f9fafb)",borderRadius:"0.75rem",border:"1px solid var(--nice-border-color, #e5e7eb)"}},s.createElement("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"1.5rem"}},s.createElement(Rc,{size:"lg",showTooltip:!1}),s.createElement("div",null,s.createElement("h3",{style:{margin:0,fontSize:"1.125rem",fontWeight:600}},l("traceless.title","Privacy Settings")),s.createElement("p",{style:{margin:0,fontSize:"0.875rem",color:"var(--nice-text-muted, #6b7280)"}},C[d.effectiveMode]))),a&&s.createElement("div",{style:{marginBottom:"1.5rem"}},s.createElement("label",{style:{display:"block",marginBottom:"0.5rem",fontWeight:500}},l("traceless.level","Privacy Level")),s.createElement("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"}},r.map(_=>s.createElement("button",{key:_,onClick:()=>g(_),style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:d.effectiveMode===_?"2px solid var(--nice-primary, #3b82f6)":"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:d.effectiveMode===_?"var(--nice-info-bg, #eff6ff)":"var(--nice-bg-primary, #fff)",cursor:"pointer",fontWeight:d.effectiveMode===_?600:400}},f[_])))),s.createElement("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"1rem",marginBottom:"1.5rem"}},s.createElement(Xa,{title:l("traceless.cookies","Cookies"),allowed:d.cookiesAllowed,icon:s.createElement(c.NiceIcon,{name:"file",size:24})}),s.createElement(Xa,{title:"localStorage",allowed:d.localStorageAllowed,icon:s.createElement(c.NiceIcon,{name:"save",size:24})}),s.createElement(Xa,{title:"sessionStorage",allowed:d.sessionStorageAllowed,icon:s.createElement(c.NiceIcon,{name:"clipboard",size:24})})),s.createElement("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap"}},i&&s.createElement("button",{onClick:y,style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"0.375rem"}},s.createElement(c.NiceIcon,{name:"search",size:16}),l("traceless.runAudit","Run Audit")),n&&s.createElement("button",{onClick:v,style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"0.375rem"}},s.createElement(c.NiceIcon,{name:"file",size:16}),l("traceless.generateReport","Generate Report"))),p&&s.createElement("div",{style:{marginTop:"1rem",padding:"1rem",backgroundColor:p.compliant?"var(--nice-success-bg, #ecfdf5)":"var(--nice-danger-bg, #fef2f2)",borderRadius:"0.5rem",border:`1px solid ${p.compliant?"var(--nice-color-success, #10b981)":"var(--nice-color-error, #ef4444)"}`}},s.createElement("p",{style:{margin:0,fontWeight:500,color:p.compliant?"var(--nice-success, #059669)":"var(--nice-color-error, #dc2626)",display:"inline-flex",alignItems:"center",gap:"0.375rem"}},s.createElement(c.NiceIcon,{name:p.compliant?"check":"close",size:16}),p.compliant?l("traceless.compliant","Compliant"):l("traceless.violations","Violations Found")),!p.compliant&&p.violations.map((_,T)=>s.createElement("p",{key:T,style:{margin:"0.5rem 0 0",fontSize:"0.875rem"}},`• ${_.message}`))),x&&s.createElement("div",{style:{marginTop:"1rem",padding:"1rem",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #d1d5db)"}},s.createElement("h4",{style:{margin:"0 0 0.5rem",fontSize:"0.875rem",fontWeight:600}},l("traceless.statement","Compliance Statement")),s.createElement("p",{style:{margin:0,fontSize:"0.875rem",color:"var(--nice-text-secondary, #4b5563)"}},x.statement)))}function Xa({title:t,allowed:n,icon:i}){const{t:a}=c.useNiceTranslation();return s.createElement("div",{style:{padding:"0.75rem",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #e5e7eb)",textAlign:"center"}},s.createElement("div",{style:{fontSize:"1.5rem",marginBottom:"0.25rem"}},i),s.createElement("div",{style:{fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem"}},t),s.createElement("div",{style:{fontSize:"0.75rem",color:n?"var(--nice-color-success, #10b981)":"var(--nice-text-muted, #6b7280)",fontWeight:500,display:"inline-flex",alignItems:"center",gap:"0.25rem"}},s.createElement(c.NiceIcon,{name:n?"check":"close",size:12}),n?a("enabled","Enabled"):a("disabled","Disabled")))}function Rp({className:t="",position:n="bottom",onAccept:i,onDecline:a,onCustomize:r,privacyPolicyUrl:o,acceptText:l,declineText:d}){const{t:u}=c.useNiceTranslation(),{shouldShow:m,mode:h,dismiss:p}=Lt.useCookieBannerVisibility(),y=s.useCallback(()=>{i?.(),p()},[i,p]),x=s.useCallback(()=>{a?.(),p()},[a,p]);if(!m)return null;const b=n==="top"?{top:0,borderBottom:"1px solid var(--nice-border-color, #e5e7eb)"}:{bottom:0,borderTop:"1px solid var(--nice-border-color, #e5e7eb)"};return s.createElement("div",{className:`nice-consent-banner ${t}`.trim(),role:"dialog","aria-label":u("cookie.title","Cookie consent"),style:{position:"fixed",left:0,right:0,padding:"1rem 1.5rem",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",boxShadow:"0 -4px 6px -1px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem",flexWrap:"wrap",...b}},s.createElement("div",{style:{flex:1,minWidth:"200px"}},s.createElement("p",{style:{margin:0,fontSize:"0.875rem"}},`${u("cookie.message","This site uses cookies to improve your experience.")} `,o&&s.createElement("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--nice-color-primary, #3b82f6)"}},u("cookie.learnMore","Learn more")))),s.createElement("div",{style:{display:"flex",gap:"0.5rem",flexShrink:0}},r&&s.createElement("button",{onClick:r,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"}},u("cookie.customize","Customize")),s.createElement("button",{onClick:x,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"}},d??u("cookie.reject","Reject all")),s.createElement("button",{onClick:y,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"none",backgroundColor:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontWeight:500}},l??u("cookie.accept","Accept all"))))}function $p({useCase:t,className:n="",message:i,variant:a="inline",dismissible:r=!1,onDismiss:o}){const{t:l}=c.useNiceTranslation(),{warningMessage:d}=Lt.useTracelessPolicySafe().policy.effectiveMode==="traceless"?{warningMessage:i||l("traceless.limitedFeature","This feature has limited functionality in Traceless mode.")}:{warningMessage:void 0},[u,m]=s.useState(!1),h=s.useCallback(()=>{m(!0),o?.()},[o]);if(!d||u)return null;const p={inline:{padding:"0.5rem 0.75rem",backgroundColor:"var(--nice-warning-bg, #fef3c7)",border:"1px solid var(--nice-warning-light, #fbbf24)",borderRadius:"0.375rem",fontSize:"0.875rem"},banner:{padding:"0.75rem 1rem",backgroundColor:"var(--nice-warning-bg, #fef3c7)",borderBottom:"1px solid var(--nice-warning-light, #fbbf24)",fontSize:"0.875rem"},toast:{padding:"0.75rem 1rem",backgroundColor:"var(--nice-text-primary, #1f2937)",color:"var(--nice-text-inverse, #fff)",borderRadius:"0.5rem",boxShadow:"0 4px 6px -1px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",fontSize:"0.875rem"}};return s.createElement("div",{className:`nice-traceless-warning nice-traceless-warning--${a} ${n}`.trim(),role:"alert",style:{display:"flex",alignItems:"center",gap:"0.5rem",...p[a]}},s.createElement("span",{"aria-hidden":!0},s.createElement(c.NiceIcon,{name:"warning",size:16})),s.createElement("span",{style:{flex:1}},d),r&&s.createElement("button",{onClick:h,"aria-label":l("traceless.dismissWarning","Dismiss warning"),style:{background:"none",border:"none",cursor:"pointer",padding:"0.25rem",opacity:.7}},s.createElement(c.NiceIcon,{name:"close",size:14})))}const $c=s.createContext(null);function Mp(){const t=s.useContext($c);return t||{isActive:!1,trackEvent:()=>{},trackPageView:()=>{},setUserProperties:()=>{},mode:"traceless",provider:"custom"}}function Op({children:t,provider:n,trackingId:i,endpoint:a,customHandler:r,cookies:o=!0,localStorage:l=!1,minMode:d="balanced",autoTrackPageViews:u=!0,respectDoNotTrack:m=!0,debug:h=!1,domain:p,scriptUrl:y,anonymizeIp:x=!0,cookieless:b=!1}){const{policy:g,mode:v}=Lt.useTracelessPolicySafe(),f=s.useMemo(()=>{if(m&&typeof navigator<"u"){const k=navigator.doNotTrack||window.doNotTrack;if(k==="1"||k==="yes")return h&&Nn("Disabled: Do Not Track is set"),!1}const N=["traceless","ephemeral","private","balanced","full"],j=N.indexOf(v),w=N.indexOf(d);return j<w?(h&&Nn(`Disabled: mode ${v} < minMode ${d}`),!1):o&&!g.cookiesAllowed&&!b?(h&&Nn("Disabled: cookies required but not allowed"),!1):l&&!g.localStorageAllowed?(h&&Nn("Disabled: localStorage required but not allowed"),!1):!0},[v,d,g,o,l,b,m,h]);s.useEffect(()=>{if(f){if(n==="custom"&&r){r.init();return}switch(n){case"plausible":Pi(y||"https://plausible.io/js/script.js",{"data-domain":i||p});break;case"simple-analytics":Pi(y||"https://scripts.simpleanalyticscdn.com/latest.js");break;case"umami":Pi(y||a||"",{"data-website-id":i});break;case"fathom":Pi(y||"https://cdn.usefathom.com/script.js",{"data-site":i});break;case"matomo":Bp(a||"",i||"",x);break;case"google-analytics":b||(Pi(`https://www.googletagmanager.com/gtag/js?id=${i}`),zp(i||"",x));break;case"google-tag-manager":b||Lp(i||"");break;default:h&&console.warn(`[NiceAnalyticsTracker] Unknown provider: ${n}`)}h&&Nn(`Initialized: ${n}`)}},[f,n,i,a,y,p,x,b,r,h]);const C=s.useCallback(N=>{if(f){if(h&&Nn("trackPageView:",N),n==="custom"&&r){r.trackPageView(N);return}switch(n){case"plausible":window.plausible?.("pageview");break;case"umami":window.umami?.track();break;case"fathom":window.fathom?.trackPageview();break;case"matomo":window._paq?.push(["trackPageView"]);break;case"google-analytics":window.gtag?.("event","page_view",{page_path:N.path,page_title:N.title});break}}},[f,n,r,h]);s.useEffect(()=>{if(!f||!u)return;C({path:typeof window<"u"?window.location.pathname:"/",title:typeof document<"u"?document.title:""});const N=()=>{C({path:window.location.pathname,title:document.title})};return window.addEventListener("popstate",N),()=>window.removeEventListener("popstate",N)},[f,u,C]);const _=s.useCallback(N=>{if(f){if(h&&Nn("trackEvent:",N),n==="custom"&&r){r.trackEvent(N);return}switch(n){case"plausible":window.plausible?.(N.name,{props:N.properties});break;case"umami":window.umami?.track(N.name,N.properties);break;case"fathom":window.fathom?.trackGoal(N.name,N.value??0);break;case"matomo":window._paq?.push(["trackEvent",N.category,N.name,N.label,N.value]);break;case"google-analytics":window.gtag?.("event",N.name,{event_category:N.category,event_label:N.label,value:N.value,...N.properties});break}}},[f,n,r,h]),T=s.useCallback(N=>{if(f){if(h&&Nn("setUserProperties:",N),n==="custom"&&r?.setUserProperties){r.setUserProperties(N);return}switch(n){case"google-analytics":window.gtag?.("set","user_properties",N);break;case"matomo":Object.entries(N).forEach(([j,w])=>{window._paq?.push(["setCustomVariable",j,String(w)])});break}}},[f,n,r,h]),S=s.useMemo(()=>({isActive:f,trackEvent:_,trackPageView:C,setUserProperties:T,mode:v,provider:n}),[f,_,C,T,v,n]);return s.createElement($c.Provider,{value:S},t)}function Nn(...t){console.log("[NiceAnalyticsTracker]",...t)}function Pi(t,n){if(typeof document>"u"||!t||document.querySelector(`script[src="${t}"]`))return;const a=document.createElement("script");a.src=t,a.async=!0,a.defer=!0,n&&Object.entries(n).forEach(([r,o])=>{o!==void 0&&a.setAttribute(r,o)}),document.head.appendChild(a)}function zp(t,n){if(typeof window>"u")return;window.dataLayer=window.dataLayer||[];function i(...a){window.dataLayer.push(arguments)}window.gtag=i,i("js",new Date),i("config",t,{anonymize_ip:n})}function Lp(t){if(typeof window>"u")return;window.dataLayer=window.dataLayer||[],window.dataLayer.push({"gtm.start":new Date().getTime(),event:"gtm.js"});const n=document.createElement("script");n.async=!0,n.src=`https://www.googletagmanager.com/gtm.js?id=${t}`,document.head.appendChild(n)}function Bp(t,n,i){if(typeof window>"u"||!t)return;window._paq=window._paq||[];const a=window._paq;i&&a.push(["setAnonymizeIp",!0]),a.push(["trackPageView"]),a.push(["enableLinkTracking"]),a.push(["setTrackerUrl",`${t}/matomo.php`]),a.push(["setSiteId",n]);const r=document.createElement("script");r.async=!0,r.src=`${t}/matomo.js`,document.head.appendChild(r)}function pn(t,n=2){return String(t).padStart(n,"0")}function Za(t){return pn(t.getUTCFullYear(),4)+pn(t.getUTCMonth()+1)+pn(t.getUTCDate())+"T"+pn(t.getUTCHours())+pn(t.getUTCMinutes())+pn(t.getUTCSeconds())+"Z"}function Xr(t){return pn(t.getFullYear(),4)+pn(t.getMonth()+1)+pn(t.getDate())}function Ai(t){return t.replace(/\\/g,"\\\\").replace(/;/g,"\\;").replace(/,/g,"\\,").replace(/\r?\n/g,"\\n")}function Fp(t){if(t.length<=75)return t;const n=[];let i=0;for(;i<t.length;)n.push(t.slice(i,i+75)),i+=75;return n.join(`\r
2
2
  `)}function Mc(t,n={}){const{prodId:i="-//nice2dev//NiceToDev.UI//EN",calendarName:a,method:r}=n,o=["BEGIN:VCALENDAR","VERSION:2.0",`PRODID:${i}`,"CALSCALE:GREGORIAN"];r&&o.push(`METHOD:${r}`),a&&o.push(`X-WR-CALNAME:${Ai(a)}`);const l=Za(new Date);for(const d of t)o.push("BEGIN:VEVENT"),o.push(`UID:${d.uid}`),o.push(`DTSTAMP:${l}`),d.allDay?(o.push(`DTSTART;VALUE=DATE:${Xr(d.start)}`),d.end&&o.push(`DTEND;VALUE=DATE:${Xr(d.end)}`)):(o.push(`DTSTART:${Za(d.start)}`),d.end&&o.push(`DTEND:${Za(d.end)}`)),o.push(`SUMMARY:${Ai(d.summary)}`),d.description&&o.push(`DESCRIPTION:${Ai(d.description)}`),d.location&&o.push(`LOCATION:${Ai(d.location)}`),d.url&&o.push(`URL:${d.url}`),d.status&&o.push(`STATUS:${d.status}`),d.rrule&&o.push(`RRULE:${d.rrule}`),d.categories&&d.categories.length>0&&o.push(`CATEGORIES:${d.categories.map(Ai).join(",")}`),o.push("END:VEVENT");return o.push("END:VCALENDAR"),o.map(Fp).join(`\r
3
- `)}function Oc(t,n={}){const i=Mc(t,n);return new Blob([i],{type:"text/calendar;charset=utf-8"})}function Vp(t,n="calendar.ics",i={}){if(typeof window>"u"||typeof URL.createObjectURL!="function")return;const a=Oc(t,i),r=URL.createObjectURL(a),o=document.createElement("a");o.href=r,o.download=n,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(r)}const qp=[];function Up(t){const n=t?.closest?.("[data-theme], .nice-dark, .nice-light, .dark");if(!n)return"";const i=n.getAttribute("data-theme");return i==="dark"||n.classList.contains("nice-dark")||n.classList.contains("dark")?"nice-dark":i==="light"||n.classList.contains("nice-light")?"nice-light":""}const zc=({icon:t,items:n=qp,direction:i="right",position:a={bottom:24,right:24},disabled:r=!1,className:o,style:l,id:d,"data-testid":u})=>{const[m,h]=s.useState(!1),p=m&&!r,y=s.useRef(null),x=s.useRef(null),[b,g]=s.useState(null),[v,f]=s.useState(""),C=s.useRef(null);c.useMenuButton(x,C,{open:p,onOpenChange:h,orientation:i==="up"||i==="down"?"vertical":"horizontal"}),s.useLayoutEffect(()=>{if(!p||!x.current)return;const T=x.current,S=()=>g(T.getBoundingClientRect());return S(),f(Up(y.current)),window.addEventListener("scroll",S,!0),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[p]);const _=e.jsx("div",{className:"nice-speed-dial__items",role:"menu",ref:C,children:n.map(T=>e.jsx("button",{type:"button",role:"menuitem",className:"nice-speed-dial__item nice-btn nice-btn--secondary",onClick:()=>{T.onClick?.(),h(!1)},title:T.label,"aria-label":T.label,children:T.icon},T.key))});return e.jsxs("div",{ref:y,id:d,"data-testid":u,className:["nice-speed-dial",`nice-speed-dial--${i}`,p?"nice-speed-dial--open":"",r?"nice-speed-dial--disabled":"",o||""].filter(Boolean).join(" "),style:{...a,...l},children:[e.jsx("button",{ref:x,type:"button",className:"nice-speed-dial__trigger nice-btn nice-btn--primary",onClick:()=>h(T=>!T),"aria-expanded":p,"aria-haspopup":"menu",disabled:r,children:e.jsx("span",{className:"nice-speed-dial__trigger-icon",children:t??e.jsx(c.NiceIcon,{name:"plus",size:24})})}),p&&b&&typeof document<"u"&&Pc.createPortal(e.jsx("div",{className:["nice-speed-dial","nice-speed-dial--portal",`nice-speed-dial--${i}`,"nice-speed-dial--open",v].filter(Boolean).join(" "),"data-theme":v==="nice-dark"?"dark":v==="nice-light"?"light":void 0,style:{position:"fixed",left:b.left,top:b.top,width:b.width,height:b.height,right:"auto",bottom:"auto",margin:0},children:_}),document.body)]})},Wt=({children:t,variant:n="primary",size:i="md",dot:a,outline:r,subtle:o,pulse:l,icon:d,removable:u,onRemove:m,className:h,style:p,displayStyle:y,testId:x,"data-testid":b})=>{const{t:g}=c.useNiceTranslation(),v=c.useComponentDisplayStyle("badge",y),f=c.useComponentDisplayClass("badge",y),C={...v};for(const _ of["fontSize","padding","paddingLeft","paddingRight","paddingTop","paddingBottom","paddingInline","paddingBlock"])delete C[_];if(n!=="primary"||r||o)for(const _ of["background","backgroundColor","color"])delete C[_];if(r||o)for(const _ of["border","borderColor","borderWidth","borderStyle","boxShadow"])delete C[_];return e.jsxs("span",{className:`nice-badge nice-badge--${n} nice-badge--${i} nice-badge--ds-${f} ${a?"nice-badge--dot":""} ${r?"nice-badge--outline":""} ${o?"nice-badge--subtle":""} ${l?"nice-badge--pulse":""} ${u?"nice-badge--removable":""} ${h||""}`,style:{...C,...p},"data-testid":b??x,children:[d&&e.jsx("span",{className:"nice-badge__icon",children:d}),t,u&&e.jsx("button",{type:"button",className:"nice-badge__remove",onClick:m,"aria-label":g("badge.remove","Remove"),children:e.jsx(c.NiceIcon,{name:"close",size:14})})]})},Pa=({children:t,selected:n,removable:i,onClick:a,onRemove:r,color:o,size:l="md",className:d,style:u,testId:m,"data-testid":h})=>{const{t:p}=c.useNiceTranslation(),y=typeof t=="string"||typeof t=="number"?`${p("tag.remove","Remove")}: ${t}`:p("tag.remove","Remove");return e.jsxs("span",{className:`nice-tag nice-tag--${l} ${a?"nice-tag--clickable":""} ${n?"nice-tag--selected":""} ${d||""}`,style:{...u,...o&&!n?{borderColor:o,color:o}:{}},"data-testid":h??m,...a&&{onClick:a,role:"button",tabIndex:0,"aria-pressed":n,onKeyDown:x=>{x.target===x.currentTarget&&(x.key==="Enter"||x.key===" "?(x.preventDefault(),a()):i&&(x.key==="Delete"||x.key==="Backspace")&&(x.preventDefault(),r?.()))}},children:[t,i&&e.jsx("button",{type:"button",className:"nice-tag__remove",onClick:x=>{x.stopPropagation(),r?.()},"aria-label":y,children:e.jsx(c.NiceIcon,{name:"close",size:14})})]})};function Hp(t){return t.split(" ").map(n=>n[0]).filter(Boolean).slice(0,2).join("").toUpperCase()}const Vt=({src:t,alt:n,name:i,size:a="md",square:r,color:o,className:l,style:d,testId:u,"data-testid":m})=>e.jsx("div",{className:`nice-avatar nice-avatar--${a} ${r?"nice-avatar--square":""} ${l||""}`,style:{...d,...o?{background:o}:{}},"aria-label":n||i,"data-testid":m??u,children:t?e.jsx("img",{src:t,alt:n||i||""}):i?Hp(i):e.jsx(c.NiceIcon,{name:"user",size:"md",className:"nice-avatar__fallback-icon"})});function Gp(t){return t?t.trim().split(/\s+/).map(n=>n[0]).join("").slice(0,2).toUpperCase():""}const Ks=({children:t,items:n,max:i,size:a="md",className:r,style:o,testId:l,"data-testid":d})=>{const u=`nice-avatar nice-avatar--${a}`;let m,h;if(n&&n.length>0)h=n.length,m=(i?n.slice(0,i):n).map((x,b)=>{const g=x.src?e.jsx("img",{src:x.src,alt:x.name??""}):e.jsx("span",{children:Gp(x.name)});return x.href?e.jsx("a",{className:u,href:x.href,title:x.name,onClick:x.onClick,children:g},b):x.onClick?e.jsx("button",{type:"button",className:u,title:x.name,onClick:x.onClick,children:g},b):e.jsx("span",{className:u,title:x.name,children:g},b)});else{const y=s.Children.toArray(t);h=y.length,m=(i?y.slice(0,i):y).map(b=>s.isValidElement(b)&&b.props.size==null?s.cloneElement(b,{size:a}):b)}const p=i?Math.max(0,h-i):0;return e.jsxs("div",{className:`nice-avatar-group nice-avatar-group--${a} ${r||""}`,style:o,"data-testid":d??l,children:[m,p>0&&e.jsxs("div",{className:u,style:{background:"var(--nice-text-muted)"},children:["+",p]})]})},Wp={xxs:4,xs:6,sm:8,md:12,lg:16,xl:20,xxl:28},Lc=Object.assign(s.forwardRef(({children:t,items:n,renderCard:i,searchable:a,searchField:r="text",searchPlaceholder:o,emptyText:l,onCardClick:d,size:u="md",minColumnWidth:m=240,columns:h,gap:p,align:y="stretch",equalHeight:x=!1,value:b,onChange:g,name:v,disabled:f,readOnly:C,loading:_,error:T,errorText:S,className:N,style:j,testId:w,"data-testid":k},I)=>{const{t:M}=c.useNiceTranslation(),[z,R]=s.useState(""),A=h?`repeat(${h}, minmax(0, 1fr))`:`repeat(auto-fill, minmax(${m}px, 1fr))`,E=p??Wp[u]??12,$=typeof T=="string"?T.length>0:!!T,O=typeof T=="string"?T:T?S??"":"",V=n!=null&&i!=null,K=s.useMemo(()=>{if(!V||!z)return n??[];const J=z.toLowerCase();return(n??[]).filter(re=>String(re[r]??"").toLowerCase().includes(J))},[V,n,z,r]),te=g!=null||b!=null,B=s.useMemo(()=>({value:b,onChange:J=>{!f&&!C&&g?.(J)},name:v}),[b,g,v,f,C]),W=x?"stretch":y,ne=x?"1fr":void 0,ae=`nice-card-group nice-card-group--${u}${x?" nice-card-group--equal":""}${f?" nice-card-group--disabled":""}${C?" nice-card-group--readonly":""}${_?" nice-card-group--loading":""}${$?" nice-card-group--error":""}${N?` ${N}`:""}`;if(V)return e.jsx(Be.NiceCardGroupSizeContext.Provider,{value:u,children:e.jsxs("div",{ref:I,className:ae,style:{position:"relative",...j},"aria-disabled":f||void 0,"aria-busy":_||void 0,"data-testid":k??w,children:[a&&e.jsx("div",{className:"nice-card-group__search",children:e.jsx("input",{type:"text",value:z,onChange:J=>R(J.target.value),placeholder:o||M("controls.search","Search...")})}),_?e.jsx("div",{className:"nice-card-group__empty",children:e.jsx("span",{className:"nice-spinner nice-spinner--md"})}):K.length===0?e.jsx("div",{className:"nice-card-group__empty",children:l||M("controls.noData","No data available")}):e.jsx("div",{className:"nice-card-group__grid",style:{display:"grid",gridTemplateColumns:A,gridAutoRows:ne,gap:E,alignItems:W},children:K.map(J=>e.jsx("div",{className:"nice-card-group__data-card",onClick:d?()=>d(J):void 0,onKeyDown:d?re=>{re.target===re.currentTarget&&(re.key==="Enter"||re.key===" ")&&(re.preventDefault(),d(J))}:void 0,role:d?"button":void 0,tabIndex:d?0:void 0,style:d?{cursor:"pointer"}:void 0,children:i(J)},J.key))}),O&&e.jsx("div",{className:"nice-card-group__error",role:"alert",children:O})]})});const Y=e.jsxs("div",{ref:I,className:ae,style:{display:"grid",gridTemplateColumns:A,gridAutoRows:ne,gap:E,alignItems:W,position:_?"relative":void 0,...j},role:te?"radiogroup":void 0,"aria-label":te?v:void 0,"aria-disabled":f||void 0,"aria-busy":_||void 0,"data-testid":k??w,children:[t,_&&e.jsx("span",{className:"nice-card-group__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),O&&!x&&e.jsx("div",{className:"nice-card-group__error",role:"alert",style:{gridColumn:"1 / -1"},children:O})]}),F=O&&x&&e.jsx("div",{className:"nice-card-group__error",role:"alert",children:O});return e.jsxs(Be.NiceCardGroupSizeContext.Provider,{value:u,children:[te?e.jsx(Be.NiceCardRadioContext.Provider,{value:B,children:Y}):Y,F]})}),{displayName:"NiceCardGroup"}),Kp={color:!0,description:!0,volume:!0,gain:!0},Ys=s.forwardRef(function(n,i){const{t:a}=c.useNiceTranslation(),{children:r,name:o,description:l,defaultDescription:d,onDescriptionChange:u,labelPlacement:m="bottom",number:h,color:p="transparent",onColorChange:y,volume:x,defaultVolume:b,onVolumeChange:g,gain:v,defaultGain:f,onGainChange:C,contextMenu:_=!0,quickControls:T,onOpenConfig:S,fullConfigLabel:N=a("deviceTile.fullConfiguration","Full configuration"),selected:j,onClick:w,focusId:k,className:I,style:M,title:z,"data-testid":R}=n,A={...Kp,...T},E=s.useRef(null),$=G=>{E.current=G,typeof i=="function"?i(G):i&&(i.current=G)},O=E;c.useSpatialFocusable(O,{id:k??"",onActivate:w,disabled:!k});const[V,K]=c.useControllableState({value:l,defaultValue:d,fallbackValue:"",onChange:u,componentName:"NiceDeviceTile"}),[te,B]=c.useControllableState({value:x,defaultValue:b,fallbackValue:80,onChange:g,componentName:"NiceDeviceTile"}),[W,ne]=c.useControllableState({value:v,defaultValue:f,fallbackValue:50,onChange:C,componentName:"NiceDeviceTile"}),ae=c.useSpatialNavOptional(),[Y,F]=s.useState(null),J=s.useRef(null);c.useClickOutside(J,()=>F(null)),s.useEffect(()=>{if(Y)return ae?.pauseNavigation(),()=>{ae?.resumeNavigation()}},[Y,ae]),c.useOverlayFocus(J,{open:Y!=null,modal:!1,onClose:()=>F(null)});const re=G=>{if(!_)return;G.preventDefault();let{clientX:ge,clientY:Ce}=G;if(ge===0&&Ce===0){const H=G.currentTarget.getBoundingClientRect();ge=H.left,Ce=H.bottom}const he=Math.min(ge,window.innerWidth-256),L=Math.min(Ce,window.innerHeight-320);F({x:Math.max(8,he),y:Math.max(8,L)})},se=p!=="transparent"&&p!=="";return e.jsxs("div",{ref:$,className:["nice-device-tile",`nice-device-tile--label-${m}`,j?"nice-device-tile--selected":"",se?"nice-device-tile--colored":"",I??""].filter(Boolean).join(" "),style:{...M,"--device-color":p},title:z,"data-testid":R,onClick:w,onKeyDown:w?G=>{G.target===G.currentTarget&&(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),G.currentTarget.click())}:void 0,onContextMenu:re,role:w?"button":void 0,tabIndex:k||w?0:void 0,children:[e.jsxs("div",{className:"nice-device-tile__device",children:[h!=null&&e.jsx("span",{className:"nice-device-tile__badge",children:h}),r]}),(o||V)&&e.jsxs("div",{className:"nice-device-tile__caption",children:[o&&e.jsx("span",{className:"nice-device-tile__name",children:o}),V&&e.jsx("span",{className:"nice-device-tile__description",children:V})]}),Y&&e.jsx("div",{ref:J,className:"nice-device-tile__menu",style:{position:"fixed",left:Y.x,top:Y.y},role:"dialog","aria-label":o,children:e.jsxs("div",{style:{display:"contents"},onClick:G=>G.stopPropagation(),onKeyDown:G=>{G.key!=="Escape"&&G.stopPropagation()},children:[o&&e.jsx("div",{className:"nice-device-tile__menu-title",children:o}),A.color&&e.jsxs("div",{className:"nice-device-tile__menu-row",children:[e.jsx("span",{className:"nice-device-tile__menu-label",children:a("deviceTile.color","Color")}),e.jsx(Hn.NiceColorPicker,{compact:!0,value:se?p:"#3b82f6",onChange:G=>y?.(G)})]}),A.description&&e.jsxs("div",{className:"nice-device-tile__menu-row nice-device-tile__menu-row--stack",children:[e.jsx("span",{className:"nice-device-tile__menu-label",children:a("deviceTile.description","Description")}),e.jsx(Ye.NiceTextInput,{value:V,onChange:G=>K(G),size:"sm"})]}),A.volume&&e.jsxs("div",{className:"nice-device-tile__menu-row",children:[e.jsx("span",{className:"nice-device-tile__menu-label",children:a("deviceTile.volume","Volume")}),e.jsx(it.NiceSlider,{value:te,onChange:G=>B(G),min:0,max:100})]}),A.gain&&e.jsxs("div",{className:"nice-device-tile__menu-row",children:[e.jsx("span",{className:"nice-device-tile__menu-label",children:a("deviceTile.gain","Gain")}),e.jsx(it.NiceSlider,{value:W,onChange:G=>ne(G),min:0,max:100})]}),S&&e.jsx(Le.NiceButton,{size:"sm",variant:"outline",className:"nice-device-tile__menu-config",onClick:()=>{F(null),S()},children:N})]})})]})}),Yp={xxs:20,xs:24,sm:32,md:40,lg:56,xl:72,xxl:96},ca=15,ni=18,la=6,Ri=30,Bc=({level:t=0,size:n="md",muted:i=!1,...a})=>{const{t:r}=c.useNiceTranslation(),l=`nice-mic-clip-${c.useControlId()}`,d=typeof n=="number"?n:Yp[n]??40,u=Math.max(0,Math.min(1,t)),m=la+(1-u)*Ri,h=u*Ri;return e.jsx(Ys,{...a,children:e.jsxs("svg",{className:`nice-microphone${i?" nice-microphone--muted":""}`,width:d,height:d*(64/48),viewBox:"0 0 48 64",role:"img","aria-label":a.name?r("microphone.microphone","Microphone: {name}").replace("{name}",String(a.name)):r("microphone.microphone2","Microphone"),children:[e.jsx("defs",{children:e.jsx("clipPath",{id:l,children:e.jsx("rect",{x:ca,y:la,width:ni,height:Ri,rx:ni/2})})}),e.jsxs("g",{clipPath:`url(#${l})`,children:[e.jsx("rect",{x:ca,y:la,width:ni,height:Ri,className:"nice-microphone__body"}),h>0&&e.jsx("rect",{x:ca,y:m,width:ni,height:h,className:"nice-microphone__level"})]}),e.jsx("rect",{x:ca,y:la,width:ni,height:Ri,rx:ni/2,className:"nice-microphone__outline"}),e.jsx("path",{d:"M10 30 a14 14 0 0 0 28 0",className:"nice-microphone__stand"}),e.jsx("line",{x1:"24",y1:"44",x2:"24",y2:"56",className:"nice-microphone__stand"}),e.jsx("line",{x1:"16",y1:"56",x2:"32",y2:"56",className:"nice-microphone__stand"}),i&&e.jsx("line",{x1:"9",y1:"9",x2:"39",y2:"49",className:"nice-microphone__slash"})]})})},Jp={xxs:22,xs:28,sm:36,md:48,lg:64,xl:84,xxl:110},Qp=[{id:"LT",shape:{kind:"rect",x:18,y:3,w:16,h:5,rx:2},label:[26,1]},{id:"RT",shape:{kind:"rect",x:66,y:3,w:16,h:5,rx:2},label:[74,1]},{id:"LB",shape:{kind:"rect",x:18,y:10,w:16,h:5,rx:2},label:[26,9]},{id:"RB",shape:{kind:"rect",x:66,y:10,w:16,h:5,rx:2},label:[74,9]},{id:"DpadUp",shape:{kind:"rect",x:25,y:26,w:5,h:6,rx:1},label:[27,24]},{id:"DpadDown",shape:{kind:"rect",x:25,y:38,w:5,h:6,rx:1},label:[27,50]},{id:"DpadLeft",shape:{kind:"rect",x:18,y:32,w:6,h:5,rx:1},label:[16,35]},{id:"DpadRight",shape:{kind:"rect",x:31,y:32,w:6,h:5,rx:1},label:[40,35]},{id:"Y",shape:{kind:"circle",cx:74,cy:25,r:4},label:[74,19]},{id:"A",shape:{kind:"circle",cx:74,cy:41,r:4},label:[74,51]},{id:"X",shape:{kind:"circle",cx:66,cy:33,r:4},label:[58,35]},{id:"B",shape:{kind:"circle",cx:82,cy:33,r:4},label:[90,35]},{id:"Back",shape:{kind:"circle",cx:44,cy:26,r:2.6},label:[44,20]},{id:"Start",shape:{kind:"circle",cx:56,cy:26,r:2.6},label:[56,20]},{id:"LS",shape:{kind:"circle",cx:42,cy:42,r:6},label:[42,54]},{id:"RS",shape:{kind:"circle",cx:60,cy:44,r:6},label:[60,56]}],Xp="M50 18 C66 18 72 20 76 26 L90 48 C94 58 86 64 80 58 L66 46 L34 46 L20 58 C14 64 6 58 10 48 L24 26 C28 20 34 18 50 18 Z";function Zp({shape:t}){return t.kind==="circle"?e.jsx("circle",{cx:t.cx,cy:t.cy,r:t.r}):e.jsx("rect",{x:t.x,y:t.y,width:t.w,height:t.h,rx:t.rx??1})}const Fc=({view:t="compact",size:n="md",onButtonPress:i,pressedButtons:a,highlightedButtons:r,live:o=!1,gamepadIndex:l=0,buttonLabels:d,actionTree:u,assignments:m,onAssign:h,...p})=>{const{t:y}=c.useNiceTranslation(),x=typeof n=="number"?n:Jp[n]??48,[b,g]=s.useState(()=>new Set),[v,f]=s.useState(null);c.useGamepad({index:l,enabled:o,onButtonDown:M=>{g(z=>{const R=new Set(z);return R.add(M),R}),i?.(M)},onButtonUp:M=>{g(z=>{const R=new Set(z);return R.delete(M),R})}});const C=M=>!!r?.includes(M)||!!a?.includes(M)||b.has(M),_=x*1.5,T=_*(68/100),S=(M,z)=>{M.stopPropagation(),i?.(z),u&&f(R=>R===z?null:z)},N=t==="compact",j=!N&&(!!i||!!u),w=s.useRef(null);c.useRovingFocus(w,{orientation:"grid",itemSelector:".nice-gamepad__btn",enabled:j});const k=e.jsxs("svg",{className:`nice-gamepad nice-gamepad--${t}${j?" nice-gamepad--interactive":""}`,width:_,height:T,viewBox:"0 0 100 68",role:j?"group":"img","aria-label":p.name?y("gamepad.gamepad","Gamepad: {name}").replace("{name}",String(p.name)):y("gamepad.gamepad2","Gamepad"),children:[e.jsx("path",{d:Xp,className:"nice-gamepad__body"}),!N&&Qp.map(({id:M,shape:z,label:R})=>{const A=d?.[M]??m?.[M];return e.jsxs("g",{"data-button":M,"data-pressed":C(M)?"true":void 0,className:`nice-gamepad__btn${v===M?" nice-gamepad__btn--armed":""}`,role:j?"button":void 0,"aria-label":j?A?`${M} ${A}`:M:void 0,"aria-pressed":j&&u?v===M:void 0,onClick:E=>S(E,M),onKeyDown:E=>{j&&(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),S(E,M))},children:[e.jsx(Zp,{shape:z}),A&&e.jsx("text",{x:R[0],y:R[1],className:"nice-gamepad__label",children:A})]},M)})]}),I=j?e.jsx("div",{ref:w,className:"nice-gamepad__pad",children:k}):k;return e.jsx(Ys,{...p,children:u&&!N?e.jsxs("div",{className:"nice-gamepad__assign",children:[I,e.jsxs("div",{className:"nice-gamepad__tree",children:[e.jsx("div",{className:"nice-gamepad__tree-hint",children:v?y("gamepad.assignTo",'Assign to "{armed}"…').replace("{armed}",String(v)):y("gamepad.clickAButtonThenA","Click a button, then a node")}),e.jsx(yt.NiceTreeView,{nodes:u,selectionMode:"single",onNodeClick:M=>{v&&(h?.(v,M),f(null))}})]})]}):I})},em=[],tm=({devices:t,defaultDevices:n,onDevicesChange:i,autoDetect:a=!0,kinds:r=["microphone","gamepad"],slots:o,onAssign:l,onOpenConfig:d,columns:u,minColumnWidth:m=160,className:h,style:p,id:y,"data-testid":x})=>{const{t:b}=c.useNiceTranslation(),[g,v]=c.useControllableState({value:t,defaultValue:n,fallbackValue:em,onChange:i,componentName:"NiceDeviceManager"}),f=s.useCallback(N=>{N.length!==0&&v(j=>{const w=new Set(j.map(I=>I.id)),k=N.filter(I=>!w.has(I.id));return k.length?[...j,...k]:j})},[v]);s.useEffect(()=>{if(!a||!r.includes("microphone")||!navigator.mediaDevices?.enumerateDevices)return;let N=!1;const j=()=>{navigator.mediaDevices.enumerateDevices().then(w=>{if(N)return;const k=w.filter(I=>I.kind==="audioinput").map((I,M)=>({id:`mic:${I.deviceId||M}`,kind:"microphone",name:I.label||`Microphone ${M+1}`,deviceId:I.deviceId}));f(k)}).catch(()=>{})};return j(),navigator.mediaDevices.addEventListener?.("devicechange",j),()=>{N=!0,navigator.mediaDevices.removeEventListener?.("devicechange",j)}},[a,r,f]);const C=c.useConnectedGamepads(),_=a&&r.includes("gamepad");s.useEffect(()=>{_&&f(C.map(N=>({id:`pad:${N.index}`,kind:"gamepad",name:N.id.split("(")[0]?.trim()||`Controller ${N.index+1}`,deviceId:String(N.index)})))},[_,C,f]);const T=s.useCallback((N,j)=>{v(w=>w.map(k=>k.id===N?{...k,...j}:k))},[v]),S=s.useCallback((N,j)=>{T(N,{assignedTo:j}),l?.(N,j)},[T,l]);return e.jsx("div",{id:y,"data-testid":x,className:`nice-device-manager ${h??""}`.trim(),style:p,children:g.length===0?e.jsx("p",{className:"nice-device-manager__empty",children:b("deviceManager.noDevicesDetected","No devices detected.")}):e.jsx(Lc,{columns:u,minColumnWidth:m,gap:12,children:g.map((N,j)=>{const w={name:N.name,description:N.description,number:N.number??j+1,color:N.color??"transparent",volume:N.volume,gain:N.gain,onColorChange:k=>T(N.id,{color:k}),onDescriptionChange:k=>T(N.id,{description:k}),onVolumeChange:k=>T(N.id,{volume:k}),onGainChange:k=>T(N.id,{gain:k}),onOpenConfig:()=>d?.(N)};return e.jsxs("div",{className:"nice-device-manager__cell",children:[N.kind==="microphone"?e.jsx(Bc,{...w,level:N.level}):e.jsx(Fc,{...w,view:"compact",live:!0}),o&&o.length>0&&e.jsx("div",{className:"nice-device-manager__slots",children:o.map(k=>e.jsx(Le.NiceButton,{size:"sm",variant:N.assignedTo===k.id?"primary":"ghost",onClick:()=>S(N.id,N.assignedTo===k.id?null:k.id),children:k.label},k.id))})]},N.id)})})})},nm=[];function Zr(t,n){const i=t.getBoundingClientRect(),a=n.getBoundingClientRect(),r=getComputedStyle(t),o=parseFloat(r.borderLeftWidth)||0,l=parseFloat(r.borderTopWidth)||0;return{width:a.width,height:a.height,left:0,top:0,transform:`translate(${a.left-i.left-o}px, ${a.top-i.top-l}px)`,opacity:1}}function tn({options:t=nm,value:n,defaultValue:i,onChange:a,size:r="md",block:o=!1,disabled:l=!1,readOnly:d=!1,loading:u=!1,error:m,highlightFill:h=!0,errorPlacement:p="bottom",className:y="",style:x,"data-testid":b="nice-segmented-control"}){const{t:g}=c.useNiceTranslation(),v=s.useRef(null),[f,C]=s.useState(i),[_,T]=s.useState({}),S=n!==void 0?n:f,N=t.findIndex(k=>k.value===S);s.useEffect(()=>{if(!v.current||N<0){T({opacity:0});return}const k=v.current,M=k.querySelectorAll(".nice-segmented-control__option")[N];if(!M){T({opacity:0});return}T(Zr(k,M))},[N,t.length,h,r,o]),s.useEffect(()=>{const k=()=>{if(!v.current||N<0)return;const I=v.current,z=I.querySelectorAll(".nice-segmented-control__option")[N];z&&T(Zr(I,z))};return window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)},[N]);const j=s.useCallback(k=>{l||d||u||t.find(M=>M.value===k)?.disabled||(n===void 0&&C(k),a?.(k))},[l,d,u,t,n,a]);c.useRovingFocus(v,{orientation:"both",wrap:!0,activateOnMove:!0});const w=e.jsxs("div",{ref:v,className:`nice-segmented-control nice-segmented-control--${r} ${o?"nice-segmented-control--block":""} ${l?"nice-segmented-control--disabled":""} ${d?"nice-segmented-control--readonly":""} ${u?"nice-segmented-control--loading":""} ${m?"nice-segmented-control--error":""} ${h?"nice-segmented-control--fill":""} ${y}`,style:x,role:"radiogroup","aria-label":g("controls.select","Select option"),"aria-busy":u||void 0,"aria-invalid":!!m||void 0,"data-testid":b,children:[e.jsx("div",{className:"nice-segmented-control__thumb",style:_}),t.map((k,I)=>{const M=k.value===S,z=l||k.disabled;return e.jsxs("button",{type:"button",className:`nice-segmented-control__option ${M?"nice-segmented-control__option--selected":""} ${z?"nice-segmented-control__option--disabled":""}`,onClick:()=>j(k.value),disabled:z||u,role:"radio","aria-checked":M,"data-testid":`${b}-option-${I}`,children:[k.icon&&e.jsx("span",{className:"nice-segmented-control__icon",children:k.icon}),e.jsx("span",{className:"nice-segmented-control__label",children:k.label})]},String(k.value))}),u&&e.jsx("div",{className:"nice-segmented-control__spinner","aria-hidden":"true",children:e.jsx("div",{className:"nice-spinner nice-spinner--sm"})})]});return m?e.jsxs("div",{className:`nice-segmented-control-field${p==="right"?" nice-segmented-control-field--err-right":""}`,children:[w,e.jsx("div",{className:"nice-segmented-control__error",role:"alert",children:m})]}):w}process.env.NODE_ENV!=="production"&&(tn.displayName="NiceSegmentedControl");const im=["gamepad","hints","navigation","bindings"],am=["activate","back","secondary","tertiary","menu","view","sectionPrev","sectionNext","pagePrev","pageNext","first","last","toggleHints"],es={navigate:"Move",activate:"Select",back:"Back",secondary:"Options",tertiary:"More",menu:"Menu",view:"Switch area",sectionPrev:"Previous section",sectionNext:"Next section",pagePrev:"Previous page",pageNext:"Next page",first:"First",last:"Last",scroll:"Scroll",toggleHints:"Show or hide hints"},sm=Object.assign(function({sections:n=im,className:i,style:a,id:r,"data-testid":o}){const{t:l}=c.useNiceTranslation(),[d,u]=c.useInputPreferences(),[m,h]=s.useState(null);s.useEffect(()=>{if(!(!m||typeof window>"u"))return c.getInputEngine().captureNextInput(g=>{m.device==="gamepad"&&g.button?u({gamepadBindings:{...d.gamepadBindings,[m.intent]:[g.button]}}):m.device==="keyboard"&&g.keys&&u({keyboardBindings:{...d.keyboardBindings,[m.intent]:[g.keys]}}),h(null)})},[m,d.gamepadBindings,d.keyboardBindings,u]);const p=(g,v)=>u({[g]:v}),y=l("inputSettings.auto","Automatic"),x=g=>{const{[g]:v,...f}=d.gamepadBindings,{[g]:C,..._}=d.keyboardBindings;u({gamepadBindings:f,keyboardBindings:_})},b=g=>{switch(g){case"gamepad":return e.jsxs("section",{className:"nice-input-settings__section",children:[e.jsx("h3",{className:"nice-input-settings__title",children:l("inputSettings.section.gamepad","Gamepad")}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:l("inputSettings.confirmButton","Confirm with")}),e.jsx(tn,{value:d.confirmButton,onChange:v=>p("confirmButton",v),options:[{value:"auto",label:y},{value:"south",label:l("input.pad.bottomButton","Bottom button")},{value:"east",label:l("input.pad.rightButton","Right button")}]})]}),e.jsx(Ut.NiceSelect,{label:l("inputSettings.glyphFamily","Button symbols"),value:d.glyphFamily,onChange:v=>p("glyphFamily",v),options:[{value:"auto",label:y},{value:"xbox",label:"Xbox"},{value:"playstation",label:"PlayStation"},{value:"nintendo",label:"Nintendo"},{value:"steam",label:"Steam"},{value:"generic",label:l("inputSettings.family.generic","Generic")}]}),e.jsx(it.NiceSlider,{label:l("inputSettings.stickThreshold","Stick push needed to move"),min:.2,max:.9,step:.05,value:d.stickThreshold,onChange:v=>p("stickThreshold",v),showValue:!0}),e.jsx(it.NiceSlider,{label:l("inputSettings.repeatDelay","Repeat after (ms)"),min:200,max:800,step:20,value:d.repeatDelay,onChange:v=>p("repeatDelay",v),showValue:!0}),e.jsx(it.NiceSlider,{label:l("inputSettings.repeatInterval","Repeat every (ms)"),min:50,max:250,step:10,value:d.repeatInterval,onChange:v=>p("repeatInterval",v),showValue:!0}),e.jsx(Ht.NiceToggle,{label:l("inputSettings.invertScroll","Invert scrolling with the right stick"),checked:d.invertScroll,onChange:v=>p("invertScroll",v)}),e.jsx(Ht.NiceToggle,{label:l("inputSettings.vibration","Vibration"),checked:d.vibration,onChange:v=>p("vibration",v)})]},g);case"hints":return e.jsxs("section",{className:"nice-input-settings__section",children:[e.jsx("h3",{className:"nice-input-settings__title",children:l("inputSettings.section.hints","Button hints")}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:l("inputSettings.hints","Show hints")}),e.jsx(tn,{value:d.hints,onChange:v=>p("hints",v),options:[{value:"auto",label:l("inputSettings.hints.auto","With keyboard or pad")},{value:"always",label:l("inputSettings.always","Always")},{value:"never",label:l("inputSettings.never","Never")}]})]}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:l("inputSettings.hintDensity","Where")}),e.jsx(tn,{value:d.hintDensity,onChange:v=>p("hintDensity",v),options:[{value:"bar",label:l("inputSettings.density.bar","Hint bar")},{value:"bar-and-controls",label:l("inputSettings.density.barAndControls","Bar and controls")}]})]})]},g);case"navigation":return e.jsxs("section",{className:"nice-input-settings__section",children:[e.jsx("h3",{className:"nice-input-settings__title",children:l("inputSettings.section.navigation","Navigation")}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:l("inputSettings.arrowNavigation","Arrow keys outside lists")}),e.jsx(tn,{value:d.arrowNavigation,onChange:v=>p("arrowNavigation",v),options:[{value:"auto",label:l("inputSettings.arrows.auto","Depends on the area")},{value:"spatial",label:l("inputSettings.arrows.spatial","Move focus")},{value:"native",label:l("inputSettings.arrows.native","Scroll")}]})]}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:l("inputSettings.onScreenKeyboard","On-screen keyboard")}),e.jsx(tn,{value:d.onScreenKeyboard,onChange:v=>p("onScreenKeyboard",v),options:[{value:"auto",label:l("inputSettings.osk.auto","With a pad")},{value:"always",label:l("inputSettings.always","Always")},{value:"never",label:l("inputSettings.never","Never")}]})]})]},g);default:return e.jsxs("section",{className:"nice-input-settings__section",children:[e.jsx("h3",{className:"nice-input-settings__title",children:l("inputSettings.section.bindings","Buttons and keys")}),e.jsxs("table",{className:"nice-input-settings__bindings",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:l("inputSettings.actionColumn","Action")}),e.jsx("th",{scope:"col",children:l("inputSettings.gamepadColumn","Gamepad")}),e.jsx("th",{scope:"col",children:l("inputSettings.keyboardColumn","Keyboard")}),e.jsx("th",{scope:"col",children:e.jsx("span",{className:"nice-sr-only",children:l("inputSettings.reset","Reset")})})]})}),e.jsx("tbody",{children:am.map(v=>{const f=_=>m?.intent===v&&m.device===_,C=(d.keyboardBindings[v]??c.NICE_DEFAULT_KEYBOARD_BINDINGS[v])[0];return e.jsxs("tr",{children:[e.jsx("th",{scope:"row",className:"nice-input-settings__action",children:l(`input.intent.${v}`,es[v])}),e.jsx("td",{children:e.jsx(Le.NiceButton,{size:"sm",variant:"ghost",onClick:()=>h({intent:v,device:"gamepad"}),"aria-label":`${l("inputSettings.change","Change")}: ${l(`input.intent.${v}`,es[v])}`,children:f("gamepad")?l("inputSettings.pressButton","Press a button…"):e.jsx(c.NiceButtonPrompt,{intent:v,device:"gamepad",size:"sm"})})}),e.jsx("td",{children:e.jsx(Le.NiceButton,{size:"sm",variant:"ghost",onClick:()=>h({intent:v,device:"keyboard"}),"aria-label":`${l("inputSettings.change","Change")}: ${l(`input.intent.${v}`,es[v])}`,children:f("keyboard")?l("inputSettings.pressKey","Press a key…"):C?e.jsx(c.NiceKeyCap,{keys:C,size:"sm"}):l("inputSettings.none","None")})}),e.jsx("td",{children:e.jsx(Le.NiceButton,{size:"sm",variant:"ghost",onClick:()=>x(v),children:l("inputSettings.reset","Reset")})})]},v)})})]}),e.jsxs("div",{className:"nice-input-settings__actions",children:[m&&e.jsx(Le.NiceButton,{size:"sm",onClick:()=>h(null),children:l("inputSettings.cancel","Cancel")}),e.jsx(Le.NiceButton,{size:"sm",variant:"secondary",onClick:()=>u({gamepadBindings:{},keyboardBindings:{}}),children:l("inputSettings.resetAll","Reset all bindings")})]})]},g)}};return e.jsx("div",{id:r,"data-testid":o,className:`nice-input-settings${i?` ${i}`:""}`,style:a,children:n.map(b)})},{displayName:"NiceInputSettings"}),Ta=({value:t,max:n=100,label:i,helperText:a,error:r,required:o,disabled:l,loading:d,showValue:u=!0,text:m,variant:h="primary",size:p="md",striped:y,animated:x,formatValue:b,labelPlacement:g="top",errorPlacement:v="bottom",labelWidth:f,controlWidth:C,className:_,style:T,id:S})=>{const N=c.useControlId(S),j=Math.min(100,Math.max(0,t/n*100)),w=m??(b?b(t,n):`${Math.round(j)}%`),k=u,I=i?e.jsxs("label",{className:"nice-field__label",htmlFor:N,children:[i,o&&e.jsx("span",{className:"nice-field__required",children:"*"})]}):null,M=r?e.jsx("div",{id:`${N}-error`,className:"nice-field__error",role:"alert",children:r}):null,z=!r&&a?e.jsx("div",{id:`${N}-helper`,className:"nice-field__helper",children:a}):null,R=e.jsxs("div",{className:`nice-progress ${l?"nice-progress--disabled":""} ${d?"nice-progress--loading":""}`,role:"progressbar",id:N,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":n,"aria-busy":d||void 0,"aria-disabled":l||void 0,children:[e.jsx("div",{className:`nice-progress__track ${p!=="md"?`nice-progress__track--${p}`:""}`,children:e.jsx("div",{className:`nice-progress__fill nice-progress__fill--${h} ${y||d?"nice-progress__fill--striped":""} ${x||d?"nice-progress__fill--animated":""}`,style:{width:d?"100%":`${j}%`}})}),k&&(g==="left"||g==="right")&&e.jsx("span",{className:"nice-progress__value",children:w})]}),A=e.jsxs("div",{className:"nice-progress__header",children:[I,k&&e.jsx("span",{className:"nice-progress__value",children:w})]});return e.jsxs("div",{className:`nice-field nice-field--${p} ${g==="left"?"nice-field--label-left":""} ${_||""}`,style:{...T,...f!=null&&{"--nice-field-label-width":typeof f=="number"?`${f}px`:f},...C!=null&&{"--nice-field-control-width":typeof C=="number"?`${C}px`:C}},children:[g==="top"&&(k?A:I),g==="left"||g==="right"?e.jsxs("div",{className:"nice-field__control",style:{display:"flex",alignItems:"center",gap:"var(--nice-space-2, 8px)",flex:"1 1 auto"},children:[g==="right"?e.jsxs(e.Fragment,{children:[R,I]}):e.jsxs(e.Fragment,{children:[I,R]}),v==="right"&&M,v==="right"&&!r&&z]}):e.jsx("div",{className:"nice-field__control",children:R}),g==="bottom"&&(k?A:I),v!=="right"&&M,v!=="right"&&z]})},Aa=({vertical:t,text:n,size:i="md",className:a,style:r,testId:o,"data-testid":l})=>t?e.jsx("hr",{className:`nice-divider nice-divider--vertical nice-divider--${i} ${a||""}`,style:r,"data-testid":l??o}):n?e.jsx("div",{className:`nice-divider--with-text nice-divider--${i} ${a||""}`,style:r,"data-testid":l??o,children:n}):e.jsx("hr",{className:`nice-divider nice-divider--${i} ${a||""}`,style:r,"data-testid":l??o}),eo=t=>typeof t=="number"?t:/^\d+(\.\d+)?$/.test(t.trim())?`${t}px`:t,rm={text:14,rect:80,circle:40},om={xxs:{text:6,rect:28,circle:16},xs:{text:8,rect:40,circle:24},sm:{text:11,rect:60,circle:32},small:{text:11,rect:60,circle:32},md:{text:14,rect:80,circle:40},medium:{text:14,rect:80,circle:40},lg:{text:20,rect:120,circle:56},large:{text:20,rect:120,circle:56},xl:{text:28,rect:160,circle:72},xxl:{text:36,rect:220,circle:96}},Hi=({variant:t="text",width:n,height:i,count:a=1,size:r="md",orientation:o="vertical",animationSpeed:l,className:d,style:u,testId:m,"data-testid":h})=>{const p=om[r]??rm,y=eo(n??(t==="circle"?p.circle:"100%")),x=eo(i??(t==="text"?p.text:t==="circle"?p.circle:p.rect)),b=l!=null&&l>0?{"--nice-skeleton-speed":`${l}s`}:null;if(a<=1)return e.jsx("div",{className:`nice-skeleton nice-skeleton--${t} nice-skeleton--${r} ${d||""}`,style:{width:y,height:x,...b,...u},"data-testid":h??m});const g=o==="horizontal";return e.jsx("div",{className:`nice-skeleton-group ${d||""}`,style:{display:"flex",flexDirection:g?"row":"column",gap:"var(--nice-space-2, 8px)",width:"100%",...b,...u},"data-testid":h??m,children:Array.from({length:a}).map((v,f)=>e.jsx("div",{className:`nice-skeleton nice-skeleton--${t} nice-skeleton--${r}`,style:g?{flex:"1 1 0",minWidth:0,height:x}:{width:y,height:x}},f))})},Js=({icon:t,title:n,description:i,action:a,size:r="md",className:o,style:l,testId:d,"data-testid":u})=>e.jsxs("div",{className:`nice-empty nice-empty--${r} ${o||""}`,style:l,"data-testid":u??d,role:"status","aria-label":n,children:[t&&e.jsx("div",{className:"nice-empty__icon","aria-hidden":"true",children:t}),e.jsx("div",{className:"nice-empty__title",children:n}),i&&e.jsx("div",{className:"nice-empty__desc",children:i}),a]}),cm=[],to={xxs:9,xs:11,sm:13,small:13,md:16,medium:16,lg:20,large:20,xl:24,xxl:28},Vc=Object.assign(s.forwardRef(({items:t=cm,mode:n="left",size:i="md",isFragment:a=!1,renderItem:r,className:o,style:l,id:d,testId:u,"data-testid":m,...h},p)=>{const{renderIcon:y}=c.useNiceIcon(),x=to[i]??to.md;return e.jsx("div",{ref:p,id:d,className:`nice-timeline nice-timeline--${n} nice-timeline--${i} ${a?"nice-timeline--fragment":""} ${o||""}`,style:l,"data-testid":m??u,...h,children:t.map((b,g)=>{const v=n==="alternate"?g%2===0?"left":"right":n;return e.jsxs("div",{className:`nice-timeline__item nice-timeline__item--${v}`,children:[e.jsx("div",{className:"nice-timeline__dot",style:b.color?{borderColor:b.color,color:b.color}:void 0,children:y(b.icon,x)??e.jsx("span",{className:"nice-timeline__dot-inner",style:b.color?{background:b.color}:void 0})}),a&&g===0&&e.jsx("div",{className:"nice-timeline__connector nice-timeline__connector--leading"}),(g<t.length-1||a)&&e.jsx("div",{className:"nice-timeline__connector"}),e.jsx("div",{className:"nice-timeline__content",children:r?r(b,g):e.jsxs(e.Fragment,{children:[b.title&&e.jsx("div",{className:"nice-timeline__title",children:b.title}),b.subtitle&&e.jsx("div",{className:"nice-timeline__subtitle",children:b.subtitle}),b.content&&e.jsx("div",{className:"nice-timeline__body",children:b.content})]})})]},b.key)})})}),{displayName:"NiceTimeline"}),lm=[],qc=Object.assign(s.forwardRef(({items:t=lm,visibleCount:n=1,showArrows:i=!0,showDots:a=!0,autoPlay:r=7e3,circular:o=!0,activeIndex:l,onChange:d,size:u="md",fullWidth:m=!0,className:h,style:p,id:y,testId:x,"data-testid":b,...g},v)=>{const{t:f}=c.useNiceTranslation(),[C,_]=s.useState(0),T=s.useRef(void 0),N=l!=null&&typeof d=="function"?l:C,j=Math.max(1,Math.floor(n||1)),w=Math.max(0,t.length-j),k=s.useCallback(F=>{let J=F;o?J=(F%t.length+t.length)%t.length:J=Math.max(0,Math.min(w,F)),_(J),d?.(J)},[t.length,w,o,d]),I=s.useCallback(()=>k(N+1),[k,N]),M=s.useCallback(()=>k(N-1),[k,N]),[z,R]=s.useState(!1),[A,E]=s.useState(!1),[$,O]=s.useState(!1),V=r>0&&!$&&!z&&!A;s.useEffect(()=>{if(V)return T.current=setInterval(I,r),()=>clearInterval(T.current)},[V,r,I]);const K=o||N>0,te=o||N<w,B=s.useRef(null);s.useEffect(()=>{const F=B.current?.children;F&&Array.from(F).forEach((J,re)=>{J.toggleAttribute("inert",re<N||re>=N+j)})},[N,j,t.length]);const W=s.useRef(null),ne=s.useCallback(F=>{W.current=F,typeof v=="function"?v(F):v&&(v.current=F)},[v]);c.useIntent(["sectionPrev","sectionNext"],F=>{if(F.intent==="sectionNext"?!te:!K)return!1;F.intent==="sectionNext"?I():M()},{ref:W,enabled:t.length>j}),c.useInputHints(W,[{intent:"sectionPrev",label:f("carousel.prev","Previous slide")},{intent:"sectionNext",label:f("carousel.next","Next slide")}],{enabled:t.length>j});const ae=s.useCallback(F=>{F.target===F.currentTarget&&(F.key==="ArrowLeft"&&K?(F.preventDefault(),M()):F.key==="ArrowRight"&&te?(F.preventDefault(),I()):F.key==="Home"?(F.preventDefault(),k(0)):F.key==="End"&&(F.preventDefault(),k(w)))},[M,I,k,K,te,w]),Y=s.useRef(null);return c.useRovingFocus(Y,{orientation:"horizontal",activateOnMove:!0}),e.jsxs("div",{ref:ne,id:y,className:`nice-carousel nice-carousel--${u} ${m?"nice-carousel--full-width":""} ${h||""}`,style:p,"data-testid":b??x,role:"region","aria-roledescription":"carousel","aria-label":f("carousel.label","Carousel"),tabIndex:0,onKeyDown:ae,onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),onFocus:()=>E(!0),onBlur:F=>{F.currentTarget.contains(F.relatedTarget)||E(!1)},...g,children:[r>0&&e.jsx("button",{type:"button",className:"nice-carousel__rotation",onClick:()=>O(F=>!F),"aria-label":$?f("carousel.startRotation","Start automatic slide show"):f("carousel.stopRotation","Stop automatic slide show"),children:e.jsx(c.NiceIcon,{name:$?"play":"pause",size:16})}),e.jsx("div",{className:"nice-carousel__viewport","aria-live":V?"off":"polite",children:e.jsx("div",{ref:B,className:"nice-carousel__track",style:{transform:`translateX(-${N*(100/j)}%)`,"--nice-carousel-slide-basis":`${100/j}%`},children:t.map((F,J)=>e.jsx("div",{className:"nice-carousel__slide",role:"group","aria-roledescription":"slide","aria-label":`${J+1} / ${t.length}`,children:F},J))})}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-carousel__arrow nice-carousel__arrow--prev",onClick:M,disabled:!K,"aria-label":f("carousel.prev","Previous"),children:e.jsx(c.NiceIcon,{name:"chevron-left",size:20})}),e.jsx("button",{type:"button",className:"nice-carousel__arrow nice-carousel__arrow--next",onClick:I,disabled:!te,"aria-label":f("carousel.next","Next"),children:e.jsx(c.NiceIcon,{name:"chevron-right",size:20})})]}),a&&t.length>j&&e.jsx("div",{className:"nice-carousel__dots",role:"tablist",ref:Y,children:Array.from({length:w+1},(F,J)=>e.jsx("button",{type:"button",className:`nice-carousel__dot ${J===N?"nice-carousel__dot--active":""}`,onClick:()=>k(J),role:"tab","aria-selected":J===N,"aria-label":`${f("carousel.goTo","Go to slide")} ${J+1}`},J))})]})}),{displayName:"NiceCarousel"}),dm=[];function um({items:t=dm,itemHeight:n,height:i=400,overscan:a=3,renderItem:r,itemKey:o,className:l,style:d,size:u="md",disabled:m,readOnly:h,loading:p,error:y,testId:x,"data-testid":b,...g},v){const f=s.useRef(null),[C,_]=s.useState(0),T=typeof i=="number"?i:parseFloat(String(i)),S=Number.isFinite(T)?T:400,N=Number.isFinite(n)&&n>0?n:1,j=Number.isFinite(a)&&a>=0?Math.floor(a):0,w=t.length*N,{startIndex:k,endIndex:I}=s.useMemo(()=>{const R=Math.max(1,Math.ceil(S/N)),A=Math.floor(C/N),E=Math.max(0,A-j),$=Math.min(t.length-1,A+R+j);return{startIndex:E,endIndex:$}},[C,S,N,t.length,j]),M=s.useCallback(R=>{_(R.currentTarget.scrollTop)},[]);s.useEffect(()=>{v&&(typeof v=="function"?v(f.current):v.current=f.current)},[v]);const z=s.useMemo(()=>{const R=[];for(let A=k;A<=I;A++){const E=o?o(t[A],A):A;R.push(e.jsx("div",{className:"nice-virtual-scroller__item",style:{position:"absolute",top:A*N,left:0,right:0,height:N},children:r(t[A],A)},E))}return R},[k,I,t,N,r,o]);return e.jsxs("div",{ref:f,className:`nice-virtual-scroller nice-virtual-scroller--${u} ${m?"nice-virtual-scroller--disabled":""} ${y?"nice-virtual-scroller--error":""} ${l||""}`,style:{width:"100%",...d,height:typeof i=="string"&&!/^\d+(\.\d+)?$/.test(i)?i:S,overflow:"auto",position:"relative"},onScroll:M,role:"list","aria-disabled":m||void 0,"aria-busy":p||void 0,"data-testid":b??x,...g,children:[y?e.jsx("div",{className:"nice-virtual-scroller__error",role:"alert",children:y}):e.jsx("div",{style:{height:w,position:"relative",width:"100%"},children:z}),p&&e.jsx("div",{className:"nice-virtual-scroller__loading","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})}const Uc=Object.assign(s.forwardRef(um),{displayName:"NiceVirtualScroller"}),pm=[],Hc=s.createContext(null);function Ha(){const t=s.useContext(Hc);if(!t)throw new Error("useFAQ must be used within NiceFAQ");return t}function da(t,n){if(!n)return{score:1,indices:[]};const i=t.toLowerCase(),r=n.toLowerCase().split(/\s+/).filter(Boolean);let o=0;const l=[];for(const u of r){let m=!1,h=0;for(;(h=i.indexOf(u,h))!==-1;){m=!0,l.push([h,h+u.length]);const p=h===0||/\s/.test(t[h-1]),y=h+u.length===t.length||/\s/.test(t[h+u.length]);p&&y?o+=2:p?o+=1.5:o+=1,h+=1}if(!m){let p=0,y=-1;for(let x=0;x<i.length&&p<u.length;x++)if(i[x]===u[p]){if(y===-1||x===y+1)if(y===-1)l.push([x,x+1]);else{const b=l[l.length-1];b[1]=x+1}else l.push([x,x+1]);y=x,p++}if(p===u.length)o+=.5;else return null}}const d=mm(l);return{score:o/r.length,indices:d}}function mm(t){if(t.length===0)return[];const n=[...t].sort((a,r)=>a[0]-r[0]),i=[n[0]];for(let a=1;a<n.length;a++){const r=i[i.length-1],o=n[a];o[0]<=r[1]?r[1]=Math.max(r[1],o[1]):i.push(o)}return i}function hm(t,n){if(!n.trim())return t.map(a=>({item:a,score:1,matches:[]}));const i=[];for(const a of t){const r=[];let o=0;const l=da(a.question,n);if(l&&l.score>0&&(r.push({field:"question",indices:l.indices}),o+=l.score*3),typeof a.answer=="string"){const d=da(a.answer,n);d&&d.score>0&&(r.push({field:"answer",indices:d.indices}),o+=d.score*1)}if(a.tags)for(const d of a.tags){const u=da(d,n);if(u&&u.score>0){r.push({field:"tags",indices:u.indices}),o+=u.score*2;break}}if(a.keywords)for(const d of a.keywords){const u=da(d,n);if(u&&u.score>0){r.push({field:"keywords",indices:u.indices}),o+=u.score*2.5;break}}r.length>0&&(a.featured&&(o*=1.2),i.push({item:a,score:o,matches:r}))}return i.sort((a,r)=>r.score-a.score)}const gm=({text:t,indices:n})=>{if(n.length===0)return e.jsx(e.Fragment,{children:t});const i=[];let a=0;for(const[r,o]of n)r>a&&i.push(e.jsx("span",{children:t.slice(a,r)},`text-${a}`)),i.push(e.jsx("mark",{className:"nice-faq-highlight",children:t.slice(r,o)},`mark-${r}`)),a=o;return a<t.length&&i.push(e.jsx("span",{children:t.slice(a)},`text-${a}`)),e.jsx(e.Fragment,{children:i})},Gc=({placeholder:t,autoFocus:n=!1,showIcon:i=!0,debounceMs:a=200})=>{const{t:r}=c.useNiceTranslation(),o=t??r("faq.searchFaqPlaceholder","Search FAQ..."),{searchQuery:l,setSearchQuery:d}=Ha(),[u,m]=s.useState(l),h=s.useRef(null),p=s.useRef(null);s.useEffect(()=>(p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{d(u)},a),()=>{p.current&&clearTimeout(p.current)}),[u,a,d]);const y=s.useCallback(()=>{m(""),d(""),h.current?.focus()},[d]);return e.jsxs("div",{className:"nice-faq-search",children:[i&&e.jsx("span",{className:"nice-faq-search-icon",children:e.jsx(c.NiceIcon,{name:"search",size:16})}),e.jsx("input",{ref:h,type:"text",className:"nice-faq-search-input",placeholder:o,value:u,onChange:x=>m(x.target.value),autoFocus:n,"aria-label":r("faq.searchFaq","Search FAQ")}),u&&e.jsx("button",{className:"nice-faq-search-clear",onClick:y,"aria-label":r("faq.clearSearch","Clear search"),children:e.jsx(c.NiceIcon,{name:"close",size:14})})]})},Wc=({showCounts:t=!0,layout:n="horizontal"})=>{const{t:i}=c.useNiceTranslation(),{categories:a,items:r,selectedCategory:o,setSelectedCategory:l}=Ha(),d=s.useMemo(()=>{const u={all:r.length};for(const m of r)m.category&&(u[m.category]=(u[m.category]||0)+1);return u},[r]);return a.length===0?null:n==="dropdown"?e.jsx("div",{className:"nice-faq-category-dropdown",children:e.jsxs("select",{value:o||"all",onChange:u=>l(u.target.value==="all"?null:u.target.value),className:"nice-faq-category-select",children:[e.jsxs("option",{value:"all",children:[i("faq.allCategories","All Categories")," ",t&&`(${d.all})`]}),a.map(u=>e.jsxs("option",{value:u.id,children:[u.name," ",t&&`(${d[u.id]||0})`]},u.id))]})}):e.jsxs("div",{className:`nice-faq-categories nice-faq-categories--${n}`,children:[e.jsxs("button",{className:`nice-faq-category-btn ${o?"":"nice-faq-category-btn--active"}`,onClick:()=>l(null),children:[e.jsx("span",{children:i("faq.all","All")}),t&&e.jsx("span",{className:"nice-faq-category-count",children:d.all})]}),a.map(u=>e.jsxs("button",{className:`nice-faq-category-btn ${o===u.id?"nice-faq-category-btn--active":""}`,onClick:()=>l(u.id),style:u.color?{"--cat-color":u.color}:void 0,children:[u.icon&&e.jsx("span",{className:"nice-faq-category-icon",children:u.icon}),e.jsx("span",{children:u.name}),t&&e.jsx("span",{className:"nice-faq-category-count",children:d[u.id]||0})]},u.id))]})},Qs=({result:t,showFeedback:n=!0,showRelated:i=!0,animateExpand:a=!0})=>{const{t:r}=c.useNiceTranslation(),{item:o,matches:l}=t,{expandedIds:d,toggleExpanded:u,items:m,submitFeedback:h}=Ha(),[p,y]=s.useState(null),[x,b]=s.useState(!1),[g,v]=s.useState(""),f=s.useRef(null),C=d.has(o.id);s.useEffect(()=>{f.current?.toggleAttribute("inert",!C)},[C]);const _=l.find(j=>j.field==="question")?.indices||[],T=s.useMemo(()=>!i||!o.relatedIds||o.relatedIds.length===0?[]:m.filter(j=>o.relatedIds?.includes(j.id)),[i,o.relatedIds,m]),S=j=>{y(j),j?h(o.id,j):b(!0)},N=()=>{h(o.id,!1,g),b(!1),v("")};return e.jsxs("div",{className:`nice-faq-item ${C?"nice-faq-item--expanded":""} ${o.featured?"nice-faq-item--featured":""}`,"data-question-id":o.id,children:[e.jsxs("button",{className:"nice-faq-question",onClick:()=>u(o.id),"aria-expanded":C,"aria-controls":`faq-answer-${o.id}`,children:[o.icon&&e.jsx("span",{className:"nice-faq-question-icon",children:o.icon}),e.jsx("span",{className:"nice-faq-question-text",children:e.jsx(gm,{text:o.question,indices:_})}),e.jsx("span",{className:`nice-faq-chevron ${C?"nice-faq-chevron--open":""}`,children:e.jsx(c.NiceIcon,{name:"chevron-down",size:16})})]}),e.jsx("div",{id:`faq-answer-${o.id}`,className:`nice-faq-answer ${a?"nice-faq-answer--animated":""}`,ref:f,style:{maxHeight:C?a?f.current?.scrollHeight??1e3:void 0:0},"aria-hidden":!C,children:e.jsxs("div",{className:"nice-faq-answer-content",children:[typeof o.answer=="string"?e.jsx("p",{children:o.answer}):o.answer,o.tags&&o.tags.length>0&&e.jsx("div",{className:"nice-faq-tags",children:o.tags.map(j=>e.jsx("span",{className:"nice-faq-tag",children:j},j))}),T.length>0&&e.jsxs("div",{className:"nice-faq-related",children:[e.jsx("span",{className:"nice-faq-related-label",children:r("faq.related","Related:")}),T.map(j=>e.jsx("button",{className:"nice-faq-related-link",onClick:w=>{w.stopPropagation(),u(j.id),document.querySelector(`[data-question-id="${j.id}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})},children:j.question},j.id))]}),n&&e.jsxs("div",{className:"nice-faq-feedback",children:[p===null?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-faq-feedback-label",children:r("faq.wasThisHelpful","Was this helpful?")}),e.jsxs("button",{className:"nice-faq-feedback-btn nice-faq-feedback-btn--yes",onClick:()=>S(!0),"aria-label":r("faq.yesThisWasHelpful","Yes, this was helpful"),children:[e.jsx(c.NiceIcon,{name:"check",size:14})," ",r("faq.yes","Yes")]}),e.jsxs("button",{className:"nice-faq-feedback-btn nice-faq-feedback-btn--no",onClick:()=>S(!1),"aria-label":r("faq.noThisWasNotHelpful","No, this was not helpful"),children:[e.jsx(c.NiceIcon,{name:"close",size:14})," ",r("faq.no","No")]})]}):e.jsx("span",{className:"nice-faq-feedback-thanks",children:p?r("faq.thanksForYourFeedback","Thanks for your feedback!"):""}),x&&e.jsxs("div",{className:"nice-faq-feedback-form",children:[e.jsx("textarea",{placeholder:r("faq.howCanWeImproveThis","How can we improve this answer?"),value:g,onChange:j=>v(j.target.value),className:"nice-faq-feedback-textarea",rows:3}),e.jsxs("div",{className:"nice-faq-feedback-actions",children:[e.jsx("button",{className:"nice-faq-feedback-submit",onClick:N,children:r("faq.submit","Submit")}),e.jsx("button",{className:"nice-faq-feedback-cancel",onClick:()=>{b(!1),y(null)},children:r("faq.cancel","Cancel")})]})]})]})]})})]})},Is=({category:t,results:n,showFeedback:i,showRelated:a,collapsible:r=!0})=>{const{t:o}=c.useNiceTranslation(),[l,d]=s.useState(!1),u=s.useId();return n.length===0?null:e.jsxs("div",{className:"nice-faq-group",children:[e.jsxs("div",{className:`nice-faq-group-header ${r?"nice-faq-group-header--collapsible":""}`,role:"presentation",onClick:r?()=>d(!l):void 0,style:t.color?{borderColor:t.color}:void 0,children:[t.icon&&e.jsx("span",{className:"nice-faq-group-icon",children:t.icon}),e.jsx("h3",{className:"nice-faq-group-title",children:t.name}),t.description&&e.jsx("p",{className:"nice-faq-group-desc",children:t.description}),e.jsx("span",{className:"nice-faq-group-count",children:n.length}),r&&e.jsx("button",{type:"button",className:`nice-faq-group-chevron ${l?"":"nice-faq-group-chevron--open"}`,"aria-expanded":!l,"aria-controls":l?void 0:u,"aria-label":`${l?o("faq.expandGroup","Expand"):o("faq.collapseGroup","Collapse")}: ${t.name}`,onClick:m=>{m.stopPropagation(),d(!l)},children:e.jsx(c.NiceIcon,{name:"chevron-down",size:16})})]}),!l&&e.jsx("div",{id:u,className:"nice-faq-group-items",children:n.map(m=>e.jsx(Qs,{result:m,showFeedback:i,showRelated:a},m.item.id))})]})},fm=({items:t=pm,categories:n=[],showSearch:i=!0,searchPlaceholder:a,autoFocusSearch:r=!1,showCategories:o=!0,categoryLayout:l="horizontal",groupByCategory:d=!0,allowMultiple:u=!0,defaultExpanded:m=[],showFeedback:h=!0,showRelated:p=!0,onFeedback:y,onAnalytics:x,showExpandControls:b=!0,animateExpand:g=!0,emptyMessage:v,generateSchema:f=!0,header:C,footer:_,size:T="md",className:S,style:N,testId:j,"data-testid":w})=>{const{t:k}=c.useNiceTranslation(),I=a??k("faq.searchFrequentlyAskedQuestions","Search frequently asked questions..."),M=v??k("faq.noQuestionsFoundMatchingYour","No questions found matching your search."),[z,R]=s.useState(new Set(m)),[A,E]=s.useState(""),[$,O]=s.useState(null),V=s.useMemo(()=>[...t].sort((se,G)=>se.featured&&!G.featured?-1:!se.featured&&G.featured?1:(se.order??999)-(G.order??999)),[t]),K=s.useMemo(()=>$?V.filter(se=>se.category===$):V,[V,$]),te=s.useMemo(()=>hm(K,A),[K,A]),B=s.useMemo(()=>{if(!d||n.length===0)return null;const se={},G=[];for(const ge of te){const Ce=ge.item.category;Ce?(se[Ce]||(se[Ce]=[]),se[Ce].push(ge)):G.push(ge)}return{groups:se,uncategorized:G}},[d,n,te]),W=s.useCallback(se=>{R(G=>{const ge=new Set(G);return ge.has(se)?(ge.delete(se),x?.({type:"collapse",questionId:se,timestamp:new Date().toISOString()})):(u||ge.clear(),ge.add(se),x?.({type:"expand",questionId:se,timestamp:new Date().toISOString()})),ge})},[u,x]),ne=s.useCallback(()=>{R(new Set(t.map(se=>se.id)))},[t]),ae=s.useCallback(()=>{R(new Set)},[]),Y=s.useCallback(se=>{E(se),se.trim()&&x?.({type:"search",searchQuery:se,timestamp:new Date().toISOString()})},[x]),F=s.useCallback((se,G,ge)=>{const Ce={questionId:se,helpful:G,comment:ge,timestamp:new Date().toISOString()};y?.(Ce),x?.({type:"feedback",questionId:se,timestamp:Ce.timestamp,metadata:{helpful:G,comment:ge}})},[y,x]),J=s.useMemo(()=>{if(!f)return null;const se={"@context":"https://schema.org","@type":"FAQPage",mainEntity:t.map(G=>({"@type":"Question",name:G.question,acceptedAnswer:{"@type":"Answer",text:typeof G.answer=="string"?G.answer:""}}))};return e.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(se)}})},[f,t]),re={items:V,categories:n,expandedIds:z,searchQuery:A,selectedCategory:$,toggleExpanded:W,expandAll:ne,collapseAll:ae,setSearchQuery:Y,setSelectedCategory:O,submitFeedback:F};return e.jsx(Hc.Provider,{value:re,children:e.jsxs("div",{className:`nice-faq nice-faq--${T} ${S||""}`,style:N,"data-testid":w??j,children:[J,C&&e.jsx("div",{className:"nice-faq-header",children:C}),e.jsxs("div",{className:"nice-faq-controls",children:[i&&e.jsx(Gc,{placeholder:I,autoFocus:r}),o&&n.length>0&&e.jsx(Wc,{layout:l,showCounts:!0}),b&&e.jsxs("div",{className:"nice-faq-expand-controls",children:[e.jsx("button",{className:"nice-faq-expand-btn",onClick:ne,children:k("faq.expandAll","Expand All")}),e.jsx("button",{className:"nice-faq-expand-btn",onClick:ae,children:k("faq.collapseAll","Collapse All")})]})]}),A&&e.jsx("div",{className:"nice-faq-results-info",children:(te.length===1?k("faq.foundOneResult",'Found 1 result for "{query}"'):k("faq.foundResults",'Found {count} results for "{query}"')).replace("{count}",String(te.length)).replace("{query}",A)}),e.jsx("div",{className:"nice-faq-list",children:te.length===0?e.jsx("div",{className:"nice-faq-empty",children:typeof M=="string"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-faq-empty-icon",children:e.jsx(c.NiceIcon,{name:"search",size:32})}),e.jsx("p",{children:M})]}):M}):B?e.jsxs(e.Fragment,{children:[n.sort((se,G)=>(se.order??999)-(G.order??999)).map(se=>e.jsx(Is,{category:se,results:B.groups[se.id]||[],showFeedback:h,showRelated:p},se.id)),B.uncategorized.length>0&&e.jsx(Is,{category:{id:"other",name:"Other Questions"},results:B.uncategorized,showFeedback:h,showRelated:p})]}):te.map(se=>e.jsx(Qs,{result:se,showFeedback:h,showRelated:p,animateExpand:g},se.item.id))}),_&&e.jsx("div",{className:"nice-faq-footer",children:_})]})})},bm=[];function ts(t,n){return n.split(".").reduce((i,a)=>{if(i&&typeof i=="object")return i[a]},t)}const xm=({status:t})=>{const{t:n}=c.useNiceTranslation(),a={connecting:{color:"var(--nice-color-warning, #f59e0b)",label:n("liveGrid.connecting","Connecting...")},connected:{color:"var(--nice-color-success, #22c55e)",label:n("liveGrid.live","Live")},disconnected:{color:"var(--nice-text-muted, #6b7280)",label:n("liveGrid.disconnected","Disconnected")},error:{color:"var(--nice-color-error, #ef4444)",label:n("error","Error")}}[t];return e.jsxs("div",{className:"nice-live-grid-status",children:[e.jsx("span",{className:"nice-live-grid-status-dot",style:{backgroundColor:a.color}}),e.jsx("span",{className:"nice-live-grid-status-label",children:a.label})]})};function vm({columns:t=bm,data:n=[],dataSource:i,rowKey:a="id",showConnectionStatus:r=!0,highlightDuration:o=2e3,updateAnimation:l="flash",maxRows:d,selectable:u=!1,selectedIds:m,onSelectionChange:h,onRowClick:p,onUpdate:y,onConnectionStatusChange:x,emptyContent:b,loadingContent:g,sortable:v=!1,sortField:f,sortDirection:C,onSortChange:_,virtualized:T=!1,rowHeight:S=40,height:N=400,className:j="",style:w,"data-testid":k},I){const{t:M}=c.useNiceTranslation(),[z,R]=s.useState(n),[A,E]=s.useState(!1),[$,O]=s.useState("disconnected"),[V,K]=s.useState(new Map),[te,B]=s.useState(m||new Set),W=s.useRef(null),ne=s.useRef(null),ae=s.useRef(new Map),Y=m??te,F=h??B,J=s.useCallback(D=>D[a],[a]),re=s.useCallback((D,ee,le=[])=>{K(de=>{const oe=new Map(de);return oe.set(D,{operation:ee,changedFields:new Set(le),timestamp:Date.now()}),oe});const ue=ae.current.get(D);ue&&clearTimeout(ue);const me=setTimeout(()=>{K(de=>{const oe=new Map(de);return oe.delete(D),oe}),ae.current.delete(D)},o);ae.current.set(D,me)},[o]),se=s.useCallback(D=>{const ee=J(D.row);if(R(le=>{switch(D.operation){case"insert":{if(le.some(de=>J(de)===ee))return le;const me=[D.row,...le];return d&&me.length>d?me.slice(0,d):me}case"update":return le.map(ue=>J(ue)===ee?{...ue,...D.row,...D.changes||{}}:ue);case"upsert":{if(le.some(de=>J(de)===ee))return le.map(de=>J(de)===ee?{...de,...D.row,...D.changes||{}}:de);const me=[D.row,...le];return d&&me.length>d?me.slice(0,d):me}case"delete":return le.filter(ue=>J(ue)!==ee);default:return le}}),l!=="none"){const le=D.changes?Object.keys(D.changes):[];re(ee,D.operation,le)}y?.(D)},[J,d,l,re,y]),G=s.useCallback(D=>{"updates"in D?D.fullRefresh?R(D.updates.map(ee=>ee.row)):D.updates.forEach(se):se(D)},[se]);s.useEffect(()=>{if(!i)return;i.fetchInitial&&(E(!0),i.fetchInitial().then(ee=>{R(ee),E(!1)})),ne.current=i.subscribe(G);let D;return i.onStatusChange?D=i.onStatusChange(ee=>{O(ee),x?.(ee)}):(O("connected"),x?.("connected")),()=>{ne.current?.(),D?.()}},[i,G,x]),s.useEffect(()=>{const D=ae.current;return()=>{D.forEach(ee=>clearTimeout(ee))}},[]),s.useImperativeHandle(I,()=>({getData:()=>z,addRow:D=>se({operation:"insert",row:D}),updateRow:(D,ee)=>{const le=z.find(ue=>J(ue)===D);le&&se({operation:"update",row:le,changes:ee})},deleteRow:D=>{const ee=z.find(le=>J(le)===D);ee&&se({operation:"delete",row:ee})},refresh:()=>{i?.fetchInitial&&(E(!0),i.fetchInitial().then(D=>{R(D),E(!1)}))},getConnectionStatus:()=>$}));const ge=s.useMemo(()=>!f||!C?z:[...z].sort((D,ee)=>{const le=ts(D,f),ue=ts(ee,f);if(le===ue)return 0;if(le==null)return 1;if(ue==null)return-1;const me=le<ue?-1:1;return C==="asc"?me:-me}),[z,f,C]),Ce=s.useCallback((D,ee)=>{if(u){const le=J(D),ue=new Set(Y);ue.has(le)?ue.delete(le):ue.add(le),F(ue)}p?.(D,ee)},[u,J,Y,F,p]),he=s.useCallback(D=>{if(!v)return;let ee="asc";f===D&&(ee=C==="asc"?"desc":"asc"),_?.(D,ee)},[v,f,C,_]),L=s.useCallback(D=>{const ee=J(D),le=V.get(ee),ue=Y.has(ee),me=["nice-live-grid-row"];return ue&&me.push("nice-live-grid-row--selected"),le&&(me.push(`nice-live-grid-row--${le.operation}`),me.push(`nice-live-grid-row--${l}`)),me.join(" ")},[J,V,Y,l]),H=s.useCallback((D,ee)=>{const le=J(D);return V.get(le)?.changedFields.has(ee)?"nice-live-grid-cell--changed":""},[J,V]);return A&&z.length===0?e.jsx("div",{className:`nice-live-grid nice-live-grid--loading ${j}`,style:w,"data-testid":k,children:g===void 0?M("loading","Loading…"):g}):e.jsxs("div",{ref:W,className:`nice-live-grid ${j}`,style:{...w,height:N},"data-testid":k,children:[r&&e.jsxs("div",{className:"nice-live-grid-header",children:[e.jsx(xm,{status:$}),e.jsx("span",{className:"nice-live-grid-count",children:M("liveGrid.rows","{count} rows").replace("{count}",String(z.length))})]}),e.jsx("div",{className:"nice-live-grid-table-wrapper",children:e.jsxs("table",{className:"nice-live-grid-table",children:[e.jsx("thead",{children:e.jsx("tr",{children:t.map(D=>e.jsxs("th",{className:`nice-live-grid-th ${v&&D.sortable!==!1?"nice-live-grid-th--sortable":""}`,style:{width:D.width,minWidth:D.minWidth,maxWidth:D.maxWidth,textAlign:D.align||"left"},onClick:()=>D.sortable!==!1&&he(String(D.field)),children:[D.headerRender?D.headerRender(D):D.header,f===String(D.field)&&e.jsx("span",{className:"nice-live-grid-sort-icon",children:e.jsx(c.NiceIcon,{name:C==="asc"?"sort-asc":"sort-desc",size:12})})]},String(D.field)))})}),e.jsx("tbody",{children:ge.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:t.length,className:"nice-live-grid-empty",children:b===void 0?M("noData","No data"):b})}):ge.map(D=>e.jsx("tr",{className:L(D),onClick:ee=>Ce(D,ee),style:{height:S},children:t.map(ee=>{const le=ts(D,String(ee.field));return e.jsx("td",{className:`nice-live-grid-td ${H(D,String(ee.field))}`,style:{textAlign:ee.align||"left"},children:ee.render?ee.render(le,D,ee):String(le??"")},String(ee.field))})},String(J(D))))})]})})]})}const ym=Object.assign(s.forwardRef(vm),{displayName:"NiceLiveDataGrid"}),Kc=s.createContext(null);function Yc(){return s.useContext(Kc)}const Nm=5;function _m(t,n,i,a){if(n.button!==0)return;const r=n.currentTarget,o=n.pointerId,l=n.clientX,d=n.clientY;let u=!1,m={x:l,y:d};try{r.setPointerCapture?.(o)}catch{}const h=g=>{if(g.pointerId===o){if(m={x:g.clientX,y:g.clientY},!u){if(Math.hypot(g.clientX-l,g.clientY-d)<Nm)return;u=!0}g.preventDefault(),t.setGhost({label:a,x:g.clientX,y:g.clientY}),t.emit({type:"move",payload:i,x:g.clientX,y:g.clientY})}},p=g=>{if(r.removeEventListener("pointermove",h),r.removeEventListener("pointerup",y),r.removeEventListener("pointercancel",x),r.removeEventListener("keydown",b),u){t.setGhost(null),t.emit({type:"end",payload:i,x:m.x,y:m.y,commit:g});const v=f=>{f.stopPropagation(),f.preventDefault()};r.addEventListener("click",v,{capture:!0,once:!0}),window.setTimeout(()=>r.removeEventListener("click",v,{capture:!0}),0)}},y=g=>{g.pointerId===o&&p(!0)},x=g=>{g.pointerId===o&&p(!1)},b=g=>{g.key==="Escape"&&u&&(g.preventDefault(),p(!1))};r.addEventListener("pointermove",h),r.addEventListener("pointerup",y),r.addEventListener("pointercancel",x),r.addEventListener("keydown",b)}const jm=({children:t})=>{const n=s.useRef(new Set),[i,a]=s.useState(null),r=s.useMemo(()=>({subscribe:o=>(n.current.add(o),()=>{n.current.delete(o)}),emit:o=>{n.current.forEach(l=>l(o))},setGhost:a}),[]);return e.jsxs(Kc.Provider,{value:r,children:[t,i&&e.jsx("div",{className:"nice-sortable-tree__ghost","aria-hidden":"true",style:{left:i.x,top:i.y},children:i.label})]})};function vi(t){return{key:t?.keyField??"id",children:t?.childrenField??"children"}}function fi(t,n){return String(t[n])}function bi(t,n){const i=t[n];return Array.isArray(i)?i:void 0}function no(t,n,i){return{...t,[n]:i}}function Zt(t,n,i){const a=vi(i),r=(o,l,d)=>{o.forEach((u,m)=>{const h={node:u,parent:l,parentId:l===null?null:fi(l,a.key),index:m,siblings:o,ancestors:d,depth:d.length};if(n(u,h)===!1)return;const p=bi(u,a.children);p?.length&&r(p,u,[...d,u])})};r(t,null,[])}function Et(t,n,i){const a=vi(i),r=(o,l,d)=>{for(let u=0;u<o.length;u++){const m=o[u];if(fi(m,a.key)===n)return{node:m,parent:l,parentId:l===null?null:fi(l,a.key),index:u,siblings:o,ancestors:d,depth:d.length};const h=bi(m,a.children);if(h?.length){const p=r(h,m,[...d,m]);if(p)return p}}};return r(t,null,[])}function Vn(t,n,i){return Et(t,n,i)?.node}function Xs(t,n,i,a){const r=vi(a);return!!Et(t,n,a)?.ancestors.some(l=>fi(l,r.key)===i)}function Ji(t,n){const i=vi(n),a=bi(t,i.children);return a?.length?1+Math.max(...a.map(r=>Ji(r,n))):1}function Zs(t,n,i,a){const r=vi(a);if(n===null)return i(t);let o=!1;const l=d=>{let u=null;for(let m=0;m<d.length&&!o;m++){const h=d[m];let p=null;if(fi(h,r.key)===n)p=no(h,r.children,i(bi(h,r.children)??[])),o=!0;else{const y=bi(h,r.children),x=y?.length?l(y):null;x&&(p=no(h,r.children,x))}p&&(u=u??[...d],u[m]=p)}return u};return l(t)??[...t]}function In(t,n,i,a){return i.parentId!==null&&!Vn(t,i.parentId,a)?t:Zs(t,i.parentId,r=>{const o=[...r];return o.splice(Math.max(0,Math.min(i.index,o.length)),0,n),o},a)}function Wn(t,n,i){const a=Et(t,n,i);return a?Zs(t,a.parentId,r=>r.filter((o,l)=>l!==a.index),i):t}function Zi(t,n,i,a){const r=Et(t,n,a);if(!r)return t;const o=typeof i=="function"?i(r.node):{...r.node,...i};return Zs(t,r.parentId,l=>l.map((d,u)=>u===r.index?o:d),a)}function yi(t,n,i,a){const r=Et(t,n,a);if(!r||i.parentId!==null&&(i.parentId===n||Xs(t,i.parentId,n,a)||!Vn(t,i.parentId,a)))return t;let o=i.index;if(r.parentId===i.parentId&&(o>r.index&&(o-=1),o=Math.max(0,Math.min(o,r.siblings.length-1)),o===r.index))return t;const l=Wn(t,n,a);return In(l,r.node,{parentId:i.parentId,index:o},a)}function Ra(t,n,i,a){const r=Et(t,n,a);if(!r)return t;const o=Math.max(0,Math.min(r.index+i,r.siblings.length-1));return o===r.index?t:yi(t,n,{parentId:r.parentId,index:o>r.index?o+1:o},a)}function er(t,n,i){const a=vi(i),r=Et(t,n,i);if(!r||r.index===0)return t;const o=r.siblings[r.index-1];return yi(t,n,{parentId:fi(o,a.key),index:bi(o,a.children)?.length??0},i)}function tr(t,n,i){const a=Et(t,n,i);if(!a||a.parentId===null)return t;const r=Et(t,a.parentId,i);return r?yi(t,n,{parentId:r.parentId,index:r.index+1},i):t}const wm=[],km=["moveUp","moveDown","indent","outdent","rename","remove"],Cm=5,io=28,Sm=600,Tm=16,Em=10;function Im(t){const{value:n,defaultValue:i,onChange:a,keyField:r="id",childrenField:o="children",labelField:l="label",getLabel:d,renderLabel:u,getIcon:m,renderRowEnd:h,selectedId:p,defaultSelectedId:y,onSelect:x,collapsedIds:b,defaultCollapsedIds:g,onCollapsedChange:v,canHaveChildren:f,canDrag:C,canDrop:_,maxDepth:T,editable:S=!1,removable:N=!1,actions:j=!0,contextMenuItems:w,onExternalDrop:k,emptyText:I,"aria-label":M,height:z,size:R="md",readOnly:A=!1,disabled:E=!1,className:$,style:O,id:V,title:K,accessMode:te,"data-testid":B}=t,{t:W}=c.useNiceTranslation(),ne=c.useNiceAccessMode(te,V),ae=E||ne==="disabled",Y=A||ne==="readOnly"||ae,F=s.useMemo(()=>({keyField:r,childrenField:o}),[r,o]),[J,re]=c.useControllableState({value:n,defaultValue:i,fallbackValue:[],componentName:"NiceSortableTree"}),[se,G]=c.useControllableState({value:p,defaultValue:y,fallbackValue:null,componentName:"NiceSortableTree"}),[ge,Ce]=c.useControllableState({value:b,defaultValue:g,fallbackValue:wm,componentName:"NiceSortableTree"}),he=s.useCallback(ce=>String(ce[r]),[r]),L=s.useCallback(ce=>{const Ie=ce[o];return Array.isArray(Ie)?Ie:[]},[o]),H=s.useCallback(ce=>{if(d)return d(ce);const Ie=ce[l];return Ie==null?he(ce):String(Ie)},[d,l,he]),D=(ce,Ie)=>!Y&&(typeof ce=="function"?ce(Ie):ce),ee=s.useCallback(ce=>f?f(ce):!0,[f]),le=s.useMemo(()=>new Set(ge),[ge]),ue=s.useMemo(()=>{const ce=[];return Zt(J,(Ie,Ve)=>{const Ke=he(Ie),nt=L(Ie).length>0,gt=nt&&!le.has(Ke);return ce.push({node:Ie,id:Ke,depth:Ve.depth,parentId:Ve.parentId,index:Ve.index,setSize:Ve.siblings.length,hasChildren:nt,expanded:gt}),gt?void 0:!1},F),ce},[J,le,he,L,F]),me=s.useMemo(()=>new Map(ue.map(ce=>[ce.id,ce])),[ue]),de=s.useRef(null),oe=s.useRef(null),[ie,Te]=s.useState(""),X=s.useRef(null),je=s.useCallback(ce=>{Ce(ce),v?.(ce)},[Ce,v]),Z=s.useCallback((ce,Ie)=>{const Ve=ge.includes(ce);Ie&&Ve?je(ge.filter(Ke=>Ke!==ce)):!Ie&&!Ve&&je([...ge,ce])},[ge,je]),ve=s.useCallback(ce=>{G(ce),x?.(ce,ce===null?null:Vn(J,ce,F)??null)},[G,x,J,F]);c.useTreeFocus(oe,{onToggle:(ce,Ie)=>{const Ve=ce.dataset.nodeId;Ve!==void 0&&Z(Ve,Ie)}});const U=ce=>{const Ie=Et(J,ce,F);return Ie?{parentId:Ie.parentId,index:Ie.index}:null},ye=(ce,Ie)=>{const Ve=Et(ce,Ie,F);if(!Ve)return;const Ke=Ve.parent?H(Ve.parent):W("sortableTree.root","top level");Te(W("sortableTree.announceMoved","{label} moved to {parent}, position {position} of {count}").replace("{label}",H(Ve.node)).replace("{parent}",Ke).replace("{position}",String(Ve.index+1)).replace("{count}",String(Ve.siblings.length)))},Ne=(ce,Ie)=>ce===J?!1:(re(ce),a?.(ce,Ie),!0),ze=(ce,Ie,Ve,Ke)=>{let nt=0;if(Ie.parentId!==null){if(ce!==null&&(Ie.parentId===ce||Xs(J,Ie.parentId,ce,F)))return!1;const gt=Et(J,Ie.parentId,F);if(!gt||!ee(gt.node))return!1;nt=gt.depth+1}return T!==void 0&&nt+Ve>T?!1:_?_(ce,Ie,Ke):!0},P=(ce,Ie,Ve,Ke)=>{const nt=U(ce);if(!nt)return;const gt=Vn(J,ce,F);if(!gt||!ze(ce,Ie,Ji(gt,F)))return;const tt=Et(Ke,ce,F),vt=tt?{parentId:tt.parentId,index:tt.index}:Ie;Ne(Ke,{type:Ve,id:ce,from:nt,to:vt})&&(X.current=ce,vt.parentId!==null&&Z(vt.parentId,!0),ye(Ke,ce))},q=(ce,Ie)=>{const Ve=Ra(J,ce,Ie,F),Ke=Et(Ve,ce,F);Ke&&P(ce,{parentId:Ke.parentId,index:Ke.index},"move",Ve)},Q=ce=>{const Ie=er(J,ce,F),Ve=Et(Ie,ce,F);Ve&&Ie!==J&&P(ce,{parentId:Ve.parentId,index:Ve.index},"indent",Ie)},be=ce=>{const Ie=tr(J,ce,F),Ve=Et(Ie,ce,F);Ve&&Ie!==J&&P(ce,{parentId:Ve.parentId,index:Ve.index},"outdent",Ie)},Re=ce=>{const Ie=U(ce);if(!Ie)return;const Ve=ue.findIndex(ft=>ft.id===ce),Ke=new Set,nt=Vn(J,ce,F);nt&&Zt([nt],ft=>{Ke.add(he(ft))},F);const gt=ue.slice(Ve+1).find(ft=>!Ke.has(ft.id)),tt=ue.slice(0,Math.max(0,Ve)).reverse().find(ft=>!Ke.has(ft.id)),vt=gt?.id??tt?.id??null;Ne(Wn(J,ce,F),{type:"remove",id:ce,from:Ie})&&(se!==null&&Ke.has(se)&&ve(vt),X.current=vt,Te(W("sortableTree.announceRemoved","{label} removed").replace("{label}",nt?H(nt):ce)))},[Se,_e]=s.useState(null),Fe=s.useRef(null);s.useEffect(()=>{Se!==null&&(Fe.current?.focus(),Fe.current?.select())},[Se]);const qe=(ce,Ie)=>{_e(null),X.current=ce;const Ve=Vn(J,ce,F),Ke=Ie?.trim();!Ve||!Ke||Ke===H(Ve)||Ne(Zi(J,ce,{[l]:Ke},F),{type:"rename",id:ce,label:Ke})};s.useLayoutEffect(()=>{const ce=X.current;if(ce===null||Se!==null)return;X.current=null;const Ie=[...oe.current?.querySelectorAll("[data-node-id]")??[]].find(Ve=>Ve.dataset.nodeId===ce);Ie&&(Ie.focus(),Ie.scrollIntoView?.({block:"nearest"}))});const et=(ce,Ie)=>{const Ve=oe.current;if(!Ve)return null;const Ke=[...Ve.querySelectorAll("[data-node-id]")];if(Ke.length===0)return{target:{parentId:null,index:0},line:null,insideId:null,invalid:!1};const nt=Ke[0],gt=Ke[Ke.length-1],tt=(vt,ft,bt)=>({top:ft==="top"?vt.offsetTop:vt.offsetTop+vt.offsetHeight,depth:bt});if(ce<nt.getBoundingClientRect().top){const vt=me.get(nt.dataset.nodeId??"");return vt&&!Ie.has(vt.id)?{target:{parentId:null,index:0},line:tt(nt,"top",0),insideId:null,invalid:!1}:null}for(const vt of Ke){const ft=vt.getBoundingClientRect();if(ce<ft.top||ce>=ft.bottom)continue;const bt=me.get(vt.dataset.nodeId??"");if(!bt||Ie.has(bt.id))return null;const qt=(ce-ft.top)/Math.max(1,ft.height),on=ee(bt.node)?qt<.25?"before":qt>.75?"after":"inside":qt<.5?"before":"after";return on==="before"?{target:{parentId:bt.parentId,index:bt.index},line:tt(vt,"top",bt.depth),insideId:null,invalid:!1}:on==="inside"?{target:{parentId:bt.id,index:L(bt.node).length},line:null,insideId:bt.id,invalid:!1}:bt.expanded?{target:{parentId:bt.id,index:0},line:tt(vt,"bottom",bt.depth+1),insideId:null,invalid:!1}:{target:{parentId:bt.parentId,index:bt.index+1},line:tt(vt,"bottom",bt.depth),insideId:null,invalid:!1}}return{target:{parentId:null,index:J.length},line:tt(gt,"bottom",0),insideId:null,invalid:!1}},dt=s.useRef(null),[rt,jt]=s.useState(null),[ht,at]=s.useState(null),_t=s.useRef(!1),It=ce=>{clearTimeout(ce.hoverTimer),ce.hoverTimer=void 0,ce.hoverId=null},we=(ce,Ie)=>{const Ve=Ie?.insideId??null;if(Ve===ce.hoverId)return;It(ce);const Ke=Ve?me.get(Ve):void 0;Ke&&Ke.hasChildren&&!Ke.expanded&&(ce.hoverId=Ve,ce.hoverTimer=setTimeout(()=>Z(Ke.id,!0),Sm))},Ae=ce=>{const Ie=de.current;if(!Ie||Ie.scrollHeight<=Ie.clientHeight)return;const Ve=Ie.getBoundingClientRect();ce<Ve.top+io?Ie.scrollTop-=10:ce>Ve.bottom-io&&(Ie.scrollTop+=10)},Ue=(ce,Ie)=>{const Ve=!!ce.target.closest(".nice-sortable-tree__grip");if(Y||ce.button!==0||Se!==null||ce.pointerType==="touch"&&!Ve||ce.target.closest(".nice-sortable-tree__toggle, input, button")||C&&!C(Ie.node))return;const Ke=new Set;Zt([Ie.node],nt=>{Ke.add(he(nt))},F),dt.current={id:Ie.id,pointerId:ce.pointerId,startY:ce.clientY,startX:ce.clientX,startScroll:de.current?.scrollTop??0,rowTop:ce.currentTarget.getBoundingClientRect().top,started:!1,height:Ji(Ie.node,F),block:Ke,view:null,hoverId:null,hoverTimer:void 0}},ut=ce=>{const Ie=dt.current;if(!Ie||ce.pointerId!==Ie.pointerId)return;const Ve=(de.current?.scrollTop??0)-Ie.startScroll,Ke=ce.clientY+Em-Ie.rowTop+Ve;if(!Ie.started){if(Math.hypot(ce.clientX-Ie.startX,ce.clientY-Ie.startY)<Cm)return;Ie.started=!0,ce.currentTarget.setPointerCapture?.(ce.pointerId),ce.currentTarget.focus()}Ae(ce.clientY);const nt=et(ce.clientY,Ie.block),gt=nt?{...nt,invalid:!ze(Ie.id,nt.target,Ie.height)}:null;Ie.view=gt,we(Ie,gt),jt({ids:Ie.block,dy:Ke}),at(gt)},We=ce=>{const Ie=dt.current;if(dt.current=null,!!Ie){if(It(Ie),Ie.started){if(ce&&Ie.view&&!Ie.view.invalid){const Ve=yi(J,Ie.id,Ie.view.target,F),Ke=Et(Ve,Ie.id,F);Ke&&Ve!==J&&P(Ie.id,{parentId:Ke.parentId,index:Ke.index},"move",Ve)}_t.current=!0,window.setTimeout(()=>{_t.current=!1},0)}jt(null),at(null)}},ot=Yc(),fe=s.useRef({view:null,hoverId:null,hoverTimer:void 0}),$e=s.useRef(()=>{});$e.current=ce=>{const Ie=fe.current,Ve=de.current?.getBoundingClientRect(),Ke=!!Ve&&ce.x>=Ve.left&&ce.x<=Ve.right&&ce.y>=Ve.top&&ce.y<=Ve.bottom;if(ce.type==="move"){if(!Ke||Y||!k){Ie.view&&(Ie.view=null,It(Ie),at(null));return}Ae(ce.y);const gt=et(ce.y,new Set),tt=gt?{...gt,invalid:!ze(null,gt.target,1,ce.payload)}:null;Ie.view=tt,we(Ie,tt),at(tt);return}const nt=Ie.view;Ie.view=null,It(Ie),at(null),ce.commit&&Ke&&nt&&!nt.invalid&&k?.(ce.payload,nt.target)},s.useEffect(()=>ot?.subscribe(ce=>$e.current(ce)),[ot]);const[Je,pe]=s.useState(null),Ee=s.useRef(null);c.useOverlayFocus(Ee,{open:Je!==null,modal:!1,onClose:()=>pe(null)}),c.useRovingFocus(Ee,{orientation:"vertical",wrap:!0,enabled:Je!==null}),s.useLayoutEffect(()=>{const ce=Ee.current;if(!Je||!ce||typeof window>"u")return;const Ie=ce.getBoundingClientRect(),Ve=Math.max(8,Math.min(Je.x,window.innerWidth-Ie.width-8)),Ke=Math.max(8,Math.min(Je.y,window.innerHeight-Ie.height-8));(Ve!==Je.x||Ke!==Je.y)&&pe({...Je,x:Ve,y:Ke})},[Je]),s.useEffect(()=>{if(!Je)return;const ce=Ie=>{Ee.current?.contains(Ie.target)||pe(null)};return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[Je]);const Me=j===!0?km:j===!1?[]:j,He=Je?me.get(Je.id):void 0,ct=[];if(He){const ce=He.node,Ie=!Y&&(!C||C(ce)),Ve=He.index>0,Ke=(nt,gt,tt,vt,ft)=>{Me.includes(nt)&&ct.push({id:nt,label:gt,icon:e.jsx(c.NiceIcon,{name:tt,size:14}),disabled:!vt,onClick:ft})};Ke("moveUp",W("sortableTree.moveUp","Move up"),"chevron-up",Ie&&Ve,()=>q(He.id,-1)),Ke("moveDown",W("sortableTree.moveDown","Move down"),"chevron-down",Ie&&He.index<He.setSize-1,()=>q(He.id,1)),Ke("indent",W("sortableTree.indent","Indent"),"indent",Ie&&Ve,()=>Q(He.id)),Ke("outdent",W("sortableTree.outdent","Outdent"),"outdent",Ie&&He.parentId!==null,()=>be(He.id)),Ke("rename",W("sortableTree.rename","Rename"),"edit",D(S,ce),()=>_e(He.id)),Ke("remove",W("sortableTree.remove","Remove"),"trash",D(N,ce),()=>Re(He.id)),ct.push(...w?.(ce)??[])}const zt=(ce,Ie)=>{if(ce.target!==ce.currentTarget)return;if(ce.key==="Escape"&&dt.current?.started){ce.preventDefault(),We(!1);return}if(!Y&&(!C||C(Ie.node))&&ce.ctrlKey&&ce.shiftKey&&!ce.altKey){const Ke=typeof window<"u"&&de.current!==null&&window.getComputedStyle(de.current).direction==="rtl",nt=Ke&&ce.key==="ArrowLeft"?"ArrowRight":Ke&&ce.key==="ArrowRight"?"ArrowLeft":ce.key,gt={ArrowUp:()=>q(Ie.id,-1),ArrowDown:()=>q(Ie.id,1),ArrowRight:()=>Q(Ie.id),ArrowLeft:()=>be(Ie.id)};if(gt[nt]){ce.preventDefault(),gt[nt]();return}}ce.key==="F2"&&D(S,Ie.node)?(ce.preventDefault(),_e(Ie.id)):ce.key==="Delete"&&D(N,Ie.node)&&(ce.preventDefault(),Re(Ie.id))};if(ne==="hidden")return null;const Dt=rt?.ids;return e.jsxs("div",{ref:de,id:V,title:K,"data-testid":B,className:["nice-sortable-tree",`nice-sortable-tree--${R}`,rt?"nice-sortable-tree--dragging":"",ht&&ue.length===0&&!ht.invalid?"nice-sortable-tree--drop-empty":"",ae?"nice-sortable-tree--disabled":"",$??""].filter(Boolean).join(" "),style:{...z!==void 0?{height:z,overflow:"auto"}:{},...O},"aria-disabled":ae||void 0,children:[ue.length===0&&e.jsx("div",{className:"nice-sortable-tree__empty",children:I??W("sortableTree.empty","Nothing here yet")}),e.jsxs("ul",{ref:oe,role:"tree","aria-label":M,"aria-disabled":ae||void 0,className:"nice-sortable-tree__list",children:[ue.map(ce=>{const Ie=ce.id===se,Ve=!!Dt?.has(ce.id),Ke={depth:ce.depth,hasChildren:ce.hasChildren,expanded:ce.expanded,selected:Ie,dragging:Ve},nt=Se===ce.id,gt={"--nice-sortable-tree-depth":ce.depth,...Ve&&rt?{transform:`translate(${Tm}px, ${rt.dy}px)`}:{}};return e.jsxs("li",{role:"treeitem","data-node-id":ce.id,"aria-level":ce.depth+1,"aria-setsize":ce.setSize,"aria-posinset":ce.index+1,"aria-expanded":ce.hasChildren?ce.expanded:void 0,"aria-selected":Ie,"aria-label":H(ce.node),tabIndex:-1,className:["nice-sortable-tree__row",Ie?"nice-sortable-tree__row--selected":"",Ve?"nice-sortable-tree__row--dragging":"",ht?.insideId===ce.id?ht.invalid?"nice-sortable-tree__row--drop-invalid":"nice-sortable-tree__row--drop-inside":""].filter(Boolean).join(" "),style:gt,onClick:tt=>{if(_t.current){_t.current=!1;return}if(!ae){if(ce.hasChildren&&tt.target.closest(".nice-sortable-tree__toggle")){Z(ce.id,!ce.expanded);return}ve(ce.id)}},onDoubleClick:()=>{D(S,ce.node)&&_e(ce.id)},onKeyDown:tt=>zt(tt,ce),onPointerDown:tt=>Ue(tt,ce),onPointerMove:ut,onPointerUp:()=>We(!0),onPointerCancel:()=>We(!1),onContextMenu:tt=>{if(ae||Me.length===0&&!w)return;tt.preventDefault(),tt.stopPropagation();const vt=tt.currentTarget.getBoundingClientRect(),ft=tt.clientX===0&&tt.clientY===0;pe({id:ce.id,x:ft?vt.left+24:tt.clientX,y:ft?vt.bottom:tt.clientY})},children:[!Y&&(!C||C(ce.node))&&e.jsx("span",{className:"nice-sortable-tree__grip","aria-hidden":"true",children:e.jsx(c.NiceIcon,{name:"grip",size:14})}),ce.hasChildren?e.jsx("span",{className:"nice-sortable-tree__toggle","aria-hidden":"true",children:e.jsx(c.NiceIcon,{name:ce.expanded?"chevron-down":"chevron-right",size:14})}):e.jsx("span",{className:"nice-sortable-tree__toggle nice-sortable-tree__toggle--leaf","aria-hidden":"true"}),m&&e.jsx("span",{className:"nice-sortable-tree__icon","aria-hidden":"true",children:m(ce.node,Ke)}),nt?e.jsx("input",{ref:Fe,className:"nice-sortable-tree__input","aria-label":W("sortableTree.renameField","New name"),defaultValue:H(ce.node),onClick:tt=>tt.stopPropagation(),onPointerDown:tt=>tt.stopPropagation(),onKeyDown:tt=>{tt.stopPropagation(),tt.key==="Enter"?(tt.preventDefault(),qe(ce.id,tt.currentTarget.value)):tt.key==="Escape"&&(tt.preventDefault(),qe(ce.id,null))},onBlur:tt=>{Se===ce.id&&qe(ce.id,tt.currentTarget.value)}}):e.jsx("span",{className:"nice-sortable-tree__label",children:u?u(ce.node,Ke):H(ce.node)}),h&&e.jsx("span",{className:"nice-sortable-tree__end",children:h(ce.node,Ke)})]},ce.id)}),ht?.line&&e.jsx("li",{role:"none",className:`nice-sortable-tree__drop-line${ht.invalid?" nice-sortable-tree__drop-line--invalid":""}`,style:{top:ht.line.top,"--nice-sortable-tree-depth":ht.line.depth}})]}),e.jsx("div",{className:"nice-sr-only","aria-live":"polite",role:"status",children:ie}),Je&&ct.length>0&&e.jsx("ul",{ref:Ee,role:"menu","aria-label":W("sortableTree.menu","Node actions"),className:"nice-contextmenu nice-contextmenu__list nice-sortable-tree__menu",style:{position:"fixed",left:Je.x,top:Je.y},children:ct.map((ce,Ie)=>e.jsx("li",{role:"none",className:"nice-contextmenu__item",children:e.jsxs("button",{type:"button",role:"menuitem",className:`nice-contextmenu__btn${ce.danger?" nice-contextmenu__btn--danger":""}`,disabled:ce.disabled,onClick:Ve=>{pe(null),ce.onClick?.(Ve)},children:[ce.icon&&e.jsx("span",{className:"nice-contextmenu__icon","aria-hidden":"true",children:ce.icon}),e.jsx("span",{children:ce.label??ce.text})]})},ce.id??ce.key??Ie))})]})}const Jc=Object.assign(Im,{displayName:"NiceSortableTree"}),ao=new WeakMap;function xn(t){const n=ao.get(t);if(n)return n;const i=new Map;return Zt(t,(a,r)=>{i.set(a.id,{node:a,ancestors:[...r.ancestors],order:i.size})}),ao.set(t,i),i}function Qc(t,n){return xn(t).get(n)?.node}function Dm(t,n){const i=xn(t),a=new Set;for(const r of n){const o=i.get(r);o&&Zt([o.node],l=>{l.route&&!l.disabled&&a.add(l.id)})}return[...a].sort((r,o)=>(i.get(r)?.order??0)-(i.get(o)?.order??0))}function pi(t,n){let i;return Zt(t,a=>{if(i)return!1;n(a)&&(i=a)}),i}function nr(t){const n=new Set;return Zt(t,i=>{n.add(i.id)}),n}function mi(t,n){let i=n;for(let a=2;t.has(i);a++)i=`${n}-${a}`;return t.add(i),i}function ir(t){const n=[];return Zt(t,i=>{i.ref&&n.push(i.ref)}),n}function Xc(t,n){const i=xn(n),a=[];return Zt(t,r=>{r.ref&&!i.get(r.ref)?.node.route&&a.push(r.id)}),a}function ar(t,n){if(t.label)return t.label;const i=xn(n);return(t.ref?i.get(t.ref)?.node.label:void 0)??(t.from?i.get(t.from)?.node.label:void 0)??t.ref??t.from??t.id}function $a(t,n){const i=xn(n);return(t.ref?i.get(t.ref):void 0)?.node??(t.from?i.get(t.from):void 0)?.node}function Zc(t,n){return xn(t).get(n)?.ancestors.map(i=>i.label)??[]}function so(t,n,i){let a=null,r=t;for(const o of n){const l=pi(r,m=>m.from===o.id);if(l){a=l.id;continue}const d={id:mi(i,`g:${o.id}`),from:o.id,children:[]},u=a===null?r:Et(r,a)?.node.children??[];r=In(r,d,{parentId:a,index:u.length}),a=d.id}return{menu:r,parentId:a}}function el(t,n,i,a={}){const r=xn(n),o=Math.max(0,a.skipLevels??0),l=new Set(ir(t)),d=nr(t);let u=t;const m=[...new Set(i)].filter(h=>r.get(h)?.node.route&&!r.get(h)?.node.disabled).sort((h,p)=>(r.get(h)?.order??0)-(r.get(p)?.order??0));for(const h of m){const p=r.get(h);if(!p||l.has(h))continue;l.add(h);const y=p.ancestors.slice(o);if(p.node.children?.length){const g=so(u,[...y,p.node],d);u=g.menu,g.parentId!==null&&(u=Zi(u,g.parentId,{ref:h}));continue}const x=so(u,y,d);u=x.menu;const b=x.parentId===null?u:Et(u,x.parentId)?.node.children??[];u=In(u,{id:mi(d,`p:${h}`),ref:h},{parentId:x.parentId,index:b.length})}return u}function tl(t){let n=t;for(;;){const i=pi(n,a=>!!a.from&&!a.ref&&!a.children?.length);if(!i)return n;n=Wn(n,i.id)}}function nl(t,n){const i=new Set(n);let a=t;for(const r of i){const o=pi(a,l=>l.ref===r);o&&(o.children?.length?a=Zi(a,o.id,l=>{const{ref:d,...u}=l;return{...u,from:u.from??r}}):a=Wn(a,o.id))}return a===t?a:tl(a)}function il(t,n,i,a,r={}){const o=xn(n),l=nr(t);let d=t,u=a.index;const m=h=>{const p=(h.children??[]).map(m).filter(b=>b!==null),y=!!h.route&&!h.disabled,x=y?pi(d,b=>b.ref===h.id):void 0;return x&&(d=Wn(d,x.id),l.delete(x.id)),h.children?.length?!p.length&&!y?null:{id:mi(l,`g:${h.id}`),from:h.id,...y?{ref:h.id}:{},children:p}:y?{id:mi(l,`p:${h.id}`),ref:h.id}:null};for(const h of i){const p=o.get(h);if(!p)continue;const y=!!p.node.route&&!p.node.disabled,x=!p.node.children?.length||r.asPage,b=y?pi(d,v=>v.ref===h):void 0;if(x){if(b)d=yi(d,b.id,{parentId:a.parentId,index:u});else if(y)d=In(d,{id:mi(l,`p:${h}`),ref:h},{parentId:a.parentId,index:u});else continue;const v=pi(d,f=>f.ref===h);u=(v?Et(d,v.id)?.index??u:u)+1;continue}const g=m(p.node);g&&(a.parentId!==null&&!Et(d,a.parentId)?d=In(d,g,{parentId:null,index:d.length}):(d=In(d,g,{parentId:a.parentId,index:u}),u+=1))}return tl(d)}function al(t,n,i){const a=nr(t),r=mi(a,"group");return{menu:In(t,{id:r,label:n,children:[]},i??{parentId:null,index:t.length}),id:r}}function Pm(t,n,i){if(t.icon)return i?i(t.icon):void 0;const a=n?.icon;return typeof a=="string"?i?i(a):void 0:a}function sl(t,n,i={}){const a=xn(n),r=o=>o.flatMap(l=>{const u=(l.ref?a.get(l.ref)?.node:void 0)?.route,m=r(l.children??[]);return!u&&m.length===0?[]:[{id:l.id,label:ar(l,n),icon:Pm(l,$a(l,n),i.renderIcon),...u?{route:u}:{},...m.length?{children:m}:{}}]});return r(t)}function rl(t,n,i={}){const a=sl(t,n,i),r=[];let o=[];const l=()=>{o.length&&(r.push({id:`${o[0].id}:other`,label:i.otherLabel??"Other",views:o}),o=[])};for(const d of a){if(!d.children?.length){o.push(d);continue}l();const u=d.route?[{id:`${d.id}:page`,label:d.label,icon:d.icon,route:d.route}]:[];r.push({id:d.id,label:d.label,icon:d.icon,views:[...u,...d.children]})}return l(),[{source:i.source??{id:"menu",label:i.otherLabel??"Menu"},modules:r,roles:[],units:[]}]}function Am(t,n={}){const i=n.key??"id",a=(d,u)=>typeof i=="function"?i(d,u):i==="route"?d.route??d.id:d.id,r=(d,u)=>d.map(m=>({id:a(m,u),label:m.label,icon:m.icon,...m.route?{route:m.route}:{},...m.children?.length?{children:r(m.children,u)}:{}})),o=d=>d.modules.map(u=>({id:u.id,label:u.label,icon:u.icon,children:r(u.views,u)}));return n.includeSources??t.length>1?t.map(d=>({id:d.source.id,label:d.source.label,icon:d.source.icon,children:o(d)})):t.flatMap(o)}const Rm=[],$m=[],Mm={},Om=60,zm=t=>e.jsx(c.NiceIcon,{name:t,size:16});function ol(t){return t.map(n=>{const i=n.children?.length?ol(n.children):void 0,a=!!i?.some(r=>r.placeable);return n.route&&i?{key:`${n.id}::branch`,nodeId:n.id,label:n.label,icon:n.icon,placeable:!0,disabled:n.disabled,children:[{key:n.id,nodeId:n.id,label:n.label,icon:n.icon,route:n.route,own:!0,placeable:!0,disabled:n.disabled},...i]}:{key:n.id,nodeId:n.id,label:n.label,icon:n.icon,route:n.route,placeable:!!n.route||a,disabled:n.disabled,children:i}})}function cl(t,n){return n<=0?[]:t.flatMap(i=>i.children?.length?[i.key,...cl(i.children,n-1)]:[])}const Lm=({drag:t,label:n,title:i})=>{const a=Yc();return e.jsx("span",{className:"nice-menu-builder__grip",title:i,"aria-hidden":"true",onPointerDown:r=>{a&&(r.stopPropagation(),_m(a,r,t,n))},children:e.jsx(c.NiceIcon,{name:"grip",size:14})})},Bm=({value:t,onChange:n,renderIcon:i})=>{const{t:a}=c.useNiceTranslation(),[r,o]=s.useState(""),l=s.useRef(null);c.useRovingFocus(l,{orientation:"grid",itemSelector:"button"});const d=s.useMemo(()=>{const u=r.trim().toLowerCase(),m=u?c.NICE_BUILTIN_ICONS.filter(p=>p.includes(u)):c.NICE_BUILTIN_ICONS,h=m.slice(0,Om);return t&&m.includes(t)&&!h.includes(t)?[t,...h]:h},[r,t]);return e.jsxs("div",{className:"nice-menu-builder__icon-picker",children:[e.jsx(Ye.NiceTextInput,{type:"search",size:"sm",label:a("menuBuilder.iconSearch","Search icons"),value:r,onChange:o}),e.jsxs("div",{ref:l,role:"group","aria-label":a("menuBuilder.icons","Icons"),className:"nice-menu-builder__icon-grid",children:[d.map(u=>e.jsx("button",{type:"button",title:u,"aria-label":u,"aria-pressed":u===t,className:`nice-menu-builder__icon-option${u===t?" nice-menu-builder__icon-option--on":""}`,onClick:()=>n(u),children:i(u)},u)),d.length===0&&e.jsx("span",{className:"nice-menu-builder__hint",children:a("menuBuilder.noIcons","No icons found")})]})]})},Fm=({catalog:t=Rm,value:n,defaultValue:i,onChange:a,skipLevels:r=0,maxDepth:o,renderIcon:l=zm,renderIconPicker:d,showPreview:u=!0,previewProps:m,toolbar:h,height:p,size:y="md",readOnly:x=!1,disabled:b=!1,className:g,style:v,id:f,title:C,accessMode:_,"data-testid":T})=>{const{t:S}=c.useNiceTranslation(),N=c.useNiceAccessMode(_,f),j=b||N==="disabled",w=x||N==="readOnly"||j,[k,I]=c.useControllableState({value:n,defaultValue:i,fallbackValue:$m,componentName:"NiceMenuBuilder"}),M=oe=>{oe===k||w||(I(oe),a?.(oe))},[z,R]=s.useState(null),A=s.useRef(null),[E,$]=s.useState(0);s.useEffect(()=>{E>0&&A.current?.querySelector("input")?.focus()},[E]);const O=s.useMemo(()=>ol(t),[t]),V=s.useMemo(()=>ir(k),[k]),K=s.useMemo(()=>new Set(Xc(k,t)),[k,t]),te=s.useMemo(()=>cl(O,2),[O]),B=oe=>{const ie=new Set(oe),Te=new Set(V),X=oe.filter(ve=>!Te.has(ve)),je=V.filter(ve=>!ie.has(ve));let Z=k;X.length&&(Z=el(Z,t,X,{skipLevels:r})),je.length&&(Z=nl(Z,je)),M(Z)},W=s.useMemo(()=>[{field:"label",header:S("menuBuilder.catalogColumn","View"),render:(oe,ie)=>e.jsxs("span",{className:"nice-menu-builder__catalog-cell",children:[!w&&!ie.disabled&&e.jsx(Lm,{drag:{ids:[ie.nodeId],asPage:!!ie.own},label:ie.label,title:S("menuBuilder.dragHint","Drag into the menu")}),ie.icon!==void 0&&e.jsx("span",{className:"nice-menu-builder__icon","aria-hidden":"true",children:typeof ie.icon=="string"?l(ie.icon):ie.icon}),e.jsx("span",{className:"nice-menu-builder__label",children:ie.label}),ie.own&&e.jsx("span",{className:"nice-menu-builder__hint",children:S("menuBuilder.ownPage","(page)")})]})}],[S,w,l]),ne=z?Et(k,z)?.node:void 0,ae=oe=>!oe.ref||oe.children!==void 0,Y=oe=>Et(k,oe)?.depth??0,F=(oe,ie)=>{const Te=oe;!Te||!Array.isArray(Te.ids)||M(il(k,t,Te.ids,ie,{asPage:Te.asPage}))},J=()=>{let oe;if(ne){const Te=Et(k,ne.id);ae(ne)&&(o===void 0||(Te?.depth??0)+2<=o)?oe={parentId:ne.id,index:ne.children?.length??0}:Te&&(oe={parentId:Te.parentId,index:Te.index+1})}const ie=al(k,S("menuBuilder.newGroup","New group"),oe);M(ie.menu),R(ie.id),$(Te=>Te+1)},re=oe=>{const ie=Et(k,oe.id);if(!ie||ie.index===0)return!1;const Te=ie.siblings[ie.index-1];return ae(Te)&&(o===void 0||ie.depth+1+Ji(oe)<=o)},se=ne?Et(k,ne.id):void 0,G=oe=>{ne&&M(oe(k,ne.id))},ge=()=>{if(!ne||!se)return;const oe=se.siblings[se.index+1]??se.siblings[se.index-1];M(Wn(k,ne.id)),R(oe?.id??se.parentId)},Ce=oe=>{if(oe.icon)return l(oe.icon);const ie=$a(oe,t);return typeof ie?.icon=="string"?l(ie.icon):ie?.icon!==void 0?ie.icon:e.jsx(c.NiceIcon,{name:oe.ref?"file":"folder",size:16})},he=oe=>{ne&&M(Zi(k,ne.id,ie=>{const Te={...ie,...oe};return Object.keys(oe).forEach(X=>{oe[X]===void 0&&delete Te[X]}),Te}))},L=ne?$a(ne,t):void 0,H=ne?.ref?Qc(t,ne.ref):void 0,D=L?.label,ee=L?[...Zc(t,L.id),L.label].join(" / "):"",le=ne?(d??(oe=>e.jsx(Bm,{...oe,renderIcon:l})))({value:ne.icon,onChange:oe=>he({icon:oe})}):null,ue=s.useMemo(()=>u?rl(k,t,{renderIcon:l,otherLabel:S("menuBuilder.other","Other"),source:{id:"menu-preview",label:S("menuBuilder.preview","Preview")}}):[],[u,k,t,l,S]);if(N==="hidden")return null;const me=(oe,ie,Te,X,je)=>e.jsx(Le.NiceButton,{variant:"ghost",size:"sm",ariaLabel:ie,title:ie,disabled:!X,onClick:je,children:e.jsx(c.NiceIcon,{name:Te,size:16})},oe),de=!w;return e.jsx(jm,{children:e.jsx("div",{id:f,title:C,"data-testid":T,className:["nice-menu-builder",j?"nice-menu-builder--disabled":"",g??""].filter(Boolean).join(" "),style:{...p!==void 0?{height:p}:{},...v},"aria-disabled":j||void 0,children:e.jsxs("div",{className:"nice-menu-builder__grid",children:[e.jsxs("section",{className:"nice-menu-builder__column nice-menu-builder__column--catalog","aria-label":S("menuBuilder.catalog","Available views"),children:[e.jsx("header",{className:"nice-menu-builder__head",children:e.jsx("span",{className:"nice-menu-builder__title",children:S("menuBuilder.catalog","Available views")})}),e.jsx("div",{className:"nice-menu-builder__body nice-menu-builder__body--flush",children:e.jsx(yt.NiceTreeGrid,{data:O,nested:!0,keyField:"key",columns:W,checkable:!0,checkStrategy:"leaves",checkedKeys:V,onCheckedChange:B,isRowCheckable:oe=>oe.placeable,isRowDisabled:oe=>!!oe.disabled,getRowLabel:oe=>oe.label,defaultExpandedKeys:te,searchable:!0,searchPlaceholder:S("menuBuilder.searchViews","Search views"),searchFields:["label"],toolbarActions:["onlyChecked"],showSelectAll:!1,size:y,compact:!0,readOnly:w,emptyText:S("menuBuilder.catalogEmpty","No views to choose from")})})]}),e.jsxs("section",{className:"nice-menu-builder__column nice-menu-builder__column--menu","aria-label":S("menuBuilder.menu","Menu"),children:[e.jsxs("header",{className:"nice-menu-builder__head",children:[e.jsx("span",{className:"nice-menu-builder__title",children:S("menuBuilder.menu","Menu")}),de&&e.jsxs("span",{className:"nice-menu-builder__tools",role:"group","aria-label":S("menuBuilder.tools","Menu tools"),children:[me("group",S("menuBuilder.addGroup","New group"),"folder",!0,J),me("up",S("sortableTree.moveUp","Move up"),"chevron-up",!!se&&se.index>0,()=>G((oe,ie)=>Ra(oe,ie,-1))),me("down",S("sortableTree.moveDown","Move down"),"chevron-down",!!se&&se.index<se.siblings.length-1,()=>G((oe,ie)=>Ra(oe,ie,1))),me("indent",S("sortableTree.indent","Indent"),"indent",!!ne&&re(ne),()=>G(er)),me("outdent",S("sortableTree.outdent","Outdent"),"outdent",!!se&&se.parentId!==null,()=>G(tr)),me("remove",S("sortableTree.remove","Remove"),"trash",!!ne,ge)]}),h]}),e.jsx("div",{className:"nice-menu-builder__body",children:e.jsx(Jc,{"aria-label":S("menuBuilder.menu","Menu"),value:k,onChange:oe=>M(oe),selectedId:z,onSelect:oe=>R(oe),getLabel:oe=>ar(oe,t),getIcon:oe=>Ce(oe),renderRowEnd:oe=>K.has(oe.id)?e.jsx("span",{className:"nice-menu-builder__badge",children:S("menuBuilder.unavailable","unavailable")}):null,canHaveChildren:ae,canDrop:(oe,ie)=>ie.parentId===null||o===void 0||oe!==null||Y(ie.parentId)+2<=o,maxDepth:o,editable:de,removable:de,onExternalDrop:F,emptyText:S("menuBuilder.menuEmpty","Check views on the left or drag them here"),size:y,readOnly:w})})]}),e.jsxs("div",{className:"nice-menu-builder__side",children:[e.jsxs("section",{className:"nice-menu-builder__column nice-menu-builder__column--item","aria-label":S("menuBuilder.item","Item"),children:[e.jsxs("header",{className:"nice-menu-builder__head",children:[e.jsx("span",{className:"nice-menu-builder__title",children:S("menuBuilder.item","Item")}),ne&&e.jsx("span",{className:"nice-menu-builder__kind",children:ne.ref?S("menuBuilder.page","Page"):S("menuBuilder.group","Group")})]}),e.jsxs("div",{className:"nice-menu-builder__body nice-menu-builder__props",children:[!ne&&e.jsx("p",{className:"nice-menu-builder__hint",children:S("menuBuilder.selectHint","Select an item of the menu to rename it or change its icon.")}),ne&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-menu-builder__field",ref:A,children:[e.jsx(Ye.NiceTextInput,{label:S("menuBuilder.name","Name"),size:"sm",value:ne.label??"",placeholder:D??S("menuBuilder.newGroup","New group"),onChange:oe=>he({label:oe.trim()?oe:void 0}),readOnly:w}),de&&ne.label&&D&&e.jsx(Le.NiceButton,{variant:"ghost",size:"sm",ariaLabel:S("menuBuilder.resetName","Name from the catalog"),title:S("menuBuilder.resetName","Name from the catalog"),onClick:()=>he({label:void 0}),children:e.jsx(c.NiceIcon,{name:"undo",size:16})})]}),e.jsxs("div",{className:"nice-menu-builder__field nice-menu-builder__field--icon",children:[e.jsx("span",{className:"nice-menu-builder__field-label",children:S("menuBuilder.icon","Icon")}),e.jsx("span",{className:"nice-menu-builder__icon-now","aria-hidden":"true",children:Ce(ne)}),de&&ne.icon&&e.jsx(Le.NiceButton,{variant:"ghost",size:"sm",ariaLabel:S("menuBuilder.resetIcon","Icon from the catalog"),title:S("menuBuilder.resetIcon","Icon from the catalog"),onClick:()=>he({icon:void 0}),children:e.jsx(c.NiceIcon,{name:"undo",size:16})})]}),de&&le,(H?.route||ee)&&e.jsxs("dl",{className:"nice-menu-builder__facts",children:[H?.route&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:S("menuBuilder.route","Opens")}),e.jsx("dd",{children:e.jsx("code",{children:H.route})})]}),ee&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:S("menuBuilder.source","In the catalog")}),e.jsx("dd",{children:ee})]})]}),K.has(ne.id)&&e.jsx("p",{className:"nice-menu-builder__warning",role:"note",children:S("menuBuilder.orphan","This view is no longer in the catalog — it will not show in the menu.")})]})]})]}),u&&e.jsxs("section",{className:"nice-menu-builder__column nice-menu-builder__column--preview","aria-label":S("menuBuilder.preview","Preview"),children:[e.jsx("header",{className:"nice-menu-builder__head",children:e.jsx("span",{className:"nice-menu-builder__title",children:S("menuBuilder.preview","Preview")})}),e.jsx("div",{className:"nice-menu-builder__body nice-menu-builder__body--flush",children:e.jsx(Be.NiceSidebarNav,{data:ue,minimal:!0,readonly:!0,contextMenu:!1,preferences:Mm,...m})})]})]})]})})})},ll=s.createContext(null),Vm=({children:t,type:n="single",value:i,defaultValue:a,disabled:r=!1,onChange:o,className:l="",style:d,testId:u,"data-testid":m})=>{const[h,p]=s.useState(a??(n==="single"?"":[])),y=i!==void 0,x=y?i:h,b=s.useCallback(f=>n==="single"?x===f:Array.isArray(x)&&x.includes(f),[n,x]),g=s.useCallback(f=>{let C;if(n==="single")C=x===f?"":f;else{const _=Array.isArray(x)?x:[];C=_.includes(f)?_.filter(T=>T!==f):[..._,f]}y||p(C),o?.(C)},[n,x,y,o]),v=s.useMemo(()=>({type:n,isPressed:b,toggle:g,disabled:r}),[n,b,g,r]);return e.jsx(ll.Provider,{value:v,children:e.jsx("div",{role:"group",className:`nice-toggle-group nice-toggle-group--${n} ${l}`,style:d,"data-testid":m??u,children:t})})},qm=Object.assign(({value:t,children:n,disabled:i=!1})=>{const a=s.useContext(ll);if(!a)throw new Error("NiceToggleGroup.Item must be rendered inside <NiceToggleGroup>");const r=a.isPressed(t),o=a.disabled||i;return e.jsx("button",{type:"button",className:`nice-toggle-group__item ${r?"nice-toggle-group__item--pressed":""}`,"aria-pressed":r,disabled:o,onClick:()=>a.toggle(t),children:n})},{displayName:"NiceToggleGroup.Item"}),Ds=Object.assign(Vm,{displayName:"NiceToggleGroup",Item:qm}),Um=["daily","weekly","monthly","yearly"],Hm={daily:"Daily",weekly:"Weekly",monthly:"Monthly",yearly:"Yearly"},Gm={daily:"Repeat every (days)",weekly:"Repeat every (weeks)",monthly:"Repeat every (months)",yearly:"Repeat every (years)"},Wm={daily:{single:"Every day",other:"Every {n} days"},weekly:{single:"Every week",other:"Every {n} weeks"},monthly:{single:"Every month",other:"Every {n} months"},yearly:{single:"Every year",other:"Every {n} years"}},ro=10,dl=864e5,Km=new Date(2023,0,1);function oo(t,n){try{return new Intl.PluralRules(t).select(n)}catch{return n===1?"one":"other"}}function Ps(t,n,i){const a=new Date(Km.getTime()+n*dl);try{return new Intl.DateTimeFormat(t,{weekday:i}).format(a)}catch{return new Intl.DateTimeFormat("en",{weekday:i}).format(a)}}function ul(t,n){try{return new Intl.DateTimeFormat(t,n)}catch{return new Intl.DateTimeFormat("en",n)}}function co(t){const n=i=>String(i).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Ym(t,n,i,a){const r=Math.max(1,Math.floor(t.interval??1)),o=Wm[t.freq],l=[r===1?n(`recurrence.summary.${t.freq}.single`,o.single):n(`recurrence.summary.${t.freq}.${oo(i,r)}`,o.other).replace("{n}",String(r))];if(t.freq==="weekly"&&t.byDay?.length&&l.push(a.filter(d=>t.byDay?.includes(d)).map(d=>Ps(i,d,"short")).join(", ")),t.count&&t.count>0)l.push(n(`recurrence.summary.times.${oo(i,t.count)}`,t.count===1?"once":"{n} times").replace("{n}",String(t.count)));else if(t.until){const d=ul(i,{day:"numeric",month:"short",year:"numeric"});l.push(`${n("recurrence.summary.until","until")} ${d.format(new Date(t.until))}`)}return l.join(" · ")}const Jm=({value:t,defaultValue:n=null,onChange:i,start:a,allowNone:r=!0,previewCount:o=5,weekStartsOn:l=1,label:d,size:u="md",disabled:m=!1,readOnly:h=!1,className:p="",style:y,id:x,accessMode:b,"data-testid":g})=>{const{t:v,lang:f}=c.useNiceTranslation(),C=c.useNiceAccessMode(b,x),[_,T]=c.useControllableState({value:t,defaultValue:n,onChange:i,componentName:"NiceRecurrenceEditor"}),[S]=s.useState(()=>new Date),N=a??S,j=m||h||C==="disabled"||C==="readOnly",w=c.normalizeSize(u),k=w==="xxs"||w==="xs"?w:"sm",I=s.useMemo(()=>Array.from({length:7},(V,K)=>(K+l)%7),[l]),M=s.useMemo(()=>{if(!_||o<=0)return[];const V=new Date(N.getTime()+100*365*dl);return At.recurrenceDates(_,N,V,o)},[_,N,o]);if(C==="hidden")return null;const z=V=>{_&&T({..._,...V})},R=V=>{if(V==="none"){T(null);return}const K=V,te=_?{..._,freq:K}:{freq:K,interval:1};K==="weekly"?te.byDay=_?.byDay?.length?_.byDay:[N.getDay()]:delete te.byDay,T(te)},A=_?.count?"after":_?.until?"on":"never",E=V=>{if(!_)return;const K={..._};if(delete K.count,delete K.until,V==="after")T({...K,count:ro});else if(V==="on"){const te=new Date(N);te.setMonth(te.getMonth()+3),T({...K,until:te})}else T(K)},$=[...r?[{value:"none",label:v("recurrence.freq.none","Does not repeat")}]:[],...Um.map(V=>({value:V,label:v(`recurrence.freq.${V}`,Hm[V])}))],O=ul(f,{weekday:"short",day:"numeric",month:"short",year:"numeric"});return e.jsxs("div",{id:x,className:`nice-recurrence nice-recurrence--${w} ${p}`,style:y,"data-testid":g,children:[e.jsx(Ut.NiceSelect,{size:k,label:d??v("recurrence.frequency","Repeats"),value:_?_.freq:"none",options:$,onChange:V=>R(Array.isArray(V)?V[0]??"none":V),disabled:j}),_&&e.jsxs(e.Fragment,{children:[e.jsx(Ye.NiceNumberInput,{size:k,className:"nice-recurrence__interval",label:v(`recurrence.interval.${_.freq}`,Gm[_.freq]),min:1,max:999,value:_.interval??1,onChange:V=>z({interval:Math.max(1,Math.round(V??1))}),disabled:j}),_.freq==="weekly"&&e.jsxs("div",{className:"nice-recurrence__days",role:"group","aria-label":v("recurrence.days","On days"),children:[e.jsx("span",{className:"nice-recurrence__caption",children:v("recurrence.days","On days")}),e.jsx(Ds,{type:"multiple",disabled:j,value:(_.byDay??[]).map(String),onChange:V=>{const K=(Array.isArray(V)?V:[V]).map(Number);K.length>0&&z({byDay:K.sort((te,B)=>te-B)})},children:I.map(V=>e.jsx(Ds.Item,{value:String(V),children:e.jsx("span",{title:Ps(f,V,"long"),children:Ps(f,V,"short")})},V))})]}),e.jsxs("div",{className:"nice-recurrence__ends",children:[e.jsx(it.NiceRadioGroup,{size:k,label:v("recurrence.endsLabel","Ends"),direction:"vertical",value:A,onChange:E,disabled:j,options:[{value:"never",label:v("recurrence.ends.never","Never")},{value:"on",label:v("recurrence.ends.on","On a date")},{value:"after",label:v("recurrence.ends.after","After a number of occurrences")}]}),A==="on"&&_.until&&e.jsx(it.NiceDateTimePicker,{size:k,label:v("recurrence.endDate","End date"),dateFormatPreset:"date-local",value:co(new Date(_.until)),min:co(N),onChange:V=>{const[K,te,B]=V.split("-").map(Number);K&&te&&B&&z({until:new Date(K,te-1,B,23,59,59)})},disabled:j}),A==="after"&&e.jsx(Ye.NiceNumberInput,{size:k,className:"nice-recurrence__count",label:v("recurrence.count","Occurrences"),min:1,max:9999,value:_.count??ro,onChange:V=>z({count:Math.max(1,Math.round(V??1))}),disabled:j})]}),e.jsx("p",{className:"nice-recurrence__summary","aria-live":"polite",children:Ym(_,v,f,I)}),M.length>0&&e.jsxs("div",{className:"nice-recurrence__preview",children:[e.jsx("span",{className:"nice-recurrence__caption",children:v("recurrence.next","Next dates")}),e.jsx("ol",{className:"nice-recurrence__dates",children:M.map(V=>e.jsx("li",{children:e.jsx("time",{dateTime:V.toISOString(),children:O.format(V)})},V.getTime()))})]})]})]})};function Qm(t,n=1){let i;if(typeof t.quantity=="number"){const r=t.quantity*n;i=Number.isInteger(r)?String(r):String(Math.round(r*100)/100)}else i=t.quantity!=null?String(t.quantity):"";const a=t.unit??"";return[i,a].filter(Boolean).join(" ").trim()}const Xm=({photos:t})=>{const{t:n}=c.useNiceTranslation(),i=[...t].sort((l,d)=>+!!d.primary-+!!l.primary),[a,r]=s.useState(i[0]?.id),o=i.find(l=>l.id===a)??i[0];return e.jsxs("div",{className:"nice-recipe__gallery",children:[o&&e.jsxs("div",{className:"nice-recipe__photo-main",children:[e.jsx("img",{src:o.url,alt:o.caption??""}),o.caption&&e.jsx("div",{className:"nice-recipe__photo-caption",children:o.caption})]}),i.length>1&&e.jsx("div",{className:"nice-recipe__photo-thumbs",children:i.map(l=>e.jsx("button",{type:"button",className:`nice-recipe__thumb${l.id===o?.id?" nice-recipe__thumb--active":""}`,onClick:()=>r(l.id),"aria-label":l.caption??n("recipe.photo","Photo"),children:e.jsx("img",{src:l.url,alt:l.caption??""})},l.id))})]})},Zm=({recipe:t,compact:n=!1,hidePhotos:i=!1,hideIngredients:a=!1,hideSteps:r=!1,onIngredientToggle:o,onStepToggle:l,className:d,style:u,accessMode:m,id:h,"data-testid":p})=>{const{t:y}=c.useNiceTranslation(),x=c.useNiceAccessMode(m,h),b=t.servings,[g,v]=s.useState(b);if(s.useEffect(()=>{v(b)},[b]),x==="hidden")return null;const f=x==="readOnly"||x==="disabled",C=At.recipeTotalMinutes(t),_=t.photos??[],T=[...t.steps].sort((w,k)=>w.order-k.order),S=!f&&typeof b=="number"&&b>0&&typeof g=="number"&&g>0?g/b:1,N=!n&&typeof b=="number"&&b>0&&!f,j=()=>{typeof window<"u"&&window.print()};return e.jsxs("div",{className:`nice-recipe${n?" nice-recipe--compact":""} ${d??""}`,style:u,"data-testid":p,children:[e.jsxs("header",{className:"nice-recipe__header",children:[e.jsx("h3",{className:"nice-recipe__title",children:t.title||y("recipe.untitled","Untitled recipe")}),!n&&t.description&&e.jsx("p",{className:"nice-recipe__description",children:t.description}),e.jsxs("div",{className:"nice-recipe__meta",children:[t.servings!=null&&e.jsxs("span",{className:"nice-recipe__meta-item",children:[e.jsx(c.NiceIcon,{name:"box",size:14})," ",g??t.servings," ",y("recipe.servings","servings")]}),C!=null&&e.jsxs("span",{className:"nice-recipe__meta-item",children:[e.jsx(c.NiceIcon,{name:"clock",size:14})," ",C," ",y("recipe.minutes","min")]}),t.difficulty&&e.jsx("span",{className:`nice-recipe__badge nice-recipe__badge--${t.difficulty}`,children:y(`recipe.difficulty.${t.difficulty}`,t.difficulty)}),t.cuisine&&e.jsxs("span",{className:"nice-recipe__meta-item",children:[e.jsx(c.NiceIcon,{name:"globe",size:14})," ",t.cuisine]}),t.sourceUrl&&e.jsxs("a",{className:"nice-recipe__meta-item nice-recipe__source",href:t.sourceUrl,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(c.NiceIcon,{name:"link",size:14})," ",y("recipe.source","Source")]})]}),(N||!n)&&e.jsxs("div",{className:"nice-recipe__actions",children:[N&&e.jsxs("span",{className:"nice-recipe__servings-stepper",children:[e.jsx("button",{type:"button",className:"nice-recipe__servings-btn","aria-label":y("recipe.servingsDecrease","Decrease servings"),onClick:()=>v(w=>Math.max(1,(w??b??1)-1)),disabled:(g??b??1)<=1,children:"−"}),e.jsxs("span",{"aria-live":"polite",className:"nice-recipe__servings-value",children:[g??b," ×"]}),e.jsx("button",{type:"button",className:"nice-recipe__servings-btn","aria-label":y("recipe.servingsIncrease","Increase servings"),onClick:()=>v(w=>Math.min(99,(w??b??1)+1)),disabled:(g??b??1)>=99,children:"+"}),S!==1&&e.jsx("button",{type:"button",className:"nice-recipe__servings-reset",onClick:()=>v(b),children:y("recipe.reset","Reset")})]}),!n&&e.jsxs("button",{type:"button",className:"nice-recipe__print",onClick:j,"aria-label":y("recipe.print","Print recipe"),children:[e.jsx(c.NiceIcon,{name:"printer",size:14})," ",y("recipe.print","Print")]})]}),t.tags&&t.tags.length>0&&e.jsx("div",{className:"nice-recipe__tags",children:t.tags.map(w=>e.jsxs("span",{className:"nice-recipe__tag",children:["#",w]},w))})]}),!i&&_.length>0&&e.jsx(Xm,{photos:_}),e.jsxs("div",{className:"nice-recipe__body",children:[!a&&t.ingredients.length>0&&e.jsxs("section",{className:"nice-recipe__section nice-recipe__section--ingredients",children:[e.jsx("h4",{className:"nice-recipe__section-title",children:y("recipe.ingredients","Ingredients")}),e.jsx("ul",{className:"nice-recipe__ingredients",children:t.ingredients.map(w=>e.jsx("li",{className:"nice-recipe__ingredient",children:e.jsxs("label",{className:`nice-recipe__ingredient-row${w.checked?" nice-recipe__ingredient-row--checked":""}`,children:[e.jsx("input",{type:"checkbox",checked:!!w.checked,disabled:f||!o,onChange:()=>o?.(w)}),e.jsx("span",{className:"nice-recipe__ingredient-qty",children:Qm(w,S)}),e.jsx("span",{className:"nice-recipe__ingredient-name",children:w.name}),w.notes&&e.jsxs("span",{className:"nice-recipe__ingredient-notes",children:["— ",w.notes]})]})},w.id))})]}),!r&&T.length>0&&e.jsxs("section",{className:"nice-recipe__section nice-recipe__section--steps",children:[e.jsx("h4",{className:"nice-recipe__section-title",children:y("recipe.steps","Steps")}),e.jsx("ol",{className:"nice-recipe__steps",children:T.map(w=>e.jsx("li",{className:`nice-recipe__step${w.done?" nice-recipe__step--done":""}`,children:e.jsxs("label",{className:"nice-recipe__step-row",children:[e.jsx("input",{type:"checkbox",checked:!!w.done,disabled:f||!l,onChange:()=>l?.(w)}),e.jsxs("div",{className:"nice-recipe__step-body",children:[e.jsx("div",{className:"nice-recipe__step-instruction",children:w.instruction}),w.durationMinutes!=null&&e.jsxs("div",{className:"nice-recipe__step-duration",children:[e.jsx(c.NiceIcon,{name:"clock",size:14})," ",w.durationMinutes," ",y("recipe.minutes","min")]}),w.image&&e.jsx("img",{className:"nice-recipe__step-image",src:w.image,alt:""})]})]})},w.id))})]})]}),!n&&t.nutrition&&e.jsxs("footer",{className:"nice-recipe__nutrition",children:[t.nutrition.calories!=null&&e.jsx("span",{children:y("recipe.kcal","{label}: {value} kcal").replace("{label}",y("recipe.nutrition.calories","Calories")).replace("{value}",String(t.nutrition.calories))}),t.nutrition.protein!=null&&e.jsxs("span",{children:[y("recipe.nutrition.protein","Protein"),": ",t.nutrition.protein," g"]}),t.nutrition.fat!=null&&e.jsxs("span",{children:[y("recipe.nutrition.fat","Fat"),": ",t.nutrition.fat," g"]}),t.nutrition.carbs!=null&&e.jsxs("span",{children:[y("recipe.nutrition.carbs","Carbs"),": ",t.nutrition.carbs," g"]}),t.nutrition.fiber!=null&&e.jsxs("span",{children:[y("recipe.nutrition.fiber","Fiber"),": ",t.nutrition.fiber," g"]}),t.nutrition.sugar!=null&&e.jsxs("span",{children:[y("recipe.nutrition.sugar","Sugar"),": ",t.nutrition.sugar," g"]}),t.nutrition.sodium!=null&&e.jsx("span",{children:y("recipe.mg","{label}: {value} mg").replace("{label}",y("recipe.nutrition.sodium","Sodium")).replace("{value}",String(t.nutrition.sodium))})]})]})},eh=[],th=[{value:"",label:"All"},{value:"easy",label:"Easy"},{value:"medium",label:"Medium"},{value:"hard",label:"Hard"}],pl=({recipes:t=eh,onSelect:n,initialQuery:i="",hideFilters:a,emptyMessage:r,className:o,style:l,"data-testid":d})=>{const{t:u}=c.useNiceTranslation(),[m,h]=s.useState(i),[p,y]=s.useState(""),[x,b]=s.useState(""),g=s.useMemo(()=>{const f=new Set;for(const C of t)for(const _ of C.tags??[])f.add(_);return Array.from(f).sort()},[t]),v=s.useMemo(()=>{const f=m.trim().toLowerCase();return t.filter(C=>p&&C.difficulty!==p||x&&!(C.tags??[]).includes(x)?!1:f?[C.title,C.description??"",C.cuisine??"",...C.tags??[]].join(" ").toLowerCase().includes(f):!0)},[t,m,p,x]);return e.jsxs("div",{className:`nice-recipe-list ${o??""}`,style:l,"data-testid":d,children:[e.jsxs("div",{className:"nice-recipe-list__toolbar",children:[e.jsx("input",{type:"search",className:"nice-recipe-list__search",value:m,placeholder:u("recipe.list.search","Search recipes…"),onChange:f=>h(f.target.value),"aria-label":u("recipe.list.search","Search recipes")}),!a&&e.jsxs(e.Fragment,{children:[e.jsx("select",{className:"nice-recipe-list__filter",value:p,onChange:f=>y(f.target.value),"aria-label":u("recipe.difficulty","Difficulty"),children:th.map(f=>e.jsx("option",{value:f.value,children:f.label},f.value||"all"))}),g.length>0&&e.jsxs("select",{className:"nice-recipe-list__filter",value:x,onChange:f=>b(f.target.value),"aria-label":u("recipe.tags","Tags"),children:[e.jsx("option",{value:"",children:u("recipe.list.allTags","All tags")}),g.map(f=>e.jsxs("option",{value:f,children:["#",f]},f))]})]}),e.jsxs("span",{className:"nice-recipe-list__count","aria-live":"polite",children:[v.length," / ",t.length]})]}),v.length===0?e.jsx("div",{className:"nice-recipe-list__empty",children:r??u("recipe.list.empty","No recipes match the current filters.")}):e.jsx("ul",{className:"nice-recipe-list__grid",children:v.map(f=>{const C=f.photos?.find(T=>T.primary)??f.photos?.[0],_=At.recipeTotalMinutes(f);return e.jsx("li",{className:"nice-recipe-list__item",children:e.jsxs("button",{type:"button",className:"nice-recipe-list__card",onClick:()=>n?.(f),children:[C&&e.jsx("span",{className:"nice-recipe-list__thumb",children:e.jsx("img",{src:C.url,alt:C.caption??f.title,loading:"lazy"})}),e.jsxs("span",{className:"nice-recipe-list__body",children:[e.jsx("span",{className:"nice-recipe-list__title",children:f.title}),f.description&&e.jsx("span",{className:"nice-recipe-list__desc",children:f.description}),e.jsxs("span",{className:"nice-recipe-list__meta",children:[typeof f.servings=="number"&&e.jsxs("span",{className:"nice-recipe-list__meta-item",children:[e.jsx(c.NiceIcon,{name:"utensils",size:12})," ",f.servings]}),_!=null&&_>0&&e.jsxs("span",{className:"nice-recipe-list__meta-item",children:[e.jsx(c.NiceIcon,{name:"clock",size:12})," ",u("recipe.min","{total} min").replace("{total}",String(_))]}),f.difficulty&&e.jsx("span",{className:`nice-recipe__badge nice-recipe__badge--${f.difficulty}`,children:f.difficulty})]}),f.tags&&f.tags.length>0&&e.jsx("span",{className:"nice-recipe-list__tags",children:f.tags.slice(0,4).map(T=>e.jsxs("span",{className:"nice-recipe__tag",children:["#",T]},T))})]})]})},f.id)})})]})},nh=[],ih=[],ah=["breakfast","lunch","dinner"],sh=1440*60*1e3;function rh(t){const n=new Date(t);n.setHours(0,0,0,0);const i=n.getDay(),a=i===0?-6:1-i;return n.setDate(n.getDate()+a),n}function lo(t,n){return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}const oh=({recipes:t=nh,meals:n=ih,onChange:i,weekStart:a,rows:r=ah,readOnly:o,className:l,style:d,"data-testid":u})=>{const{t:m,lang:h}=c.useNiceTranslation(),p=s.useMemo(()=>rh(a??new Date),[a]),y=s.useMemo(()=>Array.from({length:7},(T,S)=>new Date(p.getTime()+S*sh)),[p]),x=s.useMemo(()=>{const T=new Map;for(const S of t)T.set(S.id,S);return T},[t]),b=s.useCallback((T,S)=>n.filter(N=>N.kind===S&&N.servedAt instanceof Date&&lo(N.servedAt,T)),[n]),g=s.useCallback((T,S,N)=>{if(!N||o)return;const j=x.get(N),w=new Date(T);w.setHours(S==="breakfast"?8:S==="lunch"?13:S==="dinner"?19:16,0,0,0);const k={id:At.newRecipeId("meal"),name:j?.title??m("mealplan.untitled","Meal"),kind:S,servedAt:w,recipeIds:[N],servings:j?.servings};i?.([...n,k])},[n,i,o,x,m]),v=s.useCallback(T=>{o||i?.(n.filter(S=>S.id!==T))},[n,i,o]),f=T=>T.toLocaleDateString(h,{weekday:"short",day:"numeric",month:"short"}),C=T=>m(`mealplan.kind.${T}`,T.charAt(0).toUpperCase()+T.slice(1)),_=new Date;return e.jsx("div",{className:`nice-mealplan ${l??""}`,style:d,"data-testid":u,children:e.jsxs("div",{className:"nice-mealplan__grid",style:{gridTemplateColumns:"auto repeat(7, minmax(8rem, 1fr))"},children:[e.jsx("div",{className:"nice-mealplan__corner"}),y.map(T=>e.jsx("div",{className:`nice-mealplan__day-head${lo(T,_)?" nice-mealplan__day-head--today":""}`,children:f(T)},T.toISOString())),r.map(T=>e.jsxs(s.Fragment,{children:[e.jsx("div",{className:"nice-mealplan__row-head",children:C(T)}),y.map(S=>{const N=b(S,T);return e.jsxs("div",{className:"nice-mealplan__cell",children:[N.map(j=>{const w=j.recipeIds[0]?x.get(j.recipeIds[0]):void 0;return e.jsxs("div",{className:"nice-mealplan__chip",title:j.name,children:[e.jsx("span",{className:"nice-mealplan__chip-title",children:w?.title??j.name}),!o&&e.jsx("button",{type:"button",className:"nice-mealplan__chip-remove","aria-label":m("mealplan.remove","Remove meal"),onClick:()=>v(j.id),children:e.jsx(c.NiceIcon,{name:"close",size:14})})]},j.id)}),!o&&t.length>0&&e.jsxs("select",{className:"nice-mealplan__add",value:"","aria-label":m("mealplan.addRecipe","Add recipe"),onChange:j=>{const w=j.target.value;w&&g(S,T,w),j.target.value=""},children:[e.jsxs("option",{value:"",children:["+ ",m("mealplan.add","Add")]}),t.map(j=>e.jsx("option",{value:j.id,children:j.title},j.id))]})]},`${T}-${S.toISOString()}`)})]},T))]})})},ch=[],lh=[],dh=({recipes:t=ch,collections:n=lh,onChange:i,readOnly:a,onSelectRecipe:r,className:o,style:l,"data-testid":d})=>{const{t:u}=c.useNiceTranslation(),{prompt:m,element:h}=xt.useNiceDialogs(),[p,y]=s.useState(n[0]?.id??null),[x,b]=s.useState(null),g=s.useMemo(()=>{const k=new Map;for(const I of t)k.set(I.id,I);return k},[t]),v=s.useMemo(()=>n.find(k=>k.id===p)??n[0]??null,[n,p]),f=s.useMemo(()=>v?v.recipeIds.map(k=>g.get(k)).filter(k=>!!k):[],[v,g]),C=s.useCallback(k=>{i?.(k)},[i]),_=s.useCallback(()=>{a||m({title:u("collections.namePrompt","Collection name")}).then(k=>{if(!k||!k.trim())return;const I={id:At.newRecipeId("coll"),name:k.trim(),recipeIds:[]};C([...n,I]),y(I.id)})},[n,a,u,C,m]),T=s.useCallback(k=>{if(a)return;const I=n.filter(M=>M.id!==k);C(I),p===k&&y(I[0]?.id??null)},[p,n,a,C]),S=s.useCallback(()=>{if(!x)return;const k=x.value.trim();k&&C(n.map(I=>I.id===x.id?{...I,name:k}:I)),b(null)},[n,x,C]),N=s.useCallback(k=>{!v||!k||a||v.recipeIds.includes(k)||C(n.map(I=>I.id===v.id?{...I,recipeIds:[...I.recipeIds,k]}:I))},[v,n,a,C]),j=s.useCallback(k=>{!v||a||C(n.map(I=>I.id===v.id?{...I,recipeIds:I.recipeIds.filter(M=>M!==k)}:I))},[v,n,a,C]),w=s.useMemo(()=>v?t.filter(k=>!v.recipeIds.includes(k.id)):[],[v,t]);return e.jsxs("div",{className:`nice-recipe-collections ${o??""}`,style:l,"data-testid":d,children:[h,e.jsxs("aside",{className:"nice-recipe-collections__sidebar",children:[e.jsxs("div",{className:"nice-recipe-collections__sidebar-head",children:[e.jsx("span",{className:"nice-recipe-collections__sidebar-title",children:u("collections.title","Collections")}),!a&&e.jsx("button",{type:"button",className:"nice-recipe-collections__sidebar-add",onClick:_,"aria-label":u("collections.create","Create collection"),children:e.jsx(c.NiceIcon,{name:"plus",size:14})})]}),e.jsx("ul",{className:"nice-recipe-collections__list",children:n.map(k=>{const I=v?.id===k.id,M=x?.id===k.id;return e.jsxs("li",{className:`nice-recipe-collections__item${I?" nice-recipe-collections__item--active":""}`,children:[M?e.jsx("input",{autoFocus:!0,className:"nice-recipe-collections__rename",value:x.value,onChange:z=>b({id:k.id,value:z.target.value}),onBlur:S,onKeyDown:z=>{z.key==="Enter"?S():z.key==="Escape"&&b(null)}}):e.jsxs("button",{type:"button",className:"nice-recipe-collections__item-btn",onClick:()=>y(k.id),onDoubleClick:()=>!a&&b({id:k.id,value:k.name}),children:[e.jsx("span",{className:"nice-recipe-collections__item-name",children:k.name}),e.jsx("span",{className:"nice-recipe-collections__item-count",children:k.recipeIds.length})]}),!a&&!M&&e.jsx("button",{type:"button",className:"nice-recipe-collections__item-remove",onClick:()=>T(k.id),"aria-label":u("collections.delete","Delete collection"),title:u("collections.delete","Delete collection"),children:e.jsx(c.NiceIcon,{name:"close",size:14})})]},k.id)})})]}),e.jsx("section",{className:"nice-recipe-collections__main",children:v?e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"nice-recipe-collections__header",children:[e.jsx("h3",{className:"nice-recipe-collections__name",children:v.name}),!a&&w.length>0&&e.jsxs("select",{className:"nice-recipe-collections__add-recipe",value:"","aria-label":u("collections.addRecipe","Add recipe"),onChange:k=>{const I=k.target.value;I&&N(I),k.target.value=""},children:[e.jsxs("option",{value:"",children:["+ ",u("collections.addRecipe","Add recipe")]}),w.map(k=>e.jsx("option",{value:k.id,children:k.title},k.id))]})]}),f.length===0?e.jsx("div",{className:"nice-recipe-collections__empty",children:u("collections.empty","No recipes in this collection yet.")}):e.jsx(pl,{recipes:f,hideFilters:!0,onSelect:k=>r?.(k)}),!a&&f.length>0&&e.jsxs("details",{className:"nice-recipe-collections__manage",children:[e.jsx("summary",{children:u("collections.manage","Manage recipes")}),e.jsx("ul",{className:"nice-recipe-collections__manage-list",children:f.map(k=>e.jsxs("li",{children:[e.jsx("span",{children:k.title}),e.jsx("button",{type:"button",onClick:()=>j(k.id),"aria-label":u("collections.removeRecipe","Remove recipe from collection"),children:u("collections.removeShort","Remove")})]},k.id))})]})]}):e.jsx("div",{className:"nice-recipe-collections__empty",children:u("collections.emptyState","No collection selected.")})})]})},uh=[],ii=["hour","day","week","month","quarter","year"],ph=t=>{switch(t){case"hour":return{msPerPixel:6e4,unitMs:36e5,unitLabel:"HH:mm",headerFormat:"MMM d, yyyy"};case"day":return{msPerPixel:36e5,unitMs:864e5,unitLabel:"d",headerFormat:"MMM yyyy"};case"week":return{msPerPixel:864e5/2,unitMs:6048e5,unitLabel:"W",headerFormat:"MMM yyyy"};case"month":return{msPerPixel:864e5*2,unitMs:2592e6,unitLabel:"MMM",headerFormat:"yyyy"};case"quarter":return{msPerPixel:864e5*7,unitMs:7776e6,unitLabel:"Q",headerFormat:"yyyy"};case"year":return{msPerPixel:864e5*30,unitMs:31536e6,unitLabel:"yyyy",headerFormat:""};default:return{msPerPixel:864e5,unitMs:864e5,unitLabel:"d",headerFormat:"MMM yyyy"}}},ai=(t,n,i="pl-PL")=>{const a={};if(n.includes("yyyy")&&(a.year="numeric"),n.includes("MMM")&&(a.month="short"),n.includes("MM")&&!n.includes("MMM")&&(a.month="2-digit"),(n.includes("dd")||n.includes("d"))&&(a.day="2-digit"),n.includes("EEE")&&(a.weekday="short"),n.includes("HH")&&(a.hour="2-digit",a.hour12=!1),n.includes("mm")&&!n.includes("MMM")&&(a.minute="2-digit"),n==="W")return`T${mh(t)}`;if(n==="Q")return`Q${Math.ceil((t.getMonth()+1)/3)}`;const r=a.year||a.month||a.day||a.weekday;return(a.hour||a.minute)&&!r?t.toLocaleTimeString(i,a):t.toLocaleDateString(i,a)},mh=t=>{const n=new Date(t);n.setHours(0,0,0,0),n.setDate(n.getDate()+4-(n.getDay()||7));const i=new Date(n.getFullYear(),0,1);return Math.ceil(((n.getTime()-i.getTime())/864e5+1)/7)},uo=(t,n)=>new Date(t.getTime()+n),hh=["var(--nice-color-primary, #3b82f6)","var(--nice-color-error, #ef4444)","var(--nice-color-success, #22c55e)","var(--nice-color-warning, #f59e0b)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-color-info, #06b6d4)","var(--nice-success, #84cc16)","var(--nice-warning, #f97316)","var(--nice-color-accent, #6366f1)"],gh=Object.assign(s.forwardRef((t,n)=>{const{t:i}=c.useNiceTranslation(),{events:a=uh,groups:r=[],markers:o=[],initialZoom:l="week",initialDate:d,width:u=800,height:m=400,showToday:h=!0,showZoomControls:p=!0,showNavControls:y=!0,showMinimap:x=!1,onEventClick:b,onEventHover:g,onDateChange:v,onZoomChange:f,renderEvent:C,colors:_=hh,locale:T="pl-PL",className:S,style:N,...j}=t,[w,k]=s.useState(l),[I,M]=s.useState(d||new Date),[z,R]=s.useState(!1),[A,E]=s.useState({x:0,date:new Date}),[$,O]=s.useState(null),[V,K]=s.useState(new Set),te=s.useRef(null),B=s.useMemo(()=>ph(w),[w]),W=u*B.msPerPixel,ne=I.getTime()-W/2,ae=I.getTime()+W/2,Y=s.useMemo(()=>new Date(ne),[ne]),F=s.useMemo(()=>new Date(ae),[ae]),J=s.useCallback(U=>(U.getTime()-Y.getTime())/B.msPerPixel,[Y,B.msPerPixel]);s.useCallback(U=>{const ye=U*B.msPerPixel;return new Date(Y.getTime()+ye)},[Y,B.msPerPixel]);const re=s.useMemo(()=>{const U=[];let ye=new Date(Y);switch(w){case"hour":ye.setMinutes(0,0,0);break;case"day":ye.setHours(0,0,0,0);break;case"week":{const Ne=ye.getDay();ye.setDate(ye.getDate()-Ne+1),ye.setHours(0,0,0,0);break}case"month":ye.setDate(1),ye.setHours(0,0,0,0);break;case"quarter":ye.setMonth(Math.floor(ye.getMonth()/3)*3),ye.setDate(1),ye.setHours(0,0,0,0);break;case"year":ye.setMonth(0,1),ye.setHours(0,0,0,0);break}for(;ye<=F;){const Ne=J(ye),ze=w==="day"?ye.getDay()===1:w==="week"?ye.getDate()===1:w==="month"?ye.getMonth()%3===0:w==="quarter"?ye.getMonth()===0:!0;U.push({date:new Date(ye),x:Ne,isMain:ze,isWeekend:w==="day"&&(ye.getDay()===0||ye.getDay()===6)}),ye=uo(ye,B.unitMs)}return U},[Y,F,w,B,J]),se=s.useMemo(()=>{const U=B.unitMs/B.msPerPixel;return U<=0?1:Math.max(1,Math.ceil(40/U))},[B]),G=s.useMemo(()=>{const U=new Map;return U.set("__default",[]),r.forEach(ye=>U.set(ye.id,[])),a.forEach(ye=>{const Ne=ye.group&&U.has(ye.group)?ye.group:"__default",ze=U.get(Ne)||[];ze.push(ye),U.set(Ne,ze)}),U},[a,r]),ge=s.useMemo(()=>{const U=[];return G.get("__default")?.length&&U.push({id:"__default",title:"",events:G.get("__default")||[],isGroup:!1}),r.forEach(ye=>{V.has(ye.id)||U.push({id:ye.id,title:ye.title,events:G.get(ye.id)||[],isGroup:!0})}),U},[G,r,V]),Ce=s.useCallback(U=>{M(U),v?.(U)},[v]),he=s.useCallback(()=>{const U=ii.indexOf(w);if(U>0){const ye=ii[U-1];k(ye),f?.(ye)}},[w,f]),L=s.useCallback(()=>{const U=ii.indexOf(w);if(U<ii.length-1){const ye=ii[U+1];k(ye),f?.(ye)}},[w,f]),H=s.useCallback(U=>{k(U),f?.(U)},[f]),D=s.useCallback(U=>{const ye=uo(I,U*W*.5);Ce(ye)},[I,W,Ce]),ee=s.useCallback(U=>{U.button===0&&(R(!0),E({x:U.clientX,date:I}))},[I]),le=s.useCallback(U=>{if(!z)return;const Ne=(A.x-U.clientX)*B.msPerPixel,ze=new Date(A.date.getTime()+Ne);M(ze)},[z,A,B.msPerPixel]),ue=s.useCallback(()=>{z&&(R(!1),v?.(I))},[z,I,v]),me=s.useCallback(U=>{U.preventDefault(),U.deltaY<0?he():L()},[he,L]),de=s.useCallback(U=>{O(U),g?.(U)},[g]),oe=s.useCallback(()=>{O(null),g?.(null)},[g]),ie=s.useRef(null);c.useRovingFocus(ie,{orientation:"grid",itemSelector:".nice-timeline-event, .nice-timeline-milestone"});const Te=U=>ye=>{(ye.key==="Enter"||ye.key===" ")&&(ye.preventDefault(),b?.(U))};s.useImperativeHandle(n,()=>({goToDate:Ce,zoomIn:he,zoomOut:L,setZoom:H,getCurrentDate:()=>I,getCurrentZoom:()=>w}),[Ce,he,L,H,I,w]);const X=40,je=60,Z=Math.max(ge.length*X,m-je-40),ve=J(new Date);return e.jsxs("div",{className:`nice-timeline ${S||""}`,style:{width:u,...N},...j,children:[e.jsxs("div",{className:"nice-timeline-toolbar",children:[y&&e.jsx("div",{className:"nice-timeline-nav",children:e.jsxs(At.NiceButtonGroup,{size:"sm",children:[e.jsx(Le.NiceButton,{onClick:()=>D(-1),"aria-label":i("planning.previous","Previous"),children:e.jsx(c.NiceIcon,{name:"chevron-left",size:14})}),e.jsx(Le.NiceButton,{onClick:()=>Ce(new Date),children:i("scheduling.today","Today")}),e.jsx(Le.NiceButton,{onClick:()=>D(1),"aria-label":i("planning.next","Next"),children:e.jsx(c.NiceIcon,{name:"chevron-right",size:14})})]})}),e.jsx("div",{className:"nice-timeline-center",children:e.jsxs("span",{className:"nice-timeline-range",children:[ai(Y,"MMM d, yyyy",T)," —"," ",ai(F,"MMM d, yyyy",T)]})}),p&&e.jsx("div",{className:"nice-timeline-zoom",children:e.jsx(At.NiceButtonGroup,{size:"sm",children:ii.map(U=>e.jsx(Le.NiceButton,{variant:w===U?"primary":"secondary",onClick:()=>H(U),children:U==="hour"?i("planning.hourShort","hr"):U==="day"?i("planning.dayShort","day"):U==="week"?i("planning.weekShort","wk"):U==="month"?i("planning.monthShort","mo"):U==="quarter"?i("planning.quarterShort","qtr"):i("planning.yearShort","yr")},U))})})]}),e.jsxs("div",{ref:te,className:"nice-timeline-container",onMouseDown:ee,onMouseMove:le,onMouseUp:ue,onMouseLeave:ue,onWheel:me,style:{cursor:z?"grabbing":"grab"},children:[e.jsxs("div",{className:"nice-timeline-header",style:{height:je},children:[e.jsx("div",{className:"nice-timeline-header-main",children:B.headerFormat&&e.jsx("span",{children:ai(I,B.headerFormat,T)})}),e.jsx("div",{className:"nice-timeline-header-units",children:re.map((U,ye)=>{const Ne=ye%se===0||U.isMain,ze=w==="hour"&&U.date.getHours()===0,P=ze?"d MMM":B.unitLabel;return e.jsx("div",{className:`nice-timeline-unit ${U.isMain?"main":""} ${U.isWeekend?"nice-timeline-unit--weekend":""} ${ze?"nice-timeline-unit--midnight":""} ${Ne?"":"nice-timeline-unit--no-label"}`,style:{left:U.x},children:Ne&&e.jsx("span",{children:ai(U.date,P,T)})},ye)})})]}),e.jsxs("div",{ref:ie,className:"nice-timeline-chart",style:{height:Z},role:"group","aria-label":i("timeline.events","Events"),children:[e.jsxs("svg",{className:"nice-timeline-grid",width:u,height:Z,children:[re.map((U,ye)=>{if(!U.isWeekend)return null;const Ne=re[ye+1],ze=(Ne?Ne.x:U.x+B.unitMs/B.msPerPixel)-U.x;return e.jsx("rect",{x:U.x,y:0,width:ze,height:Z,className:"nice-timeline-weekend-band"},`wk-${ye}`)}),re.map((U,ye)=>e.jsx("line",{x1:U.x,y1:0,x2:U.x,y2:Z,className:U.isMain?"main":"minor"},ye)),h&&ve>=0&&ve<=u&&e.jsx("line",{x1:ve,y1:0,x2:ve,y2:Z,className:"today"}),ge.map((U,ye)=>e.jsx("line",{x1:0,y1:(ye+1)*X,x2:u,y2:(ye+1)*X,className:"row-sep"},ye))]}),o.map((U,ye)=>{const Ne=J(U.date);return Ne<0||Ne>u?null:e.jsx("div",{className:`nice-timeline-marker ${U.type||"line"}`,style:{left:Ne,borderColor:U.color},children:e.jsx("span",{className:"nice-timeline-marker-label",children:U.label})},ye)}),ge.map((U,ye)=>e.jsx("div",{className:"nice-timeline-row",style:{top:ye*X,height:X},children:U.events.map((Ne,ze)=>{const P=J(Ne.start),q=Ne.end?J(Ne.end):P+10,Q=Math.max(q-P,20),be=Ne.color||_[ze%_.length];return P>u||q<0?null:Ne.type==="milestone"?e.jsx("div",{className:`nice-timeline-milestone ${$?.id===Ne.id?"hovered":""}`,style:{left:P,borderColor:be},onClick:()=>b?.(Ne),onKeyDown:Te(Ne),onMouseEnter:()=>de(Ne),onMouseLeave:oe,onFocus:()=>de(Ne),onBlur:oe,role:"button","aria-label":Ne.title,title:Ne.title,children:Ne.icon||e.jsx(c.NiceIcon,{name:"diamond",size:12})},Ne.id):e.jsx("div",{className:`nice-timeline-event ${Ne.type||"event"} ${$?.id===Ne.id?"hovered":""}`,style:{left:Math.max(P,0),width:Q,backgroundColor:be},onClick:()=>b?.(Ne),onKeyDown:Te(Ne),onMouseEnter:()=>de(Ne),onMouseLeave:oe,onFocus:()=>de(Ne),onBlur:oe,role:"button","aria-label":Ne.title,title:Ne.description||Ne.title,children:C?C(Ne):e.jsx("span",{className:"nice-timeline-event-title",children:Ne.title})},Ne.id)})},U.id)),h&&ve>=0&&ve<=u&&e.jsx("div",{className:"nice-timeline-today-marker",style:{left:ve},children:e.jsx("span",{children:i("scheduling.today","Today")})})]}),$&&e.jsxs("div",{className:"nice-timeline-tooltip",style:{left:J($.start)+10},children:[e.jsx("strong",{children:$.title}),$.description&&e.jsx("p",{children:$.description}),e.jsxs("small",{children:[ai($.start,"MMM d, yyyy HH:mm",T),$.end&&` — ${ai($.end,"MMM d, yyyy HH:mm",T)}`]})]})]}),x&&e.jsx("div",{className:"nice-timeline-minimap"}),e.jsx("style",{children:`
3
+ `)}function Oc(t,n={}){const i=Mc(t,n);return new Blob([i],{type:"text/calendar;charset=utf-8"})}function Vp(t,n="calendar.ics",i={}){if(typeof window>"u"||typeof URL.createObjectURL!="function")return;const a=Oc(t,i),r=URL.createObjectURL(a),o=document.createElement("a");o.href=r,o.download=n,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(r)}const qp=[];function Up(t){const n=t?.closest?.("[data-theme], .nice-dark, .nice-light, .dark");if(!n)return"";const i=n.getAttribute("data-theme");return i==="dark"||n.classList.contains("nice-dark")||n.classList.contains("dark")?"nice-dark":i==="light"||n.classList.contains("nice-light")?"nice-light":""}const zc=({icon:t,items:n=qp,direction:i="right",position:a={bottom:24,right:24},disabled:r=!1,className:o,style:l,id:d,"data-testid":u})=>{const[m,h]=s.useState(!1),p=m&&!r,y=s.useRef(null),x=s.useRef(null),[b,g]=s.useState(null),[v,f]=s.useState(""),C=s.useRef(null);c.useMenuButton(x,C,{open:p,onOpenChange:h,orientation:i==="up"||i==="down"?"vertical":"horizontal"}),s.useLayoutEffect(()=>{if(!p||!x.current)return;const T=x.current,S=()=>g(T.getBoundingClientRect());return S(),f(Up(y.current)),window.addEventListener("scroll",S,!0),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[p]);const _=e.jsx("div",{className:"nice-speed-dial__items",role:"menu",ref:C,children:n.map(T=>e.jsx("button",{type:"button",role:"menuitem",className:"nice-speed-dial__item nice-btn nice-btn--secondary",onClick:()=>{T.onClick?.(),h(!1)},title:T.label,"aria-label":T.label,children:T.icon},T.key))});return e.jsxs("div",{ref:y,id:d,"data-testid":u,className:["nice-speed-dial",`nice-speed-dial--${i}`,p?"nice-speed-dial--open":"",r?"nice-speed-dial--disabled":"",o||""].filter(Boolean).join(" "),style:{...a,...l},children:[e.jsx("button",{ref:x,type:"button",className:"nice-speed-dial__trigger nice-btn nice-btn--primary",onClick:()=>h(T=>!T),"aria-expanded":p,"aria-haspopup":"menu",disabled:r,children:e.jsx("span",{className:"nice-speed-dial__trigger-icon",children:t??e.jsx(c.NiceIcon,{name:"plus",size:24})})}),p&&b&&typeof document<"u"&&Pc.createPortal(e.jsx("div",{className:["nice-speed-dial","nice-speed-dial--portal",`nice-speed-dial--${i}`,"nice-speed-dial--open",v].filter(Boolean).join(" "),"data-theme":v==="nice-dark"?"dark":v==="nice-light"?"light":void 0,style:{position:"fixed",left:b.left,top:b.top,width:b.width,height:b.height,right:"auto",bottom:"auto",margin:0},children:_}),document.body)]})},Wt=({children:t,variant:n="primary",size:i="md",dot:a,outline:r,subtle:o,pulse:l,icon:d,removable:u,onRemove:m,className:h,style:p,displayStyle:y,testId:x,"data-testid":b})=>{const{t:g}=c.useNiceTranslation(),v=c.useComponentDisplayStyle("badge",y),f=c.useComponentDisplayClass("badge",y),C={...v};for(const _ of["fontSize","padding","paddingLeft","paddingRight","paddingTop","paddingBottom","paddingInline","paddingBlock"])delete C[_];if(n!=="primary"||r||o)for(const _ of["background","backgroundColor","color"])delete C[_];if(r||o)for(const _ of["border","borderColor","borderWidth","borderStyle","boxShadow"])delete C[_];return e.jsxs("span",{className:`nice-badge nice-badge--${n} nice-badge--${i} nice-badge--ds-${f} ${a?"nice-badge--dot":""} ${r?"nice-badge--outline":""} ${o?"nice-badge--subtle":""} ${l?"nice-badge--pulse":""} ${u?"nice-badge--removable":""} ${h||""}`,style:{...C,...p},"data-testid":b??x,children:[d&&e.jsx("span",{className:"nice-badge__icon",children:d}),t,u&&e.jsx("button",{type:"button",className:"nice-badge__remove",onClick:m,"aria-label":g("badge.remove","Remove"),children:e.jsx(c.NiceIcon,{name:"close",size:14})})]})},Pa=({children:t,selected:n,removable:i,onClick:a,onRemove:r,color:o,size:l="md",className:d,style:u,testId:m,"data-testid":h})=>{const{t:p}=c.useNiceTranslation(),y=typeof t=="string"||typeof t=="number"?`${p("tag.remove","Remove")}: ${t}`:p("tag.remove","Remove");return e.jsxs("span",{className:`nice-tag nice-tag--${l} ${a?"nice-tag--clickable":""} ${n?"nice-tag--selected":""} ${d||""}`,style:{...u,...o&&!n?{borderColor:o,color:o}:{}},"data-testid":h??m,...a&&{onClick:a,role:"button",tabIndex:0,"aria-pressed":n,onKeyDown:x=>{x.target===x.currentTarget&&(x.key==="Enter"||x.key===" "?(x.preventDefault(),a()):i&&(x.key==="Delete"||x.key==="Backspace")&&(x.preventDefault(),r?.()))}},children:[t,i&&e.jsx("button",{type:"button",className:"nice-tag__remove",onClick:x=>{x.stopPropagation(),r?.()},"aria-label":y,children:e.jsx(c.NiceIcon,{name:"close",size:14})})]})};function Hp(t){return t.split(" ").map(n=>n[0]).filter(Boolean).slice(0,2).join("").toUpperCase()}const Vt=({src:t,alt:n,name:i,size:a="md",square:r,color:o,className:l,style:d,testId:u,"data-testid":m})=>e.jsx("div",{className:`nice-avatar nice-avatar--${a} ${r?"nice-avatar--square":""} ${l||""}`,style:{...d,...o?{background:o}:{}},"aria-label":n||i,"data-testid":m??u,children:t?e.jsx("img",{src:t,alt:n||i||""}):i?Hp(i):e.jsx(c.NiceIcon,{name:"user",size:"md",className:"nice-avatar__fallback-icon"})});function Gp(t){return t?t.trim().split(/\s+/).map(n=>n[0]).join("").slice(0,2).toUpperCase():""}const Ks=({children:t,items:n,max:i,size:a="md",className:r,style:o,testId:l,"data-testid":d})=>{const u=`nice-avatar nice-avatar--${a}`;let m,h;if(n&&n.length>0)h=n.length,m=(i?n.slice(0,i):n).map((x,b)=>{const g=x.src?e.jsx("img",{src:x.src,alt:x.name??""}):e.jsx("span",{children:Gp(x.name)});return x.href?e.jsx("a",{className:u,href:x.href,title:x.name,onClick:x.onClick,children:g},b):x.onClick?e.jsx("button",{type:"button",className:u,title:x.name,onClick:x.onClick,children:g},b):e.jsx("span",{className:u,title:x.name,children:g},b)});else{const y=s.Children.toArray(t);h=y.length,m=(i?y.slice(0,i):y).map(b=>s.isValidElement(b)&&b.props.size==null?s.cloneElement(b,{size:a}):b)}const p=i?Math.max(0,h-i):0;return e.jsxs("div",{className:`nice-avatar-group nice-avatar-group--${a} ${r||""}`,style:o,"data-testid":d??l,children:[m,p>0&&e.jsxs("div",{className:u,style:{background:"var(--nice-text-muted)"},children:["+",p]})]})},Wp={xxs:4,xs:6,sm:8,md:12,lg:16,xl:20,xxl:28},Lc=Object.assign(s.forwardRef(({children:t,items:n,renderCard:i,searchable:a,searchField:r="text",searchPlaceholder:o,emptyText:l,onCardClick:d,size:u="md",minColumnWidth:m=240,columns:h,gap:p,align:y="stretch",equalHeight:x=!1,value:b,onChange:g,name:v,disabled:f,readOnly:C,loading:_,error:T,errorText:S,className:N,style:j,testId:w,"data-testid":k},I)=>{const{t:M}=c.useNiceTranslation(),[z,R]=s.useState(""),A=h?`repeat(${h}, minmax(0, 1fr))`:`repeat(auto-fill, minmax(${m}px, 1fr))`,E=p??Wp[u]??12,$=typeof T=="string"?T.length>0:!!T,O=typeof T=="string"?T:T?S??"":"",V=n!=null&&i!=null,K=s.useMemo(()=>{if(!V||!z)return n??[];const J=z.toLowerCase();return(n??[]).filter(re=>String(re[r]??"").toLowerCase().includes(J))},[V,n,z,r]),te=g!=null||b!=null,B=s.useMemo(()=>({value:b,onChange:J=>{!f&&!C&&g?.(J)},name:v}),[b,g,v,f,C]),W=x?"stretch":y,ne=x?"1fr":void 0,ae=`nice-card-group nice-card-group--${u}${x?" nice-card-group--equal":""}${f?" nice-card-group--disabled":""}${C?" nice-card-group--readonly":""}${_?" nice-card-group--loading":""}${$?" nice-card-group--error":""}${N?` ${N}`:""}`;if(V)return e.jsx(Be.NiceCardGroupSizeContext.Provider,{value:u,children:e.jsxs("div",{ref:I,className:ae,style:{position:"relative",...j},"aria-disabled":f||void 0,"aria-busy":_||void 0,"data-testid":k??w,children:[a&&e.jsx("div",{className:"nice-card-group__search",children:e.jsx("input",{type:"text",value:z,onChange:J=>R(J.target.value),placeholder:o||M("controls.search","Search...")})}),_?e.jsx("div",{className:"nice-card-group__empty",children:e.jsx("span",{className:"nice-spinner nice-spinner--md"})}):K.length===0?e.jsx("div",{className:"nice-card-group__empty",children:l||M("controls.noData","No data available")}):e.jsx("div",{className:"nice-card-group__grid",style:{display:"grid",gridTemplateColumns:A,gridAutoRows:ne,gap:E,alignItems:W},children:K.map(J=>e.jsx("div",{className:"nice-card-group__data-card",onClick:d?()=>d(J):void 0,onKeyDown:d?re=>{re.target===re.currentTarget&&(re.key==="Enter"||re.key===" ")&&(re.preventDefault(),d(J))}:void 0,role:d?"button":void 0,tabIndex:d?0:void 0,style:d?{cursor:"pointer"}:void 0,children:i(J)},J.key))}),O&&e.jsx("div",{className:"nice-card-group__error",role:"alert",children:O})]})});const Y=e.jsxs("div",{ref:I,className:ae,style:{display:"grid",gridTemplateColumns:A,gridAutoRows:ne,gap:E,alignItems:W,position:_?"relative":void 0,...j},role:te?"radiogroup":void 0,"aria-label":te?v:void 0,"aria-disabled":f||void 0,"aria-busy":_||void 0,"data-testid":k??w,children:[t,_&&e.jsx("span",{className:"nice-card-group__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),O&&!x&&e.jsx("div",{className:"nice-card-group__error",role:"alert",style:{gridColumn:"1 / -1"},children:O})]}),F=O&&x&&e.jsx("div",{className:"nice-card-group__error",role:"alert",children:O});return e.jsxs(Be.NiceCardGroupSizeContext.Provider,{value:u,children:[te?e.jsx(Be.NiceCardRadioContext.Provider,{value:B,children:Y}):Y,F]})}),{displayName:"NiceCardGroup"}),Kp={color:!0,description:!0,volume:!0,gain:!0},Ys=s.forwardRef(function(n,i){const{t:a}=c.useNiceTranslation(),{children:r,name:o,description:l,defaultDescription:d,onDescriptionChange:u,labelPlacement:m="bottom",number:h,color:p="transparent",onColorChange:y,volume:x,defaultVolume:b,onVolumeChange:g,gain:v,defaultGain:f,onGainChange:C,contextMenu:_=!0,quickControls:T,onOpenConfig:S,fullConfigLabel:N=a("deviceTile.fullConfiguration","Full configuration"),selected:j,onClick:w,focusId:k,className:I,style:M,title:z,"data-testid":R}=n,A={...Kp,...T},E=s.useRef(null),$=G=>{E.current=G,typeof i=="function"?i(G):i&&(i.current=G)},O=E;c.useSpatialFocusable(O,{id:k??"",onActivate:w,disabled:!k});const[V,K]=c.useControllableState({value:l,defaultValue:d,fallbackValue:"",onChange:u,componentName:"NiceDeviceTile"}),[te,B]=c.useControllableState({value:x,defaultValue:b,fallbackValue:80,onChange:g,componentName:"NiceDeviceTile"}),[W,ne]=c.useControllableState({value:v,defaultValue:f,fallbackValue:50,onChange:C,componentName:"NiceDeviceTile"}),ae=c.useSpatialNavOptional(),[Y,F]=s.useState(null),J=s.useRef(null);c.useClickOutside(J,()=>F(null)),s.useEffect(()=>{if(Y)return ae?.pauseNavigation(),()=>{ae?.resumeNavigation()}},[Y,ae]),c.useOverlayFocus(J,{open:Y!=null,modal:!1,onClose:()=>F(null)});const re=G=>{if(!_)return;G.preventDefault();let{clientX:ge,clientY:Ce}=G;if(ge===0&&Ce===0){const H=G.currentTarget.getBoundingClientRect();ge=H.left,Ce=H.bottom}const he=Math.min(ge,window.innerWidth-256),L=Math.min(Ce,window.innerHeight-320);F({x:Math.max(8,he),y:Math.max(8,L)})},se=p!=="transparent"&&p!=="";return e.jsxs("div",{ref:$,className:["nice-device-tile",`nice-device-tile--label-${m}`,j?"nice-device-tile--selected":"",se?"nice-device-tile--colored":"",I??""].filter(Boolean).join(" "),style:{...M,"--device-color":p},title:z,"data-testid":R,onClick:w,onKeyDown:w?G=>{G.target===G.currentTarget&&(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),G.currentTarget.click())}:void 0,onContextMenu:re,role:w?"button":void 0,tabIndex:k||w?0:void 0,children:[e.jsxs("div",{className:"nice-device-tile__device",children:[h!=null&&e.jsx("span",{className:"nice-device-tile__badge",children:h}),r]}),(o||V)&&e.jsxs("div",{className:"nice-device-tile__caption",children:[o&&e.jsx("span",{className:"nice-device-tile__name",children:o}),V&&e.jsx("span",{className:"nice-device-tile__description",children:V})]}),Y&&e.jsx("div",{ref:J,className:"nice-device-tile__menu",style:{position:"fixed",left:Y.x,top:Y.y},role:"dialog","aria-label":o,children:e.jsxs("div",{style:{display:"contents"},onClick:G=>G.stopPropagation(),onKeyDown:G=>{G.key!=="Escape"&&G.stopPropagation()},children:[o&&e.jsx("div",{className:"nice-device-tile__menu-title",children:o}),A.color&&e.jsxs("div",{className:"nice-device-tile__menu-row",children:[e.jsx("span",{className:"nice-device-tile__menu-label",children:a("deviceTile.color","Color")}),e.jsx(Hn.NiceColorPicker,{compact:!0,value:se?p:"#3b82f6",onChange:G=>y?.(G)})]}),A.description&&e.jsxs("div",{className:"nice-device-tile__menu-row nice-device-tile__menu-row--stack",children:[e.jsx("span",{className:"nice-device-tile__menu-label",children:a("deviceTile.description","Description")}),e.jsx(Ye.NiceTextInput,{value:V,onChange:G=>K(G),size:"sm"})]}),A.volume&&e.jsxs("div",{className:"nice-device-tile__menu-row",children:[e.jsx("span",{className:"nice-device-tile__menu-label",children:a("deviceTile.volume","Volume")}),e.jsx(it.NiceSlider,{value:te,onChange:G=>B(G),min:0,max:100})]}),A.gain&&e.jsxs("div",{className:"nice-device-tile__menu-row",children:[e.jsx("span",{className:"nice-device-tile__menu-label",children:a("deviceTile.gain","Gain")}),e.jsx(it.NiceSlider,{value:W,onChange:G=>ne(G),min:0,max:100})]}),S&&e.jsx(Le.NiceButton,{size:"sm",variant:"outline",className:"nice-device-tile__menu-config",onClick:()=>{F(null),S()},children:N})]})})]})}),Yp={xxs:20,xs:24,sm:32,md:40,lg:56,xl:72,xxl:96},ca=15,ni=18,la=6,Ri=30,Bc=({level:t=0,size:n="md",muted:i=!1,...a})=>{const{t:r}=c.useNiceTranslation(),l=`nice-mic-clip-${c.useControlId()}`,d=typeof n=="number"?n:Yp[n]??40,u=Math.max(0,Math.min(1,t)),m=la+(1-u)*Ri,h=u*Ri;return e.jsx(Ys,{...a,children:e.jsxs("svg",{className:`nice-microphone${i?" nice-microphone--muted":""}`,width:d,height:d*(64/48),viewBox:"0 0 48 64",role:"img","aria-label":a.name?r("microphone.microphone","Microphone: {name}").replace("{name}",String(a.name)):r("microphone.microphone2","Microphone"),children:[e.jsx("defs",{children:e.jsx("clipPath",{id:l,children:e.jsx("rect",{x:ca,y:la,width:ni,height:Ri,rx:ni/2})})}),e.jsxs("g",{clipPath:`url(#${l})`,children:[e.jsx("rect",{x:ca,y:la,width:ni,height:Ri,className:"nice-microphone__body"}),h>0&&e.jsx("rect",{x:ca,y:m,width:ni,height:h,className:"nice-microphone__level"})]}),e.jsx("rect",{x:ca,y:la,width:ni,height:Ri,rx:ni/2,className:"nice-microphone__outline"}),e.jsx("path",{d:"M10 30 a14 14 0 0 0 28 0",className:"nice-microphone__stand"}),e.jsx("line",{x1:"24",y1:"44",x2:"24",y2:"56",className:"nice-microphone__stand"}),e.jsx("line",{x1:"16",y1:"56",x2:"32",y2:"56",className:"nice-microphone__stand"}),i&&e.jsx("line",{x1:"9",y1:"9",x2:"39",y2:"49",className:"nice-microphone__slash"})]})})},Jp={xxs:22,xs:28,sm:36,md:48,lg:64,xl:84,xxl:110},Qp=[{id:"LT",shape:{kind:"rect",x:18,y:3,w:16,h:5,rx:2},label:[26,1]},{id:"RT",shape:{kind:"rect",x:66,y:3,w:16,h:5,rx:2},label:[74,1]},{id:"LB",shape:{kind:"rect",x:18,y:10,w:16,h:5,rx:2},label:[26,9]},{id:"RB",shape:{kind:"rect",x:66,y:10,w:16,h:5,rx:2},label:[74,9]},{id:"DpadUp",shape:{kind:"rect",x:25,y:26,w:5,h:6,rx:1},label:[27,24]},{id:"DpadDown",shape:{kind:"rect",x:25,y:38,w:5,h:6,rx:1},label:[27,50]},{id:"DpadLeft",shape:{kind:"rect",x:18,y:32,w:6,h:5,rx:1},label:[16,35]},{id:"DpadRight",shape:{kind:"rect",x:31,y:32,w:6,h:5,rx:1},label:[40,35]},{id:"Y",shape:{kind:"circle",cx:74,cy:25,r:4},label:[74,19]},{id:"A",shape:{kind:"circle",cx:74,cy:41,r:4},label:[74,51]},{id:"X",shape:{kind:"circle",cx:66,cy:33,r:4},label:[58,35]},{id:"B",shape:{kind:"circle",cx:82,cy:33,r:4},label:[90,35]},{id:"Back",shape:{kind:"circle",cx:44,cy:26,r:2.6},label:[44,20]},{id:"Start",shape:{kind:"circle",cx:56,cy:26,r:2.6},label:[56,20]},{id:"LS",shape:{kind:"circle",cx:42,cy:42,r:6},label:[42,54]},{id:"RS",shape:{kind:"circle",cx:60,cy:44,r:6},label:[60,56]}],Xp="M50 18 C66 18 72 20 76 26 L90 48 C94 58 86 64 80 58 L66 46 L34 46 L20 58 C14 64 6 58 10 48 L24 26 C28 20 34 18 50 18 Z";function Zp({shape:t}){return t.kind==="circle"?e.jsx("circle",{cx:t.cx,cy:t.cy,r:t.r}):e.jsx("rect",{x:t.x,y:t.y,width:t.w,height:t.h,rx:t.rx??1})}const Fc=({view:t="compact",size:n="md",onButtonPress:i,pressedButtons:a,highlightedButtons:r,live:o=!1,gamepadIndex:l=0,buttonLabels:d,actionTree:u,assignments:m,onAssign:h,...p})=>{const{t:y}=c.useNiceTranslation(),x=typeof n=="number"?n:Jp[n]??48,[b,g]=s.useState(()=>new Set),[v,f]=s.useState(null);c.useGamepad({index:l,enabled:o,onButtonDown:M=>{g(z=>{const R=new Set(z);return R.add(M),R}),i?.(M)},onButtonUp:M=>{g(z=>{const R=new Set(z);return R.delete(M),R})}});const C=M=>!!r?.includes(M)||!!a?.includes(M)||b.has(M),_=x*1.5,T=_*(68/100),S=(M,z)=>{M.stopPropagation(),i?.(z),u&&f(R=>R===z?null:z)},N=t==="compact",j=!N&&(!!i||!!u),w=s.useRef(null);c.useRovingFocus(w,{orientation:"grid",itemSelector:".nice-gamepad__btn",enabled:j});const k=e.jsxs("svg",{className:`nice-gamepad nice-gamepad--${t}${j?" nice-gamepad--interactive":""}`,width:_,height:T,viewBox:"0 0 100 68",role:j?"group":"img","aria-label":p.name?y("gamepad.gamepad","Gamepad: {name}").replace("{name}",String(p.name)):y("gamepad.gamepad2","Gamepad"),children:[e.jsx("path",{d:Xp,className:"nice-gamepad__body"}),!N&&Qp.map(({id:M,shape:z,label:R})=>{const A=d?.[M]??m?.[M];return e.jsxs("g",{"data-button":M,"data-pressed":C(M)?"true":void 0,className:`nice-gamepad__btn${v===M?" nice-gamepad__btn--armed":""}`,role:j?"button":void 0,"aria-label":j?A?`${M} ${A}`:M:void 0,"aria-pressed":j&&u?v===M:void 0,onClick:E=>S(E,M),onKeyDown:E=>{j&&(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),S(E,M))},children:[e.jsx(Zp,{shape:z}),A&&e.jsx("text",{x:R[0],y:R[1],className:"nice-gamepad__label",children:A})]},M)})]}),I=j?e.jsx("div",{ref:w,className:"nice-gamepad__pad",children:k}):k;return e.jsx(Ys,{...p,children:u&&!N?e.jsxs("div",{className:"nice-gamepad__assign",children:[I,e.jsxs("div",{className:"nice-gamepad__tree",children:[e.jsx("div",{className:"nice-gamepad__tree-hint",children:v?y("gamepad.assignTo",'Assign to "{armed}"…').replace("{armed}",String(v)):y("gamepad.clickAButtonThenA","Click a button, then a node")}),e.jsx(yt.NiceTreeView,{nodes:u,selectionMode:"single",onNodeClick:M=>{v&&(h?.(v,M),f(null))}})]})]}):I})},em=[],tm=({devices:t,defaultDevices:n,onDevicesChange:i,autoDetect:a=!0,kinds:r=["microphone","gamepad"],slots:o,onAssign:l,onOpenConfig:d,columns:u,minColumnWidth:m=160,className:h,style:p,id:y,"data-testid":x})=>{const{t:b}=c.useNiceTranslation(),[g,v]=c.useControllableState({value:t,defaultValue:n,fallbackValue:em,onChange:i,componentName:"NiceDeviceManager"}),f=s.useCallback(N=>{N.length!==0&&v(j=>{const w=new Set(j.map(I=>I.id)),k=N.filter(I=>!w.has(I.id));return k.length?[...j,...k]:j})},[v]);s.useEffect(()=>{if(!a||!r.includes("microphone")||!navigator.mediaDevices?.enumerateDevices)return;let N=!1;const j=()=>{navigator.mediaDevices.enumerateDevices().then(w=>{if(N)return;const k=w.filter(I=>I.kind==="audioinput").map((I,M)=>({id:`mic:${I.deviceId||M}`,kind:"microphone",name:I.label||`Microphone ${M+1}`,deviceId:I.deviceId}));f(k)}).catch(()=>{})};return j(),navigator.mediaDevices.addEventListener?.("devicechange",j),()=>{N=!0,navigator.mediaDevices.removeEventListener?.("devicechange",j)}},[a,r,f]);const C=c.useConnectedGamepads(),_=a&&r.includes("gamepad");s.useEffect(()=>{_&&f(C.map(N=>({id:`pad:${N.index}`,kind:"gamepad",name:N.id.split("(")[0]?.trim()||`Controller ${N.index+1}`,deviceId:String(N.index)})))},[_,C,f]);const T=s.useCallback((N,j)=>{v(w=>w.map(k=>k.id===N?{...k,...j}:k))},[v]),S=s.useCallback((N,j)=>{T(N,{assignedTo:j}),l?.(N,j)},[T,l]);return e.jsx("div",{id:y,"data-testid":x,className:`nice-device-manager ${h??""}`.trim(),style:p,children:g.length===0?e.jsx("p",{className:"nice-device-manager__empty",children:b("deviceManager.noDevicesDetected","No devices detected.")}):e.jsx(Lc,{columns:u,minColumnWidth:m,gap:12,children:g.map((N,j)=>{const w={name:N.name,description:N.description,number:N.number??j+1,color:N.color??"transparent",volume:N.volume,gain:N.gain,onColorChange:k=>T(N.id,{color:k}),onDescriptionChange:k=>T(N.id,{description:k}),onVolumeChange:k=>T(N.id,{volume:k}),onGainChange:k=>T(N.id,{gain:k}),onOpenConfig:()=>d?.(N)};return e.jsxs("div",{className:"nice-device-manager__cell",children:[N.kind==="microphone"?e.jsx(Bc,{...w,level:N.level}):e.jsx(Fc,{...w,view:"compact",live:!0}),o&&o.length>0&&e.jsx("div",{className:"nice-device-manager__slots",children:o.map(k=>e.jsx(Le.NiceButton,{size:"sm",variant:N.assignedTo===k.id?"primary":"ghost",onClick:()=>S(N.id,N.assignedTo===k.id?null:k.id),children:k.label},k.id))})]},N.id)})})})},nm=[];function Zr(t,n){const i=t.getBoundingClientRect(),a=n.getBoundingClientRect(),r=getComputedStyle(t),o=parseFloat(r.borderLeftWidth)||0,l=parseFloat(r.borderTopWidth)||0;return{width:a.width,height:a.height,left:0,top:0,transform:`translate(${a.left-i.left-o}px, ${a.top-i.top-l}px)`,opacity:1}}function tn({options:t=nm,value:n,defaultValue:i,onChange:a,size:r="md",block:o=!1,disabled:l=!1,readOnly:d=!1,loading:u=!1,error:m,highlightFill:h=!0,errorPlacement:p="bottom",className:y="",style:x,"data-testid":b="nice-segmented-control"}){const{t:g}=c.useNiceTranslation(),v=s.useRef(null),[f,C]=s.useState(i),[_,T]=s.useState({}),S=n!==void 0?n:f,N=t.findIndex(k=>k.value===S);s.useEffect(()=>{if(!v.current||N<0){T({opacity:0});return}const k=v.current,M=k.querySelectorAll(".nice-segmented-control__option")[N];if(!M){T({opacity:0});return}T(Zr(k,M))},[N,t.length,h,r,o]),s.useEffect(()=>{const k=()=>{if(!v.current||N<0)return;const I=v.current,z=I.querySelectorAll(".nice-segmented-control__option")[N];z&&T(Zr(I,z))};return window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)},[N]);const j=s.useCallback(k=>{l||d||u||t.find(M=>M.value===k)?.disabled||(n===void 0&&C(k),a?.(k))},[l,d,u,t,n,a]);c.useRovingFocus(v,{orientation:"both",wrap:!0,activateOnMove:!0});const w=e.jsxs("div",{ref:v,className:`nice-segmented-control nice-segmented-control--${r} ${o?"nice-segmented-control--block":""} ${l?"nice-segmented-control--disabled":""} ${d?"nice-segmented-control--readonly":""} ${u?"nice-segmented-control--loading":""} ${m?"nice-segmented-control--error":""} ${h?"nice-segmented-control--fill":""} ${y}`,style:x,role:"radiogroup","aria-label":g("controls.select","Select option"),"aria-busy":u||void 0,"aria-invalid":!!m||void 0,"data-testid":b,children:[e.jsx("div",{className:"nice-segmented-control__thumb",style:_}),t.map((k,I)=>{const M=k.value===S,z=l||k.disabled;return e.jsxs("button",{type:"button",className:`nice-segmented-control__option ${M?"nice-segmented-control__option--selected":""} ${z?"nice-segmented-control__option--disabled":""}`,onClick:()=>j(k.value),disabled:z||u,role:"radio","aria-checked":M,"data-testid":`${b}-option-${I}`,children:[k.icon&&e.jsx("span",{className:"nice-segmented-control__icon",children:k.icon}),e.jsx("span",{className:"nice-segmented-control__label",children:k.label})]},String(k.value))}),u&&e.jsx("div",{className:"nice-segmented-control__spinner","aria-hidden":"true",children:e.jsx("div",{className:"nice-spinner nice-spinner--sm"})})]});return m?e.jsxs("div",{className:`nice-segmented-control-field${p==="right"?" nice-segmented-control-field--err-right":""}`,children:[w,e.jsx("div",{className:"nice-segmented-control__error",role:"alert",children:m})]}):w}process.env.NODE_ENV!=="production"&&(tn.displayName="NiceSegmentedControl");const im=["gamepad","hints","navigation","bindings"],am=["activate","back","secondary","tertiary","menu","view","sectionPrev","sectionNext","pagePrev","pageNext","first","last","toggleHints"],es={navigate:"Move",activate:"Select",back:"Back",secondary:"Options",tertiary:"More",menu:"Menu",view:"Switch area",sectionPrev:"Previous section",sectionNext:"Next section",pagePrev:"Previous page",pageNext:"Next page",first:"First",last:"Last",scroll:"Scroll",toggleHints:"Show or hide hints"},sm=Object.assign(function({sections:n=im,className:i,style:a,id:r,"data-testid":o}){const{t:l}=c.useNiceTranslation(),[d,u]=c.useInputPreferences(),[m,h]=s.useState(null);s.useEffect(()=>{if(!(!m||typeof window>"u"))return c.getInputEngine().captureNextInput(g=>{m.device==="gamepad"&&g.button?u({gamepadBindings:{...d.gamepadBindings,[m.intent]:[g.button]}}):m.device==="keyboard"&&g.keys&&u({keyboardBindings:{...d.keyboardBindings,[m.intent]:[g.keys]}}),h(null)})},[m,d.gamepadBindings,d.keyboardBindings,u]);const p=(g,v)=>u({[g]:v}),y=l("inputSettings.auto","Automatic"),x=g=>{const{[g]:v,...f}=d.gamepadBindings,{[g]:C,..._}=d.keyboardBindings;u({gamepadBindings:f,keyboardBindings:_})},b=g=>{switch(g){case"gamepad":return e.jsxs("section",{className:"nice-input-settings__section",children:[e.jsx("h3",{className:"nice-input-settings__title",children:l("inputSettings.section.gamepad","Gamepad")}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:l("inputSettings.confirmButton","Confirm with")}),e.jsx(tn,{value:d.confirmButton,onChange:v=>p("confirmButton",v),options:[{value:"auto",label:y},{value:"south",label:l("input.pad.bottomButton","Bottom button")},{value:"east",label:l("input.pad.rightButton","Right button")}]})]}),e.jsx(Ut.NiceSelect,{label:l("inputSettings.glyphFamily","Button symbols"),value:d.glyphFamily,onChange:v=>p("glyphFamily",v),options:[{value:"auto",label:y},{value:"xbox",label:"Xbox"},{value:"playstation",label:"PlayStation"},{value:"nintendo",label:"Nintendo"},{value:"steam",label:"Steam"},{value:"generic",label:l("inputSettings.family.generic","Generic")}]}),e.jsx(it.NiceSlider,{label:l("inputSettings.stickThreshold","Stick push needed to move"),min:.2,max:.9,step:.05,value:d.stickThreshold,onChange:v=>p("stickThreshold",v),showValue:!0}),e.jsx(it.NiceSlider,{label:l("inputSettings.repeatDelay","Repeat after (ms)"),min:200,max:800,step:20,value:d.repeatDelay,onChange:v=>p("repeatDelay",v),showValue:!0}),e.jsx(it.NiceSlider,{label:l("inputSettings.repeatInterval","Repeat every (ms)"),min:50,max:250,step:10,value:d.repeatInterval,onChange:v=>p("repeatInterval",v),showValue:!0}),e.jsx(Ht.NiceToggle,{label:l("inputSettings.invertScroll","Invert scrolling with the right stick"),checked:d.invertScroll,onChange:v=>p("invertScroll",v)}),e.jsx(Ht.NiceToggle,{label:l("inputSettings.vibration","Vibration"),checked:d.vibration,onChange:v=>p("vibration",v)})]},g);case"hints":return e.jsxs("section",{className:"nice-input-settings__section",children:[e.jsx("h3",{className:"nice-input-settings__title",children:l("inputSettings.section.hints","Button hints")}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:l("inputSettings.hints","Show hints")}),e.jsx(tn,{value:d.hints,onChange:v=>p("hints",v),options:[{value:"auto",label:l("inputSettings.hints.auto","With keyboard or pad")},{value:"always",label:l("inputSettings.always","Always")},{value:"never",label:l("inputSettings.never","Never")}]})]}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:l("inputSettings.hintDensity","Where")}),e.jsx(tn,{value:d.hintDensity,onChange:v=>p("hintDensity",v),options:[{value:"bar",label:l("inputSettings.density.bar","Hint bar")},{value:"bar-and-controls",label:l("inputSettings.density.barAndControls","Bar and controls")}]})]})]},g);case"navigation":return e.jsxs("section",{className:"nice-input-settings__section",children:[e.jsx("h3",{className:"nice-input-settings__title",children:l("inputSettings.section.navigation","Navigation")}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:l("inputSettings.arrowNavigation","Arrow keys outside lists")}),e.jsx(tn,{value:d.arrowNavigation,onChange:v=>p("arrowNavigation",v),options:[{value:"auto",label:l("inputSettings.arrows.auto","Depends on the area")},{value:"spatial",label:l("inputSettings.arrows.spatial","Move focus")},{value:"native",label:l("inputSettings.arrows.native","Scroll")}]})]}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:l("inputSettings.onScreenKeyboard","On-screen keyboard")}),e.jsx(tn,{value:d.onScreenKeyboard,onChange:v=>p("onScreenKeyboard",v),options:[{value:"auto",label:l("inputSettings.osk.auto","With a pad")},{value:"always",label:l("inputSettings.always","Always")},{value:"never",label:l("inputSettings.never","Never")}]})]})]},g);default:return e.jsxs("section",{className:"nice-input-settings__section",children:[e.jsx("h3",{className:"nice-input-settings__title",children:l("inputSettings.section.bindings","Buttons and keys")}),e.jsxs("table",{className:"nice-input-settings__bindings",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:l("inputSettings.actionColumn","Action")}),e.jsx("th",{scope:"col",children:l("inputSettings.gamepadColumn","Gamepad")}),e.jsx("th",{scope:"col",children:l("inputSettings.keyboardColumn","Keyboard")}),e.jsx("th",{scope:"col",children:e.jsx("span",{className:"nice-sr-only",children:l("inputSettings.reset","Reset")})})]})}),e.jsx("tbody",{children:am.map(v=>{const f=_=>m?.intent===v&&m.device===_,C=(d.keyboardBindings[v]??c.NICE_DEFAULT_KEYBOARD_BINDINGS[v])[0];return e.jsxs("tr",{children:[e.jsx("th",{scope:"row",className:"nice-input-settings__action",children:l(`input.intent.${v}`,es[v])}),e.jsx("td",{children:e.jsx(Le.NiceButton,{size:"sm",variant:"ghost",onClick:()=>h({intent:v,device:"gamepad"}),"aria-label":`${l("inputSettings.change","Change")}: ${l(`input.intent.${v}`,es[v])}`,children:f("gamepad")?l("inputSettings.pressButton","Press a button…"):e.jsx(c.NiceButtonPrompt,{intent:v,device:"gamepad",size:"sm"})})}),e.jsx("td",{children:e.jsx(Le.NiceButton,{size:"sm",variant:"ghost",onClick:()=>h({intent:v,device:"keyboard"}),"aria-label":`${l("inputSettings.change","Change")}: ${l(`input.intent.${v}`,es[v])}`,children:f("keyboard")?l("inputSettings.pressKey","Press a key…"):C?e.jsx(c.NiceKeyCap,{keys:C,size:"sm"}):l("inputSettings.none","None")})}),e.jsx("td",{children:e.jsx(Le.NiceButton,{size:"sm",variant:"ghost",onClick:()=>x(v),children:l("inputSettings.reset","Reset")})})]},v)})})]}),e.jsxs("div",{className:"nice-input-settings__actions",children:[m&&e.jsx(Le.NiceButton,{size:"sm",onClick:()=>h(null),children:l("inputSettings.cancel","Cancel")}),e.jsx(Le.NiceButton,{size:"sm",variant:"secondary",onClick:()=>u({gamepadBindings:{},keyboardBindings:{}}),children:l("inputSettings.resetAll","Reset all bindings")})]})]},g)}};return e.jsx("div",{id:r,"data-testid":o,className:`nice-input-settings${i?` ${i}`:""}`,style:a,children:n.map(b)})},{displayName:"NiceInputSettings"}),Ta=({value:t,max:n=100,label:i,helperText:a,error:r,required:o,disabled:l,loading:d,showValue:u=!0,text:m,variant:h="primary",size:p="md",striped:y,animated:x,formatValue:b,labelPlacement:g="top",errorPlacement:v="bottom",labelWidth:f,controlWidth:C,className:_,style:T,id:S})=>{const N=c.useControlId(S),j=Math.min(100,Math.max(0,t/n*100)),w=m??(b?b(t,n):`${Math.round(j)}%`),k=u,I=i?e.jsxs("label",{className:"nice-field__label",htmlFor:N,children:[i,o&&e.jsx("span",{className:"nice-field__required",children:"*"})]}):null,M=r?e.jsx("div",{id:`${N}-error`,className:"nice-field__error",role:"alert",children:r}):null,z=!r&&a?e.jsx("div",{id:`${N}-helper`,className:"nice-field__helper",children:a}):null,R=e.jsxs("div",{className:`nice-progress ${l?"nice-progress--disabled":""} ${d?"nice-progress--loading":""}`,role:"progressbar",id:N,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":n,"aria-busy":d||void 0,"aria-disabled":l||void 0,children:[e.jsx("div",{className:`nice-progress__track ${p!=="md"?`nice-progress__track--${p}`:""}`,children:e.jsx("div",{className:`nice-progress__fill nice-progress__fill--${h} ${y||d?"nice-progress__fill--striped":""} ${x||d?"nice-progress__fill--animated":""}`,style:{width:d?"100%":`${j}%`}})}),k&&(g==="left"||g==="right")&&e.jsx("span",{className:"nice-progress__value",children:w})]}),A=e.jsxs("div",{className:"nice-progress__header",children:[I,k&&e.jsx("span",{className:"nice-progress__value",children:w})]});return e.jsxs("div",{className:`nice-field nice-field--${p} nice-field--progress ${g==="left"?"nice-field--label-left":""} ${_||""}`,style:{...T,...f!=null&&{"--nice-field-label-width":typeof f=="number"?`${f}px`:f},...C!=null&&{"--nice-field-control-width":typeof C=="number"?`${C}px`:C}},children:[g==="top"&&(k?A:I),g==="left"||g==="right"?e.jsxs("div",{className:"nice-field__control",style:{display:"flex",alignItems:"center",gap:"var(--nice-space-2, 8px)",flex:"1 1 auto"},children:[g==="right"?e.jsxs(e.Fragment,{children:[R,I]}):e.jsxs(e.Fragment,{children:[I,R]}),v==="right"&&M,v==="right"&&!r&&z]}):e.jsx("div",{className:"nice-field__control",children:R}),g==="bottom"&&(k?A:I),v!=="right"&&M,v!=="right"&&z]})},Aa=({vertical:t,text:n,size:i="md",className:a,style:r,testId:o,"data-testid":l})=>t?e.jsx("hr",{className:`nice-divider nice-divider--vertical nice-divider--${i} ${a||""}`,style:r,"data-testid":l??o}):n?e.jsx("div",{className:`nice-divider--with-text nice-divider--${i} ${a||""}`,style:r,"data-testid":l??o,children:n}):e.jsx("hr",{className:`nice-divider nice-divider--${i} ${a||""}`,style:r,"data-testid":l??o}),eo=t=>typeof t=="number"?t:/^\d+(\.\d+)?$/.test(t.trim())?`${t}px`:t,rm={text:14,rect:80,circle:40},om={xxs:{text:6,rect:28,circle:16},xs:{text:8,rect:40,circle:24},sm:{text:11,rect:60,circle:32},small:{text:11,rect:60,circle:32},md:{text:14,rect:80,circle:40},medium:{text:14,rect:80,circle:40},lg:{text:20,rect:120,circle:56},large:{text:20,rect:120,circle:56},xl:{text:28,rect:160,circle:72},xxl:{text:36,rect:220,circle:96}},Hi=({variant:t="text",width:n,height:i,count:a=1,size:r="md",orientation:o="vertical",animationSpeed:l,className:d,style:u,testId:m,"data-testid":h})=>{const p=om[r]??rm,y=eo(n??(t==="circle"?p.circle:"100%")),x=eo(i??(t==="text"?p.text:t==="circle"?p.circle:p.rect)),b=l!=null&&l>0?{"--nice-skeleton-speed":`${l}s`}:null;if(a<=1)return e.jsx("div",{className:`nice-skeleton nice-skeleton--${t} nice-skeleton--${r} ${d||""}`,style:{width:y,height:x,...b,...u},"data-testid":h??m});const g=o==="horizontal";return e.jsx("div",{className:`nice-skeleton-group ${d||""}`,style:{display:"flex",flexDirection:g?"row":"column",gap:"var(--nice-space-2, 8px)",width:"100%",...b,...u},"data-testid":h??m,children:Array.from({length:a}).map((v,f)=>e.jsx("div",{className:`nice-skeleton nice-skeleton--${t} nice-skeleton--${r}`,style:g?{flex:"1 1 0",minWidth:0,height:x}:{width:y,height:x}},f))})},Js=({icon:t,title:n,description:i,action:a,size:r="md",className:o,style:l,testId:d,"data-testid":u})=>e.jsxs("div",{className:`nice-empty nice-empty--${r} ${o||""}`,style:l,"data-testid":u??d,role:"status","aria-label":n,children:[t&&e.jsx("div",{className:"nice-empty__icon","aria-hidden":"true",children:t}),e.jsx("div",{className:"nice-empty__title",children:n}),i&&e.jsx("div",{className:"nice-empty__desc",children:i}),a]}),cm=[],to={xxs:9,xs:11,sm:13,small:13,md:16,medium:16,lg:20,large:20,xl:24,xxl:28},Vc=Object.assign(s.forwardRef(({items:t=cm,mode:n="left",size:i="md",isFragment:a=!1,renderItem:r,className:o,style:l,id:d,testId:u,"data-testid":m,...h},p)=>{const{renderIcon:y}=c.useNiceIcon(),x=to[i]??to.md;return e.jsx("div",{ref:p,id:d,className:`nice-timeline nice-timeline--${n} nice-timeline--${i} ${a?"nice-timeline--fragment":""} ${o||""}`,style:l,"data-testid":m??u,...h,children:t.map((b,g)=>{const v=n==="alternate"?g%2===0?"left":"right":n;return e.jsxs("div",{className:`nice-timeline__item nice-timeline__item--${v}`,children:[e.jsx("div",{className:"nice-timeline__dot",style:b.color?{borderColor:b.color,color:b.color}:void 0,children:y(b.icon,x)??e.jsx("span",{className:"nice-timeline__dot-inner",style:b.color?{background:b.color}:void 0})}),a&&g===0&&e.jsx("div",{className:"nice-timeline__connector nice-timeline__connector--leading"}),(g<t.length-1||a)&&e.jsx("div",{className:"nice-timeline__connector"}),e.jsx("div",{className:"nice-timeline__content",children:r?r(b,g):e.jsxs(e.Fragment,{children:[b.title&&e.jsx("div",{className:"nice-timeline__title",children:b.title}),b.subtitle&&e.jsx("div",{className:"nice-timeline__subtitle",children:b.subtitle}),b.content&&e.jsx("div",{className:"nice-timeline__body",children:b.content})]})})]},b.key)})})}),{displayName:"NiceTimeline"}),lm=[],qc=Object.assign(s.forwardRef(({items:t=lm,visibleCount:n=1,showArrows:i=!0,showDots:a=!0,autoPlay:r=7e3,circular:o=!0,activeIndex:l,onChange:d,size:u="md",fullWidth:m=!0,className:h,style:p,id:y,testId:x,"data-testid":b,...g},v)=>{const{t:f}=c.useNiceTranslation(),[C,_]=s.useState(0),T=s.useRef(void 0),N=l!=null&&typeof d=="function"?l:C,j=Math.max(1,Math.floor(n||1)),w=Math.max(0,t.length-j),k=s.useCallback(F=>{let J=F;o?J=(F%t.length+t.length)%t.length:J=Math.max(0,Math.min(w,F)),_(J),d?.(J)},[t.length,w,o,d]),I=s.useCallback(()=>k(N+1),[k,N]),M=s.useCallback(()=>k(N-1),[k,N]),[z,R]=s.useState(!1),[A,E]=s.useState(!1),[$,O]=s.useState(!1),V=r>0&&!$&&!z&&!A;s.useEffect(()=>{if(V)return T.current=setInterval(I,r),()=>clearInterval(T.current)},[V,r,I]);const K=o||N>0,te=o||N<w,B=s.useRef(null);s.useEffect(()=>{const F=B.current?.children;F&&Array.from(F).forEach((J,re)=>{J.toggleAttribute("inert",re<N||re>=N+j)})},[N,j,t.length]);const W=s.useRef(null),ne=s.useCallback(F=>{W.current=F,typeof v=="function"?v(F):v&&(v.current=F)},[v]);c.useIntent(["sectionPrev","sectionNext"],F=>{if(F.intent==="sectionNext"?!te:!K)return!1;F.intent==="sectionNext"?I():M()},{ref:W,enabled:t.length>j}),c.useInputHints(W,[{intent:"sectionPrev",label:f("carousel.prev","Previous slide")},{intent:"sectionNext",label:f("carousel.next","Next slide")}],{enabled:t.length>j});const ae=s.useCallback(F=>{F.target===F.currentTarget&&(F.key==="ArrowLeft"&&K?(F.preventDefault(),M()):F.key==="ArrowRight"&&te?(F.preventDefault(),I()):F.key==="Home"?(F.preventDefault(),k(0)):F.key==="End"&&(F.preventDefault(),k(w)))},[M,I,k,K,te,w]),Y=s.useRef(null);return c.useRovingFocus(Y,{orientation:"horizontal",activateOnMove:!0}),e.jsxs("div",{ref:ne,id:y,className:`nice-carousel nice-carousel--${u} ${m?"nice-carousel--full-width":""} ${h||""}`,style:p,"data-testid":b??x,role:"region","aria-roledescription":"carousel","aria-label":f("carousel.label","Carousel"),tabIndex:0,onKeyDown:ae,onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),onFocus:()=>E(!0),onBlur:F=>{F.currentTarget.contains(F.relatedTarget)||E(!1)},...g,children:[r>0&&e.jsx("button",{type:"button",className:"nice-carousel__rotation",onClick:()=>O(F=>!F),"aria-label":$?f("carousel.startRotation","Start automatic slide show"):f("carousel.stopRotation","Stop automatic slide show"),children:e.jsx(c.NiceIcon,{name:$?"play":"pause",size:16})}),e.jsx("div",{className:"nice-carousel__viewport","aria-live":V?"off":"polite",children:e.jsx("div",{ref:B,className:"nice-carousel__track",style:{transform:`translateX(-${N*(100/j)}%)`,"--nice-carousel-slide-basis":`${100/j}%`},children:t.map((F,J)=>e.jsx("div",{className:"nice-carousel__slide",role:"group","aria-roledescription":"slide","aria-label":`${J+1} / ${t.length}`,children:F},J))})}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-carousel__arrow nice-carousel__arrow--prev",onClick:M,disabled:!K,"aria-label":f("carousel.prev","Previous"),children:e.jsx(c.NiceIcon,{name:"chevron-left",size:20})}),e.jsx("button",{type:"button",className:"nice-carousel__arrow nice-carousel__arrow--next",onClick:I,disabled:!te,"aria-label":f("carousel.next","Next"),children:e.jsx(c.NiceIcon,{name:"chevron-right",size:20})})]}),a&&t.length>j&&e.jsx("div",{className:"nice-carousel__dots",role:"tablist",ref:Y,children:Array.from({length:w+1},(F,J)=>e.jsx("button",{type:"button",className:`nice-carousel__dot ${J===N?"nice-carousel__dot--active":""}`,onClick:()=>k(J),role:"tab","aria-selected":J===N,"aria-label":`${f("carousel.goTo","Go to slide")} ${J+1}`},J))})]})}),{displayName:"NiceCarousel"}),dm=[];function um({items:t=dm,itemHeight:n,height:i=400,overscan:a=3,renderItem:r,itemKey:o,className:l,style:d,size:u="md",disabled:m,readOnly:h,loading:p,error:y,testId:x,"data-testid":b,...g},v){const f=s.useRef(null),[C,_]=s.useState(0),T=typeof i=="number"?i:parseFloat(String(i)),S=Number.isFinite(T)?T:400,N=Number.isFinite(n)&&n>0?n:1,j=Number.isFinite(a)&&a>=0?Math.floor(a):0,w=t.length*N,{startIndex:k,endIndex:I}=s.useMemo(()=>{const R=Math.max(1,Math.ceil(S/N)),A=Math.floor(C/N),E=Math.max(0,A-j),$=Math.min(t.length-1,A+R+j);return{startIndex:E,endIndex:$}},[C,S,N,t.length,j]),M=s.useCallback(R=>{_(R.currentTarget.scrollTop)},[]);s.useEffect(()=>{v&&(typeof v=="function"?v(f.current):v.current=f.current)},[v]);const z=s.useMemo(()=>{const R=[];for(let A=k;A<=I;A++){const E=o?o(t[A],A):A;R.push(e.jsx("div",{className:"nice-virtual-scroller__item",style:{position:"absolute",top:A*N,left:0,right:0,height:N},children:r(t[A],A)},E))}return R},[k,I,t,N,r,o]);return e.jsxs("div",{ref:f,className:`nice-virtual-scroller nice-virtual-scroller--${u} ${m?"nice-virtual-scroller--disabled":""} ${y?"nice-virtual-scroller--error":""} ${l||""}`,style:{width:"100%",...d,height:typeof i=="string"&&!/^\d+(\.\d+)?$/.test(i)?i:S,overflow:"auto",position:"relative"},onScroll:M,role:"list","aria-disabled":m||void 0,"aria-busy":p||void 0,"data-testid":b??x,...g,children:[y?e.jsx("div",{className:"nice-virtual-scroller__error",role:"alert",children:y}):e.jsx("div",{style:{height:w,position:"relative",width:"100%"},children:z}),p&&e.jsx("div",{className:"nice-virtual-scroller__loading","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})}const Uc=Object.assign(s.forwardRef(um),{displayName:"NiceVirtualScroller"}),pm=[],Hc=s.createContext(null);function Ha(){const t=s.useContext(Hc);if(!t)throw new Error("useFAQ must be used within NiceFAQ");return t}function da(t,n){if(!n)return{score:1,indices:[]};const i=t.toLowerCase(),r=n.toLowerCase().split(/\s+/).filter(Boolean);let o=0;const l=[];for(const u of r){let m=!1,h=0;for(;(h=i.indexOf(u,h))!==-1;){m=!0,l.push([h,h+u.length]);const p=h===0||/\s/.test(t[h-1]),y=h+u.length===t.length||/\s/.test(t[h+u.length]);p&&y?o+=2:p?o+=1.5:o+=1,h+=1}if(!m){let p=0,y=-1;for(let x=0;x<i.length&&p<u.length;x++)if(i[x]===u[p]){if(y===-1||x===y+1)if(y===-1)l.push([x,x+1]);else{const b=l[l.length-1];b[1]=x+1}else l.push([x,x+1]);y=x,p++}if(p===u.length)o+=.5;else return null}}const d=mm(l);return{score:o/r.length,indices:d}}function mm(t){if(t.length===0)return[];const n=[...t].sort((a,r)=>a[0]-r[0]),i=[n[0]];for(let a=1;a<n.length;a++){const r=i[i.length-1],o=n[a];o[0]<=r[1]?r[1]=Math.max(r[1],o[1]):i.push(o)}return i}function hm(t,n){if(!n.trim())return t.map(a=>({item:a,score:1,matches:[]}));const i=[];for(const a of t){const r=[];let o=0;const l=da(a.question,n);if(l&&l.score>0&&(r.push({field:"question",indices:l.indices}),o+=l.score*3),typeof a.answer=="string"){const d=da(a.answer,n);d&&d.score>0&&(r.push({field:"answer",indices:d.indices}),o+=d.score*1)}if(a.tags)for(const d of a.tags){const u=da(d,n);if(u&&u.score>0){r.push({field:"tags",indices:u.indices}),o+=u.score*2;break}}if(a.keywords)for(const d of a.keywords){const u=da(d,n);if(u&&u.score>0){r.push({field:"keywords",indices:u.indices}),o+=u.score*2.5;break}}r.length>0&&(a.featured&&(o*=1.2),i.push({item:a,score:o,matches:r}))}return i.sort((a,r)=>r.score-a.score)}const gm=({text:t,indices:n})=>{if(n.length===0)return e.jsx(e.Fragment,{children:t});const i=[];let a=0;for(const[r,o]of n)r>a&&i.push(e.jsx("span",{children:t.slice(a,r)},`text-${a}`)),i.push(e.jsx("mark",{className:"nice-faq-highlight",children:t.slice(r,o)},`mark-${r}`)),a=o;return a<t.length&&i.push(e.jsx("span",{children:t.slice(a)},`text-${a}`)),e.jsx(e.Fragment,{children:i})},Gc=({placeholder:t,autoFocus:n=!1,showIcon:i=!0,debounceMs:a=200})=>{const{t:r}=c.useNiceTranslation(),o=t??r("faq.searchFaqPlaceholder","Search FAQ..."),{searchQuery:l,setSearchQuery:d}=Ha(),[u,m]=s.useState(l),h=s.useRef(null),p=s.useRef(null);s.useEffect(()=>(p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{d(u)},a),()=>{p.current&&clearTimeout(p.current)}),[u,a,d]);const y=s.useCallback(()=>{m(""),d(""),h.current?.focus()},[d]);return e.jsxs("div",{className:"nice-faq-search",children:[i&&e.jsx("span",{className:"nice-faq-search-icon",children:e.jsx(c.NiceIcon,{name:"search",size:16})}),e.jsx("input",{ref:h,type:"text",className:"nice-faq-search-input",placeholder:o,value:u,onChange:x=>m(x.target.value),autoFocus:n,"aria-label":r("faq.searchFaq","Search FAQ")}),u&&e.jsx("button",{className:"nice-faq-search-clear",onClick:y,"aria-label":r("faq.clearSearch","Clear search"),children:e.jsx(c.NiceIcon,{name:"close",size:14})})]})},Wc=({showCounts:t=!0,layout:n="horizontal"})=>{const{t:i}=c.useNiceTranslation(),{categories:a,items:r,selectedCategory:o,setSelectedCategory:l}=Ha(),d=s.useMemo(()=>{const u={all:r.length};for(const m of r)m.category&&(u[m.category]=(u[m.category]||0)+1);return u},[r]);return a.length===0?null:n==="dropdown"?e.jsx("div",{className:"nice-faq-category-dropdown",children:e.jsxs("select",{value:o||"all",onChange:u=>l(u.target.value==="all"?null:u.target.value),className:"nice-faq-category-select",children:[e.jsxs("option",{value:"all",children:[i("faq.allCategories","All Categories")," ",t&&`(${d.all})`]}),a.map(u=>e.jsxs("option",{value:u.id,children:[u.name," ",t&&`(${d[u.id]||0})`]},u.id))]})}):e.jsxs("div",{className:`nice-faq-categories nice-faq-categories--${n}`,children:[e.jsxs("button",{className:`nice-faq-category-btn ${o?"":"nice-faq-category-btn--active"}`,onClick:()=>l(null),children:[e.jsx("span",{children:i("faq.all","All")}),t&&e.jsx("span",{className:"nice-faq-category-count",children:d.all})]}),a.map(u=>e.jsxs("button",{className:`nice-faq-category-btn ${o===u.id?"nice-faq-category-btn--active":""}`,onClick:()=>l(u.id),style:u.color?{"--cat-color":u.color}:void 0,children:[u.icon&&e.jsx("span",{className:"nice-faq-category-icon",children:u.icon}),e.jsx("span",{children:u.name}),t&&e.jsx("span",{className:"nice-faq-category-count",children:d[u.id]||0})]},u.id))]})},Qs=({result:t,showFeedback:n=!0,showRelated:i=!0,animateExpand:a=!0})=>{const{t:r}=c.useNiceTranslation(),{item:o,matches:l}=t,{expandedIds:d,toggleExpanded:u,items:m,submitFeedback:h}=Ha(),[p,y]=s.useState(null),[x,b]=s.useState(!1),[g,v]=s.useState(""),f=s.useRef(null),C=d.has(o.id);s.useEffect(()=>{f.current?.toggleAttribute("inert",!C)},[C]);const _=l.find(j=>j.field==="question")?.indices||[],T=s.useMemo(()=>!i||!o.relatedIds||o.relatedIds.length===0?[]:m.filter(j=>o.relatedIds?.includes(j.id)),[i,o.relatedIds,m]),S=j=>{y(j),j?h(o.id,j):b(!0)},N=()=>{h(o.id,!1,g),b(!1),v("")};return e.jsxs("div",{className:`nice-faq-item ${C?"nice-faq-item--expanded":""} ${o.featured?"nice-faq-item--featured":""}`,"data-question-id":o.id,children:[e.jsxs("button",{className:"nice-faq-question",onClick:()=>u(o.id),"aria-expanded":C,"aria-controls":`faq-answer-${o.id}`,children:[o.icon&&e.jsx("span",{className:"nice-faq-question-icon",children:o.icon}),e.jsx("span",{className:"nice-faq-question-text",children:e.jsx(gm,{text:o.question,indices:_})}),e.jsx("span",{className:`nice-faq-chevron ${C?"nice-faq-chevron--open":""}`,children:e.jsx(c.NiceIcon,{name:"chevron-down",size:16})})]}),e.jsx("div",{id:`faq-answer-${o.id}`,className:`nice-faq-answer ${a?"nice-faq-answer--animated":""}`,ref:f,style:{maxHeight:C?a?f.current?.scrollHeight??1e3:void 0:0},"aria-hidden":!C,children:e.jsxs("div",{className:"nice-faq-answer-content",children:[typeof o.answer=="string"?e.jsx("p",{children:o.answer}):o.answer,o.tags&&o.tags.length>0&&e.jsx("div",{className:"nice-faq-tags",children:o.tags.map(j=>e.jsx("span",{className:"nice-faq-tag",children:j},j))}),T.length>0&&e.jsxs("div",{className:"nice-faq-related",children:[e.jsx("span",{className:"nice-faq-related-label",children:r("faq.related","Related:")}),T.map(j=>e.jsx("button",{className:"nice-faq-related-link",onClick:w=>{w.stopPropagation(),u(j.id),document.querySelector(`[data-question-id="${j.id}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})},children:j.question},j.id))]}),n&&e.jsxs("div",{className:"nice-faq-feedback",children:[p===null?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-faq-feedback-label",children:r("faq.wasThisHelpful","Was this helpful?")}),e.jsxs("button",{className:"nice-faq-feedback-btn nice-faq-feedback-btn--yes",onClick:()=>S(!0),"aria-label":r("faq.yesThisWasHelpful","Yes, this was helpful"),children:[e.jsx(c.NiceIcon,{name:"check",size:14})," ",r("faq.yes","Yes")]}),e.jsxs("button",{className:"nice-faq-feedback-btn nice-faq-feedback-btn--no",onClick:()=>S(!1),"aria-label":r("faq.noThisWasNotHelpful","No, this was not helpful"),children:[e.jsx(c.NiceIcon,{name:"close",size:14})," ",r("faq.no","No")]})]}):e.jsx("span",{className:"nice-faq-feedback-thanks",children:p?r("faq.thanksForYourFeedback","Thanks for your feedback!"):""}),x&&e.jsxs("div",{className:"nice-faq-feedback-form",children:[e.jsx("textarea",{placeholder:r("faq.howCanWeImproveThis","How can we improve this answer?"),value:g,onChange:j=>v(j.target.value),className:"nice-faq-feedback-textarea",rows:3}),e.jsxs("div",{className:"nice-faq-feedback-actions",children:[e.jsx("button",{className:"nice-faq-feedback-submit",onClick:N,children:r("faq.submit","Submit")}),e.jsx("button",{className:"nice-faq-feedback-cancel",onClick:()=>{b(!1),y(null)},children:r("faq.cancel","Cancel")})]})]})]})]})})]})},Is=({category:t,results:n,showFeedback:i,showRelated:a,collapsible:r=!0})=>{const{t:o}=c.useNiceTranslation(),[l,d]=s.useState(!1),u=s.useId();return n.length===0?null:e.jsxs("div",{className:"nice-faq-group",children:[e.jsxs("div",{className:`nice-faq-group-header ${r?"nice-faq-group-header--collapsible":""}`,role:"presentation",onClick:r?()=>d(!l):void 0,style:t.color?{borderColor:t.color}:void 0,children:[t.icon&&e.jsx("span",{className:"nice-faq-group-icon",children:t.icon}),e.jsx("h3",{className:"nice-faq-group-title",children:t.name}),t.description&&e.jsx("p",{className:"nice-faq-group-desc",children:t.description}),e.jsx("span",{className:"nice-faq-group-count",children:n.length}),r&&e.jsx("button",{type:"button",className:`nice-faq-group-chevron ${l?"":"nice-faq-group-chevron--open"}`,"aria-expanded":!l,"aria-controls":l?void 0:u,"aria-label":`${l?o("faq.expandGroup","Expand"):o("faq.collapseGroup","Collapse")}: ${t.name}`,onClick:m=>{m.stopPropagation(),d(!l)},children:e.jsx(c.NiceIcon,{name:"chevron-down",size:16})})]}),!l&&e.jsx("div",{id:u,className:"nice-faq-group-items",children:n.map(m=>e.jsx(Qs,{result:m,showFeedback:i,showRelated:a},m.item.id))})]})},fm=({items:t=pm,categories:n=[],showSearch:i=!0,searchPlaceholder:a,autoFocusSearch:r=!1,showCategories:o=!0,categoryLayout:l="horizontal",groupByCategory:d=!0,allowMultiple:u=!0,defaultExpanded:m=[],showFeedback:h=!0,showRelated:p=!0,onFeedback:y,onAnalytics:x,showExpandControls:b=!0,animateExpand:g=!0,emptyMessage:v,generateSchema:f=!0,header:C,footer:_,size:T="md",className:S,style:N,testId:j,"data-testid":w})=>{const{t:k}=c.useNiceTranslation(),I=a??k("faq.searchFrequentlyAskedQuestions","Search frequently asked questions..."),M=v??k("faq.noQuestionsFoundMatchingYour","No questions found matching your search."),[z,R]=s.useState(new Set(m)),[A,E]=s.useState(""),[$,O]=s.useState(null),V=s.useMemo(()=>[...t].sort((se,G)=>se.featured&&!G.featured?-1:!se.featured&&G.featured?1:(se.order??999)-(G.order??999)),[t]),K=s.useMemo(()=>$?V.filter(se=>se.category===$):V,[V,$]),te=s.useMemo(()=>hm(K,A),[K,A]),B=s.useMemo(()=>{if(!d||n.length===0)return null;const se={},G=[];for(const ge of te){const Ce=ge.item.category;Ce?(se[Ce]||(se[Ce]=[]),se[Ce].push(ge)):G.push(ge)}return{groups:se,uncategorized:G}},[d,n,te]),W=s.useCallback(se=>{R(G=>{const ge=new Set(G);return ge.has(se)?(ge.delete(se),x?.({type:"collapse",questionId:se,timestamp:new Date().toISOString()})):(u||ge.clear(),ge.add(se),x?.({type:"expand",questionId:se,timestamp:new Date().toISOString()})),ge})},[u,x]),ne=s.useCallback(()=>{R(new Set(t.map(se=>se.id)))},[t]),ae=s.useCallback(()=>{R(new Set)},[]),Y=s.useCallback(se=>{E(se),se.trim()&&x?.({type:"search",searchQuery:se,timestamp:new Date().toISOString()})},[x]),F=s.useCallback((se,G,ge)=>{const Ce={questionId:se,helpful:G,comment:ge,timestamp:new Date().toISOString()};y?.(Ce),x?.({type:"feedback",questionId:se,timestamp:Ce.timestamp,metadata:{helpful:G,comment:ge}})},[y,x]),J=s.useMemo(()=>{if(!f)return null;const se={"@context":"https://schema.org","@type":"FAQPage",mainEntity:t.map(G=>({"@type":"Question",name:G.question,acceptedAnswer:{"@type":"Answer",text:typeof G.answer=="string"?G.answer:""}}))};return e.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(se)}})},[f,t]),re={items:V,categories:n,expandedIds:z,searchQuery:A,selectedCategory:$,toggleExpanded:W,expandAll:ne,collapseAll:ae,setSearchQuery:Y,setSelectedCategory:O,submitFeedback:F};return e.jsx(Hc.Provider,{value:re,children:e.jsxs("div",{className:`nice-faq nice-faq--${T} ${S||""}`,style:N,"data-testid":w??j,children:[J,C&&e.jsx("div",{className:"nice-faq-header",children:C}),e.jsxs("div",{className:"nice-faq-controls",children:[i&&e.jsx(Gc,{placeholder:I,autoFocus:r}),o&&n.length>0&&e.jsx(Wc,{layout:l,showCounts:!0}),b&&e.jsxs("div",{className:"nice-faq-expand-controls",children:[e.jsx("button",{className:"nice-faq-expand-btn",onClick:ne,children:k("faq.expandAll","Expand All")}),e.jsx("button",{className:"nice-faq-expand-btn",onClick:ae,children:k("faq.collapseAll","Collapse All")})]})]}),A&&e.jsx("div",{className:"nice-faq-results-info",children:(te.length===1?k("faq.foundOneResult",'Found 1 result for "{query}"'):k("faq.foundResults",'Found {count} results for "{query}"')).replace("{count}",String(te.length)).replace("{query}",A)}),e.jsx("div",{className:"nice-faq-list",children:te.length===0?e.jsx("div",{className:"nice-faq-empty",children:typeof M=="string"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-faq-empty-icon",children:e.jsx(c.NiceIcon,{name:"search",size:32})}),e.jsx("p",{children:M})]}):M}):B?e.jsxs(e.Fragment,{children:[n.sort((se,G)=>(se.order??999)-(G.order??999)).map(se=>e.jsx(Is,{category:se,results:B.groups[se.id]||[],showFeedback:h,showRelated:p},se.id)),B.uncategorized.length>0&&e.jsx(Is,{category:{id:"other",name:"Other Questions"},results:B.uncategorized,showFeedback:h,showRelated:p})]}):te.map(se=>e.jsx(Qs,{result:se,showFeedback:h,showRelated:p,animateExpand:g},se.item.id))}),_&&e.jsx("div",{className:"nice-faq-footer",children:_})]})})},bm=[];function ts(t,n){return n.split(".").reduce((i,a)=>{if(i&&typeof i=="object")return i[a]},t)}const xm=({status:t})=>{const{t:n}=c.useNiceTranslation(),a={connecting:{color:"var(--nice-color-warning, #f59e0b)",label:n("liveGrid.connecting","Connecting...")},connected:{color:"var(--nice-color-success, #22c55e)",label:n("liveGrid.live","Live")},disconnected:{color:"var(--nice-text-muted, #6b7280)",label:n("liveGrid.disconnected","Disconnected")},error:{color:"var(--nice-color-error, #ef4444)",label:n("error","Error")}}[t];return e.jsxs("div",{className:"nice-live-grid-status",children:[e.jsx("span",{className:"nice-live-grid-status-dot",style:{backgroundColor:a.color}}),e.jsx("span",{className:"nice-live-grid-status-label",children:a.label})]})};function vm({columns:t=bm,data:n=[],dataSource:i,rowKey:a="id",showConnectionStatus:r=!0,highlightDuration:o=2e3,updateAnimation:l="flash",maxRows:d,selectable:u=!1,selectedIds:m,onSelectionChange:h,onRowClick:p,onUpdate:y,onConnectionStatusChange:x,emptyContent:b,loadingContent:g,sortable:v=!1,sortField:f,sortDirection:C,onSortChange:_,virtualized:T=!1,rowHeight:S=40,height:N=400,className:j="",style:w,"data-testid":k},I){const{t:M}=c.useNiceTranslation(),[z,R]=s.useState(n),[A,E]=s.useState(!1),[$,O]=s.useState("disconnected"),[V,K]=s.useState(new Map),[te,B]=s.useState(m||new Set),W=s.useRef(null),ne=s.useRef(null),ae=s.useRef(new Map),Y=m??te,F=h??B,J=s.useCallback(D=>D[a],[a]),re=s.useCallback((D,ee,le=[])=>{K(de=>{const oe=new Map(de);return oe.set(D,{operation:ee,changedFields:new Set(le),timestamp:Date.now()}),oe});const ue=ae.current.get(D);ue&&clearTimeout(ue);const me=setTimeout(()=>{K(de=>{const oe=new Map(de);return oe.delete(D),oe}),ae.current.delete(D)},o);ae.current.set(D,me)},[o]),se=s.useCallback(D=>{const ee=J(D.row);if(R(le=>{switch(D.operation){case"insert":{if(le.some(de=>J(de)===ee))return le;const me=[D.row,...le];return d&&me.length>d?me.slice(0,d):me}case"update":return le.map(ue=>J(ue)===ee?{...ue,...D.row,...D.changes||{}}:ue);case"upsert":{if(le.some(de=>J(de)===ee))return le.map(de=>J(de)===ee?{...de,...D.row,...D.changes||{}}:de);const me=[D.row,...le];return d&&me.length>d?me.slice(0,d):me}case"delete":return le.filter(ue=>J(ue)!==ee);default:return le}}),l!=="none"){const le=D.changes?Object.keys(D.changes):[];re(ee,D.operation,le)}y?.(D)},[J,d,l,re,y]),G=s.useCallback(D=>{"updates"in D?D.fullRefresh?R(D.updates.map(ee=>ee.row)):D.updates.forEach(se):se(D)},[se]);s.useEffect(()=>{if(!i)return;i.fetchInitial&&(E(!0),i.fetchInitial().then(ee=>{R(ee),E(!1)})),ne.current=i.subscribe(G);let D;return i.onStatusChange?D=i.onStatusChange(ee=>{O(ee),x?.(ee)}):(O("connected"),x?.("connected")),()=>{ne.current?.(),D?.()}},[i,G,x]),s.useEffect(()=>{const D=ae.current;return()=>{D.forEach(ee=>clearTimeout(ee))}},[]),s.useImperativeHandle(I,()=>({getData:()=>z,addRow:D=>se({operation:"insert",row:D}),updateRow:(D,ee)=>{const le=z.find(ue=>J(ue)===D);le&&se({operation:"update",row:le,changes:ee})},deleteRow:D=>{const ee=z.find(le=>J(le)===D);ee&&se({operation:"delete",row:ee})},refresh:()=>{i?.fetchInitial&&(E(!0),i.fetchInitial().then(D=>{R(D),E(!1)}))},getConnectionStatus:()=>$}));const ge=s.useMemo(()=>!f||!C?z:[...z].sort((D,ee)=>{const le=ts(D,f),ue=ts(ee,f);if(le===ue)return 0;if(le==null)return 1;if(ue==null)return-1;const me=le<ue?-1:1;return C==="asc"?me:-me}),[z,f,C]),Ce=s.useCallback((D,ee)=>{if(u){const le=J(D),ue=new Set(Y);ue.has(le)?ue.delete(le):ue.add(le),F(ue)}p?.(D,ee)},[u,J,Y,F,p]),he=s.useCallback(D=>{if(!v)return;let ee="asc";f===D&&(ee=C==="asc"?"desc":"asc"),_?.(D,ee)},[v,f,C,_]),L=s.useCallback(D=>{const ee=J(D),le=V.get(ee),ue=Y.has(ee),me=["nice-live-grid-row"];return ue&&me.push("nice-live-grid-row--selected"),le&&(me.push(`nice-live-grid-row--${le.operation}`),me.push(`nice-live-grid-row--${l}`)),me.join(" ")},[J,V,Y,l]),H=s.useCallback((D,ee)=>{const le=J(D);return V.get(le)?.changedFields.has(ee)?"nice-live-grid-cell--changed":""},[J,V]);return A&&z.length===0?e.jsx("div",{className:`nice-live-grid nice-live-grid--loading ${j}`,style:w,"data-testid":k,children:g===void 0?M("loading","Loading…"):g}):e.jsxs("div",{ref:W,className:`nice-live-grid ${j}`,style:{...w,height:N},"data-testid":k,children:[r&&e.jsxs("div",{className:"nice-live-grid-header",children:[e.jsx(xm,{status:$}),e.jsx("span",{className:"nice-live-grid-count",children:M("liveGrid.rows","{count} rows").replace("{count}",String(z.length))})]}),e.jsx("div",{className:"nice-live-grid-table-wrapper",children:e.jsxs("table",{className:"nice-live-grid-table",children:[e.jsx("thead",{children:e.jsx("tr",{children:t.map(D=>e.jsxs("th",{className:`nice-live-grid-th ${v&&D.sortable!==!1?"nice-live-grid-th--sortable":""}`,style:{width:D.width,minWidth:D.minWidth,maxWidth:D.maxWidth,textAlign:D.align||"left"},onClick:()=>D.sortable!==!1&&he(String(D.field)),children:[D.headerRender?D.headerRender(D):D.header,f===String(D.field)&&e.jsx("span",{className:"nice-live-grid-sort-icon",children:e.jsx(c.NiceIcon,{name:C==="asc"?"sort-asc":"sort-desc",size:12})})]},String(D.field)))})}),e.jsx("tbody",{children:ge.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:t.length,className:"nice-live-grid-empty",children:b===void 0?M("noData","No data"):b})}):ge.map(D=>e.jsx("tr",{className:L(D),onClick:ee=>Ce(D,ee),style:{height:S},children:t.map(ee=>{const le=ts(D,String(ee.field));return e.jsx("td",{className:`nice-live-grid-td ${H(D,String(ee.field))}`,style:{textAlign:ee.align||"left"},children:ee.render?ee.render(le,D,ee):String(le??"")},String(ee.field))})},String(J(D))))})]})})]})}const ym=Object.assign(s.forwardRef(vm),{displayName:"NiceLiveDataGrid"}),Kc=s.createContext(null);function Yc(){return s.useContext(Kc)}const Nm=5;function _m(t,n,i,a){if(n.button!==0)return;const r=n.currentTarget,o=n.pointerId,l=n.clientX,d=n.clientY;let u=!1,m={x:l,y:d};try{r.setPointerCapture?.(o)}catch{}const h=g=>{if(g.pointerId===o){if(m={x:g.clientX,y:g.clientY},!u){if(Math.hypot(g.clientX-l,g.clientY-d)<Nm)return;u=!0}g.preventDefault(),t.setGhost({label:a,x:g.clientX,y:g.clientY}),t.emit({type:"move",payload:i,x:g.clientX,y:g.clientY})}},p=g=>{if(r.removeEventListener("pointermove",h),r.removeEventListener("pointerup",y),r.removeEventListener("pointercancel",x),r.removeEventListener("keydown",b),u){t.setGhost(null),t.emit({type:"end",payload:i,x:m.x,y:m.y,commit:g});const v=f=>{f.stopPropagation(),f.preventDefault()};r.addEventListener("click",v,{capture:!0,once:!0}),window.setTimeout(()=>r.removeEventListener("click",v,{capture:!0}),0)}},y=g=>{g.pointerId===o&&p(!0)},x=g=>{g.pointerId===o&&p(!1)},b=g=>{g.key==="Escape"&&u&&(g.preventDefault(),p(!1))};r.addEventListener("pointermove",h),r.addEventListener("pointerup",y),r.addEventListener("pointercancel",x),r.addEventListener("keydown",b)}const jm=({children:t})=>{const n=s.useRef(new Set),[i,a]=s.useState(null),r=s.useMemo(()=>({subscribe:o=>(n.current.add(o),()=>{n.current.delete(o)}),emit:o=>{n.current.forEach(l=>l(o))},setGhost:a}),[]);return e.jsxs(Kc.Provider,{value:r,children:[t,i&&e.jsx("div",{className:"nice-sortable-tree__ghost","aria-hidden":"true",style:{left:i.x,top:i.y},children:i.label})]})};function vi(t){return{key:t?.keyField??"id",children:t?.childrenField??"children"}}function fi(t,n){return String(t[n])}function bi(t,n){const i=t[n];return Array.isArray(i)?i:void 0}function no(t,n,i){return{...t,[n]:i}}function Zt(t,n,i){const a=vi(i),r=(o,l,d)=>{o.forEach((u,m)=>{const h={node:u,parent:l,parentId:l===null?null:fi(l,a.key),index:m,siblings:o,ancestors:d,depth:d.length};if(n(u,h)===!1)return;const p=bi(u,a.children);p?.length&&r(p,u,[...d,u])})};r(t,null,[])}function Et(t,n,i){const a=vi(i),r=(o,l,d)=>{for(let u=0;u<o.length;u++){const m=o[u];if(fi(m,a.key)===n)return{node:m,parent:l,parentId:l===null?null:fi(l,a.key),index:u,siblings:o,ancestors:d,depth:d.length};const h=bi(m,a.children);if(h?.length){const p=r(h,m,[...d,m]);if(p)return p}}};return r(t,null,[])}function Vn(t,n,i){return Et(t,n,i)?.node}function Xs(t,n,i,a){const r=vi(a);return!!Et(t,n,a)?.ancestors.some(l=>fi(l,r.key)===i)}function Ji(t,n){const i=vi(n),a=bi(t,i.children);return a?.length?1+Math.max(...a.map(r=>Ji(r,n))):1}function Zs(t,n,i,a){const r=vi(a);if(n===null)return i(t);let o=!1;const l=d=>{let u=null;for(let m=0;m<d.length&&!o;m++){const h=d[m];let p=null;if(fi(h,r.key)===n)p=no(h,r.children,i(bi(h,r.children)??[])),o=!0;else{const y=bi(h,r.children),x=y?.length?l(y):null;x&&(p=no(h,r.children,x))}p&&(u=u??[...d],u[m]=p)}return u};return l(t)??[...t]}function In(t,n,i,a){return i.parentId!==null&&!Vn(t,i.parentId,a)?t:Zs(t,i.parentId,r=>{const o=[...r];return o.splice(Math.max(0,Math.min(i.index,o.length)),0,n),o},a)}function Wn(t,n,i){const a=Et(t,n,i);return a?Zs(t,a.parentId,r=>r.filter((o,l)=>l!==a.index),i):t}function Zi(t,n,i,a){const r=Et(t,n,a);if(!r)return t;const o=typeof i=="function"?i(r.node):{...r.node,...i};return Zs(t,r.parentId,l=>l.map((d,u)=>u===r.index?o:d),a)}function yi(t,n,i,a){const r=Et(t,n,a);if(!r||i.parentId!==null&&(i.parentId===n||Xs(t,i.parentId,n,a)||!Vn(t,i.parentId,a)))return t;let o=i.index;if(r.parentId===i.parentId&&(o>r.index&&(o-=1),o=Math.max(0,Math.min(o,r.siblings.length-1)),o===r.index))return t;const l=Wn(t,n,a);return In(l,r.node,{parentId:i.parentId,index:o},a)}function Ra(t,n,i,a){const r=Et(t,n,a);if(!r)return t;const o=Math.max(0,Math.min(r.index+i,r.siblings.length-1));return o===r.index?t:yi(t,n,{parentId:r.parentId,index:o>r.index?o+1:o},a)}function er(t,n,i){const a=vi(i),r=Et(t,n,i);if(!r||r.index===0)return t;const o=r.siblings[r.index-1];return yi(t,n,{parentId:fi(o,a.key),index:bi(o,a.children)?.length??0},i)}function tr(t,n,i){const a=Et(t,n,i);if(!a||a.parentId===null)return t;const r=Et(t,a.parentId,i);return r?yi(t,n,{parentId:r.parentId,index:r.index+1},i):t}const wm=[],km=["moveUp","moveDown","indent","outdent","rename","remove"],Cm=5,io=28,Sm=600,Tm=16,Em=10;function Im(t){const{value:n,defaultValue:i,onChange:a,keyField:r="id",childrenField:o="children",labelField:l="label",getLabel:d,renderLabel:u,getIcon:m,renderRowEnd:h,selectedId:p,defaultSelectedId:y,onSelect:x,collapsedIds:b,defaultCollapsedIds:g,onCollapsedChange:v,canHaveChildren:f,canDrag:C,canDrop:_,maxDepth:T,editable:S=!1,removable:N=!1,actions:j=!0,contextMenuItems:w,onExternalDrop:k,emptyText:I,"aria-label":M,height:z,size:R="md",readOnly:A=!1,disabled:E=!1,className:$,style:O,id:V,title:K,accessMode:te,"data-testid":B}=t,{t:W}=c.useNiceTranslation(),ne=c.useNiceAccessMode(te,V),ae=E||ne==="disabled",Y=A||ne==="readOnly"||ae,F=s.useMemo(()=>({keyField:r,childrenField:o}),[r,o]),[J,re]=c.useControllableState({value:n,defaultValue:i,fallbackValue:[],componentName:"NiceSortableTree"}),[se,G]=c.useControllableState({value:p,defaultValue:y,fallbackValue:null,componentName:"NiceSortableTree"}),[ge,Ce]=c.useControllableState({value:b,defaultValue:g,fallbackValue:wm,componentName:"NiceSortableTree"}),he=s.useCallback(ce=>String(ce[r]),[r]),L=s.useCallback(ce=>{const Ie=ce[o];return Array.isArray(Ie)?Ie:[]},[o]),H=s.useCallback(ce=>{if(d)return d(ce);const Ie=ce[l];return Ie==null?he(ce):String(Ie)},[d,l,he]),D=(ce,Ie)=>!Y&&(typeof ce=="function"?ce(Ie):ce),ee=s.useCallback(ce=>f?f(ce):!0,[f]),le=s.useMemo(()=>new Set(ge),[ge]),ue=s.useMemo(()=>{const ce=[];return Zt(J,(Ie,Ve)=>{const Ke=he(Ie),nt=L(Ie).length>0,gt=nt&&!le.has(Ke);return ce.push({node:Ie,id:Ke,depth:Ve.depth,parentId:Ve.parentId,index:Ve.index,setSize:Ve.siblings.length,hasChildren:nt,expanded:gt}),gt?void 0:!1},F),ce},[J,le,he,L,F]),me=s.useMemo(()=>new Map(ue.map(ce=>[ce.id,ce])),[ue]),de=s.useRef(null),oe=s.useRef(null),[ie,Te]=s.useState(""),X=s.useRef(null),je=s.useCallback(ce=>{Ce(ce),v?.(ce)},[Ce,v]),Z=s.useCallback((ce,Ie)=>{const Ve=ge.includes(ce);Ie&&Ve?je(ge.filter(Ke=>Ke!==ce)):!Ie&&!Ve&&je([...ge,ce])},[ge,je]),ve=s.useCallback(ce=>{G(ce),x?.(ce,ce===null?null:Vn(J,ce,F)??null)},[G,x,J,F]);c.useTreeFocus(oe,{onToggle:(ce,Ie)=>{const Ve=ce.dataset.nodeId;Ve!==void 0&&Z(Ve,Ie)}});const U=ce=>{const Ie=Et(J,ce,F);return Ie?{parentId:Ie.parentId,index:Ie.index}:null},ye=(ce,Ie)=>{const Ve=Et(ce,Ie,F);if(!Ve)return;const Ke=Ve.parent?H(Ve.parent):W("sortableTree.root","top level");Te(W("sortableTree.announceMoved","{label} moved to {parent}, position {position} of {count}").replace("{label}",H(Ve.node)).replace("{parent}",Ke).replace("{position}",String(Ve.index+1)).replace("{count}",String(Ve.siblings.length)))},Ne=(ce,Ie)=>ce===J?!1:(re(ce),a?.(ce,Ie),!0),ze=(ce,Ie,Ve,Ke)=>{let nt=0;if(Ie.parentId!==null){if(ce!==null&&(Ie.parentId===ce||Xs(J,Ie.parentId,ce,F)))return!1;const gt=Et(J,Ie.parentId,F);if(!gt||!ee(gt.node))return!1;nt=gt.depth+1}return T!==void 0&&nt+Ve>T?!1:_?_(ce,Ie,Ke):!0},P=(ce,Ie,Ve,Ke)=>{const nt=U(ce);if(!nt)return;const gt=Vn(J,ce,F);if(!gt||!ze(ce,Ie,Ji(gt,F)))return;const tt=Et(Ke,ce,F),vt=tt?{parentId:tt.parentId,index:tt.index}:Ie;Ne(Ke,{type:Ve,id:ce,from:nt,to:vt})&&(X.current=ce,vt.parentId!==null&&Z(vt.parentId,!0),ye(Ke,ce))},q=(ce,Ie)=>{const Ve=Ra(J,ce,Ie,F),Ke=Et(Ve,ce,F);Ke&&P(ce,{parentId:Ke.parentId,index:Ke.index},"move",Ve)},Q=ce=>{const Ie=er(J,ce,F),Ve=Et(Ie,ce,F);Ve&&Ie!==J&&P(ce,{parentId:Ve.parentId,index:Ve.index},"indent",Ie)},be=ce=>{const Ie=tr(J,ce,F),Ve=Et(Ie,ce,F);Ve&&Ie!==J&&P(ce,{parentId:Ve.parentId,index:Ve.index},"outdent",Ie)},Re=ce=>{const Ie=U(ce);if(!Ie)return;const Ve=ue.findIndex(ft=>ft.id===ce),Ke=new Set,nt=Vn(J,ce,F);nt&&Zt([nt],ft=>{Ke.add(he(ft))},F);const gt=ue.slice(Ve+1).find(ft=>!Ke.has(ft.id)),tt=ue.slice(0,Math.max(0,Ve)).reverse().find(ft=>!Ke.has(ft.id)),vt=gt?.id??tt?.id??null;Ne(Wn(J,ce,F),{type:"remove",id:ce,from:Ie})&&(se!==null&&Ke.has(se)&&ve(vt),X.current=vt,Te(W("sortableTree.announceRemoved","{label} removed").replace("{label}",nt?H(nt):ce)))},[Se,_e]=s.useState(null),Fe=s.useRef(null);s.useEffect(()=>{Se!==null&&(Fe.current?.focus(),Fe.current?.select())},[Se]);const qe=(ce,Ie)=>{_e(null),X.current=ce;const Ve=Vn(J,ce,F),Ke=Ie?.trim();!Ve||!Ke||Ke===H(Ve)||Ne(Zi(J,ce,{[l]:Ke},F),{type:"rename",id:ce,label:Ke})};s.useLayoutEffect(()=>{const ce=X.current;if(ce===null||Se!==null)return;X.current=null;const Ie=[...oe.current?.querySelectorAll("[data-node-id]")??[]].find(Ve=>Ve.dataset.nodeId===ce);Ie&&(Ie.focus(),Ie.scrollIntoView?.({block:"nearest"}))});const et=(ce,Ie)=>{const Ve=oe.current;if(!Ve)return null;const Ke=[...Ve.querySelectorAll("[data-node-id]")];if(Ke.length===0)return{target:{parentId:null,index:0},line:null,insideId:null,invalid:!1};const nt=Ke[0],gt=Ke[Ke.length-1],tt=(vt,ft,bt)=>({top:ft==="top"?vt.offsetTop:vt.offsetTop+vt.offsetHeight,depth:bt});if(ce<nt.getBoundingClientRect().top){const vt=me.get(nt.dataset.nodeId??"");return vt&&!Ie.has(vt.id)?{target:{parentId:null,index:0},line:tt(nt,"top",0),insideId:null,invalid:!1}:null}for(const vt of Ke){const ft=vt.getBoundingClientRect();if(ce<ft.top||ce>=ft.bottom)continue;const bt=me.get(vt.dataset.nodeId??"");if(!bt||Ie.has(bt.id))return null;const qt=(ce-ft.top)/Math.max(1,ft.height),on=ee(bt.node)?qt<.25?"before":qt>.75?"after":"inside":qt<.5?"before":"after";return on==="before"?{target:{parentId:bt.parentId,index:bt.index},line:tt(vt,"top",bt.depth),insideId:null,invalid:!1}:on==="inside"?{target:{parentId:bt.id,index:L(bt.node).length},line:null,insideId:bt.id,invalid:!1}:bt.expanded?{target:{parentId:bt.id,index:0},line:tt(vt,"bottom",bt.depth+1),insideId:null,invalid:!1}:{target:{parentId:bt.parentId,index:bt.index+1},line:tt(vt,"bottom",bt.depth),insideId:null,invalid:!1}}return{target:{parentId:null,index:J.length},line:tt(gt,"bottom",0),insideId:null,invalid:!1}},dt=s.useRef(null),[rt,jt]=s.useState(null),[ht,at]=s.useState(null),_t=s.useRef(!1),It=ce=>{clearTimeout(ce.hoverTimer),ce.hoverTimer=void 0,ce.hoverId=null},we=(ce,Ie)=>{const Ve=Ie?.insideId??null;if(Ve===ce.hoverId)return;It(ce);const Ke=Ve?me.get(Ve):void 0;Ke&&Ke.hasChildren&&!Ke.expanded&&(ce.hoverId=Ve,ce.hoverTimer=setTimeout(()=>Z(Ke.id,!0),Sm))},Ae=ce=>{const Ie=de.current;if(!Ie||Ie.scrollHeight<=Ie.clientHeight)return;const Ve=Ie.getBoundingClientRect();ce<Ve.top+io?Ie.scrollTop-=10:ce>Ve.bottom-io&&(Ie.scrollTop+=10)},Ue=(ce,Ie)=>{const Ve=!!ce.target.closest(".nice-sortable-tree__grip");if(Y||ce.button!==0||Se!==null||ce.pointerType==="touch"&&!Ve||ce.target.closest(".nice-sortable-tree__toggle, input, button")||C&&!C(Ie.node))return;const Ke=new Set;Zt([Ie.node],nt=>{Ke.add(he(nt))},F),dt.current={id:Ie.id,pointerId:ce.pointerId,startY:ce.clientY,startX:ce.clientX,startScroll:de.current?.scrollTop??0,rowTop:ce.currentTarget.getBoundingClientRect().top,started:!1,height:Ji(Ie.node,F),block:Ke,view:null,hoverId:null,hoverTimer:void 0}},ut=ce=>{const Ie=dt.current;if(!Ie||ce.pointerId!==Ie.pointerId)return;const Ve=(de.current?.scrollTop??0)-Ie.startScroll,Ke=ce.clientY+Em-Ie.rowTop+Ve;if(!Ie.started){if(Math.hypot(ce.clientX-Ie.startX,ce.clientY-Ie.startY)<Cm)return;Ie.started=!0,ce.currentTarget.setPointerCapture?.(ce.pointerId),ce.currentTarget.focus()}Ae(ce.clientY);const nt=et(ce.clientY,Ie.block),gt=nt?{...nt,invalid:!ze(Ie.id,nt.target,Ie.height)}:null;Ie.view=gt,we(Ie,gt),jt({ids:Ie.block,dy:Ke}),at(gt)},We=ce=>{const Ie=dt.current;if(dt.current=null,!!Ie){if(It(Ie),Ie.started){if(ce&&Ie.view&&!Ie.view.invalid){const Ve=yi(J,Ie.id,Ie.view.target,F),Ke=Et(Ve,Ie.id,F);Ke&&Ve!==J&&P(Ie.id,{parentId:Ke.parentId,index:Ke.index},"move",Ve)}_t.current=!0,window.setTimeout(()=>{_t.current=!1},0)}jt(null),at(null)}},ot=Yc(),fe=s.useRef({view:null,hoverId:null,hoverTimer:void 0}),$e=s.useRef(()=>{});$e.current=ce=>{const Ie=fe.current,Ve=de.current?.getBoundingClientRect(),Ke=!!Ve&&ce.x>=Ve.left&&ce.x<=Ve.right&&ce.y>=Ve.top&&ce.y<=Ve.bottom;if(ce.type==="move"){if(!Ke||Y||!k){Ie.view&&(Ie.view=null,It(Ie),at(null));return}Ae(ce.y);const gt=et(ce.y,new Set),tt=gt?{...gt,invalid:!ze(null,gt.target,1,ce.payload)}:null;Ie.view=tt,we(Ie,tt),at(tt);return}const nt=Ie.view;Ie.view=null,It(Ie),at(null),ce.commit&&Ke&&nt&&!nt.invalid&&k?.(ce.payload,nt.target)},s.useEffect(()=>ot?.subscribe(ce=>$e.current(ce)),[ot]);const[Je,pe]=s.useState(null),Ee=s.useRef(null);c.useOverlayFocus(Ee,{open:Je!==null,modal:!1,onClose:()=>pe(null)}),c.useRovingFocus(Ee,{orientation:"vertical",wrap:!0,enabled:Je!==null}),s.useLayoutEffect(()=>{const ce=Ee.current;if(!Je||!ce||typeof window>"u")return;const Ie=ce.getBoundingClientRect(),Ve=Math.max(8,Math.min(Je.x,window.innerWidth-Ie.width-8)),Ke=Math.max(8,Math.min(Je.y,window.innerHeight-Ie.height-8));(Ve!==Je.x||Ke!==Je.y)&&pe({...Je,x:Ve,y:Ke})},[Je]),s.useEffect(()=>{if(!Je)return;const ce=Ie=>{Ee.current?.contains(Ie.target)||pe(null)};return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[Je]);const Me=j===!0?km:j===!1?[]:j,He=Je?me.get(Je.id):void 0,ct=[];if(He){const ce=He.node,Ie=!Y&&(!C||C(ce)),Ve=He.index>0,Ke=(nt,gt,tt,vt,ft)=>{Me.includes(nt)&&ct.push({id:nt,label:gt,icon:e.jsx(c.NiceIcon,{name:tt,size:14}),disabled:!vt,onClick:ft})};Ke("moveUp",W("sortableTree.moveUp","Move up"),"chevron-up",Ie&&Ve,()=>q(He.id,-1)),Ke("moveDown",W("sortableTree.moveDown","Move down"),"chevron-down",Ie&&He.index<He.setSize-1,()=>q(He.id,1)),Ke("indent",W("sortableTree.indent","Indent"),"indent",Ie&&Ve,()=>Q(He.id)),Ke("outdent",W("sortableTree.outdent","Outdent"),"outdent",Ie&&He.parentId!==null,()=>be(He.id)),Ke("rename",W("sortableTree.rename","Rename"),"edit",D(S,ce),()=>_e(He.id)),Ke("remove",W("sortableTree.remove","Remove"),"trash",D(N,ce),()=>Re(He.id)),ct.push(...w?.(ce)??[])}const zt=(ce,Ie)=>{if(ce.target!==ce.currentTarget)return;if(ce.key==="Escape"&&dt.current?.started){ce.preventDefault(),We(!1);return}if(!Y&&(!C||C(Ie.node))&&ce.ctrlKey&&ce.shiftKey&&!ce.altKey){const Ke=typeof window<"u"&&de.current!==null&&window.getComputedStyle(de.current).direction==="rtl",nt=Ke&&ce.key==="ArrowLeft"?"ArrowRight":Ke&&ce.key==="ArrowRight"?"ArrowLeft":ce.key,gt={ArrowUp:()=>q(Ie.id,-1),ArrowDown:()=>q(Ie.id,1),ArrowRight:()=>Q(Ie.id),ArrowLeft:()=>be(Ie.id)};if(gt[nt]){ce.preventDefault(),gt[nt]();return}}ce.key==="F2"&&D(S,Ie.node)?(ce.preventDefault(),_e(Ie.id)):ce.key==="Delete"&&D(N,Ie.node)&&(ce.preventDefault(),Re(Ie.id))};if(ne==="hidden")return null;const Dt=rt?.ids;return e.jsxs("div",{ref:de,id:V,title:K,"data-testid":B,className:["nice-sortable-tree",`nice-sortable-tree--${R}`,rt?"nice-sortable-tree--dragging":"",ht&&ue.length===0&&!ht.invalid?"nice-sortable-tree--drop-empty":"",ae?"nice-sortable-tree--disabled":"",$??""].filter(Boolean).join(" "),style:{...z!==void 0?{height:z,overflow:"auto"}:{},...O},"aria-disabled":ae||void 0,children:[ue.length===0&&e.jsx("div",{className:"nice-sortable-tree__empty",children:I??W("sortableTree.empty","Nothing here yet")}),e.jsxs("ul",{ref:oe,role:"tree","aria-label":M,"aria-disabled":ae||void 0,className:"nice-sortable-tree__list",children:[ue.map(ce=>{const Ie=ce.id===se,Ve=!!Dt?.has(ce.id),Ke={depth:ce.depth,hasChildren:ce.hasChildren,expanded:ce.expanded,selected:Ie,dragging:Ve},nt=Se===ce.id,gt={"--nice-sortable-tree-depth":ce.depth,...Ve&&rt?{transform:`translate(${Tm}px, ${rt.dy}px)`}:{}};return e.jsxs("li",{role:"treeitem","data-node-id":ce.id,"aria-level":ce.depth+1,"aria-setsize":ce.setSize,"aria-posinset":ce.index+1,"aria-expanded":ce.hasChildren?ce.expanded:void 0,"aria-selected":Ie,"aria-label":H(ce.node),tabIndex:-1,className:["nice-sortable-tree__row",Ie?"nice-sortable-tree__row--selected":"",Ve?"nice-sortable-tree__row--dragging":"",ht?.insideId===ce.id?ht.invalid?"nice-sortable-tree__row--drop-invalid":"nice-sortable-tree__row--drop-inside":""].filter(Boolean).join(" "),style:gt,onClick:tt=>{if(_t.current){_t.current=!1;return}if(!ae){if(ce.hasChildren&&tt.target.closest(".nice-sortable-tree__toggle")){Z(ce.id,!ce.expanded);return}ve(ce.id)}},onDoubleClick:()=>{D(S,ce.node)&&_e(ce.id)},onKeyDown:tt=>zt(tt,ce),onPointerDown:tt=>Ue(tt,ce),onPointerMove:ut,onPointerUp:()=>We(!0),onPointerCancel:()=>We(!1),onContextMenu:tt=>{if(ae||Me.length===0&&!w)return;tt.preventDefault(),tt.stopPropagation();const vt=tt.currentTarget.getBoundingClientRect(),ft=tt.clientX===0&&tt.clientY===0;pe({id:ce.id,x:ft?vt.left+24:tt.clientX,y:ft?vt.bottom:tt.clientY})},children:[!Y&&(!C||C(ce.node))&&e.jsx("span",{className:"nice-sortable-tree__grip","aria-hidden":"true",children:e.jsx(c.NiceIcon,{name:"grip",size:14})}),ce.hasChildren?e.jsx("span",{className:"nice-sortable-tree__toggle","aria-hidden":"true",children:e.jsx(c.NiceIcon,{name:ce.expanded?"chevron-down":"chevron-right",size:14})}):e.jsx("span",{className:"nice-sortable-tree__toggle nice-sortable-tree__toggle--leaf","aria-hidden":"true"}),m&&e.jsx("span",{className:"nice-sortable-tree__icon","aria-hidden":"true",children:m(ce.node,Ke)}),nt?e.jsx("input",{ref:Fe,className:"nice-sortable-tree__input","aria-label":W("sortableTree.renameField","New name"),defaultValue:H(ce.node),onClick:tt=>tt.stopPropagation(),onPointerDown:tt=>tt.stopPropagation(),onKeyDown:tt=>{tt.stopPropagation(),tt.key==="Enter"?(tt.preventDefault(),qe(ce.id,tt.currentTarget.value)):tt.key==="Escape"&&(tt.preventDefault(),qe(ce.id,null))},onBlur:tt=>{Se===ce.id&&qe(ce.id,tt.currentTarget.value)}}):e.jsx("span",{className:"nice-sortable-tree__label",children:u?u(ce.node,Ke):H(ce.node)}),h&&e.jsx("span",{className:"nice-sortable-tree__end",children:h(ce.node,Ke)})]},ce.id)}),ht?.line&&e.jsx("li",{role:"none",className:`nice-sortable-tree__drop-line${ht.invalid?" nice-sortable-tree__drop-line--invalid":""}`,style:{top:ht.line.top,"--nice-sortable-tree-depth":ht.line.depth}})]}),e.jsx("div",{className:"nice-sr-only","aria-live":"polite",role:"status",children:ie}),Je&&ct.length>0&&e.jsx("ul",{ref:Ee,role:"menu","aria-label":W("sortableTree.menu","Node actions"),className:"nice-contextmenu nice-contextmenu__list nice-sortable-tree__menu",style:{position:"fixed",left:Je.x,top:Je.y},children:ct.map((ce,Ie)=>e.jsx("li",{role:"none",className:"nice-contextmenu__item",children:e.jsxs("button",{type:"button",role:"menuitem",className:`nice-contextmenu__btn${ce.danger?" nice-contextmenu__btn--danger":""}`,disabled:ce.disabled,onClick:Ve=>{pe(null),ce.onClick?.(Ve)},children:[ce.icon&&e.jsx("span",{className:"nice-contextmenu__icon","aria-hidden":"true",children:ce.icon}),e.jsx("span",{children:ce.label??ce.text})]})},ce.id??ce.key??Ie))})]})}const Jc=Object.assign(Im,{displayName:"NiceSortableTree"}),ao=new WeakMap;function xn(t){const n=ao.get(t);if(n)return n;const i=new Map;return Zt(t,(a,r)=>{i.set(a.id,{node:a,ancestors:[...r.ancestors],order:i.size})}),ao.set(t,i),i}function Qc(t,n){return xn(t).get(n)?.node}function Dm(t,n){const i=xn(t),a=new Set;for(const r of n){const o=i.get(r);o&&Zt([o.node],l=>{l.route&&!l.disabled&&a.add(l.id)})}return[...a].sort((r,o)=>(i.get(r)?.order??0)-(i.get(o)?.order??0))}function pi(t,n){let i;return Zt(t,a=>{if(i)return!1;n(a)&&(i=a)}),i}function nr(t){const n=new Set;return Zt(t,i=>{n.add(i.id)}),n}function mi(t,n){let i=n;for(let a=2;t.has(i);a++)i=`${n}-${a}`;return t.add(i),i}function ir(t){const n=[];return Zt(t,i=>{i.ref&&n.push(i.ref)}),n}function Xc(t,n){const i=xn(n),a=[];return Zt(t,r=>{r.ref&&!i.get(r.ref)?.node.route&&a.push(r.id)}),a}function ar(t,n){if(t.label)return t.label;const i=xn(n);return(t.ref?i.get(t.ref)?.node.label:void 0)??(t.from?i.get(t.from)?.node.label:void 0)??t.ref??t.from??t.id}function $a(t,n){const i=xn(n);return(t.ref?i.get(t.ref):void 0)?.node??(t.from?i.get(t.from):void 0)?.node}function Zc(t,n){return xn(t).get(n)?.ancestors.map(i=>i.label)??[]}function so(t,n,i){let a=null,r=t;for(const o of n){const l=pi(r,m=>m.from===o.id);if(l){a=l.id;continue}const d={id:mi(i,`g:${o.id}`),from:o.id,children:[]},u=a===null?r:Et(r,a)?.node.children??[];r=In(r,d,{parentId:a,index:u.length}),a=d.id}return{menu:r,parentId:a}}function el(t,n,i,a={}){const r=xn(n),o=Math.max(0,a.skipLevels??0),l=new Set(ir(t)),d=nr(t);let u=t;const m=[...new Set(i)].filter(h=>r.get(h)?.node.route&&!r.get(h)?.node.disabled).sort((h,p)=>(r.get(h)?.order??0)-(r.get(p)?.order??0));for(const h of m){const p=r.get(h);if(!p||l.has(h))continue;l.add(h);const y=p.ancestors.slice(o);if(p.node.children?.length){const g=so(u,[...y,p.node],d);u=g.menu,g.parentId!==null&&(u=Zi(u,g.parentId,{ref:h}));continue}const x=so(u,y,d);u=x.menu;const b=x.parentId===null?u:Et(u,x.parentId)?.node.children??[];u=In(u,{id:mi(d,`p:${h}`),ref:h},{parentId:x.parentId,index:b.length})}return u}function tl(t){let n=t;for(;;){const i=pi(n,a=>!!a.from&&!a.ref&&!a.children?.length);if(!i)return n;n=Wn(n,i.id)}}function nl(t,n){const i=new Set(n);let a=t;for(const r of i){const o=pi(a,l=>l.ref===r);o&&(o.children?.length?a=Zi(a,o.id,l=>{const{ref:d,...u}=l;return{...u,from:u.from??r}}):a=Wn(a,o.id))}return a===t?a:tl(a)}function il(t,n,i,a,r={}){const o=xn(n),l=nr(t);let d=t,u=a.index;const m=h=>{const p=(h.children??[]).map(m).filter(b=>b!==null),y=!!h.route&&!h.disabled,x=y?pi(d,b=>b.ref===h.id):void 0;return x&&(d=Wn(d,x.id),l.delete(x.id)),h.children?.length?!p.length&&!y?null:{id:mi(l,`g:${h.id}`),from:h.id,...y?{ref:h.id}:{},children:p}:y?{id:mi(l,`p:${h.id}`),ref:h.id}:null};for(const h of i){const p=o.get(h);if(!p)continue;const y=!!p.node.route&&!p.node.disabled,x=!p.node.children?.length||r.asPage,b=y?pi(d,v=>v.ref===h):void 0;if(x){if(b)d=yi(d,b.id,{parentId:a.parentId,index:u});else if(y)d=In(d,{id:mi(l,`p:${h}`),ref:h},{parentId:a.parentId,index:u});else continue;const v=pi(d,f=>f.ref===h);u=(v?Et(d,v.id)?.index??u:u)+1;continue}const g=m(p.node);g&&(a.parentId!==null&&!Et(d,a.parentId)?d=In(d,g,{parentId:null,index:d.length}):(d=In(d,g,{parentId:a.parentId,index:u}),u+=1))}return tl(d)}function al(t,n,i){const a=nr(t),r=mi(a,"group");return{menu:In(t,{id:r,label:n,children:[]},i??{parentId:null,index:t.length}),id:r}}function Pm(t,n,i){if(t.icon)return i?i(t.icon):void 0;const a=n?.icon;return typeof a=="string"?i?i(a):void 0:a}function sl(t,n,i={}){const a=xn(n),r=o=>o.flatMap(l=>{const u=(l.ref?a.get(l.ref)?.node:void 0)?.route,m=r(l.children??[]);return!u&&m.length===0?[]:[{id:l.id,label:ar(l,n),icon:Pm(l,$a(l,n),i.renderIcon),...u?{route:u}:{},...m.length?{children:m}:{}}]});return r(t)}function rl(t,n,i={}){const a=sl(t,n,i),r=[];let o=[];const l=()=>{o.length&&(r.push({id:`${o[0].id}:other`,label:i.otherLabel??"Other",views:o}),o=[])};for(const d of a){if(!d.children?.length){o.push(d);continue}l();const u=d.route?[{id:`${d.id}:page`,label:d.label,icon:d.icon,route:d.route}]:[];r.push({id:d.id,label:d.label,icon:d.icon,views:[...u,...d.children]})}return l(),[{source:i.source??{id:"menu",label:i.otherLabel??"Menu"},modules:r,roles:[],units:[]}]}function Am(t,n={}){const i=n.key??"id",a=(d,u)=>typeof i=="function"?i(d,u):i==="route"?d.route??d.id:d.id,r=(d,u)=>d.map(m=>({id:a(m,u),label:m.label,icon:m.icon,...m.route?{route:m.route}:{},...m.children?.length?{children:r(m.children,u)}:{}})),o=d=>d.modules.map(u=>({id:u.id,label:u.label,icon:u.icon,children:r(u.views,u)}));return n.includeSources??t.length>1?t.map(d=>({id:d.source.id,label:d.source.label,icon:d.source.icon,children:o(d)})):t.flatMap(o)}const Rm=[],$m=[],Mm={},Om=60,zm=t=>e.jsx(c.NiceIcon,{name:t,size:16});function ol(t){return t.map(n=>{const i=n.children?.length?ol(n.children):void 0,a=!!i?.some(r=>r.placeable);return n.route&&i?{key:`${n.id}::branch`,nodeId:n.id,label:n.label,icon:n.icon,placeable:!0,disabled:n.disabled,children:[{key:n.id,nodeId:n.id,label:n.label,icon:n.icon,route:n.route,own:!0,placeable:!0,disabled:n.disabled},...i]}:{key:n.id,nodeId:n.id,label:n.label,icon:n.icon,route:n.route,placeable:!!n.route||a,disabled:n.disabled,children:i}})}function cl(t,n){return n<=0?[]:t.flatMap(i=>i.children?.length?[i.key,...cl(i.children,n-1)]:[])}const Lm=({drag:t,label:n,title:i})=>{const a=Yc();return e.jsx("span",{className:"nice-menu-builder__grip",title:i,"aria-hidden":"true",onPointerDown:r=>{a&&(r.stopPropagation(),_m(a,r,t,n))},children:e.jsx(c.NiceIcon,{name:"grip",size:14})})},Bm=({value:t,onChange:n,renderIcon:i})=>{const{t:a}=c.useNiceTranslation(),[r,o]=s.useState(""),l=s.useRef(null);c.useRovingFocus(l,{orientation:"grid",itemSelector:"button"});const d=s.useMemo(()=>{const u=r.trim().toLowerCase(),m=u?c.NICE_BUILTIN_ICONS.filter(p=>p.includes(u)):c.NICE_BUILTIN_ICONS,h=m.slice(0,Om);return t&&m.includes(t)&&!h.includes(t)?[t,...h]:h},[r,t]);return e.jsxs("div",{className:"nice-menu-builder__icon-picker",children:[e.jsx(Ye.NiceTextInput,{type:"search",size:"sm",label:a("menuBuilder.iconSearch","Search icons"),value:r,onChange:o}),e.jsxs("div",{ref:l,role:"group","aria-label":a("menuBuilder.icons","Icons"),className:"nice-menu-builder__icon-grid",children:[d.map(u=>e.jsx("button",{type:"button",title:u,"aria-label":u,"aria-pressed":u===t,className:`nice-menu-builder__icon-option${u===t?" nice-menu-builder__icon-option--on":""}`,onClick:()=>n(u),children:i(u)},u)),d.length===0&&e.jsx("span",{className:"nice-menu-builder__hint",children:a("menuBuilder.noIcons","No icons found")})]})]})},Fm=({catalog:t=Rm,value:n,defaultValue:i,onChange:a,skipLevels:r=0,maxDepth:o,renderIcon:l=zm,renderIconPicker:d,showPreview:u=!0,previewProps:m,toolbar:h,height:p,size:y="md",readOnly:x=!1,disabled:b=!1,className:g,style:v,id:f,title:C,accessMode:_,"data-testid":T})=>{const{t:S}=c.useNiceTranslation(),N=c.useNiceAccessMode(_,f),j=b||N==="disabled",w=x||N==="readOnly"||j,[k,I]=c.useControllableState({value:n,defaultValue:i,fallbackValue:$m,componentName:"NiceMenuBuilder"}),M=oe=>{oe===k||w||(I(oe),a?.(oe))},[z,R]=s.useState(null),A=s.useRef(null),[E,$]=s.useState(0);s.useEffect(()=>{E>0&&A.current?.querySelector("input")?.focus()},[E]);const O=s.useMemo(()=>ol(t),[t]),V=s.useMemo(()=>ir(k),[k]),K=s.useMemo(()=>new Set(Xc(k,t)),[k,t]),te=s.useMemo(()=>cl(O,2),[O]),B=oe=>{const ie=new Set(oe),Te=new Set(V),X=oe.filter(ve=>!Te.has(ve)),je=V.filter(ve=>!ie.has(ve));let Z=k;X.length&&(Z=el(Z,t,X,{skipLevels:r})),je.length&&(Z=nl(Z,je)),M(Z)},W=s.useMemo(()=>[{field:"label",header:S("menuBuilder.catalogColumn","View"),render:(oe,ie)=>e.jsxs("span",{className:"nice-menu-builder__catalog-cell",children:[!w&&!ie.disabled&&e.jsx(Lm,{drag:{ids:[ie.nodeId],asPage:!!ie.own},label:ie.label,title:S("menuBuilder.dragHint","Drag into the menu")}),ie.icon!==void 0&&e.jsx("span",{className:"nice-menu-builder__icon","aria-hidden":"true",children:typeof ie.icon=="string"?l(ie.icon):ie.icon}),e.jsx("span",{className:"nice-menu-builder__label",children:ie.label}),ie.own&&e.jsx("span",{className:"nice-menu-builder__hint",children:S("menuBuilder.ownPage","(page)")})]})}],[S,w,l]),ne=z?Et(k,z)?.node:void 0,ae=oe=>!oe.ref||oe.children!==void 0,Y=oe=>Et(k,oe)?.depth??0,F=(oe,ie)=>{const Te=oe;!Te||!Array.isArray(Te.ids)||M(il(k,t,Te.ids,ie,{asPage:Te.asPage}))},J=()=>{let oe;if(ne){const Te=Et(k,ne.id);ae(ne)&&(o===void 0||(Te?.depth??0)+2<=o)?oe={parentId:ne.id,index:ne.children?.length??0}:Te&&(oe={parentId:Te.parentId,index:Te.index+1})}const ie=al(k,S("menuBuilder.newGroup","New group"),oe);M(ie.menu),R(ie.id),$(Te=>Te+1)},re=oe=>{const ie=Et(k,oe.id);if(!ie||ie.index===0)return!1;const Te=ie.siblings[ie.index-1];return ae(Te)&&(o===void 0||ie.depth+1+Ji(oe)<=o)},se=ne?Et(k,ne.id):void 0,G=oe=>{ne&&M(oe(k,ne.id))},ge=()=>{if(!ne||!se)return;const oe=se.siblings[se.index+1]??se.siblings[se.index-1];M(Wn(k,ne.id)),R(oe?.id??se.parentId)},Ce=oe=>{if(oe.icon)return l(oe.icon);const ie=$a(oe,t);return typeof ie?.icon=="string"?l(ie.icon):ie?.icon!==void 0?ie.icon:e.jsx(c.NiceIcon,{name:oe.ref?"file":"folder",size:16})},he=oe=>{ne&&M(Zi(k,ne.id,ie=>{const Te={...ie,...oe};return Object.keys(oe).forEach(X=>{oe[X]===void 0&&delete Te[X]}),Te}))},L=ne?$a(ne,t):void 0,H=ne?.ref?Qc(t,ne.ref):void 0,D=L?.label,ee=L?[...Zc(t,L.id),L.label].join(" / "):"",le=ne?(d??(oe=>e.jsx(Bm,{...oe,renderIcon:l})))({value:ne.icon,onChange:oe=>he({icon:oe})}):null,ue=s.useMemo(()=>u?rl(k,t,{renderIcon:l,otherLabel:S("menuBuilder.other","Other"),source:{id:"menu-preview",label:S("menuBuilder.preview","Preview")}}):[],[u,k,t,l,S]);if(N==="hidden")return null;const me=(oe,ie,Te,X,je)=>e.jsx(Le.NiceButton,{variant:"ghost",size:"sm",ariaLabel:ie,title:ie,disabled:!X,onClick:je,children:e.jsx(c.NiceIcon,{name:Te,size:16})},oe),de=!w;return e.jsx(jm,{children:e.jsx("div",{id:f,title:C,"data-testid":T,className:["nice-menu-builder",j?"nice-menu-builder--disabled":"",g??""].filter(Boolean).join(" "),style:{...p!==void 0?{height:p}:{},...v},"aria-disabled":j||void 0,children:e.jsxs("div",{className:"nice-menu-builder__grid",children:[e.jsxs("section",{className:"nice-menu-builder__column nice-menu-builder__column--catalog","aria-label":S("menuBuilder.catalog","Available views"),children:[e.jsx("header",{className:"nice-menu-builder__head",children:e.jsx("span",{className:"nice-menu-builder__title",children:S("menuBuilder.catalog","Available views")})}),e.jsx("div",{className:"nice-menu-builder__body nice-menu-builder__body--flush",children:e.jsx(yt.NiceTreeGrid,{data:O,nested:!0,keyField:"key",columns:W,checkable:!0,checkStrategy:"leaves",checkedKeys:V,onCheckedChange:B,isRowCheckable:oe=>oe.placeable,isRowDisabled:oe=>!!oe.disabled,getRowLabel:oe=>oe.label,defaultExpandedKeys:te,searchable:!0,searchPlaceholder:S("menuBuilder.searchViews","Search views"),searchFields:["label"],toolbarActions:["onlyChecked"],showSelectAll:!1,size:y,compact:!0,readOnly:w,emptyText:S("menuBuilder.catalogEmpty","No views to choose from")})})]}),e.jsxs("section",{className:"nice-menu-builder__column nice-menu-builder__column--menu","aria-label":S("menuBuilder.menu","Menu"),children:[e.jsxs("header",{className:"nice-menu-builder__head",children:[e.jsx("span",{className:"nice-menu-builder__title",children:S("menuBuilder.menu","Menu")}),de&&e.jsxs("span",{className:"nice-menu-builder__tools",role:"group","aria-label":S("menuBuilder.tools","Menu tools"),children:[me("group",S("menuBuilder.addGroup","New group"),"folder",!0,J),me("up",S("sortableTree.moveUp","Move up"),"chevron-up",!!se&&se.index>0,()=>G((oe,ie)=>Ra(oe,ie,-1))),me("down",S("sortableTree.moveDown","Move down"),"chevron-down",!!se&&se.index<se.siblings.length-1,()=>G((oe,ie)=>Ra(oe,ie,1))),me("indent",S("sortableTree.indent","Indent"),"indent",!!ne&&re(ne),()=>G(er)),me("outdent",S("sortableTree.outdent","Outdent"),"outdent",!!se&&se.parentId!==null,()=>G(tr)),me("remove",S("sortableTree.remove","Remove"),"trash",!!ne,ge)]}),h]}),e.jsx("div",{className:"nice-menu-builder__body",children:e.jsx(Jc,{"aria-label":S("menuBuilder.menu","Menu"),value:k,onChange:oe=>M(oe),selectedId:z,onSelect:oe=>R(oe),getLabel:oe=>ar(oe,t),getIcon:oe=>Ce(oe),renderRowEnd:oe=>K.has(oe.id)?e.jsx("span",{className:"nice-menu-builder__badge",children:S("menuBuilder.unavailable","unavailable")}):null,canHaveChildren:ae,canDrop:(oe,ie)=>ie.parentId===null||o===void 0||oe!==null||Y(ie.parentId)+2<=o,maxDepth:o,editable:de,removable:de,onExternalDrop:F,emptyText:S("menuBuilder.menuEmpty","Check views on the left or drag them here"),size:y,readOnly:w})})]}),e.jsxs("div",{className:"nice-menu-builder__side",children:[e.jsxs("section",{className:"nice-menu-builder__column nice-menu-builder__column--item","aria-label":S("menuBuilder.item","Item"),children:[e.jsxs("header",{className:"nice-menu-builder__head",children:[e.jsx("span",{className:"nice-menu-builder__title",children:S("menuBuilder.item","Item")}),ne&&e.jsx("span",{className:"nice-menu-builder__kind",children:ne.ref?S("menuBuilder.page","Page"):S("menuBuilder.group","Group")})]}),e.jsxs("div",{className:"nice-menu-builder__body nice-menu-builder__props",children:[!ne&&e.jsx("p",{className:"nice-menu-builder__hint",children:S("menuBuilder.selectHint","Select an item of the menu to rename it or change its icon.")}),ne&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-menu-builder__field",ref:A,children:[e.jsx(Ye.NiceTextInput,{label:S("menuBuilder.name","Name"),size:"sm",value:ne.label??"",placeholder:D??S("menuBuilder.newGroup","New group"),onChange:oe=>he({label:oe.trim()?oe:void 0}),readOnly:w}),de&&ne.label&&D&&e.jsx(Le.NiceButton,{variant:"ghost",size:"sm",ariaLabel:S("menuBuilder.resetName","Name from the catalog"),title:S("menuBuilder.resetName","Name from the catalog"),onClick:()=>he({label:void 0}),children:e.jsx(c.NiceIcon,{name:"undo",size:16})})]}),e.jsxs("div",{className:"nice-menu-builder__field nice-menu-builder__field--icon",children:[e.jsx("span",{className:"nice-menu-builder__field-label",children:S("menuBuilder.icon","Icon")}),e.jsx("span",{className:"nice-menu-builder__icon-now","aria-hidden":"true",children:Ce(ne)}),de&&ne.icon&&e.jsx(Le.NiceButton,{variant:"ghost",size:"sm",ariaLabel:S("menuBuilder.resetIcon","Icon from the catalog"),title:S("menuBuilder.resetIcon","Icon from the catalog"),onClick:()=>he({icon:void 0}),children:e.jsx(c.NiceIcon,{name:"undo",size:16})})]}),de&&le,(H?.route||ee)&&e.jsxs("dl",{className:"nice-menu-builder__facts",children:[H?.route&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:S("menuBuilder.route","Opens")}),e.jsx("dd",{children:e.jsx("code",{children:H.route})})]}),ee&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:S("menuBuilder.source","In the catalog")}),e.jsx("dd",{children:ee})]})]}),K.has(ne.id)&&e.jsx("p",{className:"nice-menu-builder__warning",role:"note",children:S("menuBuilder.orphan","This view is no longer in the catalog — it will not show in the menu.")})]})]})]}),u&&e.jsxs("section",{className:"nice-menu-builder__column nice-menu-builder__column--preview","aria-label":S("menuBuilder.preview","Preview"),children:[e.jsx("header",{className:"nice-menu-builder__head",children:e.jsx("span",{className:"nice-menu-builder__title",children:S("menuBuilder.preview","Preview")})}),e.jsx("div",{className:"nice-menu-builder__body nice-menu-builder__body--flush",children:e.jsx(Be.NiceSidebarNav,{data:ue,minimal:!0,readonly:!0,contextMenu:!1,preferences:Mm,...m})})]})]})]})})})},ll=s.createContext(null),Vm=({children:t,type:n="single",value:i,defaultValue:a,disabled:r=!1,onChange:o,className:l="",style:d,testId:u,"data-testid":m})=>{const[h,p]=s.useState(a??(n==="single"?"":[])),y=i!==void 0,x=y?i:h,b=s.useCallback(f=>n==="single"?x===f:Array.isArray(x)&&x.includes(f),[n,x]),g=s.useCallback(f=>{let C;if(n==="single")C=x===f?"":f;else{const _=Array.isArray(x)?x:[];C=_.includes(f)?_.filter(T=>T!==f):[..._,f]}y||p(C),o?.(C)},[n,x,y,o]),v=s.useMemo(()=>({type:n,isPressed:b,toggle:g,disabled:r}),[n,b,g,r]);return e.jsx(ll.Provider,{value:v,children:e.jsx("div",{role:"group",className:`nice-toggle-group nice-toggle-group--${n} ${l}`,style:d,"data-testid":m??u,children:t})})},qm=Object.assign(({value:t,children:n,disabled:i=!1})=>{const a=s.useContext(ll);if(!a)throw new Error("NiceToggleGroup.Item must be rendered inside <NiceToggleGroup>");const r=a.isPressed(t),o=a.disabled||i;return e.jsx("button",{type:"button",className:`nice-toggle-group__item ${r?"nice-toggle-group__item--pressed":""}`,"aria-pressed":r,disabled:o,onClick:()=>a.toggle(t),children:n})},{displayName:"NiceToggleGroup.Item"}),Ds=Object.assign(Vm,{displayName:"NiceToggleGroup",Item:qm}),Um=["daily","weekly","monthly","yearly"],Hm={daily:"Daily",weekly:"Weekly",monthly:"Monthly",yearly:"Yearly"},Gm={daily:"Repeat every (days)",weekly:"Repeat every (weeks)",monthly:"Repeat every (months)",yearly:"Repeat every (years)"},Wm={daily:{single:"Every day",other:"Every {n} days"},weekly:{single:"Every week",other:"Every {n} weeks"},monthly:{single:"Every month",other:"Every {n} months"},yearly:{single:"Every year",other:"Every {n} years"}},ro=10,dl=864e5,Km=new Date(2023,0,1);function oo(t,n){try{return new Intl.PluralRules(t).select(n)}catch{return n===1?"one":"other"}}function Ps(t,n,i){const a=new Date(Km.getTime()+n*dl);try{return new Intl.DateTimeFormat(t,{weekday:i}).format(a)}catch{return new Intl.DateTimeFormat("en",{weekday:i}).format(a)}}function ul(t,n){try{return new Intl.DateTimeFormat(t,n)}catch{return new Intl.DateTimeFormat("en",n)}}function co(t){const n=i=>String(i).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Ym(t,n,i,a){const r=Math.max(1,Math.floor(t.interval??1)),o=Wm[t.freq],l=[r===1?n(`recurrence.summary.${t.freq}.single`,o.single):n(`recurrence.summary.${t.freq}.${oo(i,r)}`,o.other).replace("{n}",String(r))];if(t.freq==="weekly"&&t.byDay?.length&&l.push(a.filter(d=>t.byDay?.includes(d)).map(d=>Ps(i,d,"short")).join(", ")),t.count&&t.count>0)l.push(n(`recurrence.summary.times.${oo(i,t.count)}`,t.count===1?"once":"{n} times").replace("{n}",String(t.count)));else if(t.until){const d=ul(i,{day:"numeric",month:"short",year:"numeric"});l.push(`${n("recurrence.summary.until","until")} ${d.format(new Date(t.until))}`)}return l.join(" · ")}const Jm=({value:t,defaultValue:n=null,onChange:i,start:a,allowNone:r=!0,previewCount:o=5,weekStartsOn:l=1,label:d,size:u="md",disabled:m=!1,readOnly:h=!1,className:p="",style:y,id:x,accessMode:b,"data-testid":g})=>{const{t:v,lang:f}=c.useNiceTranslation(),C=c.useNiceAccessMode(b,x),[_,T]=c.useControllableState({value:t,defaultValue:n,onChange:i,componentName:"NiceRecurrenceEditor"}),[S]=s.useState(()=>new Date),N=a??S,j=m||h||C==="disabled"||C==="readOnly",w=c.normalizeSize(u),k=w==="xxs"||w==="xs"?w:"sm",I=s.useMemo(()=>Array.from({length:7},(V,K)=>(K+l)%7),[l]),M=s.useMemo(()=>{if(!_||o<=0)return[];const V=new Date(N.getTime()+100*365*dl);return At.recurrenceDates(_,N,V,o)},[_,N,o]);if(C==="hidden")return null;const z=V=>{_&&T({..._,...V})},R=V=>{if(V==="none"){T(null);return}const K=V,te=_?{..._,freq:K}:{freq:K,interval:1};K==="weekly"?te.byDay=_?.byDay?.length?_.byDay:[N.getDay()]:delete te.byDay,T(te)},A=_?.count?"after":_?.until?"on":"never",E=V=>{if(!_)return;const K={..._};if(delete K.count,delete K.until,V==="after")T({...K,count:ro});else if(V==="on"){const te=new Date(N);te.setMonth(te.getMonth()+3),T({...K,until:te})}else T(K)},$=[...r?[{value:"none",label:v("recurrence.freq.none","Does not repeat")}]:[],...Um.map(V=>({value:V,label:v(`recurrence.freq.${V}`,Hm[V])}))],O=ul(f,{weekday:"short",day:"numeric",month:"short",year:"numeric"});return e.jsxs("div",{id:x,className:`nice-recurrence nice-recurrence--${w} ${p}`,style:y,"data-testid":g,children:[e.jsx(Ut.NiceSelect,{size:k,label:d??v("recurrence.frequency","Repeats"),value:_?_.freq:"none",options:$,onChange:V=>R(Array.isArray(V)?V[0]??"none":V),disabled:j}),_&&e.jsxs(e.Fragment,{children:[e.jsx(Ye.NiceNumberInput,{size:k,className:"nice-recurrence__interval",label:v(`recurrence.interval.${_.freq}`,Gm[_.freq]),min:1,max:999,value:_.interval??1,onChange:V=>z({interval:Math.max(1,Math.round(V??1))}),disabled:j}),_.freq==="weekly"&&e.jsxs("div",{className:"nice-recurrence__days",role:"group","aria-label":v("recurrence.days","On days"),children:[e.jsx("span",{className:"nice-recurrence__caption",children:v("recurrence.days","On days")}),e.jsx(Ds,{type:"multiple",disabled:j,value:(_.byDay??[]).map(String),onChange:V=>{const K=(Array.isArray(V)?V:[V]).map(Number);K.length>0&&z({byDay:K.sort((te,B)=>te-B)})},children:I.map(V=>e.jsx(Ds.Item,{value:String(V),children:e.jsx("span",{title:Ps(f,V,"long"),children:Ps(f,V,"short")})},V))})]}),e.jsxs("div",{className:"nice-recurrence__ends",children:[e.jsx(it.NiceRadioGroup,{size:k,label:v("recurrence.endsLabel","Ends"),direction:"vertical",value:A,onChange:E,disabled:j,options:[{value:"never",label:v("recurrence.ends.never","Never")},{value:"on",label:v("recurrence.ends.on","On a date")},{value:"after",label:v("recurrence.ends.after","After a number of occurrences")}]}),A==="on"&&_.until&&e.jsx(it.NiceDateTimePicker,{size:k,label:v("recurrence.endDate","End date"),dateFormatPreset:"date-local",value:co(new Date(_.until)),min:co(N),onChange:V=>{const[K,te,B]=V.split("-").map(Number);K&&te&&B&&z({until:new Date(K,te-1,B,23,59,59)})},disabled:j}),A==="after"&&e.jsx(Ye.NiceNumberInput,{size:k,className:"nice-recurrence__count",label:v("recurrence.count","Occurrences"),min:1,max:9999,value:_.count??ro,onChange:V=>z({count:Math.max(1,Math.round(V??1))}),disabled:j})]}),e.jsx("p",{className:"nice-recurrence__summary","aria-live":"polite",children:Ym(_,v,f,I)}),M.length>0&&e.jsxs("div",{className:"nice-recurrence__preview",children:[e.jsx("span",{className:"nice-recurrence__caption",children:v("recurrence.next","Next dates")}),e.jsx("ol",{className:"nice-recurrence__dates",children:M.map(V=>e.jsx("li",{children:e.jsx("time",{dateTime:V.toISOString(),children:O.format(V)})},V.getTime()))})]})]})]})};function Qm(t,n=1){let i;if(typeof t.quantity=="number"){const r=t.quantity*n;i=Number.isInteger(r)?String(r):String(Math.round(r*100)/100)}else i=t.quantity!=null?String(t.quantity):"";const a=t.unit??"";return[i,a].filter(Boolean).join(" ").trim()}const Xm=({photos:t})=>{const{t:n}=c.useNiceTranslation(),i=[...t].sort((l,d)=>+!!d.primary-+!!l.primary),[a,r]=s.useState(i[0]?.id),o=i.find(l=>l.id===a)??i[0];return e.jsxs("div",{className:"nice-recipe__gallery",children:[o&&e.jsxs("div",{className:"nice-recipe__photo-main",children:[e.jsx("img",{src:o.url,alt:o.caption??""}),o.caption&&e.jsx("div",{className:"nice-recipe__photo-caption",children:o.caption})]}),i.length>1&&e.jsx("div",{className:"nice-recipe__photo-thumbs",children:i.map(l=>e.jsx("button",{type:"button",className:`nice-recipe__thumb${l.id===o?.id?" nice-recipe__thumb--active":""}`,onClick:()=>r(l.id),"aria-label":l.caption??n("recipe.photo","Photo"),children:e.jsx("img",{src:l.url,alt:l.caption??""})},l.id))})]})},Zm=({recipe:t,compact:n=!1,hidePhotos:i=!1,hideIngredients:a=!1,hideSteps:r=!1,onIngredientToggle:o,onStepToggle:l,className:d,style:u,accessMode:m,id:h,"data-testid":p})=>{const{t:y}=c.useNiceTranslation(),x=c.useNiceAccessMode(m,h),b=t.servings,[g,v]=s.useState(b);if(s.useEffect(()=>{v(b)},[b]),x==="hidden")return null;const f=x==="readOnly"||x==="disabled",C=At.recipeTotalMinutes(t),_=t.photos??[],T=[...t.steps].sort((w,k)=>w.order-k.order),S=!f&&typeof b=="number"&&b>0&&typeof g=="number"&&g>0?g/b:1,N=!n&&typeof b=="number"&&b>0&&!f,j=()=>{typeof window<"u"&&window.print()};return e.jsxs("div",{className:`nice-recipe${n?" nice-recipe--compact":""} ${d??""}`,style:u,"data-testid":p,children:[e.jsxs("header",{className:"nice-recipe__header",children:[e.jsx("h3",{className:"nice-recipe__title",children:t.title||y("recipe.untitled","Untitled recipe")}),!n&&t.description&&e.jsx("p",{className:"nice-recipe__description",children:t.description}),e.jsxs("div",{className:"nice-recipe__meta",children:[t.servings!=null&&e.jsxs("span",{className:"nice-recipe__meta-item",children:[e.jsx(c.NiceIcon,{name:"box",size:14})," ",g??t.servings," ",y("recipe.servings","servings")]}),C!=null&&e.jsxs("span",{className:"nice-recipe__meta-item",children:[e.jsx(c.NiceIcon,{name:"clock",size:14})," ",C," ",y("recipe.minutes","min")]}),t.difficulty&&e.jsx("span",{className:`nice-recipe__badge nice-recipe__badge--${t.difficulty}`,children:y(`recipe.difficulty.${t.difficulty}`,t.difficulty)}),t.cuisine&&e.jsxs("span",{className:"nice-recipe__meta-item",children:[e.jsx(c.NiceIcon,{name:"globe",size:14})," ",t.cuisine]}),t.sourceUrl&&e.jsxs("a",{className:"nice-recipe__meta-item nice-recipe__source",href:t.sourceUrl,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(c.NiceIcon,{name:"link",size:14})," ",y("recipe.source","Source")]})]}),(N||!n)&&e.jsxs("div",{className:"nice-recipe__actions",children:[N&&e.jsxs("span",{className:"nice-recipe__servings-stepper",children:[e.jsx("button",{type:"button",className:"nice-recipe__servings-btn","aria-label":y("recipe.servingsDecrease","Decrease servings"),onClick:()=>v(w=>Math.max(1,(w??b??1)-1)),disabled:(g??b??1)<=1,children:"−"}),e.jsxs("span",{"aria-live":"polite",className:"nice-recipe__servings-value",children:[g??b," ×"]}),e.jsx("button",{type:"button",className:"nice-recipe__servings-btn","aria-label":y("recipe.servingsIncrease","Increase servings"),onClick:()=>v(w=>Math.min(99,(w??b??1)+1)),disabled:(g??b??1)>=99,children:"+"}),S!==1&&e.jsx("button",{type:"button",className:"nice-recipe__servings-reset",onClick:()=>v(b),children:y("recipe.reset","Reset")})]}),!n&&e.jsxs("button",{type:"button",className:"nice-recipe__print",onClick:j,"aria-label":y("recipe.print","Print recipe"),children:[e.jsx(c.NiceIcon,{name:"printer",size:14})," ",y("recipe.print","Print")]})]}),t.tags&&t.tags.length>0&&e.jsx("div",{className:"nice-recipe__tags",children:t.tags.map(w=>e.jsxs("span",{className:"nice-recipe__tag",children:["#",w]},w))})]}),!i&&_.length>0&&e.jsx(Xm,{photos:_}),e.jsxs("div",{className:"nice-recipe__body",children:[!a&&t.ingredients.length>0&&e.jsxs("section",{className:"nice-recipe__section nice-recipe__section--ingredients",children:[e.jsx("h4",{className:"nice-recipe__section-title",children:y("recipe.ingredients","Ingredients")}),e.jsx("ul",{className:"nice-recipe__ingredients",children:t.ingredients.map(w=>e.jsx("li",{className:"nice-recipe__ingredient",children:e.jsxs("label",{className:`nice-recipe__ingredient-row${w.checked?" nice-recipe__ingredient-row--checked":""}`,children:[e.jsx("input",{type:"checkbox",checked:!!w.checked,disabled:f||!o,onChange:()=>o?.(w)}),e.jsx("span",{className:"nice-recipe__ingredient-qty",children:Qm(w,S)}),e.jsx("span",{className:"nice-recipe__ingredient-name",children:w.name}),w.notes&&e.jsxs("span",{className:"nice-recipe__ingredient-notes",children:["— ",w.notes]})]})},w.id))})]}),!r&&T.length>0&&e.jsxs("section",{className:"nice-recipe__section nice-recipe__section--steps",children:[e.jsx("h4",{className:"nice-recipe__section-title",children:y("recipe.steps","Steps")}),e.jsx("ol",{className:"nice-recipe__steps",children:T.map(w=>e.jsx("li",{className:`nice-recipe__step${w.done?" nice-recipe__step--done":""}`,children:e.jsxs("label",{className:"nice-recipe__step-row",children:[e.jsx("input",{type:"checkbox",checked:!!w.done,disabled:f||!l,onChange:()=>l?.(w)}),e.jsxs("div",{className:"nice-recipe__step-body",children:[e.jsx("div",{className:"nice-recipe__step-instruction",children:w.instruction}),w.durationMinutes!=null&&e.jsxs("div",{className:"nice-recipe__step-duration",children:[e.jsx(c.NiceIcon,{name:"clock",size:14})," ",w.durationMinutes," ",y("recipe.minutes","min")]}),w.image&&e.jsx("img",{className:"nice-recipe__step-image",src:w.image,alt:""})]})]})},w.id))})]})]}),!n&&t.nutrition&&e.jsxs("footer",{className:"nice-recipe__nutrition",children:[t.nutrition.calories!=null&&e.jsx("span",{children:y("recipe.kcal","{label}: {value} kcal").replace("{label}",y("recipe.nutrition.calories","Calories")).replace("{value}",String(t.nutrition.calories))}),t.nutrition.protein!=null&&e.jsxs("span",{children:[y("recipe.nutrition.protein","Protein"),": ",t.nutrition.protein," g"]}),t.nutrition.fat!=null&&e.jsxs("span",{children:[y("recipe.nutrition.fat","Fat"),": ",t.nutrition.fat," g"]}),t.nutrition.carbs!=null&&e.jsxs("span",{children:[y("recipe.nutrition.carbs","Carbs"),": ",t.nutrition.carbs," g"]}),t.nutrition.fiber!=null&&e.jsxs("span",{children:[y("recipe.nutrition.fiber","Fiber"),": ",t.nutrition.fiber," g"]}),t.nutrition.sugar!=null&&e.jsxs("span",{children:[y("recipe.nutrition.sugar","Sugar"),": ",t.nutrition.sugar," g"]}),t.nutrition.sodium!=null&&e.jsx("span",{children:y("recipe.mg","{label}: {value} mg").replace("{label}",y("recipe.nutrition.sodium","Sodium")).replace("{value}",String(t.nutrition.sodium))})]})]})},eh=[],th=[{value:"",label:"All"},{value:"easy",label:"Easy"},{value:"medium",label:"Medium"},{value:"hard",label:"Hard"}],pl=({recipes:t=eh,onSelect:n,initialQuery:i="",hideFilters:a,emptyMessage:r,className:o,style:l,"data-testid":d})=>{const{t:u}=c.useNiceTranslation(),[m,h]=s.useState(i),[p,y]=s.useState(""),[x,b]=s.useState(""),g=s.useMemo(()=>{const f=new Set;for(const C of t)for(const _ of C.tags??[])f.add(_);return Array.from(f).sort()},[t]),v=s.useMemo(()=>{const f=m.trim().toLowerCase();return t.filter(C=>p&&C.difficulty!==p||x&&!(C.tags??[]).includes(x)?!1:f?[C.title,C.description??"",C.cuisine??"",...C.tags??[]].join(" ").toLowerCase().includes(f):!0)},[t,m,p,x]);return e.jsxs("div",{className:`nice-recipe-list ${o??""}`,style:l,"data-testid":d,children:[e.jsxs("div",{className:"nice-recipe-list__toolbar",children:[e.jsx("input",{type:"search",className:"nice-recipe-list__search",value:m,placeholder:u("recipe.list.search","Search recipes…"),onChange:f=>h(f.target.value),"aria-label":u("recipe.list.search","Search recipes")}),!a&&e.jsxs(e.Fragment,{children:[e.jsx("select",{className:"nice-recipe-list__filter",value:p,onChange:f=>y(f.target.value),"aria-label":u("recipe.difficulty","Difficulty"),children:th.map(f=>e.jsx("option",{value:f.value,children:f.label},f.value||"all"))}),g.length>0&&e.jsxs("select",{className:"nice-recipe-list__filter",value:x,onChange:f=>b(f.target.value),"aria-label":u("recipe.tags","Tags"),children:[e.jsx("option",{value:"",children:u("recipe.list.allTags","All tags")}),g.map(f=>e.jsxs("option",{value:f,children:["#",f]},f))]})]}),e.jsxs("span",{className:"nice-recipe-list__count","aria-live":"polite",children:[v.length," / ",t.length]})]}),v.length===0?e.jsx("div",{className:"nice-recipe-list__empty",children:r??u("recipe.list.empty","No recipes match the current filters.")}):e.jsx("ul",{className:"nice-recipe-list__grid",children:v.map(f=>{const C=f.photos?.find(T=>T.primary)??f.photos?.[0],_=At.recipeTotalMinutes(f);return e.jsx("li",{className:"nice-recipe-list__item",children:e.jsxs("button",{type:"button",className:"nice-recipe-list__card",onClick:()=>n?.(f),children:[C&&e.jsx("span",{className:"nice-recipe-list__thumb",children:e.jsx("img",{src:C.url,alt:C.caption??f.title,loading:"lazy"})}),e.jsxs("span",{className:"nice-recipe-list__body",children:[e.jsx("span",{className:"nice-recipe-list__title",children:f.title}),f.description&&e.jsx("span",{className:"nice-recipe-list__desc",children:f.description}),e.jsxs("span",{className:"nice-recipe-list__meta",children:[typeof f.servings=="number"&&e.jsxs("span",{className:"nice-recipe-list__meta-item",children:[e.jsx(c.NiceIcon,{name:"utensils",size:12})," ",f.servings]}),_!=null&&_>0&&e.jsxs("span",{className:"nice-recipe-list__meta-item",children:[e.jsx(c.NiceIcon,{name:"clock",size:12})," ",u("recipe.min","{total} min").replace("{total}",String(_))]}),f.difficulty&&e.jsx("span",{className:`nice-recipe__badge nice-recipe__badge--${f.difficulty}`,children:f.difficulty})]}),f.tags&&f.tags.length>0&&e.jsx("span",{className:"nice-recipe-list__tags",children:f.tags.slice(0,4).map(T=>e.jsxs("span",{className:"nice-recipe__tag",children:["#",T]},T))})]})]})},f.id)})})]})},nh=[],ih=[],ah=["breakfast","lunch","dinner"],sh=1440*60*1e3;function rh(t){const n=new Date(t);n.setHours(0,0,0,0);const i=n.getDay(),a=i===0?-6:1-i;return n.setDate(n.getDate()+a),n}function lo(t,n){return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}const oh=({recipes:t=nh,meals:n=ih,onChange:i,weekStart:a,rows:r=ah,readOnly:o,className:l,style:d,"data-testid":u})=>{const{t:m,lang:h}=c.useNiceTranslation(),p=s.useMemo(()=>rh(a??new Date),[a]),y=s.useMemo(()=>Array.from({length:7},(T,S)=>new Date(p.getTime()+S*sh)),[p]),x=s.useMemo(()=>{const T=new Map;for(const S of t)T.set(S.id,S);return T},[t]),b=s.useCallback((T,S)=>n.filter(N=>N.kind===S&&N.servedAt instanceof Date&&lo(N.servedAt,T)),[n]),g=s.useCallback((T,S,N)=>{if(!N||o)return;const j=x.get(N),w=new Date(T);w.setHours(S==="breakfast"?8:S==="lunch"?13:S==="dinner"?19:16,0,0,0);const k={id:At.newRecipeId("meal"),name:j?.title??m("mealplan.untitled","Meal"),kind:S,servedAt:w,recipeIds:[N],servings:j?.servings};i?.([...n,k])},[n,i,o,x,m]),v=s.useCallback(T=>{o||i?.(n.filter(S=>S.id!==T))},[n,i,o]),f=T=>T.toLocaleDateString(h,{weekday:"short",day:"numeric",month:"short"}),C=T=>m(`mealplan.kind.${T}`,T.charAt(0).toUpperCase()+T.slice(1)),_=new Date;return e.jsx("div",{className:`nice-mealplan ${l??""}`,style:d,"data-testid":u,children:e.jsxs("div",{className:"nice-mealplan__grid",style:{gridTemplateColumns:"auto repeat(7, minmax(8rem, 1fr))"},children:[e.jsx("div",{className:"nice-mealplan__corner"}),y.map(T=>e.jsx("div",{className:`nice-mealplan__day-head${lo(T,_)?" nice-mealplan__day-head--today":""}`,children:f(T)},T.toISOString())),r.map(T=>e.jsxs(s.Fragment,{children:[e.jsx("div",{className:"nice-mealplan__row-head",children:C(T)}),y.map(S=>{const N=b(S,T);return e.jsxs("div",{className:"nice-mealplan__cell",children:[N.map(j=>{const w=j.recipeIds[0]?x.get(j.recipeIds[0]):void 0;return e.jsxs("div",{className:"nice-mealplan__chip",title:j.name,children:[e.jsx("span",{className:"nice-mealplan__chip-title",children:w?.title??j.name}),!o&&e.jsx("button",{type:"button",className:"nice-mealplan__chip-remove","aria-label":m("mealplan.remove","Remove meal"),onClick:()=>v(j.id),children:e.jsx(c.NiceIcon,{name:"close",size:14})})]},j.id)}),!o&&t.length>0&&e.jsxs("select",{className:"nice-mealplan__add",value:"","aria-label":m("mealplan.addRecipe","Add recipe"),onChange:j=>{const w=j.target.value;w&&g(S,T,w),j.target.value=""},children:[e.jsxs("option",{value:"",children:["+ ",m("mealplan.add","Add")]}),t.map(j=>e.jsx("option",{value:j.id,children:j.title},j.id))]})]},`${T}-${S.toISOString()}`)})]},T))]})})},ch=[],lh=[],dh=({recipes:t=ch,collections:n=lh,onChange:i,readOnly:a,onSelectRecipe:r,className:o,style:l,"data-testid":d})=>{const{t:u}=c.useNiceTranslation(),{prompt:m,element:h}=xt.useNiceDialogs(),[p,y]=s.useState(n[0]?.id??null),[x,b]=s.useState(null),g=s.useMemo(()=>{const k=new Map;for(const I of t)k.set(I.id,I);return k},[t]),v=s.useMemo(()=>n.find(k=>k.id===p)??n[0]??null,[n,p]),f=s.useMemo(()=>v?v.recipeIds.map(k=>g.get(k)).filter(k=>!!k):[],[v,g]),C=s.useCallback(k=>{i?.(k)},[i]),_=s.useCallback(()=>{a||m({title:u("collections.namePrompt","Collection name")}).then(k=>{if(!k||!k.trim())return;const I={id:At.newRecipeId("coll"),name:k.trim(),recipeIds:[]};C([...n,I]),y(I.id)})},[n,a,u,C,m]),T=s.useCallback(k=>{if(a)return;const I=n.filter(M=>M.id!==k);C(I),p===k&&y(I[0]?.id??null)},[p,n,a,C]),S=s.useCallback(()=>{if(!x)return;const k=x.value.trim();k&&C(n.map(I=>I.id===x.id?{...I,name:k}:I)),b(null)},[n,x,C]),N=s.useCallback(k=>{!v||!k||a||v.recipeIds.includes(k)||C(n.map(I=>I.id===v.id?{...I,recipeIds:[...I.recipeIds,k]}:I))},[v,n,a,C]),j=s.useCallback(k=>{!v||a||C(n.map(I=>I.id===v.id?{...I,recipeIds:I.recipeIds.filter(M=>M!==k)}:I))},[v,n,a,C]),w=s.useMemo(()=>v?t.filter(k=>!v.recipeIds.includes(k.id)):[],[v,t]);return e.jsxs("div",{className:`nice-recipe-collections ${o??""}`,style:l,"data-testid":d,children:[h,e.jsxs("aside",{className:"nice-recipe-collections__sidebar",children:[e.jsxs("div",{className:"nice-recipe-collections__sidebar-head",children:[e.jsx("span",{className:"nice-recipe-collections__sidebar-title",children:u("collections.title","Collections")}),!a&&e.jsx("button",{type:"button",className:"nice-recipe-collections__sidebar-add",onClick:_,"aria-label":u("collections.create","Create collection"),children:e.jsx(c.NiceIcon,{name:"plus",size:14})})]}),e.jsx("ul",{className:"nice-recipe-collections__list",children:n.map(k=>{const I=v?.id===k.id,M=x?.id===k.id;return e.jsxs("li",{className:`nice-recipe-collections__item${I?" nice-recipe-collections__item--active":""}`,children:[M?e.jsx("input",{autoFocus:!0,className:"nice-recipe-collections__rename",value:x.value,onChange:z=>b({id:k.id,value:z.target.value}),onBlur:S,onKeyDown:z=>{z.key==="Enter"?S():z.key==="Escape"&&b(null)}}):e.jsxs("button",{type:"button",className:"nice-recipe-collections__item-btn",onClick:()=>y(k.id),onDoubleClick:()=>!a&&b({id:k.id,value:k.name}),children:[e.jsx("span",{className:"nice-recipe-collections__item-name",children:k.name}),e.jsx("span",{className:"nice-recipe-collections__item-count",children:k.recipeIds.length})]}),!a&&!M&&e.jsx("button",{type:"button",className:"nice-recipe-collections__item-remove",onClick:()=>T(k.id),"aria-label":u("collections.delete","Delete collection"),title:u("collections.delete","Delete collection"),children:e.jsx(c.NiceIcon,{name:"close",size:14})})]},k.id)})})]}),e.jsx("section",{className:"nice-recipe-collections__main",children:v?e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"nice-recipe-collections__header",children:[e.jsx("h3",{className:"nice-recipe-collections__name",children:v.name}),!a&&w.length>0&&e.jsxs("select",{className:"nice-recipe-collections__add-recipe",value:"","aria-label":u("collections.addRecipe","Add recipe"),onChange:k=>{const I=k.target.value;I&&N(I),k.target.value=""},children:[e.jsxs("option",{value:"",children:["+ ",u("collections.addRecipe","Add recipe")]}),w.map(k=>e.jsx("option",{value:k.id,children:k.title},k.id))]})]}),f.length===0?e.jsx("div",{className:"nice-recipe-collections__empty",children:u("collections.empty","No recipes in this collection yet.")}):e.jsx(pl,{recipes:f,hideFilters:!0,onSelect:k=>r?.(k)}),!a&&f.length>0&&e.jsxs("details",{className:"nice-recipe-collections__manage",children:[e.jsx("summary",{children:u("collections.manage","Manage recipes")}),e.jsx("ul",{className:"nice-recipe-collections__manage-list",children:f.map(k=>e.jsxs("li",{children:[e.jsx("span",{children:k.title}),e.jsx("button",{type:"button",onClick:()=>j(k.id),"aria-label":u("collections.removeRecipe","Remove recipe from collection"),children:u("collections.removeShort","Remove")})]},k.id))})]})]}):e.jsx("div",{className:"nice-recipe-collections__empty",children:u("collections.emptyState","No collection selected.")})})]})},uh=[],ii=["hour","day","week","month","quarter","year"],ph=t=>{switch(t){case"hour":return{msPerPixel:6e4,unitMs:36e5,unitLabel:"HH:mm",headerFormat:"MMM d, yyyy"};case"day":return{msPerPixel:36e5,unitMs:864e5,unitLabel:"d",headerFormat:"MMM yyyy"};case"week":return{msPerPixel:864e5/2,unitMs:6048e5,unitLabel:"W",headerFormat:"MMM yyyy"};case"month":return{msPerPixel:864e5*2,unitMs:2592e6,unitLabel:"MMM",headerFormat:"yyyy"};case"quarter":return{msPerPixel:864e5*7,unitMs:7776e6,unitLabel:"Q",headerFormat:"yyyy"};case"year":return{msPerPixel:864e5*30,unitMs:31536e6,unitLabel:"yyyy",headerFormat:""};default:return{msPerPixel:864e5,unitMs:864e5,unitLabel:"d",headerFormat:"MMM yyyy"}}},ai=(t,n,i="pl-PL")=>{const a={};if(n.includes("yyyy")&&(a.year="numeric"),n.includes("MMM")&&(a.month="short"),n.includes("MM")&&!n.includes("MMM")&&(a.month="2-digit"),(n.includes("dd")||n.includes("d"))&&(a.day="2-digit"),n.includes("EEE")&&(a.weekday="short"),n.includes("HH")&&(a.hour="2-digit",a.hour12=!1),n.includes("mm")&&!n.includes("MMM")&&(a.minute="2-digit"),n==="W")return`T${mh(t)}`;if(n==="Q")return`Q${Math.ceil((t.getMonth()+1)/3)}`;const r=a.year||a.month||a.day||a.weekday;return(a.hour||a.minute)&&!r?t.toLocaleTimeString(i,a):t.toLocaleDateString(i,a)},mh=t=>{const n=new Date(t);n.setHours(0,0,0,0),n.setDate(n.getDate()+4-(n.getDay()||7));const i=new Date(n.getFullYear(),0,1);return Math.ceil(((n.getTime()-i.getTime())/864e5+1)/7)},uo=(t,n)=>new Date(t.getTime()+n),hh=["var(--nice-color-primary, #3b82f6)","var(--nice-color-error, #ef4444)","var(--nice-color-success, #22c55e)","var(--nice-color-warning, #f59e0b)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-color-info, #06b6d4)","var(--nice-success, #84cc16)","var(--nice-warning, #f97316)","var(--nice-color-accent, #6366f1)"],gh=Object.assign(s.forwardRef((t,n)=>{const{t:i}=c.useNiceTranslation(),{events:a=uh,groups:r=[],markers:o=[],initialZoom:l="week",initialDate:d,width:u=800,height:m=400,showToday:h=!0,showZoomControls:p=!0,showNavControls:y=!0,showMinimap:x=!1,onEventClick:b,onEventHover:g,onDateChange:v,onZoomChange:f,renderEvent:C,colors:_=hh,locale:T="pl-PL",className:S,style:N,...j}=t,[w,k]=s.useState(l),[I,M]=s.useState(d||new Date),[z,R]=s.useState(!1),[A,E]=s.useState({x:0,date:new Date}),[$,O]=s.useState(null),[V,K]=s.useState(new Set),te=s.useRef(null),B=s.useMemo(()=>ph(w),[w]),W=u*B.msPerPixel,ne=I.getTime()-W/2,ae=I.getTime()+W/2,Y=s.useMemo(()=>new Date(ne),[ne]),F=s.useMemo(()=>new Date(ae),[ae]),J=s.useCallback(U=>(U.getTime()-Y.getTime())/B.msPerPixel,[Y,B.msPerPixel]);s.useCallback(U=>{const ye=U*B.msPerPixel;return new Date(Y.getTime()+ye)},[Y,B.msPerPixel]);const re=s.useMemo(()=>{const U=[];let ye=new Date(Y);switch(w){case"hour":ye.setMinutes(0,0,0);break;case"day":ye.setHours(0,0,0,0);break;case"week":{const Ne=ye.getDay();ye.setDate(ye.getDate()-Ne+1),ye.setHours(0,0,0,0);break}case"month":ye.setDate(1),ye.setHours(0,0,0,0);break;case"quarter":ye.setMonth(Math.floor(ye.getMonth()/3)*3),ye.setDate(1),ye.setHours(0,0,0,0);break;case"year":ye.setMonth(0,1),ye.setHours(0,0,0,0);break}for(;ye<=F;){const Ne=J(ye),ze=w==="day"?ye.getDay()===1:w==="week"?ye.getDate()===1:w==="month"?ye.getMonth()%3===0:w==="quarter"?ye.getMonth()===0:!0;U.push({date:new Date(ye),x:Ne,isMain:ze,isWeekend:w==="day"&&(ye.getDay()===0||ye.getDay()===6)}),ye=uo(ye,B.unitMs)}return U},[Y,F,w,B,J]),se=s.useMemo(()=>{const U=B.unitMs/B.msPerPixel;return U<=0?1:Math.max(1,Math.ceil(40/U))},[B]),G=s.useMemo(()=>{const U=new Map;return U.set("__default",[]),r.forEach(ye=>U.set(ye.id,[])),a.forEach(ye=>{const Ne=ye.group&&U.has(ye.group)?ye.group:"__default",ze=U.get(Ne)||[];ze.push(ye),U.set(Ne,ze)}),U},[a,r]),ge=s.useMemo(()=>{const U=[];return G.get("__default")?.length&&U.push({id:"__default",title:"",events:G.get("__default")||[],isGroup:!1}),r.forEach(ye=>{V.has(ye.id)||U.push({id:ye.id,title:ye.title,events:G.get(ye.id)||[],isGroup:!0})}),U},[G,r,V]),Ce=s.useCallback(U=>{M(U),v?.(U)},[v]),he=s.useCallback(()=>{const U=ii.indexOf(w);if(U>0){const ye=ii[U-1];k(ye),f?.(ye)}},[w,f]),L=s.useCallback(()=>{const U=ii.indexOf(w);if(U<ii.length-1){const ye=ii[U+1];k(ye),f?.(ye)}},[w,f]),H=s.useCallback(U=>{k(U),f?.(U)},[f]),D=s.useCallback(U=>{const ye=uo(I,U*W*.5);Ce(ye)},[I,W,Ce]),ee=s.useCallback(U=>{U.button===0&&(R(!0),E({x:U.clientX,date:I}))},[I]),le=s.useCallback(U=>{if(!z)return;const Ne=(A.x-U.clientX)*B.msPerPixel,ze=new Date(A.date.getTime()+Ne);M(ze)},[z,A,B.msPerPixel]),ue=s.useCallback(()=>{z&&(R(!1),v?.(I))},[z,I,v]),me=s.useCallback(U=>{U.preventDefault(),U.deltaY<0?he():L()},[he,L]),de=s.useCallback(U=>{O(U),g?.(U)},[g]),oe=s.useCallback(()=>{O(null),g?.(null)},[g]),ie=s.useRef(null);c.useRovingFocus(ie,{orientation:"grid",itemSelector:".nice-timeline-event, .nice-timeline-milestone"});const Te=U=>ye=>{(ye.key==="Enter"||ye.key===" ")&&(ye.preventDefault(),b?.(U))};s.useImperativeHandle(n,()=>({goToDate:Ce,zoomIn:he,zoomOut:L,setZoom:H,getCurrentDate:()=>I,getCurrentZoom:()=>w}),[Ce,he,L,H,I,w]);const X=40,je=60,Z=Math.max(ge.length*X,m-je-40),ve=J(new Date);return e.jsxs("div",{className:`nice-timeline ${S||""}`,style:{width:u,...N},...j,children:[e.jsxs("div",{className:"nice-timeline-toolbar",children:[y&&e.jsx("div",{className:"nice-timeline-nav",children:e.jsxs(At.NiceButtonGroup,{size:"sm",children:[e.jsx(Le.NiceButton,{onClick:()=>D(-1),"aria-label":i("planning.previous","Previous"),children:e.jsx(c.NiceIcon,{name:"chevron-left",size:14})}),e.jsx(Le.NiceButton,{onClick:()=>Ce(new Date),children:i("scheduling.today","Today")}),e.jsx(Le.NiceButton,{onClick:()=>D(1),"aria-label":i("planning.next","Next"),children:e.jsx(c.NiceIcon,{name:"chevron-right",size:14})})]})}),e.jsx("div",{className:"nice-timeline-center",children:e.jsxs("span",{className:"nice-timeline-range",children:[ai(Y,"MMM d, yyyy",T)," —"," ",ai(F,"MMM d, yyyy",T)]})}),p&&e.jsx("div",{className:"nice-timeline-zoom",children:e.jsx(At.NiceButtonGroup,{size:"sm",children:ii.map(U=>e.jsx(Le.NiceButton,{variant:w===U?"primary":"secondary",onClick:()=>H(U),children:U==="hour"?i("planning.hourShort","hr"):U==="day"?i("planning.dayShort","day"):U==="week"?i("planning.weekShort","wk"):U==="month"?i("planning.monthShort","mo"):U==="quarter"?i("planning.quarterShort","qtr"):i("planning.yearShort","yr")},U))})})]}),e.jsxs("div",{ref:te,className:"nice-timeline-container",onMouseDown:ee,onMouseMove:le,onMouseUp:ue,onMouseLeave:ue,onWheel:me,style:{cursor:z?"grabbing":"grab"},children:[e.jsxs("div",{className:"nice-timeline-header",style:{height:je},children:[e.jsx("div",{className:"nice-timeline-header-main",children:B.headerFormat&&e.jsx("span",{children:ai(I,B.headerFormat,T)})}),e.jsx("div",{className:"nice-timeline-header-units",children:re.map((U,ye)=>{const Ne=ye%se===0||U.isMain,ze=w==="hour"&&U.date.getHours()===0,P=ze?"d MMM":B.unitLabel;return e.jsx("div",{className:`nice-timeline-unit ${U.isMain?"main":""} ${U.isWeekend?"nice-timeline-unit--weekend":""} ${ze?"nice-timeline-unit--midnight":""} ${Ne?"":"nice-timeline-unit--no-label"}`,style:{left:U.x},children:Ne&&e.jsx("span",{children:ai(U.date,P,T)})},ye)})})]}),e.jsxs("div",{ref:ie,className:"nice-timeline-chart",style:{height:Z},role:"group","aria-label":i("timeline.events","Events"),children:[e.jsxs("svg",{className:"nice-timeline-grid",width:u,height:Z,children:[re.map((U,ye)=>{if(!U.isWeekend)return null;const Ne=re[ye+1],ze=(Ne?Ne.x:U.x+B.unitMs/B.msPerPixel)-U.x;return e.jsx("rect",{x:U.x,y:0,width:ze,height:Z,className:"nice-timeline-weekend-band"},`wk-${ye}`)}),re.map((U,ye)=>e.jsx("line",{x1:U.x,y1:0,x2:U.x,y2:Z,className:U.isMain?"main":"minor"},ye)),h&&ve>=0&&ve<=u&&e.jsx("line",{x1:ve,y1:0,x2:ve,y2:Z,className:"today"}),ge.map((U,ye)=>e.jsx("line",{x1:0,y1:(ye+1)*X,x2:u,y2:(ye+1)*X,className:"row-sep"},ye))]}),o.map((U,ye)=>{const Ne=J(U.date);return Ne<0||Ne>u?null:e.jsx("div",{className:`nice-timeline-marker ${U.type||"line"}`,style:{left:Ne,borderColor:U.color},children:e.jsx("span",{className:"nice-timeline-marker-label",children:U.label})},ye)}),ge.map((U,ye)=>e.jsx("div",{className:"nice-timeline-row",style:{top:ye*X,height:X},children:U.events.map((Ne,ze)=>{const P=J(Ne.start),q=Ne.end?J(Ne.end):P+10,Q=Math.max(q-P,20),be=Ne.color||_[ze%_.length];return P>u||q<0?null:Ne.type==="milestone"?e.jsx("div",{className:`nice-timeline-milestone ${$?.id===Ne.id?"hovered":""}`,style:{left:P,borderColor:be},onClick:()=>b?.(Ne),onKeyDown:Te(Ne),onMouseEnter:()=>de(Ne),onMouseLeave:oe,onFocus:()=>de(Ne),onBlur:oe,role:"button","aria-label":Ne.title,title:Ne.title,children:Ne.icon||e.jsx(c.NiceIcon,{name:"diamond",size:12})},Ne.id):e.jsx("div",{className:`nice-timeline-event ${Ne.type||"event"} ${$?.id===Ne.id?"hovered":""}`,style:{left:Math.max(P,0),width:Q,backgroundColor:be},onClick:()=>b?.(Ne),onKeyDown:Te(Ne),onMouseEnter:()=>de(Ne),onMouseLeave:oe,onFocus:()=>de(Ne),onBlur:oe,role:"button","aria-label":Ne.title,title:Ne.description||Ne.title,children:C?C(Ne):e.jsx("span",{className:"nice-timeline-event-title",children:Ne.title})},Ne.id)})},U.id)),h&&ve>=0&&ve<=u&&e.jsx("div",{className:"nice-timeline-today-marker",style:{left:ve},children:e.jsx("span",{children:i("scheduling.today","Today")})})]}),$&&e.jsxs("div",{className:"nice-timeline-tooltip",style:{left:J($.start)+10},children:[e.jsx("strong",{children:$.title}),$.description&&e.jsx("p",{children:$.description}),e.jsxs("small",{children:[ai($.start,"MMM d, yyyy HH:mm",T),$.end&&` — ${ai($.end,"MMM d, yyyy HH:mm",T)}`]})]})]}),x&&e.jsx("div",{className:"nice-timeline-minimap"}),e.jsx("style",{children:`
4
4
  .nice-timeline {
5
5
  font-family: var(--nice-font-family, system-ui, -apple-system, sans-serif);
6
6
  background: var(--nice-bg-primary, white);
@@ -1284,7 +1284,7 @@ ${Q}
1284
1284
  color: var(--nice-primary, #2563eb); border-radius: var(--nice-radius-sm, 4px); padding: 4px 12px;
1285
1285
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; margin-top: 2px;
1286
1286
  }
1287
- `;class Sl{constructor(){this.components=new Map,this.actionHandlers=new Map}register(n){return this.components.set(n.type,n),this}registerAll(n){for(const i of n)this.register(i);return this}unregister(n){return this.components.delete(n)}get(n){return this.components.get(n)}has(n){return this.components.has(n)}getAll(){return Array.from(this.components.values())}getByCategory(n){return this.getAll().filter(i=>i.category===n)}getCategories(){return[...new Set(this.getAll().map(n=>n.category))]}registerAction(n,i){return this.actionHandlers.set(n,i),this}getAction(n){return this.actionHandlers.get(n)}hasAction(n){return this.actionHandlers.has(n)}getActionNames(){return Array.from(this.actionHandlers.keys())}validateTypes(n){const i=[];for(const a of n)this.has(a)||i.push(a);return i}clear(){this.components.clear(),this.actionHandlers.clear()}}const dr=xg();function xg(){const t=new Sl;return vg(t),yg(t),t}function vg(t){t.registerAll([{type:"text",label:"Text",category:"content",component:(n=>s.createElement("p",{className:"nice-view-v2__text"},String(n.content??n.text??"")))},{type:"heading",label:"Heading",category:"content",component:(n=>{const a=`h${Math.min(6,Math.max(1,Number(n.level??2)))}`;return s.createElement(a,{className:"nice-view-v2__heading"},String(n.text??""))})},{type:"container",label:"Container",category:"layout",component:(n=>s.createElement("div",{className:"nice-view-v2__container",style:{flexDirection:n.direction??"column",gap:typeof n.gap=="number"?n.gap:8}},n.children))},{type:"button",label:"Button",category:"actions",component:(n=>s.createElement("button",{type:"button",className:"nice-btn nice-btn--primary"},String(n.label??n.text??"Button")))}])}function Jt(t,n,i,a){const r=s.lazy(()=>n().then(l=>({default:i(l)}))),o=l=>s.createElement(s.Suspense,{fallback:null},s.createElement(r,l));t.register({...a,component:o})}function yg(t){Jt(t,()=>Promise.resolve().then(()=>require("./no-code-BQqK8mvU.cjs")).then(n=>n.NiceTextInput$1),n=>n.NiceTextInput,{type:"textInput",label:"Text Input",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceForm-Cl5syDvY.cjs")).then(n=>n.NiceTextArea$1),n=>n.NiceTextArea,{type:"textArea",label:"Text Area",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./no-code-BQqK8mvU.cjs")).then(n=>n.NiceNumberInput$1),n=>n.NiceNumberInput,{type:"numberInput",label:"Number Input",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./no-code-BQqK8mvU.cjs")).then(n=>n.NiceCheckbox$1),n=>n.NiceCheckbox,{type:"checkbox",label:"Checkbox",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceSelect-BNPXs6FQ.cjs")).then(n=>n.NiceSelect$1),n=>n.NiceSelect,{type:"select",label:"Select",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceForm-Cl5syDvY.cjs")).then(n=>n.NiceSlider$1),n=>n.NiceSlider,{type:"slider",label:"Slider",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceForm-Cl5syDvY.cjs")).then(n=>n.NiceRating$1),n=>n.NiceRating,{type:"rating",label:"Rating",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceForm-Cl5syDvY.cjs")).then(n=>n.NiceRadioGroup$1),n=>n.NiceRadioGroup,{type:"radioGroup",label:"Radio Group",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceForm-Cl5syDvY.cjs")).then(n=>n.NiceDateTimePicker$1),n=>n.NiceDateTimePicker,{type:"datePicker",label:"Date Picker",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceForm-Cl5syDvY.cjs")).then(n=>n.NiceDateTimePicker$1),n=>n.NiceDateTimePicker,{type:"timePicker",label:"Time Picker",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceColorPicker-BLwYNSXJ.cjs")),n=>n.NiceColorPicker,{type:"colorPicker",label:"Color Picker",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceModuleLifecyclePanel-DZHj2xTn.cjs")).then(n=>n.NiceCard$1),n=>n.NiceCard,{type:"card",label:"Card",category:"layout"})}function Oa(t,n){let i=t;for(const a of n.split(".")){if(i==null||typeof i!="object")return;i=i[a]}return i}const Ng={toUpperCase:t=>typeof t=="string"?t.toUpperCase():t,toLowerCase:t=>typeof t=="string"?t.toLowerCase():t,trim:t=>typeof t=="string"?t.trim():t,toFixed2:t=>typeof t=="number"?t.toFixed(2):t,toFixed0:t=>typeof t=="number"?t.toFixed(0):t,toString:t=>String(t??""),toNumber:t=>Number(t)||0,boolean:t=>!!t,not:t=>!t,length:t=>Array.isArray(t)||typeof t=="string"?t.length:0,json:t=>{try{return JSON.stringify(t)}catch{return""}},date:t=>{try{return new Date(t).toLocaleDateString()}catch{return String(t)}},datetime:t=>{try{return new Date(t).toLocaleString()}catch{return String(t)}},currency:t=>typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):t,percent:t=>typeof t=="number"?`${(t*100).toFixed(1)}%`:t};function _g(t,n,i){const a=t.split("|").map(o=>o.trim());let r=n;for(const o of a){if(o.startsWith("field:")){r=Oa(i,o.slice(6));continue}const l=Ng[o];l&&(r=l(r,i))}return r}function jg(t,n,i){if(!n)return;const a=n.getRecord(t.source,i);if(!a)return;const r=Oa(a,t.field);if(t.transform)try{return _g(t.transform,r,a)}catch{return r}return r}function Tl(t,n,i){const a=t.trim();if(a.startsWith("!"))return!Tl(a.slice(1),n,i);const r=a.match(/^([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)\s*(===?|!==?|>=?|<=?)\s*(.+)$/);if(r){const[,d,u,m]=r,[h,...p]=d.split("."),y=n.getRecord(h,i),x=y?Oa(y,p.join(".")):void 0;let b=m.trim();switch(b==="true"?b=!0:b==="false"?b=!1:b==="null"||b==="undefined"?b=void 0:/^-?\d+(\.\d+)?$/.test(b)?b=Number(b):(b.startsWith("'")&&b.endsWith("'")||b.startsWith('"')&&b.endsWith('"'))&&(b=b.slice(1,-1)),u){case"==":case"===":return x===b;case"!=":case"!==":return x!==b;case">":return Number(x)>Number(b);case">=":return Number(x)>=Number(b);case"<":return Number(x)<Number(b);case"<=":return Number(x)<=Number(b);default:return!0}}const[o,...l]=a.split(".");if(o){const d=n.getRecord(o,i);return d?!!(l.length?Oa(d,l.join(".")):d):!1}return!0}function xo(t,n,i){if(!t||!n)return!0;try{return Tl(t,n,i)}catch{return!0}}function vo(t,n){if(!t||t.length===0)return"editable";if(!n||n.length===0)return"hidden";let i="hidden";const a={hidden:0,readonly:1,editable:2};for(const r of t)(n.includes(r.role)||r.role==="*")&&a[r.access]>a[i]&&(i=r.access);return i}function wg(t,n){return t+1}const El=Object.assign(s.forwardRef(({view:t,registry:n=dr,dataStore:i,userRoles:a,onNavigate:r,onNotify:o,onOpenDialog:l,onCloseDialog:d,fallback:u,recordIndex:m,onRunScript:h,className:p,style:y,id:x,...b},g)=>{const{t:v}=c.useNiceTranslation(),{confirm:f,element:C}=xt.useNiceDialogs(),[,_]=s.useReducer(wg,0),T=s.useRef(_);T.current=_;const S=s.useMemo(()=>({dataSources:new Proxy({},{get:(A,E)=>i?.get(E)}),navigate:A=>r?.(A),notify:(A,E)=>o?.(A,E),refreshDataSource:A=>{i?.refresh(A),T.current({type:"tick"})},openDialog:A=>l?.(A),closeDialog:()=>d?.()}),[i,r,o,l,d]),N=s.useCallback(async A=>{for(const E of A)if(!(E.confirm&&!await f({message:E.confirm})))try{switch(E.type){case"navigate":E.target&&S.navigate(E.target);break;case"apiCall":if(E.endpoint){const $=E.endpoint.trim().toLowerCase();if(!$.startsWith("http://")&&!$.startsWith("https://")&&!$.startsWith("/")){console.warn("[NiceViewRenderer] Blocked unsafe endpoint:",E.endpoint);break}await fetch(E.endpoint,{method:E.method??"POST",headers:{"Content-Type":"application/json"},body:E.body?JSON.stringify(E.body):void 0})}E.successMessage&&S.notify(E.successMessage,"success");break;case"setField":if(E.field&&i){const[$,...O]=E.field.split(".");i.setField($,O.join("."),E.value,m)}break;case"refresh":E.dataSourceKey&&S.refreshDataSource(E.dataSourceKey);break;case"openDialog":E.dialogViewId&&S.openDialog(E.dialogViewId);break;case"closeDialog":S.closeDialog();break;case"submit":break;case"custom":{const $=E.handler?n.getAction(E.handler):void 0;$&&await $(E.params??{},S);break}case"script":E.script&&(h?await h(E.script,{language:E.language??"js",action:E,context:S}):typeof console<"u"&&console.warn("[NiceViewRenderer] script action skipped: no onRunScript handler provided.",E));break}}catch($){const O=E.errorMessage??`Action failed: ${$.message}`;S.notify(O,"error")}},[S,i,m,n,h,f]),j=s.useCallback(A=>{if(!xo(A.visibleWhen,i,m))return null;const E=vo(A.permissions,a);if(E==="hidden")return null;const $={...A.props};if(A.bindings){for(const[K,te]of Object.entries(A.bindings))if($[K]=jg(te,i,m),te.twoWay){const B=`on${K.charAt(0).toUpperCase()}${K.slice(1)}Change`;$[B]=W=>{i?.setField(te.source,te.field,W,m),T.current({type:"tick"})}}}if(E==="readonly"&&($.disabled=!0,$.readOnly=!0),A.events)for(const K of A.events)$[K.event]=(...te)=>{N(K.actions)};const O=n.get(A.controlType);if(!O)return u?e.jsx(u,{controlType:A.controlType}):e.jsx("div",{className:"nice-view-v2__unknown",children:v("view.unknownControl","Unknown control: {type}").replace("{type}",A.controlType)});const V=O.component;return e.jsx(V,{...O.defaultProps??{},...$})},[n,i,a,m,N,u,v]),w=s.useCallback((A,E)=>A.map($=>xo($.visibleWhen,i,m)?e.jsx("div",{className:`nice-view-v2__row ${$.cssClass??""}`,style:{gridTemplateColumns:`repeat(${E}, 1fr)`,...$.height?{minHeight:$.height}:{}},children:$.cells.map(O=>e.jsx("div",{className:`nice-view-v2__cell ${O.cssClass??""}`,style:{gridColumn:O.colSpan?`span ${O.colSpan}`:void 0,gridRow:O.rowSpan?`span ${O.rowSpan}`:void 0},children:j(O)},O.id))},$.id):null),[j,i,m]),k=s.useCallback((A,E)=>{switch(A.type){case"tabs":return e.jsx("div",{className:"nice-view-v2__tabs",children:A.sections.map($=>e.jsxs("div",{className:"nice-view-v2__tab-panel",children:[$.label&&e.jsx("div",{className:"nice-view-v2__tab-label",children:$.label}),$.rows&&w($.rows,E),$.container&&k($.container,E)]},$.id))});case"accordion":return e.jsx("div",{className:"nice-view-v2__accordion",children:A.sections.map($=>e.jsxs("details",{className:"nice-view-v2__accordion-panel",children:[e.jsx("summary",{children:$.label??$.id}),$.rows&&w($.rows,E),$.container&&k($.container,E)]},$.id))});case"splitter":{const $=A.props?.sizes??A.sections.map(()=>"1fr");return e.jsx("div",{className:"nice-view-v2__splitter",style:{gridTemplateColumns:$.join(" ")},children:A.sections.map(O=>e.jsxs("div",{className:"nice-view-v2__splitter-panel",children:[O.rows&&w(O.rows,E),O.container&&k(O.container,E)]},O.id))})}case"stack":return e.jsx("div",{className:"nice-view-v2__stack",children:A.sections.map($=>e.jsxs("div",{children:[$.label&&e.jsx("h3",{className:"nice-view-v2__section-label",children:$.label}),$.rows&&w($.rows,E),$.container&&k($.container,E)]},$.id))});default:return e.jsx(e.Fragment,{children:A.sections.map($=>e.jsxs("div",{children:[$.label&&e.jsx("h3",{className:"nice-view-v2__section-label",children:$.label}),$.rows&&w($.rows,E),$.container&&k($.container,E)]},$.id))})}},[w]),I=s.useCallback(A=>!A||A.length===0?null:A.map((E,$)=>e.jsx("div",{className:`nice-view-v2__toolbar nice-view-v2__toolbar--${E.position}`,children:E.items.map(O=>O.type==="separator"?e.jsx("span",{className:"nice-view-v2__toolbar-sep"},O.id):O.type==="spacer"?e.jsx("span",{className:"nice-view-v2__toolbar-spacer"},O.id):e.jsxs("button",{type:"button",className:"nice-view-v2__toolbar-btn",disabled:typeof O.disabled=="boolean"?O.disabled:!1,onClick:()=>O.actions&&void N(O.actions),children:[O.icon&&e.jsx("span",{className:"nice-view-v2__toolbar-icon",children:e.jsx(c.NiceIcon,{name:O.icon,size:14})}),O.label]},O.id))},$)),[N]);if(vo(t.permissions?.map(A=>({...A})),a)==="hidden")return null;const z=t.toolbars?.filter(A=>A.position==="top"),R=t.toolbars?.filter(A=>A.position==="bottom");return e.jsxs("div",{ref:g,id:x,className:`nice-view-v2 ${p??""}`,style:y,"data-view-id":t.id,"data-view-module":t.module,...b,children:[C,I(z),t.container?k(t.container,t.columns??12):t.rows&&w(t.rows,t.columns??12),I(R)]})}),{displayName:"NiceViewRenderer"});function kg(t){const n=[];for(const i of t??[])for(const a of i.cells??[])n.push(a);return n}function ur(t,n){if(Array.isArray(n))return n;if(n&&typeof n=="object"){const i=n,a=t.dataSources?.[0]?.key;if(a&&Array.isArray(i[a]))return i[a];const r=Object.values(i).find(o=>Array.isArray(o));if(Array.isArray(r))return r}return[]}function pr(t,n){const i=[],a=new Set;for(const r of kg(t.rows)){const o=r,l=o.binding?.field??o.props?.field;l&&!a.has(l)&&(a.add(l),i.push({field:l,header:o.label??o.props?.label??l}))}if(i.length===0&&n.length>0)for(const r of Object.keys(n[0]))i.push({field:r,header:r});return i}function is(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function As(t,n,i={}){const a=ur(t,n),r=i.columns??pr(t,a),o=is(t.name||"Report"),l=r.length>0?`<table><thead><tr>${r.map(d=>`<th>${is(d.header)}</th>`).join("")}</tr></thead><tbody>${a.map(d=>`<tr>${r.map(u=>`<td>${is(d[u.field])}</td>`).join("")}</tr>`).join("")}</tbody></table>`:"<p>No data.</p>";return`<!doctype html><html><head><meta charset="utf-8"><title>${o}</title><style>body{font-family:Inter,system-ui,Arial,sans-serif;color:#111;margin:24px;}h1{font-size:18px;margin:0 0 16px;}table{border-collapse:collapse;width:100%;font-size:12px;}th,td{border:1px solid #ccc;padding:6px 8px;text-align:left;}thead th{background:#f3f4f6;}@media print{body{margin:0;}@page{margin:16mm;}}</style></head><body><h1>${o}</h1>${l}</body></html>`}function yo(t,n,i){if(typeof document>"u")return;const a=new Blob([t],{type:n}),r=URL.createObjectURL(a),o=document.createElement("a");o.href=r,o.download=i,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}async function Il(t,n,i,a={}){const r=ur(t,n);if(a.onExport){await a.onExport(t,r,i);return}const o=a.columns??pr(t,r),l=a.fileName??t.name??"export";switch(i){case"csv":Mt.downloadCSV(r,o,{fileName:l});return;case"xlsx":Mt.downloadXLSX(r,o,{fileName:l,sheetName:t.name||"Sheet1"});return;case"html":yo(As(t,n,{columns:o}),"text/html;charset=utf-8",`${l}.html`);return;case"docx":yo(As(t,n,{columns:o}),"application/msword",`${l}.doc`);return;case"pdf":default:Mt.exportToPDF(r,o,{title:t.name});return}}const Cg=[{target:".nice-view-editor",titleKey:"tutorial.viewEditor.intro.title",title:"View editor",contentKey:"tutorial.viewEditor.intro.content",content:"Author any view kind from one place: choose the kind (or scaffold from an entity), drag controls from the palette into the grid cells, then configure each cell — data binding, role permissions and event actions. Switch Design / Preview / Source, and Save when valid.",placement:"auto"},{target:".nice-view-editor__palette",titleKey:"tutorial.viewEditor.palette.title",title:"Palette",contentKey:"tutorial.viewEditor.palette.content",content:"Add controls from the palette into the grid — inputs, data grids, charts, KPIs, buttons and display blocks.",placement:"right"},{target:".nice-view-editor__canvas",titleKey:"tutorial.viewEditor.canvas.title",title:"Canvas",contentKey:"tutorial.viewEditor.canvas.content",content:"Arrange cells into rows and set each cell’s column span. Click a cell to configure it.",placement:"auto"},{target:".nice-view-editor__props",titleKey:"tutorial.viewEditor.props.title",title:"Properties",contentKey:"tutorial.viewEditor.props.content",content:"Configure the selected control: props, data binding, role permissions and event actions. With nothing selected, manage the view’s data sources.",placement:"left"},{target:".nice-view-editor__modes",titleKey:"tutorial.viewEditor.modes.title",title:"Design / Preview / Source",contentKey:"tutorial.viewEditor.modes.content",content:"Switch between the visual designer, a live preview, and the raw NiceViewDefinition JSON. Save when the view is valid.",placement:"bottom"}],Sg=[{category:"Inputs",items:[{type:"textInput",label:"Text"},{type:"textArea",label:"Text area"},{type:"numberInput",label:"Number"},{type:"select",label:"Select"},{type:"checkbox",label:"Checkbox"},{type:"datePicker",label:"Date"}]},{category:"Data",items:[{type:"dataGrid",label:"Data grid"}]},{category:"BI",items:[{type:"chart",label:"Chart"},{type:"kpi",label:"KPI"}]},{category:"Actions",items:[{type:"button",label:"Button"}]},{category:"Display",items:[{type:"text",label:"Text"},{type:"heading",label:"Heading"},{type:"badge",label:"Badge"},{type:"card",label:"Card"}]}],Tg=["rest","odata","graphql","static","query","entity"],Eg=["hidden","readonly","editable"],Ig=[{value:"form",label:"Form"},{value:"detail",label:"Detail"},{value:"grid",label:"Grid"},{value:"dashboard",label:"Dashboard"},{value:"content",label:"Content"},{value:"report",label:"Report"},{value:"print",label:"Print"},{value:"mix",label:"Mix"}],Dg=new Set(["report","print","grid"]),Pg=["pdf","docx","xlsx","csv","html"];let Ag=0;const Ea=t=>`${t}-${Date.now().toString(36)}-${(Ag++).toString(36)}`;function Rg(){return{id:Ea("view"),name:"New View",version:2,columns:12,rows:[],dataSources:[]}}function $g(t){const n={};for(const i of t.dataSources??[]){const a=i.data;n[i.key]=Array.isArray(a)&&a.length>0?a:[{}]}return{get:i=>n[i],getRecord:(i,a=0)=>n[i]?.[a]??{},setField:(i,a,r,o=0)=>{const l=n[i]??(n[i]=[{}]),d=l[o]??(l[o]={});d[a]=r},refresh:()=>{}}}const Mg=s.forwardRef(function(n,i){const a=s.useRef(null);c.useRovingFocus(a,{orientation:"horizontal",wrap:!0,activateOnMove:!0}),fn.injectStyleOnce(Lg,Bg);const{value:r,onChange:o,registry:l=dr,entities:d,dataSourceOptions:u,onSave:m,onExport:h,height:p=560,tutorial:y,className:x,style:b,id:g,"data-testid":v}=n,{t:f}=c.useNiceTranslation(),[C,_]=s.useState(()=>r??Rg()),T=r??C,[S,N]=s.useState(null),[j,w]=s.useState("design"),k=s.useCallback(L=>{o?o(L):_(L)},[o]),I=s.useMemo(()=>T.rows??[],[T.rows]),M=(T.dataSources??[]).map(L=>L.key),z=s.useMemo(()=>l.getActionNames(),[l]),A=s.useCallback(L=>{if(!L)return null;for(const H of I){const D=H.cells.find(ee=>ee.id===L);if(D)return{row:H,cell:D}}return null},[I])(S),E=L=>k({...T,rows:L}),$=(L,H)=>E(I.map(D=>({...D,cells:D.cells.map(ee=>ee.id===L?{...ee,...H}:ee)}))),O=()=>E([...I,{id:Ea("row"),cells:[]}]),V=L=>{const H={id:Ea("cell"),controlType:L,props:{label:L},colSpan:6},D=I.length>0?I.slice():[{id:Ea("row"),cells:[]}];D[D.length-1]={...D[D.length-1],cells:[...D[D.length-1].cells,H]},E(D),N(H.id)},K=L=>{E(I.map(H=>({...H,cells:H.cells.filter(D=>D.id!==L)}))),S===L&&N(null)},te=(L,H)=>{const D=d?.find(ee=>ee.name===L);D&&(k(kl(D,H)),N(null))},B=s.useMemo(()=>(d??[]).map(L=>L.name).filter(L=>!!L),[d]),W=s.useMemo(()=>lr(T),[T]),ne=s.useMemo(()=>$g(T),[T]),ae=s.useMemo(()=>{const L={};for(const H of T.dataSources??[]){const D=H.data;L[H.key]=Array.isArray(D)?D:[]}return L},[T]),Y=T.kind??T.meta?.kind??"form",F=L=>{Il(T,ae,L,{onExport:h})},J=e.jsxs("div",{className:"nice-view-editor__toolbar",children:[e.jsx("input",{className:"nice-view-editor__name",value:T.name,onChange:L=>k({...T,name:L.target.value}),placeholder:f("viewEditor.name","View name"),"aria-label":f("viewEditor.name","View name")}),e.jsx("select",{className:"nice-view-editor__kind",value:Y,onChange:L=>k({...T,kind:L.target.value}),"aria-label":f("viewEditor.kindAria","View kind"),children:Ig.map(L=>e.jsx("option",{value:L.value,children:f("viewEditor.kind."+L.value,L.label)},L.value))}),d&&d.length>0&&e.jsxs("select",{className:"nice-view-editor__from-entity",value:"",onChange:L=>{const[H,D]=L.target.value.split("::");H&&te(H,D)},"aria-label":f("viewEditor.fromEntityAria","New view from entity"),children:[e.jsx("option",{value:"",children:f("viewEditor.fromEntity","New from entity…")}),d.map(L=>["form","detail","grid"].map(H=>e.jsxs("option",{value:`${L.name}::${H}`,children:[L.name," · ",H]},`${L.name}-${H}`)))]}),Dg.has(Y)&&e.jsxs("select",{className:"nice-view-editor__export",value:"",onChange:L=>{const H=L.target.value;H&&F(H)},"aria-label":f("viewEditor.exportAria","Export view"),children:[e.jsx("option",{value:"",children:f("viewEditor.export","Export…")}),Pg.map(L=>e.jsx("option",{value:L,children:L.toUpperCase()},L))]}),e.jsx("span",{className:"nice-view-editor__spacer"}),e.jsx("div",{className:"nice-view-editor__modes",ref:a,role:"tablist",children:["design","preview","source"].map(L=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===L,className:"nice-view-editor__mode"+(j===L?" nice-view-editor__mode--active":""),onClick:()=>w(L),children:f("viewEditor.mode."+L,L[0].toUpperCase()+L.slice(1))},L))}),e.jsxs("span",{className:"nice-view-editor__status"+(W.length?" nice-view-editor__status--err":""),title:W.join(`
1287
+ `;class Sl{constructor(){this.components=new Map,this.actionHandlers=new Map}register(n){return this.components.set(n.type,n),this}registerAll(n){for(const i of n)this.register(i);return this}unregister(n){return this.components.delete(n)}get(n){return this.components.get(n)}has(n){return this.components.has(n)}getAll(){return Array.from(this.components.values())}getByCategory(n){return this.getAll().filter(i=>i.category===n)}getCategories(){return[...new Set(this.getAll().map(n=>n.category))]}registerAction(n,i){return this.actionHandlers.set(n,i),this}getAction(n){return this.actionHandlers.get(n)}hasAction(n){return this.actionHandlers.has(n)}getActionNames(){return Array.from(this.actionHandlers.keys())}validateTypes(n){const i=[];for(const a of n)this.has(a)||i.push(a);return i}clear(){this.components.clear(),this.actionHandlers.clear()}}const dr=xg();function xg(){const t=new Sl;return vg(t),yg(t),t}function vg(t){t.registerAll([{type:"text",label:"Text",category:"content",component:(n=>s.createElement("p",{className:"nice-view-v2__text"},String(n.content??n.text??"")))},{type:"heading",label:"Heading",category:"content",component:(n=>{const a=`h${Math.min(6,Math.max(1,Number(n.level??2)))}`;return s.createElement(a,{className:"nice-view-v2__heading"},String(n.text??""))})},{type:"container",label:"Container",category:"layout",component:(n=>s.createElement("div",{className:"nice-view-v2__container",style:{flexDirection:n.direction??"column",gap:typeof n.gap=="number"?n.gap:8}},n.children))},{type:"button",label:"Button",category:"actions",component:(n=>s.createElement("button",{type:"button",className:"nice-btn nice-btn--primary"},String(n.label??n.text??"Button")))}])}function Jt(t,n,i,a){const r=s.lazy(()=>n().then(l=>({default:i(l)}))),o=l=>s.createElement(s.Suspense,{fallback:null},s.createElement(r,l));t.register({...a,component:o})}function yg(t){Jt(t,()=>Promise.resolve().then(()=>require("./no-code-BQqK8mvU.cjs")).then(n=>n.NiceTextInput$1),n=>n.NiceTextInput,{type:"textInput",label:"Text Input",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceForm-Cxvh2O6y.cjs")).then(n=>n.NiceTextArea$1),n=>n.NiceTextArea,{type:"textArea",label:"Text Area",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./no-code-BQqK8mvU.cjs")).then(n=>n.NiceNumberInput$1),n=>n.NiceNumberInput,{type:"numberInput",label:"Number Input",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./no-code-BQqK8mvU.cjs")).then(n=>n.NiceCheckbox$1),n=>n.NiceCheckbox,{type:"checkbox",label:"Checkbox",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceSelect-BNPXs6FQ.cjs")).then(n=>n.NiceSelect$1),n=>n.NiceSelect,{type:"select",label:"Select",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceForm-Cxvh2O6y.cjs")).then(n=>n.NiceSlider$1),n=>n.NiceSlider,{type:"slider",label:"Slider",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceForm-Cxvh2O6y.cjs")).then(n=>n.NiceRating$1),n=>n.NiceRating,{type:"rating",label:"Rating",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceForm-Cxvh2O6y.cjs")).then(n=>n.NiceRadioGroup$1),n=>n.NiceRadioGroup,{type:"radioGroup",label:"Radio Group",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceForm-Cxvh2O6y.cjs")).then(n=>n.NiceDateTimePicker$1),n=>n.NiceDateTimePicker,{type:"datePicker",label:"Date Picker",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceForm-Cxvh2O6y.cjs")).then(n=>n.NiceDateTimePicker$1),n=>n.NiceDateTimePicker,{type:"timePicker",label:"Time Picker",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceColorPicker-BLwYNSXJ.cjs")),n=>n.NiceColorPicker,{type:"colorPicker",label:"Color Picker",category:"input"}),Jt(t,()=>Promise.resolve().then(()=>require("./NiceModuleLifecyclePanel-DHHAjwQx.cjs")).then(n=>n.NiceCard$1),n=>n.NiceCard,{type:"card",label:"Card",category:"layout"})}function Oa(t,n){let i=t;for(const a of n.split(".")){if(i==null||typeof i!="object")return;i=i[a]}return i}const Ng={toUpperCase:t=>typeof t=="string"?t.toUpperCase():t,toLowerCase:t=>typeof t=="string"?t.toLowerCase():t,trim:t=>typeof t=="string"?t.trim():t,toFixed2:t=>typeof t=="number"?t.toFixed(2):t,toFixed0:t=>typeof t=="number"?t.toFixed(0):t,toString:t=>String(t??""),toNumber:t=>Number(t)||0,boolean:t=>!!t,not:t=>!t,length:t=>Array.isArray(t)||typeof t=="string"?t.length:0,json:t=>{try{return JSON.stringify(t)}catch{return""}},date:t=>{try{return new Date(t).toLocaleDateString()}catch{return String(t)}},datetime:t=>{try{return new Date(t).toLocaleString()}catch{return String(t)}},currency:t=>typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):t,percent:t=>typeof t=="number"?`${(t*100).toFixed(1)}%`:t};function _g(t,n,i){const a=t.split("|").map(o=>o.trim());let r=n;for(const o of a){if(o.startsWith("field:")){r=Oa(i,o.slice(6));continue}const l=Ng[o];l&&(r=l(r,i))}return r}function jg(t,n,i){if(!n)return;const a=n.getRecord(t.source,i);if(!a)return;const r=Oa(a,t.field);if(t.transform)try{return _g(t.transform,r,a)}catch{return r}return r}function Tl(t,n,i){const a=t.trim();if(a.startsWith("!"))return!Tl(a.slice(1),n,i);const r=a.match(/^([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)\s*(===?|!==?|>=?|<=?)\s*(.+)$/);if(r){const[,d,u,m]=r,[h,...p]=d.split("."),y=n.getRecord(h,i),x=y?Oa(y,p.join(".")):void 0;let b=m.trim();switch(b==="true"?b=!0:b==="false"?b=!1:b==="null"||b==="undefined"?b=void 0:/^-?\d+(\.\d+)?$/.test(b)?b=Number(b):(b.startsWith("'")&&b.endsWith("'")||b.startsWith('"')&&b.endsWith('"'))&&(b=b.slice(1,-1)),u){case"==":case"===":return x===b;case"!=":case"!==":return x!==b;case">":return Number(x)>Number(b);case">=":return Number(x)>=Number(b);case"<":return Number(x)<Number(b);case"<=":return Number(x)<=Number(b);default:return!0}}const[o,...l]=a.split(".");if(o){const d=n.getRecord(o,i);return d?!!(l.length?Oa(d,l.join(".")):d):!1}return!0}function xo(t,n,i){if(!t||!n)return!0;try{return Tl(t,n,i)}catch{return!0}}function vo(t,n){if(!t||t.length===0)return"editable";if(!n||n.length===0)return"hidden";let i="hidden";const a={hidden:0,readonly:1,editable:2};for(const r of t)(n.includes(r.role)||r.role==="*")&&a[r.access]>a[i]&&(i=r.access);return i}function wg(t,n){return t+1}const El=Object.assign(s.forwardRef(({view:t,registry:n=dr,dataStore:i,userRoles:a,onNavigate:r,onNotify:o,onOpenDialog:l,onCloseDialog:d,fallback:u,recordIndex:m,onRunScript:h,className:p,style:y,id:x,...b},g)=>{const{t:v}=c.useNiceTranslation(),{confirm:f,element:C}=xt.useNiceDialogs(),[,_]=s.useReducer(wg,0),T=s.useRef(_);T.current=_;const S=s.useMemo(()=>({dataSources:new Proxy({},{get:(A,E)=>i?.get(E)}),navigate:A=>r?.(A),notify:(A,E)=>o?.(A,E),refreshDataSource:A=>{i?.refresh(A),T.current({type:"tick"})},openDialog:A=>l?.(A),closeDialog:()=>d?.()}),[i,r,o,l,d]),N=s.useCallback(async A=>{for(const E of A)if(!(E.confirm&&!await f({message:E.confirm})))try{switch(E.type){case"navigate":E.target&&S.navigate(E.target);break;case"apiCall":if(E.endpoint){const $=E.endpoint.trim().toLowerCase();if(!$.startsWith("http://")&&!$.startsWith("https://")&&!$.startsWith("/")){console.warn("[NiceViewRenderer] Blocked unsafe endpoint:",E.endpoint);break}await fetch(E.endpoint,{method:E.method??"POST",headers:{"Content-Type":"application/json"},body:E.body?JSON.stringify(E.body):void 0})}E.successMessage&&S.notify(E.successMessage,"success");break;case"setField":if(E.field&&i){const[$,...O]=E.field.split(".");i.setField($,O.join("."),E.value,m)}break;case"refresh":E.dataSourceKey&&S.refreshDataSource(E.dataSourceKey);break;case"openDialog":E.dialogViewId&&S.openDialog(E.dialogViewId);break;case"closeDialog":S.closeDialog();break;case"submit":break;case"custom":{const $=E.handler?n.getAction(E.handler):void 0;$&&await $(E.params??{},S);break}case"script":E.script&&(h?await h(E.script,{language:E.language??"js",action:E,context:S}):typeof console<"u"&&console.warn("[NiceViewRenderer] script action skipped: no onRunScript handler provided.",E));break}}catch($){const O=E.errorMessage??`Action failed: ${$.message}`;S.notify(O,"error")}},[S,i,m,n,h,f]),j=s.useCallback(A=>{if(!xo(A.visibleWhen,i,m))return null;const E=vo(A.permissions,a);if(E==="hidden")return null;const $={...A.props};if(A.bindings){for(const[K,te]of Object.entries(A.bindings))if($[K]=jg(te,i,m),te.twoWay){const B=`on${K.charAt(0).toUpperCase()}${K.slice(1)}Change`;$[B]=W=>{i?.setField(te.source,te.field,W,m),T.current({type:"tick"})}}}if(E==="readonly"&&($.disabled=!0,$.readOnly=!0),A.events)for(const K of A.events)$[K.event]=(...te)=>{N(K.actions)};const O=n.get(A.controlType);if(!O)return u?e.jsx(u,{controlType:A.controlType}):e.jsx("div",{className:"nice-view-v2__unknown",children:v("view.unknownControl","Unknown control: {type}").replace("{type}",A.controlType)});const V=O.component;return e.jsx(V,{...O.defaultProps??{},...$})},[n,i,a,m,N,u,v]),w=s.useCallback((A,E)=>A.map($=>xo($.visibleWhen,i,m)?e.jsx("div",{className:`nice-view-v2__row ${$.cssClass??""}`,style:{gridTemplateColumns:`repeat(${E}, 1fr)`,...$.height?{minHeight:$.height}:{}},children:$.cells.map(O=>e.jsx("div",{className:`nice-view-v2__cell ${O.cssClass??""}`,style:{gridColumn:O.colSpan?`span ${O.colSpan}`:void 0,gridRow:O.rowSpan?`span ${O.rowSpan}`:void 0},children:j(O)},O.id))},$.id):null),[j,i,m]),k=s.useCallback((A,E)=>{switch(A.type){case"tabs":return e.jsx("div",{className:"nice-view-v2__tabs",children:A.sections.map($=>e.jsxs("div",{className:"nice-view-v2__tab-panel",children:[$.label&&e.jsx("div",{className:"nice-view-v2__tab-label",children:$.label}),$.rows&&w($.rows,E),$.container&&k($.container,E)]},$.id))});case"accordion":return e.jsx("div",{className:"nice-view-v2__accordion",children:A.sections.map($=>e.jsxs("details",{className:"nice-view-v2__accordion-panel",children:[e.jsx("summary",{children:$.label??$.id}),$.rows&&w($.rows,E),$.container&&k($.container,E)]},$.id))});case"splitter":{const $=A.props?.sizes??A.sections.map(()=>"1fr");return e.jsx("div",{className:"nice-view-v2__splitter",style:{gridTemplateColumns:$.join(" ")},children:A.sections.map(O=>e.jsxs("div",{className:"nice-view-v2__splitter-panel",children:[O.rows&&w(O.rows,E),O.container&&k(O.container,E)]},O.id))})}case"stack":return e.jsx("div",{className:"nice-view-v2__stack",children:A.sections.map($=>e.jsxs("div",{children:[$.label&&e.jsx("h3",{className:"nice-view-v2__section-label",children:$.label}),$.rows&&w($.rows,E),$.container&&k($.container,E)]},$.id))});default:return e.jsx(e.Fragment,{children:A.sections.map($=>e.jsxs("div",{children:[$.label&&e.jsx("h3",{className:"nice-view-v2__section-label",children:$.label}),$.rows&&w($.rows,E),$.container&&k($.container,E)]},$.id))})}},[w]),I=s.useCallback(A=>!A||A.length===0?null:A.map((E,$)=>e.jsx("div",{className:`nice-view-v2__toolbar nice-view-v2__toolbar--${E.position}`,children:E.items.map(O=>O.type==="separator"?e.jsx("span",{className:"nice-view-v2__toolbar-sep"},O.id):O.type==="spacer"?e.jsx("span",{className:"nice-view-v2__toolbar-spacer"},O.id):e.jsxs("button",{type:"button",className:"nice-view-v2__toolbar-btn",disabled:typeof O.disabled=="boolean"?O.disabled:!1,onClick:()=>O.actions&&void N(O.actions),children:[O.icon&&e.jsx("span",{className:"nice-view-v2__toolbar-icon",children:e.jsx(c.NiceIcon,{name:O.icon,size:14})}),O.label]},O.id))},$)),[N]);if(vo(t.permissions?.map(A=>({...A})),a)==="hidden")return null;const z=t.toolbars?.filter(A=>A.position==="top"),R=t.toolbars?.filter(A=>A.position==="bottom");return e.jsxs("div",{ref:g,id:x,className:`nice-view-v2 ${p??""}`,style:y,"data-view-id":t.id,"data-view-module":t.module,...b,children:[C,I(z),t.container?k(t.container,t.columns??12):t.rows&&w(t.rows,t.columns??12),I(R)]})}),{displayName:"NiceViewRenderer"});function kg(t){const n=[];for(const i of t??[])for(const a of i.cells??[])n.push(a);return n}function ur(t,n){if(Array.isArray(n))return n;if(n&&typeof n=="object"){const i=n,a=t.dataSources?.[0]?.key;if(a&&Array.isArray(i[a]))return i[a];const r=Object.values(i).find(o=>Array.isArray(o));if(Array.isArray(r))return r}return[]}function pr(t,n){const i=[],a=new Set;for(const r of kg(t.rows)){const o=r,l=o.binding?.field??o.props?.field;l&&!a.has(l)&&(a.add(l),i.push({field:l,header:o.label??o.props?.label??l}))}if(i.length===0&&n.length>0)for(const r of Object.keys(n[0]))i.push({field:r,header:r});return i}function is(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function As(t,n,i={}){const a=ur(t,n),r=i.columns??pr(t,a),o=is(t.name||"Report"),l=r.length>0?`<table><thead><tr>${r.map(d=>`<th>${is(d.header)}</th>`).join("")}</tr></thead><tbody>${a.map(d=>`<tr>${r.map(u=>`<td>${is(d[u.field])}</td>`).join("")}</tr>`).join("")}</tbody></table>`:"<p>No data.</p>";return`<!doctype html><html><head><meta charset="utf-8"><title>${o}</title><style>body{font-family:Inter,system-ui,Arial,sans-serif;color:#111;margin:24px;}h1{font-size:18px;margin:0 0 16px;}table{border-collapse:collapse;width:100%;font-size:12px;}th,td{border:1px solid #ccc;padding:6px 8px;text-align:left;}thead th{background:#f3f4f6;}@media print{body{margin:0;}@page{margin:16mm;}}</style></head><body><h1>${o}</h1>${l}</body></html>`}function yo(t,n,i){if(typeof document>"u")return;const a=new Blob([t],{type:n}),r=URL.createObjectURL(a),o=document.createElement("a");o.href=r,o.download=i,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}async function Il(t,n,i,a={}){const r=ur(t,n);if(a.onExport){await a.onExport(t,r,i);return}const o=a.columns??pr(t,r),l=a.fileName??t.name??"export";switch(i){case"csv":Mt.downloadCSV(r,o,{fileName:l});return;case"xlsx":Mt.downloadXLSX(r,o,{fileName:l,sheetName:t.name||"Sheet1"});return;case"html":yo(As(t,n,{columns:o}),"text/html;charset=utf-8",`${l}.html`);return;case"docx":yo(As(t,n,{columns:o}),"application/msword",`${l}.doc`);return;case"pdf":default:Mt.exportToPDF(r,o,{title:t.name});return}}const Cg=[{target:".nice-view-editor",titleKey:"tutorial.viewEditor.intro.title",title:"View editor",contentKey:"tutorial.viewEditor.intro.content",content:"Author any view kind from one place: choose the kind (or scaffold from an entity), drag controls from the palette into the grid cells, then configure each cell — data binding, role permissions and event actions. Switch Design / Preview / Source, and Save when valid.",placement:"auto"},{target:".nice-view-editor__palette",titleKey:"tutorial.viewEditor.palette.title",title:"Palette",contentKey:"tutorial.viewEditor.palette.content",content:"Add controls from the palette into the grid — inputs, data grids, charts, KPIs, buttons and display blocks.",placement:"right"},{target:".nice-view-editor__canvas",titleKey:"tutorial.viewEditor.canvas.title",title:"Canvas",contentKey:"tutorial.viewEditor.canvas.content",content:"Arrange cells into rows and set each cell’s column span. Click a cell to configure it.",placement:"auto"},{target:".nice-view-editor__props",titleKey:"tutorial.viewEditor.props.title",title:"Properties",contentKey:"tutorial.viewEditor.props.content",content:"Configure the selected control: props, data binding, role permissions and event actions. With nothing selected, manage the view’s data sources.",placement:"left"},{target:".nice-view-editor__modes",titleKey:"tutorial.viewEditor.modes.title",title:"Design / Preview / Source",contentKey:"tutorial.viewEditor.modes.content",content:"Switch between the visual designer, a live preview, and the raw NiceViewDefinition JSON. Save when the view is valid.",placement:"bottom"}],Sg=[{category:"Inputs",items:[{type:"textInput",label:"Text"},{type:"textArea",label:"Text area"},{type:"numberInput",label:"Number"},{type:"select",label:"Select"},{type:"checkbox",label:"Checkbox"},{type:"datePicker",label:"Date"}]},{category:"Data",items:[{type:"dataGrid",label:"Data grid"}]},{category:"BI",items:[{type:"chart",label:"Chart"},{type:"kpi",label:"KPI"}]},{category:"Actions",items:[{type:"button",label:"Button"}]},{category:"Display",items:[{type:"text",label:"Text"},{type:"heading",label:"Heading"},{type:"badge",label:"Badge"},{type:"card",label:"Card"}]}],Tg=["rest","odata","graphql","static","query","entity"],Eg=["hidden","readonly","editable"],Ig=[{value:"form",label:"Form"},{value:"detail",label:"Detail"},{value:"grid",label:"Grid"},{value:"dashboard",label:"Dashboard"},{value:"content",label:"Content"},{value:"report",label:"Report"},{value:"print",label:"Print"},{value:"mix",label:"Mix"}],Dg=new Set(["report","print","grid"]),Pg=["pdf","docx","xlsx","csv","html"];let Ag=0;const Ea=t=>`${t}-${Date.now().toString(36)}-${(Ag++).toString(36)}`;function Rg(){return{id:Ea("view"),name:"New View",version:2,columns:12,rows:[],dataSources:[]}}function $g(t){const n={};for(const i of t.dataSources??[]){const a=i.data;n[i.key]=Array.isArray(a)&&a.length>0?a:[{}]}return{get:i=>n[i],getRecord:(i,a=0)=>n[i]?.[a]??{},setField:(i,a,r,o=0)=>{const l=n[i]??(n[i]=[{}]),d=l[o]??(l[o]={});d[a]=r},refresh:()=>{}}}const Mg=s.forwardRef(function(n,i){const a=s.useRef(null);c.useRovingFocus(a,{orientation:"horizontal",wrap:!0,activateOnMove:!0}),fn.injectStyleOnce(Lg,Bg);const{value:r,onChange:o,registry:l=dr,entities:d,dataSourceOptions:u,onSave:m,onExport:h,height:p=560,tutorial:y,className:x,style:b,id:g,"data-testid":v}=n,{t:f}=c.useNiceTranslation(),[C,_]=s.useState(()=>r??Rg()),T=r??C,[S,N]=s.useState(null),[j,w]=s.useState("design"),k=s.useCallback(L=>{o?o(L):_(L)},[o]),I=s.useMemo(()=>T.rows??[],[T.rows]),M=(T.dataSources??[]).map(L=>L.key),z=s.useMemo(()=>l.getActionNames(),[l]),A=s.useCallback(L=>{if(!L)return null;for(const H of I){const D=H.cells.find(ee=>ee.id===L);if(D)return{row:H,cell:D}}return null},[I])(S),E=L=>k({...T,rows:L}),$=(L,H)=>E(I.map(D=>({...D,cells:D.cells.map(ee=>ee.id===L?{...ee,...H}:ee)}))),O=()=>E([...I,{id:Ea("row"),cells:[]}]),V=L=>{const H={id:Ea("cell"),controlType:L,props:{label:L},colSpan:6},D=I.length>0?I.slice():[{id:Ea("row"),cells:[]}];D[D.length-1]={...D[D.length-1],cells:[...D[D.length-1].cells,H]},E(D),N(H.id)},K=L=>{E(I.map(H=>({...H,cells:H.cells.filter(D=>D.id!==L)}))),S===L&&N(null)},te=(L,H)=>{const D=d?.find(ee=>ee.name===L);D&&(k(kl(D,H)),N(null))},B=s.useMemo(()=>(d??[]).map(L=>L.name).filter(L=>!!L),[d]),W=s.useMemo(()=>lr(T),[T]),ne=s.useMemo(()=>$g(T),[T]),ae=s.useMemo(()=>{const L={};for(const H of T.dataSources??[]){const D=H.data;L[H.key]=Array.isArray(D)?D:[]}return L},[T]),Y=T.kind??T.meta?.kind??"form",F=L=>{Il(T,ae,L,{onExport:h})},J=e.jsxs("div",{className:"nice-view-editor__toolbar",children:[e.jsx("input",{className:"nice-view-editor__name",value:T.name,onChange:L=>k({...T,name:L.target.value}),placeholder:f("viewEditor.name","View name"),"aria-label":f("viewEditor.name","View name")}),e.jsx("select",{className:"nice-view-editor__kind",value:Y,onChange:L=>k({...T,kind:L.target.value}),"aria-label":f("viewEditor.kindAria","View kind"),children:Ig.map(L=>e.jsx("option",{value:L.value,children:f("viewEditor.kind."+L.value,L.label)},L.value))}),d&&d.length>0&&e.jsxs("select",{className:"nice-view-editor__from-entity",value:"",onChange:L=>{const[H,D]=L.target.value.split("::");H&&te(H,D)},"aria-label":f("viewEditor.fromEntityAria","New view from entity"),children:[e.jsx("option",{value:"",children:f("viewEditor.fromEntity","New from entity…")}),d.map(L=>["form","detail","grid"].map(H=>e.jsxs("option",{value:`${L.name}::${H}`,children:[L.name," · ",H]},`${L.name}-${H}`)))]}),Dg.has(Y)&&e.jsxs("select",{className:"nice-view-editor__export",value:"",onChange:L=>{const H=L.target.value;H&&F(H)},"aria-label":f("viewEditor.exportAria","Export view"),children:[e.jsx("option",{value:"",children:f("viewEditor.export","Export…")}),Pg.map(L=>e.jsx("option",{value:L,children:L.toUpperCase()},L))]}),e.jsx("span",{className:"nice-view-editor__spacer"}),e.jsx("div",{className:"nice-view-editor__modes",ref:a,role:"tablist",children:["design","preview","source"].map(L=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===L,className:"nice-view-editor__mode"+(j===L?" nice-view-editor__mode--active":""),onClick:()=>w(L),children:f("viewEditor.mode."+L,L[0].toUpperCase()+L.slice(1))},L))}),e.jsxs("span",{className:"nice-view-editor__status"+(W.length?" nice-view-editor__status--err":""),title:W.join(`
1288
1288
  `),children:[e.jsx(c.NiceIcon,{name:W.length===0?"check":"warning",size:14})," ",W.length===0?f("viewEditor.valid","Valid"):W.length]}),m&&e.jsx("button",{type:"button",className:"nice-view-editor__save",onClick:()=>m(T),disabled:W.length>0,children:f("viewEditor.save","Save")}),e.jsx(c.NiceTutorialButton,{steps:c.resolveTutorial(y,Cg)})]}),re=e.jsxs("div",{className:"nice-view-editor__palette",children:[Sg.map(L=>e.jsxs("div",{className:"nice-view-editor__pal-group",children:[e.jsx("div",{className:"nice-view-editor__pal-cat",children:f("viewEditor.cat."+L.category,L.category)}),L.items.map(H=>{const D=f("viewEditor.pal."+H.type,H.label);return e.jsx("button",{type:"button",className:"nice-view-editor__pal-item",onClick:()=>V(H.type),title:`${f("viewEditor.add","Add")} ${D}`,children:D},H.type)})]},L.category)),e.jsxs("button",{type:"button",className:"nice-view-editor__add-row",onClick:O,children:["+ ",f("viewEditor.addRow","Add row")]})]}),se=e.jsxs("div",{className:"nice-view-editor__canvas",children:[I.length===0&&e.jsx("div",{className:"nice-view-editor__canvas-empty",children:f("viewEditor.canvasEmpty","Add a row, then drop controls from the palette — or start “New from entity”.")}),I.map(L=>e.jsxs("div",{className:"nice-view-editor__row",style:{gridTemplateColumns:`repeat(${T.columns??12}, 1fr)`},children:[L.cells.map(H=>e.jsxs("button",{type:"button",className:"nice-view-editor__cell"+(H.id===S?" nice-view-editor__cell--sel":""),style:{gridColumn:`span ${H.colSpan??6}`},onClick:()=>N(H.id),onKeyDown:D=>{D.key==="Delete"&&(D.preventDefault(),K(H.id))},children:[e.jsx("span",{className:"nice-view-editor__cell-type",children:H.controlType}),H.bindings?.value?.field&&e.jsxs("span",{className:"nice-view-editor__cell-field",children:[e.jsx(c.NiceIcon,{name:"link",size:12})," ",H.bindings.value.field]}),e.jsx("span",{className:"nice-view-editor__cell-x",role:"button",tabIndex:-1,"aria-label":f("viewEditor.removeCell","Remove cell"),onClick:D=>{D.stopPropagation(),K(H.id)},onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),D.stopPropagation(),K(H.id))},children:e.jsx(c.NiceIcon,{name:"close",size:14})})]},H.id)),L.cells.length===0&&e.jsx("span",{className:"nice-view-editor__row-empty",children:f("viewEditor.emptyRow","empty row")})]},L.id))]}),G=A?e.jsx(Og,{cell:A.cell,dsKeys:M,handlerNames:z,onPatch:L=>$(A.cell.id,L)}):e.jsx(zg,{dataSources:T.dataSources??[],onChange:L=>k({...T,dataSources:L}),queryOptions:u,entityNames:B}),ge="nice-view-editor"+(x?` ${x}`:""),Ce=j==="design",he=j==="source"?e.jsx("pre",{className:"nice-view-editor__source",children:jl(T)}):j==="preview"?e.jsx("div",{className:"nice-view-editor__preview",children:e.jsx(El,{view:T,registry:l,dataStore:ne})}):se;return e.jsx(xt.NiceAppShell,{ref:i,id:g,className:ge,style:{height:p,...b},"data-testid":v,flush:!0,toolbar:J,sidebar:Ce?re:void 0,rightSidebar:Ce?e.jsx("div",{className:"nice-view-editor__props",children:G}):void 0,children:he})});function Og({cell:t,dsKeys:n,handlerNames:i,onPatch:a}){const{t:r}=c.useNiceTranslation(),o=t.bindings?.value,l=p=>{const y={source:"",field:"",...o,...p};a({bindings:{...t.bindings,value:y}})},d=t.events??[],u=p=>a({events:p}),m=t.permissions??[],h=p=>a({permissions:p});return e.jsxs("div",{className:"nice-view-editor__panel",children:[e.jsxs("div",{className:"nice-view-editor__panel-title",children:[r("viewEditor.control","Control")," · ",t.controlType]}),e.jsx("label",{className:"nice-view-editor__lbl",children:r("viewEditor.cp.label","Label")}),e.jsx("input",{className:"nice-view-editor__in",value:t.props.label??"",onChange:p=>a({props:{...t.props,label:p.target.value}})}),e.jsx("label",{className:"nice-view-editor__lbl",children:r("viewEditor.cp.colSpan","Column span")}),e.jsx("input",{className:"nice-view-editor__in",type:"number",min:1,max:12,value:t.colSpan??6,onChange:p=>a({colSpan:Number(p.target.value)||6})}),e.jsx("div",{className:"nice-view-editor__panel-sub",children:r("viewEditor.cp.binding","Binding")}),e.jsx("label",{className:"nice-view-editor__lbl",children:r("viewEditor.cp.dataSource","Data source")}),e.jsxs("select",{className:"nice-view-editor__in",value:o?.source??"",onChange:p=>l({source:p.target.value}),children:[e.jsx("option",{value:"",children:r("viewEditor.cp.none","— none —")}),n.map(p=>e.jsx("option",{value:p,children:p},p))]}),e.jsx("label",{className:"nice-view-editor__lbl",children:r("viewEditor.cp.field","Field")}),e.jsx("input",{className:"nice-view-editor__in",value:o?.field??"",onChange:p=>l({field:p.target.value}),placeholder:r("viewEditor.cp.fieldPath","field path")}),e.jsxs("label",{className:"nice-view-editor__chk",children:[e.jsx("input",{type:"checkbox",checked:!!o?.twoWay,onChange:p=>l({twoWay:p.target.checked})}),r("viewEditor.cp.twoWay","Two-way")]}),e.jsx("div",{className:"nice-view-editor__panel-sub",children:r("viewEditor.cp.permissions","Permissions")}),m.map((p,y)=>e.jsxs("div",{className:"nice-view-editor__perm",children:[e.jsx("input",{className:"nice-view-editor__in",value:p.role,placeholder:r("viewEditor.cp.role","role"),onChange:x=>h(m.map((b,g)=>g===y?{...b,role:x.target.value}:b))}),e.jsx("select",{className:"nice-view-editor__in",value:p.access,onChange:x=>h(m.map((b,g)=>g===y?{...b,access:x.target.value}:b)),children:Eg.map(x=>e.jsx("option",{value:x,children:x},x))}),e.jsx("button",{type:"button",onClick:()=>h(m.filter((x,b)=>b!==y)),"aria-label":r("viewEditor.remove","Remove"),children:e.jsx(c.NiceIcon,{name:"close",size:14})})]},y)),e.jsxs("button",{type:"button",className:"nice-view-editor__mini-add",onClick:()=>h([...m,{role:"*",access:"editable"}]),children:["+ ",r("viewEditor.cp.addPermission","Permission")]}),e.jsx("div",{className:"nice-view-editor__panel-sub",children:r("viewEditor.cp.events","Events")}),d.map((p,y)=>e.jsxs("div",{className:"nice-view-editor__event",children:[e.jsx("input",{className:"nice-view-editor__in",value:p.event,placeholder:r("viewEditor.cp.eventPlaceholder","event (onClick / onValueChange…)"),onChange:x=>u(d.map((b,g)=>g===y?{...b,event:x.target.value}:b))}),e.jsx(Cl,{value:p.actions,handlers:i,dataSources:n,onChange:x=>u(d.map((b,g)=>g===y?{...b,actions:x}:b))}),e.jsx("button",{type:"button",className:"nice-view-editor__mini-remove",onClick:()=>u(d.filter((x,b)=>b!==y)),children:r("viewEditor.cp.removeEvent","Remove event")})]},y)),e.jsxs("button",{type:"button",className:"nice-view-editor__mini-add",onClick:()=>u([...d,{event:"onClick",actions:[]}]),children:["+ ",r("viewEditor.cp.addEvent","Event")]})]})}function zg({dataSources:t,onChange:n,queryOptions:i,entityNames:a}){const{t:r}=c.useNiceTranslation(),o=(d,u)=>n(t.map((m,h)=>h===d?{...m,...u}:m)),l=(d,u)=>d.type==="query"&&i&&i.length>0?e.jsxs("select",{className:"nice-view-editor__in",value:d.ref??"","aria-label":r("viewEditor.ds.ref","Module data source"),onChange:m=>o(u,{ref:m.target.value||void 0}),children:[e.jsx("option",{value:"",children:r("viewEditor.ds.refPick","Pick a data source…")}),i.map(m=>e.jsx("option",{value:m.key,children:m.label??m.key},m.key))]}):d.type==="query"?e.jsx("input",{className:"nice-view-editor__in",value:d.ref??"",placeholder:r("viewEditor.ds.ref","Module data source"),onChange:m=>o(u,{ref:m.target.value||void 0})}):d.type==="entity"&&a.length>0?e.jsxs("select",{className:"nice-view-editor__in",value:d.entity??"","aria-label":r("viewEditor.ds.entity","Entity"),onChange:m=>o(u,{entity:m.target.value||void 0}),children:[e.jsx("option",{value:"",children:r("viewEditor.ds.entityPick","Pick an entity…")}),a.map(m=>e.jsx("option",{value:m,children:m},m))]}):d.type==="entity"?e.jsx("input",{className:"nice-view-editor__in",value:d.entity??"",placeholder:r("viewEditor.ds.entity","Entity"),onChange:m=>o(u,{entity:m.target.value||void 0})}):e.jsx("input",{className:"nice-view-editor__in",value:d.endpoint??"",placeholder:r("viewEditor.ds.endpoint","endpoint"),onChange:m=>o(u,{endpoint:m.target.value})});return e.jsxs("div",{className:"nice-view-editor__panel",children:[e.jsx("div",{className:"nice-view-editor__panel-title",children:r("viewEditor.ds.title","Data sources")}),e.jsx("div",{className:"nice-view-editor__hint",children:r("viewEditor.ds.hint","Select a control to edit its props, binding & events.")}),t.map((d,u)=>e.jsxs("div",{className:"nice-view-editor__ds",children:[e.jsx("input",{className:"nice-view-editor__in",value:d.key,placeholder:r("viewEditor.ds.key","key"),onChange:m=>o(u,{key:m.target.value})}),e.jsx("select",{className:"nice-view-editor__in",value:d.type,onChange:m=>o(u,{type:m.target.value}),children:Tg.map(m=>e.jsx("option",{value:m,children:m},m))}),l(d,u),e.jsxs("label",{className:"nice-view-editor__chk",children:[e.jsx("input",{type:"checkbox",checked:!!d.autoLoad,onChange:m=>o(u,{autoLoad:m.target.checked})}),r("viewEditor.ds.autoLoad","auto-load")]}),e.jsx("button",{type:"button",onClick:()=>n(t.filter((m,h)=>h!==u)),"aria-label":r("viewEditor.remove","Remove"),children:e.jsx(c.NiceIcon,{name:"close",size:14})})]},u)),e.jsxs("button",{type:"button",className:"nice-view-editor__mini-add",onClick:()=>n([...t,{key:`ds${t.length+1}`,type:"rest",autoLoad:!0}]),children:["+ ",r("viewEditor.ds.add","Data source")]})]})}const Lg="nice-view-editor-styles",Bg=`
1289
1289
  .nice-view-editor { display: flex; flex-direction: column; border: 1px solid var(--nice-border-color, #e5e7eb); border-radius: 8px; overflow: hidden; background: var(--nice-bg-primary, #fff); color: var(--nice-text-primary, #111827); }
1290
1290
  .nice-view-editor__toolbar { display: flex; align-items: center; gap: 8px; padding: 8px; border-bottom: 1px solid var(--nice-border-color, #e5e7eb); flex-wrap: wrap; }