1import{ae as Cs,r as s,ex as Ns,j as e,e as Y,c7 as En,a3 as Rt,au as Tn,dv as Es,hz as Rn,hA as Ye,R as $e,k as Yt,c0 as nn,jh as Ts,c2 as sn,ji as Rs,c4 as lt,b7 as Ln,b4 as ct,e3 as Ls,e2 as Ms,b5 as Ps,d0 as Mn,jj as Os,h$ as As,j3 as Ds,j5 as Fs,j6 as Bs,ba as $s,jk as Vs,jl as Is,az as Jt,cF as Hs,e4 as Lt,jd as rn,je as on,jm as an,ab as Us,gX as zs,b as Qt,d as Gt,gY as Gs,jc as Ks,gC as ln,fA as Ws,a1 as qs,a5 as Xs,f as Pn,x as On,aj as it,G as An,I as Dn,m as _t,jn as Fn,c as Bn,jo as $n,jp as Vn,l as In,jq as Hn,ay as Kt,i as Ys,L as Le,T as Js,gD as Un,S as St,hd as zn,dj as Qs,c6 as Gn,P as cn,cv as dn,db as Zs,dc as er,dd as tr,ar as nr,de as sr,dg as rr,u as or,ho as ir,hu as ar}from"./appBoot-Dxz8j10y.js";import{u as Kn}from"./dropdown-menu-BsAadLk2.js";import{f as lr,g as cr,q as dr,r as ur,s as pr,t as xr,b as hr,v as Wn,w as mr,x as fr,y as qn,h as Xn,i as br,z as gr,A as wr,P as Yn,S as Jn,B as Qn,W as vr,D as yr,k as jr,a as kr,m as _r,M as Sr,n as Cr,R as Nr,l as Er,d as Tr,j as Rr}from"./RenderQueueButton-D4f0NezK.js";import{m as Lr,e as un,r as Mr,h as Zn,u as Pr,C as Or,E as es}from"./ExportModal-BbiVxqhn.js";import{H as ts}from"./useRenderInbox-B417YMVl.js";import{L as Ar,p as Dr,t as Fr,T as Ct,a as Xe,S as Br,B as $r}from"./ToolControlsPanel-3RfzNlZQ.js";import{H as pn}from"./HomeHeader-Blkky3dO.js";import{t as fe}from"./toast-DNVpd0HV.js";import{R as at}from"./RemixIcon-Cd8cLV7X.js";import{j as Vr}from"./SettingsModal-BdwUr7rp.js";import{A as ns}from"./timeline-CCJAy-E_.js";import{T as Ir,D as ss}from"./toolControls-CYSc6lnV.js";import{u as Hr,a as Ur,R as zr}from"./toolStillCapture-BRdeAS3U.js";import{a as rs}from"./ToolControlErrorBoundary-DWaUqFwj.js";import{u as Gr}from"./useNavHide-7P5kFTEW.js";import{u as os}from"./useStructuredData-DAyxzAQQ.js";import{r as is,R as Kr}from"./recentlyOpened-DC-lAjGx.js";import{i as Be}from"./toolVisibility-C7K8osz3.js";import{t as as}from"./toolInteractions-DEQprzQW.js";import{u as Wr}from"./useRemixTool-BiFdGBXL.js";import{B as Wt}from"./bookmark-C5YWmTwp.js";import{T as ls}from"./trash-2-Ct7Vz6pI.js";import{C as cs}from"./chevron-right-D9EIuD5Q.js";import{P as qr,a as Xr,b as Yr}from"./popover-DrGOBAC7.js";import{X as Jr,c as Qr}from"./ToolIconSquare-BQvcKKDP.js";import{B as Zr}from"./BookmarkBorderIcon-C4nEDYkX.js";import"./index-ljb57BpO.js";import"./index-CsrgrvO-.js";import"./index-BcPJfXKs.js";import"./check-COk8nmih.js";import"./DrawerHandle-eISd2HZK.js";import"./ControlRenderer-DpkIVAi6.js";import"./mediaManager-Bg_E6rOl.js";import"./useMutation-DHcmpDxE.js";import"./box-BxxpxooF.js";import"./file-text-Nrf8667l.js";import"./loader-circle-BCfq-2mn.js";import"./chevron-down-DG2KPdoc.js";import"./media-manager.data-hooks-Dw7yvSdn.js";import"./color-5hdXErkH.js";import"./fontUrls-DdoURDar.js";import"./upload-DPsDV2K5.js";import"./link-TeGPTvtI.js";import"./plus-DHt39h5B.js";import"./isTypingTarget-JIPVTNKT.js";import"./switch-DIXaikzg.js";import"./index-DFEiaXlK.js";import"./menuChrome-Dz6JPORQ.js";import"./eye-off-DwYC47JC.js";import"./eye-CVEDcGWE.js";import"./DeleteIcon-DgHJlhTb.js";import"./play-Bngef7it.js";import"./DisabledReasonTooltip-CjkulTTZ.js";import"./BrikLoader-CjNOeIRG.js";import"./select-DnuH09j8.js";import"./sharedUserMedia-GUJ8cMGr.js";import"./UserMenuQuota-BT1ct3U8.js";import"./gem-BS_wAOa6.js";import"./save-DhVJKyKq.js";import"./UserAvatar-BMziAR2k.js";import"./copy-DC44z2om.js";import"./ThumbnailMedia-DYtZ_Yhp.js";import"./docs-CCdFHTo2.js";import"./RefreshIcon-C6ENIr8L.js";import"./usePlanCheckout-B11j5LZK.js";import"./PlanCard-Bj4_LHIf.js";import"./info-CRrYz4X0.js";import"./CustomPlanModal-CTVDCgk5.js";import"./reactExport-Bq0PUtpl.js";import"./ToggleSwitch-CnN740WT.js";import"./textarea-yQyS1GJ0.js";import"./download-BqNALG3E.js";import"./Dropdown-1YbVM1gi.js";import"./EditPencilIcon-CO34yDTG.js";import"./Slider-D7VGzGfF.js";import"./useInfiniteQuery-DAIPQ19y.js";import"./music-9oPPfy3e.js";import"./film-BAOeN0d_.js";import"./formatBytes-BUdPTGxu.js";import"./TextInput-EQhtyGC8.js";import"./search-BLUe6Yts.js";import"./biButtons-CgzvhAdD.js";import"./ControlRendererV2-DVOnVaEY.js";import"./TextArea-a9QlORF5.js";import"./sparkles-C5BSao5z.js";import"./grip-vertical-B9bJ7kHp.js";import"./folder-CdR2GkAk.js";import"./InlineAlert-Cu6fLdyt.js";import"./circle-alert-C307qU9J.js";import"./ConfirmDialog-YXvNzQpT.js";import"./useHasBeenNearViewport-Bb0NW8ir.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const eo=[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],ds=Cs("Settings2",eo),to={switch:{loading:"tool-viewer-switch-loading"}},xn="For the full Brik experience, switch to desktop.",us="brik-desktop-nudge-seen";function no(){try{return window.localStorage.getItem(us)==="1"}catch{return!1}}function Nt({message:t=xn,chromeVariant:i="legacy"}){const n=t===xn,[r,a]=s.useState(()=>n&&no()),c=Ns();if(s.useEffect(()=>{if(!(!n||r))try{window.localStorage.setItem(us,"1")}catch{}},[n,r]),r)return null;const m=i==="v2";return e.jsxs("div",{role:"status",className:Y(c,"shrink-0 flex items-start gap-[10px]",m?"mx-[16px] mb-[15px] border border-[var(--product-grey-02-legacy)] bg-[var(--product-white-00)] px-[14px] py-[12px]":"mx-[20px] mb-[15px] rounded-[12px] bg-white px-[14px] py-[12px] shadow-[0_1px_6px_rgba(0,0,0,0.1)]"),children:[e.jsx("span",{className:Y("flex-1",m?"text-product-text text-[var(--product-black-00)]":"text-[13px] leading-[1.35] tracking-[-0.26px] text-[#1a1a1a]"),children:t}),e.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>a(!0),className:Y("shrink-0 flex h-[20px] w-[20px] items-center justify-center",m?"text-[var(--product-grey-05)]":"text-[#7d7d7d]"),children:m?e.jsx(En,{className:"size-[14px]"}):e.jsx(Rt,{className:"h-[14px] w-[14px]",strokeWidth:2})})]})}const so=[{id:"whatsapp",label:"WhatsApp",color:"#25D366",icon:e.jsx("svg",{viewBox:"0 0 24 24",fill:"
6currentColor",children:e.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})})},{id:"telegram",label:"Telegram",color:"#2AABEE",icon:e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"})})},{id:"x",label:"X",color:"#000000",icon:e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})})},{id:"facebook",label:"Facebook",color:"#1877F2",icon:e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})})},{id:"email",label:"Email",color:"#7d7d7d",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]})},{id:"more",label:"More",color:"#a3a3a3",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"5",cy:"12",r:"2.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"2.5"}),e.jsx("circle",{cx:"19",cy:"12",r:"2.5"})]})}];function ro({open:t,toolName:i,toolSlug:n,toolId:r,onClose:a}){Tn({open:t,modalName:"mobile_share_sheet"});const{sendModalClicked:c}=Es(),m=s.useRef(null),d=s.useRef(null);s.useEffect(()=>{var P;if(!t)return;d.current=document.activeElement,(P=m.current)==null||P.focus();const p=document.body.style.overflow;document.body.style.overflow="hidden";const y=()=>{const u=m.current;if(!u)return[];const v=u.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');return Array.from(v).filter(j=>!j.hasAttribute("aria-hidden")&&j.offsetParent!==null)},b=u=>{var g,A;if(u.key==="Escape"){a();return}if(u.key!=="Tab")return;const v=y();if(v.length===0){u.preventDefault(),(g=m.current)==null||g.focus();return}const j=v[0],O=v[v.length-1],R=document.activeElement;u.shiftKey?(R===j||!((A=m.current)!=null&&A.contains(R)))&&(u.preventDefault(),O.focus()):R===O&&(u.preventDefault(),j.focus())};return window.addEventListener("keydown",b),()=>{var u,v;window.removeEventListener("keydown",b),document.body.style.overflow=p,(v=(u=d.current)==null?void 0:u.focus)==null||v.call(u)}},[t,a]);
6const x=n?Rn(n,Ye.appId):r?`${window.location.origin}${$e({id:r,slug:null})}`:window.location.href,h=`${i||"Check this out"} â ${x}`,_=s.useCallback(async()=>{c({modal_name:"mobile_share_sheet",button_name:"mobile_share_sheet_copy_link",button_type:"button",button_value:"copy_link"});try{await navigator.clipboard.writeText(x),fe.success("Link copied!",{duration:1500})}catch{fe.error("Could not copy link")}a()},[x,a,c]),w=s.useCallback(async p=>{if(c({modal_name:"mobile_share_sheet",button_name:`mobile_share_sheet_${p}`,button_type:"button",button_value:p}),p==="more"){try{await navigator.share({title:i||"Check this out",url:x})}catch{}a();return}const y={whatsapp:`https://wa.me/?text=${encodeURIComponent(x)}`,telegram:`https://t.me/share/url?url=${encodeURIComponent(x)}&text=${encodeURIComponent(i||"")}`,x:`https://x.com/intent/tweet?url=${encodeURIComponent(x)}&text=${encodeURIComponent(i||"")}`,facebook:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(x)}`,email:`mailto:?subject=${encodeURIComponent(i||"Check this out")}&body=${encodeURIComponent(h)}`};window.open(y[p],"_blank","noopener,noreferrer"),a()},[i,x,h,a,c]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:Y("fixed inset-0 z-[55] bg-black/50 backdrop-blur-sm transition-opacity duration-200",t?"opacity-100":"opacity-0 pointer-events-none"),onClick:a,"aria-hidden":!0}),e.jsxs("div",{ref:m,role:"dialog","aria-modal":"true","aria-label":"Share","aria-hidden":!t,tabIndex:-1,className:Y("fixed left-0 right-0 bottom-0 z-[60] bg-white rounded-t-[15px] p-[15px] pb-[max(15px,env(safe-area-inset-bottom))] flex flex-col gap-[10px] shadow-[0_-8px_30px_rgba(0,0,0,0.2)] transition-transform duration-300 ease-out focus:outline-none",t?"translate-y-0":"translate-y-[100dvh] pointer-events-none"),children:[e.jsxs("div",{className:"flex items-center justify-between mb-[5px]",children:[e.jsxs("span",{className:"text-[12px] font-medium text-black tracking-[-0.24px]",children:["Share ",i||""]}),e.jsx("button",{type:"button",onClick:a,className:"w-[26px] h-[26px] flex items-center justify-center rounded-[5px] hover:bg-[#E8E8E8] transition-colors",children:e.jsx(Rt,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"flex justify-between px-[10px] py-[5px]",children:so.map(p=>e.jsxs("button",{type:"button",onClick:()=>w(p.id),className:"flex flex-col items-center gap-[6px] w-[52px] active:opacity-70 transition-opacity",children:[e.jsx("div",{className:"w-[44px] h-[44px] rounded-full flex items-center justify-center",style:{background:p.color},children:e.jsx("div",{className:"w-[20px] h-[20px] text-white",children:p.icon})}),e.jsx("span",{className:"text-[10px] text-[#7d7d7d] tracking-[-0.2px]",children:p.label})]},p.id))}),e.jsxs("div",{className:"flex items-center gap-[8px]",children:[e.jsxs("div",{className:"flex flex-1 min-w-0 items-center gap-[8px] h-[44px] rounded-[10px] bg-[#E8E8E8] px-[15px]",children:[e.jsx(Ar,{className:"w-[15px] h-[15px] shrink-0 text-black"}),e.jsx("span",{className:"flex-1 text-[12px] text-[#7d7d7d] tracking-[-0.24px] truncate min-w-0",children:x})]}),e.jsx("button",{type:"button",onClick:_,className:"shrink-0 h-[44px] px-[15px] rounded-[10px] bg-black text-white text-[12px] font-medium tracking-[-0.24px] active:opacity-80 transition-opacity",children:"Copy link"})]})]})]})}function ps({toolId:t}){const{anonymousUserId:i,isAnonymous:n,loading:r,sessionId:a,userId:c}=Yt(),m=lr(),d=s.useRef(!1);return s.useEffect(()=>{if(r||d.current||!t)return;d.current=!0;const h={anon_uuid:n?i:void 0,referral:m,session_id:a,tool_id:t,userId:n?void 0:c};nn(sn.TOOL_VIEWED,Ts(h),h)},[i,n,r,m,a,t,c]),{sendToolViewAction:s.useCallback(h=>{if(r||!t)return;const _={action_name:h,anon_uuid:n?i:void 0,session_id:a,tool_id:t??void 0,userId:n?void 0:c};nn(sn.TOOL_VIEW_ACTION,Rs(_),_)},[i,n,r,a,t,c])}}function xs(t){const[i,n]=s.useState(!1),r=s.useMemo(()=>t?t.slug?Rn(t.slug,Ye.appId):`${window.location.origin}${$e(t)}`:"",[t]),a=s.useMemo(()=>`${(t==null?void 0:t.name)||"Check this out"} â ${r}`,[t==null?void 0:t.name,r]),c=s.useCallback(()=>{t&&n(!0)},[t]),m=s.useCallback(async()=>{try{await navigator.clipboard.writeText(r),fe.success("Link copied.",{duration:1500}),lt.capture("tool_shared",{tool_id:t==null?void 0:t.id,tool_name:t==null?void 0:t.name,action:"copy_link",url:r})}catch{fe.error("Link wasn't copied. Try again.")}n(!1)},[r,t]),d=s.useCallback(async x=>{if(lt.capture("tool_shared",{tool_id:t==null?void 0:t.id,tool_name:t==null?void 0:t.name,action:x,url:r}),x==="more"){try{await navigator.share({title:(t==null?void 0:t.name)||"Check this out",url:r})}catch{}n(!1);return}const h={whatsapp:`https://wa.me/?text=${encodeURIComponent(r)}`,telegram:`https://t.me/share/url?url=${encodeURIComponent(r)}&text=${encodeURIComponent((t==null?void 0:t.name)||"")}`,x:`https://x.com/intent/tweet?url=${encodeURIComponent(r)}&text=${encodeURIComponent((t==null?void 0:t.name)||"")}`,facebook:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(r)}`,email:`mailto:?subject=${encodeURIComponent((t==null?void 0:t.name)||"Check this out")}&body=${encodeURIComponent(a)}`};window.open(h[x],"_blank","noopener,noreferrer"),n(!1)},[a,r,t==null?void 0:t.id,t==null?void 0:t.name]);return{shareUrl:r,shareText:a,showShareModal:i,setShowShareModal:n,handleShare:c,handleCopyLink:m,handleShareTo:d}}function hs(){const[t,i]=s.useState(!1),[n,r]=s.useState(0),[a,c]=s.useState(320),[m,d]=s.useState(!1),[x,h]=s.useState(!1),[_,w]=s.useState(()=>{try{return localStorage.getItem("clay_admin_mobile_view")==="1"}catch{return!1}}),p=s.useCallback(()=>{w(R=>{const g=!R;try{localStorage.setItem("clay_admin_mobile_view",g?"1":"0")}catch{}return g})},[]),[y,b]=s.useState({active:!1,tracked:[]}),P=s.useCallback(R=>{b(g=>g.active===R.active&&g.tracked.join("\0")===R.trackedKeys.join("\0")?g:{active:R.active,tracked:R.trackedKeys})},[]),[u,v]=s.useState(null),j=s.useRef(null),O=s.useCallback(R=>{v(g=>({key:R,nonce:((g==null?void 0:g.nonce)??0)+1})),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>v(null),2200)},[]);return s.useEffect(()=>()=>{j.current&&clearTimeout(j.current)}
6,[]),{controlsOpen:t,setControlsOpen:i,controlsDrawerHeight:n,setControlsDrawerHeight:r,panelWidth:a,setPanelWidth:c,timelineTrackKeys:y,handleTrackKeysChange:P,revealControlTarget:u,handleRevealControl:O,iframeReady:m,setIframeReady:d,controlsTouched:x,setControlsTouched:h,adminMobileView:_,toggleAdminMobileView:p}}const Zt="brik_pending_controls",en="brik_pending_controls_nonce",ms="cnonce";function hn(t,i,{reopenExport:n=!1}={}){const r=crypto.randomUUID();sessionStorage.setItem(Zt,JSON.stringify({toolId:t,values:i,reopenExport:n})),sessionStorage.setItem(en,r);const a=new URL(window.location.href);return a.searchParams.set(ms,r),a.toString()}function oo(){sessionStorage.removeItem(Zt),sessionStorage.removeItem(en)}function io(){const t=new URLSearchParams(window.location.search).get(ms);if(!t)return null;const i=sessionStorage.getItem(en);if(t!==i)return null;const n=sessionStorage.getItem(Zt);if(!n)return null;try{const r=JSON.parse(n);return!(r!=null&&r.toolId)||typeof r.values!="object"||r.values===null?null:{...r,reopenExport:!!r.reopenExport}}catch{return null}}function fs({tool:t,iframeRef:i,iframeReady:n,openAuthModal:r,registerOAuthRedirectProvider:a,setShowExport:c,setControlsTouched:m,user:d,profileLoading:x}){const[h]=s.useState(()=>io()),[_,w]=s.useState(!1),p=s.useRef(!1),y=s.useRef(!1),b=s.useCallback(()=>new Promise(u=>{var O;if(!((O=i.current)!=null&&O.contentWindow)){u(null);return}let v=!1;const j=Ln(R=>{R.type===Ms&&!v&&(v=!0,j(),u(R.payload??null))});ct(i,Ls),setTimeout(()=>{v||(v=!0,j(),u(null))},500)}),[i]),P=s.useCallback(async u=>{let v;try{if(t!=null&&t.id){const j=await b();j&&Object.keys(j).length>0&&(v=hn(t.id,j,{reopenExport:!0}))}}catch{}r(()=>c(!0),u,v)},[t==null?void 0:t.id,b,r,c]);return s.useEffect(()=>(a(async()=>{if(!(t!=null&&t.id))return;const u=await b();if(u&&Object.keys(u).length>0)return hn(t.id,u,{reopenExport:!1})}),()=>a(null)),[t==null?void 0:t.id,b,a]),s.useEffect(()=>{if(!n||!h||p.current||(t==null?void 0:t.id)!==h.toolId)return;p.current=!0,Object.entries(h.values).forEach(([v,j])=>{ct(i,Ps,{key:v,value:j})}),m(!0),oo();const u=new URL(window.location.href);u.searchParams.delete("cnonce"),window.history.replaceState({},"",`${u.pathname}${u.search}${u.hash}`),w(!0)},[n,h,t==null?void 0:t.id,m,i]),s.useEffect(()=>{!_||y.current||x||(y.current=!0,d&&(h!=null&&h.reopenExport)&&c(!0))},[_,x,d,h,c]),{openExportAuthWall:P}}function bs({animationTimelineEnabled:t,liveTimeline:i,publishedTimeline:n}){return s.useMemo(()=>t?i!==void 0?i:n??null:null,[t,i,n])}function gs({tool:t,toolUuid:i,navigate:n,sendToolViewAction:r,setPanelWidth:a,setControlsTouched:c,setIframeReady:m,iframeRef:d,iframeReady:x,originalTool:h,originalCreatorName:_,onToggleControlsPanelCollapsed:w}){s.useEffect(()=>Ln(y=>{var b,P,u;if(y.type===As&&(w==null||w()),y.type===Ds){const v=(b=y.payload)==null?void 0:b.width;typeof v=="number"&&v>0&&a(v)}if(y.type===Fs){const v=Bs((P=y.payload)==null?void 0:P.action_name);v&&(r(v),lt.capture("tool_run",{tool_id:t==null?void 0:t.id,tool_uuid:i,action_name:v}))}if(y.type===$s){const v=(u=y.payload)==null?void 0:u.dirty;c(typeof v=="boolean"?v:!0)}if(y.type===Vs){const{toolId:v,toolSlug:j}=y.payload??{};v&&n($e({id:v,slug:j??void 0}))}if(y.type===Is){const{userId:v}=y.payload??{};v&&n(Jt(v))}y.type===Hs&&m(!0)}),[r,n,t==null?void 0:t.id,i,a,c,m,w]),s.useEffect(()=>{i&&(as("view",i).catch(p=>{console.warn("[ToolViewer] Failed to track view:",p)}),lt.capture("tool_previewed",{tool_id:t==null?void 0:t.id,tool_uuid:i,tool_name:t==null?void 0:t.name,slug:t==null?void 0:t.slug,is_public:t==null?void 0:t.is_public}))},[i,t==null?void 0:t.id,t==null?void 0:t.name,t==null?void 0:t.slug,t==null?void 0:t.is_public]),s.useEffect(()=>{if(!x)return;const p=!!h&&Be(h);ct(d,Os,{name:(h==null?void 0:h.name)??null,id:(h==null?void 0:h.id)??null,slug:(h==null?void 0:h.slug)??null,isPublic:p,creatorName:_??null,creatorId:h?Mn(h):null})},[x,h,_,d])}const Mt="brik_pending_remix",Pt="brik_pending_remix_nonce",Et="rnonce";let Tt=!1;function ao(t){Tt=!1;const i=crypto.randomUUID();try{sessionStorage.setItem(Mt,t),sessionStorage.setItem(Pt,i)}catch{}return i}function lo(){const t=new URLSearchParams(window.location.search).get(Et);if(!t)return null;try{return sessionStorage.getItem(Pt)!==t?null:sessionStorage.getItem(Mt)}catch{return null}}function co(){const t=new URL(window.location.href);t.searchParams.has(Et)&&(t.searchParams.delete(Et),window.history.replaceState({},"",`${t.pathname}${t.search}${t.hash}`))}function mn(){if(Tt)return!1;Tt=!0;try{sessionStorage.removeItem(Mt),sessionStorage.removeItem(Pt)}catch{}return!0}function qt(){Tt=!1;try{sessionStorage.removeItem(Mt),sessionStorage.removeItem(Pt)}catch{}}function ws({tool:t,user:i,navigate:n,openAuthModal:r,sendToolViewAction:a}){const[c,m]=s.useState(!1),{mutateAsync:d}=Wr(),x=async()=>
6{if(!(c||!t)){m(!0);try{const w=!!(i!=null&&i.id)&&i.id===t.user_id,{tool:p}=await d({toolId:t.id,options:{source:w?"draft":"published"}});p&&n(`/tooleditor/${p.id}`)}catch(w){console.error("Remix failed:",w),fe.error(w instanceof Error?w.message:"Tool wasn't remixed due to a technical issue. Try again.")}finally{m(!1)}}},h=s.useRef(x);return h.current=x,s.useEffect(()=>{!(i!=null&&i.id)||!(t!=null&&t.id)||lo()===t.id&&mn()&&(co(),h.current())},[i==null?void 0:i.id,t==null?void 0:t.id]),{remixing:c,handleRemix:()=>{if(!(c||!t)){if(a("Remix"),lt.capture("tool_remixed_client",{tool_id:t.id,tool_uuid:t.uuid,tool_name:t.name,is_authenticated:!!i}),!i){const w=ao(t.id),p=new URL(window.location.href);p.searchParams.set(Et,w),r(()=>{mn()&&x()},"tool_viewer_remix_button",p.toString(),()=>qt());return}x()}}}}function uo(t){const{animationTimelineEnabled:i,isMobile:n,timeline:r}=t;return!i||!Lt(r)?{mountDock:!1,autoplayTimeline:null}:n?{mountDock:!1,autoplayTimeline:r??null}:{mountDock:!0,autoplayTimeline:null}}function vs({tool:t,resolvedCode:i,resolvedImpl:n,resolvedSchema:r,initialImplementation:a,creatorName:c,isMobile:m,useNewControlsPanel:d,animationTimelineEnabled:x,chromeVariant:h="legacy",setIframeReady:_,iframeRef:w,timelineDockRef:p}){const y=h==="v2",b=y,P=y&&!m,[u,v]=s.useState(null),[j,O]=s.useState(null),R=s.useMemo(()=>Dr((n==null?void 0:n.presets)??(a==null?void 0:a.presets)),[a==null?void 0:a.presets,n==null?void 0:n.presets]),g=s.useMemo(()=>uo({animationTimelineEnabled:x,isMobile:m,timeline:n==null?void 0:n.timeline}),[x,m,n]),A=g.mountDock||!m&&x&&R.some(D=>Lt(D.timeline)),f=(n==null?void 0:n.timeline)??null,N=(n==null?void 0:n.uuid)??null,U=s.useMemo(()=>Fr(f),[N]),Z=s.useMemo(()=>{if(!t||i===null)return null;const D=t,I=rn(r,n,D),se=on(n,D),K=an(D);return Us({name:t.name,controlsSchema:I,canvasCode:i,libraries:se,customCss:K,canvasConfig:zs(n),creatorName:c,creatorId:Mn(t)??void 0,timeline:g.autoplayTimeline,hideControlsOnMobile:d?!1:m,externalControls:d,showCanvasGuides:b,showToolFrameBar:P})},[t,i,n,r,c,m,d,g,b,P]),V=s.useMemo(()=>{if(!t||i===null)return null;const D=t,I=rn(r,n,D),se=on(n,D);return{id:t.id,uuid:t.uuid??null,controlsSchema:I,canvasCode:i,libraries:se,customCss:an(D),slug:t.slug??void 0,visibility:t.visibility??"public",isPublic:t.is_public}},[t,i,n,r]),H=(n==null?void 0:n.id)??(a==null?void 0:a.id)??null,q=s.useMemo(()=>{const D=(n==null?void 0:n.canvas_width)??(a==null?void 0:a.canvas_width),I=(n==null?void 0:n.canvas_height)??(a==null?void 0:a.canvas_height);return typeof D=="number"&&D>0&&typeof I=="number"&&I>0?{width:D,height:I}:null},[a==null?void 0:a.canvas_height,a==null?void 0:a.canvas_width,n==null?void 0:n.canvas_height,n==null?void 0:n.canvas_width]),ue=(u==null?void 0:u.implId)===H?u.size:q,ke=s.useCallback(D=>{var I;(I=p.current)==null||I.replaceTimeline(D)},[p]),pe=s.useCallback(D=>{v({implId:H,size:D}),cr(w,D)},[H,w]),_e=s.useMemo(()=>({versionKey:H,presets:R,timeline:f,canvasSize:ue,applyTimeline:ke,applyCanvasSize:pe}),[pe,ke,f,ue,H,R]);return s.useEffect(()=>{if(!Z){O(null);return}_(!1);const D=new Blob([Z],{type:"text/html"}),I=URL.createObjectURL(D);return O(I),()=>{URL.revokeObjectURL(I)}},[Z,_]),{toolHtml:Z,toolData:V,iframeSrc:j,mountViewerTimelineDock:A,publishedTimeline:f,viewerPresets:R,initialDockTimeline:U,viewerCanvasSize:ue,viewerPresetController:_e}}function po(t){const{data:i,isLoading:n}=Qt({queryKey:["original-tool",t==null?void 0:t.remixed_from],queryFn:async()=>{let r=t;for(let c=0;c<10&&(r!=null&&r.remixed_from);c++)r=await Gt.entities.Tool.get(r.remixed_from);if(!r||r.id===t.id)return null;const a=r.creator_name||r.created_by;return{originalTool:r,originalCreatorName:a??null}},enabled:!!(t!=null&&t.remixed_from),staleTime:6e4});return{originalTool:(i==null?void 0:i.originalTool)??null,originalCreatorName:(i==null?void 0:i.originalCreatorName)??null,isLoading:n}}function ys({slug:t,toolId:i}){const{data:n,isLoading:r,error:a,refetch:c}=Qt({queryKey:["tool-viewer",t,i],queryFn:async()=>!t&&!i?null:Ws({id:i,slug:t}),enabled:!!(t||i),staleTime:6e4}),m=a instanceof Error&&a.message.toLowerCase().includes("authentication required"),d=(n==null?void 0:n.tool)??null,x=(n==null?void 0:n.implementation)??null,h=d==null?void 0:d.uuid,[_,w]=s.useState(null),[p,y]=s.useState(null),[b,P]=s.useState(null);s.useEffect(()=>{if(!d)return;let A=!1;return(async()=>{try{const{code:f,controlsSchema:N}=await Gs(d,x);A||(y(x),w(f),P(N))}catch(f){if(console.error("[ToolViewer] Failed to resolve canvas code:",f),!A){const N=Ks(d);w(U=>U===N?U:N)}}})(),()=>{A=!0}},[x,d]);const u=(d==null?void 0:d.creator_name)||(d==null?void 0:d.created_by),v=d?ln(d):null,{originalTool:j,originalCreatorName:O}=po(d),R=j?ln(j):null,g=s.useMemo(()=>j?{name:j.name,href:Be(j)?$e({id:j.id,slug:j.slug??void 0}):void 0,creatorName:O??void 0,creatorHref:O&&j.creator_id?Jt(j.creator_id):void 0}:null,[j,O]);return{tool:d,isLoading:r,error:a,isAuthRequired:m,initialImplementation:x,toolUuid:h,resolvedCode:_,resolvedImpl:p,resolvedSchema:b,creatorName:u,creatorHref:v,originalTool:j,originalCreatorName:O,originalCreatorHref:R,desktopRemixInfo:g,refetchToolData:()=>void c()}}function js({iframeRef:t,timelineDockRef:i,toolNameForExport:n,toolUuid:r,userId:a,isMobile:c,showDevModeFeatures:m,sendAssetExported:d,setShowExport:x,setExportedFile:h}){const _=qs(),[w,p]=s.useState(-1),[y,b]=s.useState(!1),P=s.useRef(!1),{recording:u,recordingProgress:v,startRecording:j,stopRecording:O}=Lr(t,n,f=>{if(d({assetData:"video",exportData:{method:"screen-recording",format:f.format,fps:f.fps,duration:f.duration,qual
6ity:f.quality,action:"download",filename:f.filename,mime_type:f.mimeType},exportType:"video"}),P.current&&f.blob&&r&&a){const N=f.blob,U=r;(async()=>{try{const Z=un(N.type),V=new File([N],`export-${Date.now()}.${Z}`,{type:N.type}),H=await Xs(V,{awaitStream:!1});await Mr({tool_uuid:U,file_url:H.file_url,export_kind:N.type.startsWith("image/")?"image":"video",stream_url:H.stream_url,stream_format:H.stream_format,file_size_bytes:N.size}),_.invalidateQueries({queryKey:["library-assets"]}),fe.success("Saved to Media Manager."),_.invalidateQueries({queryKey:["tool-exports",U]})}catch{fe.error("Export wasn't saved due to a technical issue. Try again.")}})()}P.current=!1},(f,N)=>{if(x(!1),c)return;const U=un(N),Z=n.toLowerCase().replace(/[^a-z0-9]/g,"-").replace(/-+/g,"-"),V=new Date().toISOString().slice(0,10);h(new File([f],`${Z}-${V}.${U}`,{type:N}))}),R=s.useCallback(f=>{var N;P.current=f.saveToGallery??!1,(N=i.current)==null||N.playFromStart(),j(f)},[j,i]),{data:g=[]}=Qt({queryKey:["tool-exports",r],enabled:m&&!!r,staleTime:3e4,queryFn:async()=>await Gt.entities.ToolExport.filter({tool_uuid:r,archived:!1},"-created_date",100)}),A=s.useCallback(async f=>{try{await Gt.entities.ToolExport.update(f,{archived:!0}),p(N=>{const U=N-1;return U<-1?-1:U}),_.invalidateQueries({queryKey:["tool-exports",r]})}catch{fe.error("Export wasn't deleted due to a technical issue. Try again.")}},[_,r]);return s.useEffect(()=>{if(w<0)return;const f=N=>{N.key==="Escape"&&p(-1)};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[w]),{recording:u,recordingProgress:v,handleStartRecording:R,stopRecording:O,toolExports:g,handleDeleteExport:A,exportIndex:w,setExportIndex:p,galleryOpen:y,setGalleryOpen:b}}function ks({tool:t,user:i,profile:n,setProfile:r,openAuthModal:a,onWillSave:c}){const[m,d]=s.useState(!1),x=s.useMemo(()=>{var w;return!!(t&&((w=n==null?void 0:n.saved_tools)!=null&&w.includes(t.id)))},[t,n==null?void 0:n.saved_tools]),h=s.useCallback(async()=>{if(!t)return;if(!i||!n){a(()=>_.current(),"tool_viewer_save");return}const w=!x,p=w?[...n.saved_tools??[],t.id]:(n.saved_tools??[]).filter(y=>y!==t.id);r({...n,saved_tools:p}),w&&(c==null||c(),d(!0),setTimeout(()=>d(!1),1400));try{t.uuid&&await as(w?"save":"unsave",t.uuid)}catch{r({...n,saved_tools:n.saved_tools??[]}),fe.error("Tool wasn't saved due to a technical issue. Try again.")}},[t,i,n,r,x,a,c]),_=s.useRef(h);return _.current=h,{isSaved:x,showSavedPopup:m,handleToggleSave:h}}function xo(){var tn;const t=Pn(),i=Gr(),[n]=On(),r=n.get("slug"),a=n.get("id"),c=r&&r!=="undefined"?r:null,m=a&&a!=="undefined"?a:null,[d,x]=s.useState(!1),[h,_]=s.useState(null),[w,p]=s.useState("controls"),y=it(Ir),b=it(ss),P=it(ns),{user:u}=Yt(),{profile:v,setProfile:j,loading:O}=Kn(),{sendPageClicked:R}=An(),A=(u==null?void 0:u.role)==="admin"||b,f=Dn(),{controlsOpen:N,setControlsOpen:U,controlsDrawerHeight:Z,setControlsDrawerHeight:V,panelWidth:H,setPanelWidth:q,timelineTrackKeys:ue,handleTrackKeysChange:ke,revealControlTarget:pe,handleRevealControl:_e,iframeReady:D,setIframeReady:I,controlsTouched:se,setControlsTouched:K,adminMobileView:xe,toggleAdminMobileView:ie}=hs(),[Ve,Me]=s.useState(!1),[be,Pe]=s.useState("canvas"),W=s.useRef(null),C=s.useRef(null),k=s.useRef(null);s.useLayoutEffect(()=>{if(!Ve||!C.current)return;const M=_t.fromTo(C.current,{opacity:0,y:40,scale:.95},{opacity:1,y:0,scale:1,duration:.35,ease:"back.out(1.7)"});return()=>{M.kill()}},[Ve,be]);const o=s.useRef(null),E=s.useRef(null),{fullscreenRef:F,isFullscreen:z,isFillScreen:Se,isToolbarVisible:$,enter:Oe,exit:re,toggleFillScreen:Ie,pinToolbar:Ce,unpinToolbar:He}=dr(o);s.useEffect(()=>{window.scrollTo(0,0);const M=document.documentElement,T=document.body,te={htmlOverflow:M.style.overflow,bodyOverflow:T.style.overflow,htmlScrollbarGutter:M.style.scrollbarGutter,bodyPosition:T.style.position,bodyTop:T.style.top,bodyLeft:T.style.left,bodyRight:T.style.right,bodyWidth:T.style.width};return M.style.overflow="hidden",T.style.overflow="hidden",M.style.scrollbarGutter="auto",f&&(T.style.position="fixed",T.style.top="0",T.style.left="0",T.style.right="0",T.style.width="100%"),()=>{M.style.overflow=te.htmlOverflow,T.style.overflow=te.bodyOverflow,M.style.scrollbarGutter=te.htmlScrollbarGutter,T.style.position=te.bodyPosition,T.style.top=te.bodyTop,T.style.left=te.bodyLeft,T.
6style.right=te.bodyRight,T.style.width=te.bodyWidth}},[f]);const{tool:l,isLoading:Ne,error:Ue,isAuthRequired:Ot,initialImplementation:At,toolUuid:J,resolvedCode:Dt,resolvedImpl:ge,resolvedSchema:Ee,creatorName:ae,creatorHref:Te,originalTool:we,originalCreatorName:Je,originalCreatorHref:G,desktopRemixInfo:Ft,refetchToolData:le}=ys({slug:c,toolId:m});s.useEffect(()=>{u!=null&&u.id&&(l!=null&&l.id)&&is(u.id,l.id)},[u==null?void 0:u.id,l==null?void 0:l.id]);const{sendToolViewAction:X}=ps({toolId:l==null?void 0:l.id}),{sendAssetExported:Ae}=Zn({toolId:l==null?void 0:l.id,toolViewMode:"viewer"}),Bt=l?`${(((tn=l.description)==null?void 0:tn.trim())||Fn(l)).slice(0,150)} · Made with Brik`:void 0;Bn("ToolViewer",{title:l?`${l.name} -- Brik`:void 0,description:Bt,image:$n(l,Ye.appId),url:typeof window>"u"?void 0:`${window.location.origin}${window.location.pathname}${window.location.search}`}),os(Be(l)?Vn(l,window.location.origin,Ye.appId):null);const ve=(l==null?void 0:l.name)||"tool",{recording:he,recordingProgress:ce,handleStartRecording:dt,stopRecording:Qe,toolExports:B,handleDeleteExport:Re,exportIndex:de,setExportIndex:De,galleryOpen:Fe,setGalleryOpen:$t}=js({iframeRef:o,timelineDockRef:E,toolNameForExport:ve,toolUuid:J,userId:u==null?void 0:u.id,isMobile:f,showDevModeFeatures:A,sendAssetExported:Ae,setShowExport:x,setExportedFile:_}),[ut,pt]=s.useState(void 0);s.useEffect(()=>{pt(void 0)},[ge==null?void 0:ge.uuid]);const{openAuthModal:ze,registerOAuthRedirectProvider:xt}=In(),{toolHtml:ht,toolData:ee,iframeSrc:ne,mountViewerTimelineDock:Ze,publishedTimeline:mt,viewerPresets:Ge,initialDockTimeline:ft,viewerCanvasSize:ye,viewerPresetController:et}=vs({tool:l,resolvedCode:Dt,resolvedImpl:ge,resolvedSchema:Ee,initialImplementation:At,creatorName:ae,isMobile:f,useNewControlsPanel:y,animationTimelineEnabled:P,setIframeReady:I,iframeRef:o,timelineDockRef:E});gs({tool:l,toolUuid:J,navigate:t,sendToolViewAction:X,setPanelWidth:q,setControlsTouched:K,setIframeReady:I,iframeRef:o,iframeReady:D,originalTool:we,originalCreatorName:Je}),s.useEffect(()=>{K(!1)},[ne,K]),s.useEffect(()=>{q(320)},[c,m,l==null?void 0:l.id,q]);const{activeStream:bt}=Hr(o,ne),{visible:Vt,toggle:tt}=Pr();Ur(o,ne),rs(),s.useEffect(()=>{if(!(!f||!ne))return Pe("canvas"),Me(!0),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>Me(!1),5e3),()=>{W.current&&clearTimeout(W.current)}},[f,ne]);const{openExportAuthWall:Ke}=fs({tool:l,iframeRef:o,iframeReady:D,openAuthModal:ze,registerOAuthRedirectProvider:xt,setShowExport:x,setControlsTouched:K,user:u,profileLoading:O}),{isSaved:We,showSavedPopup:nt,handleToggleSave:It}=ks({tool:l,user:u,profile:v,setProfile:j,openAuthModal:ze,onWillSave:()=>Me(!1)});s.useLayoutEffect(()=>{if(!nt||!k.current)return;const M=_t.fromTo(k.current,{opacity:0,y:12,scale:.9},{opacity:1,y:0,scale:1,duration:.4,ease:"back.out(2)"}),T=_t.to(k.current,{opacity:0,y:-8,delay:1,duration:.35,ease:"power2.in"});return()=>{M.kill(),T.kill()}},[nt]);const{showShareModal:qe,setShowShareModal:st,handleShare:S}=xs(l??void 0),L=l==null?void 0:l.id,{remixing:Q,handleRemix:gt}=ws({tool:l,user:u,navigate:t,openAuthModal:ze,sendToolViewAction:X}),wt=bs({animationTimelineEnabled:P,liveTimeline:ut,publishedTimeline:mt});if(Ot)return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center px-4",style:{background:f?"#ffffff":"#E8E8E8"},children:[e.jsx("h2",{className:"text-lg font-medium text-[#1a1a1a] mb-1 tracking-[-0.24px]",children:"Private Tool"}),e.jsx("p",{className:"text-sm text-[#7d7d7d] mb-4",children:"Login to view this tool."}),e.jsx("button",{onClick:()=>{R({button_name:"tool_viewer_login"}),ze(le,"tool_viewer_login")},className:"flex h-[36px] items-center justify-center rounded-[10px] bg-black px-[15px] text-[12px] font-medium tracking-[-0.24px] text-white transition-opacity hover:opacity-90",children:"Login"})]});if(Ue||!Ne&&!l)return e.jsx(Hn,{});const je=!f&&y&&!!ee;return e.jsxs(ts,{children:[l&&e.jsxs("div",{className:Y("flex flex-col",f?"h-[100dvh] overflow-hidden transition-[padding] duration-300 ease-out":"pt-[100px] lg:pt-0",!f&&(je?"h-[100dvh] overflow-hidden":"min-h-[100dvh]")),style:{background:f?"#ffffff"
6:"#E8E8E8",paddingBottom:f&&N?Z:void 0},children:[f?N?null:e.jsx("div",{className:Y("shrink-0 transition-opacity",he&&"pointer-events-none opacity-50"),"aria-hidden":he||void 0,style:{paddingTop:"env(safe-area-inset-top, 0px)"},children:e.jsx(pn,{inverted:!0,buildButtonStyle:"secondary",mobileSlimLeadingAction:e.jsx("button",{type:"button",onClick:()=>{var T;X("Back"),(((T=window.history.state)==null?void 0:T.idx)??0)>0?t(-1):t(Ys("Home"))},"aria-label":"Back",className:"lg:hidden flex items-center justify-center shrink-0 h-[40px] w-[40px] rounded-[10px] bg-transparent text-black hover:bg-black/5 transition-colors",children:e.jsx(Kt,{className:"w-[20px] h-[20px]",strokeWidth:2})}),mobileSlimAction:e.jsxs("div",{className:"flex items-center gap-[6px]",children:[e.jsxs("div",{className:"flex items-center gap-0",children:[e.jsx("button",{type:"button",onClick:()=>{X("Save"),It()},"aria-label":We?"Unsave":"Save",title:We?"Unsave":"Save",className:"flex items-center justify-center shrink-0 h-[36px] w-[36px] rounded-[10px] bg-transparent text-black hover:bg-black/5 transition-colors",children:e.jsx(Wt,{className:Y("w-[16px] h-[16px]",We&&"fill-current"),strokeWidth:2})}),e.jsx("button",{type:"button",onClick:()=>{X("Share"),S()},"aria-label":"Share",title:"Share",className:"flex items-center justify-center shrink-0 h-[36px] w-[36px] rounded-[10px] bg-transparent text-black hover:bg-black/5 transition-colors",children:e.jsx(ur,{className:"w-[16px] h-[16px]",strokeWidth:2})})]}),e.jsxs("button",{type:"button",onClick:()=>{X("Remix"),gt()},disabled:Q,"aria-label":"Remix",className:"flex items-center justify-center shrink-0 h-[36px] px-[12px] gap-[6px] rounded-[10px] bg-white border border-solid border-[#e1e1e1] text-black text-[12px] font-medium tracking-[-0.24px] hover:bg-neutral-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(at,{size:12}),Q?"Cloning...":"Remix"]}),e.jsxs("button",{type:"button",onClick:()=>{if(X("Export"),!u){Ke("tool_viewer_mobile_topbar");return}x(!0)},"aria-label":"Export",className:"flex items-center justify-center shrink-0 h-[36px] px-[12px] gap-[6px] rounded-[10px] text-white border border-solid border-transparent text-[12px] font-medium tracking-[-0.24px] shadow-[0_6px_16px_rgba(255,89,241,0.25),inset_0_1px_4px_0_#ffd9e8]",style:{background:"linear-gradient(180deg, #FF4447 0%, #FF59F1 100%) padding-box, linear-gradient(180deg, #FFB8BA 0%, #FFB8F8 100%) border-box"},children:[e.jsx(pr,{className:"size-[14px] shrink-0"}),"Export"]})]})})}):e.jsx("div",{className:`fixed lg:static left-0 right-0 z-20 flex justify-center lg:justify-stretch pointer-events-none lg:pointer-events-auto px-[20px] top-[20px] lg:top-auto lg:transition-[transform,opacity] lg:duration-300 ${i?"lg:-translate-y-full lg:opacity-0":""}`,children:e.jsx("div",{className:"pointer-events-auto w-full",children:e.jsx(pn,{inverted:!0,buildButtonStyle:"secondary",slimDesktopLeading:l?e.jsx("span",{className:"text-[12px] font-medium tracking-[-0.24px] text-black whitespace-nowrap",children:l.name}):null,children:l&&e.jsxs("div",{className:"hidden lg:flex shrink-0 items-center gap-[5px]",children:[A&&e.jsx("button",{type:"button",onClick:()=>{X("Edit"),t(`/tooleditor/${l.id}`)},className:"flex h-[40px] shrink-0 items-center gap-[8px] rounded-[10px] border border-[#e1e1e1] bg-amber-600 px-[15px] text-[12px] font-medium tracking-[-0.24px] text-white whitespace-nowrap transition-opacity hover:opacity-80",style:{borderStyle:"solid"},children:"Edit (Admin)"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-[5px]",children:[e.jsx(Vr,{}),e.jsx(xr,{onClick:()=>{X("Share"),S()}}),e.jsxs("button",{type:"button",onClick:gt,disabled:Q,className:"flex h-[40px] items-center justify-center gap-[8px] rounded-[10px] border border-[#e1e1e1] bg-white px-[15px] text-[12px] font-medium tracking-[-0.24px] text-black whitespace-nowrap transition-colors hover:bg-neutral-50 disabled:opacity-50 disabled:cursor-not-allowed",style:{borderStyle:"solid"},children:[e.jsx(at,{size:12}),Q?"Cloning...":"Remix"]}),e.jsx(hr,{biButtonName:"tool_viewer_export",onExport:()=>{if(X("Export"),!u){Ke("tool_viewer_topbar");return}x(!0)}})]})]})})})}),f&&(l==null?void 0:l.name)&&e.jsxs("div",{className:"shrink-0 px-[30px] pt-[15px] pb-[20px] flex items-center justify-between gap-[8px]",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsx("span",{className:"text-[16px] font-medium text-black tracking-[-0.32px] truncate",children:l.name}),ae&&e.jsxs("span",{className:"text-[14px] text-[#686868] tracking-[-0.28px] truncate",children:["by"," ",Te?e.jsx(Le,{to:Te,className:"hover:underline",children:ae}):ae]}),we&&e.jsxs("span",{className:"flex items-center gap-[3px] text-[10px] text-[#888] tracking-[-0.2px] truncate",children:[e.jsx(at,{size:8,className:"mr-[3px]"}),e.jsx("span",{children:"Remixed:"}),Be(we)?e.jsx(Le,{to:$e({id:we.id,slug:we.slug??void 0}),className:"hover:underline",children:we.name}):e.jsx("span",{children:we.name}),Je&&G&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"by"}),e.jsx(Le,{to:G,className:"hover:underline",children:Je})]})]})]}),A&&e.jsxs("button",{type:"button",onClick:ie,title:xe?"Switch to user view":"Switch to admin view","aria-pressed":xe,className:Y("shrink-0 flex items-center gap-[5px] h-[28px] px-[10px] rounded-[8px] text-[11px] font-medium tracking-[-0.22px] transition-colors",xe?"bg-amber-600 text-white":"bg-[#E8E8E8] text-[#555]"),children:[e.jsx(ds,{className:"w-3 h-3 shrink-0"}),xe?"Admin view":"User view"]}),se&&e.jsxs("button",{type:"button",onClick:()=>{R({button_name:"tool_viewer_mobile_reset"}),ct(o,zn),K(!1)},className:"shrink-0 flex items-center gap-[4px] h-[28px] px-[10px] rounded-[8px] text-[12px] font-medium text-[#666] tracking-[-0.24px] hover:bg-black/5 transition-colors",children:[e.jsx(zr,{className:"w-[12px] h-[12px]",strokeWidth:2}),"Reset"]})]}),e.jsx("div",{className:Y("flex flex-col min-h-0",f?"mx-[20px]":"ml-[20px] mr-[20px] mt-[10px] mb-[20px]",Fe&&B.length>0?"hidden":"flex-1"),children:e.jsx(Wn,{initialConfig:{},children:e.jsx("div",{className:"tool-stage flex-1 flex flex-col min-h-0 relative overflow-hidden",style:{border:"none",borderRadius:"10px",background:"transparent"},children:ht?e.jsx(e.Fragment,{children:e.jsxs("div",{ref:F,className:Y("relative flex-1 min-h-0 w-full overflow-hidden transition-colors duration-150 ease-out",f?"flex items-center justify-center pb-[16
6px]":"",je?"flex flex-row gap-[10px]":"",z?"fixed inset-0 z-[10070] rounded-none bg-[#E8E8E8]":""),style:f&&!z?{containerType:"size"}:void 0,tabIndex:z?-1:void 0,"aria-label":z?"Fullscreen tool viewer":void 0,children:[e.jsxs("div",{className:Y(je?"relative flex-1 min-w-0 h-full":"contents"),children:[(()=>{const M=f&&!z,T=ye==null?void 0:ye.width,te=ye==null?void 0:ye.height,vt=T&&T>0?T:1200,yt=te&&te>0?te:800;return e.jsxs("div",{className:Y("relative",M?"rounded-[10px] overflow-hidden bg-white":"absolute inset-0 z-0 h-full w-full"),style:M?{aspectRatio:`${vt} / ${yt}`,width:`min(100cqw, calc(100cqh * ${vt} / ${yt}))`,height:"auto"}:void 0,children:[e.jsx("iframe",{ref:o,src:ne??void 0,sandbox:Js,title:l.name,className:Y("border-0",M?"absolute inset-0 h-full w-full":"absolute inset-0 z-0 h-full w-full")}),M&&he&&e.jsxs("div",{className:"absolute top-[10px] right-[10px] z-10 flex items-center gap-[6px] pointer-events-none","aria-live":"polite",children:[e.jsx("span",{className:"w-[7px] h-[7px] rounded-full bg-[#FF3B30] animate-pulse shadow-[0_0_8px_rgba(255,59,48,0.6)]"}),e.jsxs("span",{className:"text-[11px] font-semibold tracking-[-0.22px] text-[#7d7d7d]",children:["REC IN PROGRESS",ce.duration?` ${Math.max(0,Math.ceil(ce.duration-ce.elapsed))}s`:""]})]})]})})(),e.jsx(Or,{stream:bt,visible:Vt,onToggle:tt}),!f&&e.jsx(mr,{panelWidth:H,visible:!z,trackPageClick:!1,viewerLayout:!0,onFullscreenClick:Oe}),!f&&z?e.jsx(fr,{visible:$,isFillScreen:Se,onExit:re,onFillToggle:Ie,onHold:Ce,onRelease:He}):null,!f&&he&&!z?e.jsx(qn,{elapsed:ce.elapsed,duration:ce.duration,onStop:Qe}):null,Ze&&ee?e.jsx(Xn,{ref:E,controlsSchema:ee.controlsSchema,iframeRef:o,toolLoadKey:ne,chatCollapsed:!0,draftImplId:null,initialTimeline:ft,controlsPanelWidth:je?0:H,onTimelineChange:pt,onTrackKeysChange:ke,onRevealControl:_e,playbackLocked:
6he}):null]}),je&&ee?e.jsx(Ct,{mode:"desktop",controlsSchema:ee.controlsSchema,iframeRef:o,toolLoadKey:ne,toolId:(l==null?void 0:l.id)??null,open:!0,toolName:l.name,creatorName:ae??void 0,creatorHref:l.creator_id?Jt(l.creator_id):void 0,remix:Ft,presetController:et,timelineActive:Ze&&ue.active,trackedControlKeys:ue.tracked,onToggleTrack:M=>{var T;return(T=E.current)==null?void 0:T.addOrRevealTrack(M)},revealControl:pe,onPresetBiAction:X}):null]})}):e.jsx("div",{className:"flex-1"})})})}),A&&B.length>0&&e.jsxs("div",{className:`mx-[20px] mb-[20px] ${Fe?"flex-1 flex flex-col min-h-0":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>$t(M=>!M),className:"flex items-center gap-2 px-4 py-2 bg-white border border-[#e1e1e1] rounded-[8px] text-[12px] font-medium text-black hover:bg-[#f5f5f5] transition-colors",children:[e.jsx(Un,{className:"w-3.5 h-3.5"}),Fe?"Hide Gallery":`Show Gallery (${B.length})`]}),Fe&&e.jsx("div",{className:`mt-3 flex-1 overflow-y-auto grid gap-2 ${B.length===1?"grid-cols-1":B.length<=4?"grid-cols-2":"grid-cols-3"}`,children:B.map((M,T)=>e.jsxs("div",{className:"relative group/export aspect-video rounded-[8px] overflow-hidden cursor-pointer bg-[#111] border border-[#222] hover:border-[#444] transition-colors",onClick:()=>De(T),children:[M.export_kind==="video"?e.jsx(St,{fallbackUrl:M.file_url,streamFormat:M.stream_format,streamUrl:M.stream_url,muted:!0,className:"absolute inset-0 w-full h-full object-cover"}):e.jsx("img",{src:M.file_url,alt:"",className:"absolute inset-0 w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:te=>{te.stopPropagation(),Re(M.id)},className:"absolute top-2 right-2 opacity-0 group-hover/export:opacity-100 transition-opacity flex items-center gap-1 px-2 py-1 rounded-[4px] bg-black/60 text-white text-[10px] hover:bg-red-600/80",children:e.jsx(ls,{className:"w-3 h-3"})})]},M.id))})]}),f&&l&&!N&&!(Fe&&B.length>0)&&e.jsxs(e.Fragment,{children:[e.jsx(Nt,{}),P&&Lt(ge==null?void 0:ge.timeline)&&e.jsx(Nt,{message:"This tool contains a timeline animation. Switch to desktop."}),e.jsx("div",{className:"shrink-0 px-[20px] pb-[20px]",style:{paddingBottom:"calc(20px + env(safe-area-inset-bottom, 0px))"},children:e.jsxs("div",{className:"flex w-full gap-[10px]",children:[e.jsxs("button",{type:"button","data-testid":Xe.viewerBottomBar.controls,onClick:()=>{X("Edit"),p("controls"),U(!0)},className:"flex h-[48px] flex-1 items-center justify-center gap-[8px] rounded-[10px] border border-solid border-[#e1e1e1] bg-white text-[12px] font-medium tracking-[-0.24px] text-black transition-colors hover:bg-[#fafafa]",children:[e.jsx(Br,{className:"w-[12px] h-[12px]",strokeWidth:2}),"Edit Controls"]}),Ge.length>0?e.jsxs("button",{type:"button","data-testid":Xe.viewerBottomBar.presets,onClick:()=>{X("Presets"),p("presets"),U(!0)},className:"flex h-[48px] flex-1 items-center justify-center gap-[8px] rounded-[10px] border border-solid border-[#e1e1e1] bg-white text-[12px] font-medium tracking-[-0.24px] text-black transition-colors hover:bg-[#fafafa]",children:[e.jsx($r,{className:"size-[12px]"}),"Presets"]}):null]})})]}),A&&de>=0&&B[de]&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/90 flex items-center justify-center",onClick:()=>De(-1),children:[e.jsx("button",{type:"button",onClick:()=>De(-1),className:"absolute top-4 right-4 flex items-center justify-center w-8 h-8 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors",children:e.jsx(Rt,{className:"w-4 h-4"})}),B.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),De(T=>T<=0?B.length-1:T-1)},className:"absolute left-4 top-1/2 -translate-y-1/2 flex items-center justify-center w-10 h-10 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors",children:e.jsx(Kt,{className:"w-5 h-5"})}),e.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),De(T=>T>=B.length-1?0:T+1)},className:"absolute right-4 top-1/2 -translate-y-1/2 flex items-center justify-center w-10 h-10 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors",children:e.jsx(cs,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"max-w-[90vw] max-h-[85vh] flex items-center justify-center",onClick:M=>M.stopPropagation(),children:B[de].export_kind==="video"?e.jsx(St,{fallbackUrl:B[de].file_url,streamFormat:B[de].stream_format,streamUrl:B[de].stream_url,controls:!0,autoPlay:!0,loop:!0,muted:!0,className:"max-w-full max-h-[85vh] rounded-[8px]"}):e.jsx("img",{src:B[de].file_url,alt:`Export ${de+1}`,className:"max-w-full max-h-[85vh] rounded-[8px] object-contain"})}),B.length>1&&e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white/50 text-[12px] tabular-nums",children:[de+1," / ",B.length]})]}),f&&ee&&(y||Ge.length>0?(console.info("[ToolViewer] rendering new ToolControlsPanel mobile",{controlsOpen:N,iframeSrc:ne,schemaCount:ee.controlsSchema.length}),e.jsx(Ct,{mode:"mobile",controlsSchema:ee.controlsSchema,iframeRef:o,toolL
6oadKey:ne,toolId:(l==null?void 0:l.id)??null,open:N,onClose:()=>U(!1),onHeightChange:V,presetController:et,view:w,onPresetBiAction:X})):(console.info("[ToolViewer] rendering legacy MobileControlsDrawer",{controlsOpen:N,iframeSrc:ne,schemaCount:ee.controlsSchema.length}),e.jsx(br,{controlsSchema:ee.controlsSchema,iframeRef:o,toolLoadKey:ne,toolId:(l==null?void 0:l.id)??null,open:N,onClose:()=>U(!1),onHeightChange:V}))),f?e.jsx(gr,{open:d,onClose:()=>x(!1),children:e.jsx(wr,{open:d,onClose:()=>x(!1),iframeRef:o,toolName:ve,toolData:ee??void 0,toolUuid:J,isAdmin:A,modalOrigin:"tool_viewer_mobile_topbar",onStartRecording:dt,recording:he,toolViewMode:"viewer",timeline:wt,onImageReady:()=>{x(!1)}})}):e.jsx(es,{open:d,onClose:()=>x(!1),iframeRef:o,toolName:ve,toolData:ee??void 0,toolUuid:J,isAdmin:A,isOwner:!!(u!=null&&u.id)&&!!l&&u.id===l.user_id,modalOrigin:"tool_viewer_canvas_toolbar",onStartRecording:dt,recording:he,toolViewMode:"viewer",timeline:wt,onImageReady:(M,T)=>{const te=`image/${T}`,vt=ve.toLowerCase().replace(/[^a-z0-9]/g,"-").replace(/-+/g,"-"),yt=new Date().toISOString().slice(0,10);fetch(M).then(Ht=>Ht.blob()).then(Ht=>{x(!1),_(new File([Ht],`${vt}-${yt}.${T}`,{type:te}))}).catch(()=>{x(!1)})}}),e.jsx(Yn,{file:h,toolName:ve,toolSlug:(l==null?void 0:l.slug)??c,onClose:()=>_(null)}),f?e.jsx(ro,{open:qe,toolName:ve,toolSlug:(l==null?void 0:l.slug)??c,toolId:L,onClose:()=>st(!1)}):e.jsx(Jn,{open:qe,autoDismissMs:3e4,toolName:ve,toolSlug:(l==null?void 0:l.slug)??c,onClose:()=>st(!1)}),nt&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:e.jsxs("div",{ref:k,className:"flex items-center gap-[8px] bg-white/90 backdrop-blur-xl text-black border border-white/50 px-[20px] py-[12px] rounded-[12px] shadow-lg",children:[e.jsx(Wt,{className:"w-5 h-5 fill-current"}),e.jsx("span",{className:"text-[14px] font-medium tracking-[-0.28px]",children:"Saved to your collection"})]})})]}),e.jsx(Qn,{position:"fixed",background:f?"#ffffff":"#E8E8E8",visible:Ne||!D})]})}const Ut="flex h-[30px] flex-1 items-center justify-center border border-[var(--product-grey-02)] bg-[var(--product-white-00)] text-[var(--product-black-00)] transition-colors hover:bg-[var(--product-grey-01)]";function ho({shareUrl:t,copied:i,onCopyLink:n,onWhatsApp:r,onX:a,onTikTok:c,onClose:m}){return e.jsxs("div",{className:"flex w-[455px] flex-col border border-[var(--product-grey-03)] bg-[var(--product-white-00)]",children:[e.jsxs("div",{className:"flex items-start justify-between p-[12px]",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-[3px]",children:[e.jsx("p",{className:"text-[14px] leading-[1.2] tracking-[-0.14px] text-[var(--product-black-00)]",children:"Share this tool"}),e.jsx("p",{className:"text-[12px] leading-[1.3] tracking-[-0.12px] text-[var(--product-grey-04)]",children:"Share a link or post it directly to your channels"})]}),e.jsx("button",{type:"button",onClick:m,"aria-label":"Close",className:"flex size-[24px] shrink-0 items-center justify-center text-[var(--product-black-00)]",children:e.jsx(En,{className:"size-[15px]"})})]}),e.jsx(Qs,{}),e.jsx("div",{className:"border border-[var(--product-grey-02)] p-[12px]",children:e.jsxs("div",{className:"flex h-[36px] flex-1 items-center gap-[12px] border border-[var(--product-grey-02)] bg-[var(--product-white-00)] p-[8px]",children:[e.jsx("span",{className:"flex-1 truncate text-[12px] tracking-[-0.12px] text-[var(--product-grey-04)]",children:t??"Publish the tool first to get a shareable link."}),e.jsx("button",{type:"button",onClick:n,className:"shrink-0 whitespace-nowrap bg-[var(--product-black-00)] px-[8px] py-[4px] text-[12px] tracking-[-0.12px] text-[var(--product-white-00)] transition-opacity hover:opacity-90",children:i?"Copied!":"Copy link"})]})}),e.jsxs("div",{className:"flex items-center py-[12px]",children:[e.jsx("p",{className:"flex-1 px-[24px] text-[12px] tracking-[-0.12px] text-[var(--product-black-00)]",children:"Or share directly"}),e.jsxs("div",{className:"flex flex-1 gap-[4px] px-[24px]",children:[e.jsx("button",{type:"button","aria-label":"Share on WhatsApp",onClick:r,className:Ut,children:e.jsx(vr,{className:"size-[22px]"})}),e.jsx("button",{type:"button","aria-label":"Share on X",onClick:a,className:Ut,children:e.jsx(Jr,{className:"size-[22px]"})}),e.jsx("button",{type:"button","aria-label":"Share on TikTok",onClick:c,className:Ut,children:e.jsx(Qr,{className:"size-[22px]"})})]})]})]})}function mo({open:t,onOpenChange:i,toolName:n,toolSlug:r,toolId:a}){Tn({open:t,modalName:"share_tool_modal"});const{shareUrl:c,copied:m,handleCopyLink:d,handleWhatsApp:x,handleX:h,handleTikTok:_}=yr({toolName:n,toolSlug:r,toolId:a});return e.jsxs(qr,{open:t,onOpenChange:i,children:[e.jsx(Xr,{asChild:!0,children:e.jsx(Gn,{size:"big",skin:"ghost",priority:"primary","aria-label":"Share",className:"border-l border-[var(--product-grey-02)]",glyphClassName:"size-[18px]",icon:e.jsx(jr,{className:"size-full shrink-0"})})}),e.jsx(Yr,{align:"end",side:"bottom",sideOffset:0,className:"w-auto rounded-none border-0 bg-transparent p-0 shadow-none",onOpenAutoFocus:w=>w.preventDefault(),children:e.jsx(ho,{shareUrl:c,copied:m,onCopyLink:d,onWhatsApp:x,onX:h,onTikTok:_,onClose:()=>i(!1)})})]})}const fn=35,fo=500,bo=5e3,bn="Join Brik",go=({onClick:t})=>{const i=s.useRef(null);return s.useEffect(()=>
6{const n=i.current;if(!n||matchMedia("(prefers-reduced-motion: reduce)").matches)return;const r=[...n.querySelectorAll(".brik-nav-flip-letter")];if(!r[r.length-1])return;let c=!1,m=0,d=0;const x=fo+(r.length-1)*fn,h=()=>{window.clearTimeout(m),!c&&(m=window.setTimeout(()=>{if(c||n.matches(":hover")||n.classList.contains("is-flipping")){h();return}n.classList.add("is-flipping"),d=window.setTimeout(()=>{c||n.classList.remove("is-flipping"),h()},x)},bo))};return h(),()=>{c=!0,window.clearTimeout(m),window.clearTimeout(d),n.classList.remove("is-flipping")}},[]),e.jsx("button",{ref:i,type:"button",className:"jbt brik-nav-flip text-product-title","aria-label":bn,onClick:t,children:[...bn].map((n,r)=>e.jsx("span",{className:"brik-nav-flip-letter inline-block whitespace-pre",style:{animationDelay:`${r*fn}ms`},children:n},`${n}-${r}`))})},rt="Join Brik",me=6,gn=.85,wn=.7,vn=.4,jt=740,wo=800,vo=440,yn=100,yo=300,jo=90,ko=5e3,_o=.16,So=.34,Co=.9,No=400,Eo=950,zt=70,Xt="#193EF9",jn="#ffffff",kn={bg:"transparent",ink:Xt},kt=[{bg:Xt,ink:jn},{bg:jn,ink:Xt}];function _s(t,i,n,r){const a=3*t,c=3*(n-t)-a,m=1-a-c,d=3*i,x=3*(r-i)-d,h=1-d-x,_=p=>((m*p+c)*p+a)*p,w=p=>(3*m*p+2*c)*p+a;return p=>{if(p<=0)return 0;if(p>=1)return 1;let y=p;for(let b=0;b<8;b++){const P=_(y)-p;if(Math.abs(P)<1e-6)break;const u=w(y);if(Math.abs(u)<1e-6)break;y-=P/u}return((h*y+x)*y+d)*y}}const To=_s(.62,0,.38,1),_n=_s(.23,1,.32,1);function ot(t,i,n,r,a){let c=0,m=!1;const d=performance.now();let x=()=>{};const h=new Promise(w=>{x=w}),_=w=>{if(m)return;const p=n<=0?1:Math.min(1,(w-d)/n);a(t+(i-t)*(r?r(p):p)),p<1?c=requestAnimationFrame(_):x(!0)};return c=requestAnimationFrame(_),{finished:h,stop:()=>{m=!0,cancelAnimationFrame(c),x(!1)}}}function Sn(t){let i=()=>{};const n=new Promise(a=>{i=a}),r=window.setTimeout(()=>i(!0),t);return{finished:n,stop:()=>{window.clearTimeout(r),i(!1)}}}function Ss(t){return t<0?0:t>1?1:t}function Cn(t,i,n){const r=n-1-i,a=n-1,c=gn*Math.pow(r,wn),m=gn*Math.pow(a,wn),d=1-vn*(r/a),x=m+(1-vn),h=Ss((t*x-c)/d);return h*h*(3-2*h)}function oe(t,i,n){const r=document.createElement(t);return r.className=i,n&&(r.textContent=n),r}function Ro(t){const i=matchMedia("(prefers-reduced-motion: reduce)").matches,n=matchMedia("(hover: hover) and (pointer: fine)").matches,r=oe("span","jn-shell"),a=oe("span","jn-cube");r.appendChild(a),t.appendChild(r);const c=[],m=[];let d=null,x=null,h=null,_=null;for(let C=0;C<4;C++){const k=oe("span","jn-face");if(k.style.setProperty("--k",String(C)),C===0){const o=oe("span","jn-fill");x=oe("span","jn-base"),o.appendChild(x),h=oe("span","jn-lbl jn-ink",rt),o.appendChild(h);for(let E=0;E<me;E++){const F=oe("span","jn-slice jn-slice-ink"),z=oe("span","jn-lbl",rt);F.appendChild(z),o.appendChild(F),c.push({el:F,lbl:z})}_=oe("span","jn-revbg"),o.appendChild(_);for(let E=0;E<me;E++){const F=oe("span","jn-slice jn-slice-rev"),z=oe("span","jn-lbl",rt);F.appendChild(z),o.appendChild(F),m.push({el:F,lbl:z})}d=o,k.appendChild(o),k.appendChild(oe("span","jn-rest",rt))}else k.className="jn-face jn-face-back",k.appendChild(oe("span","jn-lbl",rt));a.appendChild(k)}let w=0,p=0,y=1,b=-1,P=!1,u=!1,v=1,j=jt,O=null,R=0,g=null,A=null,f=null,N=null,U=null,Z=!1,V=!1;const H=t.parentElement,q=[];function ue(C){const k=performance.now();for(q.push({x:C.clientX,y:C.clientY,t:k});q.length>1&&k-q[0].t>zt;)q.shift()}function ke(){if(q.length<3)return null;const C=q[0],k=q[q.length-1];if(performance.now()-k.t>zt)return null;const o=k.y-C.y;return Math.abs(o)<2?null:o>0?-1:1}function pe(){if(q.length<3)return null;const C=q[0],k=q[q.length-1];if(performance.now()-k.t>zt)return null;const o=Math.max(1,k.t-C.t);return Math.hypot(k.x-C.x,k.y-C.y)/o}function _e(){const C=pe();if(C===null)return jt;const k=jt*Co/Math.max(C,.05);return Math.min(Eo,Math.max(No,k))}function D(C){Z=C,H==null||H.classList.toggle("is-3d",C),C||(a.style.transform=""),K()}function I(C,k){const o=O;O=null,o==null||o.stop(),D(!0),w=0,R=performance.now()+k;const E=ot(0,C,k,To,F=>{w=F,K()});O=E,E.finished.then(F=>{O!==E||V||(O=null,F&&D(!1))})}function se(){if(!d)return;const C=d.getBoundingClientRect();if(!C.height)return;const k=window.devicePixelRatio||1,o=[];for(let E=0;E<=me;E++){const F=C.top+C.height*E/me;o.push(Math.round(F*k)/k-C.top)}o[0]=0,o[me]=C.height,N={h:C.height,e:o};for(let E=0;E<me;E++)c[E].el.style.clipPath=`inset(${o[E].toFixed(3)}px 0 ${(C.height-o[E+1]).toFixed(3)}px 0)`}function K(){if(a.style.transform=Z?`rotateX(${w}deg)`:"",!N||!x||!_||!h)return;const C=b<0?kn:kt[b%kt.length],k=P?kn:C,o=P?C:kt[(b+1)%kt.length];x.style.background=k.bg,_.style.background=o.bg;const E=["100% 0%","100% 100%"];for(let $=me-1;$>=0;$--){const re=`${((1-Cn(p,$,me))*100).toFixed(3)}%`;E.push(`${re}
6 ${(N.e[$+1]/N.h*100).toFixed(4)}%`),E.push(`${re} ${(N.e[$]/N.h*100).toFixed(4)}%`)}_.style.clipPath=`polygon(${E.join(",")})`;const F=p>0;if(F!==U){U=F,h.style.display=F?"none":"";for(const $ of c)$.el.style.display=F?"":"none"}h.style.color=k.ink;const z=(1-Math.cos(2*Math.PI*Ss(p)))/2,Se=H&&parseFloat(getComputedStyle(H).fontSize)||0;for(let $=0;$<me;$++){const Oe=Cn(p,$,me),Ie=`translateX(${(-((1-Math.cos(2*Math.PI*Oe))/2*_o+z*So)*y*Se).toFixed(3)}px)`;F&&(c[$].lbl.style.color=k.ink,c[$].lbl.style.transform=Ie),m[$].el.style.clipPath=`inset(${N.e[$].toFixed(3)}px 0 ${(N.h-N.e[$+1]).toFixed(3)}px ${((1-Oe)*100).toFixed(2)}%)`,m[$].lbl.style.color=o.ink,m[$].lbl.style.transform=Ie}}let xe=0;function ie(){window.clearTimeout(xe),xe=window.setTimeout(Ve,ko)}function Ve(){if(V||i||u||P){V||ie();return}I(360,jt),ie()}async function Me(){if(u||V)return;u=!0,A==null||A.stop(),P=!1,y=1,t.classList.add("is-filling"),se();const C=Z?Math.max(0,R-performance.now()):null;C==null&&I(v*360,j);let k=!1;f=()=>{k=!0};const o=Sn(Math.max(0,(C??j)-jo));g=o;const E=await o.finished;if(!(k||V||!E))for(let F=b+1;!k&&!V;F++){p=0;const z=ot(0,1,wo,null,$=>{p=$,K()});if(g=z,!await z.finished||k||V)return;b=F,p=0,K();const Se=Sn(vo);if(g=Se,!await Se.finished||k||V)return}}async function be(){if(!u||V)return;u=!1,f==null||f(),g==null||g.stop();const C=ot(y,0,yn,_n,E=>{y=E,K()}),k=ot(p,0,yn,_n,E=>{p=E,K()});if(A=k,await Promise.all([k.finished,C.finished]),u||V)return;if(b<0){p=0,K(),t.classList.remove("is-filling"),ie();return}P=!0,p=1,K();const o=ot(1,0,yo,null,E=>{p=E,K()});A=o,await o.finished,!(u||V)&&(p=0,b=-1,P=!1,y=1,K(),t.classList.remove("is-filling"),ie())}function Pe(C){const k=t.getBoundingClientRect(),o=C.clientY<k.top+k.height/2?-1:1,E=ke();v=E!==null?E:o,j=_e(),ie(),Me()}function W(){be()}return window.addEventListener("pointermove",ue,{passive:!0}),window.addEventListener("resize",se),n&&!i&&(t.addEventListener("pointerenter",Pe),t.addEventListener("pointerleave",W),t.addEventListener("blur",W)),i||ie(),K(),()=>{V=!0,window.clearTimeout(xe),O==null||O.stop(),g==null||g.stop(),A==null||A.stop(),window.removeEventListener("pointermove",ue),window.removeEventListener("resize",se),t.removeEventListener("pointerenter",Pe),t.removeEventListener("pointerleave",W),t.removeEventListener("blur",W),t.classList.remove("is-filling"),t.replaceChildren(),H==null||H.classList.remove("is-3d")}}const Lo=({onClick:t,className:i})=>{const n=s.useRef(null);return s.useEffect(()=>{const r=n.current;if(r)return Ro(r)},[]),e.jsx("div",{className:i?`jn-stage ${i}`:"jn-stage",children:e.jsx("button",{ref:n,type:"button",className:"jn","aria-label":"Join Brik",onClick:t})})};function Mo({iframeRef:t,toolHtml:i}){const n=s.useRef(null);return s.useEffect(()=>{var r;t.current=((r=n.current)==null?void 0:r.getIframeRef())??null},[i,t]),{previewRef:n}}function Po(t,i){const[n,r]=s.useState(null);return s.useLayoutEffect(()=>{const a=t.current;if(!a||!i)return;let c;const m=()=>{const d=a.querySelector(".tool-stage"),x=a.querySelector(`[data-testid="${kr.topBar.root}"]`);if(!(d instanceof HTMLElement)||!(x instanceof HTMLElement))return;c.observe(d);const h=d.getBoundingClientRect(),_=x.getBoundingClientRect(),w=h.left+h.width/2-_.left;r(p=>p!=null&&Math.abs(p-w)<.5?p:w)};return c=new ResizeObserver(()=>{m()}),c.observe(a),m(),()=>c.disconnect()},[t,i]),i?n:null}const Nn="w-[176px]";function Oo(){var st;const t=Pn(),[i]=On(),n=i.get("slug"),r=i.get("id"),a=n&&n!=="undefined"?n:null,c=r&&r!=="undefined"?r:null,[m,d]=s.useState(!1),[x,h]=s.useState(null),[_,w]=s.useState("controls"),p=it(ss),y=it(ns),{user:b}=Yt(),{profile:P,setProfile:u,loading:v}=Kn(),{sendPageClicked:j}=An(),O=(b==null?void 0:b.role)==="admin",R=O||p,g=Dn(),{controlsOpen:A,setControlsOpen:f,controlsDrawerHeight:N,setControlsDrawerHeight:U,panelWidth:Z,setPanelWidth:V,timelineTrackKeys:H,handleTrackKeysChange:q,revealControlTarget:ue,handleRevealControl:ke,iframeReady:pe,setIframeReady:_e,controlsTouched:D,setControlsTouched:I,adminMobileView:se,toggleAdminMobileView:K}=hs(),[xe,ie]=s.useState(!1),[Ve,Me]=s.useState("canvas"),be=s.useRef(null),Pe=s.useRef(null);s.useLayoutEffect(()=>{if(!xe||!Pe.current)return;const S=_t.fromTo(Pe.current,{opacity:0,y:40,scale:.95},{opacity:1,y:0,scale:1,duration:.35,ease:"back.out(1.7)"});return()=>{S.kill()}},[xe,Ve]);const W=s.useRef(null),C=s.useRef(null),k=s.useRef(null);s.useEffect(()=>{window.scrollTo(0,0);const S=document.documentElement,L=document.body,Q={htmlOverflow:S.style.overflow,bodyOverflow:L.style.overflow,htmlScrollbarGutter:S.style.scrollbarGutter,bodyPosition:L.style.position,bodyTop:L.style.top,bodyLeft:L.style.left,bodyRight:L.style.right,bodyWidth:L.style.width};return S.style.overflow="hidden",L.style.overflow="hidden",S.style.scrollbarGutter="auto",g&&(L.style.position="fixed",L.style.top="0",L.style.left="0",L.style.right="0",L.style.width="100%"),()=>{S.style.overflow=Q.htmlOverflow,L.style.overflow=Q.bodyOverflow,S.style.scrollbarGutter=Q.htmlScrollbarGutter,L.style.position=Q.bodyPosition,L.style.top=Q.bodyTop,L.style.left=Q.bodyLeft,L.style.right=Q.bodyRight,L.style.width=Q.bodyWidth}},[g]);const{tool:o,isLoading:E,error:F,isAuthRequired:z,initialImplementation:Se,toolUuid:$,resolvedCode:Oe,resolvedImpl:re,resolvedSchema:Ie,creatorName:Ce,creatorHref:He,originalTool:l,originalCreatorName:Ne,originalCreatorHref:Ue,desktopRemixInfo:Ot,refetchToolData:At}=ys({slug:a,toolId:c});s.useEffect(()=>{b!=null&&b.id&&(o!=null&&o.id)&&is(b.id,o.id)},[b==null?void 0:b.id,o==null?void 0:o.id]);const{sendToolViewAction:J}=ps({toolId:o==null?void 0:o.id}),{sendAssetExported:Dt}=Zn({toolId:o==null?void 0:o.id,toolViewMode:"viewer"}),ge=o?`${(((st=o.description)==null?void 0:st.trim())||Fn(o)).slice(0,150)} · Made with Brik`:void 0;Bn("ToolViewer",{title:o?`${o.name} -- Brik`:void 0,description:ge,image:$n(o,Ye.appId),url:typeof window>"u"?void 0:`${window.location.origin}${window.location.pathname}${window.location.search}`}),os(Be(o)?Vn(o,window.location.origin,Ye.appId):null);const Ee=(o==null?void 0:o.name)||"tool",{recording:ae,recordingProgress:Te,handleStartRecording:we,stopRecording:Je,toolExports:G,handleDeleteExport:Ft,exportIndex:le,setExportIndex:X,galleryOpen:Ae,setGalleryOpen:Bt}=js({iframeRef:W,timelineDockRef:k,toolNameForExport:Ee,toolUuid:$,userId:b==null?void 0:b.id,isMobile:g,showDevModeFeatures:R,sendAssetExported:Dt,setShowExport:d,setExportedFile:h}),[ve,he]=s.useState(void 0);s.useEffect(()=>{he(void 0)},[re==null?void 0:re.uuid]);const{openAuthModal:ce,registerOAuthRedirectProvider:dt}=In(),{toolHtml:Qe,toolData:B,iframeSrc:Re,mountViewerTimelineDock:de,publishedTimeline:De,viewerPresets:Fe,initialDockTimeline:$t,viewerPresetController:ut}=vs({tool:o,resolvedCode:Oe,resolvedImpl:re,resolvedSchema:Ie,initialImplementation:Se,creatorName:Ce,isMobile:g,useNewControl
6sPanel:!0,animationTimelineEnabled:y,chromeVariant:"v2",setIframeReady:_e,iframeRef:W,timelineDockRef:k}),{previewRef:pt}=Mo({iframeRef:W,toolHtml:Qe}),[ze,xt]=s.useState(!1);s.useEffect(()=>{xt(!1)},[o==null?void 0:o.id]),gs({tool:o,toolUuid:$,navigate:t,sendToolViewAction:J,setPanelWidth:V,setControlsTouched:I,setIframeReady:_e,iframeRef:W,iframeReady:pe,originalTool:l,originalCreatorName:Ne,onToggleControlsPanelCollapsed:()=>xt(S=>!S)}),s.useEffect(()=>{I(!1)},[Re,I]),s.useEffect(()=>{V(320)},[a,c,o==null?void 0:o.id,V]),rs(),s.useEffect(()=>{if(!(!g||!Re))return Me("canvas"),ie(!0),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>ie(!1),5e3),()=>{be.current&&clearTimeout(be.current)}},[g,Re]);const{openExportAuthWall:ht}=fs({tool:o,iframeRef:W,iframeReady:pe,openAuthModal:ce,registerOAuthRedirectProvider:dt,setShowExport:d,setControlsTouched:I,user:b,profileLoading:v}),{isSaved:ee,showSavedPopup:ne,handleToggleSave:Ze}=ks({tool:o,user:b,profile:P,setProfile:u,openAuthModal:ce,onWillSave:()=>ie(!1)}),mt=s.useRef(null);s.useEffect(()=>{var S;ne&&((S=mt.current)==null||S.dismiss(),mt.current=fe.success("Saved to your collection",{icon:e.jsx(Wt,{className:"h-4 w-4 fill-current","aria-hidden":!0})}))},[ne]);const{showShareModal:Ge,setShowShareModal:ft,handleShare:ye}=xs(o??void 0),et=A||m||Ge,bt=s.useRef(null),[Vt,tt]=s.useState(0);s.useEffect(()=>{const S=bt.current;if(!S){tt(0);return}const L=new ResizeObserver(()=>tt(S.offsetHeight));return L.observe(S),tt(S.offsetHeight),()=>L.disconnect()},[g,o]);const{remixing:Ke,handleRemix:We}=ws({tool:o,user:b,navigate:t,openAuthModal:ce,sendToolViewAction:J}),nt=bs({animationTimelineEnabled:y,liveTimeline:ve,publishedTimeline:De}),It=Po(C,R&&!g&&!!o&&!F&&!z);if(z)return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center px-4",style:{background:"var(--product-grey-01)"},children:[e.jsx("h2",{className:"text-lg font-medium text-[#1a1a1a] mb-1 tracking-[-0.24px]",children:"Private Tool"}),e.jsx("p",{className:"text-sm text-[#7d7d7d] mb-4",children:"Login to view this tool."}),e.jsx("button",{onClick:()=>{j({button_name:"tool_viewer_login"}),ce(At,"tool_viewer_login")},className:"flex h-[36px] items-center justify-center rounded-[10px] bg-black px-[15px] text-[12px] font-medium tracking-[-0.24px] text-white transition-opacity hover:opacity-90",children:"Login"})]});if(F||!E&&!o)return e.jsx(Hn,{});const qe=!g&&!!B;return e.jsxs(ts,{children:[o&&e.jsxs("div",{className:Y(!g&&"flex h-[100dvh] overflow-hidden"),children:[!g&&e.jsx(_r,{markFill:"var(--product-black-00)"}),e.jsxs("div",{ref:C,className:Y("flex flex-col flex-1 min-w-0",g&&"h-[100dvh] overflow-hidden transition-[padding] duration-300 ease-out",!g&&(qe?"h-[100dvh] overflow-hidden":"min-h-[100dvh]")),style:{background:"var(--product-grey-01)",paddingBottom:g&&A?Math.max(0,N-Vt):void 0},children:[g?e.jsx("div",{className:Y("shrink-0 transition-opacity",ae&&"pointer-events-none opacity-50"),"aria-hidden":ae||void 0,style:{paddingTop:"env(safe-area-inset-top, 0px)"},children:e.jsx(Sr,{chromeVariant:"v2",surface:"viewer",toolName:o.name,thumbnailUrl:cn(o)??null,showCreator:!0,creatorName:Ce??void 0,creatorHref:He??void 0,lineage:l?e.jsxs("span",{"data-testid":Xe.viewerTopBar.lineage,className:"flex items-center gap-[3px] truncate text-[10px] tracking-[-0.2px] text-[var(--product-grey-05)]",children:[e.jsx(at,{size:8,className:"mr-[3px]"}),e.jsx("span",{children:"Remixed:"}),Be(l)?e.jsx(Le,{to:$e({id:l.id,slug:l.slug??void 0}),className:"hover:underline",children:l.name}):e.jsx("span",{children:l.name}),Ne&&Ue&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"by"}),e.jsx(Le,{to:Ue,className:"hover:underline",children:Ne})]})]}):null,publishLabel:Ke?"Cloning...":"Remix",isBookmarked:ee,onToggleBookmark:()=>{J("Save"),Ze()},onShare:()=>{J("Share"),ye()},onPublish:We,onExport:()=>{if(J("Export"),!b){ht("tool_viewer_mobile_topbar");return}d(!0)},endSlot:b?null:e.jsx(go,{onClick:()=>{j({button_name:"tool_viewer_join"}),qt(),ce(void 0,"tool_viewer_join",window.location.href)}})})}):e.jsx(Cr,{toolName:o.name,nameSuffix:Ce?e.jsxs(e.Fragment,{children:["by"," ",He?e.jsx(Le,{to:He,className:"hover:underline",children:Ce}):Ce]}):null,center:R?e.jsx("button",{type:"button",onClick:()=>{J("Edit"),t(`/tooleditor/${o.id}`)},className:"flex h-[40px] shrink-0 items-center gap-[8px] rounded-[10px] border border-solid border-[#e1e1e1] bg-amber-600 px-[15px] text-[12px] font-medium tracking-[-0.24px] text-white whitespace-nowrap transition-opacity hover:opacity-80",children:"Edit (Admin)"}):null,centerX:It,secondLine:l?e.jsxs("span",{className:"inline-flex items-center gap-[3px]",children:[e.jsx(at,{size:8}),e.jsx("span",{children:"Remixed:"}
6),Be(l)?e.jsx(Le,{to:$e({id:l.id,slug:l.slug??void 0}),className:"hover:underline",children:l.name}):e.jsx("span",{children:l.name}),Ne&&Ue&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"by"}),e.jsx(Le,{to:Ue,className:"hover:underline",children:Ne})]})]}):"",actions:e.jsxs("div",{className:"flex h-full items-center",children:[!b&&e.jsx(Lo,{className:"-mr-px -translate-y-px self-start",onClick:()=>{j({button_name:"tool_viewer_join"}),qt(),ce(void 0,"tool_viewer_join",window.location.href)}}),e.jsx(mo,{open:Ge,onOpenChange:S=>{S?(J("Share"),ye()):ft(!1)},toolName:Ee,toolSlug:(o==null?void 0:o.slug)??a,toolId:(o==null?void 0:o.id)??c}),e.jsx(Gn,{size:"big",skin:ee?"standard":"ghost",priority:"primary","aria-label":ee?"Unsave":"Save",onClick:()=>{J("Save"),Ze()},className:"border-l border-[var(--product-grey-02)]",glyphClassName:"size-[18px]",icon:e.jsx(Zr,{className:"size-full shrink-0"})}),b?e.jsx(Nr,{}):null,e.jsxs(dn,{size:"big",skin:"standard",priority:"secondary",onClick:We,disabled:Ke,className:Y(Nn,"border-y-0 border-[var(--product-grey-02)]",b&&"border-l-0","disabled:border-y-0",b&&"disabled:border-l-0"),children:[e.jsx(Kr,{className:"size-[20px] shrink-0"}),e.jsx("span",{children:Ke?"Cloning...":"Remix"})]}),e.jsxs(dn,{size:"big",skin:"standard",priority:"primary",onClick:()=>{if(J("Export"),j({button_name:"tool_viewer_export"}),!b){ht("tool_viewer_topbar");return}d(!0)},className:Nn,children:[e.jsx(Er,{className:"size-[20px] shrink-0"}),e.jsx("span",{children:"Export"})]})]})}),e.jsxs("div",{className:Y("flex min-h-0",g?"flex-col":"flex-row",Ae&&G.length>0?"hidden":"flex-1"),children:[e.jsx("div",{className:"flex flex-col min-h-0 flex-1 min-w-0",children:e.jsx(Wn,{initialConfig:{},children:e.jsx("div",{className:"tool-stage flex-1 flex flex-col min-h-0 relative overflow-hidden",style:{border:"none",borderRadius:0,background:"transparent"},children:Qe?e.jsx(e.Fragment,{children:e.jsx("div",{className:"relative flex-1 min-h-0 w-full overflow-hidden transition-colors duration-150 ease-out",children:e.jsxs("div",{className:"contents",children:[e.jsxs("div",{className:"relative h-full min-h-0 flex flex-col overflow-hidden",children:[e.jsx(Tr,{ref:pt,toolHtml:Qe,toolName:o.name,isAdmin:O,toolLoaded:pe,chatCollapsed:!0,newDesignLayout:!0}),g&&ae&&e.jsxs("div",{className:"absolute top-[10px] right-[10px] z-10 flex items-center gap-[6px] pointer-events-none","aria-live":"polite",children:[e.jsx("span",{className:"w-[7px] h-[7px] rounded-full bg-[#FF3B30] animate-pulse shadow-[0_0_8px_rgba(255,59,48,0.6)]"}),e.jsxs("span",{className:"text-[11px] font-semibold tracking-[-0.22px] text-[#7d7d7d]",children:["REC IN PROGRESS",Te.duration?` ${Math.max(0,Math.ceil(Te.duration-Te.elapsed))}s`:""]})]})]}),!g&&ae?e.jsx(qn,{elapsed:Te.elapsed,duration:Te.duration,onStop:Je}):null,de&&B?e.jsx(Xn,{ref:k,chromeVariant:"v2",forceExpandedOnArrival:!0,controlsSchema:B.controlsSchema,iframeRef:W,toolLoadKey:Re,chatCollapsed:!0,draftImplId:null,initialTimeline:$t,controlsPanelWidth:qe?0:Z,onTimelineChange:he,onTrackKeysChange:q,onRevealControl:ke,playbackLocked:ae}):null]})})}):e.jsx("div",{className:"flex-1"})})})}),!g&&qe&&B?e.jsx(Ct,{mode:"desktop",chromeVariant:"v2",controlsSchema:B.controlsSchema,iframeRef:W,toolLoadKey:Re,toolId:(o==null?void 0:o.id)??null,open:!0,toolName:o.name,creatorName:Ce??void 0,creatorHref:He??void 0,remix:Ot,presetController:ut,timelineActive:de&&H.active,trackedControlKeys:H.tracked,onToggleTrack:S=>{var L;return(L=k.current)==null?void 0:L.addOrRevealTrack(S)},revealControl:ue,onPresetBiAction:J,collapsed:ze}):null]}),R&&G.length>0&&e.jsxs("div",{className:`mx-[20px] mb-[20px] ${Ae?"flex-1 flex flex-col min-h-0":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>Bt(S=>!S),className:"flex items-center gap-2 px-4 py-2 bg-white border border-[#e1e1e1] rounded-[8px] text-[12px] font-medium text-black hover:bg-[#f5f5f5] transition-colors",children:[e.jsx(Un,{className:"w-3.5 h-3.5"}),Ae?"Hide Gallery":`Show Gallery (${G.length})`]}),Ae&&e.jsx("div",{className:`mt-3 flex-1 overflow-y-auto grid gap-2 ${G.length===1?"grid-cols-1":G.length<=4?"grid-cols-2":"grid-cols-3"}`,children:G.map((S,L)=>e.jsxs("div",{className:"relative group/export aspect-video rounded-[8px] overflow-hidden cursor-pointer bg-[#111] border border-[#222] hover:border-[#444] transition-colors",onClick:()=>X(L),children:[S.export_kind==="video"?e.jsx(St,{fallbackUrl:S.file_url,streamFormat:S.stream_format,streamUrl:S.stream_url,muted:!0,className:"absolute inset-0 w-full h-full object-cover"}):e.jsx("img",{src:S.file_url,alt:"",className:"absolute inset-0 w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:Q=>{Q.stopPropagation(),Ft(S.id)},className:"absolute top-2 right-2 opacity-0 group-hover/export:opacity-100 transition-opacity flex items-center gap-1 px-2 py-1 rounded-[4px] bg-black/60 text-white text-[10px] hover:bg-red-600/80",children:e.jsx(ls,{className:"w-3 h-3"})})]},S.id))})]}),g&&o&&!(Ae&&G.length>0)&&e.jsxs("div",{ref:bt,className:`min-[1200px]:hidden shrink-0 transition-[opacity,transform] ease-out motion-reduce:transition-none ${et?"pointer-events-none translate-y-[8px] opacity-0 duration-0":"translate-y-0 opacity-100 delay-300 duration-200"}`,"aria-hidden":et||void 0,children:[e.jsx(Nt,{chromeVariant:"v2"}),y&&Lt(re==null?void 0:re.timeline)&&e.jsx(Nt,{chromeVariant:"v2",message:"This tool contains a timeline animation. Switch to desktop."}),e.jsx(Rr,{chromeVariant:"v2",onChat:()=>{},onControls:()=>{},cells:[{label:"Controls",testId:Xe.viewerBottomBar.controls,onClick:()=>{J("Edit"),w("controls"),f(!0)}},...Fe.length>0?[{label:"Presets",testId:Xe.viewerBottomBar.presets,onClick:()=>{J("Presets"),w("presets"),f(!0)}}]:[]]})]}),R&&G[le]&&e.jsx(Zs,{open:le>=0,onOpenChange:S=>{S||X(-1)},children:e.jsxs(er,{children:[e.jsx(tr,{className:"fixed inset-0 z-50 bg-black/90"}),e.jsxs(nr,{"aria-describedby":void 0,className:"fixed inset-0 z-50 flex items-center justify-center focus:outline-none",onClick:()=>X(-1),children:[e.jsx(sr,{className:"sr-only",children:`Export ${le+1} of ${G.length}`}),e.jsx(rr,{className:"absolute top-4 right-4 flex items-center justify-center w-8 h-8 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors","aria-label":"Close",children:e.jsx(Rt,{className:"w-4 h-4"})}),G.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),X(L=>L<=0?G.length-1:L-1)},className:"absolute left-4 top-1/2 -translate-y-1/2 flex items-center justify-center w-10 h-10 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors",children:e.jsx(Kt,{className:"w-5 h-5"})}),e.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),X(L=>L>=G.length-1?0:L+1)},className:"absolute right-4 top-1/2 -translate-y-1/2 flex items-center justify-center w-10 h-10 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors",children:e.jsx(cs,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"max-w-[90vw] max-h-[85vh] flex items-center justify-center",onClick:S=>S.stopPropagation(),children:G[le].export_kind==="video"?e.jsx(St,{fallbackUrl:G[le].file_url,streamFormat:G[le].stream_format,streamUrl:G[le].stream_url,controls:!0,autoPlay:!0,loop:!0,muted:!0,className:"max-w-full max-h-[85vh] rounded-[8px]"}):e.jsx("img",{src:G[le].file_url,alt:`Export ${le+1}`,className:"max-w-full max-h-[85vh] rounded-[8px] object-contain"})}),G.length>1&&e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white/50 text-[12px] tabular-nums",children:[le+1," / ",G.length]})]})]})}),g&&B&&e.jsx(Ct,{mode:"mobile",chromeVariant:"v2",controlsSchema:B.controlsSchema,iframeRef:W,toolLoadKey:Re,toolId:(o==null?void 0:o.id)??null,open:A,onClose:()=>f(!1),onHeightChange:U,presetController:ut,view:_,onPresetBiAction:J,headerSlot:e.jsxs(e.Fragment,{children:[R&&e.jsxs("button",{type:"button",onClick:K,title:se?"Switch to user view":"Switch to admin view","aria-pressed":se,className:Y("shrink-0 flex items-center gap-[5px] h-[28px] px-[10px] rounded-[8px] text-[11px] font-medium tracking-[-0.22px] transition-colors",se?"bg-amber-600 text-white":"bg-[#E8E8E8] text-[#555]"),children:[e.jsx(ds,{className:"w-3 h-3 shrink-0"}),se?"Admin view":"User view"]}),D&&e.jsx("button",{type:"button","data-testid":Xe.controlsDrawer.resetAll,onClick:()=>{j({button_name:"tool_viewer_mobile_reset"}),ct(W,zn),I(!1)},className:"shrink-0 flex items-center gap-[4px] h-[28px] px-[10px] rounded-[8px] text-[12px] font-medium text-[#666] tracking-[-0.24px] hover:bg-black/5 transition-colors",children:"Reset"})]})}),e.jsx(es,{chromeVariant:"v2",open:m,onClose:()=>d(!1),iframeRef:W,toolName:Ee,toolData:B??void 0,toolUuid:$,isAdmin:R,isOwner:!g&&!!(b!=null&&b.id)&&!!o&&b.id===o.user_id,modalOrigin:g?"tool_viewer_mobile_topbar":"tool_viewer_canvas_toolbar",onStartRecording:S=>{we(S),g&&d(!1)},recording:ae,toolViewMode:"viewer",timeline:nt,onImageReady:(S,L)=>{if(g){d(!1);return}const Q=`image/${L}`,gt=Ee.toLowerCase().replace(/[^a-z0-9]/g,"-").replace(/-+/g,"-"),wt=new Date().toISOString().slice(0,10);fetch(S).then(je=>je.blob()).then(je=>{d(!1),h(new File([je],`${gt}-${wt}.${L}`,{type:Q}))}).catch(()=>{d(!1)})}}),!g&&e.jsx(Yn,{file:x,toolName:Ee,toolSlug:(o==null?void 0:o.slug)??a,onClose:()=>h(null),chromeVariant:"v2"}),g&&e.jsx(Jn,{open:Ge,chromeVariant:"v2",allowNativeShare:!0,autoDismissMs:3e4,toolName:Ee,toolSlug:(o==null?void 0:o.slug)??a,toolId:(o==null?void 0:o.id)??c,coverUrl:cn(o),onClose:()=>ft(!1)})]})]}),e.jsx(Qn,{position:"fixed",chromeVariant:"v2",background:"var(--product-grey-01)",visible:E||!pe})]})}function Ao(){return e.jsx("div",{"data-testid":to.switch.loading,className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"w-6 h-6 border-2 border-[#333] border-t-[#888] rounded-full animate-spin"})})}function wa(){const t=or();return t===void 0?e.jsx(Ao,{}):t?e.jsx(ir.Provider,{value:ar,children:e.jsx(Oo,{})}):e.jsx(xo,{})}export{wa as default};
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.