@camstack/addon-admin-ui 1.2.710 → 1.2.712
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/CHANGELOG.md +14 -0
- package/dist/assets/{AccessSection-Cgv04lJf.js → AccessSection-BMHyeXXs.js} +1 -1
- package/dist/assets/{Addons-BJL6WRKD.js → Addons-Czq7HK5o.js} +1 -1
- package/dist/assets/{AdminPage-CFltVUtJ.js → AdminPage-DgcMq51y.js} +1 -1
- package/dist/assets/{AdminSectionedPage-DfZeI0TS.js → AdminSectionedPage-BKAltoSC.js} +1 -1
- package/dist/assets/{AiProfiles-DW29u0zA.js → AiProfiles-C3dVuuEs.js} +1 -1
- package/dist/assets/Archive-DD70ZFMv.js +1 -0
- package/dist/assets/{BootstrapSettingsForm-DKjedbyR.js → BootstrapSettingsForm-DNIVKIZZ.js} +1 -1
- package/dist/assets/Build-B0vH9mDa.js +40 -0
- package/dist/assets/{Calendars-Bfl32yKa.js → Calendars-B1cBJoa1.js} +1 -1
- package/dist/assets/{Cluster-BT8yE3Jd.js → Cluster-BMZ_3SCr.js} +1 -1
- package/dist/assets/CompositionBlockEditor-Bj14wly_.js +2 -0
- package/dist/assets/{CompositionEditorPage-DAZ2EbrI.js → CompositionEditorPage-sUNp8qe7.js} +1 -1
- package/dist/assets/{Data-CCLq4I9_.js → Data-DcunBcmb.js} +1 -1
- package/dist/assets/DeviceDetail-CUJRNGTx.js +1 -0
- package/dist/assets/{Devices-BbWkqyWN.js → Devices-DxX8ybfM.js} +1 -1
- package/dist/assets/{EmbedDevicePage-C3hraaEM.js → EmbedDevicePage-G-VhlNDT.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-RHniI2xA.js → EmbedPlayerPage-CVF9_4Ua.js} +1 -1
- package/dist/assets/{History-B5SE1vph.js → History-DhTpectV.js} +1 -1
- package/dist/assets/{Identity-COMelIL5.js → Identity-BhsJ_1aP.js} +1 -1
- package/dist/assets/{InstancesTable-Gi6mvKws.js → InstancesTable-w-0XwFaG.js} +1 -1
- package/dist/assets/{IntegrationDetail-BJgK3HQZ.js → IntegrationDetail-jDFoyrP9.js} +1 -1
- package/dist/assets/{Integrations-DBIDhCAF.js → Integrations-C28hBhrU.js} +1 -1
- package/dist/assets/{Integrations-BAxIjtmf.js → Integrations-C9wh6FxD.js} +1 -1
- package/dist/assets/{Library-j-P8SKgP.js → Library-Cia1655I.js} +1 -1
- package/dist/assets/{Locations-BPRZSbLT.js → Locations-C1F9DRbX.js} +1 -1
- package/dist/assets/Logs-D24n8jj9.js +1 -0
- package/dist/assets/{MaskShapeCanvas-BN6ufTmt.js → MaskShapeCanvas-mnq8FU_f.js} +1 -1
- package/dist/assets/{MotionZonesSettings-DsM7FPZE.js → MotionZonesSettings-D7_18_A_.js} +1 -1
- package/dist/assets/{MyAccess-B3gTfVDq.js → MyAccess-CHM9pog8.js} +1 -1
- package/dist/assets/{Network-CBAabM0h.js → Network-dIj7QC_n.js} +1 -1
- package/dist/assets/{NewExportModal-DGq6CWpy.js → NewExportModal-94DuvHcM.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-DCa3tgOb.js → NodeAddonsSettingsPanel-D_zP_si3.js} +1 -1
- package/dist/assets/Notifications-BtDiQ8BU.js +1 -0
- package/dist/assets/{PanelContent-CVkHXftN.js → PanelContent-_kL0sZaa.js} +1 -1
- package/dist/assets/{Pipeline-CdKKet5N.js → Pipeline-Cz-2Qr0F.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-m809AVSj.js → PrivacyMaskSettings-D4w4a5Cj.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-BRoTpS7V.js → SceneMonitorEditor-CUpdk172.js} +1 -1
- package/dist/assets/{SessionsList-Dqh1pfhl.js → SessionsList-DoB89UjE.js} +1 -1
- package/dist/assets/{Showroom-DO5dhVVy.js → Showroom-Bc0RMx1T.js} +1 -1
- package/dist/assets/{StorageLocationsTable-DjJKdT5E.js → StorageLocationsTable-DdQZaTIL.js} +1 -1
- package/dist/assets/System-xU_4F1qj.js +2 -0
- package/dist/assets/TemplateEditorDialog-DFNJgsxk.js +1 -0
- package/dist/assets/{Terminal-AxKgimJQ.js → Terminal-CF3uGeFD.js} +1 -1
- package/dist/assets/{TrainingProviders-DqSWU0Ff.js → TrainingProviders-B_G3A6On.js} +1 -1
- package/dist/assets/{Viewer-BBtW52-D.js → Viewer-WyKz0Azc.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CnAAoU-a.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CkUFXaiW.js} +1 -1
- package/dist/assets/{action-draft-xWZeLJBc.js → action-draft-CwJf5eW2.js} +1 -1
- package/dist/assets/{ai-page.helpers-DutvjEb-.js → ai-page.helpers-BHBXHNQI.js} +1 -1
- package/dist/assets/{assignment-candidates-BJPEmgFZ.js → assignment-candidates-DRmDIzIf.js} +1 -1
- package/dist/assets/{authed-media-BTPD9Rqy.js → authed-media-DQnc3x5u.js} +1 -1
- package/dist/assets/{board-model-p3qXSelJ.js → board-model-CAPxQYkg.js} +1 -1
- package/dist/assets/{camera-block-model-BmK3dL9c.js → camera-block-model-Cvhw1ACQ.js} +1 -1
- package/dist/assets/{client-D93RkunP.js → client-CU9hiVrv.js} +12 -12
- package/dist/assets/{command-vocab-DGcpiUvY.js → command-vocab-3vo0YGZY.js} +1 -1
- package/dist/assets/{device-integration-icon-Cfi7eokn.js → device-integration-icon-CZX0mESs.js} +1 -1
- package/dist/assets/device-picker-model-BoRMX84w.js +1 -0
- package/dist/assets/{dist-SwLD2DK1.js → dist-BWrpV4hP.js} +1 -1
- package/dist/assets/dist-LYFPq0g9.js +1125 -0
- package/dist/assets/{format-Dzip80Uj.js → format-kIcasnZL.js} +1 -1
- package/dist/assets/{hostInit-C3sYu6u4.js → hostInit-BZDzYAHr.js} +1 -1
- package/dist/assets/i18n-B5Xm3ktp.js +1 -0
- package/dist/assets/{icons-C4C8iPI_.js → icons-Cnaoe6qZ.js} +1 -1
- package/dist/assets/{index-BZLBXpx-.js → index-ByN-VTu-.js} +4 -4
- package/dist/assets/index-CaKMKRxP.css +2 -0
- package/dist/assets/{linked-devices-model-ChJFxnJQ.js → linked-devices-model-B9Gz49sE.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-31325a3f.js → mf-entry-bootstrap-0-ac9760ea.js} +2 -2
- package/dist/assets/mount-BoRMX84w.js +1 -0
- package/dist/assets/{notification-rule-status-BWxeQ-_D.js → notification-rule-status-CFjuiCT9.js} +1 -1
- package/dist/assets/{player-overlays-hLBmOC8C.js → player-overlays-C-OmGoqt.js} +1 -1
- package/dist/assets/remoteEntry-ComxP4sU.js +1 -0
- package/dist/assets/src-BL1KpPQ2.js +279 -0
- package/dist/assets/{sso-popup-D5c1Dbz3.js → sso-popup-D9gVafKd.js} +1 -1
- package/dist/assets/{step-inspector-model-kpUIIlrE.js → step-inspector-model-zgo3LXy6.js} +1 -1
- package/dist/assets/{use-scenes-feed-D60vwQnn.js → use-scenes-feed-C4jyU72L.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-DHZF8Bhc.js → useAdminDeviceRemoval-B5adL9sz.js} +1 -1
- package/dist/assets/useEventInvalidation-BoRMX84w.js +1 -0
- package/dist/assets/{useNodeUrlSelection-CxldmcjV.js → useNodeUrlSelection-vqyOWkjs.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DgZGj8av.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DV6hhcvX.js} +2 -2
- package/dist/index.html +9 -9
- package/dist/server/addon.js +22 -1
- package/package.json +2 -2
- package/dist/assets/Archive-DJk2nZPq.js +0 -1
- package/dist/assets/Build-CaXtQUh_.js +0 -40
- package/dist/assets/CompositionBlockEditor-DmYv5ln7.js +0 -2
- package/dist/assets/DeviceDetail-DNKg72IG.js +0 -1
- package/dist/assets/Logs-RCKlFer4.js +0 -1
- package/dist/assets/Notifications-DccqInu6.js +0 -1
- package/dist/assets/System-nfPLxCLF.js +0 -2
- package/dist/assets/TemplateEditorDialog-eOBMrmCP.js +0 -1
- package/dist/assets/device-picker-model-Bbj8t_iL.js +0 -1
- package/dist/assets/dist-ClyHN0ce.js +0 -1125
- package/dist/assets/i18n-ILINfI4k.js +0 -1
- package/dist/assets/index-BFuQYqWe.css +0 -2
- package/dist/assets/mount-Bbj8t_iL.js +0 -1
- package/dist/assets/remoteEntry-9sIn-FFM.js +0 -1
- package/dist/assets/src-CR4MjS0h.js +0 -279
- package/dist/assets/useEventInvalidation-Bbj8t_iL.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{$a as s,aa as c,fa as l,ft as u,hi as d,oa as f,sa as p}from"./player-overlays-hLBmOC8C.js";import{t as m}from"./chevron-down-CBb-F8DT.js";import{Dp as h,Gi as g,Ji as _,Kd as v,Ki as ee,Qs as y,Wi as b,Xi as x,Yi as S,yp as C}from"./src-CR4MjS0h.js";import{t as w}from"./i18n-ILINfI4k.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(C,{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(C,{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(C,{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(C,{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(h,{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(h,{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(C,{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(C,{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(C,{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=y({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=v({onSuccess:()=>{i(),t()},onError:e=>z(e instanceof Error?e.message:String(e))});return r(b,{open:!0,onOpenChange:e=>!e&&t(),children:e(ee,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(S,{children:e(x,{className:`flex items-center gap-1.5`,children:[r(d,{className:`h-3.5 w-3.5`}),l(`recordings.newExportModal.newExport`,`New export`)]})}),e(g,{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(h,{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(h,{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(h,{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(_,{children:[r(C,{variant:`outline`,size:`sm`,onClick:t,children:l(`common.cancel`,`Cancel`)}),r(C,{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{$a as s,aa as c,fa as l,ft as u,hi as d,oa as f,sa as p}from"./player-overlays-C-OmGoqt.js";import{t as m}from"./chevron-down-CBb-F8DT.js";import{Dp as h,Gi as g,Ji as _,Kd as v,Ki as ee,Qs as y,Wi as b,Xi as x,Yi as S,yp as C}from"./src-BL1KpPQ2.js";import{t as w}from"./i18n-B5Xm3ktp.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(C,{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(C,{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(C,{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(C,{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(h,{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(h,{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(C,{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(C,{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(C,{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=y({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=v({onSuccess:()=>{i(),t()},onError:e=>z(e instanceof Error?e.message:String(e))});return r(b,{open:!0,onOpenChange:e=>!e&&t(),children:e(ee,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(S,{children:e(x,{className:`flex items-center gap-1.5`,children:[r(d,{className:`h-3.5 w-3.5`}),l(`recordings.newExportModal.newExport`,`New export`)]})}),e(g,{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(h,{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(h,{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(h,{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(_,{children:[r(C,{variant:`outline`,size:`sm`,onClick:t,children:l(`common.cancel`,`Cancel`)}),r(C,{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};
|
package/dist/assets/{NodeAddonsSettingsPanel-DCa3tgOb.js → NodeAddonsSettingsPanel-D_zP_si3.js}
RENAMED
|
@@ -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-hLBmOC8C.js";import{nl as h,tl as g}from"./client-D93RkunP.js";import{No as _,at as v,fo as y,no as ee,to as te,ut as ne,vs as re,yp as b}from"./src-CR4MjS0h.js";import{t as ie}from"./useTranslation-BJr-n0es.js";import{A as ae,Bt as x,j as S}from"./index-BZLBXpx-.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=S({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(x,{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}=ie(),I=d(),L=m().trpcClient,_e=ee(),ve=te(),ye=re(),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}=y(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(ae,{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(v,{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(ne,{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-C-OmGoqt.js";import{el as h,tl as g}from"./client-CU9hiVrv.js";import{No as _,at as v,fo as y,no as ee,to as te,ut as ne,vs as re,yp as b}from"./src-BL1KpPQ2.js";import{t as ie}from"./useTranslation-BJr-n0es.js";import{A as ae,Bt as x,j as S}from"./index-ByN-VTu-.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=S({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(x,{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 g({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:g,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}=ie(),I=d(),L=m().trpcClient,_e=ee(),ve=te(),ye=re(),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:g??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},...g===void 0?{}:{capability:g},...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=h[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=>h[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}=y(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(ae,{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(v,{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(ne,{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};
|