@camstack/addon-admin-ui 1.2.704 → 1.2.705
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 +6 -0
- package/dist/assets/{AccessSection-Bbp4vCnK.js → AccessSection-BeZ-ZSZH.js} +1 -1
- package/dist/assets/{Addons-BfskS1ar.js → Addons-B67ZKiIM.js} +1 -1
- package/dist/assets/{AdminPage-Dyd6hYl8.js → AdminPage-DzJf0goX.js} +1 -1
- package/dist/assets/{AdminSectionedPage-DvahmWYI.js → AdminSectionedPage-Bbwlkaso.js} +1 -1
- package/dist/assets/{AiProfiles-Di4CMSTf.js → AiProfiles-CxMZ9OPy.js} +1 -1
- package/dist/assets/{Archive-B10-SsQm.js → Archive-CNBbQJdi.js} +1 -1
- package/dist/assets/{BootstrapSettingsForm-Cm4-eDgP.js → BootstrapSettingsForm-BtE1iXqy.js} +1 -1
- package/dist/assets/{Build-CG3kxG-Q.js → Build-CqrZdTOZ.js} +1 -1
- package/dist/assets/{Calendars-BDDqqhdh.js → Calendars-teAO90MR.js} +1 -1
- package/dist/assets/{Cluster-BQ_N__Tz.js → Cluster-B_oa3u1b.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-CAYxLM7D.js → CompositionBlockEditor-fetZVv9R.js} +1 -1
- package/dist/assets/{CompositionEditorPage-DX3tmg77.js → CompositionEditorPage-CVqCjFh9.js} +1 -1
- package/dist/assets/{Data-DdKvcS20.js → Data-BgN0TwvA.js} +1 -1
- package/dist/assets/{DeviceDetail-DHBkE6sd.js → DeviceDetail-BCK54s-r.js} +1 -1
- package/dist/assets/{Devices-BzdO_WfX.js → Devices-ByIxMq0Z.js} +1 -1
- package/dist/assets/{EmbedDevicePage-Cyos8BBm.js → EmbedDevicePage-AbQyTGP0.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-Cl2Qja7R.js → EmbedPlayerPage-8oYuEKn0.js} +1 -1
- package/dist/assets/{History-CDCxEudX.js → History-DNACKtMD.js} +1 -1
- package/dist/assets/{Identity-C-NUjzGa.js → Identity-C3aBUrgF.js} +1 -1
- package/dist/assets/{InstancesTable-CLf8XbQo.js → InstancesTable-CmQB6lsG.js} +1 -1
- package/dist/assets/{IntegrationDetail-BLtGoHv4.js → IntegrationDetail-B1I0hqJT.js} +1 -1
- package/dist/assets/{Integrations-D0p7b6sg.js → Integrations-C5n1Q4cZ.js} +1 -1
- package/dist/assets/{Integrations-DKh9soI8.js → Integrations-D7o1Lwjg.js} +1 -1
- package/dist/assets/{Library-C5NOjKCt.js → Library-DQMiKk92.js} +1 -1
- package/dist/assets/{Locations-CIm3Q3i3.js → Locations-HJ5VE6wa.js} +1 -1
- package/dist/assets/{Logs-BdYjeDAx.js → Logs-BjA3WW9I.js} +1 -1
- package/dist/assets/{MyAccess-bBE9o8UP.js → MyAccess-BCMiuZH7.js} +1 -1
- package/dist/assets/{Network-CgYpqnsc.js → Network-DNcounNC.js} +1 -1
- package/dist/assets/{NewExportModal-CsSL-XDz.js → NewExportModal-D-fqGUNF.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-DNmMoeS5.js → NodeAddonsSettingsPanel-FbnPwMoo.js} +1 -1
- package/dist/assets/{Notifications-CAl9PqU3.js → Notifications-BlJUOiOT.js} +1 -1
- package/dist/assets/{PanelContent-Cg1LPl_m.js → PanelContent-DhMH96cc.js} +1 -1
- package/dist/assets/{Pipeline-ffZklufq.js → Pipeline-BrjK_4Zb.js} +1 -1
- package/dist/assets/{SessionsList-BPJsMXCC.js → SessionsList-CnppYJx-.js} +1 -1
- package/dist/assets/{Showroom-DrnOtUc4.js → Showroom--KYoap_E.js} +1 -1
- package/dist/assets/{StorageLocationsTable-CBvJJKcK.js → StorageLocationsTable-CZ_zQ315.js} +1 -1
- package/dist/assets/{System-CiNhZGIk.js → System-BcI_W06k.js} +1 -1
- package/dist/assets/{TemplateEditorDialog-CPEjtVgr.js → TemplateEditorDialog-BBZ9-0mq.js} +1 -1
- package/dist/assets/{Terminal-CVqdDb0A.js → Terminal-Oe9r0PsA.js} +1 -1
- package/dist/assets/{TrainingProviders-dcBFMHwS.js → TrainingProviders-BShb6SXm.js} +1 -1
- package/dist/assets/{Viewer-D5ct12iH.js → Viewer-IHbAMugL.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DO_LtV7q.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-QBr80lrT.js} +1 -1
- package/dist/assets/{assignment-candidates-Cu7cpUBu.js → assignment-candidates-tjPZB3kx.js} +1 -1
- package/dist/assets/{authed-media-CU1WIjD1.js → authed-media-C67E4ttX.js} +1 -1
- package/dist/assets/{device-integration-icon-DyN7a2xu.js → device-integration-icon-ruoVMHzu.js} +1 -1
- package/dist/assets/device-picker-model-winfHeVr.js +1 -0
- package/dist/assets/{hostInit-Bl-sNtRa.js → hostInit-D0VOQryO.js} +1 -1
- package/dist/assets/{index-Dx4xn5Ud.js → index-tUZdxov8.js} +3 -3
- package/dist/assets/{linked-devices-model-BheLRl2H.js → linked-devices-model-PBa4HN8e.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-4f6c0152.js → mf-entry-bootstrap-0-6e66f04c.js} +2 -2
- package/dist/assets/mount-winfHeVr.js +1 -0
- package/dist/assets/remoteEntry-DLsOXQks.js +1 -0
- package/dist/assets/{src-BnZKlAAn.js → src-BOTovwqw.js} +1 -1
- package/dist/assets/{step-inspector-model-42AP-SPE.js → step-inspector-model-BMtWXtVA.js} +1 -1
- package/dist/assets/{use-scenes-feed-Ch3TUt2m.js → use-scenes-feed-DvbrobDf.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-CJytKQAy.js → useAdminDeviceRemoval-BINcEE2P.js} +1 -1
- package/dist/assets/useEventInvalidation-winfHeVr.js +1 -0
- package/dist/assets/{useNodeUrlSelection-D6xWhfvx.js → useNodeUrlSelection-bRnPemsT.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-QyglrCCc.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-527UmHp2.js} +2 -2
- package/dist/index.html +4 -4
- package/dist/server/addon.js +1 -1
- package/package.json +2 -2
- package/dist/assets/device-picker-model-CB3W-Dnv.js +0 -1
- package/dist/assets/mount-CB3W-Dnv.js +0 -1
- package/dist/assets/remoteEntry-DDpSLsem.js +0 -1
- package/dist/assets/useEventInvalidation-CB3W-Dnv.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-BKR7fWEx.js";import{t as m}from"./chevron-down-CBb-F8DT.js";import{Hi as h,Ji as g,Ki as _,Tp as v,Ui as ee,Wd as y,Wi as b,Xs as x,_p as S,qi as C}from"./src-BnZKlAAn.js";import{t as w}from"./i18n-CjRpxC0U.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(S,{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(S,{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(S,{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(S,{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(v,{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(v,{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(S,{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(S,{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(S,{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=x({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=y({onSuccess:()=>{i(),t()},onError:e=>z(e instanceof Error?e.message:String(e))});return r(h,{open:!0,onOpenChange:e=>!e&&t(),children:e(b,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(C,{children:e(g,{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(v,{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(v,{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(v,{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(S,{variant:`outline`,size:`sm`,onClick:t,children:l(`common.cancel`,`Cancel`)}),r(S,{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-BKR7fWEx.js";import{t as m}from"./chevron-down-CBb-F8DT.js";import{Hi as h,Ji as g,Ki as _,Tp as v,Ui as ee,Wd as y,Wi as b,Xs as x,_p as S,qi as C}from"./src-BOTovwqw.js";import{t as w}from"./i18n-CjRpxC0U.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(S,{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(S,{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(S,{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(S,{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(v,{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(v,{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(S,{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(S,{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(S,{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=x({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=y({onSuccess:()=>{i(),t()},onError:e=>z(e instanceof Error?e.message:String(e))});return r(h,{open:!0,onOpenChange:e=>!e&&t(),children:e(b,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(C,{children:e(g,{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(v,{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(v,{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(v,{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(S,{variant:`outline`,size:`sm`,onClick:t,children:l(`common.cancel`,`Cancel`)}),r(S,{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-DNmMoeS5.js → NodeAddonsSettingsPanel-FbnPwMoo.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-BKR7fWEx.js";import{el as h,tl as g}from"./client-BDuXx1QP.js";import{$a as _,_p as v,at as y,eo as b,gs as ee,jo as te,uo as ne}from"./src-BnZKlAAn.js";import{t as re}from"./useTranslation-BJr-n0es.js";import{A as ie,M as x,Vt as S,j as ae}from"./index-Dx4xn5Ud.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 le(e,t){return t===void 0?!0:t===`perNode`?e===`node`:e!==`node`}function ue(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(!le(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 de(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 fe(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 D(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>D(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function O(e,t){return{...e,fields:e.fields.map(e=>D(e,t))}}function pe(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>O(e,t))},values:t}}function k({nodeId:a,addonIds:o,level:c,deviceId:u,capability:g,omitCapabilities:v,sectionIds:x,omitSectionIds:S,fieldKeys:C,omitFieldKeys:w,hideSectionChrome:T,tabAliases:E,tabLabelOverrides:le,sectionTab:D,fieldScope:O,emptyMessage:k,extraTabs:A,schemaTabExtras:j,title:M,description:N,selfTabbed:he,activeTab:ge,onActiveTabChange:_e}){let{t:P}=re(),F=d(),I=m().trpcClient,ve=b(),ye=_(),be=ee(),xe=te(),L=he===!0||!!(A&&A.length>0),[Se,Ce]=s(null);if(c===`device`&&!u)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let R=a??`hub`,z=l({queries:o.map(e=>({queryKey:[[`addonSettings`,c===`global`?`listScopedSettings`:`getDeviceSettings`],{addonId:e,nodeId:R,deviceId:u??null,cap:g??null,omitCaps:v??null,scope:O??null,sections:[x??null,S??null]}],queryFn:async()=>{if(c===`global`){let t=await I.addonSettings.listScopedSettings.query({addonId:e,nodeId:R});if(t===null)return{addonId:e,result:null,keyTargets:{}};let n=new Set(v??[]),r=ue({declarations:t.filter(e=>!n.has(e.cap)),...O===void 0?{}:{fieldScope:O},...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 I.addonSettings.getScopedSettings.query({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:R}:{}});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=de(a);return{addonId:e,result:o.form,keyTargets:o.keyTargets}}let t=await I.addonSettings.getDeviceSettings.query({addonId:e,deviceId:u,nodeId:R});return{addonId:e,result:t!==null&&O!==void 0?ce(t,O):t,keyTargets:{}}},placeholderData:f}))}),we=z.some(e=>e.isLoading),B=z.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(`||`),V=n(()=>{let e=new Set;for(let t of z){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(oe(t.tab,E))}return[...e]},[E,B+`::`+z.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),H=n(()=>new Map((A??[]).map(e=>[e.id,e])),[A]),U=n(()=>{if(!L)return[];let e=[...new Set([...V,...(A??[]).map(e=>e.id),...(j??[]).map(e=>e.tabId)])],t=e=>{let t=H.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})},[L,V,A,H,j]),Te=n(()=>{let e=new Map,t=e=>h[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of V)e.set(n,t(n));for(let n of j??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of A??[])e.set(t.id,t.label);for(let[t,n]of Object.entries(le??{}))e.set(t,n);return e},[V,A,j,le]),W=ge===void 0?Se:ge,G=L?W&&U.includes(W)?W:U[0]??null:null,Ee=e=>{Ce(e),_e?.(e)},De=G!==null&&H.has(G),K=L?G&&!De?G:void 0:D,{data:Oe}=ne(void 0),ke=n(()=>{let e=new Map;for(let t of Oe??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[Oe]),q=t(new Map),J=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 z){if(!e.data)continue;e.data.result!==null&&q.current.set(e.data.addonId,{result:e.data.result,keyTargets:e.data.keyTargets});let t=q.current.get(e.data.addonId)??null;if(t===null)continue;let{result:i,keyTargets:a}=t,{schema:o,values:s}=pe(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},[B,x,S,C,w,T,E]),Ae=n(()=>z.flatMap(e=>c===`global`&&e.data!==void 0&&e.data.result===null&&!q.current.has(e.data.addonId)?[e.data.addonId]:[]),[B,c]),[Y,je]=s(new Map),Me=r(e=>{je(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),X=t(new Map),Ne=r(e=>t=>{t?X.current.set(e,t):X.current.delete(e)},[]),Z=r(async(e,t)=>{if(c!==`global`){await ye.mutateAsync({addonId:e,deviceId:u,nodeId:R,patch:t});return}let{groups:n,unowned:r}=fe(t,J.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=>ve.mutateAsync({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:R}:{},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 F.invalidateQueries({queryKey:[[`addonSettings`]]}),Error(`${e}: not saved to ${i.join(`; `)}`)},[c,J,ve,ye,F,R,u]),Pe=r(async(e,t)=>{await Z(e,t),F.invalidateQueries({queryKey:[[`addonSettings`]]})},[Z,F]),Fe=r(async(e,t,n,r)=>{let i=R;try{switch(t){case`reprobe-hwaccel`:await be.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await xe.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await I.addons.custom.mutate({addonId:e,action:t,input:r});return F.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[be,xe,R,F,I]),Ie=r((e,t)=>{Pe(e,t)},[Pe]),Q=p({mutationFn:async()=>{let e=[];for(let t of J){let n=Y.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 Z(e,t),e)))}},onSuccess:({saved:e})=>{for(let t of e)X.current.get(t)?.discard();F.invalidateQueries({queryKey:[[`addonSettings`]]})}}),Le=r(()=>{for(let e of X.current.values())e.discard()},[]),Re=n(()=>{let e=0;for(let t of J){let n=Y.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[J,Y]),ze=n(()=>{let e=new Map;for(let t of J){let n=Y.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},[J,Y]);if(we)return i(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let Be=G&&De?H.get(G):void 0,$=Ae.length>0?i(`div`,{className:`space-y-1 text-[11px] text-foreground-subtle`,role:`status`,children:Ae.map(e=>i(`div`,{children:P(`settings.nodeAddonsSettingsPanel.addonUnavailable`,`{{name}} not available.`,{name:ke.get(e)??e})},e))}):null;if(!L&&J.length===0)return $===null?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:k??P(`settings.nodeAddonsSettingsPanel.noAddonsIn`,{scope:o.length>0?`[${o.join(`, `)}]`:P(`settings.nodeAddonsSettingsPanel.theCurrentSelection`,`the current selection`),level:c})}):$;let Ve=Q.isPending;return e(`div`,{className:`space-y-4`,children:[(M||N)&&e(`div`,{className:`border-b border-border pb-2`,children:[M&&i(`h2`,{className:`text-sm font-semibold text-foreground`,children:M}),N&&i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:N})]}),J.length>0||L?$:null,L&&i(ie,{tabs:U.map(e=>({id:e,label:Te.get(e)??e})),activeId:G,onChange:Ee,pendingByTab:ze}),Q.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:[P(`settings.nodeAddonsSettingsPanel.saveFailed`,`Save failed:`),` `,String(Q.error?.message??Q.error)]}),i(y,{tabKey:Be?`extra:${G??``}`:`tab:${G??``}`,children:Be?Be.content:(()=>{let t=K?J.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===K).length,0):0,n=!!K&&t<=1,r=J.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>K?(e.tab??`general`)===K:!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=(j??[]).filter(e=>e.tabId===K),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:k??P(`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(me,{entries:r,paneStates:Y,displayNames:ke,disabled:Ve,setPaneRef:Ne,onPaneStateChange:Me,onImmediateSave:Ie,onAction:Fe,inline:L||!!D}),s.map((e,t)=>i(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!we&&i(ae,{pendingCount:Re,onSave:()=>Q.mutate(),onDiscard:Le,saving:Ve})]})}function me({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 y=n(()=>f?(e,t,n,r)=>f(e,t,n,r):void 0,[f]),b=e=>i(C,{ref:l(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:d,onStateChange:u,onAction:y,disabled:c},e.addonId);return m.length===1||p?i(`div`,{className:`flex flex-col gap-4`,children:m.map(b)}):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(v,{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:b(e)},e.addonId))})]})}export{k 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-BKR7fWEx.js";import{el as h,tl as g}from"./client-BDuXx1QP.js";import{$a as _,_p as v,at as y,eo as b,gs as ee,jo as te,uo as ne}from"./src-BOTovwqw.js";import{t as re}from"./useTranslation-BJr-n0es.js";import{A as ie,M as x,Vt as S,j as ae}from"./index-tUZdxov8.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 le(e,t){return t===void 0?!0:t===`perNode`?e===`node`:e!==`node`}function ue(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(!le(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 de(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 fe(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 D(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>D(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function O(e,t){return{...e,fields:e.fields.map(e=>D(e,t))}}function pe(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>O(e,t))},values:t}}function k({nodeId:a,addonIds:o,level:c,deviceId:u,capability:g,omitCapabilities:v,sectionIds:x,omitSectionIds:S,fieldKeys:C,omitFieldKeys:w,hideSectionChrome:T,tabAliases:E,tabLabelOverrides:le,sectionTab:D,fieldScope:O,emptyMessage:k,extraTabs:A,schemaTabExtras:j,title:M,description:N,selfTabbed:he,activeTab:ge,onActiveTabChange:_e}){let{t:P}=re(),F=d(),I=m().trpcClient,ve=b(),ye=_(),be=ee(),xe=te(),L=he===!0||!!(A&&A.length>0),[Se,Ce]=s(null);if(c===`device`&&!u)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let R=a??`hub`,z=l({queries:o.map(e=>({queryKey:[[`addonSettings`,c===`global`?`listScopedSettings`:`getDeviceSettings`],{addonId:e,nodeId:R,deviceId:u??null,cap:g??null,omitCaps:v??null,scope:O??null,sections:[x??null,S??null]}],queryFn:async()=>{if(c===`global`){let t=await I.addonSettings.listScopedSettings.query({addonId:e,nodeId:R});if(t===null)return{addonId:e,result:null,keyTargets:{}};let n=new Set(v??[]),r=ue({declarations:t.filter(e=>!n.has(e.cap)),...O===void 0?{}:{fieldScope:O},...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 I.addonSettings.getScopedSettings.query({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:R}:{}});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=de(a);return{addonId:e,result:o.form,keyTargets:o.keyTargets}}let t=await I.addonSettings.getDeviceSettings.query({addonId:e,deviceId:u,nodeId:R});return{addonId:e,result:t!==null&&O!==void 0?ce(t,O):t,keyTargets:{}}},placeholderData:f}))}),we=z.some(e=>e.isLoading),B=z.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(`||`),V=n(()=>{let e=new Set;for(let t of z){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(oe(t.tab,E))}return[...e]},[E,B+`::`+z.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),H=n(()=>new Map((A??[]).map(e=>[e.id,e])),[A]),U=n(()=>{if(!L)return[];let e=[...new Set([...V,...(A??[]).map(e=>e.id),...(j??[]).map(e=>e.tabId)])],t=e=>{let t=H.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})},[L,V,A,H,j]),Te=n(()=>{let e=new Map,t=e=>h[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of V)e.set(n,t(n));for(let n of j??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of A??[])e.set(t.id,t.label);for(let[t,n]of Object.entries(le??{}))e.set(t,n);return e},[V,A,j,le]),W=ge===void 0?Se:ge,G=L?W&&U.includes(W)?W:U[0]??null:null,Ee=e=>{Ce(e),_e?.(e)},De=G!==null&&H.has(G),K=L?G&&!De?G:void 0:D,{data:Oe}=ne(void 0),ke=n(()=>{let e=new Map;for(let t of Oe??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[Oe]),q=t(new Map),J=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 z){if(!e.data)continue;e.data.result!==null&&q.current.set(e.data.addonId,{result:e.data.result,keyTargets:e.data.keyTargets});let t=q.current.get(e.data.addonId)??null;if(t===null)continue;let{result:i,keyTargets:a}=t,{schema:o,values:s}=pe(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},[B,x,S,C,w,T,E]),Ae=n(()=>z.flatMap(e=>c===`global`&&e.data!==void 0&&e.data.result===null&&!q.current.has(e.data.addonId)?[e.data.addonId]:[]),[B,c]),[Y,je]=s(new Map),Me=r(e=>{je(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),X=t(new Map),Ne=r(e=>t=>{t?X.current.set(e,t):X.current.delete(e)},[]),Z=r(async(e,t)=>{if(c!==`global`){await ye.mutateAsync({addonId:e,deviceId:u,nodeId:R,patch:t});return}let{groups:n,unowned:r}=fe(t,J.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=>ve.mutateAsync({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:R}:{},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 F.invalidateQueries({queryKey:[[`addonSettings`]]}),Error(`${e}: not saved to ${i.join(`; `)}`)},[c,J,ve,ye,F,R,u]),Pe=r(async(e,t)=>{await Z(e,t),F.invalidateQueries({queryKey:[[`addonSettings`]]})},[Z,F]),Fe=r(async(e,t,n,r)=>{let i=R;try{switch(t){case`reprobe-hwaccel`:await be.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await xe.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await I.addons.custom.mutate({addonId:e,action:t,input:r});return F.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[be,xe,R,F,I]),Ie=r((e,t)=>{Pe(e,t)},[Pe]),Q=p({mutationFn:async()=>{let e=[];for(let t of J){let n=Y.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 Z(e,t),e)))}},onSuccess:({saved:e})=>{for(let t of e)X.current.get(t)?.discard();F.invalidateQueries({queryKey:[[`addonSettings`]]})}}),Le=r(()=>{for(let e of X.current.values())e.discard()},[]),Re=n(()=>{let e=0;for(let t of J){let n=Y.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[J,Y]),ze=n(()=>{let e=new Map;for(let t of J){let n=Y.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},[J,Y]);if(we)return i(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let Be=G&&De?H.get(G):void 0,$=Ae.length>0?i(`div`,{className:`space-y-1 text-[11px] text-foreground-subtle`,role:`status`,children:Ae.map(e=>i(`div`,{children:P(`settings.nodeAddonsSettingsPanel.addonUnavailable`,`{{name}} not available.`,{name:ke.get(e)??e})},e))}):null;if(!L&&J.length===0)return $===null?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:k??P(`settings.nodeAddonsSettingsPanel.noAddonsIn`,{scope:o.length>0?`[${o.join(`, `)}]`:P(`settings.nodeAddonsSettingsPanel.theCurrentSelection`,`the current selection`),level:c})}):$;let Ve=Q.isPending;return e(`div`,{className:`space-y-4`,children:[(M||N)&&e(`div`,{className:`border-b border-border pb-2`,children:[M&&i(`h2`,{className:`text-sm font-semibold text-foreground`,children:M}),N&&i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:N})]}),J.length>0||L?$:null,L&&i(ie,{tabs:U.map(e=>({id:e,label:Te.get(e)??e})),activeId:G,onChange:Ee,pendingByTab:ze}),Q.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:[P(`settings.nodeAddonsSettingsPanel.saveFailed`,`Save failed:`),` `,String(Q.error?.message??Q.error)]}),i(y,{tabKey:Be?`extra:${G??``}`:`tab:${G??``}`,children:Be?Be.content:(()=>{let t=K?J.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===K).length,0):0,n=!!K&&t<=1,r=J.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>K?(e.tab??`general`)===K:!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=(j??[]).filter(e=>e.tabId===K),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:k??P(`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(me,{entries:r,paneStates:Y,displayNames:ke,disabled:Ve,setPaneRef:Ne,onPaneStateChange:Me,onImmediateSave:Ie,onAction:Fe,inline:L||!!D}),s.map((e,t)=>i(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!we&&i(ae,{pendingCount:Re,onSave:()=>Q.mutate(),onDiscard:Le,saving:Ve})]})}function me({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 y=n(()=>f?(e,t,n,r)=>f(e,t,n,r):void 0,[f]),b=e=>i(C,{ref:l(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:d,onStateChange:u,onAction:y,disabled:c},e.addonId);return m.length===1||p?i(`div`,{className:`flex flex-col gap-4`,children:m.map(b)}):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(v,{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:b(e)},e.addonId))})]})}export{k as t};
|