@camstack/addon-admin-ui 1.2.700 → 1.2.701

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/assets/{AccessSection-DuhBff2I.js → AccessSection-CmGUVN2c.js} +1 -1
  3. package/dist/assets/{Addons-DkWR3gkq.js → Addons-CgCQDQsS.js} +1 -1
  4. package/dist/assets/{AdminPage-CyMuobXy.js → AdminPage-Dvziohv2.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-DiyrPcy9.js → AdminSectionedPage-3F0XiS4h.js} +1 -1
  6. package/dist/assets/{AiProfiles-DUZci2sf.js → AiProfiles-BAdfHll3.js} +1 -1
  7. package/dist/assets/{Archive-BumU9DOS.js → Archive-tBDnGn2J.js} +1 -1
  8. package/dist/assets/{BootstrapSettingsForm-CEkpZiEK.js → BootstrapSettingsForm-D5_YCsD2.js} +1 -1
  9. package/dist/assets/{Build-B0Su_s2L.js → Build-DgzW58SZ.js} +1 -1
  10. package/dist/assets/{Calendars-DsRFyTPC.js → Calendars-BzFF94EV.js} +1 -1
  11. package/dist/assets/{Cluster-D2qSEqhz.js → Cluster-Chna0Sjs.js} +1 -1
  12. package/dist/assets/{CompositionBlockEditor-BKG-rKjJ.js → CompositionBlockEditor-BUQTd-UR.js} +1 -1
  13. package/dist/assets/{CompositionEditorPage-8y0k5Nhe.js → CompositionEditorPage-BTvOMFXc.js} +1 -1
  14. package/dist/assets/{Data-D9LaQOXD.js → Data-Ge58RjOD.js} +1 -1
  15. package/dist/assets/{DeviceDetail-BxDpw3WU.js → DeviceDetail-C09lWDie.js} +1 -1
  16. package/dist/assets/{Devices-CDjecVeO.js → Devices-DsS5GkXt.js} +1 -1
  17. package/dist/assets/{EmbedDevicePage-BD6_HvMe.js → EmbedDevicePage-BkW36-q-.js} +1 -1
  18. package/dist/assets/{EmbedPlayerPage-Bf0oo9Q3.js → EmbedPlayerPage-BD43fNk-.js} +1 -1
  19. package/dist/assets/{History-CRvVI3U1.js → History-D-ERNFKB.js} +1 -1
  20. package/dist/assets/{Identity-CgqjNQVX.js → Identity-DXfvzQIG.js} +1 -1
  21. package/dist/assets/{InstancesTable-DcwQ5Z2U.js → InstancesTable-BzPfQPuA.js} +1 -1
  22. package/dist/assets/{IntegrationDetail-CTL_BNd5.js → IntegrationDetail-CEcOLviw.js} +1 -1
  23. package/dist/assets/{Integrations-DjE3kD95.js → Integrations-BOc2LGfc.js} +1 -1
  24. package/dist/assets/{Integrations-BWIZL8DT.js → Integrations-BgRTT3i6.js} +1 -1
  25. package/dist/assets/{Library-CnuFtxG7.js → Library-DUI94NI6.js} +1 -1
  26. package/dist/assets/{Locations-C5O5CcZV.js → Locations-DkcchiHh.js} +1 -1
  27. package/dist/assets/{Logs-BPEaFkcQ.js → Logs-DS49QhkO.js} +1 -1
  28. package/dist/assets/{MyAccess-DenZQPxt.js → MyAccess-TXMLevZM.js} +1 -1
  29. package/dist/assets/{Network-DWGrdbU2.js → Network-Dxm48n1Y.js} +1 -1
  30. package/dist/assets/{NewExportModal-Dn5qIfYF.js → NewExportModal-DQLl3C3Q.js} +1 -1
  31. package/dist/assets/{NodeAddonsSettingsPanel-C1h8YgnE.js → NodeAddonsSettingsPanel-H8ruMWFP.js} +1 -1
  32. package/dist/assets/{Notifications-RetD-vo3.js → Notifications-B44Sd1jg.js} +1 -1
  33. package/dist/assets/{PanelContent-CWdEuPnB.js → PanelContent-DnT2f8Cc.js} +1 -1
  34. package/dist/assets/{Pipeline-g9OrBU5t.js → Pipeline-XpW32I39.js} +1 -1
  35. package/dist/assets/{SessionsList-PpGdvCRu.js → SessionsList-D0tv-91a.js} +1 -1
  36. package/dist/assets/{Showroom-DSutXWcf.js → Showroom-BlMk46Us.js} +1 -1
  37. package/dist/assets/{StorageLocationsTable-eT6j45e1.js → StorageLocationsTable-13scCxNp.js} +1 -1
  38. package/dist/assets/{System-BbVT7aZV.js → System-CkjsA5xm.js} +1 -1
  39. package/dist/assets/{TemplateEditorDialog-CkVm64ab.js → TemplateEditorDialog-fJjZNx16.js} +1 -1
  40. package/dist/assets/{Terminal-jh3VZwwP.js → Terminal-BwEVkhLM.js} +1 -1
  41. package/dist/assets/{TrainingProviders-B0MPb6es.js → TrainingProviders-CPc4S7AF.js} +1 -1
  42. package/dist/assets/{Viewer-Fo86cc0-.js → Viewer-B4D9Uq2-.js} +1 -1
  43. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-rBseLAXs.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D6FI5YpS.js} +1 -1
  44. package/dist/assets/{assignment-candidates-tNcnUZOo.js → assignment-candidates-BfJhT0tz.js} +1 -1
  45. package/dist/assets/{authed-media-Dmn6VKYc.js → authed-media-ChKbSmi3.js} +1 -1
  46. package/dist/assets/{device-detail-CRi_SiN0.js → device-detail-CFJoqbEo.js} +1 -1
  47. package/dist/assets/{device-integration-icon-DigkwuPa.js → device-integration-icon-BwgC8WB_.js} +1 -1
  48. package/dist/assets/device-picker-model-CVOfqhXA.js +1 -0
  49. package/dist/assets/{hostInit-DKsMmBUL.js → hostInit-DO8vSCT5.js} +1 -1
  50. package/dist/assets/{index-BtSb3e7u.js → index-BN2PojUq.js} +3 -3
  51. package/dist/assets/{linked-devices-model-DfectUL6.js → linked-devices-model-bymuMeaF.js} +1 -1
  52. package/dist/assets/{mf-entry-bootstrap-0-3133e5cd.js → mf-entry-bootstrap-0-dc995488.js} +2 -2
  53. package/dist/assets/mount-CVOfqhXA.js +1 -0
  54. package/dist/assets/remoteEntry-CeXhbAxp.js +1 -0
  55. package/dist/assets/{src-CFKmxwYU.js → src-C9_yKHH3.js} +1 -1
  56. package/dist/assets/{step-inspector-model-BTxke2pR.js → step-inspector-model-B_OOCp6Z.js} +1 -1
  57. package/dist/assets/{use-scenes-feed-BO3ulLXX.js → use-scenes-feed-D9kXSeA2.js} +1 -1
  58. package/dist/assets/{useAdminDeviceRemoval-DnSeZ4C8.js → useAdminDeviceRemoval-CF8lG06z.js} +1 -1
  59. package/dist/assets/useEventInvalidation-CVOfqhXA.js +1 -0
  60. package/dist/assets/{useNodeUrlSelection-B7z0eVw2.js → useNodeUrlSelection-ju70FIba.js} +1 -1
  61. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-COrdYohN.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BSgZU_Z3.js} +2 -2
  62. package/dist/index.html +4 -4
  63. package/dist/server/addon.js +1 -1
  64. package/package.json +2 -2
  65. package/dist/assets/device-picker-model-Ct4hIz-N.js +0 -1
  66. package/dist/assets/mount-Ct4hIz-N.js +0 -1
  67. package/dist/assets/remoteEntry-dUdMqzVb.js +0 -1
  68. package/dist/assets/useEventInvalidation-Ct4hIz-N.js +0 -1
