@camstack/addon-admin-ui 1.2.678 → 1.2.679
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 +10 -0
- package/dist/assets/Addons-CcHG87CO.js +5 -0
- package/dist/assets/{AdminPage-BEQJlUNo.js → AdminPage-DhtpNaF0.js} +1 -1
- package/dist/assets/{AdminSectionedPage-C7Nx9jJl.js → AdminSectionedPage-dteNFZvo.js} +1 -1
- package/dist/assets/{AiProfiles-D4eTx94W.js → AiProfiles-DW84QaSf.js} +2 -2
- package/dist/assets/{BootstrapSettingsForm-C8SgY-gH.js → BootstrapSettingsForm-DTx2a3Sd.js} +1 -1
- package/dist/assets/Build-DGxdI3Hj.js +42 -0
- package/dist/assets/{Calendars-CngFbuGP.js → Calendars-CI5dIFem.js} +1 -1
- package/dist/assets/{CameraGrids-BI3PYGPr.js → CameraGrids-Cz0cgj4f.js} +1 -1
- package/dist/assets/Cluster-DdwOin66.js +1 -0
- package/dist/assets/CompositionBlockEditor-qlSsElYl.js +2 -0
- package/dist/assets/{CompositionEditorPage-C56ErWVZ.js → CompositionEditorPage-CpW6nXF5.js} +1 -1
- package/dist/assets/Data-B0cMYuLm.js +2 -0
- package/dist/assets/DeviceDetail-9y3dyWK7.js +2 -0
- package/dist/assets/{Devices-ByKU7OhR.js → Devices-Bk_TfLmI.js} +1 -1
- package/dist/assets/{EmbedDevicePage-CUljYRrr.js → EmbedDevicePage-CPlOvLlu.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BM7zhcWx.js → EmbedPlayerPage-liQI6d7f.js} +1 -1
- package/dist/assets/{History-BCQ4IrRD.js → History-B1Q1JGWF.js} +1 -1
- package/dist/assets/Identity-DaP-TPKs.js +1 -0
- package/dist/assets/{InstancesTable-CriEfrMJ.js → InstancesTable-DMhlGx4D.js} +1 -1
- package/dist/assets/{IntegrationDetail-BCP8mmgO.js → IntegrationDetail-CGzj8QFi.js} +1 -1
- package/dist/assets/{Integrations-C30eE4UB.js → Integrations-CeWGYtB9.js} +1 -1
- package/dist/assets/{Integrations-Bqcvm_Qf.js → Integrations-DNctwKoS.js} +2 -2
- package/dist/assets/Library-4XVNGSe-.js +1 -0
- package/dist/assets/Locations-B8Y1S0hz.js +3 -0
- package/dist/assets/{Logs-DKDr8AuB.js → Logs-BhRCuJzg.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-DbmWEEiO.js → MaskShapeCanvas-BN-PRLjb.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BzScgedh.js → MotionZonesSettings-D9Prrwl-.js} +1 -1
- package/dist/assets/{MyAccess-CzfNmMJl.js → MyAccess-Bxvq6s1N.js} +1 -1
- package/dist/assets/{Network-CAbg7ZpT.js → Network-DiPGmTrB.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-DTkQMaBn.js → NodeAddonsSettingsPanel-C3eW6HeG.js} +1 -1
- package/dist/assets/Notifications-DZlP-xpq.js +1 -0
- package/dist/assets/Pipeline-BOej0Ruf.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-DgBQuyh9.js → PrivacyMaskSettings-uNqMIBUf.js} +1 -1
- package/dist/assets/{Recordings-BlCEAKse.js → Recordings-DRXSsvRE.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-D5OLGtBI.js → SceneMonitorEditor-Dd67GOFm.js} +1 -1
- package/dist/assets/{ServerShell-CSTjFsEJ.js → ServerShell-9-brnTiy.js} +1 -1
- package/dist/assets/{SessionsList-C1Ao7w_G.js → SessionsList-ChVQOhw4.js} +2 -2
- package/dist/assets/{Showroom-DCYRjXXW.js → Showroom-Ccc-k5Zm.js} +1 -1
- package/dist/assets/{StorageLocationsTable-BfwKi6fr.js → StorageLocationsTable-Dge2NowU.js} +1 -1
- package/dist/assets/{System-BvNJMfpW.js → System-DRor4yxP.js} +1 -1
- package/dist/assets/{Terminal-DQ5u6n8f.js → Terminal-rDJpyrDe.js} +2 -2
- package/dist/assets/{TerminalPanel-DC4Fs74K.js → TerminalPanel-CcQHLEGZ.js} +1 -1
- package/dist/assets/{TrainingProviders-D6bLgYi2.js → TrainingProviders-BOGrjW0M.js} +1 -1
- package/dist/assets/{Viewer-BmamcoHc.js → Viewer-Dk4V-7Im.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DcrAwx-L.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BlbUc9gS.js} +1 -1
- package/dist/assets/{action-draft-Dr5Q1lmk.js → action-draft-DgC3sdIv.js} +1 -1
- package/dist/assets/{ai-page.helpers-AOJOCF6H.js → ai-page.helpers-BGxGEY-d.js} +1 -1
- package/dist/assets/{assignment-candidates-BYfez7Z_.js → assignment-candidates-BaRiMeKr.js} +1 -1
- package/dist/assets/{authed-media-DaaHSoAj.js → authed-media-DYlVx7_x.js} +1 -1
- package/dist/assets/{board-model-COsjkU2L.js → board-model-C2Tzni7-.js} +1 -1
- package/dist/assets/client-B0p6WiZb.js +1120 -0
- package/dist/assets/{command-vocab-wRSfGsbG.js → command-vocab-DNAnc4zd.js} +1 -1
- package/dist/assets/{device-detail-CT3Wq2MX.js → device-detail-DfSFMzI_.js} +1 -1
- package/dist/assets/{device-integration-icon-CK7ULj84.js → device-integration-icon-D2nTH-29.js} +1 -1
- package/dist/assets/device-picker-model-D943WJVm.js +1 -0
- package/dist/assets/{dist-BnzMSUv0.js → dist-BZGaAsKc.js} +1 -1
- package/dist/assets/dist-auYATUda.js +1120 -0
- package/dist/assets/{format-Fw8MrMCF.js → format-YT7IgtG9.js} +1 -1
- package/dist/assets/{hostInit-BHV5j57a.js → hostInit-Cm3R_dPt.js} +1 -1
- package/dist/assets/i18n-NPZM0HGc.js +1 -0
- package/dist/assets/icons-f0SVFd9I.js +1 -0
- package/dist/assets/index-Bjvuymkk.js +4 -0
- package/dist/assets/{linked-devices-model-BRVCcL_i.js → linked-devices-model-D6oZ-Tkf.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-65134e91.js → mf-entry-bootstrap-0-76eadad6.js} +2 -2
- package/dist/assets/mount-D943WJVm.js +1 -0
- package/dist/assets/{notification-rule-status-tbLfUZee.js → notification-rule-status-BRCNbkxe.js} +1 -1
- package/dist/assets/{player-overlays-8aC2r-sd.js → player-overlays-ClFSGefV.js} +1 -1
- package/dist/assets/remoteEntry-CUYE4uFU.js +1 -0
- package/dist/assets/src-DwclSIv9.js +279 -0
- package/dist/assets/{sso-popup-C_VTtoWT.js → sso-popup-Bxcrh_Ga.js} +1 -1
- package/dist/assets/{step-inspector-model-UadKxnLr.js → step-inspector-model-CdoST47D.js} +1 -1
- package/dist/assets/{use-scenes-feed-D3bzrMKu.js → use-scenes-feed-D64cvW6x.js} +1 -1
- package/dist/assets/{use-stationary-objects-Yw5gdlLl.js → use-stationary-objects-CVtFtIWB.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-WQ4NaouA.js → useAdminDeviceRemoval-D_RkWyKn.js} +1 -1
- package/dist/assets/useEventInvalidation-D943WJVm.js +1 -0
- package/dist/assets/{useNodeUrlSelection-BSpn8JLz.js → useNodeUrlSelection-BrRsjvMi.js} +1 -1
- package/dist/assets/useTemplateSave-CGO3W8km.js +1 -0
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CTvMo-Za.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-i9bg-dgj.js} +2 -2
- package/dist/index.html +8 -8
- package/dist/server/addon.js +1500 -1078
- package/package.json +2 -2
- package/dist/assets/Addons-DKOUsYsk.js +0 -5
- package/dist/assets/Build-BuGJWdUz.js +0 -42
- package/dist/assets/Cluster-DMkIzva9.js +0 -1
- package/dist/assets/CompositionBlockEditor-BlkVIJir.js +0 -2
- package/dist/assets/Data-D-7IMZzp.js +0 -2
- package/dist/assets/DeviceDetail-CATQ56bt.js +0 -2
- package/dist/assets/Identity-D60Odj5F.js +0 -1
- package/dist/assets/Library-BbXKoa8Z.js +0 -1
- package/dist/assets/Locations-DM8nnzTd.js +0 -3
- package/dist/assets/Notifications-BnUmb5Cg.js +0 -1
- package/dist/assets/Pipeline-SaA7yA5Z.js +0 -1
- package/dist/assets/client-LrzN1ATZ.js +0 -1119
- package/dist/assets/device-picker-model-BaM_HHUO.js +0 -1
- package/dist/assets/dist-p9ea9Hzu.js +0 -1119
- package/dist/assets/i18n-DWjQ9UFE.js +0 -1
- package/dist/assets/icons-Dfx79nBH.js +0 -1
- package/dist/assets/index-BsPM4J54.js +0 -4
- package/dist/assets/mount-BaM_HHUO.js +0 -1
- package/dist/assets/remoteEntry-DuqtB7i9.js +0 -1
- package/dist/assets/src-D5UhvHcp.js +0 -279
- package/dist/assets/useEventInvalidation-BaM_HHUO.js +0 -1
- package/dist/assets/useTemplateSave-CVoxjtyr.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,P as n,R as r,S as i,V as a,Y as o,et as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Za as c}from"./player-overlays-8aC2r-sd.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-BjdR__nc.js";s();var _={rect:`#ef4444`,polygon:`#3b82f6`,grid:`#6366f1`,line:`#f59e0b`},v=`33`,y=`66`,b=`#6366f1`,x=3,S=2,C=12,w=16,T=9;function E(e,t,n){return{x:e.x*t,y:e.y*n}}function D(e,t,n){return{x:e.x/t,y:e.y/n}}function O(e,t,n){return e.flatMap(e=>[e.x*t,e.y*n])}function k(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function A(e){return e.color??_[e.shape.kind]}function j(e,t){let n=e[t],r=e[(t+1)%e.length];if(!n||!r)return[...e];let i={x:(n.x+r.x)/2,y:(n.y+r.y)/2};return[...e.slice(0,t+1),i,...e.slice(t+1)]}function M(e,t){return e.length===t.length?e.every((e,n)=>{let r=t[n];return Math.abs(e.x-r.x)<1e-6&&Math.abs(e.y-r.y)<1e-6}):!1}function N(e){return e.kind===`polygon`||e.kind===`line`}function P({items:n,selectedId:s,onSelect:f,onShapeChange:p,onDrawComplete:m,drawingKind:v,supportedShapes:y,transparent:j=!1,backdrop:P,polygonVertices:F,grid:I}){let B=c(),V=t(null),[H,ee]=o({w:800,h:450}),[U,W]=o([]),[G,K]=o(null),[te,ne]=o(null),[q,J]=o(null),Y=v!==null&&y.includes(v);a(()=>{if(!q)return;let e=n.find(e=>e.id===q.itemId);if(!e||!N(e.shape)){J(null);return}M(e.shape.points,q.points)&&J(null)},[n,q]),a(()=>{let e=V.current;if(!e)return;let t=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect;ee(j?{w:n,h:r}:{w:n,h:n*9/16})});return t.observe(e),()=>t.disconnect()},[j]),a(()=>{!Y&&G!==null&&K(null)},[Y,G]);let X=r(e=>{m(e),W([])},[m]),re=r(e=>{if(!Y||v===null){f(null);return}let t=e.target.getStage();if(!t)return;let n=t.getPointerPosition();if(!n)return;let r=D(n,H.w,H.h);if(v===`rect`){let e=k(r.x),t=k(r.y);X({kind:`rect`,x:e,y:t,width:Math.min(.2,1-e),height:Math.min(.2,1-t)});return}if(v===`grid`){let e=I?.width??w,t=I?.height??T;X({kind:`grid`,gridWidth:e,gridHeight:t,cells:Array.from({length:e*t},()=>!1)});return}if(v===`line`){if(U.length===0){W([r]);return}X({kind:`line`,points:[...U,r]});return}if(v===`polygon`){if(U.length===0){W([r]);return}if(U.length>=x){let e=E(U[0],H.w,H.h);if(Math.hypot(n.x-e.x,n.y-e.y)<C){X({kind:`polygon`,points:U});return}}W(e=>[...e,r])}},[Y,v,U,H,I,X,f]),ie=r(e=>{!Y||v!==`polygon`||U.length<x||(e.cancelBubble=!0,X({kind:`polygon`,points:U}))},[Y,v,U,X]),Z=t(null),Q=t(null);a(()=>()=>{Z.current!==null&&cancelAnimationFrame(Z.current)},[]);let ae=r(e=>{if(!Y)return;let t=e.target.getStage();t&&(Q.current=t.getPointerPosition()??null,Z.current===null&&(Z.current=requestAnimationFrame(()=>{Z.current=null,K(Q.current)})))},[Y]),oe=t(!1),se=t(!0),ce=t(new Set),le=r((e,t,n,r)=>{let i=t.gridWidth*t.gridHeight;if(n<0||n>=i||t.cells[n]===r)return;let a=[...t.cells];for(;a.length<i;)a.push(!1);a.length=i,a[n]=r,p(e,{...t,cells:a})},[p]),$=[];if(!j){for(let e=1;e<w;e++){let t=H.w/w*e;$.push(i(u,{points:[t,0,t,H.h],stroke:`#ffffff`,strokeWidth:.5,opacity:.08},`gv-${e}`))}for(let e=1;e<T;e++){let t=H.h/T*e;$.push(i(u,{points:[0,t,H.w,t],stroke:`#ffffff`,strokeWidth:.5,opacity:.08},`gh-${e}`))}}return e(`div`,{ref:V,className:j?`absolute inset-0`:`relative w-full bg-zinc-900 rounded-lg overflow-hidden`,style:{cursor:Y?`crosshair`:`default`},children:[P&&!j?i(`div`,{className:`absolute inset-0 pointer-events-none [&>*]:w-full [&>*]:h-full [&>img]:object-cover [&>video]:object-cover`,style:{width:H.w,height:H.h},children:P}):null,e(l,{width:H.w,height:H.h,onClick:re,onDblClick:ie,onMouseMove:ae,children:[e(g,{listening:!1,children:[i(u,{points:[0,0,H.w,0,H.w,H.h,0,H.h,0,0],stroke:`transparent`,strokeWidth:0}),$]}),i(g,{children:n.map(e=>{let t=e.id===s,n=e.enabled===!1,r=A(e),a=t&&!Y&&!n;if(e.shape.kind===`rect`)return i(L,{item:e,shape:e.shape,color:r,selected:t,dimmed:n,editable:a,isDrawing:Y,size:H,onSelect:f,onShapeChange:p},e.id);if(e.shape.kind===`grid`)return i(R,{item:e,shape:e.shape,color:r,dimmed:n,editable:a,size:H,onSelect:f,paintingRef:oe,paintValueRef:se,paintedRef:ce,paintCell:le},e.id);let o=e.shape.kind===`line`,c=o?S:Math.max(x,F?.min??x),l=o?S:F?.max,u=q&&q.itemId===e.id?q.points:e.shape.points;return i(z,{item:e,shape:e.shape,color:r,selected:t,dimmed:n,editable:a,isLine:o,isDrawing:Y,size:H,effectivePoints:u,minVertices:c,maxVertices:l,isDragging:te===e.id,onSelect:f,onShapeChange:p,setDragOverride:J,setDraggingItemId:ne},e.id)})}),i(g,{listening:!1,children:Y&&U.length>0&&e(d,{children:[v===`polygon`&&U.length>=2&&i(u,{points:O(U,H.w,H.h),stroke:b,strokeWidth:1.5,dash:[6,3],opacity:.8}),v===`line`&&U.length===1&&G&&i(u,{points:[U[0].x*H.w,U[0].y*H.h,G.x,G.y],stroke:_.line,strokeWidth:1.5,dash:[6,3],opacity:.7}),v===`polygon`&&G&&U.length>=1&&i(u,{points:[U[U.length-1].x*H.w,U[U.length-1].y*H.h,G.x,G.y],stroke:b,strokeWidth:1,dash:[4,4],opacity:.5}),U.map((e,t)=>{let n=E(e,H.w,H.h),r=t===0&&v===`polygon`&&U.length>=x;return i(h,{x:n.x,y:n.y,radius:r?7:4,fill:r?b:`#ffffff`,stroke:b,strokeWidth:1.5,opacity:.9},t)})]})})]}),Y?i(`div`,{className:`px-3 py-1.5 bg-zinc-800/80 text-[11px] text-zinc-400 border-t border-zinc-700`,children:v===`line`?B(`uiLibrary.maskShapeCanvas.hintLine`,`Click to set the start point, click again to complete the line`):v===`rect`?B(`uiLibrary.maskShapeCanvas.hintRect`,`Click to drop a rectangle, then drag the corner to resize`):v===`grid`?B(`uiLibrary.maskShapeCanvas.hintGrid`,`Click to add the grid, then paint cells`):U.length<x?B(`uiLibrary.maskShapeCanvas.hintPoints`,`Click to add points (min 3). Double-click or click the first point to close.`):B(`uiLibrary.maskShapeCanvas.hintMore`,`Continue adding points. Double-click or click the first point to close.`)}):null]})}var F=.02;function I(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.width-t.width)<1e-6&&Math.abs(e.height-t.height)<1e-6}function L({item:t,shape:n,color:r,selected:s,dimmed:c,editable:l,isDrawing:u,size:m,onSelect:g,onShapeChange:_}){let[b,x]=o(null),S={x:n.x,y:n.y,width:n.width,height:n.height};a(()=>{b&&I(S,b)&&x(null)},[n.x,n.y,n.width,n.height,b]);let C=b??S,w=C.x*m.w,T=C.y*m.h,E=C.width*m.w,D=C.height*m.h,O=c?.35:s?1:.85,A=e=>{x(e),_(t.id,{kind:`rect`,x:e.x,y:e.y,width:e.width,height:e.height})};return i(d,{onClick:e=>{e.cancelBubble=!0,u||g(t.id)},children:e(d,{draggable:l,dragBoundFunc:l?e=>({x:Math.max(-w,Math.min(m.w-(w+E),e.x)),y:Math.max(-T,Math.min(m.h-(T+D),e.y))}):void 0,onDragEnd:l?e=>{let t=e.target,n=t.x()/m.w,r=t.y()/m.h;if(t.position({x:0,y:0}),n===0&&r===0)return;let i=Math.min(Math.max(0,C.x+n),Math.max(0,1-C.width)),a=Math.min(Math.max(0,C.y+r),Math.max(0,1-C.height));A({...C,x:i,y:a})}:void 0,onMouseEnter:e=>{if(!l)return;let t=e.target.getStage();t&&(t.container().style.cursor=`move`)},onMouseLeave:e=>{if(!l)return;let t=e.target.getStage();t&&(t.container().style.cursor=u?`crosshair`:`default`)},children:[i(p,{x:w,y:T,width:E,height:D,fill:r+(s?y:v),stroke:r,strokeWidth:s?2.5:1.5,opacity:O}),t.label?i(f,{x:w,y:T-16,text:t.label,fontSize:12,fill:r,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1}):null,l?i(h,{x:w+E,y:T+D,radius:6,fill:r,stroke:`#ffffff`,strokeWidth:1.5,draggable:!0,dragBoundFunc:e=>({x:Math.min(m.w,Math.max(w,e.x)),y:Math.min(m.h,Math.max(T,e.y))}),onDragStart:e=>{e.cancelBubble=!0},onDragMove:e=>{let t=e.target,n=k(t.x()/m.w-C.x),r=k(t.y()/m.h-C.y);x({...C,width:Math.max(F,Math.min(n,1-C.x)),height:Math.max(F,Math.min(r,1-C.y))})},onDragEnd:e=>{let t=e.target,n=k(t.x()/m.w-C.x),r=k(t.y()/m.h-C.y);A({...C,width:Math.max(F,Math.min(n,1-C.x)),height:Math.max(F,Math.min(r,1-C.y))})},onMouseEnter:e=>{let t=e.target.getStage();t&&(t.container().style.cursor=`nwse-resize`)},onMouseLeave:e=>{let t=e.target.getStage();t&&(t.container().style.cursor=`default`)}}):null]})})}function R({item:e,shape:t,color:n,dimmed:r,editable:a,size:o,onSelect:s,paintingRef:c,paintValueRef:l,paintedRef:u,paintCell:f}){let{gridWidth:m,gridHeight:h,cells:g}=t,_=o.w/m,v=o.h/h,b=m*h,x=r?.3:1,S=n=>{if(!a){s(e.id);return}let r=g[n]!==!0;c.current=!0,l.current=r,u.current=new Set([n]),f(e.id,t,n,r)},C=n=>{!c.current||!a||u.current.has(n)||(u.current.add(n),f(e.id,t,n,l.current))},w=()=>{c.current&&(c.current=!1,u.current=new Set)};return i(d,{opacity:x,onMouseUp:w,onMouseLeave:w,children:Array.from({length:b},(e,t)=>{let r=t%m,a=Math.floor(t/m),o=g[t]===!0;return i(p,{x:r*_,y:a*v,width:_,height:v,fill:o?n+y:`#ffffff10`,stroke:o?n:`#ffffff40`,strokeWidth:.5,onMouseDown:e=>{e.cancelBubble=!0,S(t)},onMouseEnter:()=>C(t)},t)})})}function z({item:t,shape:n,color:r,selected:a,dimmed:o,editable:s,isLine:c,isDrawing:l,size:p,effectivePoints:g,minVertices:_,maxVertices:b,isDragging:x,onSelect:S,onShapeChange:C,setDragOverride:w,setDraggingItemId:T}){let k=O(g,p.w,p.h),A=o?.35:a?1:c?.8:.85,M=e=>c?{kind:`line`,points:[...e]}:{kind:`polygon`,points:[...e]},N=g.map(e=>e.x*p.w),P=g.map(e=>e.y*p.h),F=N.length>0?Math.min(...N):0,I=N.length>0?Math.max(...N):0,L=P.length>0?Math.min(...P):0,R=P.length>0?Math.max(...P):0,z=e=>({x:Math.max(-F,Math.min(p.w-I,e.x)),y:Math.max(-L,Math.min(p.h-R,e.y))}),B=e=>{let r=e.target,i=r.x()/p.w,a=r.y()/p.h;if(r.position({x:0,y:0}),T(null),i===0&&a===0)return;let o=n.points.map(e=>({x:e.x+i,y:e.y+a}));w({itemId:t.id,points:o}),C(t.id,M(o))},V=!c&&g.length>_,H=!c&&(b===void 0||g.length<b);return e(d,{onClick:e=>{e.cancelBubble=!0,l||S(t.id)},children:[e(d,{draggable:s,dragBoundFunc:s?z:void 0,onDragStart:s?()=>T(t.id):void 0,onDragEnd:s?B:void 0,onMouseEnter:e=>{if(!s)return;let t=e.target.getStage();t&&(t.container().style.cursor=`move`)},onMouseLeave:e=>{if(!s)return;let t=e.target.getStage();t&&(t.container().style.cursor=l?`crosshair`:`default`)},children:[c?i(m,{points:k,stroke:r,strokeWidth:a?3:2,fill:r,pointerLength:10,pointerWidth:8,opacity:A}):i(u,{points:k,closed:!0,fill:r+(a?y:v),stroke:r,strokeWidth:a?2.5:1.5,opacity:A}),t.label&&g.length>0?(()=>{let e=E({x:g.reduce((e,t)=>e+t.x,0)/g.length,y:g.reduce((e,t)=>e+t.y,0)/g.length},p.w,p.h),n=Math.max(40,t.label.length*11*.62);return i(f,{x:e.x-n/2,y:e.y-7,width:n,align:`center`,text:t.label,fontSize:12,fill:r,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1})})():null]}),s&&!x&&g.map((e,a)=>{let o=E(e,p.w,p.h);return i(h,{x:o.x,y:o.y,radius:5,fill:r,stroke:`#ffffff`,strokeWidth:1.5,draggable:!0,onDragMove:e=>{let r=D({x:e.target.x(),y:e.target.y()},p.w,p.h);w(e=>{let i=e&&e.itemId===t.id?e.points:n.points;return{itemId:t.id,points:i.map((e,t)=>t===a?r:e)}})},onDragEnd:e=>{let r=D({x:e.target.x(),y:e.target.y()},p.w,p.h),i=n.points.map((e,t)=>t===a?r:e);w({itemId:t.id,points:i}),C(t.id,M(i))},onContextMenu:e=>{e.evt.preventDefault(),e.cancelBubble=!0,V&&C(t.id,M(n.points.filter((e,t)=>t!==a)))}},`pt-${a}`)}),s&&!x&&H&&g.length>=2&&g.map((e,a)=>{let o=g[(a+1)%g.length],s=E({x:(e.x+o.x)/2,y:(e.y+o.y)/2},p.w,p.h);return i(h,{x:s.x,y:s.y,radius:4,fill:`#ffffff`,stroke:r,strokeWidth:1.5,opacity:.6,onMouseEnter:e=>{let t=e.target;t.to({radius:6,opacity:1,duration:.1});let n=t.getStage();n&&(n.container().style.cursor=`copy`)},onMouseLeave:e=>{let t=e.target;t.to({radius:4,opacity:.6,duration:.1});let n=t.getStage();n&&(n.container().style.cursor=l?`crosshair`:`default`)},onClick:e=>{e.cancelBubble=!0,C(t.id,M(j(n.points,a)))}},`mid-${a}`)})]})}var B=n(P);export{B as MaskShapeCanvas};
|
|
1
|
+
import{C as e,J as t,P as n,R as r,S as i,V as a,Y as o,et as s}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 c}from"./player-overlays-ClFSGefV.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-BjdR__nc.js";s();var _={rect:`#ef4444`,polygon:`#3b82f6`,grid:`#6366f1`,line:`#f59e0b`},v=`33`,y=`66`,b=`#6366f1`,x=3,S=2,C=12,w=16,T=9;function E(e,t,n){return{x:e.x*t,y:e.y*n}}function D(e,t,n){return{x:e.x/t,y:e.y/n}}function O(e,t,n){return e.flatMap(e=>[e.x*t,e.y*n])}function k(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function A(e){return e.color??_[e.shape.kind]}function j(e,t){let n=e[t],r=e[(t+1)%e.length];if(!n||!r)return[...e];let i={x:(n.x+r.x)/2,y:(n.y+r.y)/2};return[...e.slice(0,t+1),i,...e.slice(t+1)]}function M(e,t){return e.length===t.length?e.every((e,n)=>{let r=t[n];return Math.abs(e.x-r.x)<1e-6&&Math.abs(e.y-r.y)<1e-6}):!1}function N(e){return e.kind===`polygon`||e.kind===`line`}function P({items:n,selectedId:s,onSelect:f,onShapeChange:p,onDrawComplete:m,drawingKind:v,supportedShapes:y,transparent:j=!1,backdrop:P,polygonVertices:F,grid:I}){let B=c(),V=t(null),[H,ee]=o({w:800,h:450}),[U,W]=o([]),[G,K]=o(null),[te,ne]=o(null),[q,J]=o(null),Y=v!==null&&y.includes(v);a(()=>{if(!q)return;let e=n.find(e=>e.id===q.itemId);if(!e||!N(e.shape)){J(null);return}M(e.shape.points,q.points)&&J(null)},[n,q]),a(()=>{let e=V.current;if(!e)return;let t=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect;ee(j?{w:n,h:r}:{w:n,h:n*9/16})});return t.observe(e),()=>t.disconnect()},[j]),a(()=>{!Y&&G!==null&&K(null)},[Y,G]);let X=r(e=>{m(e),W([])},[m]),re=r(e=>{if(!Y||v===null){f(null);return}let t=e.target.getStage();if(!t)return;let n=t.getPointerPosition();if(!n)return;let r=D(n,H.w,H.h);if(v===`rect`){let e=k(r.x),t=k(r.y);X({kind:`rect`,x:e,y:t,width:Math.min(.2,1-e),height:Math.min(.2,1-t)});return}if(v===`grid`){let e=I?.width??w,t=I?.height??T;X({kind:`grid`,gridWidth:e,gridHeight:t,cells:Array.from({length:e*t},()=>!1)});return}if(v===`line`){if(U.length===0){W([r]);return}X({kind:`line`,points:[...U,r]});return}if(v===`polygon`){if(U.length===0){W([r]);return}if(U.length>=x){let e=E(U[0],H.w,H.h);if(Math.hypot(n.x-e.x,n.y-e.y)<C){X({kind:`polygon`,points:U});return}}W(e=>[...e,r])}},[Y,v,U,H,I,X,f]),ie=r(e=>{!Y||v!==`polygon`||U.length<x||(e.cancelBubble=!0,X({kind:`polygon`,points:U}))},[Y,v,U,X]),Z=t(null),Q=t(null);a(()=>()=>{Z.current!==null&&cancelAnimationFrame(Z.current)},[]);let ae=r(e=>{if(!Y)return;let t=e.target.getStage();t&&(Q.current=t.getPointerPosition()??null,Z.current===null&&(Z.current=requestAnimationFrame(()=>{Z.current=null,K(Q.current)})))},[Y]),oe=t(!1),se=t(!0),ce=t(new Set),le=r((e,t,n,r)=>{let i=t.gridWidth*t.gridHeight;if(n<0||n>=i||t.cells[n]===r)return;let a=[...t.cells];for(;a.length<i;)a.push(!1);a.length=i,a[n]=r,p(e,{...t,cells:a})},[p]),$=[];if(!j){for(let e=1;e<w;e++){let t=H.w/w*e;$.push(i(u,{points:[t,0,t,H.h],stroke:`#ffffff`,strokeWidth:.5,opacity:.08},`gv-${e}`))}for(let e=1;e<T;e++){let t=H.h/T*e;$.push(i(u,{points:[0,t,H.w,t],stroke:`#ffffff`,strokeWidth:.5,opacity:.08},`gh-${e}`))}}return e(`div`,{ref:V,className:j?`absolute inset-0`:`relative w-full bg-zinc-900 rounded-lg overflow-hidden`,style:{cursor:Y?`crosshair`:`default`},children:[P&&!j?i(`div`,{className:`absolute inset-0 pointer-events-none [&>*]:w-full [&>*]:h-full [&>img]:object-cover [&>video]:object-cover`,style:{width:H.w,height:H.h},children:P}):null,e(l,{width:H.w,height:H.h,onClick:re,onDblClick:ie,onMouseMove:ae,children:[e(g,{listening:!1,children:[i(u,{points:[0,0,H.w,0,H.w,H.h,0,H.h,0,0],stroke:`transparent`,strokeWidth:0}),$]}),i(g,{children:n.map(e=>{let t=e.id===s,n=e.enabled===!1,r=A(e),a=t&&!Y&&!n;if(e.shape.kind===`rect`)return i(L,{item:e,shape:e.shape,color:r,selected:t,dimmed:n,editable:a,isDrawing:Y,size:H,onSelect:f,onShapeChange:p},e.id);if(e.shape.kind===`grid`)return i(R,{item:e,shape:e.shape,color:r,dimmed:n,editable:a,size:H,onSelect:f,paintingRef:oe,paintValueRef:se,paintedRef:ce,paintCell:le},e.id);let o=e.shape.kind===`line`,c=o?S:Math.max(x,F?.min??x),l=o?S:F?.max,u=q&&q.itemId===e.id?q.points:e.shape.points;return i(z,{item:e,shape:e.shape,color:r,selected:t,dimmed:n,editable:a,isLine:o,isDrawing:Y,size:H,effectivePoints:u,minVertices:c,maxVertices:l,isDragging:te===e.id,onSelect:f,onShapeChange:p,setDragOverride:J,setDraggingItemId:ne},e.id)})}),i(g,{listening:!1,children:Y&&U.length>0&&e(d,{children:[v===`polygon`&&U.length>=2&&i(u,{points:O(U,H.w,H.h),stroke:b,strokeWidth:1.5,dash:[6,3],opacity:.8}),v===`line`&&U.length===1&&G&&i(u,{points:[U[0].x*H.w,U[0].y*H.h,G.x,G.y],stroke:_.line,strokeWidth:1.5,dash:[6,3],opacity:.7}),v===`polygon`&&G&&U.length>=1&&i(u,{points:[U[U.length-1].x*H.w,U[U.length-1].y*H.h,G.x,G.y],stroke:b,strokeWidth:1,dash:[4,4],opacity:.5}),U.map((e,t)=>{let n=E(e,H.w,H.h),r=t===0&&v===`polygon`&&U.length>=x;return i(h,{x:n.x,y:n.y,radius:r?7:4,fill:r?b:`#ffffff`,stroke:b,strokeWidth:1.5,opacity:.9},t)})]})})]}),Y?i(`div`,{className:`px-3 py-1.5 bg-zinc-800/80 text-[11px] text-zinc-400 border-t border-zinc-700`,children:v===`line`?B(`uiLibrary.maskShapeCanvas.hintLine`,`Click to set the start point, click again to complete the line`):v===`rect`?B(`uiLibrary.maskShapeCanvas.hintRect`,`Click to drop a rectangle, then drag the corner to resize`):v===`grid`?B(`uiLibrary.maskShapeCanvas.hintGrid`,`Click to add the grid, then paint cells`):U.length<x?B(`uiLibrary.maskShapeCanvas.hintPoints`,`Click to add points (min 3). Double-click or click the first point to close.`):B(`uiLibrary.maskShapeCanvas.hintMore`,`Continue adding points. Double-click or click the first point to close.`)}):null]})}var F=.02;function I(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.width-t.width)<1e-6&&Math.abs(e.height-t.height)<1e-6}function L({item:t,shape:n,color:r,selected:s,dimmed:c,editable:l,isDrawing:u,size:m,onSelect:g,onShapeChange:_}){let[b,x]=o(null),S={x:n.x,y:n.y,width:n.width,height:n.height};a(()=>{b&&I(S,b)&&x(null)},[n.x,n.y,n.width,n.height,b]);let C=b??S,w=C.x*m.w,T=C.y*m.h,E=C.width*m.w,D=C.height*m.h,O=c?.35:s?1:.85,A=e=>{x(e),_(t.id,{kind:`rect`,x:e.x,y:e.y,width:e.width,height:e.height})};return i(d,{onClick:e=>{e.cancelBubble=!0,u||g(t.id)},children:e(d,{draggable:l,dragBoundFunc:l?e=>({x:Math.max(-w,Math.min(m.w-(w+E),e.x)),y:Math.max(-T,Math.min(m.h-(T+D),e.y))}):void 0,onDragEnd:l?e=>{let t=e.target,n=t.x()/m.w,r=t.y()/m.h;if(t.position({x:0,y:0}),n===0&&r===0)return;let i=Math.min(Math.max(0,C.x+n),Math.max(0,1-C.width)),a=Math.min(Math.max(0,C.y+r),Math.max(0,1-C.height));A({...C,x:i,y:a})}:void 0,onMouseEnter:e=>{if(!l)return;let t=e.target.getStage();t&&(t.container().style.cursor=`move`)},onMouseLeave:e=>{if(!l)return;let t=e.target.getStage();t&&(t.container().style.cursor=u?`crosshair`:`default`)},children:[i(p,{x:w,y:T,width:E,height:D,fill:r+(s?y:v),stroke:r,strokeWidth:s?2.5:1.5,opacity:O}),t.label?i(f,{x:w,y:T-16,text:t.label,fontSize:12,fill:r,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1}):null,l?i(h,{x:w+E,y:T+D,radius:6,fill:r,stroke:`#ffffff`,strokeWidth:1.5,draggable:!0,dragBoundFunc:e=>({x:Math.min(m.w,Math.max(w,e.x)),y:Math.min(m.h,Math.max(T,e.y))}),onDragStart:e=>{e.cancelBubble=!0},onDragMove:e=>{let t=e.target,n=k(t.x()/m.w-C.x),r=k(t.y()/m.h-C.y);x({...C,width:Math.max(F,Math.min(n,1-C.x)),height:Math.max(F,Math.min(r,1-C.y))})},onDragEnd:e=>{let t=e.target,n=k(t.x()/m.w-C.x),r=k(t.y()/m.h-C.y);A({...C,width:Math.max(F,Math.min(n,1-C.x)),height:Math.max(F,Math.min(r,1-C.y))})},onMouseEnter:e=>{let t=e.target.getStage();t&&(t.container().style.cursor=`nwse-resize`)},onMouseLeave:e=>{let t=e.target.getStage();t&&(t.container().style.cursor=`default`)}}):null]})})}function R({item:e,shape:t,color:n,dimmed:r,editable:a,size:o,onSelect:s,paintingRef:c,paintValueRef:l,paintedRef:u,paintCell:f}){let{gridWidth:m,gridHeight:h,cells:g}=t,_=o.w/m,v=o.h/h,b=m*h,x=r?.3:1,S=n=>{if(!a){s(e.id);return}let r=g[n]!==!0;c.current=!0,l.current=r,u.current=new Set([n]),f(e.id,t,n,r)},C=n=>{!c.current||!a||u.current.has(n)||(u.current.add(n),f(e.id,t,n,l.current))},w=()=>{c.current&&(c.current=!1,u.current=new Set)};return i(d,{opacity:x,onMouseUp:w,onMouseLeave:w,children:Array.from({length:b},(e,t)=>{let r=t%m,a=Math.floor(t/m),o=g[t]===!0;return i(p,{x:r*_,y:a*v,width:_,height:v,fill:o?n+y:`#ffffff10`,stroke:o?n:`#ffffff40`,strokeWidth:.5,onMouseDown:e=>{e.cancelBubble=!0,S(t)},onMouseEnter:()=>C(t)},t)})})}function z({item:t,shape:n,color:r,selected:a,dimmed:o,editable:s,isLine:c,isDrawing:l,size:p,effectivePoints:g,minVertices:_,maxVertices:b,isDragging:x,onSelect:S,onShapeChange:C,setDragOverride:w,setDraggingItemId:T}){let k=O(g,p.w,p.h),A=o?.35:a?1:c?.8:.85,M=e=>c?{kind:`line`,points:[...e]}:{kind:`polygon`,points:[...e]},N=g.map(e=>e.x*p.w),P=g.map(e=>e.y*p.h),F=N.length>0?Math.min(...N):0,I=N.length>0?Math.max(...N):0,L=P.length>0?Math.min(...P):0,R=P.length>0?Math.max(...P):0,z=e=>({x:Math.max(-F,Math.min(p.w-I,e.x)),y:Math.max(-L,Math.min(p.h-R,e.y))}),B=e=>{let r=e.target,i=r.x()/p.w,a=r.y()/p.h;if(r.position({x:0,y:0}),T(null),i===0&&a===0)return;let o=n.points.map(e=>({x:e.x+i,y:e.y+a}));w({itemId:t.id,points:o}),C(t.id,M(o))},V=!c&&g.length>_,H=!c&&(b===void 0||g.length<b);return e(d,{onClick:e=>{e.cancelBubble=!0,l||S(t.id)},children:[e(d,{draggable:s,dragBoundFunc:s?z:void 0,onDragStart:s?()=>T(t.id):void 0,onDragEnd:s?B:void 0,onMouseEnter:e=>{if(!s)return;let t=e.target.getStage();t&&(t.container().style.cursor=`move`)},onMouseLeave:e=>{if(!s)return;let t=e.target.getStage();t&&(t.container().style.cursor=l?`crosshair`:`default`)},children:[c?i(m,{points:k,stroke:r,strokeWidth:a?3:2,fill:r,pointerLength:10,pointerWidth:8,opacity:A}):i(u,{points:k,closed:!0,fill:r+(a?y:v),stroke:r,strokeWidth:a?2.5:1.5,opacity:A}),t.label&&g.length>0?(()=>{let e=E({x:g.reduce((e,t)=>e+t.x,0)/g.length,y:g.reduce((e,t)=>e+t.y,0)/g.length},p.w,p.h),n=Math.max(40,t.label.length*11*.62);return i(f,{x:e.x-n/2,y:e.y-7,width:n,align:`center`,text:t.label,fontSize:12,fill:r,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1})})():null]}),s&&!x&&g.map((e,a)=>{let o=E(e,p.w,p.h);return i(h,{x:o.x,y:o.y,radius:5,fill:r,stroke:`#ffffff`,strokeWidth:1.5,draggable:!0,onDragMove:e=>{let r=D({x:e.target.x(),y:e.target.y()},p.w,p.h);w(e=>{let i=e&&e.itemId===t.id?e.points:n.points;return{itemId:t.id,points:i.map((e,t)=>t===a?r:e)}})},onDragEnd:e=>{let r=D({x:e.target.x(),y:e.target.y()},p.w,p.h),i=n.points.map((e,t)=>t===a?r:e);w({itemId:t.id,points:i}),C(t.id,M(i))},onContextMenu:e=>{e.evt.preventDefault(),e.cancelBubble=!0,V&&C(t.id,M(n.points.filter((e,t)=>t!==a)))}},`pt-${a}`)}),s&&!x&&H&&g.length>=2&&g.map((e,a)=>{let o=g[(a+1)%g.length],s=E({x:(e.x+o.x)/2,y:(e.y+o.y)/2},p.w,p.h);return i(h,{x:s.x,y:s.y,radius:4,fill:`#ffffff`,stroke:r,strokeWidth:1.5,opacity:.6,onMouseEnter:e=>{let t=e.target;t.to({radius:6,opacity:1,duration:.1});let n=t.getStage();n&&(n.container().style.cursor=`copy`)},onMouseLeave:e=>{let t=e.target;t.to({radius:4,opacity:.6,duration:.1});let n=t.getStage();n&&(n.container().style.cursor=l?`crosshair`:`default`)},onClick:e=>{e.cancelBubble=!0,C(t.id,M(j(n.points,a)))}},`mid-${a}`)})]})}var B=n(P);export{B as MaskShapeCanvas};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{K as te,Qa as c,U as l,X as u,Ya as ne,n as re,ri as d,vt as f,z as p}from"./player-overlays-ClFSGefV.js";import{MaskShapeCanvas as m}from"./MaskShapeCanvas-BN-PRLjb.js";s();var ie=110,h=`motion-zones`,g=0,_=[1,2,3],v=1,y=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,b=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function x(e,t,n){let r=t*n,i=Array.from({length:r});for(let t=0;t<r;t+=1)i[t]=e[t]===!0;return i}function S(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function C(e,t){return Math.ceil(e/t)}function w(e,t,n){return Math.min(n-1,Math.floor((e+.5)/t*n))}function T(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:i*a},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)e[r*t+n]===!0&&(o[s*i+w(n,t,i)]=!0)}return o}function E(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:t*n},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)o[r*t+n]=e[s*i+w(n,t,i)]===!0}return o}function D({deviceId:s}){let w=c(),D=te(f().trpcClient,s),[O,k]=o(null),[A,j]=o(!1),[M,N]=o(null),[P,F]=o(null),[I,L]=o(v),[R,z]=o(!1),[B,V]=o(!1),H=t(!1);a(()=>{if(!D)return;let e=!1;return H.current=!1,k(null),j(!1),N(null),F(null),L(v),V(!1),(async()=>{try{let t=await D.motionZones?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(k(t),H.current)return;let n=await D.motionZones?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);H.current=!0;let r=n.regions.find(e=>e.shape.kind===`grid`),i=x(r?r.shape.cells:[],t.grid.width,t.grid.height);F(i),N(T(i,t.grid.width,t.grid.height,v))}catch(t){if(e)return;l(t)?j(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[D]);let U=O?O.grid.width:0,W=O?O.grid.height:0,G=C(U,I),K=C(W,I),q=n(()=>M&&O?E(M,U,W,I):null,[M,O,U,W,I]),J=n(()=>q!==null&&P!==null&&!S(q,P),[q,P]),ae=n(()=>q?q.reduce((e,t)=>t?e+1:e,0):0,[q]),oe=U*W,Y=G*K,X=r(e=>{Y>0&&N(Array.from({length:Y},()=>e))},[Y]),se=r(()=>{N(e=>e&&e.map(e=>!e))},[]),Z=r(()=>{P&&O&&N(T(P,U,W,I))},[P,O,U,W,I]),ce=r(e=>{e===I||!O||N(t=>{if(!t)return L(e),t;let n=T(E(t,U,W,I),U,W,e);return L(e),n})},[I,O,U,W]),Q=n(()=>O&&M?[{id:g,shape:{kind:`grid`,gridWidth:G,gridHeight:K,cells:[...M]}}]:[],[O,M,G,K]),$=r((e,t)=>{t.kind===`grid`&&N(t.cells)},[]),le=r(async()=>{if(!(!D||!M||!O)){z(!0);try{let e=E(M,O.grid.width,O.grid.height,I),t={kind:`grid`,gridWidth:O.grid.width,gridHeight:O.grid.height,cells:e};await D.motionZones?.setZone({patch:{regions:[{id:g,enabled:!0,shape:t}]}});let n=await D.motionZones?.getStatus({});if(n){let e=n.regions.find(e=>e.shape.kind===`grid`),t=x(e?e.shape.cells:[],O.grid.width,O.grid.height);F(t),N(T(t,O.grid.width,O.grid.height,I))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{z(!1)}}},[D,M,O,I]);re(n(()=>B&&!A&&O&&M?{id:h,order:ie,node:i(m,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:G,height:K},selectedId:g,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[B,A,O,M,Q,$,G,K]));let ue=!A&&O!==null&&M!==null;return D?i(u,{title:w(`uiLibrary.motionZones.title`,`Motion Zones`),icon:i(d,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:i(`div`,{className:`flex flex-col gap-3`,children:A?i(`p`,{className:`${p} leading-relaxed`,children:w(`uiLibrary.motionZones.unsupported`,`This camera doesn't expose an on-board motion zones grid.`)}):ue?e(ee,{children:[i(`p`,{className:`${p} leading-relaxed`,children:i(ne,{uiKey:`uiLibrary.motionZones.intro`,fallback:`Toggle <0>Edit grid</0> to paint the region directly on the live frame, then <1>Save</1> to push the mask to the camera. Pick a bigger <2>Cell size</2> for quicker, broad-stroke painting — it's resampled to the camera's native {{width}}×{{height}} grid on save (×1 is the finest).`,components:[i(`strong`,{className:`text-foreground`},`e`),i(`strong`,{className:`text-foreground`},`s`),i(`strong`,{className:`text-foreground`},`c`)],values:{width:O.grid.width,height:O.grid.height}})}),e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[i(`button`,{type:`button`,onClick:()=>V(e=>!e),disabled:R,"aria-pressed":B,className:B?b:y,children:B?w(`uiLibrary.motionZones.doneEditing`,`Done editing`):w(`uiLibrary.motionZones.editGrid`,`Edit grid`)}),i(`button`,{type:`button`,onClick:()=>X(!0),disabled:R,className:y,children:w(`uiLibrary.motionZones.allOn`,`All on`)}),i(`button`,{type:`button`,onClick:()=>X(!1),disabled:R,className:y,children:w(`uiLibrary.motionZones.allOff`,`All off`)}),i(`button`,{type:`button`,onClick:se,disabled:R,className:y,children:w(`uiLibrary.motionZones.invert`,`Invert`)}),e(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":w(`uiLibrary.motionZones.cellSize`,`Cell size`),children:[i(`span`,{className:`${p} mr-0.5`,children:w(`uiLibrary.motionZones.cellSize`,`Cell size`)}),_.map(t=>e(`button`,{type:`button`,onClick:()=>ce(t),disabled:R,"aria-pressed":I===t,title:t===1?w(`uiLibrary.motionZones.cameraGrid`,`Camera grid {{width}}×{{height}} (finest)`,{width:U,height:W}):w(`uiLibrary.motionZones.paintingGrid`,`{{width}}×{{height}} painting grid · cells ×{{factor}} bigger`,{width:C(U,t),height:C(W,t),factor:t}),className:I===t?b:y,children:[`×`,t]},t))]}),e(`span`,{className:`${p} ml-1 tabular-nums`,children:[w(`uiLibrary.motionZones.cells`,`{{active}} / {{total}} cells · {{width}}×{{height}}`,{active:ae,total:oe,width:O.grid.width,height:O.grid.height}),I===1?``:w(`uiLibrary.motionZones.paintSuffix`,` · paint {{width}}×{{height}}`,{width:G,height:K})]}),i(`span`,{className:`flex-1`}),i(`button`,{type:`button`,onClick:Z,disabled:R||!J,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:w(`uiLibrary.motionZones.revert`,`Revert`)}),i(`button`,{type:`button`,onClick:()=>void le(),disabled:R||!J,className:b,children:R?w(`uiLibrary.motionZones.saving`,`Saving…`):w(`uiLibrary.motionZones.save`,`Save`)})]})]}):i(`p`,{className:`${p} leading-relaxed`,children:w(`uiLibrary.motionZones.loading`,`Loading the camera's grid…`)})})}):null}export{D as MotionZonesSettings};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-BHo8W_uH.js","./rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{C as n,J as r,K as i,S as a,V as o,Y as s,a as c,et as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Di as f,Fr as p,Ki as m,Mn as h,Mr as g,Oa as _,Q as v,Rr as y,Sn as b,Ur as x,Wi as S,Xt as C,Za as w,ct as T,dt as E,en as D,lr as O,pi as k,vt as A}from"./player-overlays-8aC2r-sd.js";import{vi as j,yi as M}from"./client-LrzN1ATZ.js";import{l as ee,o as N}from"./terminal-DU-tvcEm.js";import{t as P}from"./monitor-smartphone-DPI9EQus.js";import{t as te}from"./unlink-D3-IGpS8.js";import{$f as F,$i as ne,Gf as I,Mi as L,Sr as re,cl as ie,ft as ae,ji as oe,kp as R,ol as se}from"./src-D5UhvHcp.js";import{t as ce}from"./i18n-DWjQ9UFE.js";import{t as z}from"./useTranslation-BJr-n0es.js";import"./mount-BaM_HHUO.js";import{c as le,i as ue,l as B,s as V}from"./sso-popup-C_VTtoWT.js";import{F as H,di as U,hi as de,i as W,li as G}from"./index-BsPM4J54.js";import{t as fe}from"./AdminSectionedPage-C7Nx9jJl.js";import{t as pe}from"./AdminPage-BEQJlUNo.js";import{D as me,O as he,_ as ge,a as _e,h as ve,r as ye,t as be,w as xe}from"./SessionsList-C1Ao7w_G.js";l();var Se=`${j}/connect`,K={public:0,mesh:1,lan:2,"lan-ipv6":3};function Ce(e){switch(e.kind){case`public`:return e.interfaceKind===`vpn`?`mesh`:`public`;case`lan-ipv4`:return`lan`;case`lan-ipv6`:return`lan-ipv6`;case`custom`:return`public`;case`loopback`:case`app-link`:return null}}function q(e){return M(e)}function we(e){return e.startsWith(`https://`)}function Te(e){let t=e.flatMap(e=>{let t=Ce(e),n=q(e.baseUrl);return t===null||n===null?[]:[{endpoint:e,tier:t,origin:n}]}).toSorted((e,t)=>K[e.tier]-K[t.tier]||Number(t.endpoint.plausible)-Number(e.endpoint.plausible)||e.endpoint.priority-t.endpoint.priority),n=new Set;return t.flatMap(({endpoint:e,tier:t,origin:r})=>n.has(r)?[]:(n.add(r),[{origin:r,label:e.label,tier:t,secure:we(r),plausible:e.plausible}]))}function Ee(e,t,n=null){for(let r of[t,n]){if(r===null)continue;let t=q(r),n=e.find(e=>e.origin===t);if(n!==void 0)return n}return e[0]??null}function De(e){let t=new URL(Se);return t.searchParams.set(`hub`,e),t.toString()}var Oe=176,J={scheme:`https`};function ke(){let{t:e}=z(),t=ie(J),r=se(J).data?.roles.publicEndpoint.resolved??null;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(b,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?n(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(p,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?n(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[a(C,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),n(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[a(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),a(I,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):a(Ae,{candidates:Te(t.data.endpoints),preferredOrigin:r})]})]})}function Ae({candidates:e,preferredOrigin:t}){let{t:r}=z(),[o,c]=s(null),l=Ee(e,o,t),u=i(()=>l?De(l.origin):null,[l]);if(l===null||u===null)return a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.empty`)});let d=e=>r(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${d(e.tier)} — ${e.origin}`}));return n(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[a(oe,{value:u,size:Oe,alt:r(`connectPhone.qrAlt`),className:`self-start`}),n(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[n(`label`,{className:`block space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.addressLabel`)}),a(E,{value:l.origin,options:f,onChange:e=>c(e.target.value)}),n(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[d(l.tier),` · `,l.label]})]}),!l.secure&&a(Y,{text:r(`connectPhone.insecure`)}),!l.plausible&&a(Y,{text:r(`connectPhone.implausible`)}),n(`div`,{className:`space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.linkLabel`)}),n(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[a(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:u}),a(re,{value:u,srLabel:r(`connectPhone.linkLabel`)})]})]}),a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.signInHint`)})]})]})}function Y({text:e}){return n(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[a(C,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),a(`span`,{children:e})]})}l();function je(e){return new Date(e).toLocaleDateString()}function Me(){let{t:e}=z(),t=T(),i=R.useUtils(),c=R.auth.listLinkableProviders.useQuery(),l=R.auth.listOwnExternalIdentities.useQuery(),[u,d]=s(null),[f,h]=s(()=>B(window.location.search)),g=r(null),_=W(`Linking a sign-in account`),b=r(null);o(()=>()=>b.current?.(),[]);let[x,C]=s(null);o(()=>{if(f===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[f]);let w=R.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=g.current;if(g.current=null,t===null||t.closed){window.location.assign(e);return}let n=e=>{C(null),h(B(`?${e}`)),i.auth.listOwnExternalIdentities.invalidate()};b.current?.(),b.current=V(t,{onReturn:e=>{e.target===`profile`&&n(e.query)},onDone:e=>{e.target===`profile`&&n(e.query)},onClosed:()=>{b.current?.(),b.current=null,i.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=v(le(e))},onError:e=>{g.current?.close(),g.current=null,C(null),d(e.message)}}),E=R.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void i.auth.listOwnExternalIdentities.invalidate(),onError:e=>d(e.message)}),D=c.data??[],O=l.data??[],k=x!==null&&O.some(e=>e.provider===x);if(o(()=>{!k||x===null||(C(null),h({kind:`linked`,provider:x}))},[k,x]),D.length===0&&O.length===0)return null;let A=new Set(O.map(e=>e.provider)),j=e=>D.find(t=>t.provider===e)?.label??e,M=async(n,r)=>{await t({title:e(`users.linkedSignInsSection.unlinkSignInAccount`,`Unlink sign-in account`),message:e(`users.linkedSignInsSection.stopSigningInWithThis`,`Stop signing in with this {{label}} account?`,{label:r}),confirmLabel:e(`users.linkedSignInsSection.unlink`,`Unlink`),variant:`danger`})&&(d(null),E.mutate({provider:n.provider,subject:n.subject}))};return n(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[_.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(y,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`users.linkedSignInsSection.signInWithAnExternal`,`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`)}),f?.kind===`linked`&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[a(S,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:j(f.provider)})]}),(f?.kind===`error`||u)&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[a(m,{className:`h-3.5 w-3.5 shrink-0`}),u??(f?.kind===`error`?f.message:``)]}),O.length>0&&a(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:O.map(t=>{let r=t.providerLabel??t.provider;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`font-medium text-foreground truncate`,children:[r,!t.available&&a(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:e(`users.linkedSignInsSection.providerUnavailable`,`provider unavailable`)})]}),a(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:je(t.linkedAt)})})]}),n(I,{variant:`unstyled`,onClick:()=>void M(t,r),disabled:E.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[a(te,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),a(`div`,{className:`flex flex-wrap gap-2`,children:D.filter(e=>!A.has(e.provider)).map(t=>n(I,{variant:`unstyled`,onClick:()=>{d(null),h(null),_.requestProof().then(e=>{e!==null&&(g.current=ue(null),C(g.current===null?null:t.provider),w.mutate({provider:t.provider,reauthToken:e}))})},disabled:w.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[w.isPending&&w.variables?.provider===t.provider?a(p,{className:`h-3 w-3 animate-spin`}):a(y,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}l();function Ne({value:r,size:i=192}){let{t:c}=z(),[l,u]=s(null),[d,f]=s(null);if(o(()=>{let n=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(n)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(r,{errorCorrectionLevel:`M`});n||u(e)}catch(e){n||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{n||f(`qrcode library not installed`)}),()=>{n=!0}},[r]),d)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:c(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!l)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:c(`users.totpQrCode.generating`,`Generating…`)});let p=l.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)l.modules.data[e*p+t]&&h.push(a(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return n(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[a(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}l();function Pe(){let{t:e}=z(),t=A(),[r,i]=s(``),[o,c]=s(``),[l,d]=s(``),[f,h]=s(null),_=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{h({kind:`success`,msg:`Password updated.`}),i(``),c(``),d(``)},onError:e=>{h({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),v=o.length>0&&l.length>0&&o!==l,y=o.length>0&&o.length<8,b=r.length>=1&&o.length>=8&&o===l;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(X,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:r,onChange:i,autoComplete:`current-password`}),a(X,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:o,onChange:c,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),a(X,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:l,onChange:d,autoComplete:`new-password`}),(v||y)&&a(`div`,{className:`text-[11px] text-danger`,children:v?e(`systemPage.myAccess.passwordsDoNotMatch`,`Passwords do not match.`):e(`systemPage.myAccess.newPasswordMustBeAt`,`New password must be at least 8 characters.`)}),f&&n(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-success`:`text-danger`}`,children:[f.kind===`success`?a(S,{className:`h-3 w-3`}):a(m,{className:`h-3 w-3`}),f.msg]}),a(`div`,{className:`flex justify-end`,children:n(I,{onClick:()=>{h(null),_.mutate({currentPassword:r,newPassword:o})},disabled:!b||_.isPending,children:[_.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(g,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function X({label:e,value:t,onChange:r,autoComplete:i,hint:o}){return n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),a(F,{type:`password`,value:t,onChange:e=>r(e.target.value),autoComplete:i,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),o&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:o})]})}function Fe({username:e}){let{t}=z(),r=A(),l=c({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>r.getOwnTotpStatus()}),h=l.data,[g,_]=s(null),[v,y]=s(``),[x,C]=s(null),[w,T]=s(!1),E=u({mutationFn:()=>r.setupOwnTotp(),onSuccess:e=>{_({secret:e.secret,otpauthUrl:e.otpauthUrl}),y(``),C(null)},onError:e=>C(e instanceof Error?e.message:`Setup failed`)}),D=u({mutationFn:e=>r.confirmOwnTotp(e),onSuccess:()=>{_(null),y(``),C(null),l.refetch()},onError:e=>C(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),O=W(`Turning off two-factor authentication`),k=u({mutationFn:async()=>{let e=await O.requestProof();return e===null?null:r.disableOwnTotp({reauthToken:e})},onSuccess:()=>{C(null),l.refetch()},onError:e=>C(e instanceof Error?e.message:`Disable failed`)});o(()=>{if(!w)return;let e=setTimeout(()=>T(!1),1500);return()=>clearTimeout(e)},[w]);let j=i(()=>l.isLoading?`loading`:g?`setup_in_progress`:h?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,h?.enabled,g]);return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[O.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(b,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&n(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(p,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&n(d,{children:[a(`div`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.2faIsnTActiveOn`,`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`)}),a(`div`,{className:`flex justify-end`,children:n(I,{onClick:()=>{C(null),E.mutate()},disabled:E.isPending,children:[E.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(b,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&g&&n(d,{children:[a(`div`,{className:`text-[11px] text-foreground-subtle`,children:a(G,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:a(`span`,{className:`font-mono`})}})}),n(`div`,{className:`flex flex-col items-center gap-3`,children:[a(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:a(Ne,{value:g.otpauthUrl,size:180})}),n(`div`,{className:`w-full`,children:[a(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),n(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[a(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:g.secret}),n(I,{variant:`ghost`,onClick:()=>{g&&navigator.clipboard.writeText(g.secret).then(()=>T(!0))},children:[w?a(S,{className:`h-3 w-3 text-success`}):a(f,{className:`h-3 w-3`}),w?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),a(F,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:v,onChange:e=>y(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),x&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(m,{className:`h-3 w-3`}),x]}),n(`div`,{className:`flex justify-end gap-2`,children:[a(I,{variant:`outline`,onClick:()=>{_(null),C(null),y(``)},children:t(`common.cancel`,`Cancel`)}),n(I,{onClick:()=>{C(null),D.mutate({code:v})},disabled:D.isPending||v.length!==6,children:[D.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(S,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&h&&n(d,{children:[n(`div`,{className:`rounded-md border border-success/30 bg-success/5 px-3 py-2.5 flex items-start gap-2.5`,children:[a(S,{className:`h-4 w-4 mt-0.5 text-success shrink-0`}),n(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[a(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),a(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:h.confirmedAt?new Date(h.confirmedAt).toLocaleString():`—`})})]})]}),x&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(m,{className:`h-3 w-3`}),x]}),a(`div`,{className:`flex justify-end`,children:n(I,{variant:`danger`,onClick:()=>{C(null),k.mutate()},disabled:k.isPending,children:[k.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(b,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Ie(){return ne(`auth-webauthn/passkey-enrollment`)?a(L,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}l();function Z(e){return e.message.length>0?e.message:ce.t(`auth.authAuditSection.requestFailed`)}function Le(){let{t:e}=z(),{logout:t}=H(),r=T(),i=R.useUtils(),o=R.auth.listOwnSessions.useQuery(),[c,l]=s(null),u=R.auth.revokeOwnSession.useMutation({onSuccess:()=>void i.auth.listOwnSessions.invalidate(),onError:e=>l(`Sign out failed: ${Z(e)}`)}),d=R.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>l(`Sign out failed: ${Z(e)}`)}),f=async t=>{await r({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:ge(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(l(null),u.mutate({id:t.id}))},m=async()=>{await r({title:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),message:e(`auth.mySessionsSection.everySessionOfYourAccount`,`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`),confirmLabel:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(l(null),d.mutate({everywhere:!0}))};return n(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(P,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`auth.mySessionsSection.theBrowsersAndAppsSigned`,`The browsers and apps signed in to your account. Signing one out ends it at once.`)}),c!==null&&a(`div`,{className:`text-[11px] text-danger`,children:c}),a(be,{sessions:o.data??[],isLoading:o.isLoading,loadError:o.isError?o.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:u.isPending?u.variables?.id??null:null}),a(`div`,{className:`flex justify-end`,children:n(I,{variant:`unstyled`,onClick:()=>void m(),disabled:d.isPending,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[d.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(N,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}l();var Re=`You`;function Q(){let{t:e}=z(),t=T(),n=R.useUtils(),r=R.auth.listOwnDeviceCredentials.useQuery(),[o,c]=s(null),l=R.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||c(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>c(`Revoke failed: ${e.message}`)}),u=i(()=>(r.data??[]).map(e=>ye(e,Re)),[r.data]),d=async n=>{await t({title:e(`certificates.myDevicesSection.revoke`,`Revoke "{{name}}"?`,{name:n.name}),message:e(`certificates.myDevicesSection.theDeviceStopsSigningIn`,`The device stops signing in at once and its open sessions end. To use it again you have to pair it anew. This cannot be undone.`),confirmLabel:e(`certificates.myDevicesSection.revoke2`,`Revoke`),variant:`danger`})&&(c(null),l.mutate({id:n.id}))},f={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:_,isAvailable:_e,onRun:e=>void d(e),busyId:l.isPending?l.variables?.id??null:null,disabled:l.isPending};return a(me,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:b,description:e(`certificates.myDevicesSection.phonesThatStaySignedIn`,`Phones that stay signed in to your account with a certificate. If one is lost, revoke it here and it is signed out at once.`),notice:he(o),onDismissNotice:()=>c(null),children:a(xe,{rows:u,label:e(`certificates.devicesCard.label`),isLoading:r.isPending,loadError:r.error===null?null:r.error.message||`Request failed`,emptyText:`No devices are signed in with a certificate.`,hideOwner:!0,expiresNone:`—`,action:f})})}var $={profile:`profile`,signIn:`sign-in`,sessions:`sessions`,tokens:`tokens`},ze=[`linked`,`linkError`],Be={view:{icon:k,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:O,cls:`bg-primary/15 text-primary`},delete:{icon:D,cls:`bg-danger/15 text-danger`}};function Ve(){let{t:e}=z(),{user:t,logout:r}=H(),[i]=de(),o=e(`system.myAccess`,`My access`);if(!t)return a(pe,{icon:h,title:o,children:a(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});if(i.get(`tab`)===`preferences`)return a(U,{to:`/system/settings`,replace:!0});if(ze.some(e=>i.has(e))&&!i.has(`tab`)){let e=new URLSearchParams(i);return e.set(`tab`,$.signIn),a(U,{to:`?${e.toString()}`,replace:!0})}return a(fe,{icon:h,title:o,subtitle:e(`systemPage.myAccess.subtitle`,`Your account, how you sign in, where you are signed in, and your tokens.`),sectionsLabel:e(`systemPage.myAccess.sectionsLabel`,`My access sections`),defaultSection:$.profile,actions:n(I,{variant:`outline`,onClick:r,children:[a(N,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]}),sections:[{id:$.profile,label:e(`systemPage.myAccess.sections.profile`,`Profile`),content:a(He,{user:t})},{id:$.signIn,label:e(`systemPage.myAccess.sections.signIn`,`Sign-in & security`),content:n(`div`,{className:`space-y-4`,children:[a(Pe,{}),a(Fe,{username:t.username}),a(Ie,{}),a(Me,{})]})},{id:$.sessions,label:e(`systemPage.myAccess.sections.sessions`,`Sessions & devices`),content:n(`div`,{className:`space-y-4`,children:[a(Le,{}),a(Q,{}),a(ke,{})]})},{id:$.tokens,label:e(`systemPage.myAccess.sections.tokens`,`Tokens`),content:a(ve,{ownOnly:!0})}]})}function He({user:e}){let{t}=z(),r=e.isAdmin,i=e.scopes??[];return n(`div`,{className:`space-y-4`,children:[n(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[a(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),n(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),n(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r?t(`systemPage.myAccess.administrator`,`Administrator`):t(`systemPage.myAccess.user`,`User`),` `,a(G,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:e.id.slice(0,8)},components:{mono:a(`span`,{className:`font-mono`})}})]})]})]}),r&&n(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[a(x,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),n(`div`,{children:[a(`div`,{className:`font-semibold text-foreground`,children:t(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),a(`p`,{className:`text-foreground-subtle mt-0.5`,children:t(`systemPage.myAccess.adminSessionsBypassThePer`,`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`)})]})]}),i.length>0&&a(Ue,{scopes:i})]})}function Ue({scopes:e}){let{t}=z(),r=w();return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2 border-b border-border`,children:[a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`systemPage.myAccess.bakedIntoYourSessionToken`,`Baked into your session token at login; sign out + back in to refresh after changes.`)})]}),n(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[a(`div`,{children:t(`systemPage.myAccess.type`,`Type`)}),a(`div`,{children:t(`systemPage.myAccess.target`,`Target`)}),a(`div`,{children:t(`systemPage.myAccess.access`,`Access`)})]}),a(`ul`,{className:`divide-y divide-border`,children:e.map((e,i)=>n(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[a(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),a(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?ae(e.selector,r):e.target}),a(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(r=>{let i=e.access.includes(r),{icon:o,cls:s}=Be[r];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${i?s:`bg-transparent text-foreground-subtle/40 line-through`}`,title:i?t(`systemPage.myAccess.can`,`Can {{a}}`,{a:r}):t(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:r}),children:[a(o,{className:`h-3 w-3`}),r]},r)})})]},i))})]})}export{Ve as MyAccessPage};
|
|
2
|
+
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{C as n,J as r,K as i,S as a,V as o,Y as s,a as c,et as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Gi as f,Ir as p,Mn as m,Nr as h,Oi as g,Q as _,Qa as v,Sn as y,Wr as b,Xt as x,ct as S,dt as C,en as w,ka as T,lr as E,mi as D,qi as O,vt as k,zr as A}from"./player-overlays-ClFSGefV.js";import{vi as j,yi as M}from"./client-B0p6WiZb.js";import{l as ee,o as N}from"./terminal-DU-tvcEm.js";import{t as P}from"./monitor-smartphone-DPI9EQus.js";import{t as te}from"./unlink-D3-IGpS8.js";import{$f as F,$i as ne,Gf as I,Mi as L,Sr as re,cl as ie,ft as ae,ji as oe,kp as R,ol as se}from"./src-DwclSIv9.js";import{t as ce}from"./i18n-NPZM0HGc.js";import{t as z}from"./useTranslation-BJr-n0es.js";import"./mount-D943WJVm.js";import{c as le,i as ue,l as B,s as V}from"./sso-popup-Bxcrh_Ga.js";import{F as H,di as U,hi as de,i as W,li as G}from"./index-Bjvuymkk.js";import{t as fe}from"./AdminSectionedPage-dteNFZvo.js";import{t as pe}from"./AdminPage-DhtpNaF0.js";import{D as me,O as he,_ as ge,a as _e,h as ve,r as ye,t as be,w as xe}from"./SessionsList-ChVQOhw4.js";l();var Se=`${j}/connect`,K={public:0,mesh:1,lan:2,"lan-ipv6":3};function Ce(e){switch(e.kind){case`public`:return e.interfaceKind===`vpn`?`mesh`:`public`;case`lan-ipv4`:return`lan`;case`lan-ipv6`:return`lan-ipv6`;case`custom`:return`public`;case`loopback`:case`app-link`:return null}}function q(e){return M(e)}function we(e){return e.startsWith(`https://`)}function Te(e){let t=e.flatMap(e=>{let t=Ce(e),n=q(e.baseUrl);return t===null||n===null?[]:[{endpoint:e,tier:t,origin:n}]}).toSorted((e,t)=>K[e.tier]-K[t.tier]||Number(t.endpoint.plausible)-Number(e.endpoint.plausible)||e.endpoint.priority-t.endpoint.priority),n=new Set;return t.flatMap(({endpoint:e,tier:t,origin:r})=>n.has(r)?[]:(n.add(r),[{origin:r,label:e.label,tier:t,secure:we(r),plausible:e.plausible}]))}function Ee(e,t,n=null){for(let r of[t,n]){if(r===null)continue;let t=q(r),n=e.find(e=>e.origin===t);if(n!==void 0)return n}return e[0]??null}function De(e){let t=new URL(Se);return t.searchParams.set(`hub`,e),t.toString()}var Oe=176,J={scheme:`https`};function ke(){let{t:e}=z(),t=ie(J),r=se(J).data?.roles.publicEndpoint.resolved??null;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(y,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?n(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(p,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?n(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[a(x,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),n(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[a(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),a(I,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):a(Ae,{candidates:Te(t.data.endpoints),preferredOrigin:r})]})]})}function Ae({candidates:e,preferredOrigin:t}){let{t:r}=z(),[o,c]=s(null),l=Ee(e,o,t),u=i(()=>l?De(l.origin):null,[l]);if(l===null||u===null)return a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.empty`)});let d=e=>r(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${d(e.tier)} — ${e.origin}`}));return n(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[a(oe,{value:u,size:Oe,alt:r(`connectPhone.qrAlt`),className:`self-start`}),n(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[n(`label`,{className:`block space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.addressLabel`)}),a(C,{value:l.origin,options:f,onChange:e=>c(e.target.value)}),n(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[d(l.tier),` · `,l.label]})]}),!l.secure&&a(Y,{text:r(`connectPhone.insecure`)}),!l.plausible&&a(Y,{text:r(`connectPhone.implausible`)}),n(`div`,{className:`space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.linkLabel`)}),n(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[a(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:u}),a(re,{value:u,srLabel:r(`connectPhone.linkLabel`)})]})]}),a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.signInHint`)})]})]})}function Y({text:e}){return n(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[a(x,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),a(`span`,{children:e})]})}l();function je(e){return new Date(e).toLocaleDateString()}function Me(){let{t:e}=z(),t=S(),i=R.useUtils(),c=R.auth.listLinkableProviders.useQuery(),l=R.auth.listOwnExternalIdentities.useQuery(),[u,d]=s(null),[m,h]=s(()=>B(window.location.search)),g=r(null),v=W(`Linking a sign-in account`),y=r(null);o(()=>()=>y.current?.(),[]);let[b,x]=s(null);o(()=>{if(m===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[m]);let C=R.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=g.current;if(g.current=null,t===null||t.closed){window.location.assign(e);return}let n=e=>{x(null),h(B(`?${e}`)),i.auth.listOwnExternalIdentities.invalidate()};y.current?.(),y.current=V(t,{onReturn:e=>{e.target===`profile`&&n(e.query)},onDone:e=>{e.target===`profile`&&n(e.query)},onClosed:()=>{y.current?.(),y.current=null,i.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=_(le(e))},onError:e=>{g.current?.close(),g.current=null,x(null),d(e.message)}}),w=R.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void i.auth.listOwnExternalIdentities.invalidate(),onError:e=>d(e.message)}),T=c.data??[],E=l.data??[],D=b!==null&&E.some(e=>e.provider===b);if(o(()=>{!D||b===null||(x(null),h({kind:`linked`,provider:b}))},[D,b]),T.length===0&&E.length===0)return null;let k=new Set(E.map(e=>e.provider)),j=e=>T.find(t=>t.provider===e)?.label??e,M=async(n,r)=>{await t({title:e(`users.linkedSignInsSection.unlinkSignInAccount`,`Unlink sign-in account`),message:e(`users.linkedSignInsSection.stopSigningInWithThis`,`Stop signing in with this {{label}} account?`,{label:r}),confirmLabel:e(`users.linkedSignInsSection.unlink`,`Unlink`),variant:`danger`})&&(d(null),w.mutate({provider:n.provider,subject:n.subject}))};return n(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[v.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(A,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`users.linkedSignInsSection.signInWithAnExternal`,`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`)}),m?.kind===`linked`&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[a(f,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:j(m.provider)})]}),(m?.kind===`error`||u)&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[a(O,{className:`h-3.5 w-3.5 shrink-0`}),u??(m?.kind===`error`?m.message:``)]}),E.length>0&&a(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:E.map(t=>{let r=t.providerLabel??t.provider;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`font-medium text-foreground truncate`,children:[r,!t.available&&a(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:e(`users.linkedSignInsSection.providerUnavailable`,`provider unavailable`)})]}),a(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:je(t.linkedAt)})})]}),n(I,{variant:`unstyled`,onClick:()=>void M(t,r),disabled:w.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[a(te,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),a(`div`,{className:`flex flex-wrap gap-2`,children:T.filter(e=>!k.has(e.provider)).map(t=>n(I,{variant:`unstyled`,onClick:()=>{d(null),h(null),v.requestProof().then(e=>{e!==null&&(g.current=ue(null),x(g.current===null?null:t.provider),C.mutate({provider:t.provider,reauthToken:e}))})},disabled:C.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[C.isPending&&C.variables?.provider===t.provider?a(p,{className:`h-3 w-3 animate-spin`}):a(A,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}l();function Ne({value:r,size:i=192}){let{t:c}=z(),[l,u]=s(null),[d,f]=s(null);if(o(()=>{let n=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(n)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(r,{errorCorrectionLevel:`M`});n||u(e)}catch(e){n||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{n||f(`qrcode library not installed`)}),()=>{n=!0}},[r]),d)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:c(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!l)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:c(`users.totpQrCode.generating`,`Generating…`)});let p=l.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)l.modules.data[e*p+t]&&h.push(a(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return n(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[a(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}l();function Pe(){let{t:e}=z(),t=k(),[r,i]=s(``),[o,c]=s(``),[l,d]=s(``),[m,g]=s(null),_=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{g({kind:`success`,msg:`Password updated.`}),i(``),c(``),d(``)},onError:e=>{g({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),v=o.length>0&&l.length>0&&o!==l,y=o.length>0&&o.length<8,b=r.length>=1&&o.length>=8&&o===l;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(X,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:r,onChange:i,autoComplete:`current-password`}),a(X,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:o,onChange:c,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),a(X,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:l,onChange:d,autoComplete:`new-password`}),(v||y)&&a(`div`,{className:`text-[11px] text-danger`,children:v?e(`systemPage.myAccess.passwordsDoNotMatch`,`Passwords do not match.`):e(`systemPage.myAccess.newPasswordMustBeAt`,`New password must be at least 8 characters.`)}),m&&n(`div`,{className:`text-[11px] flex items-center gap-1 ${m.kind===`success`?`text-success`:`text-danger`}`,children:[m.kind===`success`?a(f,{className:`h-3 w-3`}):a(O,{className:`h-3 w-3`}),m.msg]}),a(`div`,{className:`flex justify-end`,children:n(I,{onClick:()=>{g(null),_.mutate({currentPassword:r,newPassword:o})},disabled:!b||_.isPending,children:[_.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(h,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function X({label:e,value:t,onChange:r,autoComplete:i,hint:o}){return n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),a(F,{type:`password`,value:t,onChange:e=>r(e.target.value),autoComplete:i,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),o&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:o})]})}function Fe({username:e}){let{t}=z(),r=k(),l=c({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>r.getOwnTotpStatus()}),m=l.data,[h,_]=s(null),[v,b]=s(``),[x,S]=s(null),[C,w]=s(!1),T=u({mutationFn:()=>r.setupOwnTotp(),onSuccess:e=>{_({secret:e.secret,otpauthUrl:e.otpauthUrl}),b(``),S(null)},onError:e=>S(e instanceof Error?e.message:`Setup failed`)}),E=u({mutationFn:e=>r.confirmOwnTotp(e),onSuccess:()=>{_(null),b(``),S(null),l.refetch()},onError:e=>S(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),D=W(`Turning off two-factor authentication`),A=u({mutationFn:async()=>{let e=await D.requestProof();return e===null?null:r.disableOwnTotp({reauthToken:e})},onSuccess:()=>{S(null),l.refetch()},onError:e=>S(e instanceof Error?e.message:`Disable failed`)});o(()=>{if(!C)return;let e=setTimeout(()=>w(!1),1500);return()=>clearTimeout(e)},[C]);let j=i(()=>l.isLoading?`loading`:h?`setup_in_progress`:m?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,m?.enabled,h]);return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[D.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(y,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&n(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(p,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&n(d,{children:[a(`div`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.2faIsnTActiveOn`,`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`)}),a(`div`,{className:`flex justify-end`,children:n(I,{onClick:()=>{S(null),T.mutate()},disabled:T.isPending,children:[T.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(y,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&h&&n(d,{children:[a(`div`,{className:`text-[11px] text-foreground-subtle`,children:a(G,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:a(`span`,{className:`font-mono`})}})}),n(`div`,{className:`flex flex-col items-center gap-3`,children:[a(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:a(Ne,{value:h.otpauthUrl,size:180})}),n(`div`,{className:`w-full`,children:[a(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),n(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[a(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:h.secret}),n(I,{variant:`ghost`,onClick:()=>{h&&navigator.clipboard.writeText(h.secret).then(()=>w(!0))},children:[C?a(f,{className:`h-3 w-3 text-success`}):a(g,{className:`h-3 w-3`}),C?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),a(F,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:v,onChange:e=>b(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),x&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(O,{className:`h-3 w-3`}),x]}),n(`div`,{className:`flex justify-end gap-2`,children:[a(I,{variant:`outline`,onClick:()=>{_(null),S(null),b(``)},children:t(`common.cancel`,`Cancel`)}),n(I,{onClick:()=>{S(null),E.mutate({code:v})},disabled:E.isPending||v.length!==6,children:[E.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(f,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&m&&n(d,{children:[n(`div`,{className:`rounded-md border border-success/30 bg-success/5 px-3 py-2.5 flex items-start gap-2.5`,children:[a(f,{className:`h-4 w-4 mt-0.5 text-success shrink-0`}),n(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[a(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),a(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:m.confirmedAt?new Date(m.confirmedAt).toLocaleString():`—`})})]})]}),x&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(O,{className:`h-3 w-3`}),x]}),a(`div`,{className:`flex justify-end`,children:n(I,{variant:`danger`,onClick:()=>{S(null),A.mutate()},disabled:A.isPending,children:[A.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(y,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Ie(){return ne(`auth-webauthn/passkey-enrollment`)?a(L,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}l();function Z(e){return e.message.length>0?e.message:ce.t(`auth.authAuditSection.requestFailed`)}function Le(){let{t:e}=z(),{logout:t}=H(),r=S(),i=R.useUtils(),o=R.auth.listOwnSessions.useQuery(),[c,l]=s(null),u=R.auth.revokeOwnSession.useMutation({onSuccess:()=>void i.auth.listOwnSessions.invalidate(),onError:e=>l(`Sign out failed: ${Z(e)}`)}),d=R.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>l(`Sign out failed: ${Z(e)}`)}),f=async t=>{await r({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:ge(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(l(null),u.mutate({id:t.id}))},m=async()=>{await r({title:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),message:e(`auth.mySessionsSection.everySessionOfYourAccount`,`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`),confirmLabel:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(l(null),d.mutate({everywhere:!0}))};return n(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(P,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`auth.mySessionsSection.theBrowsersAndAppsSigned`,`The browsers and apps signed in to your account. Signing one out ends it at once.`)}),c!==null&&a(`div`,{className:`text-[11px] text-danger`,children:c}),a(be,{sessions:o.data??[],isLoading:o.isLoading,loadError:o.isError?o.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:u.isPending?u.variables?.id??null:null}),a(`div`,{className:`flex justify-end`,children:n(I,{variant:`unstyled`,onClick:()=>void m(),disabled:d.isPending,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[d.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(N,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}l();var Re=`You`;function Q(){let{t:e}=z(),t=S(),n=R.useUtils(),r=R.auth.listOwnDeviceCredentials.useQuery(),[o,c]=s(null),l=R.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||c(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>c(`Revoke failed: ${e.message}`)}),u=i(()=>(r.data??[]).map(e=>ye(e,Re)),[r.data]),d=async n=>{await t({title:e(`certificates.myDevicesSection.revoke`,`Revoke "{{name}}"?`,{name:n.name}),message:e(`certificates.myDevicesSection.theDeviceStopsSigningIn`,`The device stops signing in at once and its open sessions end. To use it again you have to pair it anew. This cannot be undone.`),confirmLabel:e(`certificates.myDevicesSection.revoke2`,`Revoke`),variant:`danger`})&&(c(null),l.mutate({id:n.id}))},f={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:T,isAvailable:_e,onRun:e=>void d(e),busyId:l.isPending?l.variables?.id??null:null,disabled:l.isPending};return a(me,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:y,description:e(`certificates.myDevicesSection.phonesThatStaySignedIn`,`Phones that stay signed in to your account with a certificate. If one is lost, revoke it here and it is signed out at once.`),notice:he(o),onDismissNotice:()=>c(null),children:a(xe,{rows:u,label:e(`certificates.devicesCard.label`),isLoading:r.isPending,loadError:r.error===null?null:r.error.message||`Request failed`,emptyText:`No devices are signed in with a certificate.`,hideOwner:!0,expiresNone:`—`,action:f})})}var $={profile:`profile`,signIn:`sign-in`,sessions:`sessions`,tokens:`tokens`},ze=[`linked`,`linkError`],Be={view:{icon:D,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:E,cls:`bg-primary/15 text-primary`},delete:{icon:w,cls:`bg-danger/15 text-danger`}};function Ve(){let{t:e}=z(),{user:t,logout:r}=H(),[i]=de(),o=e(`system.myAccess`,`My access`);if(!t)return a(pe,{icon:m,title:o,children:a(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});if(i.get(`tab`)===`preferences`)return a(U,{to:`/system/settings`,replace:!0});if(ze.some(e=>i.has(e))&&!i.has(`tab`)){let e=new URLSearchParams(i);return e.set(`tab`,$.signIn),a(U,{to:`?${e.toString()}`,replace:!0})}return a(fe,{icon:m,title:o,subtitle:e(`systemPage.myAccess.subtitle`,`Your account, how you sign in, where you are signed in, and your tokens.`),sectionsLabel:e(`systemPage.myAccess.sectionsLabel`,`My access sections`),defaultSection:$.profile,actions:n(I,{variant:`outline`,onClick:r,children:[a(N,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]}),sections:[{id:$.profile,label:e(`systemPage.myAccess.sections.profile`,`Profile`),content:a(He,{user:t})},{id:$.signIn,label:e(`systemPage.myAccess.sections.signIn`,`Sign-in & security`),content:n(`div`,{className:`space-y-4`,children:[a(Pe,{}),a(Fe,{username:t.username}),a(Ie,{}),a(Me,{})]})},{id:$.sessions,label:e(`systemPage.myAccess.sections.sessions`,`Sessions & devices`),content:n(`div`,{className:`space-y-4`,children:[a(Le,{}),a(Q,{}),a(ke,{})]})},{id:$.tokens,label:e(`systemPage.myAccess.sections.tokens`,`Tokens`),content:a(ve,{ownOnly:!0})}]})}function He({user:e}){let{t}=z(),r=e.isAdmin,i=e.scopes??[];return n(`div`,{className:`space-y-4`,children:[n(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[a(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),n(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),n(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r?t(`systemPage.myAccess.administrator`,`Administrator`):t(`systemPage.myAccess.user`,`User`),` `,a(G,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:e.id.slice(0,8)},components:{mono:a(`span`,{className:`font-mono`})}})]})]})]}),r&&n(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[a(b,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),n(`div`,{children:[a(`div`,{className:`font-semibold text-foreground`,children:t(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),a(`p`,{className:`text-foreground-subtle mt-0.5`,children:t(`systemPage.myAccess.adminSessionsBypassThePer`,`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`)})]})]}),i.length>0&&a(Ue,{scopes:i})]})}function Ue({scopes:e}){let{t}=z(),r=v();return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2 border-b border-border`,children:[a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`systemPage.myAccess.bakedIntoYourSessionToken`,`Baked into your session token at login; sign out + back in to refresh after changes.`)})]}),n(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[a(`div`,{children:t(`systemPage.myAccess.type`,`Type`)}),a(`div`,{children:t(`systemPage.myAccess.target`,`Target`)}),a(`div`,{children:t(`systemPage.myAccess.access`,`Access`)})]}),a(`ul`,{className:`divide-y divide-border`,children:e.map((e,i)=>n(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[a(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),a(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?ae(e.selector,r):e.target}),a(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(r=>{let i=e.access.includes(r),{icon:o,cls:s}=Be[r];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${i?s:`bg-transparent text-foreground-subtle/40 line-through`}`,title:i?t(`systemPage.myAccess.can`,`Can {{a}}`,{a:r}):t(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:r}),children:[a(o,{className:`h-3 w-3`}),r]},r)})})]},i))})]})}export{Ve as MyAccessPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as l,Di as u,Fr as d,Hn as f,Jn as p,L as m,Ln as h,Mr as g,Ot as _,Ua as v,Xt as y,Z as b,dt as x,ea as S,en as C,fa as w,hi as T,ir as E,jn as D,mr as O,pn as ee,qn as te,rr as ne,vn as re,vt as k,wt as ie}from"./player-overlays-8aC2r-sd.js";import{_i as ae,gi as oe,hi as A,ii as se}from"./client-LrzN1ATZ.js";import{o as ce,s as le,u as j}from"./terminal-DU-tvcEm.js";import{$f as M,Al as ue,Ar as N,Cl as de,Dl as fe,Dr as pe,El as me,Gf as P,Ml as he,Ns as ge,Or as _e,Si as ve,Tl as ye,Tr as be,Wi as xe,_l as Se,al as Ce,dl as we,ep as F,fa as Te,gl as Ee,jl as De,ma as I,ml as Oe,ol as ke,pl as Ae,sl as je,wl as Me}from"./src-D5UhvHcp.js";import{t as L}from"./i18n-DWjQ9UFE.js";import{t as R}from"./useTranslation-BJr-n0es.js";import"./mount-BaM_HHUO.js";import{b as Ne,di as Pe,hi as Fe,o as z,s as B,ui as Ie}from"./index-BsPM4J54.js";import{t as Le}from"./AdminSectionedPage-C7Nx9jJl.js";import{t as V}from"./AdminPage-BEQJlUNo.js";import{r as H,t as U}from"./InstancesTable-CriEfrMJ.js";import{t as Re}from"./useInvalidateAddonSettings-CyofQfBo.js";o();var ze=5e3,Be=`network-access`,Ve={connected:!1,endpoint:null};function He(){let{t:e}=R(),t=s(),[n,i]=a(null),[o,c]=a({}),l=(e,n)=>{let r=n?.addonId;t.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),i(null),c(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},u=(e,t)=>{i(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);c(e=>({...e,[n]:r}))},d=De({onSuccess:l,onError:u}),f=he({onSuccess:l,onError:u}),p={key:`tunnel`,header:e(`system.remoteAccess.colTunnel`,`Tunnel`),notSortableReason:e(`system.remoteAccess.tunnelNotSortable`,`A live connection state is not a value to order by.`),render:e=>r(Ue,{addonId:e.addonId,error:o[e.addonId]})},m=e=>r(We,{addonId:e,busyId:n,onStart:e=>{i(e),d.mutate({addonId:e})},onStop:e=>{i(e),f.mutate({addonId:e})}});return r(U,{functionCap:Be,icon:j,title:e(`system.remoteAccess.remoteAccess2`,`Remote Access`),subtitle:e(`system.remoteAccess.publicFacingTunnelsThatExpose`,`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …).`),emptyTitle:e(`system.remoteAccess.noRemoteAccessProvidersInstalled`,`No remote-access providers installed`),emptyDescription:e(`system.remoteAccess.installATunnelAddonE`,`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`),addLabel:e(`system.remoteAccess.addTunnel`,`Add tunnel`),extraColumns:[p],rowActions:e=>m(e.addonId),fixedRowActions:e=>m(e.addonId)})}function W(e){let{data:t}=ue({addonId:e},{refetchInterval:ze,retry:!1}),n=t?se.safeParse(t):null;return n?.success?n.data:Ve}function Ue({addonId:t,error:n}){let{t:i}=R(),a=W(t);return e(`span`,{className:`flex flex-col items-start gap-1`,children:[r(I,{variant:a.connected?`success`:`default`,className:H,children:a.connected?i(`system.remoteAccess.connected`,`Connected`):i(`system.remoteAccess.disconnected`,`Disconnected`)}),a.endpoint&&e(`a`,{href:a.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1 break-all text-[11px] text-success hover:underline`,children:[r(T,{className:`h-3 w-3`}),a.endpoint.url]}),n!==void 0&&r(`span`,{role:`alert`,className:`text-xs text-danger`,children:n})]})}function We({addonId:e,busyId:t,onStart:n,onStop:i}){let{t:a}=R(),o=W(e),s=t===e;return o.connected?r(F,{icon:s?d:ee,variant:`ghost`,size:`sm`,"aria-label":a(`system.remoteAccess.stop`,`Stop`),disabled:s,onClick:()=>i(e)}):r(F,{icon:s?d:E,variant:`ghost`,size:`sm`,"aria-label":a(`system.remoteAccess.start`,`Start`),disabled:s,onClick:()=>n(e)})}function Ge(){let{t:e}=R();return r(U,{functionCap:`turn-provider`,icon:O,title:e(`system.turnServers.turnServers`,`TURN Servers`),subtitle:e(`system.turnServers.iceServersUsedForWebrtc`,`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`),emptyTitle:e(`system.turnServers.noTurnProvidersInstalled`,`No TURN providers installed`),emptyDescription:e(`system.turnServers.installATurnAddonE`,`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`),addLabel:e(`system.turnServers.addProvider`,`Add provider`)})}o();var Ke={lan:O,wifi:_,docker:w,vpn:g,loopback:h,other:h},qe={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},Je=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function Ye(n){let{t:i}=R(),{interfaces:a,disabled:o,hideLoopback:s,ipv4Only:c,emptyMessage:l}=n,u=t(()=>a.filter(e=>!(s&&e.kind===`loopback`||c&&e.family!==`IPv4`)),[a,s,c]),d=t(()=>{let e=new Map;for(let t of u){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return Je.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[u]),f=e=>n.mode===`single`?n.value===e:n.value.includes(e),p=e=>{if(o||e.kind===`loopback`)return;if(n.mode===`single`){n.onChange(n.value===e.address?null:e.address);return}let t=new Set(n.value);t.has(e.address)?t.delete(e.address):t.add(e.address),n.onChange([...t])};return u.length===0?r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l??i(`shared.addressSelector.noAddressesAvailable`,`No addresses available.`)}):r(`div`,{className:`flex flex-col gap-3`,children:d.map(({kind:t,items:a})=>e(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[r(Ke[t]??h,{className:`h-3.5 w-3.5 text-foreground-subtle`}),r(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:qe[t]??t}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,a.length]})]}),r(`ul`,{className:`divide-y divide-border`,children:a.map(t=>{let a=f(t.address),s=t.kind===`loopback`,c=!t.plausible&&!s;return e(`li`,{className:`flex items-center gap-3 px-3 py-2 ${s?`opacity-60 cursor-not-allowed`:o?`opacity-60`:c?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>p(t),children:[r(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${n.mode===`single`?`rounded-full`:`rounded`} border ${a?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:a&&r(S,{className:`h-3 w-3`})}),e(`div`,{className:`flex-1 min-w-0 ${c?`text-foreground-subtle`:``}`,children:[e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[r(`span`,{className:`font-mono text-xs font-semibold ${c?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),r(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono`,children:t.family}),t.preferred&&r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:i(`shared.addressSelector.autoPreferred`,`Auto-preferred`)}),s&&r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:i(`shared.addressSelector.alwaysIncluded`,`Always included`)}),c&&e(`span`,{className:`inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:t.plausibleReason||void 0,children:[r(y,{className:`h-2.5 w-2.5`}),i(`shared.addressSelector.unlikelyUsable`,`Unlikely usable`)]})]}),e(`div`,{className:`text-xs text-foreground-subtle mt-0.5 font-mono break-all`,children:[t.address,t.cidr&&t.cidr!==t.address?` (${t.cidr})`:``]})]})]},`${t.name}-${t.family}-${t.address}`)})})]},t))})}var G=[{role:`appConnections`,get title(){return L.t(`helpers.addressTableModel.appConnectionsTitle`)},single:!1,get help(){return L.t(`helpers.addressTableModel.appConnectionsHelp`)}},{role:`notificationTaps`,get title(){return L.t(`helpers.addressTableModel.notificationTapsTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.notificationTapsHelp`)}},{role:`publicEndpoint`,get title(){return L.t(`helpers.addressTableModel.publicEndpointTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.publicEndpointHelp`)}},{role:`internal`,get title(){return L.t(`helpers.addressTableModel.internalTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.internalHelp`)}}],Xe=`A role with nothing ticked is automatic. Add a custom address when the hub is reached at an address it cannot see itself (NAT, reverse proxy, VPN, Docker bridge).`;function K(e,t){return e.inUse.includes(t)}function Ze(e,t){if(!e.eligible.includes(t))return{kind:`none`};if(e.kind===`app-link`)return K(e,t)?{kind:`none`}:{kind:`set`,input:{role:t,baseUrl:null,enabled:!0}};if(e.flags.includes(t)||t===`appConnections`&&K(e,t))return{kind:`set`,input:{role:t,baseUrl:e.baseUrl,enabled:!1}};let n={role:t,baseUrl:e.baseUrl,enabled:!0};return t===`publicEndpoint`&&e.baseUrl.startsWith(`http:`)?{kind:`confirm-http`,input:n,reason:oe}:{kind:`set`,input:n}}function Qe(e){return G.map(({role:t,title:n})=>{if(t===`appConnections`){let r=e.roles.appConnections;return{role:t,title:n,inUse:r.resolved.length===0?`nothing reachable`:r.resolved.join(`, `),automatic:r.source!==`flagged`}}let r=e.roles[t];return{role:t,title:n,inUse:r.resolved===null?`nothing reachable`:t===`notificationTaps`&&r.source===`auto`?`CamStack app link`:r.resolved,automatic:r.source!==`flagged`}})}o();var q={"lan-ipv4":{labelKey:`system.addressesCard.kindIpv4`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`},"lan-ipv6":{labelKey:`system.addressesCard.kindIpv6`,className:`bg-violet-500/15 text-violet-700 dark:text-violet-300`},public:{labelKey:`system.addressesCard.kindPublic`,className:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},"app-link":{labelKey:`system.addressesCard.kindAppLink`,className:`bg-amber-500/15 text-amber-700 dark:text-amber-300`},custom:{labelKey:`system.addressesCard.kindCustom`,className:`bg-sky-500/15 text-sky-700 dark:text-sky-300`},loopback:{labelKey:`system.addressesCard.kindLoopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function $e({book:t,loading:n,saving:i,error:o,onSetRole:s,onAdd:c,onRemove:l}){let{t:u}=R(),[d,f]=a(``),[p,m]=a(``),[h,g]=a(null),[_,b]=a(null),x=()=>{let e=ae(d);if(!e.ok){g(e.reason);return}g(null),f(``),m(``),c(e.baseUrl,p.trim())},S=(e,t)=>{let n=Ze(e,t.role);if(n.kind!==`none`){if(n.kind===`confirm-http`){b({input:n.input,reason:n.reason});return}b(null),s(n.input)}},w=[{key:`url`,header:u(`system.addressesCard.address`,`Address`),render:n=>e(`div`,{className:`min-w-0 py-0.5`,children:[r(`div`,{className:`font-mono text-[12px] break-all ${n.plausible?`text-foreground`:`text-foreground-subtle`}`,children:n.baseUrl}),e(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:n.label}),n.kind===`app-link`&&e(`span`,{className:`font-mono`,children:[`hub=`,` `,t?.appLinkHub??u(`system.addressesCard.noneNoTunnelOrTailscale`,`none (no tunnel or Tailscale)`)]}),n.custom&&n.detected&&r(`span`,{children:u(`system.addressesCard.alsoAddedAsACustom`,`also added as a custom address`)}),n.kind!==`custom`&&n.interfaceKind!==`lan`&&n.interfaceKind!==`public`&&n.interfaceKind!==`other`&&r(`span`,{className:`uppercase tracking-wide`,children:n.interfaceKind}),!n.plausible&&n.interfaceKind!==`loopback`&&e(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:n.plausibleReason||void 0,children:[r(y,{className:`h-2.5 w-2.5`}),u(`system.addressesCard.unlikelyUsable`,`Unlikely usable`)]})]})]})},{key:`kind`,header:u(`system.addressesCard.kind`,`Kind`),nowrap:!0,render:e=>{let t=q[e.kind]??q.loopback;return r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:u(t.labelKey)})}},...G.map(t=>({key:t.role,headerRender:()=>r(`span`,{title:t.help,children:t.title}),align:`center`,nowrap:!0,width:`w-24`,render:n=>{let a=n.eligible.includes(t.role),o=n.flags.includes(t.role),s=K(n,t.role);return e(`label`,{className:`inline-flex items-center justify-center gap-1 ${a?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:a?s&&!o?u(`system.addressesCard.inUseAutomatically`,`{{title}}: in use automatically. {{help}}`,{title:t.title,help:t.help}):t.help:u(`system.addressesCard.thisAddressCannotBeUsed`,`This address cannot be used for this.`),children:[r(v,{checked:a&&s,disabled:!a||i,onChange:()=>S(n,t),"aria-label":`${t.title}: ${n.baseUrl}`}),s&&!o&&a&&r(`span`,{className:`text-[9px] text-foreground-subtle`,children:u(`common.auto`)})]})}})),{key:`actions`,header:``,align:`right`,nowrap:!0,render:e=>e.custom?r(P,{size:`sm`,variant:`ghost`,disabled:i,onClick:()=>l(e.baseUrl),"aria-label":u(`system.addressesCard.remove`,`Remove {{baseUrl}}`,{baseUrl:e.baseUrl}),title:u(`system.addressesCard.removeThisCustomAddressIts`,`Remove this custom address (its roles turn automatic)`),children:r(C,{className:`h-3 w-3`})}):null}],T=t===void 0?[]:Qe(t);return e(xe,{children:[e(`div`,{className:`px-4 py-3 border-b border-border flex flex-col gap-2`,children:[e(`div`,{children:[r(`div`,{className:`text-sm font-semibold`,children:u(`system.addressesCard.addresses`,`Addresses`)}),r(`div`,{className:`text-xs text-foreground-subtle max-w-3xl`,children:u(`system.addressesCard.everyAddressThisHubIs`,`Every address this hub is reached at, detected or added by you. Tick what each one is used for.`)}),e(`details`,{className:`mt-1.5 text-xs max-w-3xl`,"data-testid":`address-roles-help`,children:[r(`summary`,{className:`cursor-pointer select-none text-foreground-subtle hover:text-foreground`,children:u(`system.addressesCard.whatAreRoles`,`What are roles?`)}),r(`dl`,{className:`mt-1.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:G.map(t=>e(`div`,{className:`contents`,children:[r(`dt`,{className:`font-medium`,children:t.title}),r(`dd`,{className:`text-foreground-subtle`,children:t.help})]},t.role))}),r(`p`,{className:`mt-1.5 text-foreground-subtle`,children:Xe})]})]}),T.length>0&&r(`div`,{className:`grid grid-cols-[auto_1fr_auto] gap-x-3 gap-y-1 items-baseline text-xs`,"data-testid":`address-roles-summary`,children:T.map(t=>e(`div`,{className:`contents`,children:[r(`span`,{className:`text-foreground-subtle`,children:t.title}),e(`span`,{className:`font-mono break-all`,"data-testid":`address-role-${t.role}`,children:[t.inUse,r(`span`,{className:`ml-1.5 font-sans text-foreground-subtle`,children:t.automatic?u(`system.addressesCard.automatic`,`(automatic)`):u(`system.addressesCard.setByYou`,`(set by you)`)})]}),t.automatic?r(`span`,{}):r(P,{size:`sm`,variant:`secondary`,disabled:i,onClick:()=>s({role:t.role,baseUrl:null,enabled:!1}),children:u(`system.addressesCard.useAutomatic`,`Use automatic`)})]},t.role))}),_!==null&&e(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs flex flex-wrap items-center gap-2`,children:[r(y,{className:`h-3.5 w-3.5 text-amber-600`}),r(`span`,{className:`flex-1 min-w-[220px]`,children:_.reason}),r(P,{size:`sm`,variant:`secondary`,onClick:()=>{s({..._.input,acceptInsecureHttp:!0}),b(null)},children:u(`system.addressesCard.useHttpAnyway`,`Use http anyway`)}),r(P,{size:`sm`,variant:`ghost`,onClick:()=>b(null),children:u(`common.cancel`,`Cancel`)})]}),o!==null&&r(`div`,{className:`text-[11px] text-red-600 dark:text-red-400`,role:`alert`,children:o})]}),r(N,{columns:w,rows:t?.rows??[],rowKey:e=>`${e.kind}-${e.baseUrl}`,minWidthPx:760,bordered:!1,emptyMessage:n?u(`common.loading`,`Loading…`):u(`system.addressesCard.noAddressesAvailable`,`No addresses available.`),rowClassName:e=>e.plausible?void 0:`opacity-80`}),e(`div`,{className:`px-4 py-3 border-t border-border flex flex-wrap items-start gap-2`,children:[e(`div`,{className:`flex-1 min-w-[220px]`,children:[r(M,{value:d,onChange:e=>{f(e.target.value),g(null)},placeholder:`https://cams.example.com or https://192.0.2.20:4443`,"aria-label":u(`system.addressesCard.customAddress`,`Custom address`),disabled:i}),h!==null&&r(`div`,{className:`mt-1 text-[11px] text-red-600 dark:text-red-400`,children:h})]}),r(`div`,{className:`w-48`,children:r(M,{value:p,onChange:e=>m(e.target.value),placeholder:u(`system.addressesCard.labelOptional`,`Label (optional)`),"aria-label":u(`system.addressesCard.customAddressLabel`,`Custom address label`),maxLength:80,disabled:i})}),e(P,{size:`sm`,variant:`secondary`,disabled:i||d.trim()===``,onClick:x,children:[r(ne,{className:`h-3 w-3`}),u(`system.addressesCard.addCustomAddress`,`Add custom address`)]})]})]})}o();function et(){let{t:n}=R(),o=s(),c=()=>{o.invalidateQueries({queryKey:[[`localNetwork`]]})},u=we(void 0,{refetchInterval:3e4}),d=je(void 0),m=Se({onSuccess:c}),h=Oe({onSuccess:e=>{w(e.addresses),c()}}),g=t(()=>u.data?.interfaces??[],[u.data]),_=ke({scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),v=Ee({onSuccess:c}),y=Ce({onSuccess:c}),b=Ae({onSuccess:c}),x=v.error?.message??y.error?.message??b.error?.message??null,S=v.isPending||y.isPending||b.isPending,[C,w]=a([]),[T,E]=a(!1);i(()=>{!T&&d.data&&(w(d.data.addresses),E(!0))},[d.data,T]);let D=d.data?.addresses??[],O=t(()=>{if(C.length!==D.length)return!0;let e=[...C].toSorted(),t=[...D].toSorted();return e.some((e,n)=>e!==t[n])},[C,D]);return e(V,{embedded:!0,children:[e(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[r(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:n(`system.networkAddresses.pinWhichHostInterfacesExist`,`Pin which host interfaces exist, then tick what each address is used for. Add a custom address when this hub is reached at one it cannot detect.`)}),r(`div`,{className:`flex items-center gap-2 shrink-0`,children:e(P,{size:`sm`,variant:`secondary`,onClick:()=>{u.refetch(),d.refetch(),_.refetch()},disabled:u.isLoading,children:[r(p,{className:`h-3 w-3 ${u.isLoading?`animate-spin`:``}`}),n(`common.refresh`,`Refresh`)]})})]}),r(_e,{headingId:`network-allowed-addresses`,title:n(`system.networkAddresses.allowedAddresses`,`Allowed addresses`),actions:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[e(P,{size:`sm`,variant:`secondary`,onClick:()=>h.mutate(void 0),disabled:h.isPending||m.isPending,title:n(`system.networkAddresses.reRunTheAutoDetection`,`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`),children:[r(re,{className:`h-3 w-3`}),h.isPending?n(`system.networkAddresses.detecting`,`Detecting…`):n(`system.networkAddresses.bestMatch`,`Best match`)]}),e(P,{size:`sm`,variant:`secondary`,onClick:()=>{w([])},disabled:C.length===0||m.isPending,children:[r(te,{className:`h-3 w-3`}),n(`system.networkAddresses.clear`,`Clear`)]}),O&&r(P,{size:`sm`,variant:`secondary`,onClick:()=>{w(D)},disabled:m.isPending,children:n(`system.networkAddresses.discard`,`Discard`)}),e(P,{size:`sm`,variant:`primary`,onClick:()=>{m.mutate({addresses:[...C]})},disabled:!O||m.isPending,children:[r(f,{className:`h-3 w-3`}),m.isPending?n(`system.networkAddresses.saving`,`Saving…`):n(`common.save`,`Save`)]})]}),children:e(`div`,{className:l,children:[r(`p`,{className:`mb-3 text-xs text-foreground-subtle`,children:C.length===0?n(`system.networkAddresses.autoEveryNonLoopbackNon`,`Auto — every non-loopback / non-link-local interface participates.`):n(`system.networkAddresses.pinned`,`{{value1}} pinned`,{value1:String(C.length)})}),r(Ye,{mode:`multiple`,interfaces:g,value:C,onChange:w,disabled:m.isPending,emptyMessage:u.isLoading?n(`system.networkAddresses.loadingInterfaces`,`Loading interfaces…`):n(`system.networkAddresses.noInterfacesDetected`,`No interfaces detected.`)})]})}),r($e,{book:_.data,loading:_.isLoading,saving:S,error:x,onSetRole:e=>v.mutate({...e}),onAdd:(e,t)=>y.mutate({baseUrl:e,label:t}),onRemove:e=>b.mutate({baseUrl:e})})]})}var tt=5e3,nt={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function J(e){let{data:t,isLoading:n}=de({addonId:e},{refetchInterval:tt,retry:!1}),r=t?A.safeParse(t):null;return{status:r?.success?r.data:nt,isLoading:n}}function Y({addonId:t}){let{t:n}=R(),{status:i}=J(t);return e(`span`,{className:`flex flex-wrap items-center gap-1`,children:[r(I,{variant:i.joined?`success`:`default`,className:H,children:i.joined?n(`system.meshNetworks.joined`,`Joined`):n(`system.meshNetworks.notJoined`,`Not joined`)}),i.joined&&r(I,{className:`text-[10px]`,children:n(`common.peers`,{count:i.peerCount})}),i.error!==void 0&&r(I,{variant:`danger`,className:`text-[10px]`,title:i.error,children:n(`system.meshNetworks.error`,`Error`)})]})}o();function rt({addonId:t}){return e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(Y,{addonId:t}),r(it,{addonId:t})]})}function it({addonId:t}){let{t:i}=R(),o=s(),[l,u]=a(!1),[f,p]=a(null),m=k(),{status:h}=J(t),g=n(()=>{o.invalidateQueries({queryKey:[[`meshNetwork`]]})},[o]),_=fe(),v=Me({onSuccess:g}),y=me({onSuccess:g}),b=n(async()=>{u(!0);let e={cancelled:!1};p(e);try{let n=await _.mutateAsync({addonId:t});if(e.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!e.cancelled&&(await at(2e3),!e.cancelled);){let e=await m.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?A.safeParse(e):null;if(n?.success&&n.data.joined){g();break}if(Date.now()-r>6e5)break}}finally{u(!1),p(null)}},[t,g,_,m]),x=n(()=>{f&&(f.cancelled=!0),u(!1),p(null)},[f]);return r(c,{children:h.joined?e(c,{children:[e(P,{size:`sm`,variant:`secondary`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?r(d,{className:`h-3 w-3 animate-spin`}):r(ce,{className:`h-3 w-3`}),i(`system.meshNetworks.disconnect`,`Disconnect`)]}),e(P,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?r(d,{className:`h-3 w-3 animate-spin`}):r(D,{className:`h-3 w-3`}),i(`system.meshNetworks.logOut`,`Log out`)]})]}):l?e(P,{size:`sm`,variant:`ghost`,onClick:x,children:[r(ie,{className:`h-3 w-3 mr-1`}),` `,i(`common.cancel`)]}):e(c,{children:[e(P,{size:`sm`,variant:`primary`,onClick:()=>void b(),children:[r(le,{className:`h-3 w-3`}),i(`system.meshNetworks.connect`,`Connect`)]}),e(P,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?r(d,{className:`h-3 w-3 animate-spin`}):r(D,{className:`h-3 w-3`}),i(`system.meshNetworks.logOut`,`Log out`)]})]})})}function at(e){return new Promise(t=>setTimeout(t,e))}o();var ot={mesh:`bg-info/15 text-info`,public:`bg-primary/15 text-primary`},st=3e4;function ct({addonId:t}){let{t:n}=R(),{status:i}=J(t),a=ye({addonId:t},{refetchInterval:st,retry:!1});return e(`div`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`space-y-4 p-2 sm:p-4`,children:[i.error&&r(Te,{message:i.error}),r(lt,{status:i}),i.endpoints.length>0&&e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:n(`system.meshNetworks.endpoints`,`Endpoints`)}),i.endpoints.map(t=>e(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[e(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${ot[t.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[t.scope===`public`?r(j,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,t.label]}),e(`a`,{href:t.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-success hover:underline break-all flex items-center gap-1`,children:[r(T,{className:`h-3 w-3 shrink-0`}),t.url]})]},t.id))]})]}),r(`div`,{className:`border-t border-border`,children:r(dt,{peers:a.data?.peers??[],loading:a.isLoading})})]})}function lt({status:t}){let{t:n}=R();return r(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:n(`system.meshNetworks.tenant`,`Tenant`),value:t.tenantName||`—`},{label:n(`system.meshNetworks.user`,`User`),value:t.userLogin??`—`},{label:n(`system.meshNetworks.controlPlane`,`Control plane`),value:t.controlPlaneUrl||`—`},{label:n(`system.meshNetworks.meshIp`,`Mesh IP`),value:t.meshIp||`—`,mono:!0},{label:n(`system.meshNetworks.magicdns`,`MagicDNS`),value:t.magicDnsHostname||`—`,mono:!0},{label:n(`system.meshNetworks.dnsSuffix`,`DNS suffix`),value:t.magicDnsSuffix||`—`,mono:!0},{label:n(`system.meshNetworks.peers`,`Peers`),value:String(t.peerCount)},{label:n(`system.meshNetworks.keyExpiry`,`Key expiry`),value:t.keyExpiry?ut(t.keyExpiry):`—`}].map(t=>e(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[r(`span`,{className:`text-foreground-subtle shrink-0`,children:t.label}),r(`span`,{className:`text-foreground truncate ${t.mono?`font-mono`:``}`,children:t.value})]},t.label))})}function ut(e){let t=e-Date.now();if(t<0)return L.t(`system.meshNetworks.expiredAgo`,{when:Z(e)});let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return L.t(`system.meshNetworks.expiryDays`,{count:n});let r=Math.floor(t/36e5);return r>1?L.t(`system.meshNetworks.expiryHours`,{count:r}):L.t(`system.meshNetworks.expiryMin`,{count:Math.max(1,Math.floor(t/6e4))})}function dt({peers:i,loading:a}){let{t:o}=R(),s=t(()=>i.map(e=>({...e,_id:e.id})),[i]),c=n(e=>{e&&navigator.clipboard?.writeText(e)},[]),l=t(()=>[{key:`hostname`,header:o(`system.meshNetworks.hostname`,`Hostname`),render:t=>e(`div`,{className:`flex flex-col`,children:[e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.hostname||o(`system.meshNetworks.unknown`,`(unknown)`)}),t.isSelf&&r(I,{variant:`info`,children:o(`common.self`)}),t.exitNodeOption&&r(I,{variant:`warning`,children:`exit-node`})]}),t.userLogin&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:t.userLogin})]})},{key:`magicDns`,header:o(`system.meshNetworks.magicdns`,`MagicDNS`),render:t=>t.magicDns?e(`div`,{className:`flex items-center gap-1`,children:[r(`span`,{className:`font-mono text-xs truncate`,children:t.magicDns}),r(P,{variant:`unstyled`,onClick:()=>c(t.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":o(`system.meshNetworks.copyMagicdns`,`Copy MagicDNS`),children:r(u,{className:`h-3 w-3 text-foreground-subtle`})})]}):r(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:t=>{let n=t.addresses[0]??``;return n?e(`div`,{className:`flex items-center gap-1`,children:[r(`span`,{className:`font-mono text-xs`,children:n}),r(P,{variant:`unstyled`,onClick:()=>c(n),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":o(`system.meshNetworks.copyIp`,`Copy IP`),children:r(u,{className:`h-3 w-3 text-foreground-subtle`})})]}):r(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:o(`system.meshNetworks.connection`,`Connection`),render:t=>e(`div`,{className:`flex items-center gap-1.5`,children:[r(I,{variant:ft(t.connection),children:t.connection}),t.relay&&r(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:t.relay})]})},{key:`routes`,header:o(`system.meshNetworks.routes`,`Routes`),render:e=>e.advertisedRoutes.length>0?r(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):r(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:o(`system.meshNetworks.txRx`,`TX / RX`),render:t=>e(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,X(t.txBytes),` · ↓ `,X(t.rxBytes)]})},{key:`lastSeen`,header:o(`system.meshNetworks.lastSeen`,`Last seen`),render:e=>r(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?Z(e.lastSeenMs):`—`})}],[c,o]);return a&&i.length===0?e(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[r(d,{className:`h-3 w-3 animate-spin inline mr-1`}),` `,o(`systemPage.meshNetworks.loadingPeers`)]}):i.length===0?r(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:o(`system.meshNetworks.noPeersVisibleYourTailnet`,`No peers visible — your tailnet may be empty or the host is not joined.`)}):r(`div`,{className:`p-4`,children:r(N,{columns:l,rows:s,rowKey:e=>e._id,minWidthPx:820})})}function ft(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function X(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function Z(e){let t=Date.now()-e;return t<6e4?L.t(`system.meshNetworks.justNow`):t<36e5?L.t(`system.meshNetworks.agoMin`,{count:Math.round(t/6e4)}):t<864e5?L.t(`system.meshNetworks.agoHour`,{count:Math.round(t/36e5)}):L.t(`system.meshNetworks.agoDay`,{count:Math.round(t/864e5)})}var Q=`mesh-network`;function pt(){let{t}=R();return r(U,{functionCap:Q,icon:O,title:t(`system.meshNetworks.meshNetworks2`,`Mesh Networks`),subtitle:t(`system.meshNetworks.privateVpnMeshesThatConnect`,`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`),emptyTitle:t(`system.meshNetworks.noMeshNetworkProvidersInstalled`,`No mesh-network providers installed`),emptyDescription:t(`system.meshNetworks.installAMeshAddonE`,`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`),addLabel:t(`system.meshNetworks.addMesh`,`Add mesh`),install:{capability:Q,label:t(`system.meshNetworks.addMesh`,`Add mesh`)},extraColumns:[{key:`mesh-state`,header:t(`system.meshNetworks.connectionState`,`Mesh`),notSortableReason:t(`system.meshNetworks.connectionStateNotSortable`,`Live state of the tailnet, not a stored value.`),render:e=>r(Y,{addonId:e.addonId})}],lead:t=>e(`div`,{className:`flex flex-col gap-3`,children:[r(rt,{addonId:t.addonId}),r(ct,{addonId:t.addonId})]})})}var $=`/system/identity?tab=certificates`;function mt(){let{t}=R(),n=k(),i=Re();return r(V,{embedded:!0,children:e(`div`,{className:m,children:[r(`p`,{className:`text-xs text-foreground-subtle`,children:t(`system.localAccess.nativeAppsOnThisWi`,`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`)}),r(ve,{trpc:n.trpcClient,addonId:`local-network`,cap:`local-network`,scope:`node`,nodeId:`hub`,onAfterChange:i,title:t(`system.localAccess.lanHttp`,`LAN HTTP`)}),e(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`https-certificate-hint`,children:[t(`system.localAccess.certificateMoved`,`The HTTPS certificate and the local CA are managed under`),` `,r(Ie,{className:`underline`,to:$,children:t(`system.localAccess.certificateMovedLink`,`Identity → Certificates`)}),`.`]})]})})}o();function ht({value:n,onChange:i}){let{t:a}=R(),{data:o}=ge({isCamera:!0,projection:`slim`}),s=t(()=>o===void 0?[{value:``,label:a(`system.networkDiagnostics.loadingCameras`,`Loading cameras…`)}]:o.length===0?[{value:``,label:a(`system.networkDiagnostics.noCameras`,`No cameras`)}]:[{value:``,label:a(`system.networkDiagnostics.pickACamera`,`Pick a camera`)},...o.toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:String(e.id),label:`${e.name} (#${String(e.id)})`}))],[o,a]);return e(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[r(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`system.networkDiagnostics.camera`,`Camera`)}),r(x,{value:n===null?``:String(n),disabled:o===void 0||o.length===0,onChange:e=>i(e.target.value===``?null:Number(e.target.value)),options:s})]})}function gt(){let t=k(),[i,o]=a(null);return r(V,{embedded:!0,children:e(`div`,{className:m,"data-testid":`network-diagnostics`,children:[r(pe,{loadServers:n(async()=>t.trpcClient.turnProvider.getTurnServers.query(),[t])}),r(be,{trpc:t.trpcClient,serverUrl:b(),deviceId:i,cameraField:r(ht,{value:i,onChange:o})})]})})}var _t=[`certificate`,`certificates`,`https`];function vt(){let{t:e}=R(),[t]=Fe();if(_t.includes(t.get(`tab`)??``))return r(Pe,{to:$,replace:!0});let n=Ne(`/system/network`,{t:e,isAdmin:!0})??{icon:j,title:e(`system.network`,`Network`)};return r(Le,{icon:n.icon,title:n.title,defaultSection:`addresses`,sectionsLabel:`${n.title} sections`,sections:[{id:`local-access`,label:e(`systemPage.network.localAccess`,`Local access`),content:r(mt,{})},{id:`addresses`,label:e(`systemPage.network.networkAddresses`,`Network Addresses`),content:r(et,{})},{id:B.remoteAccess.tab,label:e(`systemPage.network.remoteAccess`,`Remote Access`),content:r(He,{}),ownedParams:z},{id:B.mesh.tab,label:e(`systemPage.network.meshNetworks`,`Mesh Networks`),content:r(pt,{}),ownedParams:z},{id:B.turn.tab,label:e(`systemPage.network.turnServers`,`TURN Servers`),content:r(Ge,{}),ownedParams:z},{id:`diagnostics`,label:e(`systemPage.network.diagnostics`,`Diagnostics`),content:r(gt,{})}]})}export{vt as NetworkPage};
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as l,Hn as u,Ir as d,Jn as f,L as p,Ln as m,Nr as h,Oi as g,Ot as _,Wa as v,Xt as y,Z as b,dt as x,en as S,gi as C,hr as w,ir as T,jn as E,pa as D,pn as O,qn as ee,rr as te,ta as ne,vn as re,vt as k,wt as ie}from"./player-overlays-ClFSGefV.js";import{_i as ae,gi as oe,hi as A,ii as se}from"./client-B0p6WiZb.js";import{o as ce,s as le,u as j}from"./terminal-DU-tvcEm.js";import{$f as M,Al as ue,Ar as N,Cl as de,Dl as fe,Dr as pe,El as me,Gf as P,Ml as he,Ns as ge,Or as _e,Si as ve,Tl as ye,Tr as be,Wi as xe,_l as Se,al as Ce,dl as we,ep as F,fa as Te,gl as Ee,jl as De,ma as I,ml as Oe,ol as ke,pl as Ae,sl as je,wl as Me}from"./src-DwclSIv9.js";import{t as L}from"./i18n-NPZM0HGc.js";import{t as R}from"./useTranslation-BJr-n0es.js";import"./mount-D943WJVm.js";import{b as Ne,di as Pe,hi as Fe,o as z,s as B,ui as Ie}from"./index-Bjvuymkk.js";import{t as Le}from"./AdminSectionedPage-dteNFZvo.js";import{t as V}from"./AdminPage-DhtpNaF0.js";import{r as H,t as U}from"./InstancesTable-DMhlGx4D.js";import{t as Re}from"./useInvalidateAddonSettings-CyofQfBo.js";o();var ze=5e3,Be=`network-access`,Ve={connected:!1,endpoint:null};function He(){let{t:e}=R(),t=s(),[n,i]=a(null),[o,c]=a({}),l=(e,n)=>{let r=n?.addonId;t.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),i(null),c(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},u=(e,t)=>{i(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);c(e=>({...e,[n]:r}))},d=De({onSuccess:l,onError:u}),f=he({onSuccess:l,onError:u}),p={key:`tunnel`,header:e(`system.remoteAccess.colTunnel`,`Tunnel`),notSortableReason:e(`system.remoteAccess.tunnelNotSortable`,`A live connection state is not a value to order by.`),render:e=>r(Ue,{addonId:e.addonId,error:o[e.addonId]})},m=e=>r(We,{addonId:e,busyId:n,onStart:e=>{i(e),d.mutate({addonId:e})},onStop:e=>{i(e),f.mutate({addonId:e})}});return r(U,{functionCap:Be,icon:j,title:e(`system.remoteAccess.remoteAccess2`,`Remote Access`),subtitle:e(`system.remoteAccess.publicFacingTunnelsThatExpose`,`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …).`),emptyTitle:e(`system.remoteAccess.noRemoteAccessProvidersInstalled`,`No remote-access providers installed`),emptyDescription:e(`system.remoteAccess.installATunnelAddonE`,`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`),addLabel:e(`system.remoteAccess.addTunnel`,`Add tunnel`),extraColumns:[p],rowActions:e=>m(e.addonId),fixedRowActions:e=>m(e.addonId)})}function W(e){let{data:t}=ue({addonId:e},{refetchInterval:ze,retry:!1}),n=t?se.safeParse(t):null;return n?.success?n.data:Ve}function Ue({addonId:t,error:n}){let{t:i}=R(),a=W(t);return e(`span`,{className:`flex flex-col items-start gap-1`,children:[r(I,{variant:a.connected?`success`:`default`,className:H,children:a.connected?i(`system.remoteAccess.connected`,`Connected`):i(`system.remoteAccess.disconnected`,`Disconnected`)}),a.endpoint&&e(`a`,{href:a.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1 break-all text-[11px] text-success hover:underline`,children:[r(C,{className:`h-3 w-3`}),a.endpoint.url]}),n!==void 0&&r(`span`,{role:`alert`,className:`text-xs text-danger`,children:n})]})}function We({addonId:e,busyId:t,onStart:n,onStop:i}){let{t:a}=R(),o=W(e),s=t===e;return o.connected?r(F,{icon:s?d:O,variant:`ghost`,size:`sm`,"aria-label":a(`system.remoteAccess.stop`,`Stop`),disabled:s,onClick:()=>i(e)}):r(F,{icon:s?d:T,variant:`ghost`,size:`sm`,"aria-label":a(`system.remoteAccess.start`,`Start`),disabled:s,onClick:()=>n(e)})}function Ge(){let{t:e}=R();return r(U,{functionCap:`turn-provider`,icon:w,title:e(`system.turnServers.turnServers`,`TURN Servers`),subtitle:e(`system.turnServers.iceServersUsedForWebrtc`,`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`),emptyTitle:e(`system.turnServers.noTurnProvidersInstalled`,`No TURN providers installed`),emptyDescription:e(`system.turnServers.installATurnAddonE`,`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`),addLabel:e(`system.turnServers.addProvider`,`Add provider`)})}o();var Ke={lan:w,wifi:_,docker:D,vpn:h,loopback:m,other:m},qe={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},Je=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function Ye(n){let{t:i}=R(),{interfaces:a,disabled:o,hideLoopback:s,ipv4Only:c,emptyMessage:l}=n,u=t(()=>a.filter(e=>!(s&&e.kind===`loopback`||c&&e.family!==`IPv4`)),[a,s,c]),d=t(()=>{let e=new Map;for(let t of u){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return Je.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[u]),f=e=>n.mode===`single`?n.value===e:n.value.includes(e),p=e=>{if(o||e.kind===`loopback`)return;if(n.mode===`single`){n.onChange(n.value===e.address?null:e.address);return}let t=new Set(n.value);t.has(e.address)?t.delete(e.address):t.add(e.address),n.onChange([...t])};return u.length===0?r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l??i(`shared.addressSelector.noAddressesAvailable`,`No addresses available.`)}):r(`div`,{className:`flex flex-col gap-3`,children:d.map(({kind:t,items:a})=>e(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[r(Ke[t]??m,{className:`h-3.5 w-3.5 text-foreground-subtle`}),r(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:qe[t]??t}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,a.length]})]}),r(`ul`,{className:`divide-y divide-border`,children:a.map(t=>{let a=f(t.address),s=t.kind===`loopback`,c=!t.plausible&&!s;return e(`li`,{className:`flex items-center gap-3 px-3 py-2 ${s?`opacity-60 cursor-not-allowed`:o?`opacity-60`:c?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>p(t),children:[r(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${n.mode===`single`?`rounded-full`:`rounded`} border ${a?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:a&&r(ne,{className:`h-3 w-3`})}),e(`div`,{className:`flex-1 min-w-0 ${c?`text-foreground-subtle`:``}`,children:[e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[r(`span`,{className:`font-mono text-xs font-semibold ${c?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),r(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono`,children:t.family}),t.preferred&&r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:i(`shared.addressSelector.autoPreferred`,`Auto-preferred`)}),s&&r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:i(`shared.addressSelector.alwaysIncluded`,`Always included`)}),c&&e(`span`,{className:`inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:t.plausibleReason||void 0,children:[r(y,{className:`h-2.5 w-2.5`}),i(`shared.addressSelector.unlikelyUsable`,`Unlikely usable`)]})]}),e(`div`,{className:`text-xs text-foreground-subtle mt-0.5 font-mono break-all`,children:[t.address,t.cidr&&t.cidr!==t.address?` (${t.cidr})`:``]})]})]},`${t.name}-${t.family}-${t.address}`)})})]},t))})}var G=[{role:`appConnections`,get title(){return L.t(`helpers.addressTableModel.appConnectionsTitle`)},single:!1,get help(){return L.t(`helpers.addressTableModel.appConnectionsHelp`)}},{role:`notificationTaps`,get title(){return L.t(`helpers.addressTableModel.notificationTapsTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.notificationTapsHelp`)}},{role:`publicEndpoint`,get title(){return L.t(`helpers.addressTableModel.publicEndpointTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.publicEndpointHelp`)}},{role:`internal`,get title(){return L.t(`helpers.addressTableModel.internalTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.internalHelp`)}}],Xe=`A role with nothing ticked is automatic. Add a custom address when the hub is reached at an address it cannot see itself (NAT, reverse proxy, VPN, Docker bridge).`;function K(e,t){return e.inUse.includes(t)}function Ze(e,t){if(!e.eligible.includes(t))return{kind:`none`};if(e.kind===`app-link`)return K(e,t)?{kind:`none`}:{kind:`set`,input:{role:t,baseUrl:null,enabled:!0}};if(e.flags.includes(t)||t===`appConnections`&&K(e,t))return{kind:`set`,input:{role:t,baseUrl:e.baseUrl,enabled:!1}};let n={role:t,baseUrl:e.baseUrl,enabled:!0};return t===`publicEndpoint`&&e.baseUrl.startsWith(`http:`)?{kind:`confirm-http`,input:n,reason:oe}:{kind:`set`,input:n}}function Qe(e){return G.map(({role:t,title:n})=>{if(t===`appConnections`){let r=e.roles.appConnections;return{role:t,title:n,inUse:r.resolved.length===0?`nothing reachable`:r.resolved.join(`, `),automatic:r.source!==`flagged`}}let r=e.roles[t];return{role:t,title:n,inUse:r.resolved===null?`nothing reachable`:t===`notificationTaps`&&r.source===`auto`?`CamStack app link`:r.resolved,automatic:r.source!==`flagged`}})}o();var q={"lan-ipv4":{labelKey:`system.addressesCard.kindIpv4`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`},"lan-ipv6":{labelKey:`system.addressesCard.kindIpv6`,className:`bg-violet-500/15 text-violet-700 dark:text-violet-300`},public:{labelKey:`system.addressesCard.kindPublic`,className:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},"app-link":{labelKey:`system.addressesCard.kindAppLink`,className:`bg-amber-500/15 text-amber-700 dark:text-amber-300`},custom:{labelKey:`system.addressesCard.kindCustom`,className:`bg-sky-500/15 text-sky-700 dark:text-sky-300`},loopback:{labelKey:`system.addressesCard.kindLoopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function $e({book:t,loading:n,saving:i,error:o,onSetRole:s,onAdd:c,onRemove:l}){let{t:u}=R(),[d,f]=a(``),[p,m]=a(``),[h,g]=a(null),[_,b]=a(null),x=()=>{let e=ae(d);if(!e.ok){g(e.reason);return}g(null),f(``),m(``),c(e.baseUrl,p.trim())},C=(e,t)=>{let n=Ze(e,t.role);if(n.kind!==`none`){if(n.kind===`confirm-http`){b({input:n.input,reason:n.reason});return}b(null),s(n.input)}},w=[{key:`url`,header:u(`system.addressesCard.address`,`Address`),render:n=>e(`div`,{className:`min-w-0 py-0.5`,children:[r(`div`,{className:`font-mono text-[12px] break-all ${n.plausible?`text-foreground`:`text-foreground-subtle`}`,children:n.baseUrl}),e(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:n.label}),n.kind===`app-link`&&e(`span`,{className:`font-mono`,children:[`hub=`,` `,t?.appLinkHub??u(`system.addressesCard.noneNoTunnelOrTailscale`,`none (no tunnel or Tailscale)`)]}),n.custom&&n.detected&&r(`span`,{children:u(`system.addressesCard.alsoAddedAsACustom`,`also added as a custom address`)}),n.kind!==`custom`&&n.interfaceKind!==`lan`&&n.interfaceKind!==`public`&&n.interfaceKind!==`other`&&r(`span`,{className:`uppercase tracking-wide`,children:n.interfaceKind}),!n.plausible&&n.interfaceKind!==`loopback`&&e(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:n.plausibleReason||void 0,children:[r(y,{className:`h-2.5 w-2.5`}),u(`system.addressesCard.unlikelyUsable`,`Unlikely usable`)]})]})]})},{key:`kind`,header:u(`system.addressesCard.kind`,`Kind`),nowrap:!0,render:e=>{let t=q[e.kind]??q.loopback;return r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:u(t.labelKey)})}},...G.map(t=>({key:t.role,headerRender:()=>r(`span`,{title:t.help,children:t.title}),align:`center`,nowrap:!0,width:`w-24`,render:n=>{let a=n.eligible.includes(t.role),o=n.flags.includes(t.role),s=K(n,t.role);return e(`label`,{className:`inline-flex items-center justify-center gap-1 ${a?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:a?s&&!o?u(`system.addressesCard.inUseAutomatically`,`{{title}}: in use automatically. {{help}}`,{title:t.title,help:t.help}):t.help:u(`system.addressesCard.thisAddressCannotBeUsed`,`This address cannot be used for this.`),children:[r(v,{checked:a&&s,disabled:!a||i,onChange:()=>C(n,t),"aria-label":`${t.title}: ${n.baseUrl}`}),s&&!o&&a&&r(`span`,{className:`text-[9px] text-foreground-subtle`,children:u(`common.auto`)})]})}})),{key:`actions`,header:``,align:`right`,nowrap:!0,render:e=>e.custom?r(P,{size:`sm`,variant:`ghost`,disabled:i,onClick:()=>l(e.baseUrl),"aria-label":u(`system.addressesCard.remove`,`Remove {{baseUrl}}`,{baseUrl:e.baseUrl}),title:u(`system.addressesCard.removeThisCustomAddressIts`,`Remove this custom address (its roles turn automatic)`),children:r(S,{className:`h-3 w-3`})}):null}],T=t===void 0?[]:Qe(t);return e(xe,{children:[e(`div`,{className:`px-4 py-3 border-b border-border flex flex-col gap-2`,children:[e(`div`,{children:[r(`div`,{className:`text-sm font-semibold`,children:u(`system.addressesCard.addresses`,`Addresses`)}),r(`div`,{className:`text-xs text-foreground-subtle max-w-3xl`,children:u(`system.addressesCard.everyAddressThisHubIs`,`Every address this hub is reached at, detected or added by you. Tick what each one is used for.`)}),e(`details`,{className:`mt-1.5 text-xs max-w-3xl`,"data-testid":`address-roles-help`,children:[r(`summary`,{className:`cursor-pointer select-none text-foreground-subtle hover:text-foreground`,children:u(`system.addressesCard.whatAreRoles`,`What are roles?`)}),r(`dl`,{className:`mt-1.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:G.map(t=>e(`div`,{className:`contents`,children:[r(`dt`,{className:`font-medium`,children:t.title}),r(`dd`,{className:`text-foreground-subtle`,children:t.help})]},t.role))}),r(`p`,{className:`mt-1.5 text-foreground-subtle`,children:Xe})]})]}),T.length>0&&r(`div`,{className:`grid grid-cols-[auto_1fr_auto] gap-x-3 gap-y-1 items-baseline text-xs`,"data-testid":`address-roles-summary`,children:T.map(t=>e(`div`,{className:`contents`,children:[r(`span`,{className:`text-foreground-subtle`,children:t.title}),e(`span`,{className:`font-mono break-all`,"data-testid":`address-role-${t.role}`,children:[t.inUse,r(`span`,{className:`ml-1.5 font-sans text-foreground-subtle`,children:t.automatic?u(`system.addressesCard.automatic`,`(automatic)`):u(`system.addressesCard.setByYou`,`(set by you)`)})]}),t.automatic?r(`span`,{}):r(P,{size:`sm`,variant:`secondary`,disabled:i,onClick:()=>s({role:t.role,baseUrl:null,enabled:!1}),children:u(`system.addressesCard.useAutomatic`,`Use automatic`)})]},t.role))}),_!==null&&e(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs flex flex-wrap items-center gap-2`,children:[r(y,{className:`h-3.5 w-3.5 text-amber-600`}),r(`span`,{className:`flex-1 min-w-[220px]`,children:_.reason}),r(P,{size:`sm`,variant:`secondary`,onClick:()=>{s({..._.input,acceptInsecureHttp:!0}),b(null)},children:u(`system.addressesCard.useHttpAnyway`,`Use http anyway`)}),r(P,{size:`sm`,variant:`ghost`,onClick:()=>b(null),children:u(`common.cancel`,`Cancel`)})]}),o!==null&&r(`div`,{className:`text-[11px] text-red-600 dark:text-red-400`,role:`alert`,children:o})]}),r(N,{columns:w,rows:t?.rows??[],rowKey:e=>`${e.kind}-${e.baseUrl}`,minWidthPx:760,bordered:!1,emptyMessage:n?u(`common.loading`,`Loading…`):u(`system.addressesCard.noAddressesAvailable`,`No addresses available.`),rowClassName:e=>e.plausible?void 0:`opacity-80`}),e(`div`,{className:`px-4 py-3 border-t border-border flex flex-wrap items-start gap-2`,children:[e(`div`,{className:`flex-1 min-w-[220px]`,children:[r(M,{value:d,onChange:e=>{f(e.target.value),g(null)},placeholder:`https://cams.example.com or https://192.0.2.20:4443`,"aria-label":u(`system.addressesCard.customAddress`,`Custom address`),disabled:i}),h!==null&&r(`div`,{className:`mt-1 text-[11px] text-red-600 dark:text-red-400`,children:h})]}),r(`div`,{className:`w-48`,children:r(M,{value:p,onChange:e=>m(e.target.value),placeholder:u(`system.addressesCard.labelOptional`,`Label (optional)`),"aria-label":u(`system.addressesCard.customAddressLabel`,`Custom address label`),maxLength:80,disabled:i})}),e(P,{size:`sm`,variant:`secondary`,disabled:i||d.trim()===``,onClick:x,children:[r(te,{className:`h-3 w-3`}),u(`system.addressesCard.addCustomAddress`,`Add custom address`)]})]})]})}o();function et(){let{t:n}=R(),o=s(),c=()=>{o.invalidateQueries({queryKey:[[`localNetwork`]]})},d=we(void 0,{refetchInterval:3e4}),p=je(void 0),m=Se({onSuccess:c}),h=Oe({onSuccess:e=>{w(e.addresses),c()}}),g=t(()=>d.data?.interfaces??[],[d.data]),_=ke({scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),v=Ee({onSuccess:c}),y=Ce({onSuccess:c}),b=Ae({onSuccess:c}),x=v.error?.message??y.error?.message??b.error?.message??null,S=v.isPending||y.isPending||b.isPending,[C,w]=a([]),[T,E]=a(!1);i(()=>{!T&&p.data&&(w(p.data.addresses),E(!0))},[p.data,T]);let D=p.data?.addresses??[],O=t(()=>{if(C.length!==D.length)return!0;let e=[...C].toSorted(),t=[...D].toSorted();return e.some((e,n)=>e!==t[n])},[C,D]);return e(V,{embedded:!0,children:[e(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[r(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:n(`system.networkAddresses.pinWhichHostInterfacesExist`,`Pin which host interfaces exist, then tick what each address is used for. Add a custom address when this hub is reached at one it cannot detect.`)}),r(`div`,{className:`flex items-center gap-2 shrink-0`,children:e(P,{size:`sm`,variant:`secondary`,onClick:()=>{d.refetch(),p.refetch(),_.refetch()},disabled:d.isLoading,children:[r(f,{className:`h-3 w-3 ${d.isLoading?`animate-spin`:``}`}),n(`common.refresh`,`Refresh`)]})})]}),r(_e,{headingId:`network-allowed-addresses`,title:n(`system.networkAddresses.allowedAddresses`,`Allowed addresses`),actions:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[e(P,{size:`sm`,variant:`secondary`,onClick:()=>h.mutate(void 0),disabled:h.isPending||m.isPending,title:n(`system.networkAddresses.reRunTheAutoDetection`,`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`),children:[r(re,{className:`h-3 w-3`}),h.isPending?n(`system.networkAddresses.detecting`,`Detecting…`):n(`system.networkAddresses.bestMatch`,`Best match`)]}),e(P,{size:`sm`,variant:`secondary`,onClick:()=>{w([])},disabled:C.length===0||m.isPending,children:[r(ee,{className:`h-3 w-3`}),n(`system.networkAddresses.clear`,`Clear`)]}),O&&r(P,{size:`sm`,variant:`secondary`,onClick:()=>{w(D)},disabled:m.isPending,children:n(`system.networkAddresses.discard`,`Discard`)}),e(P,{size:`sm`,variant:`primary`,onClick:()=>{m.mutate({addresses:[...C]})},disabled:!O||m.isPending,children:[r(u,{className:`h-3 w-3`}),m.isPending?n(`system.networkAddresses.saving`,`Saving…`):n(`common.save`,`Save`)]})]}),children:e(`div`,{className:l,children:[r(`p`,{className:`mb-3 text-xs text-foreground-subtle`,children:C.length===0?n(`system.networkAddresses.autoEveryNonLoopbackNon`,`Auto — every non-loopback / non-link-local interface participates.`):n(`system.networkAddresses.pinned`,`{{value1}} pinned`,{value1:String(C.length)})}),r(Ye,{mode:`multiple`,interfaces:g,value:C,onChange:w,disabled:m.isPending,emptyMessage:d.isLoading?n(`system.networkAddresses.loadingInterfaces`,`Loading interfaces…`):n(`system.networkAddresses.noInterfacesDetected`,`No interfaces detected.`)})]})}),r($e,{book:_.data,loading:_.isLoading,saving:S,error:x,onSetRole:e=>v.mutate({...e}),onAdd:(e,t)=>y.mutate({baseUrl:e,label:t}),onRemove:e=>b.mutate({baseUrl:e})})]})}var tt=5e3,nt={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function J(e){let{data:t,isLoading:n}=de({addonId:e},{refetchInterval:tt,retry:!1}),r=t?A.safeParse(t):null;return{status:r?.success?r.data:nt,isLoading:n}}function Y({addonId:t}){let{t:n}=R(),{status:i}=J(t);return e(`span`,{className:`flex flex-wrap items-center gap-1`,children:[r(I,{variant:i.joined?`success`:`default`,className:H,children:i.joined?n(`system.meshNetworks.joined`,`Joined`):n(`system.meshNetworks.notJoined`,`Not joined`)}),i.joined&&r(I,{className:`text-[10px]`,children:n(`common.peers`,{count:i.peerCount})}),i.error!==void 0&&r(I,{variant:`danger`,className:`text-[10px]`,title:i.error,children:n(`system.meshNetworks.error`,`Error`)})]})}o();function rt({addonId:t}){return e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(Y,{addonId:t}),r(it,{addonId:t})]})}function it({addonId:t}){let{t:i}=R(),o=s(),[l,u]=a(!1),[f,p]=a(null),m=k(),{status:h}=J(t),g=n(()=>{o.invalidateQueries({queryKey:[[`meshNetwork`]]})},[o]),_=fe(),v=Me({onSuccess:g}),y=me({onSuccess:g}),b=n(async()=>{u(!0);let e={cancelled:!1};p(e);try{let n=await _.mutateAsync({addonId:t});if(e.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!e.cancelled&&(await at(2e3),!e.cancelled);){let e=await m.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?A.safeParse(e):null;if(n?.success&&n.data.joined){g();break}if(Date.now()-r>6e5)break}}finally{u(!1),p(null)}},[t,g,_,m]),x=n(()=>{f&&(f.cancelled=!0),u(!1),p(null)},[f]);return r(c,{children:h.joined?e(c,{children:[e(P,{size:`sm`,variant:`secondary`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?r(d,{className:`h-3 w-3 animate-spin`}):r(ce,{className:`h-3 w-3`}),i(`system.meshNetworks.disconnect`,`Disconnect`)]}),e(P,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?r(d,{className:`h-3 w-3 animate-spin`}):r(E,{className:`h-3 w-3`}),i(`system.meshNetworks.logOut`,`Log out`)]})]}):l?e(P,{size:`sm`,variant:`ghost`,onClick:x,children:[r(ie,{className:`h-3 w-3 mr-1`}),` `,i(`common.cancel`)]}):e(c,{children:[e(P,{size:`sm`,variant:`primary`,onClick:()=>void b(),children:[r(le,{className:`h-3 w-3`}),i(`system.meshNetworks.connect`,`Connect`)]}),e(P,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?r(d,{className:`h-3 w-3 animate-spin`}):r(E,{className:`h-3 w-3`}),i(`system.meshNetworks.logOut`,`Log out`)]})]})})}function at(e){return new Promise(t=>setTimeout(t,e))}o();var ot={mesh:`bg-info/15 text-info`,public:`bg-primary/15 text-primary`},st=3e4;function ct({addonId:t}){let{t:n}=R(),{status:i}=J(t),a=ye({addonId:t},{refetchInterval:st,retry:!1});return e(`div`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`space-y-4 p-2 sm:p-4`,children:[i.error&&r(Te,{message:i.error}),r(lt,{status:i}),i.endpoints.length>0&&e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:n(`system.meshNetworks.endpoints`,`Endpoints`)}),i.endpoints.map(t=>e(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[e(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${ot[t.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[t.scope===`public`?r(j,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,t.label]}),e(`a`,{href:t.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-success hover:underline break-all flex items-center gap-1`,children:[r(C,{className:`h-3 w-3 shrink-0`}),t.url]})]},t.id))]})]}),r(`div`,{className:`border-t border-border`,children:r(dt,{peers:a.data?.peers??[],loading:a.isLoading})})]})}function lt({status:t}){let{t:n}=R();return r(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:n(`system.meshNetworks.tenant`,`Tenant`),value:t.tenantName||`—`},{label:n(`system.meshNetworks.user`,`User`),value:t.userLogin??`—`},{label:n(`system.meshNetworks.controlPlane`,`Control plane`),value:t.controlPlaneUrl||`—`},{label:n(`system.meshNetworks.meshIp`,`Mesh IP`),value:t.meshIp||`—`,mono:!0},{label:n(`system.meshNetworks.magicdns`,`MagicDNS`),value:t.magicDnsHostname||`—`,mono:!0},{label:n(`system.meshNetworks.dnsSuffix`,`DNS suffix`),value:t.magicDnsSuffix||`—`,mono:!0},{label:n(`system.meshNetworks.peers`,`Peers`),value:String(t.peerCount)},{label:n(`system.meshNetworks.keyExpiry`,`Key expiry`),value:t.keyExpiry?ut(t.keyExpiry):`—`}].map(t=>e(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[r(`span`,{className:`text-foreground-subtle shrink-0`,children:t.label}),r(`span`,{className:`text-foreground truncate ${t.mono?`font-mono`:``}`,children:t.value})]},t.label))})}function ut(e){let t=e-Date.now();if(t<0)return L.t(`system.meshNetworks.expiredAgo`,{when:Z(e)});let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return L.t(`system.meshNetworks.expiryDays`,{count:n});let r=Math.floor(t/36e5);return r>1?L.t(`system.meshNetworks.expiryHours`,{count:r}):L.t(`system.meshNetworks.expiryMin`,{count:Math.max(1,Math.floor(t/6e4))})}function dt({peers:i,loading:a}){let{t:o}=R(),s=t(()=>i.map(e=>({...e,_id:e.id})),[i]),c=n(e=>{e&&navigator.clipboard?.writeText(e)},[]),l=t(()=>[{key:`hostname`,header:o(`system.meshNetworks.hostname`,`Hostname`),render:t=>e(`div`,{className:`flex flex-col`,children:[e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.hostname||o(`system.meshNetworks.unknown`,`(unknown)`)}),t.isSelf&&r(I,{variant:`info`,children:o(`common.self`)}),t.exitNodeOption&&r(I,{variant:`warning`,children:`exit-node`})]}),t.userLogin&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:t.userLogin})]})},{key:`magicDns`,header:o(`system.meshNetworks.magicdns`,`MagicDNS`),render:t=>t.magicDns?e(`div`,{className:`flex items-center gap-1`,children:[r(`span`,{className:`font-mono text-xs truncate`,children:t.magicDns}),r(P,{variant:`unstyled`,onClick:()=>c(t.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":o(`system.meshNetworks.copyMagicdns`,`Copy MagicDNS`),children:r(g,{className:`h-3 w-3 text-foreground-subtle`})})]}):r(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:t=>{let n=t.addresses[0]??``;return n?e(`div`,{className:`flex items-center gap-1`,children:[r(`span`,{className:`font-mono text-xs`,children:n}),r(P,{variant:`unstyled`,onClick:()=>c(n),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":o(`system.meshNetworks.copyIp`,`Copy IP`),children:r(g,{className:`h-3 w-3 text-foreground-subtle`})})]}):r(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:o(`system.meshNetworks.connection`,`Connection`),render:t=>e(`div`,{className:`flex items-center gap-1.5`,children:[r(I,{variant:ft(t.connection),children:t.connection}),t.relay&&r(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:t.relay})]})},{key:`routes`,header:o(`system.meshNetworks.routes`,`Routes`),render:e=>e.advertisedRoutes.length>0?r(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):r(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:o(`system.meshNetworks.txRx`,`TX / RX`),render:t=>e(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,X(t.txBytes),` · ↓ `,X(t.rxBytes)]})},{key:`lastSeen`,header:o(`system.meshNetworks.lastSeen`,`Last seen`),render:e=>r(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?Z(e.lastSeenMs):`—`})}],[c,o]);return a&&i.length===0?e(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[r(d,{className:`h-3 w-3 animate-spin inline mr-1`}),` `,o(`systemPage.meshNetworks.loadingPeers`)]}):i.length===0?r(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:o(`system.meshNetworks.noPeersVisibleYourTailnet`,`No peers visible — your tailnet may be empty or the host is not joined.`)}):r(`div`,{className:`p-4`,children:r(N,{columns:l,rows:s,rowKey:e=>e._id,minWidthPx:820})})}function ft(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function X(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function Z(e){let t=Date.now()-e;return t<6e4?L.t(`system.meshNetworks.justNow`):t<36e5?L.t(`system.meshNetworks.agoMin`,{count:Math.round(t/6e4)}):t<864e5?L.t(`system.meshNetworks.agoHour`,{count:Math.round(t/36e5)}):L.t(`system.meshNetworks.agoDay`,{count:Math.round(t/864e5)})}var Q=`mesh-network`;function pt(){let{t}=R();return r(U,{functionCap:Q,icon:w,title:t(`system.meshNetworks.meshNetworks2`,`Mesh Networks`),subtitle:t(`system.meshNetworks.privateVpnMeshesThatConnect`,`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`),emptyTitle:t(`system.meshNetworks.noMeshNetworkProvidersInstalled`,`No mesh-network providers installed`),emptyDescription:t(`system.meshNetworks.installAMeshAddonE`,`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`),addLabel:t(`system.meshNetworks.addMesh`,`Add mesh`),install:{capability:Q,label:t(`system.meshNetworks.addMesh`,`Add mesh`)},extraColumns:[{key:`mesh-state`,header:t(`system.meshNetworks.connectionState`,`Mesh`),notSortableReason:t(`system.meshNetworks.connectionStateNotSortable`,`Live state of the tailnet, not a stored value.`),render:e=>r(Y,{addonId:e.addonId})}],lead:t=>e(`div`,{className:`flex flex-col gap-3`,children:[r(rt,{addonId:t.addonId}),r(ct,{addonId:t.addonId})]})})}var $=`/system/identity?tab=certificates`;function mt(){let{t}=R(),n=k(),i=Re();return r(V,{embedded:!0,children:e(`div`,{className:p,children:[r(`p`,{className:`text-xs text-foreground-subtle`,children:t(`system.localAccess.nativeAppsOnThisWi`,`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`)}),r(ve,{trpc:n.trpcClient,addonId:`local-network`,cap:`local-network`,scope:`node`,nodeId:`hub`,onAfterChange:i,title:t(`system.localAccess.lanHttp`,`LAN HTTP`)}),e(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`https-certificate-hint`,children:[t(`system.localAccess.certificateMoved`,`The HTTPS certificate and the local CA are managed under`),` `,r(Ie,{className:`underline`,to:$,children:t(`system.localAccess.certificateMovedLink`,`Identity → Certificates`)}),`.`]})]})})}o();function ht({value:n,onChange:i}){let{t:a}=R(),{data:o}=ge({isCamera:!0,projection:`slim`}),s=t(()=>o===void 0?[{value:``,label:a(`system.networkDiagnostics.loadingCameras`,`Loading cameras…`)}]:o.length===0?[{value:``,label:a(`system.networkDiagnostics.noCameras`,`No cameras`)}]:[{value:``,label:a(`system.networkDiagnostics.pickACamera`,`Pick a camera`)},...o.toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:String(e.id),label:`${e.name} (#${String(e.id)})`}))],[o,a]);return e(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[r(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`system.networkDiagnostics.camera`,`Camera`)}),r(x,{value:n===null?``:String(n),disabled:o===void 0||o.length===0,onChange:e=>i(e.target.value===``?null:Number(e.target.value)),options:s})]})}function gt(){let t=k(),[i,o]=a(null);return r(V,{embedded:!0,children:e(`div`,{className:p,"data-testid":`network-diagnostics`,children:[r(pe,{loadServers:n(async()=>t.trpcClient.turnProvider.getTurnServers.query(),[t])}),r(be,{trpc:t.trpcClient,serverUrl:b(),deviceId:i,cameraField:r(ht,{value:i,onChange:o})})]})})}var _t=[`certificate`,`certificates`,`https`];function vt(){let{t:e}=R(),[t]=Fe();if(_t.includes(t.get(`tab`)??``))return r(Pe,{to:$,replace:!0});let n=Ne(`/system/network`,{t:e,isAdmin:!0})??{icon:j,title:e(`system.network`,`Network`)};return r(Le,{icon:n.icon,title:n.title,defaultSection:`addresses`,sectionsLabel:`${n.title} sections`,sections:[{id:`local-access`,label:e(`systemPage.network.localAccess`,`Local access`),content:r(mt,{})},{id:`addresses`,label:e(`systemPage.network.networkAddresses`,`Network Addresses`),content:r(et,{})},{id:B.remoteAccess.tab,label:e(`systemPage.network.remoteAccess`,`Remote Access`),content:r(He,{}),ownedParams:z},{id:B.mesh.tab,label:e(`systemPage.network.meshNetworks`,`Mesh Networks`),content:r(pt,{}),ownedParams:z},{id:B.turn.tab,label:e(`systemPage.network.turnServers`,`TURN Servers`),content:r(Ge,{}),ownedParams:z},{id:`diagnostics`,label:e(`systemPage.network.diagnostics`,`Diagnostics`),content:r(gt,{})}]})}export{vt as NetworkPage};
|
package/dist/assets/{NodeAddonsSettingsPanel-DTkQMaBn.js → NodeAddonsSettingsPanel-C3eW6HeG.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
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,a as c,et as l,i as u,j as d,o as f,p,t as m}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{vt as h}from"./player-overlays-
|
|
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,a as c,et as l,i as u,j as d,o as f,p,t as m}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{vt as h}from"./player-overlays-ClFSGefV.js";import{Dc as g,Ec as _}from"./client-B0p6WiZb.js";import{Ba as v,Gf as y,Xa as b,_o as ee,rt as te,ts as ne,za as re}from"./src-DwclSIv9.js";import{t as ie}from"./useTranslation-BJr-n0es.js";import{M as ae,Mt as x,N as oe,P as S}from"./index-Bjvuymkk.js";l();var C=d(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 se(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 ce(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 le(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 ue(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}}function de(e,t){let n=e??`general`;return t?.[n]??n}function O(e){return typeof e!=`object`||!e||!(`key`in e)?null:typeof e.key==`string`?e.key:null}function fe(e,t){let n=t.fieldKeys===void 0?null:new Set(t.fieldKeys),r=[];for(let i of e){let e=n===null?i.fields:i.fields.filter(e=>{let t=O(e);return t!==null&&n.has(t)});e.length!==0&&r.push({...i,fields:e,...t.tabAliases===void 0?{}:{tab:de(i.tab,t.tabAliases)},...t.hideSectionChrome===!0?{title:``,description:void 0}:{}})}return r}var k=`login-method`,A=`integration-instances`,j=new Set;function pe(e){return e.level===`global`&&e.capability===void 0&&e.sectionIds===void 0&&e.fieldScope===void 0&&e.fieldKeys===void 0}function M(e){let t=new Set([k]);for(let n of e)for(let e of n)t.add(e);return t}function N(e){return!e.isSuccess&&!e.isError}function P(e){return e instanceof Error&&e.message.length>0?e.message:`Could not list connection providers`}function F(e){if(!e.active)return{phase:`off`,caps:j,error:null};if(!e.canQuery)return{phase:`ready`,caps:j,error:null};if(N(e.holders))return{phase:`loading`,caps:j,error:null};if(e.holders.isError)return{phase:`ready`,caps:M([]),error:P(e.holders.error)};if(e.described.some(N))return{phase:`loading`,caps:j,error:null};let t=e.described.find(e=>e.isError);return{phase:`ready`,caps:M(e.described.flatMap(e=>e.data===void 0?[]:[e.data])),error:t===void 0?null:P(t.error)}}function I(e){if(typeof e!=`object`||!e||!(`addonId`in e))return null;let t=e.addonId;return typeof t==`string`&&t.length>0?t:null}async function L(e){let t=await e({capName:A});if(!Array.isArray(t))throw Error(`listCapabilityProviders did not answer with a list`);let n=[];for(let e of t){let t=I(e);t!==null&&n.push(t)}return n}function R(e){if(typeof e!=`object`||!e||!(`kinds`in e))return[];let t=e.kinds;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e!=`object`||!e||!(`functionCap`in e))continue;let t=e.functionCap;typeof t==`string`&&t.length>0&&n.push(t)}return n}function me(e){let t=h().trpcClient,n=t.addons.listCapabilityProviders?.query,r=t.integrationInstances?.describe?.query,i=n!==void 0&&r!==void 0,a=c({queryKey:[`settings`,`provider-page-holders`],enabled:e&&i,queryFn:()=>{if(n===void 0)throw Error(`listCapabilityProviders is not available`);return L(n)}});return F({active:e,canQuery:i,holders:a,described:u({queries:(a.data??[]).map(t=>({queryKey:[`settings`,`provider-page-kinds`,t],enabled:e&&i&&a.isSuccess,queryFn:async()=>{if(r===void 0)throw Error(`integrationInstances.describe is not available`);return R(await r({addonId:t}))}}))})})}l();function z(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>z(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function B(e,t){return{...e,fields:e.fields.map(e=>z(e,t))}}function he(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>B(e,t))},values:t}}function V({nodeId:a,addonIds:o,level:c,deviceId:l,capability:d,sectionIds:g,omitSectionIds:y,fieldKeys:x,hideSectionChrome:S,tabAliases:C,tabLabelOverrides:w,sectionTab:T,fieldScope:E,emptyMessage:D,extraTabs:O,schemaTabExtras:k,title:A,description:j,selfTabbed:M,activeTab:N,onActiveTabChange:P}){let{t:F}=ie(),I=f(),L=h().trpcClient,R=v(),z=re(),B=ne(),V=ee(),H=M===!0||!!(O&&O.length>0),[_e,ve]=s(null);if(c===`device`&&!l)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let U=a??`hub`,W=me(pe({level:c,...d===void 0?{}:{capability:d},...g===void 0?{}:{sectionIds:g},...E===void 0?{}:{fieldScope:E},...x===void 0?{}:{fieldKeys:x}})),ye=W.phase===`ready`?[...W.caps].sort().join(`
|
|
2
2
|
`):``,G=u({queries:o.map(e=>({queryKey:[[`addonSettings`,c===`global`?`listScopedSettings`:`getDeviceSettings`],{addonId:e,nodeId:U,deviceId:l??null,cap:d??null,scope:E??null,sections:[g??null,y??null],providerCaps:ye}],enabled:W.phase!==`loading`,queryFn:async()=>{if(c===`global`){let t=await L.addonSettings.listScopedSettings.query({addonId:e,nodeId:U});if(t===null)return{addonId:e,result:null,keyTargets:{}};let n=ce({declarations:W.phase===`ready`?t.filter(e=>!W.caps.has(e.cap)):t,...E===void 0?{}:{fieldScope:E},...d===void 0?{}:{capability:d},...g===void 0?{}:{allowSectionIds:g},...y===void 0?{}:{omitSectionIds:y}}),r=await Promise.all(n.map(async t=>{let n=await L.addonSettings.getScopedSettings.query({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:U}:{}});return n===null?null:{declaration:t,form:n}})),i=r.filter(e=>e!==null);if(i.length!==r.length)return{addonId:e,result:null,keyTargets:{}};let a=le(i);return{addonId:e,result:a.form,keyTargets:a.keyTargets}}let t=await L.addonSettings.getDeviceSettings.query({addonId:e,deviceId:l,nodeId:U});return{addonId:e,result:t!==null&&E!==void 0?se(t,E):t,keyTargets:{}}},placeholderData:p}))}),be=W.phase===`loading`||G.some(e=>e.isLoading),xe=G.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(`||`),K=n(()=>{let e=new Set;for(let t of G){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(de(t.tab,C))}return[...e]},[C,xe+`::`+G.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),q=n(()=>new Map((O??[]).map(e=>[e.id,e])),[O]),Se=n(()=>{if(!H)return[];let e=[...new Set([...K,...(O??[]).map(e=>e.id),...(k??[]).map(e=>e.tabId)])],t=e=>{let t=q.get(e);if(t?.order!==void 0)return t.order;let n=_[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})},[H,K,O,q,k]),Ce=n(()=>{let e=new Map,t=e=>_[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of K)e.set(n,t(n));for(let n of k??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of O??[])e.set(t.id,t.label);for(let[t,n]of Object.entries(w??{}))e.set(t,n);return e},[K,O,k,w]),we=N===void 0?_e:N,J=H?we&&Se.includes(we)?we:Se[0]??null:null,Te=e=>{ve(e),P?.(e)},Ee=J!==null&&q.has(J),Y=H?J&&!Ee?J:void 0:T,{data:De}=b(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]),ke=t(new Map),X=n(()=>{let e=g?new Set(g):null,t=y?new Set(y):null,n=n=>!(e!==null&&!e.has(n)||t!==null&&t.has(n)),r=[];for(let e of G){if(!e.data)continue;e.data.result!==null&&ke.current.set(e.data.addonId,{result:e.data.result,keyTargets:e.data.keyTargets});let t=ke.current.get(e.data.addonId)??null;if(t===null)continue;let{result:i,keyTargets:a}=t,{schema:o,values:s}=he(i),c={...x===void 0?{}:{fieldKeys:x},...S===void 0?{}:{hideSectionChrome:S},...C===void 0?{}:{tabAliases:C}},l=fe(o.sections.filter(e=>n(e.id)),c);if(l.length===0)continue;let u={...i,sections:fe(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},[xe,g,y,x,S,C]),Ae=n(()=>G.flatMap(e=>c===`global`&&e.data!==void 0&&e.data.result===null&&!ke.current.has(e.data.addonId)?[e.data.addonId]:[]),[xe,c]),[Z,je]=s(new Map),Me=r(e=>{je(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),Q=t(new Map),Ne=r(e=>t=>{t?Q.current.set(e,t):Q.current.delete(e)},[]),Pe=r(async(e,t)=>{if(c!==`global`){await z.mutateAsync({addonId:e,deviceId:l,nodeId:U,patch:t});return}let{groups:n,unowned:r}=ue(t,X.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=>R.mutateAsync({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:U}:{},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,X,R,z,I,U,l]),Fe=r(async(e,t)=>{await Pe(e,t),I.invalidateQueries({queryKey:[[`addonSettings`]]})},[Pe,I]),Ie=r(async(e,t,n,r)=>{let i=U;try{switch(t){case`reprobe-hwaccel`:await B.mutateAsync({nodeId:i}),I.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await V.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}},[B,V,U,I,L]),Le=r((e,t)=>{Fe(e,t)},[Fe]),$=m({mutationFn:async()=>{let e=[];for(let t of X){let n=Z.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 Pe(e,t),e)))}},onSuccess:({saved:e})=>{for(let t of e)Q.current.get(t)?.discard();I.invalidateQueries({queryKey:[[`addonSettings`]]})}}),Re=r(()=>{for(let e of Q.current.values())e.discard()},[]),ze=n(()=>{let e=0;for(let t of X){let n=Z.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[X,Z]),Be=n(()=>{let e=new Map;for(let t of X){let n=Z.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},[X,Z]);if(be)return i(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let Ve=J&&Ee?q.get(J):void 0,He=Ae.length>0?i(`div`,{className:`space-y-1 text-[11px] text-foreground-subtle`,role:`status`,children:Ae.map(e=>i(`div`,{children:F(`settings.nodeAddonsSettingsPanel.addonUnavailable`,`{{name}} not available.`,{name:Oe.get(e)??e})},e))}):null;if(!H&&X.length===0)return He===null?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:D??F(`settings.nodeAddonsSettingsPanel.noAddonsIn`,{scope:o.length>0?`[${o.join(`, `)}]`:F(`settings.nodeAddonsSettingsPanel.theCurrentSelection`,`the current selection`),level:c})}):He;let Ue=$.isPending;return e(`div`,{className:`space-y-4`,children:[(A||j)&&e(`div`,{className:`border-b border-border pb-2`,children:[A&&i(`h2`,{className:`text-sm font-semibold text-foreground`,children:A}),j&&i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:j})]}),X.length>0||H?He:null,H&&i(ae,{tabs:Se.map(e=>({id:e,label:Ce.get(e)??e})),activeId:J,onChange:Te,pendingByTab:Be}),W.error!==null&&i(`div`,{role:`alert`,className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:F(`settings.nodeAddonsSettingsPanel.providerPagesUnknown`,`Could not check which settings already live on a connection page: {{reason}}`,{reason:W.error})}),$.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(te,{tabKey:Ve?`extra:${J??``}`:`tab:${J??``}`,children:Ve?Ve.content:(()=>{let t=Y?X.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===Y).length,0):0,n=!!Y&&t<=1,r=X.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>Y?(e.tab??`general`)===Y:!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=(k??[]).filter(e=>e.tabId===Y),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:D??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(ge,{entries:r,paneStates:Z,displayNames:Oe,disabled:Ue,setPaneRef:Ne,onPaneStateChange:Me,onImmediateSave:Le,onAction:Ie,inline:H||!!T}),s.map((e,t)=>i(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!be&&i(oe,{pendingCount:ze,onSave:()=>$.mutate(),onDiscard:Re,saving:Ue})]})}function ge({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]),b=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(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(y,{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{fe as n,V as t};
|