PageSourceSearch

https://let.ai/workbench-assets/TabHost-CP0eHQJV.js

js let.ai collected 2026-10-05 15:05:10 UTC 6,726 bytes, 1 lines download raw bytes

1import{cu as F,d as A,aa as H,dg as q,f6 as D,r as v,f7 as K,j as e,bG as m,aj as x,ay as X,H as G,f8 as U,f9 as _,fa as O,fb as I,u as V,fc as J,fd as Q,fe as Z,ff as ee}from"./index-CERQfAt1.js";const W=F()(s=>({maxPane:{},setMaxPane:(r,t)=>s(i=>{const p={...i.maxPane};return t===null?delete p[r]:p[r]=t,{maxPane:p}})}));function se({tab:s,slot:r,paneIdx:t,maximized:i,onToggleMax:p,onHeaderPointerDown:f,children:k}){const{t:o}=A(),d=H(),g=q(),{closeTab:j}=D(),[S,b]=v.useState(null),w=K(r),y=o(w.titleKey),P=()=>({key:I(`pane:${r.p}`),name:r.bind&&s.entityRef?`${y} · ${s.entityRef.label.split(" — ")[0]}`:y,glyph:w.glyph,actionId:O(r)??s.actionId,entityRef:r.bind?s.entityRef:null,scope:s.scope,panes:[{...r}],layout:"solo"}),n=[{key:"max",label:o(i?"workos.workspace.restore":"workos.workspace.maximize"),icon:e.jsx(m,{slug:i?"restore":"max",size:14}),onPick:p},{key:"move-left",label:o("workos.workspace.moveLeft"),disabled:i||t===0,onPick:()=>x.getState().swapPanes(s.id,t,t-1)},{key:"move-right",label:o("workos.workspace.moveRight"),disabled:i||t>=s.panes.length-1,onPick:()=>x.getState().swapPanes(s.id,t,t+1)},{key:"d1",label:"",divider:!0},{key:"own-tab",label:o("workos.workspace.openAsTab"),icon:e.jsx(m,{slug:"grid",size:14}),onPick:()=>{const u=x.getState().dock(P()),a=X(u,g);(a==null?void 0:a.kind)==="navigate"&&d.navigate({to:a.to,...a.hash?{hash:a.hash}:{},...a.search?{search:a.search}:{}})}},{key:"full-page",label:o("workos.workspace.openFullPage"),icon:e.jsx(m,{slug:"doc",size:14}),onPick:()=>{const u={id:"",...P()},a=X(u,g);(a==null?void 0:a.kind)==="navigate"&&d.navigate({to:a.to,...a.hash?{hash:a.hash}:{},...a.search?{search:a.search}:{}})}},{key:"copy-link",label:o("workos.workspace.copyLink"),icon:e.jsx(m,{slug:"link",size:14}),onPick:()=>{navigator.clipboard.writeText(window.location.href).then(()=>G.success(o("workos.workspace.linkCopied"))).catch(()=>{})}},{key:"d2",label:"",divider:!0},{key:"add-block",label:o("workos.workspace.addBlock"),icon:e.jsx(m,{slug:"plus",size:14}),onPick:()=>U.getState().openSearch({mode:"addBlock"})},{key:"close",label:o("workos.workspace.closeBlock"),icon:e.jsx(m,{slug:"close",size:12}),onPick:()=>{W.getState().setMaxPane(s.id,null),s.panes.length<=1?j(s):x.getState().closePane(s.id,t)}}],c=!i&&t===0&&(s.layout==="mainRail"||s.layout==="split"),l=e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"bf-act","data-bfmax":t,onClick:p,"aria-label":o(i?"workos.workspace.restore":"workos.workspace.maximize"),title:o(i?"workos.workspace.restore":"workos.workspace.maximize"),children:e.jsx(m,{slug:i?"restore":"max",size:13})}),e.jsx("button",{type:"button",className:"bf-act","data-bfmenu":t,onClick:u=>{u.stopPropagation();const a=u.currentTarget.getBoundingClientRect();b({x:a.left,y:a.bottom+6})},"aria-label":o("workos.workspace.blockMenu"),title:o("workos.workspace.blockMenu"),children:e.jsx(m,{slug:"kebab",size:13})})]});return e.jsxs("section",{className:"bf","data-pane":r.p,"data-pane-idx":t,children:[c?e.jsx("div",{className:"bf-heropill",children:l}):e.jsxs("header",{className:"bf-h",onPointerDown:f?u=>f(u,t):void 0,children:[e.jsx(m,{slug:w.glyph,size:13}),e.jsx("span",{className:"bf-title",children:y}),w.pkKey?e.jsxs("span",{className:"pk",children:["· ",o(w.pkKey)]}):null,e.jsx("span",{className:"sp"}),l]}),e.jsx("div",{className:`bf-b${w.fill?" fill":""}`,"data-clip-pane":"",children:k}),S?e.jsx(_,{at:S,items:n,onClose:()=>b(null)}):null]})}const te=6;function ae(){const{t:s}=A(),r=H(),{tabId:t}=V({strict:!1}),i=x(k=>k.tabs.find(o=>o.id===t)??null),p=W(k=>t!==void 0?k.maxPane[t]??null:null),f=!!i;return v.useEffect(()=>{if(!t||!f)return;const k=x.getState();k.activeTabId!==t&&k.setActive(t)},[t,f]),i?e.jsx(oe,{tab:i,maxPane:p}):e.jsxs("div",{className:"workos-tab-missing",children:[e.jsx("div",{className:"wtm-title",children:s("workos.workspace.missingTitle")}),e.jsx("div",{className:"wtm-body",children:s("workos.workspace.missingBody")}),e.jsx("button",{type:"button",className:"wtm-home",onClick:()=>void r.navigate({to:"/"}),children:s("workos.workspace.missingHome")})]})}function oe({tab:s,maxPane:r}){const{t}=A(),i=W(n=>n.setMaxPane),p=v.useRef(null),f=J(),[k,o]=v.useState(0),d=r!==null&&r>=0&&r<s.panes.length,g=d?[s.panes[r]]:s.panes,j=d?"solo":s.layout,S=j==="columns"?{gridTemplateColumns:`repeat(${Math.min(g.length,4)}, minmax(0, 1fr))`}:void 0,b=Math.max(0,Math.min(k,g.length-1)),w=v.useMemo(()=>!f||g.length<2?null:e.jsxs(e.Fragment,{children:[g.map((n,c)=>e.jsx("button",{type:"button","aria-current":c===b?"true":void 0,className:`ph-sv${c===b?" pri":""}`,onClick:()=>{const l=p.current;l==null||l.scrollTo({left:l.clientWidth*c,behavior:"smooth"})},children:t(K(n).titleKey)},`${c}-${n.p}`)),e.jsx("span",{className:"ph-sv-sp"}),e.jsx("button",{type:"button",className:"ph-sv","aria-label":t("workos.workspace.blockMenu"),onClick:()=>{var n,c;return(c=(n=p.current)==null?void 0:n.querySelector(`[data-bfmenu="${b}"]`))==null?void 0:c.click()},children:e.jsx(m,{slug:"kebab",size:14})})]}),[f,g,b,t]);Q(w);const y=s.id,P=v.useCallback((n,c)=>{if(n.button!==0||n.target.closest(".bf-act")||d||s.panes.length<2)return;const l=p.current;if(!l)return;const u=n.clientX,a=n.clientY;let M=!1,T=null;const C=Array.from(l.querySelectorAll(".bf")),L=h=>{if(!(!M&&Math.hypot(h.clientX-u,h.clientY-a)<te)){M=!0,T=null;for(const $ of C){const N=$.getBoundingClientRect(),Y=h.clientX>N.left&&h.clientX<N.right&&h.clientY>N.top&&h.clientY<N.bottom,z=Number($.dataset.paneIdx),B=Y&&z!==c;$.classList.toggle("swap-target",B),B&&(T=z)}}},R=()=>{removeEventListener("pointermove",L),removeEventListener("pointerup",R),removeEventListener("pointercancel",E);for(const h of C)h.classList.remove("swap-target");M&&T!==null&&x.getState().swapPanes(y,c,T)},E=()=>{removeEventListener("pointermove",L),removeEventListener("pointerup",R),removeEventListener("pointercancel",E);for(const h of C)h.classList.remove("swap-target")};addEventListener("pointermove",L),addEventListener("pointerup",R),addEventListener("pointercancel",E)},[y,d,s.panes.length]);return e.jsx("div",{className:"ws","data-worktab":s.id,children:e.jsx("div",{className:"ws-grid","data-layout":j,style:S,ref:p,onScroll:f?n=>{const c=n.currentTarget,l=Math.round(c.scrollLeft/Math.max(1,c.clientWidth));
1o(u=>u===l?u:l)}:void 0,children:g.map((n,c)=>{const l=d?r:c,u=Z(n);return e.jsx(se,{tab:s,slot:n,paneIdx:l,maximized:d,onToggleMax:()=>i(s.id,d?null:l),onHeaderPointerDown:P,children:u?e.jsx(v.Suspense,{fallback:null,children:e.jsx(ee.Provider,{value:!0,children:e.jsx(u,{slot:n,entity:s.entityRef,scope:s.scope,host:"block",frame:{layout:j,index:d?0:c}})})}):null},`${l}-${n.p}-${n.v??""}`)})})})}export{ae as TabHost};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.