@@ -1 +1 @@
1
- import{C as e,J as t,K as n,S as r,V as i,Y as a,et as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Qa as s,aa as c,fa as l,ft as u,hi as d,oa as f,sa as p}from"./player-overlays-D546iNTv.js";import{t as m}from"./chevron-down-CBb-F8DT.js";import{Bd as h,Gi as g,Ji as _,Ui as v,Wi as ee,Yi as y,Zs as b,pp as x,qi as S,xp as C}from"./src-CFKmxwYU.js";import{t as w}from"./i18n-HSlX-YO0.js";import{t as T}from"./useTranslation-BJr-n0es.js";function E(e){let{delayMs:t,invalidate:n,setTimeoutFn:r=setTimeout,clearTimeoutFn:i=clearTimeout}=e,a;function o(){a===void 0&&(a=r(()=>{a=void 0,n()},t))}function s(){a!==void 0&&(i(a),a=void 0)}return{trigger:o,cancel:s}}o();function D({cameras:n,selected:o,onChange:s}){let{t:c}=T(),[u,d]=a(!1),f=t(null);i(()=>{if(!u)return;function e(e){f.current&&e.target instanceof Node&&!f.current.contains(e.target)&&d(!1)}function t(e){e.key===`Escape`&&d(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[u]);function h(e){let t=new Set(o);t.has(e)?t.delete(e):t.add(e),s(t)}let g=o.size,_=g===0?`All cameras`:g===1?n.find(e=>o.has(e.id))?.name??`1 camera`:`${String(g)} cameras`;return e(`div`,{ref:f,className:`relative`,children:[e(x,{variant:`unstyled`,type:`button`,onClick:()=>d(e=>!e),disabled:n.length===0,className:`flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs transition-colors disabled:opacity-40 ${g>0?`border-primary/40 bg-primary/8 text-primary`:`border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[r(l,{className:`h-3.5 w-3.5`}),r(`span`,{className:`max-w-[10rem] truncate`,children:_}),r(m,{className:`h-3 w-3 opacity-70`})]}),u&&e(`div`,{className:`absolute left-0 z-30 mt-1 max-h-64 w-[min(15rem,calc(100vw-1.5rem))] overflow-y-auto rounded-md border border-border bg-surface p-1 shadow-lg shadow-black/30`,children:[g>0&&r(x,{variant:`unstyled`,type:`button`,onClick:()=>s(new Set),className:`mb-1 w-full rounded px-2 py-1 text-left text-[11px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:c(`detectionIntelligence.cameraMultiSelect.clearSelection`,`Clear selection`)}),n.map(t=>{let n=o.has(t.id);return e(x,{variant:`unstyled`,type:`button`,onClick:()=>h(t.id),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs transition-colors ${n?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[r(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border ${n?`border-primary bg-primary text-white`:`border-border`}`,children:n&&r(p,{className:`h-2.5 w-2.5`})}),r(`span`,{className:`truncate`,children:t.name})]},t.id)})]})]})}var O={fromMs:null,toMs:null},k=36e5,A=24*k;function j(e,t){switch(e){case`24h`:return{fromMs:t-A,toMs:null};case`7d`:return{fromMs:t-7*A,toMs:null};case`30d`:return{fromMs:t-30*A,toMs:null};case`all`:return O}}function M(e){return e.fromMs!==null||e.toMs!==null}function N(e,t){return M(t)?e.filter(e=>!(t.fromMs!==null&&e.timestamp<t.fromMs||t.toMs!==null&&e.timestamp>t.toMs)):[...e]}function P(e,t){return t.size===0?[...e]:e.filter(e=>t.has(e.deviceId))}function F(e){let t=new Set,n=[];for(let r of e)t.has(r.deviceId)||(t.add(r.deviceId),n.push(r.deviceId));return n}function I(e){if(!e)return null;let t=Date.parse(`${e}T00:00:00`);return Number.isNaN(t)?null:t}function L(e){if(!e)return null;let t=Date.parse(`${e}T23:59:59.999`);return Number.isNaN(t)?null:t}function R(e,t){if(!Number.isFinite(e)||e<=0)return`—`;let n=t-e;return n<6e4?w.t(`helpers.relativeTime.justNow`):n<k?w.t(`helpers.relativeTime.minutesAgo`,{count:Math.floor(n/6e4)}):n<A?w.t(`helpers.relativeTime.hoursAgo`,{count:Math.floor(n/k)}):n<7*A?w.t(`helpers.relativeTime.daysAgo`,{count:Math.floor(n/A)}):new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function z(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function B(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}o();var V=[{label:`24h`,value:`24h`},{label:`7d`,value:`7d`},{label:`30d`,value:`30d`},{labelKey:`common.all`,value:`all`}];function H({onChange:t}){let{t:n}=T(),[i,o]=a(`all`),[s,c]=a(``),[l,u]=a(``);function d(e){o(e),c(``),u(``),t(j(e,Date.now()))}function f(e,n){o(`custom`),c(e),u(n),t({fromMs:I(e),toMs:L(n)})}let p=`rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground outline-none focus:border-primary [color-scheme:light] dark:[color-scheme:dark]`;return e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[r(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:V.map(e=>r(x,{variant:`unstyled`,type:`button`,onClick:()=>d(e.value),className:`rounded px-2.5 py-1 text-[11px] transition-colors ${i===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.labelKey===void 0?e.label:n(e.labelKey)},e.value))}),e(`div`,{className:`flex items-center gap-1`,children:[r(C,{type:`date`,"aria-label":n(`detectionIntelligence.dateRangeFilter.fromDate`,`From date`),value:s,max:l||void 0,onChange:e=>f(e.target.value,l),className:`${p} ${i===`custom`&&s?`border-primary/50`:``}`}),r(`span`,{className:`text-[11px] text-foreground-subtle`,children:`→`}),r(C,{type:`date`,"aria-label":n(`detectionIntelligence.dateRangeFilter.toDate`,`To date`),value:l,min:s||void 0,onChange:e=>f(s,e.target.value),className:`${p} ${i===`custom`&&l?`border-primary/50`:``}`})]})]})}o();var U=2.6;function W({src:t,alt:n,className:o,overlay:s,fit:c=`contain`}){let[l,u]=a(!1),[d,f]=a(`50% 50%`);i(()=>{u(!1),f(`50% 50%`)},[t]);function p(e){if(!l){let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*100,r=(e.clientY-t.top)/t.height*100;f(`${String(n)}% ${String(r)}%`)}u(e=>!e)}let m=c===`natural`;return r(`div`,{className:`relative overflow-hidden bg-background ${o??``}`,onClick:p,children:e(`div`,{className:`relative select-none transition-transform duration-200 ease-out ${m?`w-full`:`h-full w-full`} ${l?`cursor-zoom-out`:`cursor-zoom-in`}`,style:{transformOrigin:d,transform:l?`scale(${String(U)})`:`scale(1)`},children:[r(`img`,{src:t,alt:n,draggable:!1,className:m?`block h-auto w-full object-contain`:`h-full w-full object-contain`}),s]})})}var G=2;function K(e,t){if(t<=1)return[{kind:`page`,n:1}];if(t<=7){let e=[];for(let n=1;n<=t;n++)e.push({kind:`page`,n});return e}let n=[],r=Math.max(2,e-G),i=Math.min(t-1,e+G);n.push({kind:`page`,n:1}),r>2&&n.push({kind:`ellipsis`,side:`left`});for(let e=r;e<=i;e++)n.push({kind:`page`,n:e});return i<t-1&&n.push({kind:`ellipsis`,side:`right`}),n.push({kind:`page`,n:t}),n}function q({currentPage:t,totalItems:n,pageSize:i,onPageChange:a,itemNoun:o=`items`}){let{t:s}=T();if(n<=i)return null;let l=Math.ceil(n/i),u=(t-1)*i+1,d=Math.min(t*i,n),p=K(t,l),m=`inline-flex h-7 min-w-7 items-center justify-center rounded-md px-2 text-[11px] transition-colors disabled:opacity-40`;return e(`div`,{className:`flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:s(`galleryPager.showing`,{from:u,to:d,total:n,noun:o})}),e(`div`,{className:`flex items-center gap-1`,children:[r(x,{variant:`unstyled`,type:`button`,className:`${m} hover:bg-surface-hover`,onClick:()=>a(t-1),disabled:t<=1,"aria-label":s(`galleryPager.previousPage`,`Previous page`),children:r(f,{className:`h-3.5 w-3.5`})}),p.map(e=>e.kind===`ellipsis`?r(`span`,{className:`px-1 opacity-60`,children:`…`},`ellipsis-${e.side}`):r(x,{variant:`unstyled`,type:`button`,className:`${m} ${e.n===t?`bg-primary/12 text-primary font-medium`:`hover:bg-surface-hover hover:text-foreground`}`,onClick:()=>a(e.n),"aria-current":e.n===t?`page`:void 0,children:e.n},e.n)),r(x,{variant:`unstyled`,type:`button`,className:`${m} hover:bg-surface-hover`,onClick:()=>a(t+1),disabled:t>=l,"aria-label":s(`galleryPager.nextPage`,`Next page`),children:r(c,{className:`h-3.5 w-3.5`})})]})]})}o();function J(e,t,r){let[o,s]=a(1);i(()=>{s(1)},[r]);let c=e.length,l=Math.max(1,Math.ceil(c/t)),u=Math.min(o,l);return i(()=>{u!==o&&s(u)},[u,o]),{page:u,setPage:s,pageItems:n(()=>{let n=(u-1)*t;return e.slice(n,n+t)},[e,u,t]),totalPages:l,totalItems:c,pageSize:t}}o();var Y=[`high`,`mid`,`low`],X=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],Z=10080*60*1e3;function Q(e){return $(Date.now()-e*6e4)}function $(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function te({onClose:t,onCreated:i,initialDeviceId:o,initialRange:c}){let{t:l}=T(),f=b({isCamera:!0,projection:`slim`}),p=n(()=>(f.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[f.data]),[m,w]=a(o??``),[E,D]=a(`high`),[O,k]=a(c===void 0?Q(60):$(c.fromMs)),[A,j]=a(c===void 0?Q(0):$(c.toMs)),[M,N]=a(1),[P,F]=a(!0),[I,L]=a(``),[R,z]=a(null),B=m===``?p[0]?.id??null:m,V=new Date(O).getTime(),H=new Date(A).getTime(),U=Number.isFinite(V)&&Number.isFinite(H)&&V<H,W=h({onSuccess:()=>{i(),t()},onError:e=>z(e instanceof Error?e.message:String(e))});return r(v,{open:!0,onOpenChange:e=>!e&&t(),children:e(g,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(_,{children:e(y,{className:`flex items-center gap-1.5`,children:[r(d,{className:`h-3.5 w-3.5`}),l(`recordings.newExportModal.newExport`,`New export`)]})}),e(ee,{className:`space-y-3`,children:[e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:l(`recordings.newExportModal.camera`,`Camera`)}),r(u,{value:B??``,onChange:e=>w(Number(e.target.value)),className:`w-full`,children:p.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:l(`recordings.newExportModal.profile`,`Profile`)}),r(u,{value:E,onChange:e=>D(e.target.value),className:`w-full`,children:Y.map(e=>r(`option`,{value:e,children:e},e))})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:l(`recordings.newExportModal.from`,`From`)}),r(C,{type:`datetime-local`,value:O,onChange:e=>k(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:l(`recordings.newExportModal.to`,`To`)}),r(C,{type:`datetime-local`,value:A,onChange:e=>j(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:l(`recordings.newExportModal.speed`,`Speed`)}),r(u,{value:M,onChange:e=>N(Number(e.target.value)),className:`w-full`,children:X.map(e=>r(`option`,{value:e.value,children:e.labelKey===null?`${e.value}×`:l(e.labelKey)},e.value))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:l(`recordings.newExportModal.titleOptional`,`Title (optional)`)}),r(C,{type:`text`,value:I,onChange:e=>L(e.target.value),placeholder:l(`recordings.newExportModal.eGCourierAtThe`,`e.g. courier at the gate`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle`})]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[r(s,{checked:P,disabled:M!==1,onChange:e=>F(e.target.checked),className:`accent-primary`}),l(M===1?`recordings.newExportModal.includeAudio`:`recordings.newExportModal.includeAudioRealtimeOnly`)]}),!U&&r(`p`,{className:`text-[11px] text-danger`,children:l(`recordings.newExportModal.fromMustBeBeforeTo`,`"From" must be before "To".`)}),R&&r(`p`,{className:`text-[11px] text-danger`,children:R})]}),e(S,{children:[r(x,{variant:`outline`,size:`sm`,onClick:t,children:l(`common.cancel`,`Cancel`)}),r(x,{size:`sm`,onClick:()=>{if(B===null||!U)return;z(null);let e=I.trim();W.mutate({deviceId:B,profile:E,fromMs:V,toMs:H,options:{includeAudio:P,maxLifeMs:Z,deleteAfterDownload:!1,...M===1?{}:{speed:M},...e.length>0?{title:e}:{}}})},disabled:B===null||!U||W.isPending,children:W.isPending?l(`recordings.newExportModal.queuing`,`Queuing…`):l(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}export{H as a,P as c,R as d,B as f,W as i,N as l,E as m,J as n,O as o,D as p,q as r,F as s,te as t,z as u};
1
+ import{C as e,J as t,K as n,S as r,V as i,Y as a,et as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Qa as s,aa as c,fa as l,ft as u,hi as d,oa as f,sa as p}from"./player-overlays-D546iNTv.js";import{t as m}from"./chevron-down-CBb-F8DT.js";import{Bd as h,Gi as g,Ji as _,Ui as v,Wi as ee,Yi as y,Zs as b,pp as x,qi as S,xp as C}from"./src-C9_yKHH3.js";import{t as w}from"./i18n-HSlX-YO0.js";import{t as T}from"./useTranslation-BJr-n0es.js";function E(e){let{delayMs:t,invalidate:n,setTimeoutFn:r=setTimeout,clearTimeoutFn:i=clearTimeout}=e,a;function o(){a===void 0&&(a=r(()=>{a=void 0,n()},t))}function s(){a!==void 0&&(i(a),a=void 0)}return{trigger:o,cancel:s}}o();function D({cameras:n,selected:o,onChange:s}){let{t:c}=T(),[u,d]=a(!1),f=t(null);i(()=>{if(!u)return;function e(e){f.current&&e.target instanceof Node&&!f.current.contains(e.target)&&d(!1)}function t(e){e.key===`Escape`&&d(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[u]);function h(e){let t=new Set(o);t.has(e)?t.delete(e):t.add(e),s(t)}let g=o.size,_=g===0?`All cameras`:g===1?n.find(e=>o.has(e.id))?.name??`1 camera`:`${String(g)} cameras`;return e(`div`,{ref:f,className:`relative`,children:[e(x,{variant:`unstyled`,type:`button`,onClick:()=>d(e=>!e),disabled:n.length===0,className:`flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs transition-colors disabled:opacity-40 ${g>0?`border-primary/40 bg-primary/8 text-primary`:`border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[r(l,{className:`h-3.5 w-3.5`}),r(`span`,{className:`max-w-[10rem] truncate`,children:_}),r(m,{className:`h-3 w-3 opacity-70`})]}),u&&e(`div`,{className:`absolute left-0 z-30 mt-1 max-h-64 w-[min(15rem,calc(100vw-1.5rem))] overflow-y-auto rounded-md border border-border bg-surface p-1 shadow-lg shadow-black/30`,children:[g>0&&r(x,{variant:`unstyled`,type:`button`,onClick:()=>s(new Set),className:`mb-1 w-full rounded px-2 py-1 text-left text-[11px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:c(`detectionIntelligence.cameraMultiSelect.clearSelection`,`Clear selection`)}),n.map(t=>{let n=o.has(t.id);return e(x,{variant:`unstyled`,type:`button`,onClick:()=>h(t.id),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs transition-colors ${n?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[r(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border ${n?`border-primary bg-primary text-white`:`border-border`}`,children:n&&r(p,{className:`h-2.5 w-2.5`})}),r(`span`,{className:`truncate`,children:t.name})]},t.id)})]})]})}var O={fromMs:null,toMs:null},k=36e5,A=24*k;function j(e,t){switch(e){case`24h`:return{fromMs:t-A,toMs:null};case`7d`:return{fromMs:t-7*A,toMs:null};case`30d`:return{fromMs:t-30*A,toMs:null};case`all`:return O}}function M(e){return e.fromMs!==null||e.toMs!==null}function N(e,t){return M(t)?e.filter(e=>!(t.fromMs!==null&&e.timestamp<t.fromMs||t.toMs!==null&&e.timestamp>t.toMs)):[...e]}function P(e,t){return t.size===0?[...e]:e.filter(e=>t.has(e.deviceId))}function F(e){let t=new Set,n=[];for(let r of e)t.has(r.deviceId)||(t.add(r.deviceId),n.push(r.deviceId));return n}function I(e){if(!e)return null;let t=Date.parse(`${e}T00:00:00`);return Number.isNaN(t)?null:t}function L(e){if(!e)return null;let t=Date.parse(`${e}T23:59:59.999`);return Number.isNaN(t)?null:t}function R(e,t){if(!Number.isFinite(e)||e<=0)return`—`;let n=t-e;return n<6e4?w.t(`helpers.relativeTime.justNow`):n<k?w.t(`helpers.relativeTime.minutesAgo`,{count:Math.floor(n/6e4)}):n<A?w.t(`helpers.relativeTime.hoursAgo`,{count:Math.floor(n/k)}):n<7*A?w.t(`helpers.relativeTime.daysAgo`,{count:Math.floor(n/A)}):new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function z(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function B(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}o();var V=[{label:`24h`,value:`24h`},{label:`7d`,value:`7d`},{label:`30d`,value:`30d`},{labelKey:`common.all`,value:`all`}];function H({onChange:t}){let{t:n}=T(),[i,o]=a(`all`),[s,c]=a(``),[l,u]=a(``);function d(e){o(e),c(``),u(``),t(j(e,Date.now()))}function f(e,n){o(`custom`),c(e),u(n),t({fromMs:I(e),toMs:L(n)})}let p=`rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground outline-none focus:border-primary [color-scheme:light] dark:[color-scheme:dark]`;return e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[r(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:V.map(e=>r(x,{variant:`unstyled`,type:`button`,onClick:()=>d(e.value),className:`rounded px-2.5 py-1 text-[11px] transition-colors ${i===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.labelKey===void 0?e.label:n(e.labelKey)},e.value))}),e(`div`,{className:`flex items-center gap-1`,children:[r(C,{type:`date`,"aria-label":n(`detectionIntelligence.dateRangeFilter.fromDate`,`From date`),value:s,max:l||void 0,onChange:e=>f(e.target.value,l),className:`${p} ${i===`custom`&&s?`border-primary/50`:``}`}),r(`span`,{className:`text-[11px] text-foreground-subtle`,children:`→`}),r(C,{type:`date`,"aria-label":n(`detectionIntelligence.dateRangeFilter.toDate`,`To date`),value:l,min:s||void 0,onChange:e=>f(s,e.target.value),className:`${p} ${i===`custom`&&l?`border-primary/50`:``}`})]})]})}o();var U=2.6;function W({src:t,alt:n,className:o,overlay:s,fit:c=`contain`}){let[l,u]=a(!1),[d,f]=a(`50% 50%`);i(()=>{u(!1),f(`50% 50%`)},[t]);function p(e){if(!l){let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*100,r=(e.clientY-t.top)/t.height*100;f(`${String(n)}% ${String(r)}%`)}u(e=>!e)}let m=c===`natural`;return r(`div`,{className:`relative overflow-hidden bg-background ${o??``}`,onClick:p,children:e(`div`,{className:`relative select-none transition-transform duration-200 ease-out ${m?`w-full`:`h-full w-full`} ${l?`cursor-zoom-out`:`cursor-zoom-in`}`,style:{transformOrigin:d,transform:l?`scale(${String(U)})`:`scale(1)`},children:[r(`img`,{src:t,alt:n,draggable:!1,className:m?`block h-auto w-full object-contain`:`h-full w-full object-contain`}),s]})})}var G=2;function K(e,t){if(t<=1)return[{kind:`page`,n:1}];if(t<=7){let e=[];for(let n=1;n<=t;n++)e.push({kind:`page`,n});return e}let n=[],r=Math.max(2,e-G),i=Math.min(t-1,e+G);n.push({kind:`page`,n:1}),r>2&&n.push({kind:`ellipsis`,side:`left`});for(let e=r;e<=i;e++)n.push({kind:`page`,n:e});return i<t-1&&n.push({kind:`ellipsis`,side:`right`}),n.push({kind:`page`,n:t}),n}function q({currentPage:t,totalItems:n,pageSize:i,onPageChange:a,itemNoun:o=`items`}){let{t:s}=T();if(n<=i)return null;let l=Math.ceil(n/i),u=(t-1)*i+1,d=Math.min(t*i,n),p=K(t,l),m=`inline-flex h-7 min-w-7 items-center justify-center rounded-md px-2 text-[11px] transition-colors disabled:opacity-40`;return e(`div`,{className:`flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:s(`galleryPager.showing`,{from:u,to:d,total:n,noun:o})}),e(`div`,{className:`flex items-center gap-1`,children:[r(x,{variant:`unstyled`,type:`button`,className:`${m} hover:bg-surface-hover`,onClick:()=>a(t-1),disabled:t<=1,"aria-label":s(`galleryPager.previousPage`,`Previous page`),children:r(f,{className:`h-3.5 w-3.5`})}),p.map(e=>e.kind===`ellipsis`?r(`span`,{className:`px-1 opacity-60`,children:`…`},`ellipsis-${e.side}`):r(x,{variant:`unstyled`,type:`button`,className:`${m} ${e.n===t?`bg-primary/12 text-primary font-medium`:`hover:bg-surface-hover hover:text-foreground`}`,onClick:()=>a(e.n),"aria-current":e.n===t?`page`:void 0,children:e.n},e.n)),r(x,{variant:`unstyled`,type:`button`,className:`${m} hover:bg-surface-hover`,onClick:()=>a(t+1),disabled:t>=l,"aria-label":s(`galleryPager.nextPage`,`Next page`),children:r(c,{className:`h-3.5 w-3.5`})})]})]})}o();function J(e,t,r){let[o,s]=a(1);i(()=>{s(1)},[r]);let c=e.length,l=Math.max(1,Math.ceil(c/t)),u=Math.min(o,l);return i(()=>{u!==o&&s(u)},[u,o]),{page:u,setPage:s,pageItems:n(()=>{let n=(u-1)*t;return e.slice(n,n+t)},[e,u,t]),totalPages:l,totalItems:c,pageSize:t}}o();var Y=[`high`,`mid`,`low`],X=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],Z=10080*60*1e3;function Q(e){return $(Date.now()-e*6e4)}function $(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function te({onClose:t,onCreated:i,initialDeviceId:o,initialRange:c}){let{t:l}=T(),f=b({isCamera:!0,projection:`slim`}),p=n(()=>(f.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[f.data]),[m,w]=a(o??``),[E,D]=a(`high`),[O,k]=a(c===void 0?Q(60):$(c.fromMs)),[A,j]=a(c===void 0?Q(0):$(c.toMs)),[M,N]=a(1),[P,F]=a(!0),[I,L]=a(``),[R,z]=a(null),B=m===``?p[0]?.id??null:m,V=new Date(O).getTime(),H=new Date(A).getTime(),U=Number.isFinite(V)&&Number.isFinite(H)&&V<H,W=h({onSuccess:()=>{i(),t()},onError:e=>z(e instanceof Error?e.message:String(e))});return r(v,{open:!0,onOpenChange:e=>!e&&t(),children:e(g,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(_,{children:e(y,{className:`flex items-center gap-1.5`,children:[r(d,{className:`h-3.5 w-3.5`}),l(`recordings.newExportModal.newExport`,`New export`)]})}),e(ee,{className:`space-y-3`,children:[e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:l(`recordings.newExportModal.camera`,`Camera`)}),r(u,{value:B??``,onChange:e=>w(Number(e.target.value)),className:`w-full`,children:p.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:l(`recordings.newExportModal.profile`,`Profile`)}),r(u,{value:E,onChange:e=>D(e.target.value),className:`w-full`,children:Y.map(e=>r(`option`,{value:e,children:e},e))})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:l(`recordings.newExportModal.from`,`From`)}),r(C,{type:`datetime-local`,value:O,onChange:e=>k(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:l(`recordings.newExportModal.to`,`To`)}),r(C,{type:`datetime-local`,value:A,onChange:e=>j(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:l(`recordings.newExportModal.speed`,`Speed`)}),r(u,{value:M,onChange:e=>N(Number(e.target.value)),className:`w-full`,children:X.map(e=>r(`option`,{value:e.value,children:e.labelKey===null?`${e.value}×`:l(e.labelKey)},e.value))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:l(`recordings.newExportModal.titleOptional`,`Title (optional)`)}),r(C,{type:`text`,value:I,onChange:e=>L(e.target.value),placeholder:l(`recordings.newExportModal.eGCourierAtThe`,`e.g. courier at the gate`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle`})]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[r(s,{checked:P,disabled:M!==1,onChange:e=>F(e.target.checked),className:`accent-primary`}),l(M===1?`recordings.newExportModal.includeAudio`:`recordings.newExportModal.includeAudioRealtimeOnly`)]}),!U&&r(`p`,{className:`text-[11px] text-danger`,children:l(`recordings.newExportModal.fromMustBeBeforeTo`,`"From" must be before "To".`)}),R&&r(`p`,{className:`text-[11px] text-danger`,children:R})]}),e(S,{children:[r(x,{variant:`outline`,size:`sm`,onClick:t,children:l(`common.cancel`,`Cancel`)}),r(x,{size:`sm`,onClick:()=>{if(B===null||!U)return;z(null);let e=I.trim();W.mutate({deviceId:B,profile:E,fromMs:V,toMs:H,options:{includeAudio:P,maxLifeMs:Z,deleteAfterDownload:!1,...M===1?{}:{speed:M},...e.length>0?{title:e}:{}}})},disabled:B===null||!U||W.isPending,children:W.isPending?l(`recordings.newExportModal.queuing`,`Queuing…`):l(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}export{H as a,P as c,R as d,B as f,W as i,N as l,E as m,J as n,O as o,D as p,q as r,F as s,te as t,z as u};
@@ -1 +1 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,W as o,Y as s,et as c,i as l,j as u,o as d,p as f,t as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{yt as m}from"./player-overlays-D546iNTv.js";import{$c as h,Qc as g}from"./client-DQzHwaNb.js";import{Mo as _,_s as v,at as y,do as ee,eo as te,pp as b,to as ne}from"./src-CFKmxwYU.js";import{t as re}from"./useTranslation-BJr-n0es.js";import{M as ie,N as ae,P as x,Vt as S}from"./index-BtSb3e7u.js";import{n as oe,t as se}from"./settings-section-shape-DbQZZpNL.js";c();var C=u(function({addonId:e,schema:s,serverValues:c,onImmediateSave:l,onStateChange:u,onAction:d,disabled:f},p){let m=x({schema:s,serverValues:c,onImmediateSave:r(t=>l(e,t),[e,l]),onDeferredSave:r(()=>{},[])});o(p,()=>({flush:()=>{let e={};for(let t of m.pendingKeys)e[t]=m.values[t];return m.handleDiscard(m.pendingKeys),e},discard:()=>m.resetAll()}),[m]);let h=m.pendingKeys,g=h.join(`|`),_=n(()=>h.map(e=>`${e}=${JSON.stringify(m.values[e])}`).join(`,`),[h,m.values]),v=t(u);a(()=>{v.current=u},[u]),a(()=>{let t={};for(let e of h)t[e]=m.values[e];v.current({addonId:e,pendingKeys:h,pendingValues:t})},[e,g,_]);let y=n(()=>{if(d)return(t,n,r)=>d(e,t,n,r)},[e,d]);return i(S,{schema:s,values:m.values,onChange:m.handleChange,disabled:f,onAction:y})});function w(e){return`perNode`in e&&e.perNode===!0}function T(e,t){if(e.type===`group`){let n=E(e.fields,t);return n.length>0?{...e,fields:n}:null}if(e.type===`sub-tabs`){let n=e.tabs.map(e=>({...e,fields:E(e.fields,t)})).filter(e=>e.fields.length>0);return n.length>0?{...e,tabs:n}:null}return w(e)===(t===`perNode`)?e:null}function E(e,t){let n=[];for(let r of e){let e=T(r,t);e!==null&&n.push(e)}return n}function ce(e,t){let n=[];for(let r of e.sections){let e=E(r.fields,t);e.length!==0&&n.push({...r,fields:e})}return{...e,sections:n}}function D(e,t){return t===void 0?!0:t===`perNode`?e===`node`:e!==`node`}function le(e){let t=e.allowSectionIds?new Set(e.allowSectionIds):null,n=e.omitSectionIds?new Set(e.omitSectionIds):null,r=new Set,i=[];for(let a of e.declarations){if(!D(a.scope,e.fieldScope)||e.capability!==void 0&&a.cap!==e.capability)continue;let o=a.sectionIds.filter(e=>r.has(e)||(r.add(e),t!==null&&!t.has(e))?!1:n===null||!n.has(e));o.length>0&&i.push({cap:a.cap,scope:a.scope,sectionIds:o})}return i}function ue(e){let t=[],n=new Map,r={};for(let{declaration:i,form:a}of e){let e=new Set(i.sectionIds),o=a.sections.filter(t=>e.has(t.id));t.push(...o);for(let e of a.tabs??[])n.has(e.id)||n.set(e.id,e);for(let e of h({sections:o}).keys()){let t=r[e]??[];t.push({cap:i.cap,scope:i.scope}),r[e]=t}}return{form:{...n.size>0?{tabs:[...n.values()]}:{},sections:t},keyTargets:r}}function de(e,t){let n=new Map,r=[];for(let[i,a]of Object.entries(e)){let e=t[i];if(e===void 0||e.length===0){r.push(i);continue}for(let t of e){let e=`${t.cap}\u0000${t.scope}`,r=n.get(e)??{target:t,patch:{}};r.patch[i]=a,n.set(e,r)}}return{groups:[...n.values()].map(e=>({...e.target,patch:e.patch})),unowned:r}}c();function O(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>O(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function k(e,t){return{...e,fields:e.fields.map(e=>O(e,t))}}function fe(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>k(e,t))},values:t}}function A({nodeId:a,addonIds:o,level:c,deviceId:u,capability:h,omitCapabilities:b,sectionIds:x,omitSectionIds:S,fieldKeys:C,omitFieldKeys:w,hideSectionChrome:T,tabAliases:E,tabLabelOverrides:D,sectionTab:O,fieldScope:k,emptyMessage:A,extraTabs:j,schemaTabExtras:M,title:N,description:P,selfTabbed:me,activeTab:he,onActiveTabChange:ge}){let{t:F}=re(),I=d(),L=m().trpcClient,_e=ne(),ve=te(),ye=v(),be=_(),R=me===!0||!!(j&&j.length>0),[xe,Se]=s(null);if(c===`device`&&!u)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let z=a??`hub`,B=l({queries:o.map(e=>({queryKey:[[`addonSettings`,c===`global`?`listScopedSettings`:`getDeviceSettings`],{addonId:e,nodeId:z,deviceId:u??null,cap:h??null,omitCaps:b??null,scope:k??null,sections:[x??null,S??null]}],queryFn:async()=>{if(c===`global`){let t=await L.addonSettings.listScopedSettings.query({addonId:e,nodeId:z});if(t===null)return{addonId:e,result:null,keyTargets:{}};let n=new Set(b??[]),r=le({declarations:t.filter(e=>!n.has(e.cap)),...k===void 0?{}:{fieldScope:k},...h===void 0?{}:{capability:h},...x===void 0?{}:{allowSectionIds:x},...S===void 0?{}:{omitSectionIds:S}}),i=await Promise.all(r.map(async t=>{let n=await L.addonSettings.getScopedSettings.query({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:z}:{}});return n===null?null:{declaration:t,form:n}})),a=i.filter(e=>e!==null);if(a.length!==i.length)return{addonId:e,result:null,keyTargets:{}};let o=ue(a);return{addonId:e,result:o.form,keyTargets:o.keyTargets}}let t=await L.addonSettings.getDeviceSettings.query({addonId:e,deviceId:u,nodeId:z});return{addonId:e,result:t!==null&&k!==void 0?ce(t,k):t,keyTargets:{}}},placeholderData:f}))}),Ce=B.some(e=>e.isLoading),V=B.map(e=>{if(!e.data)return`-`;if(e.data.result===null)return`${e.data.addonId}:n`;let t=[];for(let n of e.data.result.sections){t.push(`s:${n.id}:${n.tab??`general`}`);for(let e of n.fields){if(!(`key`in e))continue;let n=`options`in e&&Array.isArray(e.options)?e.options.map(e=>e.value).join(`,`):``,r=e.value,i=r===void 0?``:typeof r==`string`?r:JSON.stringify(r);t.push(`f:${e.key}:${n}:${i}`)}}return`${e.data.addonId}:${t.join(`|`)}`}).join(`||`),H=n(()=>{let e=new Set;for(let t of B){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(oe(t.tab,E))}return[...e]},[E,V+`::`+B.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),U=n(()=>new Map((j??[]).map(e=>[e.id,e])),[j]),W=n(()=>{if(!R)return[];let e=[...new Set([...H,...(j??[]).map(e=>e.id),...(M??[]).map(e=>e.tabId)])],t=e=>{let t=U.get(e);if(t?.order!==void 0)return t.order;let n=g[e];return n?n.order:50};return e.toSorted((e,n)=>{let r=t(e),i=t(n);return r===i?e.localeCompare(n):r-i})},[R,H,j,U,M]),we=n(()=>{let e=new Map,t=e=>g[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of H)e.set(n,t(n));for(let n of M??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of j??[])e.set(t.id,t.label);for(let[t,n]of Object.entries(D??{}))e.set(t,n);return e},[H,j,M,D]),G=he===void 0?xe:he,K=R?G&&W.includes(G)?G:W[0]??null:null,Te=e=>{Se(e),ge?.(e)},Ee=K!==null&&U.has(K),q=R?K&&!Ee?K:void 0:O,{data:De}=ee(void 0),Oe=n(()=>{let e=new Map;for(let t of De??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[De]),J=t(new Map),Y=n(()=>{let e=x?new Set(x):null,t=S?new Set(S):null,n=n=>!(e!==null&&!e.has(n)||t!==null&&t.has(n)),r=[];for(let e of B){if(!e.data)continue;e.data.result!==null&&J.current.set(e.data.addonId,{result:e.data.result,keyTargets:e.data.keyTargets});let t=J.current.get(e.data.addonId)??null;if(t===null)continue;let{result:i,keyTargets:a}=t,{schema:o,values:s}=fe(i),c={...C===void 0?{}:{fieldKeys:C},...w===void 0?{}:{omitFieldKeys:w},...T===void 0?{}:{hideSectionChrome:T},...E===void 0?{}:{tabAliases:E}},l=se(o.sections.filter(e=>n(e.id)),c);if(l.length===0)continue;let u={...i,sections:se(i.sections.filter(e=>n(e.id)),c)},d={...o,sections:l};r.push({addonId:e.data.addonId,schemaWithValues:u,schema:d,serverValues:s,keyTargets:a})}return r},[V,x,S,C,w,T,E]),ke=n(()=>B.flatMap(e=>c===`global`&&e.data!==void 0&&e.data.result===null&&!J.current.has(e.data.addonId)?[e.data.addonId]:[]),[V,c]),[X,Ae]=s(new Map),je=r(e=>{Ae(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),Z=t(new Map),Me=r(e=>t=>{t?Z.current.set(e,t):Z.current.delete(e)},[]),Q=r(async(e,t)=>{if(c!==`global`){await ve.mutateAsync({addonId:e,deviceId:u,nodeId:z,patch:t});return}let{groups:n,unowned:r}=de(t,Y.find(t=>t.addonId===e)?.keyTargets??{});if(r.length>0)throw Error(`${e}: no scoped setting declares ${r.join(`, `)}`);let i=(await Promise.allSettled(n.map(t=>_e.mutateAsync({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:z}:{},patch:t.patch})))).flatMap((e,t)=>{let r=n[t];if(e.status!==`rejected`||r===void 0)return[];let i=e.reason instanceof Error?e.reason.message:String(e.reason);return[`${r.cap}/${r.scope}: ${i}`]});if(i.length>0)throw I.invalidateQueries({queryKey:[[`addonSettings`]]}),Error(`${e}: not saved to ${i.join(`; `)}`)},[c,Y,_e,ve,I,z,u]),Ne=r(async(e,t)=>{await Q(e,t),I.invalidateQueries({queryKey:[[`addonSettings`]]})},[Q,I]),Pe=r(async(e,t,n,r)=>{let i=z;try{switch(t){case`reprobe-hwaccel`:await ye.mutateAsync({nodeId:i}),I.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await be.mutateAsync({nodeId:i}),I.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await L.addons.custom.mutate({addonId:e,action:t,input:r});return I.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[ye,be,z,I,L]),Fe=r((e,t)=>{Ne(e,t)},[Ne]),$=p({mutationFn:async()=>{let e=[];for(let t of Y){let n=X.get(t.addonId);!n||n.pendingKeys.length===0||e.push({addonId:t.addonId,patch:n.pendingValues})}return e.length===0?{saved:[]}:{saved:await Promise.all(e.map(async({addonId:e,patch:t})=>(await Q(e,t),e)))}},onSuccess:({saved:e})=>{for(let t of e)Z.current.get(t)?.discard();I.invalidateQueries({queryKey:[[`addonSettings`]]})}}),Ie=r(()=>{for(let e of Z.current.values())e.discard()},[]),Le=n(()=>{let e=0;for(let t of Y){let n=X.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[Y,X]),Re=n(()=>{let e=new Map;for(let t of Y){let n=X.get(t.addonId);if(!n||n.pendingKeys.length===0)continue;let r=new Set(n.pendingKeys);for(let n of t.schema.sections){let t=n.tab??`general`;for(let i of n.fields)`key`in i&&r.has(i.key)&&e.set(t,(e.get(t)??0)+1)}}return e},[Y,X]);if(Ce)return i(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let ze=K&&Ee?U.get(K):void 0,Be=ke.length>0?i(`div`,{className:`space-y-1 text-[11px] text-foreground-subtle`,role:`status`,children:ke.map(e=>i(`div`,{children:F(`settings.nodeAddonsSettingsPanel.addonUnavailable`,`{{name}} not available.`,{name:Oe.get(e)??e})},e))}):null;if(!R&&Y.length===0)return Be===null?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:A??F(`settings.nodeAddonsSettingsPanel.noAddonsIn`,{scope:o.length>0?`[${o.join(`, `)}]`:F(`settings.nodeAddonsSettingsPanel.theCurrentSelection`,`the current selection`),level:c})}):Be;let Ve=$.isPending;return e(`div`,{className:`space-y-4`,children:[(N||P)&&e(`div`,{className:`border-b border-border pb-2`,children:[N&&i(`h2`,{className:`text-sm font-semibold text-foreground`,children:N}),P&&i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:P})]}),Y.length>0||R?Be:null,R&&i(ie,{tabs:W.map(e=>({id:e,label:we.get(e)??e})),activeId:K,onChange:Te,pendingByTab:Re}),$.isError&&e(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[F(`settings.nodeAddonsSettingsPanel.saveFailed`,`Save failed:`),` `,String($.error?.message??$.error)]}),i(y,{tabKey:ze?`extra:${K??``}`:`tab:${K??``}`,children:ze?ze.content:(()=>{let t=q?Y.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===q).length,0):0,n=!!q&&t<=1,r=Y.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>q?(e.tab??`general`)===q:!0).map(e=>n?{...e,title:``,description:void 0}:e)}})).filter(e=>e.renderedWithValues.sections.length>0).toSorted((e,t)=>{let n=e=>{let t=1/0;for(let n of e)typeof n.order==`number`&&n.order<t&&(t=n.order);return t},r=n(e.renderedWithValues.sections),i=n(t.renderedWithValues.sections);return r===i?0:r-i}),a=(M??[]).filter(e=>e.tabId===q),o=a.filter(e=>(e.placement??`before`)===`before`),s=a.filter(e=>e.placement===`after`);return r.length===0&&a.length===0?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:A??F(`settings.nodeAddonsSettingsPanel.nothingToConfigureHereFor`,`Nothing to configure here for this node.`)}):e(`div`,{className:`space-y-6`,children:[o.map((e,t)=>i(`div`,{children:e.content},`extra-before-${t}`)),r.length>0&&i(pe,{entries:r,paneStates:X,displayNames:Oe,disabled:Ve,setPaneRef:Me,onPaneStateChange:je,onImmediateSave:Fe,onAction:Pe,inline:R||!!O}),s.map((e,t)=>i(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!Ce&&i(ae,{pendingCount:Le,onSave:()=>$.mutate(),onDiscard:Ie,saving:Ve})]})}function pe({entries:t,paneStates:r,displayNames:o,disabled:c,setPaneRef:l,onPaneStateChange:u,onImmediateSave:d,onAction:f,inline:p}){let m=n(()=>[...t].toSorted((e,t)=>{let n=o.get(e.addonId)??e.addonId,r=o.get(t.addonId)??t.addonId;return n.localeCompare(r)}),[t,o]),[h,g]=s(m[0]?.addonId??``);a(()=>{m.length!==0&&(m.find(e=>e.addonId===h)||g(m[0].addonId))},[m,h]);let _=m.find(e=>e.addonId===h)??m[0];if(!_)return null;let v=n(()=>f?(e,t,n,r)=>f(e,t,n,r):void 0,[f]),y=e=>i(C,{ref:l(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:d,onStateChange:u,onAction:v,disabled:c},e.addonId);return m.length===1||p?i(`div`,{className:`flex flex-col gap-4`,children:m.map(y)}):e(`div`,{className:`flex flex-col gap-3`,children:[i(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:m.map(t=>{let n=o.get(t.addonId)??t.addonId,a=t.addonId===_.addonId,s=(r.get(t.addonId)?.pendingKeys.length??0)>0;return e(b,{variant:`unstyled`,type:`button`,onClick:()=>g(t.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[n,s&&i(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},t.addonId)})}),i(`div`,{className:`space-y-2`,children:m.map(e=>i(`div`,{style:e.addonId===_.addonId?void 0:{display:`none`},children:y(e)},e.addonId))})]})}export{A as t};
1
+ import{C as e,J as t,K as n,R as r,S as i,V as a,W as o,Y as s,et as c,i as l,j as u,o as d,p as f,t as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{yt as m}from"./player-overlays-D546iNTv.js";import{$c as h,Qc as g}from"./client-DQzHwaNb.js";import{Mo as _,_s as v,at as y,do as ee,eo as te,pp as b,to as ne}from"./src-C9_yKHH3.js";import{t as re}from"./useTranslation-BJr-n0es.js";import{M as ie,N as ae,P as x,Vt as S}from"./index-BN2PojUq.js";import{n as oe,t as se}from"./settings-section-shape-DbQZZpNL.js";c();var C=u(function({addonId:e,schema:s,serverValues:c,onImmediateSave:l,onStateChange:u,onAction:d,disabled:f},p){let m=x({schema:s,serverValues:c,onImmediateSave:r(t=>l(e,t),[e,l]),onDeferredSave:r(()=>{},[])});o(p,()=>({flush:()=>{let e={};for(let t of m.pendingKeys)e[t]=m.values[t];return m.handleDiscard(m.pendingKeys),e},discard:()=>m.resetAll()}),[m]);let h=m.pendingKeys,g=h.join(`|`),_=n(()=>h.map(e=>`${e}=${JSON.stringify(m.values[e])}`).join(`,`),[h,m.values]),v=t(u);a(()=>{v.current=u},[u]),a(()=>{let t={};for(let e of h)t[e]=m.values[e];v.current({addonId:e,pendingKeys:h,pendingValues:t})},[e,g,_]);let y=n(()=>{if(d)return(t,n,r)=>d(e,t,n,r)},[e,d]);return i(S,{schema:s,values:m.values,onChange:m.handleChange,disabled:f,onAction:y})});function w(e){return`perNode`in e&&e.perNode===!0}function T(e,t){if(e.type===`group`){let n=E(e.fields,t);return n.length>0?{...e,fields:n}:null}if(e.type===`sub-tabs`){let n=e.tabs.map(e=>({...e,fields:E(e.fields,t)})).filter(e=>e.fields.length>0);return n.length>0?{...e,tabs:n}:null}return w(e)===(t===`perNode`)?e:null}function E(e,t){let n=[];for(let r of e){let e=T(r,t);e!==null&&n.push(e)}return n}function ce(e,t){let n=[];for(let r of e.sections){let e=E(r.fields,t);e.length!==0&&n.push({...r,fields:e})}return{...e,sections:n}}function D(e,t){return t===void 0?!0:t===`perNode`?e===`node`:e!==`node`}function le(e){let t=e.allowSectionIds?new Set(e.allowSectionIds):null,n=e.omitSectionIds?new Set(e.omitSectionIds):null,r=new Set,i=[];for(let a of e.declarations){if(!D(a.scope,e.fieldScope)||e.capability!==void 0&&a.cap!==e.capability)continue;let o=a.sectionIds.filter(e=>r.has(e)||(r.add(e),t!==null&&!t.has(e))?!1:n===null||!n.has(e));o.length>0&&i.push({cap:a.cap,scope:a.scope,sectionIds:o})}return i}function ue(e){let t=[],n=new Map,r={};for(let{declaration:i,form:a}of e){let e=new Set(i.sectionIds),o=a.sections.filter(t=>e.has(t.id));t.push(...o);for(let e of a.tabs??[])n.has(e.id)||n.set(e.id,e);for(let e of h({sections:o}).keys()){let t=r[e]??[];t.push({cap:i.cap,scope:i.scope}),r[e]=t}}return{form:{...n.size>0?{tabs:[...n.values()]}:{},sections:t},keyTargets:r}}function de(e,t){let n=new Map,r=[];for(let[i,a]of Object.entries(e)){let e=t[i];if(e===void 0||e.length===0){r.push(i);continue}for(let t of e){let e=`${t.cap}\u0000${t.scope}`,r=n.get(e)??{target:t,patch:{}};r.patch[i]=a,n.set(e,r)}}return{groups:[...n.values()].map(e=>({...e.target,patch:e.patch})),unowned:r}}c();function O(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>O(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function k(e,t){return{...e,fields:e.fields.map(e=>O(e,t))}}function fe(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>k(e,t))},values:t}}function A({nodeId:a,addonIds:o,level:c,deviceId:u,capability:h,omitCapabilities:b,sectionIds:x,omitSectionIds:S,fieldKeys:C,omitFieldKeys:w,hideSectionChrome:T,tabAliases:E,tabLabelOverrides:D,sectionTab:O,fieldScope:k,emptyMessage:A,extraTabs:j,schemaTabExtras:M,title:N,description:P,selfTabbed:me,activeTab:he,onActiveTabChange:ge}){let{t:F}=re(),I=d(),L=m().trpcClient,_e=ne(),ve=te(),ye=v(),be=_(),R=me===!0||!!(j&&j.length>0),[xe,Se]=s(null);if(c===`device`&&!u)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let z=a??`hub`,B=l({queries:o.map(e=>({queryKey:[[`addonSettings`,c===`global`?`listScopedSettings`:`getDeviceSettings`],{addonId:e,nodeId:z,deviceId:u??null,cap:h??null,omitCaps:b??null,scope:k??null,sections:[x??null,S??null]}],queryFn:async()=>{if(c===`global`){let t=await L.addonSettings.listScopedSettings.query({addonId:e,nodeId:z});if(t===null)return{addonId:e,result:null,keyTargets:{}};let n=new Set(b??[]),r=le({declarations:t.filter(e=>!n.has(e.cap)),...k===void 0?{}:{fieldScope:k},...h===void 0?{}:{capability:h},...x===void 0?{}:{allowSectionIds:x},...S===void 0?{}:{omitSectionIds:S}}),i=await Promise.all(r.map(async t=>{let n=await L.addonSettings.getScopedSettings.query({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:z}:{}});return n===null?null:{declaration:t,form:n}})),a=i.filter(e=>e!==null);if(a.length!==i.length)return{addonId:e,result:null,keyTargets:{}};let o=ue(a);return{addonId:e,result:o.form,keyTargets:o.keyTargets}}let t=await L.addonSettings.getDeviceSettings.query({addonId:e,deviceId:u,nodeId:z});return{addonId:e,result:t!==null&&k!==void 0?ce(t,k):t,keyTargets:{}}},placeholderData:f}))}),Ce=B.some(e=>e.isLoading),V=B.map(e=>{if(!e.data)return`-`;if(e.data.result===null)return`${e.data.addonId}:n`;let t=[];for(let n of e.data.result.sections){t.push(`s:${n.id}:${n.tab??`general`}`);for(let e of n.fields){if(!(`key`in e))continue;let n=`options`in e&&Array.isArray(e.options)?e.options.map(e=>e.value).join(`,`):``,r=e.value,i=r===void 0?``:typeof r==`string`?r:JSON.stringify(r);t.push(`f:${e.key}:${n}:${i}`)}}return`${e.data.addonId}:${t.join(`|`)}`}).join(`||`),H=n(()=>{let e=new Set;for(let t of B){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(oe(t.tab,E))}return[...e]},[E,V+`::`+B.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),U=n(()=>new Map((j??[]).map(e=>[e.id,e])),[j]),W=n(()=>{if(!R)return[];let e=[...new Set([...H,...(j??[]).map(e=>e.id),...(M??[]).map(e=>e.tabId)])],t=e=>{let t=U.get(e);if(t?.order!==void 0)return t.order;let n=g[e];return n?n.order:50};return e.toSorted((e,n)=>{let r=t(e),i=t(n);return r===i?e.localeCompare(n):r-i})},[R,H,j,U,M]),we=n(()=>{let e=new Map,t=e=>g[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of H)e.set(n,t(n));for(let n of M??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of j??[])e.set(t.id,t.label);for(let[t,n]of Object.entries(D??{}))e.set(t,n);return e},[H,j,M,D]),G=he===void 0?xe:he,K=R?G&&W.includes(G)?G:W[0]??null:null,Te=e=>{Se(e),ge?.(e)},Ee=K!==null&&U.has(K),q=R?K&&!Ee?K:void 0:O,{data:De}=ee(void 0),Oe=n(()=>{let e=new Map;for(let t of De??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[De]),J=t(new Map),Y=n(()=>{let e=x?new Set(x):null,t=S?new Set(S):null,n=n=>!(e!==null&&!e.has(n)||t!==null&&t.has(n)),r=[];for(let e of B){if(!e.data)continue;e.data.result!==null&&J.current.set(e.data.addonId,{result:e.data.result,keyTargets:e.data.keyTargets});let t=J.current.get(e.data.addonId)??null;if(t===null)continue;let{result:i,keyTargets:a}=t,{schema:o,values:s}=fe(i),c={...C===void 0?{}:{fieldKeys:C},...w===void 0?{}:{omitFieldKeys:w},...T===void 0?{}:{hideSectionChrome:T},...E===void 0?{}:{tabAliases:E}},l=se(o.sections.filter(e=>n(e.id)),c);if(l.length===0)continue;let u={...i,sections:se(i.sections.filter(e=>n(e.id)),c)},d={...o,sections:l};r.push({addonId:e.data.addonId,schemaWithValues:u,schema:d,serverValues:s,keyTargets:a})}return r},[V,x,S,C,w,T,E]),ke=n(()=>B.flatMap(e=>c===`global`&&e.data!==void 0&&e.data.result===null&&!J.current.has(e.data.addonId)?[e.data.addonId]:[]),[V,c]),[X,Ae]=s(new Map),je=r(e=>{Ae(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),Z=t(new Map),Me=r(e=>t=>{t?Z.current.set(e,t):Z.current.delete(e)},[]),Q=r(async(e,t)=>{if(c!==`global`){await ve.mutateAsync({addonId:e,deviceId:u,nodeId:z,patch:t});return}let{groups:n,unowned:r}=de(t,Y.find(t=>t.addonId===e)?.keyTargets??{});if(r.length>0)throw Error(`${e}: no scoped setting declares ${r.join(`, `)}`);let i=(await Promise.allSettled(n.map(t=>_e.mutateAsync({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:z}:{},patch:t.patch})))).flatMap((e,t)=>{let r=n[t];if(e.status!==`rejected`||r===void 0)return[];let i=e.reason instanceof Error?e.reason.message:String(e.reason);return[`${r.cap}/${r.scope}: ${i}`]});if(i.length>0)throw I.invalidateQueries({queryKey:[[`addonSettings`]]}),Error(`${e}: not saved to ${i.join(`; `)}`)},[c,Y,_e,ve,I,z,u]),Ne=r(async(e,t)=>{await Q(e,t),I.invalidateQueries({queryKey:[[`addonSettings`]]})},[Q,I]),Pe=r(async(e,t,n,r)=>{let i=z;try{switch(t){case`reprobe-hwaccel`:await ye.mutateAsync({nodeId:i}),I.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await be.mutateAsync({nodeId:i}),I.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await L.addons.custom.mutate({addonId:e,action:t,input:r});return I.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[ye,be,z,I,L]),Fe=r((e,t)=>{Ne(e,t)},[Ne]),$=p({mutationFn:async()=>{let e=[];for(let t of Y){let n=X.get(t.addonId);!n||n.pendingKeys.length===0||e.push({addonId:t.addonId,patch:n.pendingValues})}return e.length===0?{saved:[]}:{saved:await Promise.all(e.map(async({addonId:e,patch:t})=>(await Q(e,t),e)))}},onSuccess:({saved:e})=>{for(let t of e)Z.current.get(t)?.discard();I.invalidateQueries({queryKey:[[`addonSettings`]]})}}),Ie=r(()=>{for(let e of Z.current.values())e.discard()},[]),Le=n(()=>{let e=0;for(let t of Y){let n=X.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[Y,X]),Re=n(()=>{let e=new Map;for(let t of Y){let n=X.get(t.addonId);if(!n||n.pendingKeys.length===0)continue;let r=new Set(n.pendingKeys);for(let n of t.schema.sections){let t=n.tab??`general`;for(let i of n.fields)`key`in i&&r.has(i.key)&&e.set(t,(e.get(t)??0)+1)}}return e},[Y,X]);if(Ce)return i(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let ze=K&&Ee?U.get(K):void 0,Be=ke.length>0?i(`div`,{className:`space-y-1 text-[11px] text-foreground-subtle`,role:`status`,children:ke.map(e=>i(`div`,{children:F(`settings.nodeAddonsSettingsPanel.addonUnavailable`,`{{name}} not available.`,{name:Oe.get(e)??e})},e))}):null;if(!R&&Y.length===0)return Be===null?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:A??F(`settings.nodeAddonsSettingsPanel.noAddonsIn`,{scope:o.length>0?`[${o.join(`, `)}]`:F(`settings.nodeAddonsSettingsPanel.theCurrentSelection`,`the current selection`),level:c})}):Be;let Ve=$.isPending;return e(`div`,{className:`space-y-4`,children:[(N||P)&&e(`div`,{className:`border-b border-border pb-2`,children:[N&&i(`h2`,{className:`text-sm font-semibold text-foreground`,children:N}),P&&i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:P})]}),Y.length>0||R?Be:null,R&&i(ie,{tabs:W.map(e=>({id:e,label:we.get(e)??e})),activeId:K,onChange:Te,pendingByTab:Re}),$.isError&&e(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[F(`settings.nodeAddonsSettingsPanel.saveFailed`,`Save failed:`),` `,String($.error?.message??$.error)]}),i(y,{tabKey:ze?`extra:${K??``}`:`tab:${K??``}`,children:ze?ze.content:(()=>{let t=q?Y.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===q).length,0):0,n=!!q&&t<=1,r=Y.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>q?(e.tab??`general`)===q:!0).map(e=>n?{...e,title:``,description:void 0}:e)}})).filter(e=>e.renderedWithValues.sections.length>0).toSorted((e,t)=>{let n=e=>{let t=1/0;for(let n of e)typeof n.order==`number`&&n.order<t&&(t=n.order);return t},r=n(e.renderedWithValues.sections),i=n(t.renderedWithValues.sections);return r===i?0:r-i}),a=(M??[]).filter(e=>e.tabId===q),o=a.filter(e=>(e.placement??`before`)===`before`),s=a.filter(e=>e.placement===`after`);return r.length===0&&a.length===0?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:A??F(`settings.nodeAddonsSettingsPanel.nothingToConfigureHereFor`,`Nothing to configure here for this node.`)}):e(`div`,{className:`space-y-6`,children:[o.map((e,t)=>i(`div`,{children:e.content},`extra-before-${t}`)),r.length>0&&i(pe,{entries:r,paneStates:X,displayNames:Oe,disabled:Ve,setPaneRef:Me,onPaneStateChange:je,onImmediateSave:Fe,onAction:Pe,inline:R||!!O}),s.map((e,t)=>i(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!Ce&&i(ae,{pendingCount:Le,onSave:()=>$.mutate(),onDiscard:Ie,saving:Ve})]})}function pe({entries:t,paneStates:r,displayNames:o,disabled:c,setPaneRef:l,onPaneStateChange:u,onImmediateSave:d,onAction:f,inline:p}){let m=n(()=>[...t].toSorted((e,t)=>{let n=o.get(e.addonId)??e.addonId,r=o.get(t.addonId)??t.addonId;return n.localeCompare(r)}),[t,o]),[h,g]=s(m[0]?.addonId??``);a(()=>{m.length!==0&&(m.find(e=>e.addonId===h)||g(m[0].addonId))},[m,h]);let _=m.find(e=>e.addonId===h)??m[0];if(!_)return null;let v=n(()=>f?(e,t,n,r)=>f(e,t,n,r):void 0,[f]),y=e=>i(C,{ref:l(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:d,onStateChange:u,onAction:v,disabled:c},e.addonId);return m.length===1||p?i(`div`,{className:`flex flex-col gap-4`,children:m.map(y)}):e(`div`,{className:`flex flex-col gap-3`,children:[i(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:m.map(t=>{let n=o.get(t.addonId)??t.addonId,a=t.addonId===_.addonId,s=(r.get(t.addonId)?.pendingKeys.length??0)>0;return e(b,{variant:`unstyled`,type:`button`,onClick:()=>g(t.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[n,s&&i(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},t.addonId)})}),i(`div`,{className:`space-y-2`,children:m.map(e=>i(`div`,{style:e.addonId===_.addonId?void 0:{display:`none`},children:y(e)},e.addonId))})]})}export{A as t};