@nice2dev/ui 1.4.22 → 1.4.23

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,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@nice2dev/ui-core"),Ft=require("./core-lBFqvT0V.cjs"),r=require("react"),Oe=require("./no-code-DPc82kyy.cjs"),dt=require("./NiceForm-DM2tARZT.cjs"),Vt=require("./pickerCommons-CQnae2FM.cjs"),bn=require("./NiceColorPicker-79rkvaSk.cjs"),it=require("./NiceMention-D330ovOt.cjs"),Zl=require("./NiceHtmlEditor-BEWNA_UI.cjs"),pi=require("./NiceCodeEditor-CBgbzwjx.cjs"),Be=require("./NiceModuleLifecyclePanel-jckyVqqt.cjs"),Fe=require("./NiceButton-DzCqkG5a.cjs"),At=require("./NiceScheduler-Dff8fuq_.cjs"),Wn=require("./NicePivotGrid-BshofJh1.cjs"),e=require("react/jsx-runtime"),Fr=require("react-dom"),ft=require("./NiceSavedQueryPanel-DJKEOqy5.cjs"),_t=require("./devops-o6Zm0VKB.cjs"),hn=require("./NiceAlert-RVTgQxCE.cjs"),Fi=require("./NiceModal-BRVzjuUN.cjs"),qt=require("./NiceLoginForm-Bkm5j80r.cjs"),qr=require("./NicePagination-CnKYyKI5.cjs"),fn=require("./NiceDataGrid-Cszjz8NV.cjs"),Qe=require("./charts-C3Q3r8Yz.cjs"),kt=require("./NiceWindow-DQyf5wat.cjs"),ed=require("./NiceGantt-Drl4gvw9.cjs"),En=require("./injectStyleOnce-DeWaxcdf.cjs"),Vr=require("@nice2dev/i18n"),kh=require("./NiceDocumentViewer-CDXAmPp7.cjs"),In=require("./core-lazy-CUnBYI-T.cjs"),qi=require("./data-branching-7rpktFJ-.cjs");function td({className:t="",size:n="md",showTooltip:i=!0,showLabel:a=!0,onClick:s,label:o,tooltipPosition:c="bottom"}){const{t:d}=l.useNiceTranslation(),{badgeInfo:p,isLoading:m}=Ft.useTracelessPolicySafe(),[h,u]=r.useState(!1),x={sm:"nice-traceless-badge--sm",md:"nice-traceless-badge--md",lg:"nice-traceless-badge--lg"},f=o||p.label;return r.createElement("div",{className:`nice-traceless-badge ${p.cssClass} ${x[n]} ${t}`.trim(),onClick:s,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),role:s?"button":"status",tabIndex:s?0:void 0,onKeyDown:s?b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),s())}:void 0,"aria-label":d("traceless.badgeAria","Privacy mode: {mode}").replace("{mode}",f),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:`${p.color}20`,color:p.color,border:`1px solid ${p.color}40`,cursor:s?"pointer":"default",transition:"all 0.2s ease",position:"relative",userSelect:"none"}},r.createElement("span",{"aria-hidden":!0},r.createElement(l.NiceIcon,{name:m?"clock":p.icon,size:14})),a&&r.createElement("span",null,f),i&&h&&r.createElement("div",{role:"tooltip",style:{position:"absolute",[c==="top"?"bottom":c==="bottom"?"top":c==="left"?"right":"left"]:"100%",[c==="top"||c==="bottom"?"left":"top"]:"50%",transform:c==="top"||c==="bottom"?"translateX(-50%)":"translateY(-50%)",marginTop:c==="bottom"?"0.5rem":void 0,marginBottom:c==="top"?"0.5rem":void 0,marginLeft:c==="right"?"0.5rem":void 0,marginRight:c==="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"}},p.tooltip))}function Ch({className:t="",showReport:n=!0,showAudit:i=!0,showModeSelector:a=!0,availableModes:s=["traceless","ephemeral","private"],onModeChange:o}){const{t:c}=l.useNiceTranslation(),{policy:d,badgeInfo:p,setUserPreference:m,generateReport:h}=Ft.useTracelessPolicySafe(),{result:u,run:x}=Ft.useStorageAudit(),[f,b]=r.useState(null),g=r.useCallback(w=>{m({preferredMode:w}),o?.(w)},[m,o]),v=r.useCallback(()=>{b(h())},[h]),y={traceless:c("traceless.mode.traceless","Traceless"),ephemeral:c("traceless.mode.ephemeral","Ephemeral"),private:c("traceless.mode.private","Private"),balanced:c("traceless.mode.balanced","Balanced"),full:c("traceless.mode.full","Full"),custom:c("traceless.mode.custom","Custom")},C={traceless:c("traceless.modeDesc.traceless","Zero storage. Maximum privacy. Data resets on every page load."),ephemeral:c("traceless.modeDesc.ephemeral","Session-only. Data clears when you close the tab."),private:c("traceless.modeDesc.private","Minimal storage with secure authentication."),balanced:c("traceless.modeDesc.balanced","Local preferences saved. No tracking cookies."),full:c("traceless.modeDesc.full","All storage enabled with consent controls."),custom:c("traceless.modeDesc.custom","Custom configuration.")};return r.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)"}},r.createElement("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"1.5rem"}},r.createElement(td,{size:"lg",showTooltip:!1}),r.createElement("div",null,r.createElement("h3",{style:{margin:0,fontSize:"1.125rem",fontWeight:600}},c("traceless.title","Privacy Settings")),r.createElement("p",{style:{margin:0,fontSize:"0.875rem",color:"var(--nice-text-muted, #6b7280)"}},C[d.effectiveMode]))),a&&r.createElement("div",{style:{marginBottom:"1.5rem"}},r.createElement("label",{style:{display:"block",marginBottom:"0.5rem",fontWeight:500}},c("traceless.level","Privacy Level")),r.createElement("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"}},s.map(w=>r.createElement("button",{key:w,onClick:()=>g(w),style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:d.effectiveMode===w?"2px solid var(--nice-primary, #3b82f6)":"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:d.effectiveMode===w?"var(--nice-info-bg, #eff6ff)":"var(--nice-bg-primary, #fff)",cursor:"pointer",fontWeight:d.effectiveMode===w?600:400}},y[w])))),r.createElement("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"1rem",marginBottom:"1.5rem"}},r.createElement(Ms,{title:c("traceless.cookies","Cookies"),allowed:d.cookiesAllowed,icon:r.createElement(l.NiceIcon,{name:"file",size:24})}),r.createElement(Ms,{title:"localStorage",allowed:d.localStorageAllowed,icon:r.createElement(l.NiceIcon,{name:"save",size:24})}),r.createElement(Ms,{title:"sessionStorage",allowed:d.sessionStorageAllowed,icon:r.createElement(l.NiceIcon,{name:"clipboard",size:24})})),r.createElement("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap"}},i&&r.createElement("button",{onClick:x,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"}},r.createElement(l.NiceIcon,{name:"search",size:16}),c("traceless.runAudit","Run Audit")),n&&r.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"}},r.createElement(l.NiceIcon,{name:"file",size:16}),c("traceless.generateReport","Generate Report"))),u&&r.createElement("div",{style:{marginTop:"1rem",padding:"1rem",backgroundColor:u.compliant?"var(--nice-success-bg, #ecfdf5)":"var(--nice-danger-bg, #fef2f2)",borderRadius:"0.5rem",border:`1px solid ${u.compliant?"var(--nice-color-success, #10b981)":"var(--nice-color-error, #ef4444)"}`}},r.createElement("p",{style:{margin:0,fontWeight:500,color:u.compliant?"var(--nice-success, #059669)":"var(--nice-color-error, #dc2626)",display:"inline-flex",alignItems:"center",gap:"0.375rem"}},r.createElement(l.NiceIcon,{name:u.compliant?"check":"close",size:16}),u.compliant?c("traceless.compliant","Compliant"):c("traceless.violations","Violations Found")),!u.compliant&&u.violations.map((w,E)=>r.createElement("p",{key:E,style:{margin:"0.5rem 0 0",fontSize:"0.875rem"}},`• ${w.message}`))),f&&r.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)"}},r.createElement("h4",{style:{margin:"0 0 0.5rem",fontSize:"0.875rem",fontWeight:600}},c("traceless.statement","Compliance Statement")),r.createElement("p",{style:{margin:0,fontSize:"0.875rem",color:"var(--nice-text-secondary, #4b5563)"}},f.statement)))}function Ms({title:t,allowed:n,icon:i}){const{t:a}=l.useNiceTranslation();return r.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"}},r.createElement("div",{style:{fontSize:"1.5rem",marginBottom:"0.25rem"}},i),r.createElement("div",{style:{fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem"}},t),r.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"}},r.createElement(l.NiceIcon,{name:n?"check":"close",size:12}),n?a("enabled","Enabled"):a("disabled","Disabled")))}function Sh({className:t="",position:n="bottom",onAccept:i,onDecline:a,onCustomize:s,privacyPolicyUrl:o,acceptText:c,declineText:d}){const{t:p}=l.useNiceTranslation(),{shouldShow:m,mode:h,dismiss:u}=Ft.useCookieBannerVisibility(),x=r.useCallback(()=>{i?.(),u()},[i,u]),f=r.useCallback(()=>{a?.(),u()},[a,u]);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 r.createElement("div",{className:`nice-consent-banner ${t}`.trim(),role:"dialog","aria-label":p("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}},r.createElement("div",{style:{flex:1,minWidth:"200px"}},r.createElement("p",{style:{margin:0,fontSize:"0.875rem"}},`${p("cookie.message","This site uses cookies to improve your experience.")} `,o&&r.createElement("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--nice-color-primary, #3b82f6)"}},p("cookie.learnMore","Learn more")))),r.createElement("div",{style:{display:"flex",gap:"0.5rem",flexShrink:0}},s&&r.createElement("button",{onClick:s,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"}},p("cookie.customize","Customize")),r.createElement("button",{onClick:f,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??p("cookie.reject","Reject all")),r.createElement("button",{onClick:x,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}},c??p("cookie.accept","Accept all"))))}function Th({useCase:t,className:n="",message:i,variant:a="inline",dismissible:s=!1,onDismiss:o}){const{t:c}=l.useNiceTranslation(),{warningMessage:d}=Ft.useTracelessPolicySafe().policy.effectiveMode==="traceless"?{warningMessage:i||c("traceless.limitedFeature","This feature has limited functionality in Traceless mode.")}:{warningMessage:void 0},[p,m]=r.useState(!1),h=r.useCallback(()=>{m(!0),o?.()},[o]);if(!d||p)return null;const u={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 r.createElement("div",{className:`nice-traceless-warning nice-traceless-warning--${a} ${n}`.trim(),role:"alert",style:{display:"flex",alignItems:"center",gap:"0.5rem",...u[a]}},r.createElement("span",{"aria-hidden":!0},r.createElement(l.NiceIcon,{name:"warning",size:16})),r.createElement("span",{style:{flex:1}},d),s&&r.createElement("button",{onClick:h,"aria-label":c("traceless.dismissWarning","Dismiss warning"),style:{background:"none",border:"none",cursor:"pointer",padding:"0.25rem",opacity:.7}},r.createElement(l.NiceIcon,{name:"close",size:14})))}const nd=r.createContext(null);function Eh(){const t=r.useContext(nd);return t||{isActive:!1,trackEvent:()=>{},trackPageView:()=>{},setUserProperties:()=>{},mode:"traceless",provider:"custom"}}function Ih({children:t,provider:n,trackingId:i,endpoint:a,customHandler:s,cookies:o=!0,localStorage:c=!1,minMode:d="balanced",autoTrackPageViews:p=!0,respectDoNotTrack:m=!0,debug:h=!1,domain:u,scriptUrl:x,anonymizeIp:f=!0,cookieless:b=!1}){const{policy:g,mode:v}=Ft.useTracelessPolicySafe(),y=r.useMemo(()=>{if(m&&typeof navigator<"u"){const j=navigator.doNotTrack||window.doNotTrack;if(j==="1"||j==="yes")return h&&Rn("Disabled: Do Not Track is set"),!1}const N=["traceless","ephemeral","private","balanced","full"],_=N.indexOf(v),k=N.indexOf(d);return _<k?(h&&Rn(`Disabled: mode ${v} < minMode ${d}`),!1):o&&!g.cookiesAllowed&&!b?(h&&Rn("Disabled: cookies required but not allowed"),!1):c&&!g.localStorageAllowed?(h&&Rn("Disabled: localStorage required but not allowed"),!1):!0},[v,d,g,o,c,b,m,h]);r.useEffect(()=>{if(y){if(n==="custom"&&s){s.init();return}switch(n){case"plausible":ea(x||"https://plausible.io/js/script.js",{"data-domain":i||u});break;case"simple-analytics":ea(x||"https://scripts.simpleanalyticscdn.com/latest.js");break;case"umami":ea(x||a||"",{"data-website-id":i});break;case"fathom":ea(x||"https://cdn.usefathom.com/script.js",{"data-site":i});break;case"matomo":Ah(a||"",i||"",f);break;case"google-analytics":b||(ea(`https://www.googletagmanager.com/gtag/js?id=${i}`),Dh(i||"",f));break;case"google-tag-manager":b||Ph(i||"");break;default:h&&console.warn(`[NiceAnalyticsTracker] Unknown provider: ${n}`)}h&&Rn(`Initialized: ${n}`)}},[y,n,i,a,x,u,f,b,s,h]);const C=r.useCallback(N=>{if(y){if(h&&Rn("trackPageView:",N),n==="custom"&&s){s.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}}},[y,n,s,h]);r.useEffect(()=>{if(!y||!p)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)},[y,p,C]);const w=r.useCallback(N=>{if(y){if(h&&Rn("trackEvent:",N),n==="custom"&&s){s.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}}},[y,n,s,h]),E=r.useCallback(N=>{if(y){if(h&&Rn("setUserProperties:",N),n==="custom"&&s?.setUserProperties){s.setUserProperties(N);return}switch(n){case"google-analytics":window.gtag?.("set","user_properties",N);break;case"matomo":Object.entries(N).forEach(([_,k])=>{window._paq?.push(["setCustomVariable",_,String(k)])});break}}},[y,n,s,h]),S=r.useMemo(()=>({isActive:y,trackEvent:w,trackPageView:C,setUserProperties:E,mode:v,provider:n}),[y,w,C,E,v,n]);return r.createElement(nd.Provider,{value:S},t)}function Rn(...t){console.log("[NiceAnalyticsTracker]",...t)}function ea(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(([s,o])=>{o!==void 0&&a.setAttribute(s,o)}),document.head.appendChild(a)}function Dh(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 Ph(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 Ah(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 s=document.createElement("script");s.async=!0,s.src=`${t}/matomo.js`,document.head.appendChild(s)}function kn(t,n=2){return String(t).padStart(n,"0")}function Os(t){return kn(t.getUTCFullYear(),4)+kn(t.getUTCMonth()+1)+kn(t.getUTCDate())+"T"+kn(t.getUTCHours())+kn(t.getUTCMinutes())+kn(t.getUTCSeconds())+"Z"}function sc(t){return kn(t.getFullYear(),4)+kn(t.getMonth()+1)+kn(t.getDate())}function ta(t){return t.replace(/\\/g,"\\\\").replace(/;/g,"\\;").replace(/,/g,"\\,").replace(/\r?\n/g,"\\n")}function Rh(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 l=require("@nice2dev/ui-core"),Ft=require("./core-lBFqvT0V.cjs"),r=require("react"),Oe=require("./no-code-DPc82kyy.cjs"),dt=require("./NiceForm-DM2tARZT.cjs"),Vt=require("./pickerCommons-CQnae2FM.cjs"),bn=require("./NiceColorPicker-79rkvaSk.cjs"),it=require("./NiceMention-D330ovOt.cjs"),Zl=require("./NiceHtmlEditor-BEWNA_UI.cjs"),pi=require("./NiceCodeEditor-CBgbzwjx.cjs"),Be=require("./NiceModuleLifecyclePanel-jckyVqqt.cjs"),Fe=require("./NiceButton-DzCqkG5a.cjs"),At=require("./NiceScheduler-Dff8fuq_.cjs"),Wn=require("./NicePivotGrid-B5Fgi5E_.cjs"),e=require("react/jsx-runtime"),Fr=require("react-dom"),ft=require("./NiceSavedQueryPanel-DJKEOqy5.cjs"),_t=require("./devops-o6Zm0VKB.cjs"),hn=require("./NiceAlert-RVTgQxCE.cjs"),Fi=require("./NiceModal-BRVzjuUN.cjs"),qt=require("./NiceLoginForm-Bkm5j80r.cjs"),qr=require("./NicePagination-CnKYyKI5.cjs"),fn=require("./NiceDataGrid-Cszjz8NV.cjs"),Qe=require("./charts-C9B548D2.cjs"),kt=require("./NiceWindow-DQyf5wat.cjs"),ed=require("./NiceGantt-Drl4gvw9.cjs"),En=require("./injectStyleOnce-DeWaxcdf.cjs"),Vr=require("@nice2dev/i18n"),kh=require("./NiceDocumentViewer-CDXAmPp7.cjs"),In=require("./core-lazy-B54FdghB.cjs"),qi=require("./data-branching-7rpktFJ-.cjs");function td({className:t="",size:n="md",showTooltip:i=!0,showLabel:a=!0,onClick:s,label:o,tooltipPosition:c="bottom"}){const{t:d}=l.useNiceTranslation(),{badgeInfo:p,isLoading:m}=Ft.useTracelessPolicySafe(),[h,u]=r.useState(!1),x={sm:"nice-traceless-badge--sm",md:"nice-traceless-badge--md",lg:"nice-traceless-badge--lg"},f=o||p.label;return r.createElement("div",{className:`nice-traceless-badge ${p.cssClass} ${x[n]} ${t}`.trim(),onClick:s,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),role:s?"button":"status",tabIndex:s?0:void 0,onKeyDown:s?b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),s())}:void 0,"aria-label":d("traceless.badgeAria","Privacy mode: {mode}").replace("{mode}",f),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:`${p.color}20`,color:p.color,border:`1px solid ${p.color}40`,cursor:s?"pointer":"default",transition:"all 0.2s ease",position:"relative",userSelect:"none"}},r.createElement("span",{"aria-hidden":!0},r.createElement(l.NiceIcon,{name:m?"clock":p.icon,size:14})),a&&r.createElement("span",null,f),i&&h&&r.createElement("div",{role:"tooltip",style:{position:"absolute",[c==="top"?"bottom":c==="bottom"?"top":c==="left"?"right":"left"]:"100%",[c==="top"||c==="bottom"?"left":"top"]:"50%",transform:c==="top"||c==="bottom"?"translateX(-50%)":"translateY(-50%)",marginTop:c==="bottom"?"0.5rem":void 0,marginBottom:c==="top"?"0.5rem":void 0,marginLeft:c==="right"?"0.5rem":void 0,marginRight:c==="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"}},p.tooltip))}function Ch({className:t="",showReport:n=!0,showAudit:i=!0,showModeSelector:a=!0,availableModes:s=["traceless","ephemeral","private"],onModeChange:o}){const{t:c}=l.useNiceTranslation(),{policy:d,badgeInfo:p,setUserPreference:m,generateReport:h}=Ft.useTracelessPolicySafe(),{result:u,run:x}=Ft.useStorageAudit(),[f,b]=r.useState(null),g=r.useCallback(w=>{m({preferredMode:w}),o?.(w)},[m,o]),v=r.useCallback(()=>{b(h())},[h]),y={traceless:c("traceless.mode.traceless","Traceless"),ephemeral:c("traceless.mode.ephemeral","Ephemeral"),private:c("traceless.mode.private","Private"),balanced:c("traceless.mode.balanced","Balanced"),full:c("traceless.mode.full","Full"),custom:c("traceless.mode.custom","Custom")},C={traceless:c("traceless.modeDesc.traceless","Zero storage. Maximum privacy. Data resets on every page load."),ephemeral:c("traceless.modeDesc.ephemeral","Session-only. Data clears when you close the tab."),private:c("traceless.modeDesc.private","Minimal storage with secure authentication."),balanced:c("traceless.modeDesc.balanced","Local preferences saved. No tracking cookies."),full:c("traceless.modeDesc.full","All storage enabled with consent controls."),custom:c("traceless.modeDesc.custom","Custom configuration.")};return r.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)"}},r.createElement("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"1.5rem"}},r.createElement(td,{size:"lg",showTooltip:!1}),r.createElement("div",null,r.createElement("h3",{style:{margin:0,fontSize:"1.125rem",fontWeight:600}},c("traceless.title","Privacy Settings")),r.createElement("p",{style:{margin:0,fontSize:"0.875rem",color:"var(--nice-text-muted, #6b7280)"}},C[d.effectiveMode]))),a&&r.createElement("div",{style:{marginBottom:"1.5rem"}},r.createElement("label",{style:{display:"block",marginBottom:"0.5rem",fontWeight:500}},c("traceless.level","Privacy Level")),r.createElement("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"}},s.map(w=>r.createElement("button",{key:w,onClick:()=>g(w),style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:d.effectiveMode===w?"2px solid var(--nice-primary, #3b82f6)":"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:d.effectiveMode===w?"var(--nice-info-bg, #eff6ff)":"var(--nice-bg-primary, #fff)",cursor:"pointer",fontWeight:d.effectiveMode===w?600:400}},y[w])))),r.createElement("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"1rem",marginBottom:"1.5rem"}},r.createElement(Ms,{title:c("traceless.cookies","Cookies"),allowed:d.cookiesAllowed,icon:r.createElement(l.NiceIcon,{name:"file",size:24})}),r.createElement(Ms,{title:"localStorage",allowed:d.localStorageAllowed,icon:r.createElement(l.NiceIcon,{name:"save",size:24})}),r.createElement(Ms,{title:"sessionStorage",allowed:d.sessionStorageAllowed,icon:r.createElement(l.NiceIcon,{name:"clipboard",size:24})})),r.createElement("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap"}},i&&r.createElement("button",{onClick:x,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"}},r.createElement(l.NiceIcon,{name:"search",size:16}),c("traceless.runAudit","Run Audit")),n&&r.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"}},r.createElement(l.NiceIcon,{name:"file",size:16}),c("traceless.generateReport","Generate Report"))),u&&r.createElement("div",{style:{marginTop:"1rem",padding:"1rem",backgroundColor:u.compliant?"var(--nice-success-bg, #ecfdf5)":"var(--nice-danger-bg, #fef2f2)",borderRadius:"0.5rem",border:`1px solid ${u.compliant?"var(--nice-color-success, #10b981)":"var(--nice-color-error, #ef4444)"}`}},r.createElement("p",{style:{margin:0,fontWeight:500,color:u.compliant?"var(--nice-success, #059669)":"var(--nice-color-error, #dc2626)",display:"inline-flex",alignItems:"center",gap:"0.375rem"}},r.createElement(l.NiceIcon,{name:u.compliant?"check":"close",size:16}),u.compliant?c("traceless.compliant","Compliant"):c("traceless.violations","Violations Found")),!u.compliant&&u.violations.map((w,E)=>r.createElement("p",{key:E,style:{margin:"0.5rem 0 0",fontSize:"0.875rem"}},`• ${w.message}`))),f&&r.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)"}},r.createElement("h4",{style:{margin:"0 0 0.5rem",fontSize:"0.875rem",fontWeight:600}},c("traceless.statement","Compliance Statement")),r.createElement("p",{style:{margin:0,fontSize:"0.875rem",color:"var(--nice-text-secondary, #4b5563)"}},f.statement)))}function Ms({title:t,allowed:n,icon:i}){const{t:a}=l.useNiceTranslation();return r.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"}},r.createElement("div",{style:{fontSize:"1.5rem",marginBottom:"0.25rem"}},i),r.createElement("div",{style:{fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem"}},t),r.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"}},r.createElement(l.NiceIcon,{name:n?"check":"close",size:12}),n?a("enabled","Enabled"):a("disabled","Disabled")))}function Sh({className:t="",position:n="bottom",onAccept:i,onDecline:a,onCustomize:s,privacyPolicyUrl:o,acceptText:c,declineText:d}){const{t:p}=l.useNiceTranslation(),{shouldShow:m,mode:h,dismiss:u}=Ft.useCookieBannerVisibility(),x=r.useCallback(()=>{i?.(),u()},[i,u]),f=r.useCallback(()=>{a?.(),u()},[a,u]);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 r.createElement("div",{className:`nice-consent-banner ${t}`.trim(),role:"dialog","aria-label":p("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}},r.createElement("div",{style:{flex:1,minWidth:"200px"}},r.createElement("p",{style:{margin:0,fontSize:"0.875rem"}},`${p("cookie.message","This site uses cookies to improve your experience.")} `,o&&r.createElement("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--nice-color-primary, #3b82f6)"}},p("cookie.learnMore","Learn more")))),r.createElement("div",{style:{display:"flex",gap:"0.5rem",flexShrink:0}},s&&r.createElement("button",{onClick:s,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"}},p("cookie.customize","Customize")),r.createElement("button",{onClick:f,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??p("cookie.reject","Reject all")),r.createElement("button",{onClick:x,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}},c??p("cookie.accept","Accept all"))))}function Th({useCase:t,className:n="",message:i,variant:a="inline",dismissible:s=!1,onDismiss:o}){const{t:c}=l.useNiceTranslation(),{warningMessage:d}=Ft.useTracelessPolicySafe().policy.effectiveMode==="traceless"?{warningMessage:i||c("traceless.limitedFeature","This feature has limited functionality in Traceless mode.")}:{warningMessage:void 0},[p,m]=r.useState(!1),h=r.useCallback(()=>{m(!0),o?.()},[o]);if(!d||p)return null;const u={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 r.createElement("div",{className:`nice-traceless-warning nice-traceless-warning--${a} ${n}`.trim(),role:"alert",style:{display:"flex",alignItems:"center",gap:"0.5rem",...u[a]}},r.createElement("span",{"aria-hidden":!0},r.createElement(l.NiceIcon,{name:"warning",size:16})),r.createElement("span",{style:{flex:1}},d),s&&r.createElement("button",{onClick:h,"aria-label":c("traceless.dismissWarning","Dismiss warning"),style:{background:"none",border:"none",cursor:"pointer",padding:"0.25rem",opacity:.7}},r.createElement(l.NiceIcon,{name:"close",size:14})))}const nd=r.createContext(null);function Eh(){const t=r.useContext(nd);return t||{isActive:!1,trackEvent:()=>{},trackPageView:()=>{},setUserProperties:()=>{},mode:"traceless",provider:"custom"}}function Ih({children:t,provider:n,trackingId:i,endpoint:a,customHandler:s,cookies:o=!0,localStorage:c=!1,minMode:d="balanced",autoTrackPageViews:p=!0,respectDoNotTrack:m=!0,debug:h=!1,domain:u,scriptUrl:x,anonymizeIp:f=!0,cookieless:b=!1}){const{policy:g,mode:v}=Ft.useTracelessPolicySafe(),y=r.useMemo(()=>{if(m&&typeof navigator<"u"){const j=navigator.doNotTrack||window.doNotTrack;if(j==="1"||j==="yes")return h&&Rn("Disabled: Do Not Track is set"),!1}const N=["traceless","ephemeral","private","balanced","full"],_=N.indexOf(v),k=N.indexOf(d);return _<k?(h&&Rn(`Disabled: mode ${v} < minMode ${d}`),!1):o&&!g.cookiesAllowed&&!b?(h&&Rn("Disabled: cookies required but not allowed"),!1):c&&!g.localStorageAllowed?(h&&Rn("Disabled: localStorage required but not allowed"),!1):!0},[v,d,g,o,c,b,m,h]);r.useEffect(()=>{if(y){if(n==="custom"&&s){s.init();return}switch(n){case"plausible":ea(x||"https://plausible.io/js/script.js",{"data-domain":i||u});break;case"simple-analytics":ea(x||"https://scripts.simpleanalyticscdn.com/latest.js");break;case"umami":ea(x||a||"",{"data-website-id":i});break;case"fathom":ea(x||"https://cdn.usefathom.com/script.js",{"data-site":i});break;case"matomo":Ah(a||"",i||"",f);break;case"google-analytics":b||(ea(`https://www.googletagmanager.com/gtag/js?id=${i}`),Dh(i||"",f));break;case"google-tag-manager":b||Ph(i||"");break;default:h&&console.warn(`[NiceAnalyticsTracker] Unknown provider: ${n}`)}h&&Rn(`Initialized: ${n}`)}},[y,n,i,a,x,u,f,b,s,h]);const C=r.useCallback(N=>{if(y){if(h&&Rn("trackPageView:",N),n==="custom"&&s){s.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}}},[y,n,s,h]);r.useEffect(()=>{if(!y||!p)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)},[y,p,C]);const w=r.useCallback(N=>{if(y){if(h&&Rn("trackEvent:",N),n==="custom"&&s){s.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}}},[y,n,s,h]),E=r.useCallback(N=>{if(y){if(h&&Rn("setUserProperties:",N),n==="custom"&&s?.setUserProperties){s.setUserProperties(N);return}switch(n){case"google-analytics":window.gtag?.("set","user_properties",N);break;case"matomo":Object.entries(N).forEach(([_,k])=>{window._paq?.push(["setCustomVariable",_,String(k)])});break}}},[y,n,s,h]),S=r.useMemo(()=>({isActive:y,trackEvent:w,trackPageView:C,setUserProperties:E,mode:v,provider:n}),[y,w,C,E,v,n]);return r.createElement(nd.Provider,{value:S},t)}function Rn(...t){console.log("[NiceAnalyticsTracker]",...t)}function ea(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(([s,o])=>{o!==void 0&&a.setAttribute(s,o)}),document.head.appendChild(a)}function Dh(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 Ph(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 Ah(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 s=document.createElement("script");s.async=!0,s.src=`${t}/matomo.js`,document.head.appendChild(s)}function kn(t,n=2){return String(t).padStart(n,"0")}function Os(t){return kn(t.getUTCFullYear(),4)+kn(t.getUTCMonth()+1)+kn(t.getUTCDate())+"T"+kn(t.getUTCHours())+kn(t.getUTCMinutes())+kn(t.getUTCSeconds())+"Z"}function sc(t){return kn(t.getFullYear(),4)+kn(t.getMonth()+1)+kn(t.getDate())}function ta(t){return t.replace(/\\/g,"\\\\").replace(/;/g,"\\;").replace(/,/g,"\\,").replace(/\r?\n/g,"\\n")}function Rh(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 id(t,n={}){const{prodId:i="-//nice2dev//NiceToDev.UI//EN",calendarName:a,method:s}=n,o=["BEGIN:VCALENDAR","VERSION:2.0",`PRODID:${i}`,"CALSCALE:GREGORIAN"];s&&o.push(`METHOD:${s}`),a&&o.push(`X-WR-CALNAME:${ta(a)}`);const c=Os(new Date);for(const d of t)o.push("BEGIN:VEVENT"),o.push(`UID:${d.uid}`),o.push(`DTSTAMP:${c}`),d.allDay?(o.push(`DTSTART;VALUE=DATE:${sc(d.start)}`),d.end&&o.push(`DTEND;VALUE=DATE:${sc(d.end)}`)):(o.push(`DTSTART:${Os(d.start)}`),d.end&&o.push(`DTEND:${Os(d.end)}`)),o.push(`SUMMARY:${ta(d.summary)}`),d.description&&o.push(`DESCRIPTION:${ta(d.description)}`),d.location&&o.push(`LOCATION:${ta(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(ta).join(",")}`),o.push("END:VEVENT");return o.push("END:VCALENDAR"),o.map(Rh).join(`\r
3
3
  `)}function ad(t,n={}){const i=id(t,n);return new Blob([i],{type:"text/calendar;charset=utf-8"})}function $h(t,n="calendar.ics",i={}){if(typeof window>"u"||typeof URL.createObjectURL!="function")return;const a=ad(t,i),s=URL.createObjectURL(a),o=document.createElement("a");o.href=s,o.download=n,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(s)}const Mh=[];function Oh(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 sd=({icon:t,items:n=Mh,direction:i="right",position:a={bottom:24,right:24},disabled:s=!1,className:o,style:c,id:d,"data-testid":p})=>{const[m,h]=r.useState(!1),u=m&&!s,x=r.useRef(null),f=r.useRef(null),[b,g]=r.useState(null),[v,y]=r.useState(""),C=r.useRef(null);l.useMenuButton(f,C,{open:u,onOpenChange:h,orientation:i==="up"||i==="down"?"vertical":"horizontal"}),r.useLayoutEffect(()=>{if(!u||!f.current)return;const E=f.current,S=()=>g(E.getBoundingClientRect());return S(),y(Oh(x.current)),window.addEventListener("scroll",S,!0),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[u]);const w=e.jsx("div",{className:"nice-speed-dial__items",role:"menu",ref:C,children:n.map(E=>e.jsx("button",{type:"button",role:"menuitem",className:"nice-speed-dial__item nice-btn nice-btn--secondary",onClick:()=>{E.onClick?.(),h(!1)},title:E.label,"aria-label":E.label,children:E.icon},E.key))});return e.jsxs("div",{ref:x,id:d,"data-testid":p,className:["nice-speed-dial",`nice-speed-dial--${i}`,u?"nice-speed-dial--open":"",s?"nice-speed-dial--disabled":"",o||""].filter(Boolean).join(" "),style:{...a,...c},children:[e.jsx("button",{ref:f,type:"button",className:"nice-speed-dial__trigger nice-btn nice-btn--primary",onClick:()=>h(E=>!E),"aria-expanded":u,"aria-haspopup":"menu",disabled:s,children:e.jsx("span",{className:"nice-speed-dial__trigger-icon",children:t??e.jsx(l.NiceIcon,{name:"plus",size:24})})}),u&&b&&typeof document<"u"&&Fr.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:w}),document.body)]})},Jt=({children:t,variant:n="primary",size:i="md",dot:a,outline:s,subtle:o,pulse:c,icon:d,removable:p,onRemove:m,className:h,style:u,displayStyle:x,testId:f,"data-testid":b})=>{const{t:g}=l.useNiceTranslation(),v=l.useComponentDisplayStyle("badge",x),y=l.useComponentDisplayClass("badge",x),C={...v};for(const w of["fontSize","padding","paddingLeft","paddingRight","paddingTop","paddingBottom","paddingInline","paddingBlock"])delete C[w];if(n!=="primary"||s||o)for(const w of["background","backgroundColor","color"])delete C[w];if(s||o)for(const w of["border","borderColor","borderWidth","borderStyle","boxShadow"])delete C[w];return e.jsxs("span",{className:`nice-badge nice-badge--${n} nice-badge--${i} nice-badge--ds-${y} ${a?"nice-badge--dot":""} ${s?"nice-badge--outline":""} ${o?"nice-badge--subtle":""} ${c?"nice-badge--pulse":""} ${p?"nice-badge--removable":""} ${h||""}`,style:{...C,...u},"data-testid":b??f,children:[d&&e.jsx("span",{className:"nice-badge__icon",children:d}),t,p&&e.jsx("button",{type:"button",className:"nice-badge__remove",onClick:m,"aria-label":g("badge.remove","Remove"),children:e.jsx(l.NiceIcon,{name:"close",size:14})})]})},Lh=Object.freeze(Object.defineProperty({__proto__:null,NiceBadge:Jt},Symbol.toStringTag,{value:"Module"})),us=({children:t,selected:n,removable:i,onClick:a,onRemove:s,color:o,size:c="md",className:d,style:p,testId:m,"data-testid":h})=>{const{t:u}=l.useNiceTranslation(),x=typeof t=="string"||typeof t=="number"?`${u("tag.remove","Remove")}: ${t}`:u("tag.remove","Remove");return e.jsxs("span",{className:`nice-tag nice-tag--${c} ${a?"nice-tag--clickable":""} ${n?"nice-tag--selected":""} ${d||""}`,style:{...p,...o&&!n?{borderColor:o,color:o}:{}},"data-testid":h??m,...a&&{onClick:a,role:"button",tabIndex:0,"aria-pressed":n,onKeyDown:f=>{f.target===f.currentTarget&&(f.key==="Enter"||f.key===" "?(f.preventDefault(),a()):i&&(f.key==="Delete"||f.key==="Backspace")&&(f.preventDefault(),s?.()))}},children:[t,i&&e.jsx("button",{type:"button",className:"nice-tag__remove",onClick:f=>{f.stopPropagation(),s?.()},"aria-label":x,children:e.jsx(l.NiceIcon,{name:"close",size:14})})]})};function zh(t){return t.split(" ").map(n=>n[0]).filter(Boolean).slice(0,2).join("").toUpperCase()}const Ht=({src:t,alt:n,name:i,size:a="md",square:s,color:o,badge:c,badgePosition:d="bottom-right",className:p,style:m,testId:h,"data-testid":u})=>{const x=e.jsx("div",{className:`nice-avatar nice-avatar--${a} ${s?"nice-avatar--square":""} ${c==null&&p||""}`,style:c==null?{...m,...o?{background:o}:{}}:o?{background:o}:void 0,"aria-label":n||i,"data-testid":c==null?u??h:void 0,children:t?e.jsx("img",{src:t,alt:n||i||""}):i?zh(i):e.jsx(l.NiceIcon,{name:"user",size:"md",className:"nice-avatar__fallback-icon"})});return c==null?x:e.jsxs("span",{className:`nice-avatar-wrap ${p||""}`,style:m,"data-testid":u??h,children:[x,e.jsx("span",{className:`nice-avatar__badge nice-avatar__badge--${d}`,children:c})]})};function Bh(t){return t?t.trim().split(/\s+/).map(n=>n[0]).join("").slice(0,2).toUpperCase():""}const Ur=({children:t,items:n,max:i,size:a="md",className:s,style:o,testId:c,"data-testid":d})=>{const p=`nice-avatar nice-avatar--${a}`;let m,h;if(n&&n.length>0)h=n.length,m=(i?n.slice(0,i):n).map((f,b)=>{const g=f.src?e.jsx("img",{src:f.src,alt:f.name??""}):e.jsx("span",{children:Bh(f.name)});return f.href?e.jsx("a",{className:p,href:f.href,title:f.name,onClick:f.onClick,children:g},b):f.onClick?e.jsx("button",{type:"button",className:p,title:f.name,onClick:f.onClick,children:g},b):e.jsx("span",{className:p,title:f.name,children:g},b)});else{const x=r.Children.toArray(t);h=x.length,m=(i?x.slice(0,i):x).map(b=>r.isValidElement(b)&&b.props.size==null?r.cloneElement(b,{size:a}):b)}const u=i?Math.max(0,h-i):0;return e.jsxs("div",{className:`nice-avatar-group nice-avatar-group--${a} ${s||""}`,style:o,"data-testid":d??c,children:[m,u>0&&e.jsxs("div",{className:p,style:{background:"var(--nice-text-muted)"},children:["+",u]})]})},Fh={xxs:4,xs:6,sm:8,md:12,lg:16,xl:20,xxl:28},rd=Object.assign(r.forwardRef(({children:t,items:n,renderCard:i,searchable:a,searchField:s="text",searchPlaceholder:o,emptyText:c,onCardClick:d,size:p="md",minColumnWidth:m=240,columns:h,gap:u,align:x="stretch",equalHeight:f=!1,value:b,onChange:g,name:v,disabled:y,readOnly:C,loading:w,error:E,errorText:S,className:N,style:_,testId:k,"data-testid":j},T)=>{const{t:P}=l.useNiceTranslation(),[B,R]=r.useState(""),I=h?`repeat(${h}, minmax(0, 1fr))`:`repeat(auto-fill, minmax(${m}px, 1fr))`,D=u??Fh[p]??12,M=typeof E=="string"?E.length>0:!!E,O=typeof E=="string"?E:E?S??"":"",L=n!=null&&i!=null,V=r.useMemo(()=>{if(!L||!B)return n??[];const se=B.toLowerCase();return(n??[]).filter(ce=>String(ce[s]??"").toLowerCase().includes(se))},[L,n,B,s]),ee=g!=null||b!=null,z=r.useMemo(()=>({value:b,onChange:se=>{!y&&!C&&g?.(se)},name:v}),[b,g,v,y,C]),U=f?"stretch":x,re=f?"1fr":void 0,Y=`nice-card-group nice-card-group--${p}${f?" nice-card-group--equal":""}${y?" nice-card-group--disabled":""}${C?" nice-card-group--readonly":""}${w?" nice-card-group--loading":""}${M?" nice-card-group--error":""}${N?` ${N}`:""}`;if(L)return e.jsx(Be.NiceCardGroupSizeContext.Provider,{value:p,children:e.jsxs("div",{ref:T,className:Y,style:{position:"relative",..._},"aria-disabled":y||void 0,"aria-busy":w||void 0,"data-testid":j??k,children:[a&&e.jsx("div",{className:"nice-card-group__search",children:e.jsx("input",{type:"text",value:B,onChange:se=>R(se.target.value),placeholder:o||P("controls.search","Search...")})}),w?e.jsx("div",{className:"nice-card-group__empty",children:e.jsx("span",{className:"nice-spinner nice-spinner--md"})}):V.length===0?e.jsx("div",{className:"nice-card-group__empty",children:c||P("controls.noData","No data available")}):e.jsx("div",{className:"nice-card-group__grid",style:{display:"grid",gridTemplateColumns:I,gridAutoRows:re,gap:D,alignItems:U},children:V.map(se=>e.jsx("div",{className:"nice-card-group__data-card",onClick:d?()=>d(se):void 0,onKeyDown:d?ce=>{ce.target===ce.currentTarget&&(ce.key==="Enter"||ce.key===" ")&&(ce.preventDefault(),d(se))}:void 0,role:d?"button":void 0,tabIndex:d?0:void 0,style:d?{cursor:"pointer"}:void 0,children:i(se)},se.key))}),O&&e.jsx("div",{className:"nice-card-group__error",role:"alert",children:O})]})});const oe=e.jsxs("div",{ref:T,className:Y,style:{display:"grid",gridTemplateColumns:I,gridAutoRows:re,gap:D,alignItems:U,position:w?"relative":void 0,..._},role:ee?"radiogroup":void 0,"aria-label":ee?v:void 0,"aria-disabled":y||void 0,"aria-busy":w||void 0,"data-testid":j??k,children:[t,w&&e.jsx("span",{className:"nice-card-group__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),O&&!f&&e.jsx("div",{className:"nice-card-group__error",role:"alert",style:{gridColumn:"1 / -1"},children:O})]}),q=O&&f&&e.jsx("div",{className:"nice-card-group__error",role:"alert",children:O});return e.jsxs(Be.NiceCardGroupSizeContext.Provider,{value:p,children:[ee?e.jsx(Be.NiceCardRadioContext.Provider,{value:z,children:oe}):oe,q]})}),{displayName:"NiceCardGroup"}),qh={color:!0,description:!0,volume:!0,gain:!0},Hr=r.forwardRef(function(n,i){const{t:a}=l.useNiceTranslation(),{children:s,name:o,description:c,defaultDescription:d,onDescriptionChange:p,labelPlacement:m="bottom",number:h,color:u="transparent",onColorChange:x,volume:f,defaultVolume:b,onVolumeChange:g,gain:v,defaultGain:y,onGainChange:C,contextMenu:w=!0,quickControls:E,onOpenConfig:S,fullConfigLabel:N=a("deviceTile.fullConfiguration","Full configuration"),selected:_,onClick:k,focusId:j,className:T,style:P,title:B,"data-testid":R}=n,I={...qh,...E},D=r.useRef(null),M=J=>{D.current=J,typeof i=="function"?i(J):i&&(i.current=J)},O=D;l.useSpatialFocusable(O,{id:j??"",onActivate:k,disabled:!j});const[L,V]=l.useControllableState({value:c,defaultValue:d,fallbackValue:"",onChange:p,componentName:"NiceDeviceTile"}),[ee,z]=l.useControllableState({value:f,defaultValue:b,fallbackValue:80,onChange:g,componentName:"NiceDeviceTile"}),[U,re]=l.useControllableState({value:v,defaultValue:y,fallbackValue:50,onChange:C,componentName:"NiceDeviceTile"}),Y=l.useSpatialNavOptional(),[oe,q]=r.useState(null),se=r.useRef(null);l.useClickOutside(se,()=>q(null)),r.useEffect(()=>{if(oe)return Y?.pauseNavigation(),()=>{Y?.resumeNavigation()}},[oe,Y]),l.useOverlayFocus(se,{open:oe!=null,modal:!1,onClose:()=>q(null)});const ce=J=>{if(!w)return;J.preventDefault();let{clientX:me,clientY:je}=J;if(me===0&&je===0){const H=J.currentTarget.getBoundingClientRect();me=H.left,je=H.bottom}const ue=Math.min(me,window.innerWidth-256),F=Math.min(je,window.innerHeight-320);q({x:Math.max(8,ue),y:Math.max(8,F)})},le=u!=="transparent"&&u!=="";return e.jsxs("div",{ref:M,className:["nice-device-tile",`nice-device-tile--label-${m}`,_?"nice-device-tile--selected":"",le?"nice-device-tile--colored":"",T??""].filter(Boolean).join(" "),style:{...P,"--device-color":u},title:B,"data-testid":R,onClick:k,onKeyDown:k?J=>{J.target===J.currentTarget&&(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),J.currentTarget.click())}:void 0,onContextMenu:ce,role:k?"button":void 0,tabIndex:j||k?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}),s]}),(o||L)&&e.jsxs("div",{className:"nice-device-tile__caption",children:[o&&e.jsx("span",{className:"nice-device-tile__name",children:o}),L&&e.jsx("span",{className:"nice-device-tile__description",children:L})]}),oe&&e.jsx("div",{ref:se,className:"nice-device-tile__menu",style:{position:"fixed",left:oe.x,top:oe.y},role:"dialog","aria-label":o,children:e.jsxs("div",{style:{display:"contents"},onClick:J=>J.stopPropagation(),onKeyDown:J=>{J.key!=="Escape"&&J.stopPropagation()},children:[o&&e.jsx("div",{className:"nice-device-tile__menu-title",children:o}),I.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(bn.NiceColorPicker,{compact:!0,value:le?u:"#3b82f6",onChange:J=>x?.(J)})]}),I.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(Oe.NiceTextInput,{value:L,onChange:J=>V(J),size:"sm"})]}),I.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(dt.NiceSlider,{value:ee,onChange:J=>z(J),min:0,max:100})]}),I.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(dt.NiceSlider,{value:U,onChange:J=>re(J),min:0,max:100})]}),S&&e.jsx(Fe.NiceButton,{size:"sm",variant:"outline",className:"nice-device-tile__menu-config",onClick:()=>{q(null),S()},children:N})]})})]})}),Vh={xxs:20,xs:24,sm:32,md:40,lg:56,xl:72,xxl:96},Ma=15,wi=18,Oa=6,na=30,od=({level:t=0,size:n="md",muted:i=!1,...a})=>{const{t:s}=l.useNiceTranslation(),c=`nice-mic-clip-${l.useControlId()}`,d=typeof n=="number"?n:Vh[n]??40,p=Math.max(0,Math.min(1,t)),m=Oa+(1-p)*na,h=p*na;return e.jsx(Hr,{...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?s("microphone.microphone","Microphone: {name}").replace("{name}",String(a.name)):s("microphone.microphone2","Microphone"),children:[e.jsx("defs",{children:e.jsx("clipPath",{id:c,children:e.jsx("rect",{x:Ma,y:Oa,width:wi,height:na,rx:wi/2})})}),e.jsxs("g",{clipPath:`url(#${c})`,children:[e.jsx("rect",{x:Ma,y:Oa,width:wi,height:na,className:"nice-microphone__body"}),h>0&&e.jsx("rect",{x:Ma,y:m,width:wi,height:h,className:"nice-microphone__level"})]}),e.jsx("rect",{x:Ma,y:Oa,width:wi,height:na,rx:wi/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"})]})})},Uh={xxs:22,xs:28,sm:36,md:48,lg:64,xl:84,xxl:110},Hh=[{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]}],Gh="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 Wh({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 cd=({view:t="compact",size:n="md",onButtonPress:i,pressedButtons:a,highlightedButtons:s,live:o=!1,gamepadIndex:c=0,buttonLabels:d,actionTree:p,assignments:m,onAssign:h,...u})=>{const{t:x}=l.useNiceTranslation(),f=typeof n=="number"?n:Uh[n]??48,[b,g]=r.useState(()=>new Set),[v,y]=r.useState(null);l.useGamepad({index:c,enabled:o,onButtonDown:P=>{g(B=>{const R=new Set(B);return R.add(P),R}),i?.(P)},onButtonUp:P=>{g(B=>{const R=new Set(B);return R.delete(P),R})}});const C=P=>!!s?.includes(P)||!!a?.includes(P)||b.has(P),w=f*1.5,E=w*(68/100),S=(P,B)=>{P.stopPropagation(),i?.(B),p&&y(R=>R===B?null:B)},N=t==="compact",_=!N&&(!!i||!!p),k=r.useRef(null);l.useRovingFocus(k,{orientation:"grid",itemSelector:".nice-gamepad__btn",enabled:_});const j=e.jsxs("svg",{className:`nice-gamepad nice-gamepad--${t}${_?" nice-gamepad--interactive":""}`,width:w,height:E,viewBox:"0 0 100 68",role:_?"group":"img","aria-label":u.name?x("gamepad.gamepad","Gamepad: {name}").replace("{name}",String(u.name)):x("gamepad.gamepad2","Gamepad"),children:[e.jsx("path",{d:Gh,className:"nice-gamepad__body"}),!N&&Hh.map(({id:P,shape:B,label:R})=>{const I=d?.[P]??m?.[P];return e.jsxs("g",{"data-button":P,"data-pressed":C(P)?"true":void 0,className:`nice-gamepad__btn${v===P?" nice-gamepad__btn--armed":""}`,role:_?"button":void 0,"aria-label":_?I?`${P} ${I}`:P:void 0,"aria-pressed":_&&p?v===P:void 0,onClick:D=>S(D,P),onKeyDown:D=>{_&&(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),S(D,P))},children:[e.jsx(Wh,{shape:B}),I&&e.jsx("text",{x:R[0],y:R[1],className:"nice-gamepad__label",children:I})]},P)})]}),T=_?e.jsx("div",{ref:k,className:"nice-gamepad__pad",children:j}):j;return e.jsx(Hr,{...u,children:p&&!N?e.jsxs("div",{className:"nice-gamepad__assign",children:[T,e.jsxs("div",{className:"nice-gamepad__tree",children:[e.jsx("div",{className:"nice-gamepad__tree-hint",children:v?x("gamepad.assignTo",'Assign to "{armed}"…').replace("{armed}",String(v)):x("gamepad.clickAButtonThenA","Click a button, then a node")}),e.jsx(ft.NiceTreeView,{nodes:p,selectionMode:"single",onNodeClick:P=>{v&&(h?.(v,P),y(null))}})]})]}):T})},Kh=[],Yh=({devices:t,defaultDevices:n,onDevicesChange:i,autoDetect:a=!0,kinds:s=["microphone","gamepad"],slots:o,onAssign:c,onOpenConfig:d,columns:p,minColumnWidth:m=160,className:h,style:u,id:x,"data-testid":f})=>{const{t:b}=l.useNiceTranslation(),[g,v]=l.useControllableState({value:t,defaultValue:n,fallbackValue:Kh,onChange:i,componentName:"NiceDeviceManager"}),y=r.useCallback(N=>{N.length!==0&&v(_=>{const k=new Set(_.map(T=>T.id)),j=N.filter(T=>!k.has(T.id));return j.length?[..._,...j]:_})},[v]);r.useEffect(()=>{if(!a||!s.includes("microphone")||!navigator.mediaDevices?.enumerateDevices)return;let N=!1;const _=()=>{navigator.mediaDevices.enumerateDevices().then(k=>{if(N)return;const j=k.filter(T=>T.kind==="audioinput").map((T,P)=>({id:`mic:${T.deviceId||P}`,kind:"microphone",name:T.label||`Microphone ${P+1}`,deviceId:T.deviceId}));y(j)}).catch(()=>{})};return _(),navigator.mediaDevices.addEventListener?.("devicechange",_),()=>{N=!0,navigator.mediaDevices.removeEventListener?.("devicechange",_)}},[a,s,y]);const C=l.useConnectedGamepads(),w=a&&s.includes("gamepad");r.useEffect(()=>{w&&y(C.map(N=>({id:`pad:${N.index}`,kind:"gamepad",name:N.id.split("(")[0]?.trim()||`Controller ${N.index+1}`,deviceId:String(N.index)})))},[w,C,y]);const E=r.useCallback((N,_)=>{v(k=>k.map(j=>j.id===N?{...j,..._}:j))},[v]),S=r.useCallback((N,_)=>{E(N,{assignedTo:_}),c?.(N,_)},[E,c]);return e.jsx("div",{id:x,"data-testid":f,className:`nice-device-manager ${h??""}`.trim(),style:u,children:g.length===0?e.jsx("p",{className:"nice-device-manager__empty",children:b("deviceManager.noDevicesDetected","No devices detected.")}):e.jsx(rd,{columns:p,minColumnWidth:m,gap:12,children:g.map((N,_)=>{const k={name:N.name,description:N.description,number:N.number??_+1,color:N.color??"transparent",volume:N.volume,gain:N.gain,onColorChange:j=>E(N.id,{color:j}),onDescriptionChange:j=>E(N.id,{description:j}),onVolumeChange:j=>E(N.id,{volume:j}),onGainChange:j=>E(N.id,{gain:j}),onOpenConfig:()=>d?.(N)};return e.jsxs("div",{className:"nice-device-manager__cell",children:[N.kind==="microphone"?e.jsx(od,{...k,level:N.level}):e.jsx(cd,{...k,view:"compact",live:!0}),o&&o.length>0&&e.jsx("div",{className:"nice-device-manager__slots",children:o.map(j=>e.jsx(Fe.NiceButton,{size:"sm",variant:N.assignedTo===j.id?"primary":"ghost",onClick:()=>S(N.id,N.assignedTo===j.id?null:j.id),children:j.label},j.id))})]},N.id)})})})},Jh=[];function rc(t,n){const i=t.getBoundingClientRect(),a=n.getBoundingClientRect(),s=getComputedStyle(t),o=parseFloat(s.borderLeftWidth)||0,c=parseFloat(s.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-c}px)`,opacity:1}}function on({options:t=Jh,value:n,defaultValue:i,onChange:a,size:s="md",block:o=!1,disabled:c=!1,readOnly:d=!1,loading:p=!1,error:m,highlightFill:h=!0,errorPlacement:u="bottom",className:x="",style:f,"data-testid":b="nice-segmented-control"}){const{t:g}=l.useNiceTranslation(),v=r.useRef(null),[y,C]=r.useState(i),[w,E]=r.useState({}),S=n!==void 0?n:y,N=t.findIndex(j=>j.value===S);r.useEffect(()=>{if(!v.current||N<0){E({opacity:0});return}const j=v.current,P=j.querySelectorAll(".nice-segmented-control__option")[N];if(!P){E({opacity:0});return}E(rc(j,P))},[N,t.length,h,s,o]),r.useEffect(()=>{const j=()=>{if(!v.current||N<0)return;const T=v.current,B=T.querySelectorAll(".nice-segmented-control__option")[N];B&&E(rc(T,B))};return window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[N]);const _=r.useCallback(j=>{c||d||p||t.find(P=>P.value===j)?.disabled||(n===void 0&&C(j),a?.(j))},[c,d,p,t,n,a]);l.useRovingFocus(v,{orientation:"both",wrap:!0,activateOnMove:!0});const k=e.jsxs("div",{ref:v,className:`nice-segmented-control nice-segmented-control--${s} ${o?"nice-segmented-control--block":""} ${c?"nice-segmented-control--disabled":""} ${d?"nice-segmented-control--readonly":""} ${p?"nice-segmented-control--loading":""} ${m?"nice-segmented-control--error":""} ${h?"nice-segmented-control--fill":""} ${x}`,style:f,role:"radiogroup","aria-label":g("controls.select","Select option"),"aria-busy":p||void 0,"aria-invalid":!!m||void 0,"data-testid":b,children:[e.jsx("div",{className:"nice-segmented-control__thumb",style:w}),t.map((j,T)=>{const P=j.value===S,B=c||j.disabled;return e.jsxs("button",{type:"button",className:`nice-segmented-control__option ${P?"nice-segmented-control__option--selected":""} ${B?"nice-segmented-control__option--disabled":""}`,onClick:()=>_(j.value),disabled:B||p,role:"radio","aria-checked":P,"data-testid":`${b}-option-${T}`,children:[j.icon&&e.jsx("span",{className:"nice-segmented-control__icon",children:j.icon}),e.jsx("span",{className:"nice-segmented-control__label",children:j.label})]},String(j.value))}),p&&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${u==="right"?" nice-segmented-control-field--err-right":""}`,children:[k,e.jsx("div",{className:"nice-segmented-control__error",role:"alert",children:m})]}):k}process.env.NODE_ENV!=="production"&&(on.displayName="NiceSegmentedControl");const Qh=["gamepad","hints","navigation","bindings"],Xh=["activate","back","secondary","tertiary","menu","view","sectionPrev","sectionNext","pagePrev","pageNext","first","last","toggleHints"],Ls={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"},Zh=Object.assign(function({sections:n=Qh,className:i,style:a,id:s,"data-testid":o}){const{t:c}=l.useNiceTranslation(),[d,p]=l.useInputPreferences(),[m,h]=r.useState(null);r.useEffect(()=>{if(!(!m||typeof window>"u"))return l.getInputEngine().captureNextInput(g=>{m.device==="gamepad"&&g.button?p({gamepadBindings:{...d.gamepadBindings,[m.intent]:[g.button]}}):m.device==="keyboard"&&g.keys&&p({keyboardBindings:{...d.keyboardBindings,[m.intent]:[g.keys]}}),h(null)})},[m,d.gamepadBindings,d.keyboardBindings,p]);const u=(g,v)=>p({[g]:v}),x=c("inputSettings.auto","Automatic"),f=g=>{const{[g]:v,...y}=d.gamepadBindings,{[g]:C,...w}=d.keyboardBindings;p({gamepadBindings:y,keyboardBindings:w})},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:c("inputSettings.section.gamepad","Gamepad")}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:c("inputSettings.confirmButton","Confirm with")}),e.jsx(on,{value:d.confirmButton,onChange:v=>u("confirmButton",v),options:[{value:"auto",label:x},{value:"south",label:c("input.pad.bottomButton","Bottom button")},{value:"east",label:c("input.pad.rightButton","Right button")}]})]}),e.jsx(Oe.NiceSelect,{label:c("inputSettings.glyphFamily","Button symbols"),value:d.glyphFamily,onChange:v=>u("glyphFamily",v),options:[{value:"auto",label:x},{value:"xbox",label:"Xbox"},{value:"playstation",label:"PlayStation"},{value:"nintendo",label:"Nintendo"},{value:"steam",label:"Steam"},{value:"generic",label:c("inputSettings.family.generic","Generic")}]}),e.jsx(dt.NiceSlider,{label:c("inputSettings.stickThreshold","Stick push needed to move"),min:.2,max:.9,step:.05,value:d.stickThreshold,onChange:v=>u("stickThreshold",v),showValue:!0}),e.jsx(dt.NiceSlider,{label:c("inputSettings.repeatDelay","Repeat after (ms)"),min:200,max:800,step:20,value:d.repeatDelay,onChange:v=>u("repeatDelay",v),showValue:!0}),e.jsx(dt.NiceSlider,{label:c("inputSettings.repeatInterval","Repeat every (ms)"),min:50,max:250,step:10,value:d.repeatInterval,onChange:v=>u("repeatInterval",v),showValue:!0}),e.jsx(Vt.NiceToggle,{label:c("inputSettings.invertScroll","Invert scrolling with the right stick"),checked:d.invertScroll,onChange:v=>u("invertScroll",v)}),e.jsx(Vt.NiceToggle,{label:c("inputSettings.vibration","Vibration"),checked:d.vibration,onChange:v=>u("vibration",v)})]},g);case"hints":return e.jsxs("section",{className:"nice-input-settings__section",children:[e.jsx("h3",{className:"nice-input-settings__title",children:c("inputSettings.section.hints","Button hints")}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:c("inputSettings.hints","Show hints")}),e.jsx(on,{value:d.hints,onChange:v=>u("hints",v),options:[{value:"auto",label:c("inputSettings.hints.auto","With keyboard or pad")},{value:"always",label:c("inputSettings.always","Always")},{value:"never",label:c("inputSettings.never","Never")}]})]}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:c("inputSettings.hintDensity","Where")}),e.jsx(on,{value:d.hintDensity,onChange:v=>u("hintDensity",v),options:[{value:"bar",label:c("inputSettings.density.bar","Hint bar")},{value:"bar-and-controls",label:c("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:c("inputSettings.section.navigation","Navigation")}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:c("inputSettings.arrowNavigation","Arrow keys outside lists")}),e.jsx(on,{value:d.arrowNavigation,onChange:v=>u("arrowNavigation",v),options:[{value:"auto",label:c("inputSettings.arrows.auto","Depends on the area")},{value:"spatial",label:c("inputSettings.arrows.spatial","Move focus")},{value:"native",label:c("inputSettings.arrows.native","Scroll")}]})]}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:c("inputSettings.onScreenKeyboard","On-screen keyboard")}),e.jsx(on,{value:d.onScreenKeyboard,onChange:v=>u("onScreenKeyboard",v),options:[{value:"auto",label:c("inputSettings.osk.auto","With a pad")},{value:"always",label:c("inputSettings.always","Always")},{value:"never",label:c("inputSettings.never","Never")}]})]})]},g);default:return e.jsxs("section",{className:"nice-input-settings__section",children:[e.jsx("h3",{className:"nice-input-settings__title",children:c("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:c("inputSettings.actionColumn","Action")}),e.jsx("th",{scope:"col",children:c("inputSettings.gamepadColumn","Gamepad")}),e.jsx("th",{scope:"col",children:c("inputSettings.keyboardColumn","Keyboard")}),e.jsx("th",{scope:"col",children:e.jsx("span",{className:"nice-sr-only",children:c("inputSettings.reset","Reset")})})]})}),e.jsx("tbody",{children:Xh.map(v=>{const y=w=>m?.intent===v&&m.device===w,C=(d.keyboardBindings[v]??l.NICE_DEFAULT_KEYBOARD_BINDINGS[v])[0];return e.jsxs("tr",{children:[e.jsx("th",{scope:"row",className:"nice-input-settings__action",children:c(`input.intent.${v}`,Ls[v])}),e.jsx("td",{children:e.jsx(Fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>h({intent:v,device:"gamepad"}),"aria-label":`${c("inputSettings.change","Change")}: ${c(`input.intent.${v}`,Ls[v])}`,children:y("gamepad")?c("inputSettings.pressButton","Press a button…"):e.jsx(l.NiceButtonPrompt,{intent:v,device:"gamepad",size:"sm"})})}),e.jsx("td",{children:e.jsx(Fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>h({intent:v,device:"keyboard"}),"aria-label":`${c("inputSettings.change","Change")}: ${c(`input.intent.${v}`,Ls[v])}`,children:y("keyboard")?c("inputSettings.pressKey","Press a key…"):C?e.jsx(l.NiceKeyCap,{keys:C,size:"sm"}):c("inputSettings.none","None")})}),e.jsx("td",{children:e.jsx(Fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>f(v),children:c("inputSettings.reset","Reset")})})]},v)})})]}),e.jsxs("div",{className:"nice-input-settings__actions",children:[m&&e.jsx(Fe.NiceButton,{size:"sm",onClick:()=>h(null),children:c("inputSettings.cancel","Cancel")}),e.jsx(Fe.NiceButton,{size:"sm",variant:"secondary",onClick:()=>p({gamepadBindings:{},keyboardBindings:{}}),children:c("inputSettings.resetAll","Reset all bindings")})]})]},g)}};return e.jsx("div",{id:s,"data-testid":o,className:`nice-input-settings${i?` ${i}`:""}`,style:a,children:n.map(b)})},{displayName:"NiceInputSettings"}),rs=({value:t,max:n=100,label:i,helperText:a,error:s,required:o,disabled:c,loading:d,showValue:p=!0,text:m,variant:h="primary",size:u="md",striped:x,animated:f,formatValue:b,labelPlacement:g="top",errorPlacement:v="bottom",labelWidth:y,controlWidth:C,className:w,style:E,id:S})=>{const N=l.useControlId(S),_=Math.min(100,Math.max(0,t/n*100)),k=m??(b?b(t,n):`${Math.round(_)}%`),j=p,T=i?e.jsxs("label",{className:"nice-field__label",htmlFor:N,children:[i,o&&e.jsx("span",{className:"nice-field__required",children:"*"})]}):null,P=s?e.jsx("div",{id:`${N}-error`,className:"nice-field__error",role:"alert",children:s}):null,B=!s&&a?e.jsx("div",{id:`${N}-helper`,className:"nice-field__helper",children:a}):null,R=e.jsxs("div",{className:`nice-progress ${c?"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":c||void 0,children:[e.jsx("div",{className:`nice-progress__track ${u!=="md"?`nice-progress__track--${u}`:""}`,children:e.jsx("div",{className:`nice-progress__fill nice-progress__fill--${h} ${x||d?"nice-progress__fill--striped":""} ${f||d?"nice-progress__fill--animated":""}`,style:{width:d?"100%":`${_}%`}})}),j&&(g==="left"||g==="right")&&e.jsx("span",{className:"nice-progress__value",children:k})]}),I=e.jsxs("div",{className:"nice-progress__header",children:[T,j&&e.jsx("span",{className:"nice-progress__value",children:k})]});return e.jsxs("div",{className:`nice-field nice-field--${u} nice-field--progress ${g==="left"?"nice-field--label-left":""} ${w||""}`,style:{...E,...y!=null&&{"--nice-field-label-width":typeof y=="number"?`${y}px`:y},...C!=null&&{"--nice-field-control-width":typeof C=="number"?`${C}px`:C}},children:[g==="top"&&(j?I:T),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,T]}):e.jsxs(e.Fragment,{children:[T,R]}),v==="right"&&P,v==="right"&&!s&&B]}):e.jsx("div",{className:"nice-field__control",children:R}),g==="bottom"&&(j?I:T),v!=="right"&&P,v!=="right"&&B]})},ps=({vertical:t,text:n,size:i="md",className:a,style:s,testId:o,"data-testid":c})=>t?e.jsx("hr",{className:`nice-divider nice-divider--vertical nice-divider--${i} ${a||""}`,style:s,"data-testid":c??o}):n?e.jsx("div",{className:`nice-divider--with-text nice-divider--${i} ${a||""}`,style:s,"data-testid":c??o,children:n}):e.jsx("hr",{className:`nice-divider nice-divider--${i} ${a||""}`,style:s,"data-testid":c??o}),oc=t=>typeof t=="number"?t:/^\d+(\.\d+)?$/.test(t.trim())?`${t}px`:t,eg={text:14,rect:80,circle:40},tg={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}},ha=({variant:t="text",width:n,height:i,count:a=1,size:s="md",orientation:o="vertical",animationSpeed:c,className:d,style:p,testId:m,"data-testid":h})=>{const u=tg[s]??eg,x=oc(n??(t==="circle"?u.circle:"100%")),f=oc(i??(t==="text"?u.text:t==="circle"?u.circle:u.rect)),b=c!=null&&c>0?{"--nice-skeleton-speed":`${c}s`}:null;if(a<=1)return e.jsx("div",{className:`nice-skeleton nice-skeleton--${t} nice-skeleton--${s} ${d||""}`,style:{width:x,height:f,...b,...p},"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,...p},"data-testid":h??m,children:Array.from({length:a}).map((v,y)=>e.jsx("div",{className:`nice-skeleton nice-skeleton--${t} nice-skeleton--${s}`,style:g?{flex:"1 1 0",minWidth:0,height:f}:{width:x,height:f}},y))})},Gr=({icon:t,title:n,description:i,action:a,size:s="md",className:o,style:c,testId:d,"data-testid":p})=>e.jsxs("div",{className:`nice-empty nice-empty--${s} ${o||""}`,style:c,"data-testid":p??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]}),ng=[],cc={xxs:9,xs:11,sm:13,small:13,md:16,medium:16,lg:20,large:20,xl:24,xxl:28},ld=Object.assign(r.forwardRef(({items:t=ng,mode:n="left",size:i="md",isFragment:a=!1,renderItem:s,className:o,style:c,id:d,testId:p,"data-testid":m,...h},u)=>{const{renderIcon:x}=l.useNiceIcon(),f=cc[i]??cc.md;return e.jsx("div",{ref:u,id:d,className:`nice-timeline nice-timeline--${n} nice-timeline--${i} ${a?"nice-timeline--fragment":""} ${o||""}`,style:c,"data-testid":m??p,...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:x(b.icon,f)??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:s?s(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"}),ig=[],dd=Object.assign(r.forwardRef(({items:t=ig,visibleCount:n=1,showArrows:i=!0,showDots:a=!0,autoPlay:s=7e3,circular:o=!0,activeIndex:c,onChange:d,size:p="md",fullWidth:m=!0,className:h,style:u,id:x,testId:f,"data-testid":b,...g},v)=>{const{t:y}=l.useNiceTranslation(),[C,w]=r.useState(0),E=r.useRef(void 0),N=c!=null&&typeof d=="function"?c:C,_=Math.max(1,Math.floor(n||1)),k=Math.max(0,t.length-_),j=r.useCallback(q=>{let se=q;o?se=(q%t.length+t.length)%t.length:se=Math.max(0,Math.min(k,q)),w(se),d?.(se)},[t.length,k,o,d]),T=r.useCallback(()=>j(N+1),[j,N]),P=r.useCallback(()=>j(N-1),[j,N]),[B,R]=r.useState(!1),[I,D]=r.useState(!1),[M,O]=r.useState(!1),L=s>0&&!M&&!B&&!I;r.useEffect(()=>{if(L)return E.current=setInterval(T,s),()=>clearInterval(E.current)},[L,s,T]);const V=o||N>0,ee=o||N<k,z=r.useRef(null);r.useEffect(()=>{const q=z.current?.children;q&&Array.from(q).forEach((se,ce)=>{se.toggleAttribute("inert",ce<N||ce>=N+_)})},[N,_,t.length]);const U=r.useRef(null),re=r.useCallback(q=>{U.current=q,typeof v=="function"?v(q):v&&(v.current=q)},[v]);l.useIntent(["sectionPrev","sectionNext"],q=>{if(q.intent==="sectionNext"?!ee:!V)return!1;q.intent==="sectionNext"?T():P()},{ref:U,enabled:t.length>_}),l.useInputHints(U,[{intent:"sectionPrev",label:y("carousel.prev","Previous slide")},{intent:"sectionNext",label:y("carousel.next","Next slide")}],{enabled:t.length>_});const Y=r.useCallback(q=>{q.target===q.currentTarget&&(q.key==="ArrowLeft"&&V?(q.preventDefault(),P()):q.key==="ArrowRight"&&ee?(q.preventDefault(),T()):q.key==="Home"?(q.preventDefault(),j(0)):q.key==="End"&&(q.preventDefault(),j(k)))},[P,T,j,V,ee,k]),oe=r.useRef(null);return l.useRovingFocus(oe,{orientation:"horizontal",activateOnMove:!0}),e.jsxs("div",{ref:re,id:x,className:`nice-carousel nice-carousel--${p} ${m?"nice-carousel--full-width":""} ${h||""}`,style:u,"data-testid":b??f,role:"region","aria-roledescription":"carousel","aria-label":y("carousel.label","Carousel"),tabIndex:0,onKeyDown:Y,onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),onFocus:()=>D(!0),onBlur:q=>{q.currentTarget.contains(q.relatedTarget)||D(!1)},...g,children:[s>0&&e.jsx("button",{type:"button",className:"nice-carousel__rotation",onClick:()=>O(q=>!q),"aria-label":M?y("carousel.startRotation","Start automatic slide show"):y("carousel.stopRotation","Stop automatic slide show"),children:e.jsx(l.NiceIcon,{name:M?"play":"pause",size:16})}),e.jsx("div",{className:"nice-carousel__viewport","aria-live":L?"off":"polite",children:e.jsx("div",{ref:z,className:"nice-carousel__track",style:{transform:`translateX(-${N*(100/_)}%)`,"--nice-carousel-slide-basis":`${100/_}%`},children:t.map((q,se)=>e.jsx("div",{className:"nice-carousel__slide",role:"group","aria-roledescription":"slide","aria-label":`${se+1} / ${t.length}`,children:q},se))})}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-carousel__arrow nice-carousel__arrow--prev",onClick:P,disabled:!V,"aria-label":y("carousel.prev","Previous"),children:e.jsx(l.NiceIcon,{name:"chevron-left",size:20})}),e.jsx("button",{type:"button",className:"nice-carousel__arrow nice-carousel__arrow--next",onClick:T,disabled:!ee,"aria-label":y("carousel.next","Next"),children:e.jsx(l.NiceIcon,{name:"chevron-right",size:20})})]}),a&&t.length>_&&e.jsx("div",{className:"nice-carousel__dots",role:"tablist",ref:oe,children:Array.from({length:k+1},(q,se)=>e.jsx("button",{type:"button",className:`nice-carousel__dot ${se===N?"nice-carousel__dot--active":""}`,onClick:()=>j(se),role:"tab","aria-selected":se===N,"aria-label":`${y("carousel.goTo","Go to slide")} ${se+1}`},se))})]})}),{displayName:"NiceCarousel"}),ag=[];function sg({items:t=ag,itemHeight:n,height:i=400,overscan:a=3,renderItem:s,itemKey:o,className:c,style:d,size:p="md",disabled:m,readOnly:h,loading:u,error:x,testId:f,"data-testid":b,...g},v){const y=r.useRef(null),[C,w]=r.useState(0),E=typeof i=="number"?i:parseFloat(String(i)),S=Number.isFinite(E)?E:400,N=Number.isFinite(n)&&n>0?n:1,_=Number.isFinite(a)&&a>=0?Math.floor(a):0,k=t.length*N,{startIndex:j,endIndex:T}=r.useMemo(()=>{const R=Math.max(1,Math.ceil(S/N)),I=Math.floor(C/N),D=Math.max(0,I-_),M=Math.min(t.length-1,I+R+_);return{startIndex:D,endIndex:M}},[C,S,N,t.length,_]),P=r.useCallback(R=>{w(R.currentTarget.scrollTop)},[]);r.useEffect(()=>{v&&(typeof v=="function"?v(y.current):v.current=y.current)},[v]);const B=r.useMemo(()=>{const R=[];for(let I=j;I<=T;I++){const D=o?o(t[I],I):I;R.push(e.jsx("div",{className:"nice-virtual-scroller__item",style:{position:"absolute",top:I*N,left:0,right:0,height:N},children:s(t[I],I)},D))}return R},[j,T,t,N,s,o]);return e.jsxs("div",{ref:y,className:`nice-virtual-scroller nice-virtual-scroller--${p} ${m?"nice-virtual-scroller--disabled":""} ${x?"nice-virtual-scroller--error":""} ${c||""}`,style:{width:"100%",...d,height:typeof i=="string"&&!/^\d+(\.\d+)?$/.test(i)?i:S,overflow:"auto",position:"relative"},onScroll:P,role:"list","aria-disabled":m||void 0,"aria-busy":u||void 0,"data-testid":b??f,...g,children:[x?e.jsx("div",{className:"nice-virtual-scroller__error",role:"alert",children:x}):e.jsx("div",{style:{height:k,position:"relative",width:"100%"},children:B}),u&&e.jsx("div",{className:"nice-virtual-scroller__loading","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})}const ud=Object.assign(r.forwardRef(sg),{displayName:"NiceVirtualScroller"}),rg=[],pd=r.createContext(null);function Ts(){const t=r.useContext(pd);if(!t)throw new Error("useFAQ must be used within NiceFAQ");return t}function La(t,n){if(!n)return{score:1,indices:[]};const i=t.toLowerCase(),s=n.toLowerCase().split(/\s+/).filter(Boolean);let o=0;const c=[];for(const p of s){let m=!1,h=0;for(;(h=i.indexOf(p,h))!==-1;){m=!0,c.push([h,h+p.length]);const u=h===0||/\s/.test(t[h-1]),x=h+p.length===t.length||/\s/.test(t[h+p.length]);u&&x?o+=2:u?o+=1.5:o+=1,h+=1}if(!m){let u=0,x=-1;for(let f=0;f<i.length&&u<p.length;f++)if(i[f]===p[u]){if(x===-1||f===x+1)if(x===-1)c.push([f,f+1]);else{const b=c[c.length-1];b[1]=f+1}else c.push([f,f+1]);x=f,u++}if(u===p.length)o+=.5;else return null}}const d=og(c);return{score:o/s.length,indices:d}}function og(t){if(t.length===0)return[];const n=[...t].sort((a,s)=>a[0]-s[0]),i=[n[0]];for(let a=1;a<n.length;a++){const s=i[i.length-1],o=n[a];o[0]<=s[1]?s[1]=Math.max(s[1],o[1]):i.push(o)}return i}function cg(t,n){if(!n.trim())return t.map(a=>({item:a,score:1,matches:[]}));const i=[];for(const a of t){const s=[];let o=0;const c=La(a.question,n);if(c&&c.score>0&&(s.push({field:"question",indices:c.indices}),o+=c.score*3),typeof a.answer=="string"){const d=La(a.answer,n);d&&d.score>0&&(s.push({field:"answer",indices:d.indices}),o+=d.score*1)}if(a.tags)for(const d of a.tags){const p=La(d,n);if(p&&p.score>0){s.push({field:"tags",indices:p.indices}),o+=p.score*2;break}}if(a.keywords)for(const d of a.keywords){const p=La(d,n);if(p&&p.score>0){s.push({field:"keywords",indices:p.indices}),o+=p.score*2.5;break}}s.length>0&&(a.featured&&(o*=1.2),i.push({item:a,score:o,matches:s}))}return i.sort((a,s)=>s.score-a.score)}const lg=({text:t,indices:n})=>{if(n.length===0)return e.jsx(e.Fragment,{children:t});const i=[];let a=0;for(const[s,o]of n)s>a&&i.push(e.jsx("span",{children:t.slice(a,s)},`text-${a}`)),i.push(e.jsx("mark",{className:"nice-faq-highlight",children:t.slice(s,o)},`mark-${s}`)),a=o;return a<t.length&&i.push(e.jsx("span",{children:t.slice(a)},`text-${a}`)),e.jsx(e.Fragment,{children:i})},md=({placeholder:t,autoFocus:n=!1,showIcon:i=!0,debounceMs:a=200})=>{const{t:s}=l.useNiceTranslation(),o=t??s("faq.searchFaqPlaceholder","Search FAQ..."),{searchQuery:c,setSearchQuery:d}=Ts(),[p,m]=r.useState(c),h=r.useRef(null),u=r.useRef(null);r.useEffect(()=>(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{d(p)},a),()=>{u.current&&clearTimeout(u.current)}),[p,a,d]);const x=r.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(l.NiceIcon,{name:"search",size:16})}),e.jsx("input",{ref:h,type:"text",className:"nice-faq-search-input",placeholder:o,value:p,onChange:f=>m(f.target.value),autoFocus:n,"aria-label":s("faq.searchFaq","Search FAQ")}),p&&e.jsx("button",{className:"nice-faq-search-clear",onClick:x,"aria-label":s("faq.clearSearch","Clear search"),children:e.jsx(l.NiceIcon,{name:"close",size:14})})]})},hd=({showCounts:t=!0,layout:n="horizontal"})=>{const{t:i}=l.useNiceTranslation(),{categories:a,items:s,selectedCategory:o,setSelectedCategory:c}=Ts(),d=r.useMemo(()=>{const p={all:s.length};for(const m of s)m.category&&(p[m.category]=(p[m.category]||0)+1);return p},[s]);return a.length===0?null:n==="dropdown"?e.jsx("div",{className:"nice-faq-category-dropdown",children:e.jsxs("select",{value:o||"all",onChange:p=>c(p.target.value==="all"?null:p.target.value),className:"nice-faq-category-select",children:[e.jsxs("option",{value:"all",children:[i("faq.allCategories","All Categories")," ",t&&`(${d.all})`]}),a.map(p=>e.jsxs("option",{value:p.id,children:[p.name," ",t&&`(${d[p.id]||0})`]},p.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:()=>c(null),children:[e.jsx("span",{children:i("faq.all","All")}),t&&e.jsx("span",{className:"nice-faq-category-count",children:d.all})]}),a.map(p=>e.jsxs("button",{className:`nice-faq-category-btn ${o===p.id?"nice-faq-category-btn--active":""}`,onClick:()=>c(p.id),style:p.color?{"--cat-color":p.color}:void 0,children:[p.icon&&e.jsx("span",{className:"nice-faq-category-icon",children:p.icon}),e.jsx("span",{children:p.name}),t&&e.jsx("span",{className:"nice-faq-category-count",children:d[p.id]||0})]},p.id))]})},Wr=({result:t,showFeedback:n=!0,showRelated:i=!0,animateExpand:a=!0})=>{const{t:s}=l.useNiceTranslation(),{item:o,matches:c}=t,{expandedIds:d,toggleExpanded:p,items:m,submitFeedback:h}=Ts(),[u,x]=r.useState(null),[f,b]=r.useState(!1),[g,v]=r.useState(""),y=r.useRef(null),C=d.has(o.id);r.useEffect(()=>{y.current?.toggleAttribute("inert",!C)},[C]);const w=c.find(_=>_.field==="question")?.indices||[],E=r.useMemo(()=>!i||!o.relatedIds||o.relatedIds.length===0?[]:m.filter(_=>o.relatedIds?.includes(_.id)),[i,o.relatedIds,m]),S=_=>{x(_),_?h(o.id,_):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:()=>p(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(lg,{text:o.question,indices:w})}),e.jsx("span",{className:`nice-faq-chevron ${C?"nice-faq-chevron--open":""}`,children:e.jsx(l.NiceIcon,{name:"chevron-down",size:16})})]}),e.jsx("div",{id:`faq-answer-${o.id}`,className:`nice-faq-answer ${a?"nice-faq-answer--animated":""}`,ref:y,style:{maxHeight:C?a?y.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(_=>e.jsx("span",{className:"nice-faq-tag",children:_},_))}),E.length>0&&e.jsxs("div",{className:"nice-faq-related",children:[e.jsx("span",{className:"nice-faq-related-label",children:s("faq.related","Related:")}),E.map(_=>e.jsx("button",{className:"nice-faq-related-link",onClick:k=>{k.stopPropagation(),p(_.id),document.querySelector(`[data-question-id="${_.id}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})},children:_.question},_.id))]}),n&&e.jsxs("div",{className:"nice-faq-feedback",children:[u===null?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-faq-feedback-label",children:s("faq.wasThisHelpful","Was this helpful?")}),e.jsxs("button",{className:"nice-faq-feedback-btn nice-faq-feedback-btn--yes",onClick:()=>S(!0),"aria-label":s("faq.yesThisWasHelpful","Yes, this was helpful"),children:[e.jsx(l.NiceIcon,{name:"check",size:14})," ",s("faq.yes","Yes")]}),e.jsxs("button",{className:"nice-faq-feedback-btn nice-faq-feedback-btn--no",onClick:()=>S(!1),"aria-label":s("faq.noThisWasNotHelpful","No, this was not helpful"),children:[e.jsx(l.NiceIcon,{name:"close",size:14})," ",s("faq.no","No")]})]}):e.jsx("span",{className:"nice-faq-feedback-thanks",children:u?s("faq.thanksForYourFeedback","Thanks for your feedback!"):""}),f&&e.jsxs("div",{className:"nice-faq-feedback-form",children:[e.jsx("textarea",{placeholder:s("faq.howCanWeImproveThis","How can we improve this answer?"),value:g,onChange:_=>v(_.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:s("faq.submit","Submit")}),e.jsx("button",{className:"nice-faq-feedback-cancel",onClick:()=>{b(!1),x(null)},children:s("faq.cancel","Cancel")})]})]})]})]})})]})},xr=({category:t,results:n,showFeedback:i,showRelated:a,collapsible:s=!0})=>{const{t:o}=l.useNiceTranslation(),[c,d]=r.useState(!1),p=r.useId();return n.length===0?null:e.jsxs("div",{className:"nice-faq-group",children:[e.jsxs("div",{className:`nice-faq-group-header ${s?"nice-faq-group-header--collapsible":""}`,role:"presentation",onClick:s?()=>d(!c):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}),s&&e.jsx("button",{type:"button",className:`nice-faq-group-chevron ${c?"":"nice-faq-group-chevron--open"}`,"aria-expanded":!c,"aria-controls":c?void 0:p,"aria-label":`${c?o("faq.expandGroup","Expand"):o("faq.collapseGroup","Collapse")}: ${t.name}`,onClick:m=>{m.stopPropagation(),d(!c)},children:e.jsx(l.NiceIcon,{name:"chevron-down",size:16})})]}),!c&&e.jsx("div",{id:p,className:"nice-faq-group-items",children:n.map(m=>e.jsx(Wr,{result:m,showFeedback:i,showRelated:a},m.item.id))})]})},dg=({items:t=rg,categories:n=[],showSearch:i=!0,searchPlaceholder:a,autoFocusSearch:s=!1,showCategories:o=!0,categoryLayout:c="horizontal",groupByCategory:d=!0,allowMultiple:p=!0,defaultExpanded:m=[],showFeedback:h=!0,showRelated:u=!0,onFeedback:x,onAnalytics:f,showExpandControls:b=!0,animateExpand:g=!0,emptyMessage:v,generateSchema:y=!0,header:C,footer:w,size:E="md",className:S,style:N,testId:_,"data-testid":k})=>{const{t:j}=l.useNiceTranslation(),T=a??j("faq.searchFrequentlyAskedQuestions","Search frequently asked questions..."),P=v??j("faq.noQuestionsFoundMatchingYour","No questions found matching your search."),[B,R]=r.useState(new Set(m)),[I,D]=r.useState(""),[M,O]=r.useState(null),L=r.useMemo(()=>[...t].sort((le,J)=>le.featured&&!J.featured?-1:!le.featured&&J.featured?1:(le.order??999)-(J.order??999)),[t]),V=r.useMemo(()=>M?L.filter(le=>le.category===M):L,[L,M]),ee=r.useMemo(()=>cg(V,I),[V,I]),z=r.useMemo(()=>{if(!d||n.length===0)return null;const le={},J=[];for(const me of ee){const je=me.item.category;je?(le[je]||(le[je]=[]),le[je].push(me)):J.push(me)}return{groups:le,uncategorized:J}},[d,n,ee]),U=r.useCallback(le=>{R(J=>{const me=new Set(J);return me.has(le)?(me.delete(le),f?.({type:"collapse",questionId:le,timestamp:new Date().toISOString()})):(p||me.clear(),me.add(le),f?.({type:"expand",questionId:le,timestamp:new Date().toISOString()})),me})},[p,f]),re=r.useCallback(()=>{R(new Set(t.map(le=>le.id)))},[t]),Y=r.useCallback(()=>{R(new Set)},[]),oe=r.useCallback(le=>{D(le),le.trim()&&f?.({type:"search",searchQuery:le,timestamp:new Date().toISOString()})},[f]),q=r.useCallback((le,J,me)=>{const je={questionId:le,helpful:J,comment:me,timestamp:new Date().toISOString()};x?.(je),f?.({type:"feedback",questionId:le,timestamp:je.timestamp,metadata:{helpful:J,comment:me}})},[x,f]),se=r.useMemo(()=>{if(!y)return null;const le={"@context":"https://schema.org","@type":"FAQPage",mainEntity:t.map(J=>({"@type":"Question",name:J.question,acceptedAnswer:{"@type":"Answer",text:typeof J.answer=="string"?J.answer:""}}))};return e.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(le)}})},[y,t]),ce={items:L,categories:n,expandedIds:B,searchQuery:I,selectedCategory:M,toggleExpanded:U,expandAll:re,collapseAll:Y,setSearchQuery:oe,setSelectedCategory:O,submitFeedback:q};return e.jsx(pd.Provider,{value:ce,children:e.jsxs("div",{className:`nice-faq nice-faq--${E} ${S||""}`,style:N,"data-testid":k??_,children:[se,C&&e.jsx("div",{className:"nice-faq-header",children:C}),e.jsxs("div",{className:"nice-faq-controls",children:[i&&e.jsx(md,{placeholder:T,autoFocus:s}),o&&n.length>0&&e.jsx(hd,{layout:c,showCounts:!0}),b&&e.jsxs("div",{className:"nice-faq-expand-controls",children:[e.jsx("button",{className:"nice-faq-expand-btn",onClick:re,children:j("faq.expandAll","Expand All")}),e.jsx("button",{className:"nice-faq-expand-btn",onClick:Y,children:j("faq.collapseAll","Collapse All")})]})]}),I&&e.jsx("div",{className:"nice-faq-results-info",children:(ee.length===1?j("faq.foundOneResult",'Found 1 result for "{query}"'):j("faq.foundResults",'Found {count} results for "{query}"')).replace("{count}",String(ee.length)).replace("{query}",I)}),e.jsx("div",{className:"nice-faq-list",children:ee.length===0?e.jsx("div",{className:"nice-faq-empty",children:typeof P=="string"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-faq-empty-icon",children:e.jsx(l.NiceIcon,{name:"search",size:32})}),e.jsx("p",{children:P})]}):P}):z?e.jsxs(e.Fragment,{children:[n.sort((le,J)=>(le.order??999)-(J.order??999)).map(le=>e.jsx(xr,{category:le,results:z.groups[le.id]||[],showFeedback:h,showRelated:u},le.id)),z.uncategorized.length>0&&e.jsx(xr,{category:{id:"other",name:"Other Questions"},results:z.uncategorized,showFeedback:h,showRelated:u})]}):ee.map(le=>e.jsx(Wr,{result:le,showFeedback:h,showRelated:u,animateExpand:g},le.item.id))}),w&&e.jsx("div",{className:"nice-faq-footer",children:w})]})})},ug=[];function zs(t,n){return n.split(".").reduce((i,a)=>{if(i&&typeof i=="object")return i[a]},t)}const pg=({status:t})=>{const{t:n}=l.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 mg({columns:t=ug,data:n=[],dataSource:i,rowKey:a="id",showConnectionStatus:s=!0,highlightDuration:o=2e3,updateAnimation:c="flash",maxRows:d,selectable:p=!1,selectedIds:m,onSelectionChange:h,onRowClick:u,onUpdate:x,onConnectionStatusChange:f,emptyContent:b,loadingContent:g,sortable:v=!1,sortField:y,sortDirection:C,onSortChange:w,virtualized:E=!1,rowHeight:S=40,height:N=400,className:_="",style:k,"data-testid":j},T){const{t:P}=l.useNiceTranslation(),[B,R]=r.useState(n),[I,D]=r.useState(!1),[M,O]=r.useState("disconnected"),[L,V]=r.useState(new Map),[ee,z]=r.useState(m||new Set),U=r.useRef(null),re=r.useRef(null),Y=r.useRef(new Map),oe=m??ee,q=h??z,se=r.useCallback(A=>A[a],[a]),ce=r.useCallback((A,Z,fe=[])=>{V(Q=>{const ne=new Map(Q);return ne.set(A,{operation:Z,changedFields:new Set(fe),timestamp:Date.now()}),ne});const Ne=Y.current.get(A);Ne&&clearTimeout(Ne);const K=setTimeout(()=>{V(Q=>{const ne=new Map(Q);return ne.delete(A),ne}),Y.current.delete(A)},o);Y.current.set(A,K)},[o]),le=r.useCallback(A=>{const Z=se(A.row);if(R(fe=>{switch(A.operation){case"insert":{if(fe.some(Q=>se(Q)===Z))return fe;const K=[A.row,...fe];return d&&K.length>d?K.slice(0,d):K}case"update":return fe.map(Ne=>se(Ne)===Z?{...Ne,...A.row,...A.changes||{}}:Ne);case"upsert":{if(fe.some(Q=>se(Q)===Z))return fe.map(Q=>se(Q)===Z?{...Q,...A.row,...A.changes||{}}:Q);const K=[A.row,...fe];return d&&K.length>d?K.slice(0,d):K}case"delete":return fe.filter(Ne=>se(Ne)!==Z);default:return fe}}),c!=="none"){const fe=A.changes?Object.keys(A.changes):[];ce(Z,A.operation,fe)}x?.(A)},[se,d,c,ce,x]),J=r.useCallback(A=>{"updates"in A?A.fullRefresh?R(A.updates.map(Z=>Z.row)):A.updates.forEach(le):le(A)},[le]);r.useEffect(()=>{if(!i)return;i.fetchInitial&&(D(!0),i.fetchInitial().then(Z=>{R(Z),D(!1)})),re.current=i.subscribe(J);let A;return i.onStatusChange?A=i.onStatusChange(Z=>{O(Z),f?.(Z)}):(O("connected"),f?.("connected")),()=>{re.current?.(),A?.()}},[i,J,f]),r.useEffect(()=>{const A=Y.current;return()=>{A.forEach(Z=>clearTimeout(Z))}},[]),r.useImperativeHandle(T,()=>({getData:()=>B,addRow:A=>le({operation:"insert",row:A}),updateRow:(A,Z)=>{const fe=B.find(Ne=>se(Ne)===A);fe&&le({operation:"update",row:fe,changes:Z})},deleteRow:A=>{const Z=B.find(fe=>se(fe)===A);Z&&le({operation:"delete",row:Z})},refresh:()=>{i?.fetchInitial&&(D(!0),i.fetchInitial().then(A=>{R(A),D(!1)}))},getConnectionStatus:()=>M}));const me=r.useMemo(()=>!y||!C?B:[...B].sort((A,Z)=>{const fe=zs(A,y),Ne=zs(Z,y);if(fe===Ne)return 0;if(fe==null)return 1;if(Ne==null)return-1;const K=fe<Ne?-1:1;return C==="asc"?K:-K}),[B,y,C]),je=r.useCallback((A,Z)=>{if(p){const fe=se(A),Ne=new Set(oe);Ne.has(fe)?Ne.delete(fe):Ne.add(fe),q(Ne)}u?.(A,Z)},[p,se,oe,q,u]),ue=r.useCallback(A=>{if(!v)return;let Z="asc";y===A&&(Z=C==="asc"?"desc":"asc"),w?.(A,Z)},[v,y,C,w]),F=r.useCallback(A=>{const Z=se(A),fe=L.get(Z),Ne=oe.has(Z),K=["nice-live-grid-row"];return Ne&&K.push("nice-live-grid-row--selected"),fe&&(K.push(`nice-live-grid-row--${fe.operation}`),K.push(`nice-live-grid-row--${c}`)),K.join(" ")},[se,L,oe,c]),H=r.useCallback((A,Z)=>{const fe=se(A);return L.get(fe)?.changedFields.has(Z)?"nice-live-grid-cell--changed":""},[se,L]);return I&&B.length===0?e.jsx("div",{className:`nice-live-grid nice-live-grid--loading ${_}`,style:k,"data-testid":j,children:g===void 0?P("loading","Loading…"):g}):e.jsxs("div",{ref:U,className:`nice-live-grid ${_}`,style:{...k,height:N},"data-testid":j,children:[s&&e.jsxs("div",{className:"nice-live-grid-header",children:[e.jsx(pg,{status:M}),e.jsx("span",{className:"nice-live-grid-count",children:P("liveGrid.rows","{count} rows").replace("{count}",String(B.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(A=>e.jsxs("th",{className:`nice-live-grid-th ${v&&A.sortable!==!1?"nice-live-grid-th--sortable":""}`,style:{width:A.width,minWidth:A.minWidth,maxWidth:A.maxWidth,textAlign:A.align||"left"},onClick:()=>A.sortable!==!1&&ue(String(A.field)),children:[A.headerRender?A.headerRender(A):A.header,y===String(A.field)&&e.jsx("span",{className:"nice-live-grid-sort-icon",children:e.jsx(l.NiceIcon,{name:C==="asc"?"sort-asc":"sort-desc",size:12})})]},String(A.field)))})}),e.jsx("tbody",{children:me.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:t.length,className:"nice-live-grid-empty",children:b===void 0?P("noData","No data"):b})}):me.map(A=>e.jsx("tr",{className:F(A),onClick:Z=>je(A,Z),style:{height:S},children:t.map(Z=>{const fe=zs(A,String(Z.field));return e.jsx("td",{className:`nice-live-grid-td ${H(A,String(Z.field))}`,style:{textAlign:Z.align||"left"},children:Z.render?Z.render(fe,A,Z):String(fe??"")},String(Z.field))})},String(se(A))))})]})})]})}const hg=Object.assign(r.forwardRef(mg),{displayName:"NiceLiveDataGrid"});function Vi(t){return{key:t?.keyField??"id",children:t?.childrenField??"children"}}function Li(t,n){return String(t[n])}function zi(t,n){const i=t[n];return Array.isArray(i)?i:void 0}function lc(t,n,i){return{...t,[n]:i}}function sn(t,n,i){const a=Vi(i),s=(o,c,d)=>{o.forEach((p,m)=>{const h={node:p,parent:c,parentId:c===null?null:Li(c,a.key),index:m,siblings:o,ancestors:d,depth:d.length};if(n(p,h)===!1)return;const u=zi(p,a.children);u?.length&&s(u,p,[...d,p])})};s(t,null,[])}function It(t,n,i){const a=Vi(i),s=(o,c,d)=>{for(let p=0;p<o.length;p++){const m=o[p];if(Li(m,a.key)===n)return{node:m,parent:c,parentId:c===null?null:Li(c,a.key),index:p,siblings:o,ancestors:d,depth:d.length};const h=zi(m,a.children);if(h?.length){const u=s(h,m,[...d,m]);if(u)return u}}};return s(t,null,[])}function si(t,n,i){return It(t,n,i)?.node}function Kr(t,n,i,a){const s=Vi(a);return!!It(t,n,a)?.ancestors.some(c=>Li(c,s.key)===i)}function _a(t,n){const i=Vi(n),a=zi(t,i.children);return a?.length?1+Math.max(...a.map(s=>_a(s,n))):1}function Yr(t,n,i,a){const s=Vi(a);if(n===null)return i(t);let o=!1;const c=d=>{let p=null;for(let m=0;m<d.length&&!o;m++){const h=d[m];let u=null;if(Li(h,s.key)===n)u=lc(h,s.children,i(zi(h,s.children)??[])),o=!0;else{const x=zi(h,s.children),f=x?.length?c(x):null;f&&(u=lc(h,s.children,f))}u&&(p=p??[...d],p[m]=u)}return p};return c(t)??[...t]}function Hn(t,n,i,a){return i.parentId!==null&&!si(t,i.parentId,a)?t:Yr(t,i.parentId,s=>{const o=[...s];return o.splice(Math.max(0,Math.min(i.index,o.length)),0,n),o},a)}function mi(t,n,i){const a=It(t,n,i);return a?Yr(t,a.parentId,s=>s.filter((o,c)=>c!==a.index),i):t}function ka(t,n,i,a){const s=It(t,n,a);if(!s)return t;const o=typeof i=="function"?i(s.node):{...s.node,...i};return Yr(t,s.parentId,c=>c.map((d,p)=>p===s.index?o:d),a)}function Ui(t,n,i,a){const s=It(t,n,a);if(!s||i.parentId!==null&&(i.parentId===n||Kr(t,i.parentId,n,a)||!si(t,i.parentId,a)))return t;let o=i.index;if(s.parentId===i.parentId&&(o>s.index&&(o-=1),o=Math.max(0,Math.min(o,s.siblings.length-1)),o===s.index))return t;const c=mi(t,n,a);return Hn(c,s.node,{parentId:i.parentId,index:o},a)}function ms(t,n,i,a){const s=It(t,n,a);if(!s)return t;const o=Math.max(0,Math.min(s.index+i,s.siblings.length-1));return o===s.index?t:Ui(t,n,{parentId:s.parentId,index:o>s.index?o+1:o},a)}function Jr(t,n,i){const a=Vi(i),s=It(t,n,i);if(!s||s.index===0)return t;const o=s.siblings[s.index-1];return Ui(t,n,{parentId:Li(o,a.key),index:zi(o,a.children)?.length??0},i)}function Qr(t,n,i){const a=It(t,n,i);if(!a||a.parentId===null)return t;const s=It(t,a.parentId,i);return s?Ui(t,n,{parentId:s.parentId,index:s.index+1},i):t}const gg=[],bg=["moveUp","moveDown","indent","outdent","rename","remove"],fg=5,dc=28,vg=600,xg=16,yg=10;function Ng(t){const{value:n,defaultValue:i,onChange:a,keyField:s="id",childrenField:o="children",labelField:c="label",getLabel:d,renderLabel:p,getIcon:m,renderRowEnd:h,selectedId:u,defaultSelectedId:x,onSelect:f,collapsedIds:b,defaultCollapsedIds:g,onCollapsedChange:v,canHaveChildren:y,canDrag:C,canDrop:w,maxDepth:E,editable:S=!1,removable:N=!1,actions:_=!0,contextMenuItems:k,onExternalDrop:j,emptyText:T,"aria-label":P,height:B,size:R="md",readOnly:I=!1,disabled:D=!1,className:M,style:O,id:L,title:V,accessMode:ee,"data-testid":z}=t,{t:U}=l.useNiceTranslation(),re=l.useNiceAccessMode(ee,L),Y=D||re==="disabled",oe=I||re==="readOnly"||Y,q=r.useMemo(()=>({keyField:s,childrenField:o}),[s,o]),[se,ce]=l.useControllableState({value:n,defaultValue:i,fallbackValue:[],componentName:"NiceSortableTree"}),[le,J]=l.useControllableState({value:u,defaultValue:x,fallbackValue:null,componentName:"NiceSortableTree"}),[me,je]=l.useControllableState({value:b,defaultValue:g,fallbackValue:gg,componentName:"NiceSortableTree"}),ue=r.useCallback(de=>String(de[s]),[s]),F=r.useCallback(de=>{const De=de[o];return Array.isArray(De)?De:[]},[o]),H=r.useCallback(de=>{if(d)return d(de);const De=de[c];return De==null?ue(de):String(De)},[d,c,ue]),A=(de,De)=>!oe&&(typeof de=="function"?de(De):de),Z=r.useCallback(de=>y?y(de):!0,[y]),fe=r.useMemo(()=>new Set(me),[me]),Ne=r.useMemo(()=>{const de=[];return sn(se,(De,Ge)=>{const Ze=ue(De),lt=F(De).length>0,yt=lt&&!fe.has(Ze);return de.push({node:De,id:Ze,depth:Ge.depth,parentId:Ge.parentId,index:Ge.index,setSize:Ge.siblings.length,hasChildren:lt,expanded:yt}),yt?void 0:!1},q),de},[se,fe,ue,F,q]),K=r.useMemo(()=>new Map(Ne.map(de=>[de.id,de])),[Ne]),Q=r.useRef(null),ne=r.useRef(null),[G,Se]=r.useState(""),te=r.useRef(null),we=r.useCallback(de=>{je(de),v?.(de)},[je,v]),ie=r.useCallback((de,De)=>{const Ge=me.includes(de);De&&Ge?we(me.filter(Ze=>Ze!==de)):!De&&!Ge&&we([...me,de])},[me,we]),xe=r.useCallback(de=>{J(de),f?.(de,de===null?null:si(se,de,q)??null)},[J,f,se,q]);l.useTreeFocus(ne,{onToggle:(de,De)=>{const Ge=de.dataset.nodeId;Ge!==void 0&&ie(Ge,De)}});const W=de=>{const De=It(se,de,q);return De?{parentId:De.parentId,index:De.index}:null},be=(de,De)=>{const Ge=It(de,De,q);if(!Ge)return;const Ze=Ge.parent?H(Ge.parent):U("sortableTree.root","top level");Se(U("sortableTree.announceMoved","{label} moved to {parent}, position {position} of {count}").replace("{label}",H(Ge.node)).replace("{parent}",Ze).replace("{position}",String(Ge.index+1)).replace("{count}",String(Ge.siblings.length)))},Te=(de,De)=>de===se?!1:(ce(de),a?.(de,De),!0),Me=(de,De,Ge,Ze)=>{let lt=0;if(De.parentId!==null){if(de!==null&&(De.parentId===de||Kr(se,De.parentId,de,q)))return!1;const yt=It(se,De.parentId,q);if(!yt||!Z(yt.node))return!1;lt=yt.depth+1}return E!==void 0&&lt+Ge>E?!1:w?w(de,De,Ze):!0},$=(de,De,Ge,Ze)=>{const lt=W(de);if(!lt)return;const yt=si(se,de,q);if(!yt||!Me(de,De,_a(yt,q)))return;const ct=It(Ze,de,q),wt=ct?{parentId:ct.parentId,index:ct.index}:De;Te(Ze,{type:Ge,id:de,from:lt,to:wt})&&(te.current=de,wt.parentId!==null&&ie(wt.parentId,!0),be(Ze,de))},X=(de,De)=>{const Ge=ms(se,de,De,q),Ze=It(Ge,de,q);Ze&&$(de,{parentId:Ze.parentId,index:Ze.index},"move",Ge)},ae=de=>{const De=Jr(se,de,q),Ge=It(De,de,q);Ge&&De!==se&&$(de,{parentId:Ge.parentId,index:Ge.index},"indent",De)},ve=de=>{const De=Qr(se,de,q),Ge=It(De,de,q);Ge&&De!==se&&$(de,{parentId:Ge.parentId,index:Ge.index},"outdent",De)},Ce=de=>{const De=W(de);if(!De)return;const Ge=Ne.findIndex(Nt=>Nt.id===de),Ze=new Set,lt=si(se,de,q);lt&&sn([lt],Nt=>{Ze.add(ue(Nt))},q);const yt=Ne.slice(Ge+1).find(Nt=>!Ze.has(Nt.id)),ct=Ne.slice(0,Math.max(0,Ge)).reverse().find(Nt=>!Ze.has(Nt.id)),wt=yt?.id??ct?.id??null;Te(mi(se,de,q),{type:"remove",id:de,from:De})&&(le!==null&&Ze.has(le)&&xe(wt),te.current=wt,Se(U("sortableTree.announceRemoved","{label} removed").replace("{label}",lt?H(lt):de)))},[_e,ke]=r.useState(null),Ee=r.useRef(null);r.useEffect(()=>{_e!==null&&(Ee.current?.focus(),Ee.current?.select())},[_e]);const Re=(de,De)=>{ke(null),te.current=de;const Ge=si(se,de,q),Ze=De?.trim();!Ge||!Ze||Ze===H(Ge)||Te(ka(se,de,{[c]:Ze},q),{type:"rename",id:de,label:Ze})};r.useLayoutEffect(()=>{const de=te.current;if(de===null||_e!==null)return;te.current=null;const De=[...ne.current?.querySelectorAll("[data-node-id]")??[]].find(Ge=>Ge.dataset.nodeId===de);De&&(De.focus(),De.scrollIntoView?.({block:"nearest"}))});const qe=(de,De)=>{const Ge=ne.current;if(!Ge)return null;const Ze=[...Ge.querySelectorAll("[data-node-id]")];if(Ze.length===0)return{target:{parentId:null,index:0},line:null,insideId:null,invalid:!1};const lt=Ze[0],yt=Ze[Ze.length-1],ct=(wt,Nt,jt)=>({top:Nt==="top"?wt.offsetTop:wt.offsetTop+wt.offsetHeight,depth:jt});if(de<lt.getBoundingClientRect().top){const wt=K.get(lt.dataset.nodeId??"");return wt&&!De.has(wt.id)?{target:{parentId:null,index:0},line:ct(lt,"top",0),insideId:null,invalid:!1}:null}for(const wt of Ze){const Nt=wt.getBoundingClientRect();if(de<Nt.top||de>=Nt.bottom)continue;const jt=K.get(wt.dataset.nodeId??"");if(!jt||De.has(jt.id))return null;const Gt=(de-Nt.top)/Math.max(1,Nt.height),xn=Z(jt.node)?Gt<.25?"before":Gt>.75?"after":"inside":Gt<.5?"before":"after";return xn==="before"?{target:{parentId:jt.parentId,index:jt.index},line:ct(wt,"top",jt.depth),insideId:null,invalid:!1}:xn==="inside"?{target:{parentId:jt.id,index:F(jt.node).length},line:null,insideId:jt.id,invalid:!1}:jt.expanded?{target:{parentId:jt.id,index:0},line:ct(wt,"bottom",jt.depth+1),insideId:null,invalid:!1}:{target:{parentId:jt.parentId,index:jt.index+1},line:ct(wt,"bottom",jt.depth),insideId:null,invalid:!1}}return{target:{parentId:null,index:se.length},line:ct(yt,"bottom",0),insideId:null,invalid:!1}},Ye=r.useRef(null),[We,ot]=r.useState(null),[st,rt]=r.useState(null),mt=r.useRef(!1),Ke=de=>{clearTimeout(de.hoverTimer),de.hoverTimer=void 0,de.hoverId=null},he=(de,De)=>{const Ge=De?.insideId??null;if(Ge===de.hoverId)return;Ke(de);const Ze=Ge?K.get(Ge):void 0;Ze&&Ze.hasChildren&&!Ze.expanded&&(de.hoverId=Ge,de.hoverTimer=setTimeout(()=>ie(Ze.id,!0),vg))},Pe=de=>{const De=Q.current;if(!De||De.scrollHeight<=De.clientHeight)return;const Ge=De.getBoundingClientRect();de<Ge.top+dc?De.scrollTop-=10:de>Ge.bottom-dc&&(De.scrollTop+=10)},He=(de,De)=>{const Ge=!!de.target.closest(".nice-sortable-tree__grip");if(oe||de.button!==0||_e!==null||de.pointerType==="touch"&&!Ge||de.target.closest(".nice-sortable-tree__toggle, input, button")||C&&!C(De.node))return;const Ze=new Set;sn([De.node],lt=>{Ze.add(ue(lt))},q),Ye.current={id:De.id,pointerId:de.pointerId,startY:de.clientY,startX:de.clientX,startScroll:Q.current?.scrollTop??0,rowTop:de.currentTarget.getBoundingClientRect().top,started:!1,height:_a(De.node,q),block:Ze,view:null,hoverId:null,hoverTimer:void 0}},pt=de=>{const De=Ye.current;if(!De||de.pointerId!==De.pointerId)return;const Ge=(Q.current?.scrollTop??0)-De.startScroll,Ze=de.clientY+yg-De.rowTop+Ge;if(!De.started){if(Math.hypot(de.clientX-De.startX,de.clientY-De.startY)<fg)return;De.started=!0,de.currentTarget.setPointerCapture?.(de.pointerId),de.currentTarget.focus()}Pe(de.clientY);const lt=qe(de.clientY,De.block),yt=lt?{...lt,invalid:!Me(De.id,lt.target,De.height)}:null;De.view=yt,he(De,yt),ot({ids:De.block,dy:Ze}),rt(yt)},Xe=de=>{const De=Ye.current;if(Ye.current=null,!!De){if(Ke(De),De.started){if(de&&De.view&&!De.view.invalid){const Ge=Ui(se,De.id,De.view.target,q),Ze=It(Ge,De.id,q);Ze&&Ge!==se&&$(De.id,{parentId:Ze.parentId,index:Ze.index},"move",Ge)}mt.current=!0,window.setTimeout(()=>{mt.current=!1},0)}ot(null),rt(null)}},ut=Be.useTreeDragSession(),ge=r.useRef({view:null,hoverId:null,hoverTimer:void 0}),Le=r.useRef(()=>{});Le.current=de=>{const De=ge.current,Ge=Q.current?.getBoundingClientRect(),Ze=!!Ge&&de.x>=Ge.left&&de.x<=Ge.right&&de.y>=Ge.top&&de.y<=Ge.bottom;if(de.type==="move"){if(!Ze||oe||!j){De.view&&(De.view=null,Ke(De),rt(null));return}Pe(de.y);const yt=qe(de.y,new Set),ct=yt?{...yt,invalid:!Me(null,yt.target,1,de.payload)}:null;De.view=ct,he(De,ct),rt(ct);return}const lt=De.view;De.view=null,Ke(De),rt(null),de.commit&&Ze&&lt&&!lt.invalid&&j?.(de.payload,lt.target)},r.useEffect(()=>ut?.subscribe(de=>Le.current(de)),[ut]);const[et,pe]=r.useState(null),Ie=r.useRef(null);l.useOverlayFocus(Ie,{open:et!==null,modal:!1,onClose:()=>pe(null)}),l.useRovingFocus(Ie,{orientation:"vertical",wrap:!0,enabled:et!==null}),r.useLayoutEffect(()=>{const de=Ie.current;if(!et||!de||typeof window>"u")return;const De=de.getBoundingClientRect(),Ge=Math.max(8,Math.min(et.x,window.innerWidth-De.width-8)),Ze=Math.max(8,Math.min(et.y,window.innerHeight-De.height-8));(Ge!==et.x||Ze!==et.y)&&pe({...et,x:Ge,y:Ze})},[et]),r.useEffect(()=>{if(!et)return;const de=De=>{Ie.current?.contains(De.target)||pe(null)};return document.addEventListener("mousedown",de),()=>document.removeEventListener("mousedown",de)},[et]);const ze=_===!0?bg:_===!1?[]:_,Je=et?K.get(et.id):void 0,ht=[];if(Je){const de=Je.node,De=!oe&&(!C||C(de)),Ge=Je.index>0,Ze=(lt,yt,ct,wt,Nt)=>{ze.includes(lt)&&ht.push({id:lt,label:yt,icon:e.jsx(l.NiceIcon,{name:ct,size:14}),disabled:!wt,onClick:Nt})};Ze("moveUp",U("sortableTree.moveUp","Move up"),"chevron-up",De&&Ge,()=>X(Je.id,-1)),Ze("moveDown",U("sortableTree.moveDown","Move down"),"chevron-down",De&&Je.index<Je.setSize-1,()=>X(Je.id,1)),Ze("indent",U("sortableTree.indent","Indent"),"indent",De&&Ge,()=>ae(Je.id)),Ze("outdent",U("sortableTree.outdent","Outdent"),"outdent",De&&Je.parentId!==null,()=>ve(Je.id)),Ze("rename",U("sortableTree.rename","Rename"),"edit",A(S,de),()=>ke(Je.id)),Ze("remove",U("sortableTree.remove","Remove"),"trash",A(N,de),()=>Ce(Je.id)),ht.push(...k?.(de)??[])}const Bt=(de,De)=>{if(de.target!==de.currentTarget)return;if(de.key==="Escape"&&Ye.current?.started){de.preventDefault(),Xe(!1);return}if(!oe&&(!C||C(De.node))&&de.ctrlKey&&de.shiftKey&&!de.altKey){const Ze=typeof window<"u"&&Q.current!==null&&window.getComputedStyle(Q.current).direction==="rtl",lt=Ze&&de.key==="ArrowLeft"?"ArrowRight":Ze&&de.key==="ArrowRight"?"ArrowLeft":de.key,yt={ArrowUp:()=>X(De.id,-1),ArrowDown:()=>X(De.id,1),ArrowRight:()=>ae(De.id),ArrowLeft:()=>ve(De.id)};if(yt[lt]){de.preventDefault(),yt[lt]();return}}de.key==="F2"&&A(S,De.node)?(de.preventDefault(),ke(De.id)):de.key==="Delete"&&A(N,De.node)&&(de.preventDefault(),Ce(De.id))};if(re==="hidden")return null;const Dt=We?.ids;return e.jsxs("div",{ref:Q,id:L,title:V,"data-testid":z,className:["nice-sortable-tree",`nice-sortable-tree--${R}`,We?"nice-sortable-tree--dragging":"",st&&Ne.length===0&&!st.invalid?"nice-sortable-tree--drop-empty":"",Y?"nice-sortable-tree--disabled":"",M??""].filter(Boolean).join(" "),style:{...B!==void 0?{height:B,overflow:"auto"}:{},...O},"aria-disabled":Y||void 0,children:[Ne.length===0&&e.jsx("div",{className:"nice-sortable-tree__empty",children:T??U("sortableTree.empty","Nothing here yet")}),e.jsxs("ul",{ref:ne,role:"tree","aria-label":P,"aria-disabled":Y||void 0,className:"nice-sortable-tree__list",children:[Ne.map(de=>{const De=de.id===le,Ge=!!Dt?.has(de.id),Ze={depth:de.depth,hasChildren:de.hasChildren,expanded:de.expanded,selected:De,dragging:Ge},lt=_e===de.id,yt={"--nice-sortable-tree-depth":de.depth,...Ge&&We?{transform:`translate(${xg}px, ${We.dy}px)`}:{}};return e.jsxs("li",{role:"treeitem","data-node-id":de.id,"aria-level":de.depth+1,"aria-setsize":de.setSize,"aria-posinset":de.index+1,"aria-expanded":de.hasChildren?de.expanded:void 0,"aria-selected":De,"aria-label":H(de.node),tabIndex:-1,className:["nice-sortable-tree__row",De?"nice-sortable-tree__row--selected":"",Ge?"nice-sortable-tree__row--dragging":"",st?.insideId===de.id?st.invalid?"nice-sortable-tree__row--drop-invalid":"nice-sortable-tree__row--drop-inside":""].filter(Boolean).join(" "),style:yt,onClick:ct=>{if(mt.current){mt.current=!1;return}if(!Y){if(de.hasChildren&&ct.target.closest(".nice-sortable-tree__toggle")){ie(de.id,!de.expanded);return}xe(de.id)}},onDoubleClick:()=>{A(S,de.node)&&ke(de.id)},onKeyDown:ct=>Bt(ct,de),onPointerDown:ct=>He(ct,de),onPointerMove:pt,onPointerUp:()=>Xe(!0),onPointerCancel:()=>Xe(!1),onContextMenu:ct=>{if(Y||ze.length===0&&!k)return;ct.preventDefault(),ct.stopPropagation();const wt=ct.currentTarget.getBoundingClientRect(),Nt=ct.clientX===0&&ct.clientY===0;pe({id:de.id,x:Nt?wt.left+24:ct.clientX,y:Nt?wt.bottom:ct.clientY})},children:[!oe&&(!C||C(de.node))&&e.jsx("span",{className:"nice-sortable-tree__grip","aria-hidden":"true",children:e.jsx(l.NiceIcon,{name:"grip",size:14})}),de.hasChildren?e.jsx("span",{className:"nice-sortable-tree__toggle","aria-hidden":"true",children:e.jsx(l.NiceIcon,{name:de.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(de.node,Ze)}),lt?e.jsx("input",{ref:Ee,className:"nice-sortable-tree__input","aria-label":U("sortableTree.renameField","New name"),defaultValue:H(de.node),onClick:ct=>ct.stopPropagation(),onPointerDown:ct=>ct.stopPropagation(),onKeyDown:ct=>{ct.stopPropagation(),ct.key==="Enter"?(ct.preventDefault(),Re(de.id,ct.currentTarget.value)):ct.key==="Escape"&&(ct.preventDefault(),Re(de.id,null))},onBlur:ct=>{_e===de.id&&Re(de.id,ct.currentTarget.value)}}):e.jsx("span",{className:"nice-sortable-tree__label",children:p?p(de.node,Ze):H(de.node)}),h&&e.jsx("span",{className:"nice-sortable-tree__end",children:h(de.node,Ze)})]},de.id)}),st?.line&&e.jsx("li",{role:"none",className:`nice-sortable-tree__drop-line${st.invalid?" nice-sortable-tree__drop-line--invalid":""}`,style:{top:st.line.top,"--nice-sortable-tree-depth":st.line.depth}})]}),e.jsx("div",{className:"nice-sr-only","aria-live":"polite",role:"status",children:G}),et&&ht.length>0&&e.jsx("ul",{ref:Ie,role:"menu","aria-label":U("sortableTree.menu","Node actions"),className:"nice-contextmenu nice-contextmenu__list nice-sortable-tree__menu",style:{position:"fixed",left:et.x,top:et.y},children:ht.map((de,De)=>e.jsx("li",{role:"none",className:"nice-contextmenu__item",children:e.jsxs("button",{type:"button",role:"menuitem",className:`nice-contextmenu__btn${de.danger?" nice-contextmenu__btn--danger":""}`,disabled:de.disabled,onClick:Ge=>{pe(null),de.onClick?.(Ge)},children:[de.icon&&e.jsx("span",{className:"nice-contextmenu__icon","aria-hidden":"true",children:de.icon}),e.jsx("span",{children:de.label??de.text})]})},de.id??de.key??De))})]})}const gd=Object.assign(Ng,{displayName:"NiceSortableTree"}),uc=new WeakMap;function Dn(t){const n=uc.get(t);if(n)return n;const i=new Map;return sn(t,(a,s)=>{i.set(a.id,{node:a,ancestors:[...s.ancestors],order:i.size})}),uc.set(t,i),i}function bd(t,n){return Dn(t).get(n)?.node}function _g(t,n){const i=Dn(t),a=new Set;for(const s of n){const o=i.get(s);o&&sn([o.node],c=>{c.route&&!c.disabled&&a.add(c.id)})}return[...a].sort((s,o)=>(i.get(s)?.order??0)-(i.get(o)?.order??0))}function Ri(t,n){let i;return sn(t,a=>{if(i)return!1;n(a)&&(i=a)}),i}function Xr(t){const n=new Set;return sn(t,i=>{n.add(i.id)}),n}function $i(t,n){let i=n;for(let a=2;t.has(i);a++)i=`${n}-${a}`;return t.add(i),i}function Zr(t){const n=[];return sn(t,i=>{i.ref&&n.push(i.ref)}),n}function fd(t,n){const i=Dn(n),a=[];return sn(t,s=>{s.ref&&!i.get(s.ref)?.node.route&&a.push(s.id)}),a}function eo(t,n){if(t.label)return t.label;const i=Dn(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 hs(t,n){const i=Dn(n);return(t.ref?i.get(t.ref):void 0)?.node??(t.from?i.get(t.from):void 0)?.node}function vd(t,n){return Dn(t).get(n)?.ancestors.map(i=>i.label)??[]}function pc(t,n,i){let a=null,s=t;for(const o of n){const c=Ri(s,m=>m.from===o.id);if(c){a=c.id;continue}const d={id:$i(i,`g:${o.id}`),from:o.id,children:[]},p=a===null?s:It(s,a)?.node.children??[];s=Hn(s,d,{parentId:a,index:p.length}),a=d.id}return{menu:s,parentId:a}}function xd(t,n,i,a={}){const s=Dn(n),o=Math.max(0,a.skipLevels??0),c=new Set(Zr(t)),d=Xr(t);let p=t;const m=[...new Set(i)].filter(h=>s.get(h)?.node.route&&!s.get(h)?.node.disabled).sort((h,u)=>(s.get(h)?.order??0)-(s.get(u)?.order??0));for(const h of m){const u=s.get(h);if(!u||c.has(h))continue;c.add(h);const x=u.ancestors.slice(o);if(u.node.children?.length){const g=pc(p,[...x,u.node],d);p=g.menu,g.parentId!==null&&(p=ka(p,g.parentId,{ref:h}));continue}const f=pc(p,x,d);p=f.menu;const b=f.parentId===null?p:It(p,f.parentId)?.node.children??[];p=Hn(p,{id:$i(d,`p:${h}`),ref:h},{parentId:f.parentId,index:b.length})}return p}function yd(t){let n=t;for(;;){const i=Ri(n,a=>!!a.from&&!a.ref&&!a.children?.length);if(!i)return n;n=mi(n,i.id)}}function Nd(t,n){const i=new Set(n);let a=t;for(const s of i){const o=Ri(a,c=>c.ref===s);o&&(o.children?.length?a=ka(a,o.id,c=>{const{ref:d,...p}=c;return{...p,from:p.from??s}}):a=mi(a,o.id))}return a===t?a:yd(a)}function _d(t,n,i,a,s={}){const o=Dn(n),c=Xr(t);let d=t,p=a.index;const m=h=>{const u=(h.children??[]).map(m).filter(b=>b!==null),x=!!h.route&&!h.disabled,f=x?Ri(d,b=>b.ref===h.id):void 0;return f&&(d=mi(d,f.id),c.delete(f.id)),h.children?.length?!u.length&&!x?null:{id:$i(c,`g:${h.id}`),from:h.id,...x?{ref:h.id}:{},children:u}:x?{id:$i(c,`p:${h.id}`),ref:h.id}:null};for(const h of i){const u=o.get(h);if(!u)continue;const x=!!u.node.route&&!u.node.disabled,f=!u.node.children?.length||s.asPage,b=x?Ri(d,v=>v.ref===h):void 0;if(f){if(b)d=Ui(d,b.id,{parentId:a.parentId,index:p});else if(x)d=Hn(d,{id:$i(c,`p:${h}`),ref:h},{parentId:a.parentId,index:p});else continue;const v=Ri(d,y=>y.ref===h);p=(v?It(d,v.id)?.index??p:p)+1;continue}const g=m(u.node);g&&(a.parentId!==null&&!It(d,a.parentId)?d=Hn(d,g,{parentId:null,index:d.length}):(d=Hn(d,g,{parentId:a.parentId,index:p}),p+=1))}return yd(d)}function jd(t,n,i){const a=Xr(t),s=$i(a,"group");return{menu:Hn(t,{id:s,label:n,children:[]},i??{parentId:null,index:t.length}),id:s}}function jg(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 wd(t,n,i={}){const a=Dn(n),s=o=>o.flatMap(c=>{const p=(c.ref?a.get(c.ref)?.node:void 0)?.route,m=s(c.children??[]);return!p&&m.length===0?[]:[{id:c.id,label:eo(c,n),icon:jg(c,hs(c,n),i.renderIcon),...p?{route:p}:{},...m.length?{children:m}:{}}]});return s(t)}function kd(t,n,i={}){const a=wd(t,n,i),s=[];let o=[];const c=()=>{o.length&&(s.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}c();const p=d.route?[{id:`${d.id}:page`,label:d.label,icon:d.icon,route:d.route}]:[];s.push({id:d.id,label:d.label,icon:d.icon,views:[...p,...d.children]})}return c(),[{source:i.source??{id:"menu",label:i.otherLabel??"Menu"},modules:s,roles:[],units:[]}]}function wg(t,n={}){const i=n.key??"id",a=(d,p)=>typeof i=="function"?i(d,p):i==="route"?d.route??d.id:d.id,s=(d,p)=>d.map(m=>({id:a(m,p),label:m.label,icon:m.icon,...m.route?{route:m.route}:{},...m.children?.length?{children:s(m.children,p)}:{}})),o=d=>d.modules.map(p=>({id:p.id,label:p.label,icon:p.icon,children:s(p.views,p)}));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 kg=[],Cg=[],Sg={},Tg=60,Eg=t=>e.jsx(l.NiceIcon,{name:t,size:16});function Cd(t){return t.map(n=>{const i=n.children?.length?Cd(n.children):void 0,a=!!i?.some(s=>s.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 Sd(t,n){return n<=0?[]:t.flatMap(i=>i.children?.length?[i.key,...Sd(i.children,n-1)]:[])}const Ig=({drag:t,label:n,title:i})=>{const a=Be.useTreeDragSession();return e.jsx("span",{className:"nice-menu-builder__grip",title:i,"aria-hidden":"true",onPointerDown:s=>{a&&(s.stopPropagation(),Be.startTreeDrag(a,s,t,n))},children:e.jsx(l.NiceIcon,{name:"grip",size:14})})},Dg=({value:t,onChange:n,renderIcon:i})=>{const{t:a}=l.useNiceTranslation(),[s,o]=r.useState(""),c=r.useRef(null);l.useRovingFocus(c,{orientation:"grid",itemSelector:"button"});const d=r.useMemo(()=>{const p=s.trim().toLowerCase(),m=p?l.NICE_BUILTIN_ICONS.filter(u=>u.includes(p)):l.NICE_BUILTIN_ICONS,h=m.slice(0,Tg);return t&&m.includes(t)&&!h.includes(t)?[t,...h]:h},[s,t]);return e.jsxs("div",{className:"nice-menu-builder__icon-picker",children:[e.jsx(Oe.NiceTextInput,{type:"search",size:"sm",label:a("menuBuilder.iconSearch","Search icons"),value:s,onChange:o}),e.jsxs("div",{ref:c,role:"group","aria-label":a("menuBuilder.icons","Icons"),className:"nice-menu-builder__icon-grid",children:[d.map(p=>e.jsx("button",{type:"button",title:p,"aria-label":p,"aria-pressed":p===t,className:`nice-menu-builder__icon-option${p===t?" nice-menu-builder__icon-option--on":""}`,onClick:()=>n(p),children:i(p)},p)),d.length===0&&e.jsx("span",{className:"nice-menu-builder__hint",children:a("menuBuilder.noIcons","No icons found")})]})]})},Pg=({catalog:t=kg,value:n,defaultValue:i,onChange:a,skipLevels:s=0,maxDepth:o,renderIcon:c=Eg,renderIconPicker:d,showPreview:p=!0,previewProps:m,toolbar:h,height:u,size:x="md",readOnly:f=!1,disabled:b=!1,className:g,style:v,id:y,title:C,accessMode:w,"data-testid":E})=>{const{t:S}=l.useNiceTranslation(),N=l.useNiceAccessMode(w,y),_=b||N==="disabled",k=f||N==="readOnly"||_,[j,T]=l.useControllableState({value:n,defaultValue:i,fallbackValue:Cg,componentName:"NiceMenuBuilder"}),P=ne=>{ne===j||k||(T(ne),a?.(ne))},[B,R]=r.useState(null),I=r.useRef(null),[D,M]=r.useState(0);r.useEffect(()=>{D>0&&I.current?.querySelector("input")?.focus()},[D]);const O=r.useMemo(()=>Cd(t),[t]),L=r.useMemo(()=>Zr(j),[j]),V=r.useMemo(()=>new Set(fd(j,t)),[j,t]),ee=r.useMemo(()=>Sd(O,2),[O]),z=ne=>{const G=new Set(ne),Se=new Set(L),te=ne.filter(xe=>!Se.has(xe)),we=L.filter(xe=>!G.has(xe));let ie=j;te.length&&(ie=xd(ie,t,te,{skipLevels:s})),we.length&&(ie=Nd(ie,we)),P(ie)},U=r.useMemo(()=>[{field:"label",header:S("menuBuilder.catalogColumn","View"),render:(ne,G)=>e.jsxs("span",{className:"nice-menu-builder__catalog-cell",children:[!k&&!G.disabled&&e.jsx(Ig,{drag:{ids:[G.nodeId],asPage:!!G.own},label:G.label,title:S("menuBuilder.dragHint","Drag into the menu")}),G.icon!==void 0&&e.jsx("span",{className:"nice-menu-builder__icon","aria-hidden":"true",children:typeof G.icon=="string"?c(G.icon):G.icon}),e.jsx("span",{className:"nice-menu-builder__label",children:G.label}),G.own&&e.jsx("span",{className:"nice-menu-builder__hint",children:S("menuBuilder.ownPage","(page)")})]})}],[S,k,c]),re=B?It(j,B)?.node:void 0,Y=ne=>!ne.ref||ne.children!==void 0,oe=ne=>It(j,ne)?.depth??0,q=(ne,G)=>{const Se=ne;!Se||!Array.isArray(Se.ids)||P(_d(j,t,Se.ids,G,{asPage:Se.asPage}))},se=()=>{let ne;if(re){const Se=It(j,re.id);Y(re)&&(o===void 0||(Se?.depth??0)+2<=o)?ne={parentId:re.id,index:re.children?.length??0}:Se&&(ne={parentId:Se.parentId,index:Se.index+1})}const G=jd(j,S("menuBuilder.newGroup","New group"),ne);P(G.menu),R(G.id),M(Se=>Se+1)},ce=ne=>{const G=It(j,ne.id);if(!G||G.index===0)return!1;const Se=G.siblings[G.index-1];return Y(Se)&&(o===void 0||G.depth+1+_a(ne)<=o)},le=re?It(j,re.id):void 0,J=ne=>{re&&P(ne(j,re.id))},me=()=>{if(!re||!le)return;const ne=le.siblings[le.index+1]??le.siblings[le.index-1];P(mi(j,re.id)),R(ne?.id??le.parentId)},je=ne=>{if(ne.icon)return c(ne.icon);const G=hs(ne,t);return typeof G?.icon=="string"?c(G.icon):G?.icon!==void 0?G.icon:e.jsx(l.NiceIcon,{name:ne.ref?"file":"folder",size:16})},ue=ne=>{re&&P(ka(j,re.id,G=>{const Se={...G,...ne};return Object.keys(ne).forEach(te=>{ne[te]===void 0&&delete Se[te]}),Se}))},F=re?hs(re,t):void 0,H=re?.ref?bd(t,re.ref):void 0,A=F?.label,Z=F?[...vd(t,F.id),F.label].join(" / "):"",fe=re?(d??(ne=>e.jsx(Dg,{...ne,renderIcon:c})))({value:re.icon,onChange:ne=>ue({icon:ne})}):null,Ne=r.useMemo(()=>p?kd(j,t,{renderIcon:c,otherLabel:S("menuBuilder.other","Other"),source:{id:"menu-preview",label:S("menuBuilder.preview","Preview")}}):[],[p,j,t,c,S]);if(N==="hidden")return null;const K=(ne,G,Se,te,we)=>e.jsx(Fe.NiceButton,{variant:"ghost",size:"sm",ariaLabel:G,title:G,disabled:!te,onClick:we,children:e.jsx(l.NiceIcon,{name:Se,size:16})},ne),Q=!k;return e.jsx(Be.TreeDragSessionProvider,{children:e.jsx("div",{id:y,title:C,"data-testid":E,className:["nice-menu-builder",_?"nice-menu-builder--disabled":"",g??""].filter(Boolean).join(" "),style:{...u!==void 0?{height:u}:{},...v},"aria-disabled":_||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(ft.NiceTreeGrid,{data:O,nested:!0,keyField:"key",columns:U,checkable:!0,checkStrategy:"leaves",checkedKeys:L,onCheckedChange:z,isRowCheckable:ne=>ne.placeable,isRowDisabled:ne=>!!ne.disabled,getRowLabel:ne=>ne.label,defaultExpandedKeys:ee,searchable:!0,searchPlaceholder:S("menuBuilder.searchViews","Search views"),searchFields:["label"],toolbarActions:["onlyChecked"],showSelectAll:!1,size:x,compact:!0,readOnly:k,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")}),Q&&e.jsxs("span",{className:"nice-menu-builder__tools",role:"group","aria-label":S("menuBuilder.tools","Menu tools"),children:[K("group",S("menuBuilder.addGroup","New group"),"folder",!0,se),K("up",S("sortableTree.moveUp","Move up"),"chevron-up",!!le&&le.index>0,()=>J((ne,G)=>ms(ne,G,-1))),K("down",S("sortableTree.moveDown","Move down"),"chevron-down",!!le&&le.index<le.siblings.length-1,()=>J((ne,G)=>ms(ne,G,1))),K("indent",S("sortableTree.indent","Indent"),"indent",!!re&&ce(re),()=>J(Jr)),K("outdent",S("sortableTree.outdent","Outdent"),"outdent",!!le&&le.parentId!==null,()=>J(Qr)),K("remove",S("sortableTree.remove","Remove"),"trash",!!re,me)]}),h]}),e.jsx("div",{className:"nice-menu-builder__body",children:e.jsx(gd,{"aria-label":S("menuBuilder.menu","Menu"),value:j,onChange:ne=>P(ne),selectedId:B,onSelect:ne=>R(ne),getLabel:ne=>eo(ne,t),getIcon:ne=>je(ne),renderRowEnd:ne=>V.has(ne.id)?e.jsx("span",{className:"nice-menu-builder__badge",children:S("menuBuilder.unavailable","unavailable")}):null,canHaveChildren:Y,canDrop:(ne,G)=>G.parentId===null||o===void 0||ne!==null||oe(G.parentId)+2<=o,maxDepth:o,editable:Q,removable:Q,onExternalDrop:q,emptyText:S("menuBuilder.menuEmpty","Check views on the left or drag them here"),size:x,readOnly:k})})]}),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")}),re&&e.jsx("span",{className:"nice-menu-builder__kind",children:re.ref?S("menuBuilder.page","Page"):S("menuBuilder.group","Group")})]}),e.jsxs("div",{className:"nice-menu-builder__body nice-menu-builder__props",children:[!re&&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.")}),re&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-menu-builder__field",ref:I,children:[e.jsx(Oe.NiceTextInput,{label:S("menuBuilder.name","Name"),size:"sm",value:re.label??"",placeholder:A??S("menuBuilder.newGroup","New group"),onChange:ne=>ue({label:ne.trim()?ne:void 0}),readOnly:k}),Q&&re.label&&A&&e.jsx(Fe.NiceButton,{variant:"ghost",size:"sm",ariaLabel:S("menuBuilder.resetName","Name from the catalog"),title:S("menuBuilder.resetName","Name from the catalog"),onClick:()=>ue({label:void 0}),children:e.jsx(l.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:je(re)}),Q&&re.icon&&e.jsx(Fe.NiceButton,{variant:"ghost",size:"sm",ariaLabel:S("menuBuilder.resetIcon","Icon from the catalog"),title:S("menuBuilder.resetIcon","Icon from the catalog"),onClick:()=>ue({icon:void 0}),children:e.jsx(l.NiceIcon,{name:"undo",size:16})})]}),Q&&fe,(H?.route||Z)&&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})})]}),Z&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:S("menuBuilder.source","In the catalog")}),e.jsx("dd",{children:Z})]})]}),V.has(re.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.")})]})]})]}),p&&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:Ne,minimal:!0,readonly:!0,contextMenu:!1,preferences:Sg,...m})})]})]})]})})})},Td=r.createContext(null),Ag=({children:t,type:n="single",value:i,defaultValue:a,disabled:s=!1,onChange:o,className:c="",style:d,testId:p,"data-testid":m})=>{const[h,u]=r.useState(a??(n==="single"?"":[])),x=i!==void 0,f=x?i:h,b=r.useCallback(y=>n==="single"?f===y:Array.isArray(f)&&f.includes(y),[n,f]),g=r.useCallback(y=>{let C;if(n==="single")C=f===y?"":y;else{const w=Array.isArray(f)?f:[];C=w.includes(y)?w.filter(E=>E!==y):[...w,y]}x||u(C),o?.(C)},[n,f,x,o]),v=r.useMemo(()=>({type:n,isPressed:b,toggle:g,disabled:s}),[n,b,g,s]);return e.jsx(Td.Provider,{value:v,children:e.jsx("div",{role:"group",className:`nice-toggle-group nice-toggle-group--${n} ${c}`,style:d,"data-testid":m??p,children:t})})},Rg=Object.assign(({value:t,children:n,disabled:i=!1})=>{const a=r.useContext(Td);if(!a)throw new Error("NiceToggleGroup.Item must be rendered inside <NiceToggleGroup>");const s=a.isPressed(t),o=a.disabled||i;return e.jsx("button",{type:"button",className:`nice-toggle-group__item ${s?"nice-toggle-group__item--pressed":""}`,"aria-pressed":s,disabled:o,onClick:()=>a.toggle(t),children:n})},{displayName:"NiceToggleGroup.Item"}),yr=Object.assign(Ag,{displayName:"NiceToggleGroup",Item:Rg}),$g=["daily","weekly","monthly","yearly"],Mg={daily:"Daily",weekly:"Weekly",monthly:"Monthly",yearly:"Yearly"},Og={daily:"Repeat every (days)",weekly:"Repeat every (weeks)",monthly:"Repeat every (months)",yearly:"Repeat every (years)"},Lg={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"}},mc=10,Ed=864e5,zg=new Date(2023,0,1);function hc(t,n){try{return new Intl.PluralRules(t).select(n)}catch{return n===1?"one":"other"}}function Nr(t,n,i){const a=new Date(zg.getTime()+n*Ed);try{return new Intl.DateTimeFormat(t,{weekday:i}).format(a)}catch{return new Intl.DateTimeFormat("en",{weekday:i}).format(a)}}function Id(t,n){try{return new Intl.DateTimeFormat(t,n)}catch{return new Intl.DateTimeFormat("en",n)}}function gc(t){const n=i=>String(i).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Bg(t,n,i,a){const s=Math.max(1,Math.floor(t.interval??1)),o=Lg[t.freq],c=[s===1?n(`recurrence.summary.${t.freq}.single`,o.single):n(`recurrence.summary.${t.freq}.${hc(i,s)}`,o.other).replace("{n}",String(s))];if(t.freq==="weekly"&&t.byDay?.length&&c.push(a.filter(d=>t.byDay?.includes(d)).map(d=>Nr(i,d,"short")).join(", ")),t.count&&t.count>0)c.push(n(`recurrence.summary.times.${hc(i,t.count)}`,t.count===1?"once":"{n} times").replace("{n}",String(t.count)));else if(t.until){const d=Id(i,{day:"numeric",month:"short",year:"numeric"});c.push(`${n("recurrence.summary.until","until")} ${d.format(new Date(t.until))}`)}return c.join(" · ")}const Fg=({value:t,defaultValue:n=null,onChange:i,start:a,allowNone:s=!0,previewCount:o=5,weekStartsOn:c=1,label:d,size:p="md",disabled:m=!1,readOnly:h=!1,className:u="",style:x,id:f,accessMode:b,"data-testid":g})=>{const{t:v,lang:y}=l.useNiceTranslation(),C=l.useNiceAccessMode(b,f),[w,E]=l.useControllableState({value:t,defaultValue:n,onChange:i,componentName:"NiceRecurrenceEditor"}),[S]=r.useState(()=>new Date),N=a??S,_=m||h||C==="disabled"||C==="readOnly",k=l.normalizeSize(p),j=k==="xxs"||k==="xs"?k:"sm",T=r.useMemo(()=>Array.from({length:7},(L,V)=>(V+c)%7),[c]),P=r.useMemo(()=>{if(!w||o<=0)return[];const L=new Date(N.getTime()+100*365*Ed);return At.recurrenceDates(w,N,L,o)},[w,N,o]);if(C==="hidden")return null;const B=L=>{w&&E({...w,...L})},R=L=>{if(L==="none"){E(null);return}const V=L,ee=w?{...w,freq:V}:{freq:V,interval:1};V==="weekly"?ee.byDay=w?.byDay?.length?w.byDay:[N.getDay()]:delete ee.byDay,E(ee)},I=w?.count?"after":w?.until?"on":"never",D=L=>{if(!w)return;const V={...w};if(delete V.count,delete V.until,L==="after")E({...V,count:mc});else if(L==="on"){const ee=new Date(N);ee.setMonth(ee.getMonth()+3),E({...V,until:ee})}else E(V)},M=[...s?[{value:"none",label:v("recurrence.freq.none","Does not repeat")}]:[],...$g.map(L=>({value:L,label:v(`recurrence.freq.${L}`,Mg[L])}))],O=Id(y,{weekday:"short",day:"numeric",month:"short",year:"numeric"});return e.jsxs("div",{id:f,className:`nice-recurrence nice-recurrence--${k} ${u}`,style:x,"data-testid":g,children:[e.jsx(Oe.NiceSelect,{size:j,label:d??v("recurrence.frequency","Repeats"),value:w?w.freq:"none",options:M,onChange:L=>R(Array.isArray(L)?L[0]??"none":L),disabled:_}),w&&e.jsxs(e.Fragment,{children:[e.jsx(Oe.NiceNumberInput,{size:j,className:"nice-recurrence__interval",label:v(`recurrence.interval.${w.freq}`,Og[w.freq]),min:1,max:999,value:w.interval??1,onChange:L=>B({interval:Math.max(1,Math.round(L??1))}),disabled:_}),w.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(yr,{type:"multiple",disabled:_,value:(w.byDay??[]).map(String),onChange:L=>{const V=(Array.isArray(L)?L:[L]).map(Number);V.length>0&&B({byDay:V.sort((ee,z)=>ee-z)})},children:T.map(L=>e.jsx(yr.Item,{value:String(L),children:e.jsx("span",{title:Nr(y,L,"long"),children:Nr(y,L,"short")})},L))})]}),e.jsxs("div",{className:"nice-recurrence__ends",children:[e.jsx(dt.NiceRadioGroup,{size:j,label:v("recurrence.endsLabel","Ends"),direction:"vertical",value:I,onChange:D,disabled:_,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")}]}),I==="on"&&w.until&&e.jsx(dt.NiceDateTimePicker,{size:j,label:v("recurrence.endDate","End date"),dateFormatPreset:"date-local",value:gc(new Date(w.until)),min:gc(N),onChange:L=>{const[V,ee,z]=L.split("-").map(Number);V&&ee&&z&&B({until:new Date(V,ee-1,z,23,59,59)})},disabled:_}),I==="after"&&e.jsx(Oe.NiceNumberInput,{size:j,className:"nice-recurrence__count",label:v("recurrence.count","Occurrences"),min:1,max:9999,value:w.count??mc,onChange:L=>B({count:Math.max(1,Math.round(L??1))}),disabled:_})]}),e.jsx("p",{className:"nice-recurrence__summary","aria-live":"polite",children:Bg(w,v,y,T)}),P.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:P.map(L=>e.jsx("li",{children:e.jsx("time",{dateTime:L.toISOString(),children:O.format(L)})},L.getTime()))})]})]})]})};function qg(t,n=1){let i;if(typeof t.quantity=="number"){const s=t.quantity*n;i=Number.isInteger(s)?String(s):String(Math.round(s*100)/100)}else i=t.quantity!=null?String(t.quantity):"";const a=t.unit??"";return[i,a].filter(Boolean).join(" ").trim()}const Vg=({photos:t})=>{const{t:n}=l.useNiceTranslation(),i=[...t].sort((c,d)=>+!!d.primary-+!!c.primary),[a,s]=r.useState(i[0]?.id),o=i.find(c=>c.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(c=>e.jsx("button",{type:"button",className:`nice-recipe__thumb${c.id===o?.id?" nice-recipe__thumb--active":""}`,onClick:()=>s(c.id),"aria-label":c.caption??n("recipe.photo","Photo"),children:e.jsx("img",{src:c.url,alt:c.caption??""})},c.id))})]})},Ug=({recipe:t,compact:n=!1,hidePhotos:i=!1,hideIngredients:a=!1,hideSteps:s=!1,onIngredientToggle:o,onStepToggle:c,className:d,style:p,accessMode:m,id:h,"data-testid":u})=>{const{t:x}=l.useNiceTranslation(),f=l.useNiceAccessMode(m,h),b=t.servings,[g,v]=r.useState(b);if(r.useEffect(()=>{v(b)},[b]),f==="hidden")return null;const y=f==="readOnly"||f==="disabled",C=At.recipeTotalMinutes(t),w=t.photos??[],E=[...t.steps].sort((k,j)=>k.order-j.order),S=!y&&typeof b=="number"&&b>0&&typeof g=="number"&&g>0?g/b:1,N=!n&&typeof b=="number"&&b>0&&!y,_=()=>{typeof window<"u"&&window.print()};return e.jsxs("div",{className:`nice-recipe${n?" nice-recipe--compact":""} ${d??""}`,style:p,"data-testid":u,children:[e.jsxs("header",{className:"nice-recipe__header",children:[e.jsx("h3",{className:"nice-recipe__title",children:t.title||x("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(l.NiceIcon,{name:"box",size:14})," ",g??t.servings," ",x("recipe.servings","servings")]}),C!=null&&e.jsxs("span",{className:"nice-recipe__meta-item",children:[e.jsx(l.NiceIcon,{name:"clock",size:14})," ",C," ",x("recipe.minutes","min")]}),t.difficulty&&e.jsx("span",{className:`nice-recipe__badge nice-recipe__badge--${t.difficulty}`,children:x(`recipe.difficulty.${t.difficulty}`,t.difficulty)}),t.cuisine&&e.jsxs("span",{className:"nice-recipe__meta-item",children:[e.jsx(l.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(l.NiceIcon,{name:"link",size:14})," ",x("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":x("recipe.servingsDecrease","Decrease servings"),onClick:()=>v(k=>Math.max(1,(k??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":x("recipe.servingsIncrease","Increase servings"),onClick:()=>v(k=>Math.min(99,(k??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:x("recipe.reset","Reset")})]}),!n&&e.jsxs("button",{type:"button",className:"nice-recipe__print",onClick:_,"aria-label":x("recipe.print","Print recipe"),children:[e.jsx(l.NiceIcon,{name:"printer",size:14})," ",x("recipe.print","Print")]})]}),t.tags&&t.tags.length>0&&e.jsx("div",{className:"nice-recipe__tags",children:t.tags.map(k=>e.jsxs("span",{className:"nice-recipe__tag",children:["#",k]},k))})]}),!i&&w.length>0&&e.jsx(Vg,{photos:w}),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:x("recipe.ingredients","Ingredients")}),e.jsx("ul",{className:"nice-recipe__ingredients",children:t.ingredients.map(k=>e.jsx("li",{className:"nice-recipe__ingredient",children:e.jsxs("label",{className:`nice-recipe__ingredient-row${k.checked?" nice-recipe__ingredient-row--checked":""}`,children:[e.jsx("input",{type:"checkbox",checked:!!k.checked,disabled:y||!o,onChange:()=>o?.(k)}),e.jsx("span",{className:"nice-recipe__ingredient-qty",children:qg(k,S)}),e.jsx("span",{className:"nice-recipe__ingredient-name",children:k.name}),k.notes&&e.jsxs("span",{className:"nice-recipe__ingredient-notes",children:["— ",k.notes]})]})},k.id))})]}),!s&&E.length>0&&e.jsxs("section",{className:"nice-recipe__section nice-recipe__section--steps",children:[e.jsx("h4",{className:"nice-recipe__section-title",children:x("recipe.steps","Steps")}),e.jsx("ol",{className:"nice-recipe__steps",children:E.map(k=>e.jsx("li",{className:`nice-recipe__step${k.done?" nice-recipe__step--done":""}`,children:e.jsxs("label",{className:"nice-recipe__step-row",children:[e.jsx("input",{type:"checkbox",checked:!!k.done,disabled:y||!c,onChange:()=>c?.(k)}),e.jsxs("div",{className:"nice-recipe__step-body",children:[e.jsx("div",{className:"nice-recipe__step-instruction",children:k.instruction}),k.durationMinutes!=null&&e.jsxs("div",{className:"nice-recipe__step-duration",children:[e.jsx(l.NiceIcon,{name:"clock",size:14})," ",k.durationMinutes," ",x("recipe.minutes","min")]}),k.image&&e.jsx("img",{className:"nice-recipe__step-image",src:k.image,alt:""})]})]})},k.id))})]})]}),!n&&t.nutrition&&e.jsxs("footer",{className:"nice-recipe__nutrition",children:[t.nutrition.calories!=null&&e.jsx("span",{children:x("recipe.kcal","{label}: {value} kcal").replace("{label}",x("recipe.nutrition.calories","Calories")).replace("{value}",String(t.nutrition.calories))}),t.nutrition.protein!=null&&e.jsxs("span",{children:[x("recipe.nutrition.protein","Protein"),": ",t.nutrition.protein," g"]}),t.nutrition.fat!=null&&e.jsxs("span",{children:[x("recipe.nutrition.fat","Fat"),": ",t.nutrition.fat," g"]}),t.nutrition.carbs!=null&&e.jsxs("span",{children:[x("recipe.nutrition.carbs","Carbs"),": ",t.nutrition.carbs," g"]}),t.nutrition.fiber!=null&&e.jsxs("span",{children:[x("recipe.nutrition.fiber","Fiber"),": ",t.nutrition.fiber," g"]}),t.nutrition.sugar!=null&&e.jsxs("span",{children:[x("recipe.nutrition.sugar","Sugar"),": ",t.nutrition.sugar," g"]}),t.nutrition.sodium!=null&&e.jsx("span",{children:x("recipe.mg","{label}: {value} mg").replace("{label}",x("recipe.nutrition.sodium","Sodium")).replace("{value}",String(t.nutrition.sodium))})]})]})},Hg=[],Gg=[{value:"",label:"All"},{value:"easy",label:"Easy"},{value:"medium",label:"Medium"},{value:"hard",label:"Hard"}],Dd=({recipes:t=Hg,onSelect:n,initialQuery:i="",hideFilters:a,emptyMessage:s,className:o,style:c,"data-testid":d})=>{const{t:p}=l.useNiceTranslation(),[m,h]=r.useState(i),[u,x]=r.useState(""),[f,b]=r.useState(""),g=r.useMemo(()=>{const y=new Set;for(const C of t)for(const w of C.tags??[])y.add(w);return Array.from(y).sort()},[t]),v=r.useMemo(()=>{const y=m.trim().toLowerCase();return t.filter(C=>u&&C.difficulty!==u||f&&!(C.tags??[]).includes(f)?!1:y?[C.title,C.description??"",C.cuisine??"",...C.tags??[]].join(" ").toLowerCase().includes(y):!0)},[t,m,u,f]);return e.jsxs("div",{className:`nice-recipe-list ${o??""}`,style:c,"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:p("recipe.list.search","Search recipes…"),onChange:y=>h(y.target.value),"aria-label":p("recipe.list.search","Search recipes")}),!a&&e.jsxs(e.Fragment,{children:[e.jsx("select",{className:"nice-recipe-list__filter",value:u,onChange:y=>x(y.target.value),"aria-label":p("recipe.difficulty","Difficulty"),children:Gg.map(y=>e.jsx("option",{value:y.value,children:y.label},y.value||"all"))}),g.length>0&&e.jsxs("select",{className:"nice-recipe-list__filter",value:f,onChange:y=>b(y.target.value),"aria-label":p("recipe.tags","Tags"),children:[e.jsx("option",{value:"",children:p("recipe.list.allTags","All tags")}),g.map(y=>e.jsxs("option",{value:y,children:["#",y]},y))]})]}),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:s??p("recipe.list.empty","No recipes match the current filters.")}):e.jsx("ul",{className:"nice-recipe-list__grid",children:v.map(y=>{const C=y.photos?.find(E=>E.primary)??y.photos?.[0],w=At.recipeTotalMinutes(y);return e.jsx("li",{className:"nice-recipe-list__item",children:e.jsxs("button",{type:"button",className:"nice-recipe-list__card",onClick:()=>n?.(y),children:[C&&e.jsx("span",{className:"nice-recipe-list__thumb",children:e.jsx("img",{src:C.url,alt:C.caption??y.title,loading:"lazy"})}),e.jsxs("span",{className:"nice-recipe-list__body",children:[e.jsx("span",{className:"nice-recipe-list__title",children:y.title}),y.description&&e.jsx("span",{className:"nice-recipe-list__desc",children:y.description}),e.jsxs("span",{className:"nice-recipe-list__meta",children:[typeof y.servings=="number"&&e.jsxs("span",{className:"nice-recipe-list__meta-item",children:[e.jsx(l.NiceIcon,{name:"utensils",size:12})," ",y.servings]}),w!=null&&w>0&&e.jsxs("span",{className:"nice-recipe-list__meta-item",children:[e.jsx(l.NiceIcon,{name:"clock",size:12})," ",p("recipe.min","{total} min").replace("{total}",String(w))]}),y.difficulty&&e.jsx("span",{className:`nice-recipe__badge nice-recipe__badge--${y.difficulty}`,children:y.difficulty})]}),y.tags&&y.tags.length>0&&e.jsx("span",{className:"nice-recipe-list__tags",children:y.tags.slice(0,4).map(E=>e.jsxs("span",{className:"nice-recipe__tag",children:["#",E]},E))})]})]})},y.id)})})]})},Wg=[],Kg=[],Yg=["breakfast","lunch","dinner"],Jg=1440*60*1e3;function Qg(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 bc(t,n){return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}const Xg=({recipes:t=Wg,meals:n=Kg,onChange:i,weekStart:a,rows:s=Yg,readOnly:o,className:c,style:d,"data-testid":p})=>{const{t:m,lang:h}=l.useNiceTranslation(),u=r.useMemo(()=>Qg(a??new Date),[a]),x=r.useMemo(()=>Array.from({length:7},(E,S)=>new Date(u.getTime()+S*Jg)),[u]),f=r.useMemo(()=>{const E=new Map;for(const S of t)E.set(S.id,S);return E},[t]),b=r.useCallback((E,S)=>n.filter(N=>N.kind===S&&N.servedAt instanceof Date&&bc(N.servedAt,E)),[n]),g=r.useCallback((E,S,N)=>{if(!N||o)return;const _=f.get(N),k=new Date(E);k.setHours(S==="breakfast"?8:S==="lunch"?13:S==="dinner"?19:16,0,0,0);const j={id:At.newRecipeId("meal"),name:_?.title??m("mealplan.untitled","Meal"),kind:S,servedAt:k,recipeIds:[N],servings:_?.servings};i?.([...n,j])},[n,i,o,f,m]),v=r.useCallback(E=>{o||i?.(n.filter(S=>S.id!==E))},[n,i,o]),y=E=>E.toLocaleDateString(h,{weekday:"short",day:"numeric",month:"short"}),C=E=>m(`mealplan.kind.${E}`,E.charAt(0).toUpperCase()+E.slice(1)),w=new Date;return e.jsx("div",{className:`nice-mealplan ${c??""}`,style:d,"data-testid":p,children:e.jsxs("div",{className:"nice-mealplan__grid",style:{gridTemplateColumns:"auto repeat(7, minmax(8rem, 1fr))"},children:[e.jsx("div",{className:"nice-mealplan__corner"}),x.map(E=>e.jsx("div",{className:`nice-mealplan__day-head${bc(E,w)?" nice-mealplan__day-head--today":""}`,children:y(E)},E.toISOString())),s.map(E=>e.jsxs(r.Fragment,{children:[e.jsx("div",{className:"nice-mealplan__row-head",children:C(E)}),x.map(S=>{const N=b(S,E);return e.jsxs("div",{className:"nice-mealplan__cell",children:[N.map(_=>{const k=_.recipeIds[0]?f.get(_.recipeIds[0]):void 0;return e.jsxs("div",{className:"nice-mealplan__chip",title:_.name,children:[e.jsx("span",{className:"nice-mealplan__chip-title",children:k?.title??_.name}),!o&&e.jsx("button",{type:"button",className:"nice-mealplan__chip-remove","aria-label":m("mealplan.remove","Remove meal"),onClick:()=>v(_.id),children:e.jsx(l.NiceIcon,{name:"close",size:14})})]},_.id)}),!o&&t.length>0&&e.jsxs("select",{className:"nice-mealplan__add",value:"","aria-label":m("mealplan.addRecipe","Add recipe"),onChange:_=>{const k=_.target.value;k&&g(S,E,k),_.target.value=""},children:[e.jsxs("option",{value:"",children:["+ ",m("mealplan.add","Add")]}),t.map(_=>e.jsx("option",{value:_.id,children:_.title},_.id))]})]},`${E}-${S.toISOString()}`)})]},E))]})})},Zg=[],eb=[],tb=({recipes:t=Zg,collections:n=eb,onChange:i,readOnly:a,onSelectRecipe:s,className:o,style:c,"data-testid":d})=>{const{t:p}=l.useNiceTranslation(),{prompt:m,element:h}=_t.useNiceDialogs(),[u,x]=r.useState(n[0]?.id??null),[f,b]=r.useState(null),g=r.useMemo(()=>{const j=new Map;for(const T of t)j.set(T.id,T);return j},[t]),v=r.useMemo(()=>n.find(j=>j.id===u)??n[0]??null,[n,u]),y=r.useMemo(()=>v?v.recipeIds.map(j=>g.get(j)).filter(j=>!!j):[],[v,g]),C=r.useCallback(j=>{i?.(j)},[i]),w=r.useCallback(()=>{a||m({title:p("collections.namePrompt","Collection name")}).then(j=>{if(!j||!j.trim())return;const T={id:At.newRecipeId("coll"),name:j.trim(),recipeIds:[]};C([...n,T]),x(T.id)})},[n,a,p,C,m]),E=r.useCallback(j=>{if(a)return;const T=n.filter(P=>P.id!==j);C(T),u===j&&x(T[0]?.id??null)},[u,n,a,C]),S=r.useCallback(()=>{if(!f)return;const j=f.value.trim();j&&C(n.map(T=>T.id===f.id?{...T,name:j}:T)),b(null)},[n,f,C]),N=r.useCallback(j=>{!v||!j||a||v.recipeIds.includes(j)||C(n.map(T=>T.id===v.id?{...T,recipeIds:[...T.recipeIds,j]}:T))},[v,n,a,C]),_=r.useCallback(j=>{!v||a||C(n.map(T=>T.id===v.id?{...T,recipeIds:T.recipeIds.filter(P=>P!==j)}:T))},[v,n,a,C]),k=r.useMemo(()=>v?t.filter(j=>!v.recipeIds.includes(j.id)):[],[v,t]);return e.jsxs("div",{className:`nice-recipe-collections ${o??""}`,style:c,"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:p("collections.title","Collections")}),!a&&e.jsx("button",{type:"button",className:"nice-recipe-collections__sidebar-add",onClick:w,"aria-label":p("collections.create","Create collection"),children:e.jsx(l.NiceIcon,{name:"plus",size:14})})]}),e.jsx("ul",{className:"nice-recipe-collections__list",children:n.map(j=>{const T=v?.id===j.id,P=f?.id===j.id;return e.jsxs("li",{className:`nice-recipe-collections__item${T?" nice-recipe-collections__item--active":""}`,children:[P?e.jsx("input",{autoFocus:!0,className:"nice-recipe-collections__rename",value:f.value,onChange:B=>b({id:j.id,value:B.target.value}),onBlur:S,onKeyDown:B=>{B.key==="Enter"?S():B.key==="Escape"&&b(null)}}):e.jsxs("button",{type:"button",className:"nice-recipe-collections__item-btn",onClick:()=>x(j.id),onDoubleClick:()=>!a&&b({id:j.id,value:j.name}),children:[e.jsx("span",{className:"nice-recipe-collections__item-name",children:j.name}),e.jsx("span",{className:"nice-recipe-collections__item-count",children:j.recipeIds.length})]}),!a&&!P&&e.jsx("button",{type:"button",className:"nice-recipe-collections__item-remove",onClick:()=>E(j.id),"aria-label":p("collections.delete","Delete collection"),title:p("collections.delete","Delete collection"),children:e.jsx(l.NiceIcon,{name:"close",size:14})})]},j.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&&k.length>0&&e.jsxs("select",{className:"nice-recipe-collections__add-recipe",value:"","aria-label":p("collections.addRecipe","Add recipe"),onChange:j=>{const T=j.target.value;T&&N(T),j.target.value=""},children:[e.jsxs("option",{value:"",children:["+ ",p("collections.addRecipe","Add recipe")]}),k.map(j=>e.jsx("option",{value:j.id,children:j.title},j.id))]})]}),y.length===0?e.jsx("div",{className:"nice-recipe-collections__empty",children:p("collections.empty","No recipes in this collection yet.")}):e.jsx(Dd,{recipes:y,hideFilters:!0,onSelect:j=>s?.(j)}),!a&&y.length>0&&e.jsxs("details",{className:"nice-recipe-collections__manage",children:[e.jsx("summary",{children:p("collections.manage","Manage recipes")}),e.jsx("ul",{className:"nice-recipe-collections__manage-list",children:y.map(j=>e.jsxs("li",{children:[e.jsx("span",{children:j.title}),e.jsx("button",{type:"button",onClick:()=>_(j.id),"aria-label":p("collections.removeRecipe","Remove recipe from collection"),children:p("collections.removeShort","Remove")})]},j.id))})]})]}):e.jsx("div",{className:"nice-recipe-collections__empty",children:p("collections.emptyState","No collection selected.")})})]})},nb=[],ki=["hour","day","week","month","quarter","year"],ib=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"}}},Ci=(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${ab(t)}`;if(n==="Q")return`Q${Math.ceil((t.getMonth()+1)/3)}`;const s=a.year||a.month||a.day||a.weekday;return(a.hour||a.minute)&&!s?t.toLocaleTimeString(i,a):t.toLocaleDateString(i,a)},ab=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)},fc=(t,n)=>new Date(t.getTime()+n),sb=["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)"],rb=Object.assign(r.forwardRef((t,n)=>{const{t:i}=l.useNiceTranslation(),{events:a=nb,groups:s=[],markers:o=[],initialZoom:c="week",initialDate:d,width:p=800,height:m=400,showToday:h=!0,showZoomControls:u=!0,showNavControls:x=!0,showMinimap:f=!1,onEventClick:b,onEventHover:g,onDateChange:v,onZoomChange:y,renderEvent:C,colors:w=sb,locale:E="pl-PL",className:S,style:N,..._}=t,[k,j]=r.useState(c),[T,P]=r.useState(d||new Date),[B,R]=r.useState(!1),[I,D]=r.useState({x:0,date:new Date}),[M,O]=r.useState(null),[L,V]=r.useState(new Set),ee=r.useRef(null),z=r.useMemo(()=>ib(k),[k]),U=p*z.msPerPixel,re=T.getTime()-U/2,Y=T.getTime()+U/2,oe=r.useMemo(()=>new Date(re),[re]),q=r.useMemo(()=>new Date(Y),[Y]),se=r.useCallback(W=>(W.getTime()-oe.getTime())/z.msPerPixel,[oe,z.msPerPixel]);r.useCallback(W=>{const be=W*z.msPerPixel;return new Date(oe.getTime()+be)},[oe,z.msPerPixel]);const ce=r.useMemo(()=>{const W=[];let be=new Date(oe);switch(k){case"hour":be.setMinutes(0,0,0);break;case"day":be.setHours(0,0,0,0);break;case"week":{const Te=be.getDay();be.setDate(be.getDate()-Te+1),be.setHours(0,0,0,0);break}case"month":be.setDate(1),be.setHours(0,0,0,0);break;case"quarter":be.setMonth(Math.floor(be.getMonth()/3)*3),be.setDate(1),be.setHours(0,0,0,0);break;case"year":be.setMonth(0,1),be.setHours(0,0,0,0);break}for(;be<=q;){const Te=se(be),Me=k==="day"?be.getDay()===1:k==="week"?be.getDate()===1:k==="month"?be.getMonth()%3===0:k==="quarter"?be.getMonth()===0:!0;W.push({date:new Date(be),x:Te,isMain:Me,isWeekend:k==="day"&&(be.getDay()===0||be.getDay()===6)}),be=fc(be,z.unitMs)}return W},[oe,q,k,z,se]),le=r.useMemo(()=>{const W=z.unitMs/z.msPerPixel;return W<=0?1:Math.max(1,Math.ceil(40/W))},[z]),J=r.useMemo(()=>{const W=new Map;return W.set("__default",[]),s.forEach(be=>W.set(be.id,[])),a.forEach(be=>{const Te=be.group&&W.has(be.group)?be.group:"__default",Me=W.get(Te)||[];Me.push(be),W.set(Te,Me)}),W},[a,s]),me=r.useMemo(()=>{const W=[];return J.get("__default")?.length&&W.push({id:"__default",title:"",events:J.get("__default")||[],isGroup:!1}),s.forEach(be=>{L.has(be.id)||W.push({id:be.id,title:be.title,events:J.get(be.id)||[],isGroup:!0})}),W},[J,s,L]),je=r.useCallback(W=>{P(W),v?.(W)},[v]),ue=r.useCallback(()=>{const W=ki.indexOf(k);if(W>0){const be=ki[W-1];j(be),y?.(be)}},[k,y]),F=r.useCallback(()=>{const W=ki.indexOf(k);if(W<ki.length-1){const be=ki[W+1];j(be),y?.(be)}},[k,y]),H=r.useCallback(W=>{j(W),y?.(W)},[y]),A=r.useCallback(W=>{const be=fc(T,W*U*.5);je(be)},[T,U,je]),Z=r.useCallback(W=>{W.button===0&&(R(!0),D({x:W.clientX,date:T}))},[T]),fe=r.useCallback(W=>{if(!B)return;const Te=(I.x-W.clientX)*z.msPerPixel,Me=new Date(I.date.getTime()+Te);P(Me)},[B,I,z.msPerPixel]),Ne=r.useCallback(()=>{B&&(R(!1),v?.(T))},[B,T,v]),K=r.useCallback(W=>{W.preventDefault(),W.deltaY<0?ue():F()},[ue,F]),Q=r.useCallback(W=>{O(W),g?.(W)},[g]),ne=r.useCallback(()=>{O(null),g?.(null)},[g]),G=r.useRef(null);l.useRovingFocus(G,{orientation:"grid",itemSelector:".nice-timeline-event, .nice-timeline-milestone"});const Se=W=>be=>{(be.key==="Enter"||be.key===" ")&&(be.preventDefault(),b?.(W))};r.useImperativeHandle(n,()=>({goToDate:je,zoomIn:ue,zoomOut:F,setZoom:H,getCurrentDate:()=>T,getCurrentZoom:()=>k}),[je,ue,F,H,T,k]);const te=40,we=60,ie=Math.max(me.length*te,m-we-40),xe=se(new Date);return e.jsxs("div",{className:`nice-timeline ${S||""}`,style:{width:p,...N},..._,children:[e.jsxs("div",{className:"nice-timeline-toolbar",children:[x&&e.jsx("div",{className:"nice-timeline-nav",children:e.jsxs(At.NiceButtonGroup,{size:"sm",children:[e.jsx(Fe.NiceButton,{onClick:()=>A(-1),"aria-label":i("planning.previous","Previous"),children:e.jsx(l.NiceIcon,{name:"chevron-left",size:14})}),e.jsx(Fe.NiceButton,{onClick:()=>je(new Date),children:i("scheduling.today","Today")}),e.jsx(Fe.NiceButton,{onClick:()=>A(1),"aria-label":i("planning.next","Next"),children:e.jsx(l.NiceIcon,{name:"chevron-right",size:14})})]})}),e.jsx("div",{className:"nice-timeline-center",children:e.jsxs("span",{className:"nice-timeline-range",children:[Ci(oe,"MMM d, yyyy",E)," —"," ",Ci(q,"MMM d, yyyy",E)]})}),u&&e.jsx("div",{className:"nice-timeline-zoom",children:e.jsx(At.NiceButtonGroup,{size:"sm",children:ki.map(W=>e.jsx(Fe.NiceButton,{variant:k===W?"primary":"secondary",onClick:()=>H(W),children:W==="hour"?i("planning.hourShort","hr"):W==="day"?i("planning.dayShort","day"):W==="week"?i("planning.weekShort","wk"):W==="month"?i("planning.monthShort","mo"):W==="quarter"?i("planning.quarterShort","qtr"):i("planning.yearShort","yr")},W))})})]}),e.jsxs("div",{ref:ee,className:"nice-timeline-container",onMouseDown:Z,onMouseMove:fe,onMouseUp:Ne,onMouseLeave:Ne,onWheel:K,style:{cursor:B?"grabbing":"grab"},children:[e.jsxs("div",{className:"nice-timeline-header",style:{height:we},children:[e.jsx("div",{className:"nice-timeline-header-main",children:z.headerFormat&&e.jsx("span",{children:Ci(T,z.headerFormat,E)})}),e.jsx("div",{className:"nice-timeline-header-units",children:ce.map((W,be)=>{const Te=be%le===0||W.isMain,Me=k==="hour"&&W.date.getHours()===0,$=Me?"d MMM":z.unitLabel;return e.jsx("div",{className:`nice-timeline-unit ${W.isMain?"main":""} ${W.isWeekend?"nice-timeline-unit--weekend":""} ${Me?"nice-timeline-unit--midnight":""} ${Te?"":"nice-timeline-unit--no-label"}`,style:{left:W.x},children:Te&&e.jsx("span",{children:Ci(W.date,$,E)})},be)})})]}),e.jsxs("div",{ref:G,className:"nice-timeline-chart",style:{height:ie},role:"group","aria-label":i("timeline.events","Events"),children:[e.jsxs("svg",{className:"nice-timeline-grid",width:p,height:ie,children:[ce.map((W,be)=>{if(!W.isWeekend)return null;const Te=ce[be+1],Me=(Te?Te.x:W.x+z.unitMs/z.msPerPixel)-W.x;return e.jsx("rect",{x:W.x,y:0,width:Me,height:ie,className:"nice-timeline-weekend-band"},`wk-${be}`)}),ce.map((W,be)=>e.jsx("line",{x1:W.x,y1:0,x2:W.x,y2:ie,className:W.isMain?"main":"minor"},be)),h&&xe>=0&&xe<=p&&e.jsx("line",{x1:xe,y1:0,x2:xe,y2:ie,className:"today"}),me.map((W,be)=>e.jsx("line",{x1:0,y1:(be+1)*te,x2:p,y2:(be+1)*te,className:"row-sep"},be))]}),o.map((W,be)=>{const Te=se(W.date);return Te<0||Te>p?null:e.jsx("div",{className:`nice-timeline-marker ${W.type||"line"}`,style:{left:Te,borderColor:W.color},children:e.jsx("span",{className:"nice-timeline-marker-label",children:W.label})},be)}),me.map((W,be)=>e.jsx("div",{className:"nice-timeline-row",style:{top:be*te,height:te},children:W.events.map((Te,Me)=>{const $=se(Te.start),X=Te.end?se(Te.end):$+10,ae=Math.max(X-$,20),ve=Te.color||w[Me%w.length];return $>p||X<0?null:Te.type==="milestone"?e.jsx("div",{className:`nice-timeline-milestone ${M?.id===Te.id?"hovered":""}`,style:{left:$,borderColor:ve},onClick:()=>b?.(Te),onKeyDown:Se(Te),onMouseEnter:()=>Q(Te),onMouseLeave:ne,onFocus:()=>Q(Te),onBlur:ne,role:"button","aria-label":Te.title,title:Te.title,children:Te.icon||e.jsx(l.NiceIcon,{name:"diamond",size:12})},Te.id):e.jsx("div",{className:`nice-timeline-event ${Te.type||"event"} ${M?.id===Te.id?"hovered":""}`,style:{left:Math.max($,0),width:ae,backgroundColor:ve},onClick:()=>b?.(Te),onKeyDown:Se(Te),onMouseEnter:()=>Q(Te),onMouseLeave:ne,onFocus:()=>Q(Te),onBlur:ne,role:"button","aria-label":Te.title,title:Te.description||Te.title,children:C?C(Te):e.jsx("span",{className:"nice-timeline-event-title",children:Te.title})},Te.id)})},W.id)),h&&xe>=0&&xe<=p&&e.jsx("div",{className:"nice-timeline-today-marker",style:{left:xe},children:e.jsx("span",{children:i("scheduling.today","Today")})})]}),M&&e.jsxs("div",{className:"nice-timeline-tooltip",style:{left:se(M.start)+10},children:[e.jsx("strong",{children:M.title}),M.description&&e.jsx("p",{children:M.description}),e.jsxs("small",{children:[Ci(M.start,"MMM d, yyyy HH:mm",E),M.end&&` — ${Ci(M.end,"MMM d, yyyy HH:mm",E)}`]})]})]}),f&&e.jsx("div",{className:"nice-timeline-minimap"}),e.jsx("style",{children:`
4
4
  .nice-timeline {
@@ -1289,7 +1289,7 @@ ${ae}
1289
1289
  color: var(--nice-primary, #2563eb); border-radius: var(--nice-radius-sm, 4px); padding: 4px 12px;
1290
1290
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; margin-top: 2px;
1291
1291
  }
1292
- `;class eu{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 co=kf();function kf(){const t=new eu;return Cf(t),Sf(t),t}function Cf(t){t.registerAll([{type:"text",label:"Text",category:"content",component:(n=>r.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 r.createElement(a,{className:"nice-view-v2__heading"},String(n.text??""))})},{type:"container",label:"Container",category:"layout",component:(n=>r.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=>r.createElement("button",{type:"button",className:"nice-btn nice-btn--primary"},String(n.label??n.text??"Button")))}])}function Yt(t,n,i,a){const s=r.lazy(()=>n().then(c=>({default:i(c)}))),o=c=>r.createElement(r.Suspense,{fallback:null},r.createElement(s,c));t.register({...a,component:o})}function Sf(t){Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceTextInput$1),n=>n.NiceTextInput,{type:"textInput",label:"Text Input",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceTextArea$1),n=>n.NiceTextArea,{type:"textArea",label:"Text Area",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceNumberInput$1),n=>n.NiceNumberInput,{type:"numberInput",label:"Number Input",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceCheckbox$1),n=>n.NiceCheckbox,{type:"checkbox",label:"Checkbox",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceSelect$1),n=>n.NiceSelect,{type:"select",label:"Select",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceSlider$1),n=>n.NiceSlider,{type:"slider",label:"Slider",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceRating$1),n=>n.NiceRating,{type:"rating",label:"Rating",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceRadioGroup$1),n=>n.NiceRadioGroup,{type:"radioGroup",label:"Radio Group",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceDateTimePicker$1),n=>n.NiceDateTimePicker,{type:"datePicker",label:"Date Picker",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceDateTimePicker$1),n=>n.NiceDateTimePicker,{type:"timePicker",label:"Time Picker",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceColorPicker-79rkvaSk.cjs")),n=>n.NiceColorPicker,{type:"colorPicker",label:"Color Picker",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceModuleLifecyclePanel-jckyVqqt.cjs")).then(n=>n.NiceCard$1),n=>n.NiceCard,{type:"card",label:"Card",category:"layout"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceDataGrid-Cszjz8NV.cjs")).then(n=>n.NiceDataGrid$1),n=>(i=>r.createElement(n.NiceDataGrid,{...i,data:Array.isArray(i.data)?i.data:[]})),{type:"dataGrid",label:"Data Grid",category:"data"}),Yt(t,()=>Promise.resolve().then(()=>require("./charts-C3Q3r8Yz.cjs")).then(n=>n.NiceChart$1),n=>(i=>r.createElement(n.NiceChart,{...i,series:Array.isArray(i.series)?i.series:[]})),{type:"chart",label:"Chart",category:"data"}),Yt(t,()=>Promise.resolve().then(()=>nE),n=>(i=>r.createElement(n.NiceStatistic,{...i,title:String(i.title??i.label??"KPI"),value:typeof i.value=="number"||typeof i.value=="string"?i.value:"—"})),{type:"kpi",label:"KPI",category:"data"}),Yt(t,()=>Promise.resolve().then(()=>Lh),n=>(i=>r.createElement(n.NiceBadge,{...i,children:i.children??String(i.text??i.label??"Badge")})),{type:"badge",label:"Badge",category:"display"})}function fs(t,n){let i=t;for(const a of n.split(".")){if(i==null||typeof i!="object")return;i=i[a]}return i}const Tf={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 Ef(t,n,i){const a=t.split("|").map(o=>o.trim());let s=n;for(const o of a){if(o.startsWith("field:")){s=fs(i,o.slice(6));continue}const c=Tf[o];c&&(s=c(s,i))}return s}function If(t,n,i){if(!n)return;const a=n.getRecord(t.source,i);if(!a)return;const s=fs(a,t.field);if(t.transform)try{return Ef(t.transform,s,a)}catch{return s}return s}function tu(t,n,i){const a=t.trim();if(a.startsWith("!"))return!tu(a.slice(1),n,i);const s=a.match(/^([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)\s*(===?|!==?|>=?|<=?)\s*(.+)$/);if(s){const[,d,p,m]=s,[h,...u]=d.split("."),x=n.getRecord(h,i),f=x?fs(x,u.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)),p){case"==":case"===":return f===b;case"!=":case"!==":return f!==b;case">":return Number(f)>Number(b);case">=":return Number(f)>=Number(b);case"<":return Number(f)<Number(b);case"<=":return Number(f)<=Number(b);default:return!0}}const[o,...c]=a.split(".");if(o){const d=n.getRecord(o,i);return d?!!(c.length?fs(d,c.join(".")):d):!1}return!0}function Pc(t,n,i){if(!t||!n)return!0;try{return tu(t,n,i)}catch{return!0}}function Ac(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 s of t)(n.includes(s.role)||s.role==="*")&&a[s.access]>a[i]&&(i=s.access);return i}function Df(t,n){return t+1}const nu=Object.assign(r.forwardRef(({view:t,registry:n=co,dataStore:i,userRoles:a,onNavigate:s,onNotify:o,onOpenDialog:c,onCloseDialog:d,fallback:p,recordIndex:m,onRunScript:h,className:u,style:x,id:f,...b},g)=>{const{t:v}=l.useNiceTranslation(),{confirm:y,element:C}=_t.useNiceDialogs(),[,w]=r.useReducer(Df,0),E=r.useRef(w);E.current=w;const S=r.useMemo(()=>({dataSources:new Proxy({},{get:(I,D)=>i?.get(D)}),navigate:I=>s?.(I),notify:(I,D)=>o?.(I,D),refreshDataSource:I=>{i?.refresh(I),E.current({type:"tick"})},openDialog:I=>c?.(I),closeDialog:()=>d?.()}),[i,s,o,c,d]),N=r.useCallback(async I=>{for(const D of I)if(!(D.confirm&&!await y({message:D.confirm})))try{switch(D.type){case"navigate":D.target&&S.navigate(D.target);break;case"apiCall":if(D.endpoint){const M=D.endpoint.trim().toLowerCase();if(!M.startsWith("http://")&&!M.startsWith("https://")&&!M.startsWith("/")){console.warn("[NiceViewRenderer] Blocked unsafe endpoint:",D.endpoint);break}await fetch(D.endpoint,{method:D.method??"POST",headers:{"Content-Type":"application/json"},body:D.body?JSON.stringify(D.body):void 0})}D.successMessage&&S.notify(D.successMessage,"success");break;case"setField":if(D.field&&i){const[M,...O]=D.field.split(".");i.setField(M,O.join("."),D.value,m)}break;case"refresh":D.dataSourceKey&&S.refreshDataSource(D.dataSourceKey);break;case"openDialog":D.dialogViewId&&S.openDialog(D.dialogViewId);break;case"closeDialog":S.closeDialog();break;case"submit":break;case"custom":{const M=D.handler?n.getAction(D.handler):void 0;M&&await M(D.params??{},S);break}case"script":D.script&&(h?await h(D.script,{language:D.language??"js",action:D,context:S}):typeof console<"u"&&console.warn("[NiceViewRenderer] script action skipped: no onRunScript handler provided.",D));break}}catch(M){const O=D.errorMessage??`Action failed: ${M.message}`;S.notify(O,"error")}},[S,i,m,n,h,y]),_=r.useCallback(I=>{if(!Pc(I.visibleWhen,i,m))return null;const D=Ac(I.permissions,a);if(D==="hidden")return null;const M={...I.props};if(I.bindings){for(const[V,ee]of Object.entries(I.bindings))if(M[V]=If(ee,i,m),ee.twoWay){const z=`on${V.charAt(0).toUpperCase()}${V.slice(1)}Change`;M[z]=U=>{i?.setField(ee.source,ee.field,U,m),E.current({type:"tick"})}}}if(D==="readonly"&&(M.disabled=!0,M.readOnly=!0),I.events)for(const V of I.events)M[V.event]=(...ee)=>{N(V.actions)};const O=n.get(I.controlType);if(!O)return p?e.jsx(p,{controlType:I.controlType}):e.jsx("div",{className:"nice-view-v2__unknown",children:v("view.unknownControl","Unknown control: {type}").replace("{type}",I.controlType)});const L=O.component;return e.jsx(L,{...O.defaultProps??{},...M})},[n,i,a,m,N,p,v]),k=r.useCallback((I,D)=>I.map(M=>Pc(M.visibleWhen,i,m)?e.jsx("div",{className:`nice-view-v2__row ${M.cssClass??""}`,style:{gridTemplateColumns:`repeat(${D}, 1fr)`,...M.height?{minHeight:M.height}:{}},children:M.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:_(O)},O.id))},M.id):null),[_,i,m]),j=r.useCallback((I,D)=>{switch(I.type){case"tabs":return e.jsx("div",{className:"nice-view-v2__tabs",children:I.sections.map(M=>e.jsxs("div",{className:"nice-view-v2__tab-panel",children:[M.label&&e.jsx("div",{className:"nice-view-v2__tab-label",children:M.label}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))});case"accordion":return e.jsx("div",{className:"nice-view-v2__accordion",children:I.sections.map(M=>e.jsxs("details",{className:"nice-view-v2__accordion-panel",children:[e.jsx("summary",{children:M.label??M.id}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))});case"splitter":{const M=I.props?.sizes??I.sections.map(()=>"1fr");return e.jsx("div",{className:"nice-view-v2__splitter",style:{gridTemplateColumns:M.join(" ")},children:I.sections.map(O=>e.jsxs("div",{className:"nice-view-v2__splitter-panel",children:[O.rows&&k(O.rows,D),O.container&&j(O.container,D)]},O.id))})}case"stack":return e.jsx("div",{className:"nice-view-v2__stack",children:I.sections.map(M=>e.jsxs("div",{children:[M.label&&e.jsx("h3",{className:"nice-view-v2__section-label",children:M.label}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))});default:return e.jsx(e.Fragment,{children:I.sections.map(M=>e.jsxs("div",{children:[M.label&&e.jsx("h3",{className:"nice-view-v2__section-label",children:M.label}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))})}},[k]),T=r.useCallback(I=>!I||I.length===0?null:I.map((D,M)=>e.jsx("div",{className:`nice-view-v2__toolbar nice-view-v2__toolbar--${D.position}`,children:D.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(l.NiceIcon,{name:O.icon,size:14})}),O.label]},O.id))},M)),[N]);if(Ac(t.permissions?.map(I=>({...I})),a)==="hidden")return null;const B=t.toolbars?.filter(I=>I.position==="top"),R=t.toolbars?.filter(I=>I.position==="bottom");return e.jsxs("div",{ref:g,id:f,className:`nice-view-v2 ${u??""}`,style:x,"data-view-id":t.id,"data-view-module":t.module,...b,children:[C,T(B),t.container?j(t.container,t.columns??12):t.rows&&k(t.rows,t.columns??12),T(R)]})}),{displayName:"NiceViewRenderer"});function Pf(t){const n=[];for(const i of t??[])for(const a of i.cells??[])n.push(a);return n}function lo(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 s=Object.values(i).find(o=>Array.isArray(o));if(Array.isArray(s))return s}return[]}function uo(t,n){const i=[],a=new Set;for(const s of Pf(t.rows)){const o=s,c=o.binding?.field??o.props?.field;c&&!a.has(c)&&(a.add(c),i.push({field:c,header:o.label??o.props?.label??c}))}if(i.length===0&&n.length>0)for(const s of Object.keys(n[0]))i.push({field:s,header:s});return i}function Us(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function _r(t,n,i={}){const a=lo(t,n),s=i.columns??uo(t,a),o=Us(t.name||"Report"),c=s.length>0?`<table><thead><tr>${s.map(d=>`<th>${Us(d.header)}</th>`).join("")}</tr></thead><tbody>${a.map(d=>`<tr>${s.map(p=>`<td>${Us(d[p.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>${c}</body></html>`}function Rc(t,n,i){if(typeof document>"u")return;const a=new Blob([t],{type:n}),s=URL.createObjectURL(a),o=document.createElement("a");o.href=s,o.download=i,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),0)}async function iu(t,n,i,a={}){const s=lo(t,n);if(a.onExport){await a.onExport(t,s,i);return}const o=a.columns??uo(t,s),c=a.fileName??t.name??"export";switch(i){case"csv":Qe.downloadCSV(s,o,{fileName:c});return;case"xlsx":Qe.downloadXLSX(s,o,{fileName:c,sheetName:t.name||"Sheet1"});return;case"html":Rc(_r(t,n,{columns:o}),"text/html;charset=utf-8",`${c}.html`);return;case"docx":Rc(_r(t,n,{columns:o}),"application/msword",`${c}.doc`);return;case"pdf":default:Qe.exportToPDF(s,o,{title:t.name});return}}const Af=[{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"}],Rf=[{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"}]}],$f=["rest","odata","graphql","static","query","entity"],Mf=["hidden","readonly","editable"],Of=[{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"}],Lf=new Set(["report","print","grid"]),zf=["pdf","docx","xlsx","csv","html"];let Bf=0;const os=t=>`${t}-${Date.now().toString(36)}-${(Bf++).toString(36)}`;function Ff(){return{id:os("view"),name:"New View",version:2,columns:12,rows:[],dataSources:[]}}function qf(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,s,o=0)=>{const c=n[i]??(n[i]=[{}]),d=c[o]??(c[o]={});d[a]=s},refresh:()=>{}}}const Vf=r.forwardRef(function(n,i){const a=r.useRef(null);l.useRovingFocus(a,{orientation:"horizontal",wrap:!0,activateOnMove:!0}),En.injectStyleOnce(Gf,Wf);const{value:s,onChange:o,registry:c=co,entities:d,dataSourceOptions:p,onSave:m,onExport:h,height:u=560,tutorial:x,className:f,style:b,id:g,"data-testid":v}=n,{t:y}=l.useNiceTranslation(),[C,w]=r.useState(()=>s??Ff()),E=s??C,[S,N]=r.useState(null),[_,k]=r.useState("design"),j=r.useCallback(F=>{o?o(F):w(F)},[o]),T=r.useMemo(()=>E.rows??[],[E.rows]),P=(E.dataSources??[]).map(F=>F.key),B=r.useMemo(()=>c.getActionNames(),[c]),I=r.useCallback(F=>{if(!F)return null;for(const H of T){const A=H.cells.find(Z=>Z.id===F);if(A)return{row:H,cell:A}}return null},[T])(S),D=F=>j({...E,rows:F}),M=(F,H)=>D(T.map(A=>({...A,cells:A.cells.map(Z=>Z.id===F?{...Z,...H}:Z)}))),O=()=>D([...T,{id:os("row"),cells:[]}]),L=F=>{const H={id:os("cell"),controlType:F,props:{label:F},colSpan:6},A=T.length>0?T.slice():[{id:os("row"),cells:[]}];A[A.length-1]={...A[A.length-1],cells:[...A[A.length-1].cells,H]},D(A),N(H.id)},V=F=>{D(T.map(H=>({...H,cells:H.cells.filter(A=>A.id!==F)}))),S===F&&N(null)},ee=(F,H)=>{const A=d?.find(Z=>Z.name===F);A&&(j(Xd(A,H)),N(null))},z=r.useMemo(()=>(d??[]).map(F=>F.name).filter(F=>!!F),[d]),U=r.useMemo(()=>oo(E),[E]),re=r.useMemo(()=>qf(E),[E]),Y=r.useMemo(()=>{const F={};for(const H of E.dataSources??[]){const A=H.data;F[H.key]=Array.isArray(A)?A:[]}return F},[E]),oe=E.kind??E.meta?.kind??"form",q=F=>{iu(E,Y,F,{onExport:h})},se=e.jsxs("div",{className:"nice-view-editor__toolbar",children:[e.jsx("input",{className:"nice-view-editor__name",value:E.name,onChange:F=>j({...E,name:F.target.value}),placeholder:y("viewEditor.name","View name"),"aria-label":y("viewEditor.name","View name")}),e.jsx("select",{className:"nice-view-editor__kind",value:oe,onChange:F=>j({...E,kind:F.target.value}),"aria-label":y("viewEditor.kindAria","View kind"),children:Of.map(F=>e.jsx("option",{value:F.value,children:y("viewEditor.kind."+F.value,F.label)},F.value))}),d&&d.length>0&&e.jsxs("select",{className:"nice-view-editor__from-entity",value:"",onChange:F=>{const[H,A]=F.target.value.split("::");H&&ee(H,A)},"aria-label":y("viewEditor.fromEntityAria","New view from entity"),children:[e.jsx("option",{value:"",children:y("viewEditor.fromEntity","New from entity…")}),d.map(F=>["form","detail","grid"].map(H=>e.jsxs("option",{value:`${F.name}::${H}`,children:[F.name," · ",H]},`${F.name}-${H}`)))]}),Lf.has(oe)&&e.jsxs("select",{className:"nice-view-editor__export",value:"",onChange:F=>{const H=F.target.value;H&&q(H)},"aria-label":y("viewEditor.exportAria","Export view"),children:[e.jsx("option",{value:"",children:y("viewEditor.export","Export…")}),zf.map(F=>e.jsx("option",{value:F,children:F.toUpperCase()},F))]}),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(F=>e.jsx("button",{type:"button",role:"tab","aria-selected":_===F,className:"nice-view-editor__mode"+(_===F?" nice-view-editor__mode--active":""),onClick:()=>k(F),children:y("viewEditor.mode."+F,F[0].toUpperCase()+F.slice(1))},F))}),e.jsxs("span",{className:"nice-view-editor__status"+(U.length?" nice-view-editor__status--err":""),title:U.join(`
1292
+ `;class eu{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 co=kf();function kf(){const t=new eu;return Cf(t),Sf(t),t}function Cf(t){t.registerAll([{type:"text",label:"Text",category:"content",component:(n=>r.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 r.createElement(a,{className:"nice-view-v2__heading"},String(n.text??""))})},{type:"container",label:"Container",category:"layout",component:(n=>r.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=>r.createElement("button",{type:"button",className:"nice-btn nice-btn--primary"},String(n.label??n.text??"Button")))}])}function Yt(t,n,i,a){const s=r.lazy(()=>n().then(c=>({default:i(c)}))),o=c=>r.createElement(r.Suspense,{fallback:null},r.createElement(s,c));t.register({...a,component:o})}function Sf(t){Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceTextInput$1),n=>n.NiceTextInput,{type:"textInput",label:"Text Input",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceTextArea$1),n=>n.NiceTextArea,{type:"textArea",label:"Text Area",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceNumberInput$1),n=>n.NiceNumberInput,{type:"numberInput",label:"Number Input",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceCheckbox$1),n=>n.NiceCheckbox,{type:"checkbox",label:"Checkbox",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceSelect$1),n=>n.NiceSelect,{type:"select",label:"Select",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceSlider$1),n=>n.NiceSlider,{type:"slider",label:"Slider",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceRating$1),n=>n.NiceRating,{type:"rating",label:"Rating",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceRadioGroup$1),n=>n.NiceRadioGroup,{type:"radioGroup",label:"Radio Group",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceDateTimePicker$1),n=>n.NiceDateTimePicker,{type:"datePicker",label:"Date Picker",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceDateTimePicker$1),n=>n.NiceDateTimePicker,{type:"timePicker",label:"Time Picker",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceColorPicker-79rkvaSk.cjs")),n=>n.NiceColorPicker,{type:"colorPicker",label:"Color Picker",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceModuleLifecyclePanel-jckyVqqt.cjs")).then(n=>n.NiceCard$1),n=>n.NiceCard,{type:"card",label:"Card",category:"layout"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceDataGrid-Cszjz8NV.cjs")).then(n=>n.NiceDataGrid$1),n=>(i=>r.createElement(n.NiceDataGrid,{...i,data:Array.isArray(i.data)?i.data:[]})),{type:"dataGrid",label:"Data Grid",category:"data"}),Yt(t,()=>Promise.resolve().then(()=>require("./charts-C9B548D2.cjs")).then(n=>n.NiceChart$1),n=>(i=>r.createElement(n.NiceChart,{...i,series:Array.isArray(i.series)?i.series:[]})),{type:"chart",label:"Chart",category:"data"}),Yt(t,()=>Promise.resolve().then(()=>nE),n=>(i=>r.createElement(n.NiceStatistic,{...i,title:String(i.title??i.label??"KPI"),value:typeof i.value=="number"||typeof i.value=="string"?i.value:"—"})),{type:"kpi",label:"KPI",category:"data"}),Yt(t,()=>Promise.resolve().then(()=>Lh),n=>(i=>r.createElement(n.NiceBadge,{...i,children:i.children??String(i.text??i.label??"Badge")})),{type:"badge",label:"Badge",category:"display"})}function fs(t,n){let i=t;for(const a of n.split(".")){if(i==null||typeof i!="object")return;i=i[a]}return i}const Tf={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 Ef(t,n,i){const a=t.split("|").map(o=>o.trim());let s=n;for(const o of a){if(o.startsWith("field:")){s=fs(i,o.slice(6));continue}const c=Tf[o];c&&(s=c(s,i))}return s}function If(t,n,i){if(!n)return;const a=n.getRecord(t.source,i);if(!a)return;const s=fs(a,t.field);if(t.transform)try{return Ef(t.transform,s,a)}catch{return s}return s}function tu(t,n,i){const a=t.trim();if(a.startsWith("!"))return!tu(a.slice(1),n,i);const s=a.match(/^([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)\s*(===?|!==?|>=?|<=?)\s*(.+)$/);if(s){const[,d,p,m]=s,[h,...u]=d.split("."),x=n.getRecord(h,i),f=x?fs(x,u.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)),p){case"==":case"===":return f===b;case"!=":case"!==":return f!==b;case">":return Number(f)>Number(b);case">=":return Number(f)>=Number(b);case"<":return Number(f)<Number(b);case"<=":return Number(f)<=Number(b);default:return!0}}const[o,...c]=a.split(".");if(o){const d=n.getRecord(o,i);return d?!!(c.length?fs(d,c.join(".")):d):!1}return!0}function Pc(t,n,i){if(!t||!n)return!0;try{return tu(t,n,i)}catch{return!0}}function Ac(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 s of t)(n.includes(s.role)||s.role==="*")&&a[s.access]>a[i]&&(i=s.access);return i}function Df(t,n){return t+1}const nu=Object.assign(r.forwardRef(({view:t,registry:n=co,dataStore:i,userRoles:a,onNavigate:s,onNotify:o,onOpenDialog:c,onCloseDialog:d,fallback:p,recordIndex:m,onRunScript:h,className:u,style:x,id:f,...b},g)=>{const{t:v}=l.useNiceTranslation(),{confirm:y,element:C}=_t.useNiceDialogs(),[,w]=r.useReducer(Df,0),E=r.useRef(w);E.current=w;const S=r.useMemo(()=>({dataSources:new Proxy({},{get:(I,D)=>i?.get(D)}),navigate:I=>s?.(I),notify:(I,D)=>o?.(I,D),refreshDataSource:I=>{i?.refresh(I),E.current({type:"tick"})},openDialog:I=>c?.(I),closeDialog:()=>d?.()}),[i,s,o,c,d]),N=r.useCallback(async I=>{for(const D of I)if(!(D.confirm&&!await y({message:D.confirm})))try{switch(D.type){case"navigate":D.target&&S.navigate(D.target);break;case"apiCall":if(D.endpoint){const M=D.endpoint.trim().toLowerCase();if(!M.startsWith("http://")&&!M.startsWith("https://")&&!M.startsWith("/")){console.warn("[NiceViewRenderer] Blocked unsafe endpoint:",D.endpoint);break}await fetch(D.endpoint,{method:D.method??"POST",headers:{"Content-Type":"application/json"},body:D.body?JSON.stringify(D.body):void 0})}D.successMessage&&S.notify(D.successMessage,"success");break;case"setField":if(D.field&&i){const[M,...O]=D.field.split(".");i.setField(M,O.join("."),D.value,m)}break;case"refresh":D.dataSourceKey&&S.refreshDataSource(D.dataSourceKey);break;case"openDialog":D.dialogViewId&&S.openDialog(D.dialogViewId);break;case"closeDialog":S.closeDialog();break;case"submit":break;case"custom":{const M=D.handler?n.getAction(D.handler):void 0;M&&await M(D.params??{},S);break}case"script":D.script&&(h?await h(D.script,{language:D.language??"js",action:D,context:S}):typeof console<"u"&&console.warn("[NiceViewRenderer] script action skipped: no onRunScript handler provided.",D));break}}catch(M){const O=D.errorMessage??`Action failed: ${M.message}`;S.notify(O,"error")}},[S,i,m,n,h,y]),_=r.useCallback(I=>{if(!Pc(I.visibleWhen,i,m))return null;const D=Ac(I.permissions,a);if(D==="hidden")return null;const M={...I.props};if(I.bindings){for(const[V,ee]of Object.entries(I.bindings))if(M[V]=If(ee,i,m),ee.twoWay){const z=`on${V.charAt(0).toUpperCase()}${V.slice(1)}Change`;M[z]=U=>{i?.setField(ee.source,ee.field,U,m),E.current({type:"tick"})}}}if(D==="readonly"&&(M.disabled=!0,M.readOnly=!0),I.events)for(const V of I.events)M[V.event]=(...ee)=>{N(V.actions)};const O=n.get(I.controlType);if(!O)return p?e.jsx(p,{controlType:I.controlType}):e.jsx("div",{className:"nice-view-v2__unknown",children:v("view.unknownControl","Unknown control: {type}").replace("{type}",I.controlType)});const L=O.component;return e.jsx(L,{...O.defaultProps??{},...M})},[n,i,a,m,N,p,v]),k=r.useCallback((I,D)=>I.map(M=>Pc(M.visibleWhen,i,m)?e.jsx("div",{className:`nice-view-v2__row ${M.cssClass??""}`,style:{gridTemplateColumns:`repeat(${D}, 1fr)`,...M.height?{minHeight:M.height}:{}},children:M.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:_(O)},O.id))},M.id):null),[_,i,m]),j=r.useCallback((I,D)=>{switch(I.type){case"tabs":return e.jsx("div",{className:"nice-view-v2__tabs",children:I.sections.map(M=>e.jsxs("div",{className:"nice-view-v2__tab-panel",children:[M.label&&e.jsx("div",{className:"nice-view-v2__tab-label",children:M.label}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))});case"accordion":return e.jsx("div",{className:"nice-view-v2__accordion",children:I.sections.map(M=>e.jsxs("details",{className:"nice-view-v2__accordion-panel",children:[e.jsx("summary",{children:M.label??M.id}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))});case"splitter":{const M=I.props?.sizes??I.sections.map(()=>"1fr");return e.jsx("div",{className:"nice-view-v2__splitter",style:{gridTemplateColumns:M.join(" ")},children:I.sections.map(O=>e.jsxs("div",{className:"nice-view-v2__splitter-panel",children:[O.rows&&k(O.rows,D),O.container&&j(O.container,D)]},O.id))})}case"stack":return e.jsx("div",{className:"nice-view-v2__stack",children:I.sections.map(M=>e.jsxs("div",{children:[M.label&&e.jsx("h3",{className:"nice-view-v2__section-label",children:M.label}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))});default:return e.jsx(e.Fragment,{children:I.sections.map(M=>e.jsxs("div",{children:[M.label&&e.jsx("h3",{className:"nice-view-v2__section-label",children:M.label}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))})}},[k]),T=r.useCallback(I=>!I||I.length===0?null:I.map((D,M)=>e.jsx("div",{className:`nice-view-v2__toolbar nice-view-v2__toolbar--${D.position}`,children:D.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(l.NiceIcon,{name:O.icon,size:14})}),O.label]},O.id))},M)),[N]);if(Ac(t.permissions?.map(I=>({...I})),a)==="hidden")return null;const B=t.toolbars?.filter(I=>I.position==="top"),R=t.toolbars?.filter(I=>I.position==="bottom");return e.jsxs("div",{ref:g,id:f,className:`nice-view-v2 ${u??""}`,style:x,"data-view-id":t.id,"data-view-module":t.module,...b,children:[C,T(B),t.container?j(t.container,t.columns??12):t.rows&&k(t.rows,t.columns??12),T(R)]})}),{displayName:"NiceViewRenderer"});function Pf(t){const n=[];for(const i of t??[])for(const a of i.cells??[])n.push(a);return n}function lo(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 s=Object.values(i).find(o=>Array.isArray(o));if(Array.isArray(s))return s}return[]}function uo(t,n){const i=[],a=new Set;for(const s of Pf(t.rows)){const o=s,c=o.binding?.field??o.props?.field;c&&!a.has(c)&&(a.add(c),i.push({field:c,header:o.label??o.props?.label??c}))}if(i.length===0&&n.length>0)for(const s of Object.keys(n[0]))i.push({field:s,header:s});return i}function Us(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function _r(t,n,i={}){const a=lo(t,n),s=i.columns??uo(t,a),o=Us(t.name||"Report"),c=s.length>0?`<table><thead><tr>${s.map(d=>`<th>${Us(d.header)}</th>`).join("")}</tr></thead><tbody>${a.map(d=>`<tr>${s.map(p=>`<td>${Us(d[p.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>${c}</body></html>`}function Rc(t,n,i){if(typeof document>"u")return;const a=new Blob([t],{type:n}),s=URL.createObjectURL(a),o=document.createElement("a");o.href=s,o.download=i,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),0)}async function iu(t,n,i,a={}){const s=lo(t,n);if(a.onExport){await a.onExport(t,s,i);return}const o=a.columns??uo(t,s),c=a.fileName??t.name??"export";switch(i){case"csv":Qe.downloadCSV(s,o,{fileName:c});return;case"xlsx":Qe.downloadXLSX(s,o,{fileName:c,sheetName:t.name||"Sheet1"});return;case"html":Rc(_r(t,n,{columns:o}),"text/html;charset=utf-8",`${c}.html`);return;case"docx":Rc(_r(t,n,{columns:o}),"application/msword",`${c}.doc`);return;case"pdf":default:Qe.exportToPDF(s,o,{title:t.name});return}}const Af=[{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"}],Rf=[{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"}]}],$f=["rest","odata","graphql","static","query","entity"],Mf=["hidden","readonly","editable"],Of=[{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"}],Lf=new Set(["report","print","grid"]),zf=["pdf","docx","xlsx","csv","html"];let Bf=0;const os=t=>`${t}-${Date.now().toString(36)}-${(Bf++).toString(36)}`;function Ff(){return{id:os("view"),name:"New View",version:2,columns:12,rows:[],dataSources:[]}}function qf(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,s,o=0)=>{const c=n[i]??(n[i]=[{}]),d=c[o]??(c[o]={});d[a]=s},refresh:()=>{}}}const Vf=r.forwardRef(function(n,i){const a=r.useRef(null);l.useRovingFocus(a,{orientation:"horizontal",wrap:!0,activateOnMove:!0}),En.injectStyleOnce(Gf,Wf);const{value:s,onChange:o,registry:c=co,entities:d,dataSourceOptions:p,onSave:m,onExport:h,height:u=560,tutorial:x,className:f,style:b,id:g,"data-testid":v}=n,{t:y}=l.useNiceTranslation(),[C,w]=r.useState(()=>s??Ff()),E=s??C,[S,N]=r.useState(null),[_,k]=r.useState("design"),j=r.useCallback(F=>{o?o(F):w(F)},[o]),T=r.useMemo(()=>E.rows??[],[E.rows]),P=(E.dataSources??[]).map(F=>F.key),B=r.useMemo(()=>c.getActionNames(),[c]),I=r.useCallback(F=>{if(!F)return null;for(const H of T){const A=H.cells.find(Z=>Z.id===F);if(A)return{row:H,cell:A}}return null},[T])(S),D=F=>j({...E,rows:F}),M=(F,H)=>D(T.map(A=>({...A,cells:A.cells.map(Z=>Z.id===F?{...Z,...H}:Z)}))),O=()=>D([...T,{id:os("row"),cells:[]}]),L=F=>{const H={id:os("cell"),controlType:F,props:{label:F},colSpan:6},A=T.length>0?T.slice():[{id:os("row"),cells:[]}];A[A.length-1]={...A[A.length-1],cells:[...A[A.length-1].cells,H]},D(A),N(H.id)},V=F=>{D(T.map(H=>({...H,cells:H.cells.filter(A=>A.id!==F)}))),S===F&&N(null)},ee=(F,H)=>{const A=d?.find(Z=>Z.name===F);A&&(j(Xd(A,H)),N(null))},z=r.useMemo(()=>(d??[]).map(F=>F.name).filter(F=>!!F),[d]),U=r.useMemo(()=>oo(E),[E]),re=r.useMemo(()=>qf(E),[E]),Y=r.useMemo(()=>{const F={};for(const H of E.dataSources??[]){const A=H.data;F[H.key]=Array.isArray(A)?A:[]}return F},[E]),oe=E.kind??E.meta?.kind??"form",q=F=>{iu(E,Y,F,{onExport:h})},se=e.jsxs("div",{className:"nice-view-editor__toolbar",children:[e.jsx("input",{className:"nice-view-editor__name",value:E.name,onChange:F=>j({...E,name:F.target.value}),placeholder:y("viewEditor.name","View name"),"aria-label":y("viewEditor.name","View name")}),e.jsx("select",{className:"nice-view-editor__kind",value:oe,onChange:F=>j({...E,kind:F.target.value}),"aria-label":y("viewEditor.kindAria","View kind"),children:Of.map(F=>e.jsx("option",{value:F.value,children:y("viewEditor.kind."+F.value,F.label)},F.value))}),d&&d.length>0&&e.jsxs("select",{className:"nice-view-editor__from-entity",value:"",onChange:F=>{const[H,A]=F.target.value.split("::");H&&ee(H,A)},"aria-label":y("viewEditor.fromEntityAria","New view from entity"),children:[e.jsx("option",{value:"",children:y("viewEditor.fromEntity","New from entity…")}),d.map(F=>["form","detail","grid"].map(H=>e.jsxs("option",{value:`${F.name}::${H}`,children:[F.name," · ",H]},`${F.name}-${H}`)))]}),Lf.has(oe)&&e.jsxs("select",{className:"nice-view-editor__export",value:"",onChange:F=>{const H=F.target.value;H&&q(H)},"aria-label":y("viewEditor.exportAria","Export view"),children:[e.jsx("option",{value:"",children:y("viewEditor.export","Export…")}),zf.map(F=>e.jsx("option",{value:F,children:F.toUpperCase()},F))]}),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(F=>e.jsx("button",{type:"button",role:"tab","aria-selected":_===F,className:"nice-view-editor__mode"+(_===F?" nice-view-editor__mode--active":""),onClick:()=>k(F),children:y("viewEditor.mode."+F,F[0].toUpperCase()+F.slice(1))},F))}),e.jsxs("span",{className:"nice-view-editor__status"+(U.length?" nice-view-editor__status--err":""),title:U.join(`
1293
1293
  `),children:[e.jsx(l.NiceIcon,{name:U.length===0?"check":"warning",size:14})," ",U.length===0?y("viewEditor.valid","Valid"):U.length]}),m&&e.jsx("button",{type:"button",className:"nice-view-editor__save",onClick:()=>m(E),disabled:U.length>0,children:y("viewEditor.save","Save")}),e.jsx(l.NiceTutorialButton,{steps:l.resolveTutorial(x,Af)})]}),ce=e.jsxs("div",{className:"nice-view-editor__palette",children:[Rf.map(F=>e.jsxs("div",{className:"nice-view-editor__pal-group",children:[e.jsx("div",{className:"nice-view-editor__pal-cat",children:y("viewEditor.cat."+F.category,F.category)}),F.items.map(H=>{const A=y("viewEditor.pal."+H.type,H.label);return e.jsx("button",{type:"button",className:"nice-view-editor__pal-item",onClick:()=>L(H.type),title:`${y("viewEditor.add","Add")} ${A}`,children:A},H.type)})]},F.category)),e.jsxs("button",{type:"button",className:"nice-view-editor__add-row",onClick:O,children:["+ ",y("viewEditor.addRow","Add row")]})]}),le=e.jsxs("div",{className:"nice-view-editor__canvas",children:[T.length===0&&e.jsx("div",{className:"nice-view-editor__canvas-empty",children:y("viewEditor.canvasEmpty","Add a row, then drop controls from the palette — or start “New from entity”.")}),T.map(F=>e.jsxs("div",{className:"nice-view-editor__row",style:{gridTemplateColumns:`repeat(${E.columns??12}, 1fr)`},children:[F.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:A=>{A.key==="Delete"&&(A.preventDefault(),V(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(l.NiceIcon,{name:"link",size:12})," ",H.bindings.value.field]}),e.jsx("span",{className:"nice-view-editor__cell-x",role:"button",tabIndex:-1,"aria-label":y("viewEditor.removeCell","Remove cell"),onClick:A=>{A.stopPropagation(),V(H.id)},onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),A.stopPropagation(),V(H.id))},children:e.jsx(l.NiceIcon,{name:"close",size:14})})]},H.id)),F.cells.length===0&&e.jsx("span",{className:"nice-view-editor__row-empty",children:y("viewEditor.emptyRow","empty row")})]},F.id))]}),J=I?e.jsx(Uf,{cell:I.cell,dsKeys:P,handlerNames:B,onPatch:F=>M(I.cell.id,F)}):e.jsx(Hf,{dataSources:E.dataSources??[],onChange:F=>j({...E,dataSources:F}),queryOptions:p,entityNames:z}),me="nice-view-editor"+(f?` ${f}`:""),je=_==="design",ue=_==="source"?e.jsx("pre",{className:"nice-view-editor__source",children:Jd(E)}):_==="preview"?e.jsx("div",{className:"nice-view-editor__preview",children:e.jsx(nu,{view:E,registry:c,dataStore:re})}):le;return e.jsx(_t.NiceAppShell,{ref:i,id:g,className:me,style:{height:u,...b},"data-testid":v,flush:!0,toolbar:se,sidebar:je?ce:void 0,rightSidebar:je?e.jsx("div",{className:"nice-view-editor__props",children:J}):void 0,children:ue})});function Uf({cell:t,dsKeys:n,handlerNames:i,onPatch:a}){const{t:s}=l.useNiceTranslation(),o=t.bindings?.value,c=u=>{const x={source:"",field:"",...o,...u};a({bindings:{...t.bindings,value:x}})},d=t.events??[],p=u=>a({events:u}),m=t.permissions??[],h=u=>a({permissions:u});return e.jsxs("div",{className:"nice-view-editor__panel",children:[e.jsxs("div",{className:"nice-view-editor__panel-title",children:[s("viewEditor.control","Control")," · ",t.controlType]}),e.jsx("label",{className:"nice-view-editor__lbl",children:s("viewEditor.cp.label","Label")}),e.jsx("input",{className:"nice-view-editor__in",value:t.props.label??"",onChange:u=>a({props:{...t.props,label:u.target.value}})}),e.jsx("label",{className:"nice-view-editor__lbl",children:s("viewEditor.cp.colSpan","Column span")}),e.jsx("input",{className:"nice-view-editor__in",type:"number",min:1,max:12,value:t.colSpan??6,onChange:u=>a({colSpan:Number(u.target.value)||6})}),e.jsx("div",{className:"nice-view-editor__panel-sub",children:s("viewEditor.cp.binding","Binding")}),e.jsx("label",{className:"nice-view-editor__lbl",children:s("viewEditor.cp.dataSource","Data source")}),e.jsxs("select",{className:"nice-view-editor__in",value:o?.source??"",onChange:u=>c({source:u.target.value}),children:[e.jsx("option",{value:"",children:s("viewEditor.cp.none","— none —")}),n.map(u=>e.jsx("option",{value:u,children:u},u))]}),e.jsx("label",{className:"nice-view-editor__lbl",children:s("viewEditor.cp.field","Field")}),e.jsx("input",{className:"nice-view-editor__in",value:o?.field??"",onChange:u=>c({field:u.target.value}),placeholder:s("viewEditor.cp.fieldPath","field path")}),e.jsxs("label",{className:"nice-view-editor__chk",children:[e.jsx("input",{type:"checkbox",checked:!!o?.twoWay,onChange:u=>c({twoWay:u.target.checked})}),s("viewEditor.cp.twoWay","Two-way")]}),e.jsx("div",{className:"nice-view-editor__panel-sub",children:s("viewEditor.cp.permissions","Permissions")}),m.map((u,x)=>e.jsxs("div",{className:"nice-view-editor__perm",children:[e.jsx("input",{className:"nice-view-editor__in",value:u.role,placeholder:s("viewEditor.cp.role","role"),onChange:f=>h(m.map((b,g)=>g===x?{...b,role:f.target.value}:b))}),e.jsx("select",{className:"nice-view-editor__in",value:u.access,onChange:f=>h(m.map((b,g)=>g===x?{...b,access:f.target.value}:b)),children:Mf.map(f=>e.jsx("option",{value:f,children:f},f))}),e.jsx("button",{type:"button",onClick:()=>h(m.filter((f,b)=>b!==x)),"aria-label":s("viewEditor.remove","Remove"),children:e.jsx(l.NiceIcon,{name:"close",size:14})})]},x)),e.jsxs("button",{type:"button",className:"nice-view-editor__mini-add",onClick:()=>h([...m,{role:"*",access:"editable"}]),children:["+ ",s("viewEditor.cp.addPermission","Permission")]}),e.jsx("div",{className:"nice-view-editor__panel-sub",children:s("viewEditor.cp.events","Events")}),d.map((u,x)=>e.jsxs("div",{className:"nice-view-editor__event",children:[e.jsx("input",{className:"nice-view-editor__in",value:u.event,placeholder:s("viewEditor.cp.eventPlaceholder","event (onClick / onValueChange…)"),onChange:f=>p(d.map((b,g)=>g===x?{...b,event:f.target.value}:b))}),e.jsx(Zd,{value:u.actions,handlers:i,dataSources:n,onChange:f=>p(d.map((b,g)=>g===x?{...b,actions:f}:b))}),e.jsx("button",{type:"button",className:"nice-view-editor__mini-remove",onClick:()=>p(d.filter((f,b)=>b!==x)),children:s("viewEditor.cp.removeEvent","Remove event")})]},x)),e.jsxs("button",{type:"button",className:"nice-view-editor__mini-add",onClick:()=>p([...d,{event:"onClick",actions:[]}]),children:["+ ",s("viewEditor.cp.addEvent","Event")]})]})}function Hf({dataSources:t,onChange:n,queryOptions:i,entityNames:a}){const{t:s}=l.useNiceTranslation(),o=(d,p)=>n(t.map((m,h)=>h===d?{...m,...p}:m)),c=(d,p)=>d.type==="query"&&i&&i.length>0?e.jsxs("select",{className:"nice-view-editor__in",value:d.ref??"","aria-label":s("viewEditor.ds.ref","Module data source"),onChange:m=>o(p,{ref:m.target.value||void 0}),children:[e.jsx("option",{value:"",children:s("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:s("viewEditor.ds.ref","Module data source"),onChange:m=>o(p,{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":s("viewEditor.ds.entity","Entity"),onChange:m=>o(p,{entity:m.target.value||void 0}),children:[e.jsx("option",{value:"",children:s("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:s("viewEditor.ds.entity","Entity"),onChange:m=>o(p,{entity:m.target.value||void 0})}):e.jsx("input",{className:"nice-view-editor__in",value:d.endpoint??"",placeholder:s("viewEditor.ds.endpoint","endpoint"),onChange:m=>o(p,{endpoint:m.target.value})});return e.jsxs("div",{className:"nice-view-editor__panel",children:[e.jsx("div",{className:"nice-view-editor__panel-title",children:s("viewEditor.ds.title","Data sources")}),e.jsx("div",{className:"nice-view-editor__hint",children:s("viewEditor.ds.hint","Select a control to edit its props, binding & events.")}),t.map((d,p)=>e.jsxs("div",{className:"nice-view-editor__ds",children:[e.jsx("input",{className:"nice-view-editor__in",value:d.key,placeholder:s("viewEditor.ds.key","key"),onChange:m=>o(p,{key:m.target.value})}),e.jsx("select",{className:"nice-view-editor__in",value:d.type,onChange:m=>o(p,{type:m.target.value}),children:$f.map(m=>e.jsx("option",{value:m,children:m},m))}),c(d,p),e.jsxs("label",{className:"nice-view-editor__chk",children:[e.jsx("input",{type:"checkbox",checked:!!d.autoLoad,onChange:m=>o(p,{autoLoad:m.target.checked})}),s("viewEditor.ds.autoLoad","auto-load")]}),e.jsx("button",{type:"button",onClick:()=>n(t.filter((m,h)=>h!==p)),"aria-label":s("viewEditor.remove","Remove"),children:e.jsx(l.NiceIcon,{name:"close",size:14})})]},p)),e.jsxs("button",{type:"button",className:"nice-view-editor__mini-add",onClick:()=>n([...t,{key:`ds${t.length+1}`,type:"rest",autoLoad:!0}]),children:["+ ",s("viewEditor.ds.add","Data source")]})]})}const Gf="nice-view-editor-styles",Wf=`
1294
1294
  .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); }
1295
1295
  .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; }