@blinkk/root-cms 3.1.2 → 3.1.3
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/dist/app.js +1 -1
- package/dist/{chunk-X5CNR4CK.js → chunk-4G7S2LJH.js} +2 -2
- package/dist/plugin.js +1 -1
- package/dist/ui/{AIPage-2N5UYBRX.js → AIPage-VOTAEVJE.js} +1 -1
- package/dist/ui/AssetsPage-EWGRMRPJ.js +1 -0
- package/dist/ui/{CollectionPage-D7IG6526.js → CollectionPage-N5JIAUDS.js} +1 -1
- package/dist/ui/{ComparePage-726NIJW5.js → ComparePage-JDPVU2VA.js} +1 -1
- package/dist/ui/{DataPage-YMSQCIVK.js → DataPage-37D4CMLZ.js} +1 -1
- package/dist/ui/{DataSourcePage-7VPFUG3K.js → DataSourcePage-LX5ASYQN.js} +1 -1
- package/dist/ui/{DocTranslationsPage-FO7O76VK.js → DocTranslationsPage-V5M4KB7X.js} +1 -1
- package/dist/ui/DocumentPage-SURTQJPG.js +1 -0
- package/dist/ui/{EditDataSourcePage-Y7YK6IWT.js → EditDataSourcePage-O7DOV5LX.js} +1 -1
- package/dist/ui/{EditReleasePage-XZ4RHHRT.js → EditReleasePage-NDYTKGXY.js} +1 -1
- package/dist/ui/EmbeddedDocumentPage-SLEULNNI.js +1 -0
- package/dist/ui/LogsPage-ZGBP3I35.js +1 -0
- package/dist/ui/{NewDataSourcePage-YUPRHL7F.js → NewDataSourcePage-GQONTMP4.js} +1 -1
- package/dist/ui/{NewReleasePage-6HHLYOQP.js → NewReleasePage-7ZKXHDTD.js} +1 -1
- package/dist/ui/{NotFoundPage-A6OCYREA.js → NotFoundPage-WXEZQZK6.js} +1 -1
- package/dist/ui/ProjectPage-F7W7X6YO.js +1 -0
- package/dist/ui/{ReleasePage-V2JMPWX7.js → ReleasePage-ZKMNYPML.js} +1 -1
- package/dist/ui/{ReleasesPage-SCR4SVKN.js → ReleasesPage-JHCE6AEJ.js} +1 -1
- package/dist/ui/{SettingsPage-5XKHPG6K.js → SettingsPage-MWCPZPGE.js} +1 -1
- package/dist/ui/{SidebarToolsPage-VXVRZ2C3.js → SidebarToolsPage-API53RRR.js} +1 -1
- package/dist/ui/TaskPage-73NLAR4J.js +1 -0
- package/dist/ui/{TasksPage-DIXUWYXM.js → TasksPage-IKPW2OQO.js} +1 -1
- package/dist/ui/{TranslationsArbPage-QPD3ZBT4.js → TranslationsArbPage-QVN66DIW.js} +1 -1
- package/dist/ui/{TranslationsEditPage-475Z7UPC.js → TranslationsEditPage-ZOELF5PK.js} +1 -1
- package/dist/ui/{TranslationsPage-674JU6L4.js → TranslationsPage-NGGZB4L6.js} +1 -1
- package/dist/ui/{chunk-JBHRZ4EX.js → chunk-BOER3EAW.js} +1 -1
- package/dist/ui/{chunk-RHAJNURN.js → chunk-BT2NTAW2.js} +1 -1
- package/dist/ui/chunk-C2BLMTPR.js +3 -0
- package/dist/ui/{chunk-XWX2622O.js → chunk-DIFPCF7I.js} +1 -1
- package/dist/ui/{chunk-PTPYMVFW.js → chunk-DS27MO63.js} +1 -1
- package/dist/ui/{chunk-WMICEDOT.js → chunk-FXIR2RBE.js} +1 -1
- package/dist/ui/chunk-G5ZZDHWA.js +1 -0
- package/dist/ui/{chunk-2S5HMST6.js → chunk-IOR72US3.js} +1 -1
- package/dist/ui/{chunk-SKQECSUR.js → chunk-NSI5JSVV.js} +1 -1
- package/dist/ui/{chunk-YXSXWFLZ.js → chunk-PPYM4O5N.js} +1 -1
- package/dist/ui/{chunk-Q7IU4QCY.js → chunk-T77VOWHP.js} +1 -1
- package/dist/ui/chunk-UPDL6UXI.js +1 -0
- package/dist/ui/{chunk-SENZVSVZ.js → chunk-VPHBKJ3I.js} +1 -1
- package/dist/ui/{chunk-VJUMFJIX.js → chunk-WYJJZTCI.js} +1 -1
- package/dist/ui/{chunk-4ALFT4ES.js → chunk-Y3MCFLQU.js} +56 -56
- package/dist/ui/chunk-YUU6LWQK.js +1 -0
- package/dist/ui/{chunk-AGFPVTBA.js → chunk-Z6DBYLIM.js} +1 -1
- package/dist/ui/ui.css +1 -1
- package/dist/ui/ui.js +1 -1
- package/package.json +3 -3
- package/dist/ui/AssetsPage-KLGNE6D6.js +0 -1
- package/dist/ui/DocumentPage-M7SJ4ITQ.js +0 -1
- package/dist/ui/EmbeddedDocumentPage-4TLMCDSO.js +0 -1
- package/dist/ui/LogsPage-IGDDZGEI.js +0 -1
- package/dist/ui/ProjectPage-UHRXNN7O.js +0 -1
- package/dist/ui/TaskPage-LDPRN3G6.js +0 -1
- package/dist/ui/chunk-NWHGT476.js +0 -1
- package/dist/ui/chunk-XMESZUC5.js +0 -1
- package/dist/ui/chunk-YMBBWVBB.js +0 -3
- /package/dist/ui/{chunk-4ALFT4ES.js.LEGAL.txt → chunk-Y3MCFLQU.js.LEGAL.txt} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as Be,j as Ae,k as Oe,l as q,n as Ve,o as Ue,p as We,q as $e,s as Fe}from"./chunk-4ALFT4ES.js";import"./chunk-WFQU7V3W.js";import"./chunk-XWX2622O.js";import"./chunk-SKQECSUR.js";import"./chunk-VJUMFJIX.js";import"./chunk-JBHRZ4EX.js";import"./chunk-3E6CASIN.js";import"./chunk-FBSBL476.js";import{a as je}from"./chunk-2RAVKX2Z.js";import"./chunk-HO3W4RVG.js";import"./chunk-2EPQJUGM.js";import{c as Ne}from"./chunk-NJMNOITA.js";import"./chunk-344GZOGG.js";import{b as qe}from"./chunk-W6LP22IK.js";import"./chunk-XMESZUC5.js";import"./chunk-ENQKSLGJ.js";import"./chunk-CAY5NM4Z.js";import"./chunk-MSYTAJBV.js";import"./chunk-Q7IU4QCY.js";import{b as Le,c as ae,g as ze}from"./chunk-YXSXWFLZ.js";import"./chunk-JTIQBW33.js";import"./chunk-PTPYMVFW.js";import"./chunk-2S5HMST6.js";import{a as R}from"./chunk-FJLNXXE3.js";import{a as se}from"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import{b as Te}from"./chunk-W5DOO6ID.js";import{a as Re}from"./chunk-NSOTG64N.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as Xe}from"./chunk-P2Z66DHV.js";import{b as He}from"./chunk-WMICEDOT.js";import{a as Me}from"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{e as I}from"./chunk-BUNR5EU3.js";import{Cc as Ie,Fa as T,Ga as e,Ia as pe,Oa as ge,P as me,Qa as oe,Sa as fe,Ua as ve,W as N,Wb as De,Xb as Ce,Xc as Ee,Yc as ne,Za as Pe,a as y,ba as he,c as b,da as X,e as P,g as B,h as C,j as te,pb as we,qb as xe,rb as be,rc as Se,sb as ke,vc as ye,za as _e}from"./chunk-LROR6N3B.js";import{d as O,j as ue,k as ot}from"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";te();te();async function Ke(t,n){let a=await(await fetch("/cms/api/check.test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({check:t,docId:n})})).json();if(!a.success)throw new Error(a.error||"Check failed.");return a.data}function Je(t){let n=window.__ROOT_CTX.checks||[],o=t.docId.split("/")[0],a=n.filter(s=>!s.collections||s.collections.includes(o)),[i,r]=y({}),c=C(async s=>{r(m=>({...m,[s]:{loading:!0}}));try{let m=await Ke(s,t.docId);r(h=>({...h,[s]:{loading:!1,result:m}}))}catch(m){r(h=>({...h,[s]:{loading:!1,error:m.message||"Unknown error."}}))}},[t.docId]),l=C(async()=>{let s={};for(let m of a)s[m.id]={loading:!0};r(s);for(let m of a)try{let h=await Ke(m.id,t.docId);r(_=>({..._,[m.id]:{loading:!1,result:h}}))}catch(h){r(_=>({..._,[m.id]:{loading:!1,error:h.message||"Unknown error."}}))}},[t.docId,a]);return e("div",{className:"ChecksPanel",children:[e("div",{className:"ChecksPanel__header",children:[e("div",{className:"ChecksPanel__header__title",children:"Checks"}),e(X,{variant:"default",size:"xs",compact:!0,leftIcon:e(Se,{size:12}),onClick:l,children:"Run All"})]}),e("div",{className:"ChecksPanel__body",children:e("div",{className:"ChecksPanel__checks",children:a.map(s=>{let m=i[s.id];return e(nt,{check:s,state:m,onRun:()=>c(s.id)},s.id)})})})]})}function nt(t){let{check:n,state:o,onRun:a}=t;return e("div",{className:"ChecksPanel__check",children:[e("div",{className:"ChecksPanel__check__header",children:[e("div",{className:"ChecksPanel__check__label",children:[n.label,o?.result&&e(rt,{status:o.result.status})]}),e(X,{className:"ChecksPanel__check__runButton",variant:"default",size:"xs",compact:!0,loading:o?.loading,onClick:a,children:"Run"})]}),n.description&&e("div",{className:"ChecksPanel__check__description",children:n.description}),o?.result&&e("div",{className:I("ChecksPanel__check__result",`ChecksPanel__check__result--${o.result.status}`),children:e(Ne,{code:o.result.message})}),o?.error&&e("div",{className:"ChecksPanel__check__error",children:o.error})]})}var at={success:"green",warning:"yellow",error:"red"},it={success:Pe,warning:pe,error:ne};function rt(t){let n=at[t.status],o=it[t.status],a=t.status.charAt(0).toUpperCase()+t.status.slice(1);return e(he,{className:"ChecksPanel__statusBadge",color:n,size:"sm",variant:"filled",leftSection:e(o,{size:10}),children:a})}function Ye(t){let{device:n,expandVertically:o,iframeUrl:a,localeOptions:i,selectedLocale:r,onToggleDevice:c,onToggleExpandVertically:l,onReloadClick:s,onOpenNewTab:m,onLocaleChange:h}=t;return e("div",{className:"DocumentPagePreviewBar",children:[e("div",{className:"DocumentPagePreviewBar__devices",children:[e(T,{label:"Mobile",children:e(N,{className:I("DocumentPagePreviewBar__device",n==="mobile"&&"active"),onClick:()=>c("mobile"),children:e(ke,{size:16})})}),e(T,{label:"Tablet",children:e(N,{className:I("DocumentPagePreviewBar__device",n==="tablet"&&"active"),onClick:()=>c("tablet"),children:e(be,{size:16})})}),e(T,{label:"Desktop",children:e(N,{className:I("DocumentPagePreviewBar__device",n==="desktop"&&"active"),onClick:()=>c("desktop"),children:e(we,{size:16})})}),e(T,{label:"Expand",children:e(N,{className:I("DocumentPagePreviewBar__device",o&&"active"),"aria-pressed":o,disabled:n==="",onClick:l,children:e(fe,{size:16})})})]}),e("div",{className:"DocumentPagePreviewBar__navbar",children:e("div",{className:"DocumentPagePreviewBar__navbar__url",children:a})}),e("div",{className:"DocumentPagePreviewBar__locales",children:e(_e,{data:i,placeholder:"Locale",radius:"xl",size:"xs",required:!0,icon:e(Ee,{size:16,strokeWidth:1.5}),value:r,onChange:_=>{h(_)}})}),e("div",{className:"DocumentPagePreviewBar__buttons",children:[e(T,{label:"Reload",children:e(N,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--reload",onClick:s,children:e(ye,{size:16})})}),e(T,{label:"Open new tab",children:e(N,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--openNewTab",onClick:m,children:e(oe,{size:16})})})]})]})}te();function Qe(t){let n=t.docId.split("/")[0],o=ze(n),a=q(),i=P(null),[r,c]=y(""),[l,s]=y([]),[m,h]=y(!1),_=P("");_.current=r;let v=P(o.schema?.fields||[]);v.current=o.schema?.fields||[];let D=P(o.schema?.types||{});D.current=o.schema?.types||{};let x=B(()=>Ae(u=>{let k=u.trim();if(!k){s([]),h(!1);return}let S=a.controller?.getData()?.fields||{},L=$e(k,S,v.current,D.current);s(L),h(!0)},150),[a.controller]);b(()=>{x(r)},[r,x]),Ve(()=>{_.current.trim()&&x(_.current)}),b(()=>{t.autoFocus&&requestAnimationFrame(()=>{i.current?.focus(),i.current?.select()})},[t.autoFocus]),b(()=>{let u=()=>{i.current?.focus(),i.current?.select()};return window.addEventListener("root:focus-search",u),()=>window.removeEventListener("root:focus-search",u)},[]);let g=u=>{lt(u)};return e("div",{className:"SearchPanel",children:[e("div",{className:"SearchPanel__header",children:[e("div",{className:"SearchPanel__header__title",children:"Search"}),t.onClose&&e(N,{size:"xs",onClick:t.onClose,title:"Close search",children:e(ne,{size:14})})]}),e("div",{className:"SearchPanel__searchInput",children:[e("span",{className:"SearchPanel__searchInput__icon",children:e(Ie,{size:14})}),e("input",{ref:i,type:"text",className:"SearchPanel__searchInput__input",value:r,onInput:u=>c(u.currentTarget.value),onKeyDown:u=>{u.key==="Escape"&&t.onClose&&(u.preventDefault(),t.onClose())},placeholder:"Search field values\u2026",autoComplete:"off",spellcheck:!1})]}),e("div",{className:"SearchPanel__body",children:[!m&&!r.trim()&&e("div",{className:"SearchPanel__empty",children:"Type a query above to search field values in this document."}),m&&l.length===0&&e("div",{className:"SearchPanel__empty",children:["No matches for ",e("strong",{children:r}),"."]}),l.length>0&&e(O,{children:[e("div",{className:"SearchPanel__resultsCount",children:[l.length," ",l.length===1?"match":"matches"]}),e("ul",{className:"SearchPanel__results",children:l.map((u,k)=>e(ct,{result:u,onClick:()=>g(u)},`${u.deepKey}:${k}`))})]})]})]})}function ct(t){let{result:n}=t;return e("li",{className:"SearchPanel__result",children:e("button",{type:"button",className:"SearchPanel__result__button",onClick:t.onClick,children:[e("div",{className:"SearchPanel__result__label",children:n.label}),e("div",{className:"SearchPanel__result__snippet",children:st(n.snippet,n.matches)}),e("div",{className:"SearchPanel__result__meta",children:[e("span",{className:"SearchPanel__result__type",children:n.fieldType}),n.richTextBlock&&e("span",{className:"SearchPanel__result__badge",children:"in block"}),n.richTextInline&&e("span",{className:"SearchPanel__result__badge",children:"inline"})]})]})})}function st(t,n){if(!n||n.length===0)return t;let o=[],a=0;for(let i of n)i.start>a&&o.push({text:t.slice(a,i.start),match:!1}),o.push({text:t.slice(i.start,i.end),match:!0}),a=i.end;return a<t.length&&o.push({text:t.slice(a),match:!1}),o.map((i,r)=>i.match?e("mark",{children:i.text},r):e("span",{children:i.text},r))}function lt(t){if(window.postMessage({scrollToDeeplink:{deepKey:t.deepKey}},"*"),t.richTextBlock){let n=t.richTextBlock;setTimeout(()=>{window.dispatchEvent(new CustomEvent(Ue,{detail:n}))},350)}else if(t.richTextInline){let n=t.richTextInline;setTimeout(()=>{window.dispatchEvent(new CustomEvent(We,{detail:n}))},350)}}ot();te();var dt=ue(null);function K(t){let{className:n,localStorageId:o,children:a}=t,[i,r]=R(`root::SplitPanel:${o}`,350),[c,l]=y(!1),[s,m]=y(0),h=B(()=>new Set,[]),_=P(null),v=P(null),D={onResize:g=>(h.add(g),()=>{h.delete(g)})};if(b(()=>{let g=()=>l(!1);window.addEventListener("mouseup",g);let u=_.current;return u&&m(u.getBoundingClientRect().left),()=>window.removeEventListener("mouseup",g)},[]),b(()=>{let g=u=>{let k=u.clientX-s;r(k),h.forEach(S=>S())};return c&&window.addEventListener("mousemove",g),()=>window.removeEventListener("mousemove",g)},[c]),a?.length!==2)throw new Error("SplitPanel should have two <SplitPanel.Item> children.");let x={"--panel-size":`${i}px`};return e(dt.Provider,{value:D,children:e("div",{className:I(n,"SplitPanel",c&&"dragging"),ref:_,style:x,children:[a[0],e("div",{className:"SplitPanel__divider",ref:v,onMouseDown:()=>l(!0)}),a[1]]})})}K.Item=t=>e("div",{className:I("SplitPanel__item",t.className,t.fluid?"fluid":"static"),children:t.children});function le(t,n,o=""){let a=ae({collectionId:t,slug:n}),i=new URLSearchParams(window.location.search);i.set("preview","true"),i.delete("locale"),i.delete("modal");let r=`${i.toString()}${window.location.hash}`;return o?`${ae({collectionId:t,slug:n,locale:o})}?${r}`:`${a}?${r}`}function ut(t,n){let o=new URL(n,window.location.origin);try{let a=t.contentWindow?.location.href;if(a&&!a.startsWith("about:blank")){let i=new URL(a);i.origin===o.origin&&i.pathname===o.pathname&&(i.searchParams.forEach((r,c)=>{o.searchParams.set(c,r)}),o.hash=i.hash)}}catch{}return o.searchParams.set("preview","true"),o.toString()}function Ze(t){let n=t.collection,o=t.slug,a=`${n}/${o}`,{roles:i}=Re(),r=window.firebase.user.email||"",c=Te(i,r);return e(Oe,{docId:a,readOnly:!c,children:e(mt,{...t,canEdit:c})})}function mt(t){let n=t.canEdit,o=t.collection,a=t.slug,i=`${o}/${a}`;Xe(i);let r=window.__ROOT_CTX.collections[o],c=q(),l=!!r?.url,[s,m]=R(`root::DocumentPage::previewVisible::${o}`,l),h=B(()=>(window.__ROOT_CTX.checks||[]).some(f=>!f.collections||f.collections.includes(o)),[o]),[_,v]=R("root::DocumentPage::checksVisible",!1),D=P(_);D.current=_;let[x,g]=R("root::DocumentPage::searchVisible",!1),u=P(x);u.current=x;let k=Me(),[S,L]=R("root::DocumentPage::aiVisible",!1),M=P(S);M.current=S,b(()=>{window.dispatchEvent(new CustomEvent("root:checks-visible",{detail:_}))},[_]),b(()=>{window.dispatchEvent(new CustomEvent("root:search-visible",{detail:x}))},[x]),b(()=>{window.dispatchEvent(new CustomEvent("root:ai-visible",{detail:S}))},[S]);let[U,J]=R("root::DocumentPage::searchPanelWidth",360),[W,$]=y(U),[F,H]=y(!1),Y=P(null);if(b(()=>{let p=()=>{let f=!D.current;v(()=>f),f&&(g(()=>!1),L(()=>!1))};return window.addEventListener("root:toggle-checks",p),()=>window.removeEventListener("root:toggle-checks",p)},[]),b(()=>{let p=()=>{let f=!u.current;g(()=>f),f&&(v(()=>!1),L(()=>!1),requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("root:focus-search"))}))};return window.addEventListener("root:toggle-search",p),()=>window.removeEventListener("root:toggle-search",p)},[]),b(()=>{let p=()=>{let f=!M.current;L(()=>f),f&&(v(()=>!1),g(()=>!1))};return window.addEventListener("root:toggle-ai",p),()=>window.removeEventListener("root:toggle-ai",p)},[]),b(()=>{if(!F)return;let p=A=>{let V=Y.current;if(!V)return;let re=V.getBoundingClientRect(),ce=Math.max(240,Math.min(re.right-A.clientX,800));$(ce)},f=()=>{H(!1),$(A=>(J(()=>A),A))};return window.addEventListener("mousemove",p),window.addEventListener("mouseup",f),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",f)}},[F]),!r)return e("div",{children:"Could not find collection."});let ie=C(()=>{if(!l)return;let p=le(o,a),f=window.open(p,"_blank","noopener,noreferrer");f&&f.focus()},[l,o,a]),Q=C(()=>{n&&c.controller&&c.controller.flush()},[n,c.controller]),G=Be(),j=C(()=>{let p=c.controller?.getData()?.fields||{};G.open({data:p,onSave:f=>{c.controller&&f&&typeof f=="object"&&(c.controller.updateKey("fields",f),c.controller.flush()),G.close()}})},[c.controller]),d=C(()=>{window.dispatchEvent(new CustomEvent("root:toggle-search"))},[]),w=C(()=>{k&&window.dispatchEvent(new CustomEvent("root:toggle-ai"))},[k]),E=C(()=>{L(()=>!1)},[L]);return me([["mod+S",Q],["mod+shift+F",d],["mod+I",w]]),e(He,{children:e("div",{className:I("DocumentPage__layout",F&&"DocumentPage__layout--dragging"),ref:Y,children:[e(K,{className:"DocumentPage",localStorageId:"DocumentPage",children:[e(K.Item,{className:I("DocumentPage__side",(!l||!s)&&"DocumentPage__side--expanded"),children:[e("div",{className:"DocumentPage__side__header",children:[e("div",{className:"DocumentPage__side__header__nav",children:[e("a",{href:`/cms/content/${o}`,children:e(N,{className:"DocumentPage__side__header__back",children:e(ge,{size:16})})}),e("div",{className:"DocumentPage__side__header__docId",children:i})]}),e("div",{className:"DocumentPage__side__header__buttons",children:[e(se,{label:"You don't have access to edit this document",condition:!n,children:e(X,{className:"DocumentPage__side__header__saveButton",variant:"filled",color:"dark",size:"xs",compact:!0,leftIcon:e(xe,{size:16}),onClick:()=>Q(),disabled:!n,children:"Save"})}),e(se,{label:"You don't have access to edit this document",condition:!n,children:e(T,{label:"Edit JSON",disabled:!n,children:e(N,{className:"DocumentPage__side__header__editJson",onClick:()=>j(),disabled:!n,children:e(ve,{size:14})})})}),l&&e(O,{children:[e(T,{label:s?"Hide preview":"Show preview",children:e(N,{className:"DocumentPage__side__header__previewToggle",onClick:()=>m(!s),children:s?e(De,{size:16}):e(Ce,{size:16})})}),!s&&e(T,{label:"Open preview in new tab",children:e(N,{className:"DocumentPage__side__header__openNewTab",onClick:ie,children:e(oe,{size:16})})})]})]})]}),e("div",{className:I("DocumentPage__side__editor",(!l||!s)&&!_&&!x&&!S&&"DocumentPage__side__editor--centered"),children:e(Fe,{docId:i})})]}),e(K.Item,{className:I("DocumentPage__main",(!l||!s)&&"DocumentPage__main--hidden"),fluid:!0,children:l&&s&&e(Ze.Preview,{docId:i},i)})]}),h&&_&&e(_t,{docId:i}),x&&e(O,{children:[e("div",{className:"DocumentPage__searchDivider",onMouseDown:()=>H(!0)}),e("div",{className:"DocumentPage__search",style:{flexBasis:`${W}px`},children:e(Qe,{docId:i,autoFocus:!0,onClose:()=>g(()=>!1)})})]}),k&&S&&e(ht,{docId:i,onClose:E})]})})}function ht(t){let[n,o]=R("root::DocumentPage::aiPanelWidth",420),[a,i]=y(n),r=P(null),c=P(a),l=P(),s=B(()=>e(je,{variant:"panel",docContext:{docId:t.docId},onClose:t.onClose}),[t.docId,t.onClose]),m=C(()=>{let h=r.current?.parentElement;if(!h)return;c.current=a,h.classList.add("DocumentPage__layout--dragging");let _=x=>{let g=r.current?.parentElement;if(!g)return;let u=g.getBoundingClientRect(),k=Math.max(280,Math.min(u.right-x.clientX,800));c.current=k,i(k)},v=()=>{h.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",D),l.current=void 0},D=()=>{v(),o(()=>c.current)};l.current=v,window.addEventListener("mousemove",_),window.addEventListener("mouseup",D)},[a,o]);return b(()=>()=>l.current?.(),[]),e(O,{children:[e("div",{className:"DocumentPage__aiDivider",ref:r,onMouseDown:m}),e("div",{className:"DocumentPage__ai",style:{flexBasis:`${a}px`},children:s})]})}function _t(t){let[n,o]=R("root::DocumentPage::checksPanelWidth",360),[a,i]=y(n),r=P(null),c=P(a),l=P(),s=B(()=>e(Je,{docId:t.docId}),[t.docId]),m=C(()=>{let h=r.current?.parentElement;if(!h)return;c.current=a,h.classList.add("DocumentPage__layout--dragging");let _=x=>{let g=r.current?.parentElement;if(!g)return;let u=g.getBoundingClientRect(),k=Math.max(200,Math.min(u.right-x.clientX,800));c.current=k,i(k)},v=()=>{h.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",D),l.current=void 0},D=()=>{v(),o(()=>c.current)};l.current=v,window.addEventListener("mousemove",_),window.addEventListener("mouseup",D)},[a,o]);return b(()=>()=>l.current?.(),[]),e(O,{children:[e("div",{className:"DocumentPage__checksDivider",ref:r,onMouseDown:m}),e("div",{className:"DocumentPage__checks",style:{flexBasis:`${a}px`},children:s})]})}var Ge={mobile:[430,932],tablet:[768,1024],desktop:[1440,800]};function pt(t){let n=new Intl.DisplayNames(["en"],{type:"language"}),a=t.split("_")[0];return`${n.of(a)||t} (${t})`}Ze.Preview=t=>{let n=q();if(n.loading)return null;let[o,a]=t.docId.split("/"),r=window.__ROOT_CTX.collections[o];if(!r)throw new Error(`collection not found: ${o}`);if(!r.url)return null;let c=r.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",l=Le({collectionId:o,slug:a}),s=ae({collectionId:o,slug:a}),m=`${c}${l}`,[h,_]=y(m),[v,D]=R("root::DocumentPage::preview::device",""),[x,g]=R("root::DocumentPage::preview::expandVertically",!1),[u,k]=y({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"}),[S,L]=qe("locale",""),M=P(null),U=P(null),J=n.controller.getLocales()||[],W=le(o,a,S),$=P(W);$.current=W;let F=B(()=>[{value:"",label:"Select locale"},...J.map(d=>({value:d,label:pt(d)}))],[J]);function H(){if(document.hidden)return;let d=M.current,w=ut(d,$.current);d.src="about:blank",window.requestAnimationFrame(()=>{d.src!==w?d.src=w:d.contentWindow.location.reload()})}b(()=>{let d=M.current;function w(){let p=d.contentWindow;if(p&&s===l&&!p.location.href.startsWith("about:blank")){let f=p.location;_(`${c}${f.pathname}`)}}d.addEventListener("load",w);let E=n.controller?.onFlush(()=>{H()});return()=>{E(),d.removeEventListener("load",w)}},[]),b(()=>{let d=M.current;d.src=W},[S]);let Y=C(d=>{D(w=>{let E=w===d?"":d;return E===""&&g(!1),E})},[D,g]),ie=C(()=>{D(d=>(d&&g(w=>!w),d))},[D,g]),Q=C(()=>{n.controller&&n.controller.flush().then(()=>H())},[n.controller]),G=C(()=>{let d=le(o,a,S),w=window.open(d,"_blank","noopener,noreferrer");w&&w.focus()},[o,a,S]),j=C(()=>{if(v===""){let z={"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"};k(ee=>ee["--iframe-width"]===z["--iframe-width"]&&ee["--iframe-height"]===z["--iframe-height"]&&ee["--iframe-scale"]===z["--iframe-scale"]?ee:z);return}let d=U.current;if(!d)return;let w=d.getBoundingClientRect(),[E,p]=Ge[v],f=20,A=Math.max(w.width-2*f,0),V=Math.max(w.height-2*f,0),re=A>0&&E>0?A/E:1,ce=V>0&&p>0?V/p:1,et=Math.min(re,ce,1),de=Number(et.toFixed(4))||1,tt=x?`${Math.max(V-28,0)/de}px`:`${p}px`,Z={"--iframe-width":`${E}px`,"--iframe-height":tt,"--iframe-scale":String(de)};k(z=>z["--iframe-width"]===Z["--iframe-width"]&&z["--iframe-height"]===Z["--iframe-height"]&&z["--iframe-scale"]===Z["--iframe-scale"]?z:Z)},[v,x]);return b(()=>{j();let d=U.current;if(!d)return;let w=0,E=()=>{window.cancelAnimationFrame(w),w=window.requestAnimationFrame(j)},p=new window.ResizeObserver(E);return p.observe(d),window.addEventListener("resize",E),()=>{window.cancelAnimationFrame(w),p.disconnect(),window.removeEventListener("resize",E)}},[j]),e("div",{className:"DocumentPage__main__preview",children:[e(Ye,{device:v,expandVertically:x,iframeUrl:h,localeOptions:F,selectedLocale:S,onToggleDevice:Y,onToggleExpandVertically:ie,onReloadClick:Q,onOpenNewTab:G,onLocaleChange:L}),e("div",{className:"DocumentPage__main__previewFrame","data-device":v||"full",ref:U,style:u,children:[e("div",{className:"DocumentPage__main__previewFrame__deviceLabel",style:{display:v?void 0:"none"},children:v?`${v}: ${Ge[v].join("x")}`:""}),e("div",{className:"DocumentPage__main__previewFrame__iframeWrap",children:e("iframe",{ref:M,title:"iframe preview"})})]})]})};export{Ze as DocumentPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{k as E,l as P,m as h,s as S}from"./chunk-4ALFT4ES.js";import"./chunk-WFQU7V3W.js";import"./chunk-XWX2622O.js";import"./chunk-SKQECSUR.js";import"./chunk-VJUMFJIX.js";import"./chunk-JBHRZ4EX.js";import"./chunk-3E6CASIN.js";import{b as s}from"./chunk-FBSBL476.js";import"./chunk-HO3W4RVG.js";import"./chunk-2EPQJUGM.js";import"./chunk-NJMNOITA.js";import"./chunk-344GZOGG.js";import"./chunk-XMESZUC5.js";import"./chunk-ENQKSLGJ.js";import"./chunk-CAY5NM4Z.js";import"./chunk-MSYTAJBV.js";import"./chunk-Q7IU4QCY.js";import"./chunk-YXSXWFLZ.js";import"./chunk-JTIQBW33.js";import"./chunk-PTPYMVFW.js";import"./chunk-2S5HMST6.js";import"./chunk-FJLNXXE3.js";import"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import{b as p}from"./chunk-W5DOO6ID.js";import{a as D}from"./chunk-NSOTG64N.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as x}from"./chunk-P2Z66DHV.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{e as _}from"./chunk-BUNR5EU3.js";import{Ga as t,a as v,c as m,da as f,e as u,j as B,qb as b}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";B();function H(e){let o=`${e.collection}/${e.slug}`,{roles:d}=D(),a=window.firebase.user.email||"",n=p(d,a);return t(E,{docId:o,readOnly:!n,autoSave:!1,flushOnStop:!1,children:t(w,{...e,canEdit:n})})}function I(e){return e&&typeof e.toMillis=="function"?e.toMillis():0}function w(e){let o=`${e.collection}/${e.slug}`;x(o);let d=P(),a=d.controller,n=d.loading,[r,y]=v("NO_CHANGES");h(y);let g=u(!1);m(()=>{n||g.current||(g.current=!0,s({type:"ready",docId:o}))},[n,o]);let c=u(0);return m(()=>{let N=[a.onFlush(()=>{s({type:"saved",docId:o,saveState:"SAVED"})}),a.onChange(l=>{let i=I(l?.sys?.publishedAt);if(c.current===0){c.current=i;return}i>c.current&&(c.current=i,s({type:"published",docId:o,publishedAt:i}))})];return()=>N.forEach(l=>l())},[a,o]),t("div",{className:"EmbeddedDocumentPage",children:[e.canEdit&&!n&&t("div",{className:"EmbeddedDocumentPage__saveBar",children:[t(f,{component:"a",className:"EmbeddedDocumentPage__saveBar__docId",href:`/cms/content/${e.collection}/${e.slug}`,target:"_blank",rel:"noreferrer noopener",title:"Open in new tab",compact:!0,size:"xs",variant:"default",children:o}),t("div",{className:"EmbeddedDocumentPage__saveBar__controls",children:[t("div",{className:"EmbeddedDocumentPage__saveBar__saveState",children:[r==="UPDATE_PENDING"&&"unsaved changes",r==="SAVED"&&"saved!",r==="ERROR"&&"error saving"]}),t(f,{color:"dark",compact:!0,size:"xs",leftIcon:t(b,{size:16}),loading:r==="SAVING",disabled:r!=="UPDATE_PENDING"&&r!=="ERROR",onClick:()=>a.flush(),children:"Save"})]})]}),t("div",{className:_("EmbeddedDocumentPage__editor","DocumentPage__side"),children:t(S,{docId:o,hideStatusBar:!0})})]})}export{H as EmbeddedDocumentPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-NWHGT476.js";import"./chunk-ENQKSLGJ.js";import"./chunk-CAY5NM4Z.js";import{a}from"./chunk-MSYTAJBV.js";import"./chunk-TOGLZDK3.js";import"./chunk-JS6TK4OP.js";import"./chunk-KRNQ6L35.js";import{a as i}from"./chunk-P2Z66DHV.js";import{b as g}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as o}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function L(){return i("Action Logs"),o(g,{children:o("div",{className:"LogsPage",children:[o("div",{className:"LogsPage__header",children:o(a,{size:"h1",children:"Action Logs"})}),o(e,{})]})})}export{L as LogsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as s}from"./chunk-QF3GPZTI.js";import"./chunk-4ISFTE2G.js";import{a as l}from"./chunk-NWHGT476.js";import"./chunk-ENQKSLGJ.js";import"./chunk-CAY5NM4Z.js";import{a as n}from"./chunk-4FGASIIX.js";import{a as r}from"./chunk-TOGLZDK3.js";import"./chunk-FJLNXXE3.js";import"./chunk-JS6TK4OP.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import"./chunk-KRNQ6L35.js";import{a as c}from"./chunk-P2Z66DHV.js";import{b as a}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as e,da as i}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function o(){c("Home");let t=!!window.__ROOT_CTX.experiments?.taskManager;return e(a,{children:e("div",{className:"ProjectPage",children:e("div",{className:"ProjectPage__main",children:[t&&e(s,{}),e("div",{className:"ProjectPage__section",children:[e(o.Collections,{}),e(o.ActionLogs,{})]})]})})})}o.SectionTitle=t=>e("div",{className:"ProjectPage__sectionTitle",children:t.children});o.Collections=()=>{let t=window.__ROOT_CTX.collections,d=window.__ROOT_CTX.rootConfig.projectId;return e("div",{className:"ProjectPage__collections",children:e(n,{collections:t,projectId:d})})};o.ActionLogs=()=>e("div",{className:"ProjectPage__actionLogs",children:[e("div",{className:"ProjectPage__actionLogs__header",children:[e(o.SectionTitle,{children:"Recent actions"}),e(i,{component:"a",variant:"default",size:"xs",compact:!0,href:"/cms/logs",children:"Show all"})]}),e(r,{children:e(l,{limit:10,compact:!0})})]});export{o as ProjectPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as C,f as oe,g as re,h as le,i as ce,j as me,k as de,l as _e,m as ge,n as pe,o as ue,p as ke,q as fe,r as Te,s as he}from"./chunk-4ISFTE2G.js";import{r as ie}from"./chunk-4ALFT4ES.js";import"./chunk-WFQU7V3W.js";import"./chunk-XWX2622O.js";import"./chunk-SKQECSUR.js";import"./chunk-VJUMFJIX.js";import"./chunk-JBHRZ4EX.js";import"./chunk-3E6CASIN.js";import"./chunk-FBSBL476.js";import"./chunk-HO3W4RVG.js";import"./chunk-2EPQJUGM.js";import{b as R,c as ae}from"./chunk-NJMNOITA.js";import"./chunk-344GZOGG.js";import"./chunk-XMESZUC5.js";import"./chunk-ENQKSLGJ.js";import"./chunk-CAY5NM4Z.js";import{a as W}from"./chunk-MSYTAJBV.js";import{a as I}from"./chunk-TOGLZDK3.js";import"./chunk-Q7IU4QCY.js";import"./chunk-YXSXWFLZ.js";import"./chunk-JTIQBW33.js";import"./chunk-PTPYMVFW.js";import"./chunk-2S5HMST6.js";import"./chunk-FJLNXXE3.js";import"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import"./chunk-W5DOO6ID.js";import"./chunk-NSOTG64N.js";import{a as k}from"./chunk-J5E457OI.js";import{a as f}from"./chunk-QHJOTXYB.js";import"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as se}from"./chunk-P2Z66DHV.js";import{b as ne}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import{a as Y}from"./chunk-VD6G5NV4.js";import{e as x}from"./chunk-BUNR5EU3.js";import{Cb as Q,Fa as P,Ga as e,Rc as M,V,W as h,Wa as Z,Wc as te,Yc as A,Za as b,a as d,c as y,ca as U,da as T,e as O,g as D,hc as ee,j as Ie,lc as F,mb as B,mc as w,na as G,ua as S,wb as J,za as L}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import{h as X}from"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";Ie();function H(a){return e(ie,{className:x("TaskCommentEditor",a.className),placeholder:a.placeholder,value:a.value,onChange:a.onChange,autoFocus:a.autoFocus,autosize:!0,variant:"comment"})}var we=[{value:"new",label:"New"},{value:"in-progress",label:"In progress"},{value:"in-review",label:"In review"},{value:"closed",label:"Closed"}],Ce=[{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"normal",label:"Normal"}];function yt(a){let t=a.id,[i,o]=d(null),[_,g]=d([]),[r,l]=d([]),[n,m]=d(!0),[c,s]=d("");return se(i?`Task: ${i.title}`:`Task: ${t}`),y(()=>{m(!0),s("");let u=[oe(t,p=>{o(p),m(!1)},p=>{s(k(p)),m(!1)}),re(t,p=>g(p),p=>s(k(p))),le(t,p=>l(p),p=>s(k(p)))];return()=>u.forEach(p=>p())},[t]),e(ne,{children:e("div",{className:"TaskPage",children:[e("div",{className:"TaskPage__header",children:[e(U,{className:"TaskPage__header__breadcrumbs",children:[e("a",{href:"/cms/tasks",children:"Tasks"}),e("div",{children:t})]}),e("div",{className:"TaskPage__header__titleWrap",children:[e(Ne,{task:i,taskId:t}),i&&e("span",{className:x("TaskPage__statusBadge",`TaskPage__statusBadge--${je(i.status)}`),children:$e(i.status)})]})]}),n&&e("div",{className:"TaskPage__loading",children:e(V,{color:"gray",size:"xl"})}),!n&&c&&e("div",{className:"TaskPage__error",children:c}),!n&&!c&&!i&&e(I,{className:"TaskPage__notFound",children:"Task not found."}),!n&&!c&&i&&e("div",{className:"TaskPage__body",children:[e("main",{className:"TaskPage__main",children:[e(ze,{task:i}),e(Ae,{task:i}),e(De,{task:i,comments:_,events:r}),e(ye,{taskId:i.id})]}),e("aside",{className:"TaskPage__side",children:e(Ee,{task:i})})]})]})})}function Ne(a){let{task:t}=a,[i,o]=d(!1),[_,g]=d(t?.title||""),[r,l]=d(!1);y(()=>{i||g(t?.title||"")},[t?.title,i]);async function n(){if(!t)return;let m=_.trim();if(!m){f({title:"Could not update title",message:"Task title is required.",color:"red"});return}if(m===t.title){g(t.title),o(!1);return}l(!0);try{await me(t.id,m),o(!1)}catch(c){f({title:"Could not update title",message:k(c),color:"red",autoClose:!1})}finally{l(!1)}}return t?i?e("form",{className:"TaskPage__header__titleForm",onSubmit:m=>{m.preventDefault(),n()},children:[e(S,{autoFocus:!0,className:"TaskPage__header__titleInput",disabled:r,value:_,onChange:m=>g(m.currentTarget.value),onKeyDown:m=>{m.key==="Escape"&&(g(t.title),o(!1))}}),e(T,{compact:!0,size:"xs",color:"dark",type:"submit",loading:r,leftIcon:e(b,{size:14,strokeWidth:"1.8"}),children:"Save"}),e(T,{compact:!0,size:"xs",variant:"default",type:"button",leftIcon:e(A,{size:14,strokeWidth:"1.8"}),onClick:()=>{g(t.title),o(!1)},children:"Cancel"})]}):e("div",{className:"TaskPage__header__titleContent",children:[e(W,{size:"h1",children:t.title}),e(P,{label:"Edit title",children:e(h,{size:"sm",onClick:()=>o(!0),children:e(w,{size:16,strokeWidth:"1.8"})})})]}):e(W,{size:"h1",children:`Task #${a.taskId}`})}function ze(a){let{task:t}=a,[i,o]=d(!1),[_,g]=d(t.description||""),[r,l]=d(!1);y(()=>{i||g(t.description||"")},[t.description,i]);async function n(){l(!0);try{await pe(t.id,_.trim()),o(!1)}catch(m){f({title:"Could not update description",message:k(m),color:"red",autoClose:!1})}finally{l(!1)}}return e(I,{className:"TaskPage__description",children:[e("div",{className:"TaskPage__description__top",children:[e("div",{className:"TaskPage__description__label",children:"Description"}),!i&&e(h,{size:"sm",onClick:()=>o(!0),children:e(w,{size:16,strokeWidth:"1.8"})})]}),i?e("div",{className:"TaskPage__description__edit",children:[e(G,{autosize:!0,autoFocus:!0,minRows:4,value:_,placeholder:"Add task details, scope, and acceptance criteria.",onChange:m=>g(m.currentTarget.value)}),e("div",{className:"TaskPage__description__editActions",children:[e(T,{compact:!0,size:"xs",variant:"default",leftIcon:e(A,{size:14,strokeWidth:"1.8"}),onClick:()=>{o(!1),g(t.description||"")},children:"Cancel"}),e(T,{compact:!0,size:"xs",color:"dark",loading:r,leftIcon:e(b,{size:14,strokeWidth:"1.8"}),onClick:n,children:"Save"})]})]}):e("div",{className:x("TaskPage__description__content",!t.description&&"TaskPage__description__content--empty"),children:t.description||"No description provided."})]})}function Ae(a){let{task:t}=a,i=O(null),[o,_]=d(!1),[g,r]=d(""),l=t.attachments||[];async function n(c){let s=Array.from(c);if(s.length!==0){_(!0);try{for(let u of s){let p=await X(u);await ue(t.id,{...p,filename:p.filename||u.name,contentType:u.type||void 0,size:u.size})}f({message:s.length===1?"File attached.":`${s.length} files attached.`,color:"green"})}catch(u){f({title:"Could not attach file",message:k(u),color:"red",autoClose:!1})}finally{_(!1),i.current&&(i.current.value="")}}}async function m(c){let s=xe(c);if(window.confirm(`Remove ${s} from this task?`)){r(c.id);try{await ke(t.id,c.id)}catch(u){f({title:"Could not remove attachment",message:k(u),color:"red",autoClose:!1})}finally{r("")}}}return e("section",{className:"TaskPage__attachments",children:[e("div",{className:"TaskPage__attachments__top",children:[e("div",{className:"TaskPage__attachments__label",children:"Attachments"}),e(T,{compact:!0,size:"xs",variant:"subtle",type:"button",loading:o,leftIcon:e(F,{size:14,strokeWidth:"1.8"}),onClick:()=>i.current?.click(),children:"Attach files"}),e("input",{ref:i,className:"TaskPage__attachments__input",type:"file",multiple:!0,onChange:c=>{n(c.currentTarget.files||[])}})]}),l.length>0?e("div",{className:"TaskPage__attachments__list",children:l.map(c=>e("div",{className:"TaskPage__attachments__item",children:[e("div",{className:"TaskPage__attachments__itemIcon",children:e(F,{size:16,strokeWidth:"1.8"})}),e("div",{className:"TaskPage__attachments__itemContent",children:[e("a",{href:c.src,target:"_blank",rel:"noreferrer",className:"TaskPage__attachments__itemTitle",children:xe(c)}),e("div",{className:"TaskPage__attachments__itemMeta",children:Re(c)})]}),e("div",{className:"TaskPage__attachments__itemActions",children:[e(P,{label:"Open file",children:e(h,{component:"a",href:c.src,target:"_blank",rel:"noreferrer",size:"sm",children:e(J,{size:16,strokeWidth:"1.8"})})}),e(P,{label:"Remove attachment",children:e(h,{size:"sm",disabled:g===c.id,onClick:()=>m(c),children:e(M,{size:16,strokeWidth:"1.8"})})})]})]},c.id))}):e("div",{className:"TaskPage__attachments__empty",children:"No files attached."})]})}function Ee(a){let{task:t}=a,[i,o]=d(t.assignee||""),[_,g]=d(j(t.targetLaunchDate)),[r,l]=d("");y(()=>{o(t.assignee||""),g(j(t.targetLaunchDate))},[t.assignee,t.targetLaunchDate]);async function n(s,u){l(s);try{await u()}catch(p){f({title:"Could not update task",message:k(p),color:"red",autoClose:!1})}finally{l("")}}function m(){let s=i.trim();(t.assignee||"")!==s&&n("assignee",()=>ce(t.id,s||null))}function c(s){g(s),j(t.targetLaunchDate)!==s&&n("targetLaunchDate",()=>ge(t.id,Ke(s)))}return e(I,{className:"TaskPage__metadata",children:[e("div",{className:"TaskPage__metadata__field",children:[e("label",{children:"Status"}),e(L,{size:"xs",data:we,value:C(t.status),onChange:s=>{s&&s!==C(t.status)&&n("status",()=>de(t.id,s))}})]}),e("div",{className:"TaskPage__metadata__field",children:[e("label",{children:"Assignee"}),e("div",{className:"TaskPage__metadata__assignee",children:e(S,{size:"xs",type:"email",placeholder:"teammate@example.com",value:i,disabled:r==="assignee",onChange:s=>o(s.currentTarget.value),onBlur:()=>m(),onKeyDown:s=>{s.key==="Enter"&&s.currentTarget.blur()}})})]}),e("div",{className:"TaskPage__metadata__field",children:[e("label",{children:"Priority"}),e(L,{size:"xs",data:Ce,value:t.priority||"normal",onChange:s=>{s&&s!==(t.priority||"normal")&&n("priority",()=>_e(t.id,s))}})]}),e("div",{className:"TaskPage__metadata__field",children:[e("label",{children:"Target launch date"}),e("div",{className:"TaskPage__metadata__date",children:e("input",{type:"date",value:_,disabled:r==="targetLaunchDate",onInput:s=>c(s.currentTarget.value)})})]})]})}function De(a){let{task:t,comments:i,events:o}=a,_=D(()=>{let r=new Map;return i.filter(l=>l.parentId).forEach(l=>{let n=l.parentId||"";r.set(n,[...r.get(n)||[],l])}),r.forEach(l=>l.sort((n,m)=>E(n.createdAt)-E(m.createdAt))),r},[i]),g=D(()=>{let r=i.filter(n=>!n.parentId);return[{id:"opened",kind:"opened",createdAt:t.createdAt},...o.map(n=>({id:n.id,kind:"event",event:n,createdAt:n.createdAt})),...r.map(n=>({id:n.id,kind:"comment",comment:n,createdAt:n.createdAt}))].sort((n,m)=>E(n.createdAt)-E(m.createdAt))},[t,i,o]);return e("div",{className:"TaskPage__timeline",children:g.map(r=>r.kind==="opened"?e(Se,{task:t},r.id):r.kind==="event"?e(Le,{event:r.event},r.id):e(ve,{comment:r.comment,replies:_.get(r.comment.id)||[],threadParentId:r.comment.id},r.id))})}function Se(a){let{task:t}=a;return e("div",{className:"TaskPage__timelineItem TaskPage__timelineItem--event",children:[e("div",{className:"TaskPage__timelineItem__marker",children:e(b,{size:15,strokeWidth:"2"})}),e("div",{className:"TaskPage__timelineItem__content",children:[e("b",{children:z(t.createdBy||"unknown")})," opened this task"," ",N(t.createdAt),"."]})]})}function Le(a){let{event:t}=a;return e("div",{className:"TaskPage__timelineItem TaskPage__timelineItem--event",children:[e("div",{className:"TaskPage__timelineItem__marker",children:t.field==="title"?e(w,{size:15,strokeWidth:"2"}):t.field==="assignee"?e(te,{size:15,strokeWidth:"2"}):t.field==="priority"?e(Q,{size:15,strokeWidth:"2"}):t.field==="targetLaunchDate"?e(Z,{size:15,strokeWidth:"2"}):e(b,{size:15,strokeWidth:"2"})}),e("div",{className:"TaskPage__timelineItem__content",children:[e("b",{children:z(t.createdBy||"unknown")})," changed"," ",qe(t.field)," from"," ",e("span",{className:"TaskPage__timelineValue",children:Pe(t.field,t.oldValue)})," ","to"," ",e("span",{className:"TaskPage__timelineValue",children:Pe(t.field,t.newValue)})," ",N(t.createdAt),"."]})]})}function ve(a){let{comment:t}=a,i=window.firebase.user.email||"",[o,_]=d(!1),[g,r]=d(!1),[l,n]=d(t.body||q(t.content)),[m,c]=d(!1),s=t.createdBy===i&&!t.isDeleted,u=a.threadParentId||t.parentId||t.id;y(()=>{n(t.body||q(t.content))},[t.body,t.content]);async function p(){if(l){c(!0);try{await Te(t.taskId,t.id,l),r(!1)}catch(v){f({title:"Could not edit comment",message:k(v),color:"red",autoClose:!1})}finally{c(!1)}}}async function be(){if(window.confirm("Delete this comment?"))try{await he(t.taskId,t.id)}catch(v){f({title:"Could not delete comment",message:k(v),color:"red",autoClose:!1})}}return e("div",{className:x("TaskPage__timelineItem","TaskPage__timelineItem--comment",a.isReply&&"TaskPage__timelineItem--reply"),children:[e("div",{className:"TaskPage__timelineItem__marker",children:a.isReply?e(B,{size:15,strokeWidth:"2"}):e(ee,{size:15,strokeWidth:"2"})}),e("div",{className:"TaskPage__timelineItem__content",children:[e(I,{className:"TaskPage__comment",children:[e("div",{className:"TaskPage__comment__header",children:[e("div",{children:[e("b",{children:z(t.createdBy||"unknown")})," ",e("span",{children:N(t.createdAt)}),t.updatedAt&&!t.isDeleted&&e("span",{children:[" edited ",N(t.updatedAt)]})]}),e("div",{className:"TaskPage__comment__actions",children:[!t.isDeleted&&e(P,{label:"Reply",children:e(h,{size:"sm",onClick:()=>_(!o),children:e(B,{size:16,strokeWidth:"1.8"})})}),s&&e(P,{label:"Edit",children:e(h,{size:"sm",onClick:()=>r(!0),children:e(w,{size:16,strokeWidth:"1.8"})})}),s&&e(P,{label:"Delete",children:e(h,{size:"sm",onClick:be,children:e(M,{size:16,strokeWidth:"1.8"})})})]})]}),g?e("div",{className:"TaskPage__comment__edit",children:[e(H,{value:l,placeholder:"Edit this comment...",onChange:n}),e("div",{className:"TaskPage__comment__editActions",children:[e(T,{compact:!0,size:"xs",variant:"default",leftIcon:e(A,{size:14,strokeWidth:"1.8"}),onClick:()=>{r(!1),n(t.body||q(t.content))},children:"Cancel"}),e(T,{compact:!0,size:"xs",color:"dark",loading:m,disabled:!l,leftIcon:e(b,{size:14,strokeWidth:"1.8"}),onClick:p,children:"Save"})]})]}):e("div",{className:x("TaskPage__comment__body",t.isDeleted&&"TaskPage__comment__body--deleted"),children:t.isDeleted?"Comment deleted.":t.body?e(Be,{className:"TaskPage__comment__richText",data:t.body}):e(ae,{className:"TaskPage__comment__markdown",code:t.content})})]}),o&&e(ye,{taskId:t.taskId,parentId:u,autoFocus:!0,onSubmitted:()=>_(!1),onCancel:()=>_(!1)}),a.replies&&a.replies.length>0&&e("div",{className:"TaskPage__replies",children:a.replies.map(v=>e(ve,{comment:v,isReply:!0,threadParentId:t.id},v.id))})]})]})}function ye(a){let[t,i]=d(null),[o,_]=d(0),[g,r]=d(!1),l=!!a.parentId;async function n(m){if(m.preventDefault(),!!t){r(!0);try{await fe(a.taskId,t,a.parentId),i(null),_(c=>c+1),a.onSubmitted?.()}catch(c){f({title:l?"Could not add reply":"Could not add comment",message:k(c),color:"red",autoClose:!1})}finally{r(!1)}}}return e(I,{className:x("TaskPage__composer",l&&"TaskPage__composer--reply"),children:e("form",{onSubmit:n,children:[e(H,{autoFocus:a.autoFocus,placeholder:l?"Write a reply...":"Leave a comment...",value:t,onChange:i},o),e("div",{className:"TaskPage__composer__actions",children:[a.onCancel&&e(T,{compact:!0,size:"xs",variant:"default",type:"button",onClick:a.onCancel,children:"Cancel"}),e(T,{compact:!0,size:"xs",color:"dark",type:"submit",loading:g,disabled:!t,children:l?"Reply":"Comment"})]})]})})}function Be(a){return e("div",{className:a.className,children:(a.data.blocks||[]).map((t,i)=>e(Fe,{block:t},i))})}function Fe(a){let{block:t}=a;switch(t.type){case"paragraph":return e($,{tag:"p",html:t.data?.text});case"heading":return e($,{tag:"h4",html:t.data?.text});case"quote":return e($,{tag:"blockquote",html:t.data?.text});case"orderedList":return e("ol",{children:(t.data?.items||[]).map((i,o)=>e(K,{item:i},o))});case"unorderedList":return e("ul",{children:(t.data?.items||[]).map((i,o)=>e(K,{item:i},o))});case"image":{let i=t.data?.file;return i?.url?e("img",{src:i.url,width:Number(i.width)||void 0,height:Number(i.height)||void 0,alt:i.alt||""}):null}default:return null}}function $(a){if(!a.html)return null;let t=a.tag;return e(t,{dangerouslySetInnerHTML:{__html:R(a.html)}})}function K(a){return e("li",{children:[a.item.content&&e("span",{dangerouslySetInnerHTML:{__html:R(a.item.content)}}),a.item.items&&a.item.items.length>0&&e("ul",{children:a.item.items.map((t,i)=>e(K,{item:t},i))})]})}function q(a){return a.trim()?{blocks:a.split(/\n{2,}/).map(t=>({type:"paragraph",data:{text:Me(t).replace(/\n/g,"<br>")}})),time:Date.now(),version:"plain-text"}:null}function Me(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function E(a){return a?.toMillis?.()||0}function xe(a){let t=a.src.split("?")[0].split("/").filter(Boolean).at(-1)||"",i=a.filename||t||"Attachment";try{return decodeURIComponent(i)}catch{return i}}function Re(a){let t=[We(a.size),a.contentType||"",a.attachedBy?`attached by ${z(a.attachedBy)}`:"",a.attachedAt?N(a.attachedAt):""].filter(Boolean);return t.length>0?t.join(" - "):"Attached file"}function We(a){if(typeof a!="number")return"";if(a<1024)return`${a} B`;let t=["KB","MB","GB"],i=a/1024,o=0;for(;i>=1024&&o<t.length-1;)i=i/1024,o+=1;return`${i.toFixed(i>=10?0:1)} ${t[o]}`}function z(a){return a.split("@")[0]||a}function He(a){return a?.toMillis?new Date(a.toMillis()).toLocaleDateString("en",{month:"short",day:"numeric",year:"numeric"}):"No date"}function N(a){return a?.toMillis?new Date(a.toMillis()).toLocaleString("en",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):"just now"}function $e(a){return C(a).replace(/[-_]/g," ")}function qe(a){return a.replace(/([A-Z])/g," $1").toLowerCase()}function Pe(a,t){return t?t instanceof Y?He(t):a==="assignee"?z(t):a==="title"?t:t.replace(/[-_]/g," "):"none"}function je(a){return C(a).replace(/[^a-z0-9]+/gi,"-").toLowerCase()}function j(a){if(!a?.toMillis)return"";let t=new Date(a.toMillis()),i=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),_=String(t.getDate()).padStart(2,"0");return`${i}-${o}-${_}`}function Ke(a){if(!a)return null;let[t,i,o]=a.split("-").map(Number);return!t||!i||!o?null:new Date(t,i-1,o)}export{yt as TaskPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as k}from"./chunk-ENQKSLGJ.js";import{a as J}from"./chunk-TOGLZDK3.js";import{b as U}from"./chunk-JS6TK4OP.js";import{g as B}from"./chunk-KRNQ6L35.js";import{a as b}from"./chunk-VD6G5NV4.js";import{e as I}from"./chunk-BUNR5EU3.js";import{Cc as H,Da as F,F as O,Fa as f,Ga as t,U as w,V as N,a as l,c as v,da as m,g as A,j as et,sa as C,ua as z,wa as j,za as E}from"./chunk-LROR6N3B.js";import{d as D}from"./chunk-KUCVLANF.js";et();var S=50,at=["doc.save","doc.publish","doc.restore_version","doc.import_translations","doc.revert"],ot=[{value:"all",label:"All time"},{value:"1h",label:"Last hour"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}];function Q(e){let[a,o]=l(!0),[n,s]=l([]);return v(()=>{B(e?{limit:e}:void 0).then(d=>{s(d),o(!1)})},[e]),{loading:a,actions:n}}function $t(e){if(e.compact)return t(ct,{...e});let[a,o]=l(""),[n]=O(a,300),[s,d]=l([]),[h,q]=l([]),[p,X]=l("all"),[L,M]=l(1),{actions:r,loading:Y}=Q(),Z=A(()=>{let i=new Set;return r.forEach(c=>i.add(c.action)),Array.from(i).sort()},[r]),K=A(()=>{let i=new Set;return r.forEach(c=>{c.by&&i.add(c.by)}),Array.from(i).sort()},[r]),g=A(()=>{let i=Date.now();return r.filter(c=>{if(n){let u=n.toLowerCase(),x=c.action.toLowerCase().includes(u),_=c.by?.toLowerCase().includes(u),tt=ut(c.metadata).toLowerCase().includes(u);if(!x&&!_&&!tt)return!1}if(s.length>0&&!s.includes(c.action)||h.length>0&&(!c.by||!h.includes(c.by)))return!1;if(p&&p!=="all"){let u=T(c.timestamp);if(!u)return!1;let x=u.toMillis(),_=0;switch(p){case"1h":_=i-3600*1e3;break;case"24h":_=i-1440*60*1e3;break;case"7d":_=i-10080*60*1e3;break;case"30d":_=i-720*60*60*1e3;break}if(x<_)return!1}return!0})},[r,n,s,h,p]),P=e.compact?1:Math.ceil(g.length/S),y=A(()=>{if(e.compact)return g;let i=(L-1)*S;return g.slice(i,i+S)},[g,L,e.compact]);return v(()=>{M(1)},[n,s,h,p]),Y?t("div",{className:`ActionsLog ActionsLog--loading ${e.className||""}`,children:t(N,{color:"gray",size:"xl"})}):t("div",{className:`ActionsLog ${e.className||""}`,children:[!e.compact&&t("div",{className:"ActionsLog__tableHeader",children:[t("div",{className:"ActionsLog__filters",children:[t(z,{className:"ActionsLog__filters__search",placeholder:"Search actions...",icon:t(H,{size:16}),value:a,onChange:i=>o(i.target.value)}),t(C,{className:"ActionsLog__filters__select",placeholder:"Filter by action",clearable:!0,searchable:!0,data:Z,value:s,onChange:d}),t(C,{className:"ActionsLog__filters__select",placeholder:"Filter by user",clearable:!0,searchable:!0,data:K,value:h,onChange:q}),t(E,{className:"ActionsLog__filters__select",placeholder:"Filter by time",data:ot,value:p,onChange:X})]}),t("div",{className:"ActionsLog__summary",children:["Showing ",y.length," of ",g.length," ","actions",g.length!==r.length&&` (filtered from ${r.length} total)`]})]}),t(J,{className:"ActionsLog__tableSurface",children:t(F,{className:"ActionsLog__table",children:[t("thead",{children:t("tr",{className:"ActionsLogs__table__row ActionsLogs__table__row--header",children:[t("th",{className:"ActionsLogs__table__header",children:"Timestamp"}),t("th",{className:"ActionsLogs__table__header",children:"User"}),t("th",{className:"ActionsLogs__table__header",children:"Action"}),t("th",{className:"ActionsLogs__table__header",children:"Details"}),t("th",{className:"ActionsLogs__table__header",children:"Links"})]})}),t("tbody",{children:[y.map((i,c)=>t("tr",{className:"ActionsLogs__table__row",children:[t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:t(R,{timestamp:i.timestamp,format:"long"})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:t("span",{className:"ActionsLogs__user",children:i.by?t(D,{children:[t(k,{email:i.by,size:20}),t("span",{className:"ActionsLogs__user__email",children:i.by})]}):"\u2014"})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--action",children:t("span",{className:"ActionsLogs__action",children:i.action})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--metadata",children:t(G,{metadata:i.metadata})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--links",children:t($,{action:i})})]},c)),y.length===0&&t("tr",{children:t("td",{colSpan:5,className:"ActionsLogs__table__col ActionsLogs__table__col--empty",children:"No actions found matching your filters."})})]})]})}),!e.compact&&P>1&&t("div",{className:"ActionsLog__pagination",children:t(j,{total:P,value:L,onChange:M,size:"sm"})})]})}function G(e){let{metadata:a}=e;if(!a||Object.keys(a).length===0)return t("span",{className:"ActionsLogs__metadata--empty",children:"\u2014"});let o=Object.entries(a);return t("div",{className:"ActionsLogs__metadata",children:o.map(([n,s])=>t("div",{className:"ActionsLogs__metadata__item",children:[t("span",{className:"ActionsLogs__metadata__key",children:[n,":"]})," ",t("span",{className:"ActionsLogs__metadata__value",children:nt(s)})]},n))})}function nt(e){if(e==null)return"\u2014";if(Array.isArray(e))return e.length===0?"[]":e.length<=3?e.join(", "):`${e.slice(0,3).join(", ")} (+${e.length-3} more)`;if(typeof e=="object"){let a=st(e);try{return JSON.stringify(a)}catch(o){console.error(o),console.error("failed to stringify json:",a)}}return String(e)}function st(e){let a={};return Object.entries(e).forEach(([o,n])=>{o.startsWith("_")||(a[o]=n)}),a}function $(e){let{action:a}=e,o=[];function n(s){return e.label||s}if(a.action!=="doc.delete"&&a.metadata?.docId&&o.push(t(f,{transition:"pop",label:a.metadata.docId,children:t(m,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/content/${a.metadata.docId}`,children:n("Open doc")})},"doc")),at.includes(a.action)&&a.metadata?.docId){let s=T(a.timestamp)?.toMillis();s&&o.push(t(f,{transition:"pop",label:`Show changes to ${a.metadata.docId}`,children:t(m,{component:"a",variant:"default",size:"xs",compact:!0,href:it(a.metadata.docId,s),children:n("Show changes")})},"changes"))}return a.action!=="datasource.delete"&&a.metadata?.datasourceId&&o.push(t(f,{transition:"pop",label:a.metadata.datasourceId,children:t(m,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/data/${a.metadata.datasourceId}`,children:n("Open data source")})},"datasource")),a.action!=="release.delete"&&a.metadata?.releaseId&&o.push(t(f,{transition:"pop",label:a.metadata.releaseId,children:t(m,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${a.metadata.releaseId}`,children:n("Open release")})},"release")),a.metadata?.sheetId&&o.push(t(m,{component:"a",variant:"default",size:"xs",compact:!0,href:U(a.metadata.sheetId),target:"_blank",children:n("Open sheet")},"sheet")),a.action.startsWith("acls.")&&o.push(t(m,{component:"a",variant:"default",size:"xs",compact:!0,href:"/cms/settings",children:n("Open settings")},"settings")),a.links&&a.links.forEach((s,d)=>{o.push(t(m,{component:"a",variant:"default",size:"xs",compact:!0,href:s.url,target:s.target,children:s.label},`link-${d}`))}),o.length===0?t("span",{className:"ActionsLogs__links--empty"}):(e.limit&&(o=o.slice(0,e.limit)),t("div",{className:"ActionsLogs__table__buttons",children:o}))}function it(e,a){let o=W(e,`before:${a}`),n=W(e,`after:${a}`);return`/cms/compare?left=${o}&right=${n}`}function W(e,a){return encodeURIComponent(`${e}@${a}`).replaceAll("%2F","/").replaceAll("%40","@").replaceAll("%3A",":")}function ct(e){let{actions:a,loading:o}=Q(e.limit||10);return o?t("div",{className:I(e.className,"ActionLogsCompact","ActionLogsCompact--loading"),children:t(N,{color:"gray",size:"xl"})}):t("div",{className:I(e.className,"ActionLogsCompact"),children:t(w,{className:"ActionLogsCompact__table",multiple:!0,children:a.map((n,s)=>t(w.Item,{label:t(rt,{action:n}),children:t(lt,{action:n})},s))})})}function rt(e){let a=e.action,o=mt(a),n=e.action.by||"";return t("div",{className:"ActionLogsCompactItemPreview",children:[t("div",{className:"ActionLogsCompactItemPreview__user",children:t(k,{email:n,size:20})}),t("div",{className:"ActionLogsCompactItemPreview__timestamp",children:t(R,{timestamp:a.timestamp})}),t("div",{className:"ActionLogsCompactItemPreview__action",children:a.action}),t("div",{className:"ActionLogsCompactItemPreview__actionMetaId",children:o}),t("div",{className:"ActionLogsCompactItemPreview__buttons",children:t($,{action:a,label:"Open",limit:1})})]})}function lt(e){let a=e.action,o={user:a.by,...a.metadata};return t("div",{className:"ActionLogsCompactItemDetails",children:[t(G,{metadata:o}),t($,{action:a})]})}function mt(e){for(let a of Object.keys(e.metadata||{}))if(a.toLowerCase().endsWith("id"))return e.metadata[a];return""}function T(e){return e?e instanceof b?e:typeof e=="object"&&typeof e._seconds=="number"?new b(e._seconds,e._nanoseconds||0):typeof e=="object"&&typeof e.seconds=="number"?new b(e.seconds,e.nanoseconds||0):typeof e=="number"?b.fromMillis(e):null:null}function R(e){let a=T(e.timestamp)?.toMillis()||0;if(!a)return t("span",{children:"Invalid date"});let o=e.format==="long"?pt(a):_t(a);return t(f,{transition:"pop",label:gt(a),children:t("span",{className:"ActionsLogs__timestamp",children:o})})}var dt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function V(e){let a=e.getHours(),o=a<12?"AM":"PM",n=String(a%12||12).padStart(2,"0"),s=String(e.getMinutes()).padStart(2,"0");return`${n}:${s} ${o}`}function _t(e){let a=new Date(e),o=String(a.getDate()).padStart(2,"0");return`${dt[a.getMonth()]} ${o}, ${V(a)}`}function pt(e){let a=new Date(e),o=a.toLocaleDateString("en",{month:"long"}),n=String(a.getDate()).padStart(2,"0");return`${o} ${n}, ${a.getFullYear()} ${V(a)}`}function gt(e){return new Date(e).toLocaleString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ut(e){function a(o){return o===null?"null":typeof o>"u"?"undefined":typeof o=="string"?`"${o.replaceAll('"','\\"')}"`:typeof o!="object"?String(o):Array.isArray(o)?`[${o.map(a).join(", ")}]`:`{${Object.entries(o).map(([s,d])=>`${s}: ${a(d)}`).join(", ")}}`}return a(e)}export{$t as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as _t}from"./chunk-ENQKSLGJ.js";import{g as oe,h as Xe,i as ke,j as qe,k as Ke,l as Je,m as Qe,n as Ye,o as Ze,p as et,q as de,r as tt,s as Me,t as st,u as ce,y as _e,z as me}from"./chunk-AGFPVTBA.js";import{a as ct}from"./chunk-W5DOO6ID.js";import{a as dt}from"./chunk-NSOTG64N.js";import{b as M}from"./chunk-J5E457OI.js";import{a as b,b as je,c as Ge}from"./chunk-QHJOTXYB.js";import{b as He,d as ye}from"./chunk-KRNQ6L35.js";import{e as fe}from"./chunk-BUNR5EU3.js";import{$a as Fe,Ab as pe,Cc as it,Da as ie,Db as lt,Eb as he,Fa as Le,Fb as De,Ga as e,Pb as nt,Rc as O,Uc as rt,V as te,W as se,a as i,c as T,da as g,ea as L,g as Se,j as Ee,lb as ue,mc as ze,na as Pe,qa as k,ra as U,tb as Ne,ua as j,vb as ge,wb as ot,zb as at}from"./chunk-LROR6N3B.js";import{d as C}from"./chunk-KUCVLANF.js";import{g as Oe,h as re,k as D,l as G,m as Ce,n as H,o as Ve,p as We}from"./chunk-7SK47HHZ.js";Ee();Ee();function mt(t){let o=t.file||{},a=o.src||"",l=o.filename||a,r={"--asset-thumb-size":`${t.size}px`};if(a&&G(l))return e("div",{className:"AssetBrowser__thumb",style:r,children:e("img",{src:Ie(o,t.size*2),alt:o.alt||"",loading:"lazy"})});if(a&&H(l))return e("div",{className:"AssetBrowser__thumb",style:r,children:e("video",{src:a,muted:!0,playsInline:!0,preload:"metadata"})});let _=D(l);return e("div",{className:"AssetBrowser__thumb",style:r,children:_&&_.length<=4?e("div",{className:"AssetBrowser__thumb__ext",children:_}):e(pe,{size:20,stroke:"1.5"})})}function Ie(t,o){let a=t?.src||"";return a.startsWith(Oe)&&o?`${a}=s${o}`:a}function ve(t){let o=t?.src||"";Ce(o)&&(o=o.split("=")[0]+"=s0"),navigator.clipboard.writeText(o).then(()=>{b({message:"Copied URL to clipboard.",autoClose:2e3})})}function we(t){let o=t?.src||"";if(o)if(Ce(o)){let a=document.createElement("a");a.href=We(o),t.filename&&(a.download=t.filename),document.body.appendChild(a),a.click(),document.body.removeChild(a)}else window.open(o,"_blank")}function ft(t){let[o,a]=i(t.asset),[l,r]=i(t.asset.file?.alt||""),[_,d]=i(!1),[x,v]=i(!1),[m,B]=i(null),[h,F]=i(null),n=o.file||{},f=n.filename||o.name,N=G(f),S=H(f),V=l!==(n.alt||""),W=n.altDisabled===!0;T(()=>{_e(o.id).then(c=>F(c)).catch(c=>{console.error("failed to fetch asset usage:",c),F([])})},[o.id]);async function z(c,w){let p=await me(c,{previousFile:w});p.failedDocIds.length>0?b({title:"Some docs failed to update",message:`Failed to update: ${p.failedDocIds.join(", ")}. Re-save the asset to retry.`,color:"red",autoClose:!1}):p.updatedDocIds.length>0&&b({message:`Updated ${p.updatedDocIds.length} doc(s) that use this asset.`,color:"green"})}async function X(){d(!0),await M(async()=>{let c={...n},w=await st(o,l);a(w),t.onChanged(w),await z(w,c)}),d(!1)}function R(){let c=document.createElement("input");c.type="file",c.onchange=()=>{let w=c.files?.[0];if(!w)return;let p=D(f),y=D(w.name);if(p&&y&&p!==y){B(w);return}E(w)},c.click(),c.remove()}async function E(c){B(null),d(!0),await M(async()=>{let w={...n},p=await re(c),y=await tt(o,p);a(y),r(y.file?.alt||""),t.onChanged(y),await z(y,w)}),d(!1)}async function $(c){d(!0),await M(async()=>{let w={...n},p=await ce(o,c);a(p),r(p.file?.alt||""),t.onChanged(p),await z(p,w)}),d(!1)}async function q(){d(!0),await M(async()=>{await de(o),b({message:`Deleted "${o.name}".`,color:"green"}),t.onDeleted()}),d(!1)}return e(U,{className:"AssetBrowser__detailsModal",opened:!0,onClose:t.onClose,title:o.name,size:720,overflow:"outside",centered:!0,children:e("div",{className:"AssetBrowser__details",children:[e("div",{className:"AssetBrowser__details__preview",children:N?e("img",{src:Ie(n,800),alt:n.alt||"",style:n.canvasBgColor==="dark"?{background:"#000"}:{}}):S?e("video",{src:n.src,controls:!0,muted:!0,preload:"metadata"}):e("div",{className:"AssetBrowser__details__preview__placeholder",children:[e(pe,{size:48,stroke:"1"}),e("div",{children:f})]})}),e(ie,{className:"AssetBrowser__details__table",verticalSpacing:"xs",fontSize:"xs",children:e("tbody",{children:[e("tr",{children:[e("td",{children:e("b",{children:"Filename"})}),e("td",{children:f})]}),!!(n.width&&n.height)&&e("tr",{children:[e("td",{children:e("b",{children:"Dimensions"})}),e("td",{children:[n.width,"x",n.height]})]}),o.createdAt&&e("tr",{children:[e("td",{children:e("b",{children:"Uploaded"})}),e("td",{children:[ye(o.createdAt),o.createdBy&&e(C,{children:[" by ",o.createdBy]})]})]}),o.modifiedAt&&e("tr",{children:[e("td",{children:e("b",{children:"Modified"})}),e("td",{children:[ye(o.modifiedAt),o.modifiedBy&&e(C,{children:[" by ",o.modifiedBy]})]})]}),e("tr",{children:[e("td",{children:e("b",{children:"URL"})}),e("td",{children:e("div",{className:"AssetBrowser__details__url",children:[e(j,{readOnly:!0,value:n.src||"",size:"xs",radius:"xs",onClick:c=>c.target.select(),styles:{root:{flex:1,minWidth:0}}}),e(Le,{label:"Copy URL",transition:"pop",children:e(se,{size:"sm",onClick:()=>ve(n),children:e(ue,{size:16})})})]})})]})]})}),(N||S)&&e("div",{className:"AssetBrowser__details__alt",children:[W?e("div",{className:"AssetBrowser__details__alt__disabledNote",children:"Alt text is disabled for this asset. Docs that use it hide the alt text input and render no alt text."}):e(C,{children:[e(Pe,{label:"Alt text",description:"Used as the default alt text when the asset is selected in a doc. Updating it syncs docs that use this asset.",autosize:!0,minRows:1,size:"xs",value:l,disabled:!t.canManage||_,onChange:c=>r(c.currentTarget.value)}),t.canManage&&V&&e(g,{size:"xs",color:"dark",mt:8,loading:_,onClick:()=>X(),children:"Save alt text"})]}),t.canManage&&e(L,{className:"AssetBrowser__details__alt__disableCheckbox",label:"Disable alt text (e.g. decorative images)",size:"xs",mt:8,checked:W,disabled:_,onChange:c=>$(c.currentTarget.checked)})]}),e("div",{className:"AssetBrowser__details__usage",children:[e("div",{className:"AssetBrowser__details__usage__title",children:"Used in"}),h===null?e(te,{color:"gray",size:"sm"}):h.length===0?e("div",{className:"AssetBrowser__details__usage__empty",children:"No docs use this asset."}):e("div",{className:"AssetBrowser__details__usage__list",children:h.map(c=>e("a",{className:"AssetBrowser__details__usage__doc",href:`/cms/content/${c.id}`,target:"_blank",rel:"noreferrer",children:[e("span",{children:c.id}),e(ot,{size:14})]},c.id))})]}),e("div",{className:"AssetBrowser__details__buttons",children:[e(g,{variant:"default",size:"xs",leftIcon:e(ge,{size:14}),onClick:()=>we(n),children:"Download"}),t.canManage&&e(C,{children:[e(g,{variant:"default",size:"xs",leftIcon:e(at,{size:14}),loading:_,onClick:()=>R(),children:"Replace file"}),e(g,{className:"AssetBrowser__details__buttons__delete",color:"red",variant:"filled",size:"xs",leftIcon:e(O,{size:14}),disabled:_,onClick:()=>v(!0),children:"Delete"})]})]}),m&&e("div",{className:"AssetBrowser__details__confirmReplace",children:[e("div",{children:["The new file has a different type (",e("b",{children:[".",D(f)]})," ","\u2192 ",e("b",{children:[".",D(m.name)]}),"). Replacing will change the asset's file extension and serving URL",Me(o.name,D(m.name))!==o.name&&e(C,{children:[", and the asset will be renamed to"," ",e("b",{children:Me(o.name,D(m.name))})]}),". Docs that use this asset will be updated."]}),e("div",{className:"AssetBrowser__details__confirmReplace__buttons",children:[e(g,{variant:"default",size:"xs",onClick:()=>B(null),disabled:_,children:"Cancel"}),e(g,{color:"dark",size:"xs",loading:_,onClick:()=>E(m),children:"Replace"})]})]}),x&&e("div",{className:"AssetBrowser__details__confirmDelete",children:[e("div",{children:["Delete ",e("b",{children:o.name})," from the asset library?",h&&h.length>0&&e(C,{children:[" ","This asset is used in ",h.length," doc(s); those docs keep their copy of the file but will no longer receive updates."]})]}),e("div",{className:"AssetBrowser__details__confirmDelete__buttons",children:[e(g,{variant:"default",size:"xs",onClick:()=>v(!1),disabled:_,children:"Cancel"}),e(g,{color:"red",size:"xs",loading:_,onClick:()=>q(),children:"Delete"})]})]})]})})}function Te(t){let[o,a]=i(t.folder??t.initialFolder??""),l=t.folder??o,[r,_]=i([]),[d,x]=i(!0),[v,m]=i(""),[B,h]=i(!1),[F,n]=i(!1),[f,N]=i(null),[S,V]=i(!1),[W,z]=i(null),[X,R]=i(null),[E,$]=i(null),[q,c]=i(null),[w,p]=i(null),[y,K]=i(new Map),{roles:pt}=dt(),ht=window.firebase.user.email||"",J=ct(pt,ht),Q=v.trim().length>0;function P(s){a(s),m(""),t.onFolderChange&&t.onFolderChange(s)}async function I(s){x(!0),N(null),K(new Map),await M(async()=>{let u=await ke(s);_(u)}),x(!1)}T(()=>{I(l)},[l]),T(()=>{if(!Q||f!==null)return;let s=!1;return(async()=>{let u=[];await M(async()=>{u=await qe(l)}),s||N(u)})(),()=>{s=!0}},[Q,f,l]);let be=t.mode==="manage"?t.initialAssetId:"";T(()=>{be&&M(async()=>{let s=await Je(be);s&&s.type==="file"&&(P(s.parent),p(s))})},[be]);let Y=Se(()=>{let s=v.trim().toLowerCase(),u=s?f||[]:r;return t.mode==="pick"&&(u=u.filter(A=>A.type==="folder"||Ve(A.file?.filename||A.name,t.accept))),s&&(u=u.filter(A=>A.name.toLowerCase().includes(s))),u},[r,f,v,t.mode,t.accept]);async function Ue(s){if(s.length===0||F)return;let u="asset-browser-upload";n(!0),b({id:u,message:`Uploading ${s.length} file(s)...`,loading:!0,autoClose:!1,disallowClose:!0});let A=[],xe=[];for(let le=0;le<s.length;le++){let ne=s[le];je({id:u,message:`Uploading ${ne.name} (${le+1} of ${s.length})...`,loading:!0,autoClose:!1,disallowClose:!0});try{let Be=await re(ne),At=await Ye({parent:l,file:Be});A.push(At)}catch(Be){console.error(`failed to upload ${ne.name}:`,Be),xe.push(ne.name)}}Ge(u),n(!1),xe.length>0?b({title:"Upload failed",message:`Failed to upload: ${xe.join(", ")}`,color:"red",autoClose:!1}):b({message:`Uploaded ${A.length} file(s).`,color:"green"}),await I(l),t.mode==="pick"&&A.length===1&&s.length===1&&t.onPickFile&&t.onPickFile(A[0])}function vt(){let s=document.createElement("input");s.type="file",s.multiple=!0,t.mode==="pick"&&t.accept&&t.accept.length>0&&(s.accept=t.accept.join(",")),s.onchange=()=>{Ue(Array.from(s.files||[]))},s.click(),s.remove()}function wt(s){t.onPickFile&&t.onPickFile(s)}let Z=J,ae=t.mode==="manage"&&J,ee=Array.from(y.values()),Re=ee.filter(s=>s.type==="file"&&!s.file?.altDisabled&&(G(s.file?.filename||s.name)||H(s.file?.filename||s.name))),Ae=Y.length>0&&Y.every(s=>y.has(s.id));function $e(s){K(u=>{let A=new Map(u);return A.has(s.id)?A.delete(s.id):A.set(s.id,s),A})}function bt(){K(Ae?new Map:new Map(Y.map(s=>[s.id,s])))}return e("div",{className:fe("AssetBrowser",t.className,`AssetBrowser--${t.mode}`),children:[e("div",{className:"AssetBrowser__toolbar",children:[e(Te.Breadcrumbs,{folder:l,onNavigate:P}),e("div",{className:"AssetBrowser__toolbar__actions",children:[e(j,{className:"AssetBrowser__toolbar__filter",placeholder:"Search by name",size:"xs",icon:e(it,{size:14}),value:v,onChange:s=>m(s.currentTarget.value)}),Z&&t.mode==="manage"&&e(g,{variant:"default",size:"xs",leftIcon:e(lt,{size:16}),onClick:()=>V(!0),children:"New folder"}),Z&&e(g,{color:"dark",size:"xs",leftIcon:e(rt,{size:16}),loading:F,onClick:()=>vt(),children:"Upload"})]})]}),ae&&ee.length>0&&e("div",{className:"AssetBrowser__selectionBar",children:[e("div",{className:"AssetBrowser__selectionBar__count",children:[ee.length," selected"]}),e("div",{className:"AssetBrowser__selectionBar__actions",children:[e(g,{variant:"default",size:"xs",leftIcon:e(he,{size:14}),onClick:()=>R(ee),children:"Move"}),Re.length>0&&e(g,{variant:"default",size:"xs",onClick:()=>c(Re),children:"Disable alt text"}),e(g,{color:"red",size:"xs",leftIcon:e(O,{size:14}),onClick:()=>$(ee),children:"Delete"}),e(g,{variant:"subtle",color:"gray",size:"xs",onClick:()=>K(new Map),children:"Clear"})]})]}),e("div",{className:fe("AssetBrowser__listing",B&&"dragging"),onDragOver:s=>{Z&&(s.preventDefault(),h(!0))},onDragLeave:s=>{s.preventDefault(),h(!1)},onDrop:s=>{s.preventDefault(),h(!1),Z&&Ue(Array.from(s.dataTransfer?.files||[]))},children:d||Q&&f===null?e("div",{className:"AssetBrowser__loading",children:e(te,{color:"gray",size:"lg"})}):Y.length===0?e("div",{className:"AssetBrowser__empty","data-testid":"asset-browser-empty",children:v?e("div",{children:['No assets match "',v,'" in this folder or its subfolders.']}):e(C,{children:[e("div",{children:"This folder is empty."}),Z&&e("div",{className:"AssetBrowser__empty__hint",children:'Drop files here or click "Upload" to add assets.'})]})}):e(ie,{className:"AssetBrowser__table",verticalSpacing:"xs",fontSize:"xs",highlightOnHover:!0,children:[e("thead",{children:e("tr",{children:[ae&&e("th",{className:"AssetBrowser__table__checkboxCol",children:e(L,{size:"xs","aria-label":"Select all",checked:Ae,indeterminate:!Ae&&y.size>0,onChange:()=>bt()})}),e("th",{children:"name"}),e("th",{className:"AssetBrowser__table__modifiedCol",children:"modified"}),e("th",{className:"AssetBrowser__table__actionsCol"})]})}),e("tbody",{children:Y.map(s=>s.type==="folder"?e("tr",{className:"AssetBrowser__row AssetBrowser__row--folder",onClick:()=>P(oe(s.parent,s.name)),children:[ae&&e("td",{className:"AssetBrowser__checkboxCell",onClick:u=>u.stopPropagation(),children:e(L,{size:"xs","aria-label":`Select ${s.name}`,checked:y.has(s.id),onChange:()=>$e(s)})}),e("td",{children:e("div",{className:"AssetBrowser__nameCell",children:[e("div",{className:"AssetBrowser__thumb",children:e(De,{size:24,stroke:"1.5"})}),e("div",{className:"AssetBrowser__nameCell__text",children:[e("div",{className:"AssetBrowser__nameCell__name",children:s.name}),e(ut,{asset:s,folder:l,searching:Q,onNavigate:P})]})]})}),e("td",{children:e(gt,{asset:s})}),e("td",{onClick:u=>u.stopPropagation(),children:e("div",{className:"AssetBrowser__actionsCell",children:t.mode==="manage"&&J&&e(k,{shadow:"sm",position:"bottom",placement:"end",control:e(se,{size:"sm",children:e(Ne,{size:16})}),children:[e(k.Item,{icon:e(ze,{size:14}),onClick:()=>z(s),children:"Rename"}),e(k.Item,{icon:e(he,{size:14}),onClick:()=>R([s]),children:"Move"}),e(k.Item,{color:"red",icon:e(O,{size:14}),onClick:()=>$([s]),children:"Delete"})]})})})]},s.id):e("tr",{className:"AssetBrowser__row AssetBrowser__row--file",onClick:()=>{t.mode==="pick"?wt(s):p(s)},children:[ae&&e("td",{className:"AssetBrowser__checkboxCell",onClick:u=>u.stopPropagation(),children:e(L,{size:"xs","aria-label":`Select ${s.name}`,checked:y.has(s.id),onChange:()=>$e(s)})}),e("td",{children:e("div",{className:"AssetBrowser__nameCell",children:[e(mt,{file:s.file,size:36}),e("div",{className:"AssetBrowser__nameCell__text",children:[e("div",{className:"AssetBrowser__nameCell__name",children:[s.name,!!(s.file?.width&&s.file?.height)&&e("span",{className:"AssetBrowser__nameCell__dimens",children:[" ","(",s.file.width,"x",s.file.height,")"]})]}),e(ut,{asset:s,folder:l,searching:Q,onNavigate:P})]})]})}),e("td",{children:e(gt,{asset:s})}),e("td",{onClick:u=>u.stopPropagation(),children:e("div",{className:"AssetBrowser__actionsCell",children:t.mode!=="pick"&&e(xt,{asset:s,canManage:J,onDetails:()=>p(s),onRename:()=>z(s),onMove:()=>R([s]),onDelete:()=>$([s])})})})]},s.id))})]})}),e(Bt,{opened:S,parent:l,onClose:()=>V(!1),onCreated:s=>{V(!1),P(oe(l,s))}}),W&&e(yt,{asset:W,onClose:()=>z(null),onRenamed:()=>{z(null),I(l)}}),X&&X.length>0&&e(Ct,{assets:X,onClose:()=>R(null),onMoved:()=>{R(null),I(l)}}),E&&E.length>0&&e(Mt,{assets:E,onClose:()=>$(null),onDeleted:()=>{$(null),I(l)}}),q&&q.length>0&&e(Ft,{assets:q,onClose:()=>c(null),onDone:()=>{c(null),I(l)}}),w&&e(ft,{asset:w,canManage:J,onClose:()=>p(null),onChanged:()=>I(l),onDeleted:()=>{p(null),I(l)}})]})}Te.Breadcrumbs=t=>{let o=Xe(t.folder),a=[{label:"Assets",path:""}];return o.forEach((l,r)=>{a.push({label:l,path:o.slice(0,r+1).join("/")})}),e("div",{className:"AssetBrowser__breadcrumbs",children:a.map((l,r)=>e("div",{className:"AssetBrowser__breadcrumbs__crumb",children:[r>0&&e(Fe,{className:"AssetBrowser__breadcrumbs__divider",size:14}),e("button",{className:fe("AssetBrowser__breadcrumbs__link",r===a.length-1&&"active"),disabled:r===a.length-1,onClick:()=>t.onNavigate(l.path),children:l.label})]},l.path))})};function xt(t){let o=t.asset;return e(k,{shadow:"sm",position:"bottom",placement:"end",control:e(se,{size:"sm",children:e(Ne,{size:16})}),children:[e(k.Item,{icon:e(nt,{size:14}),onClick:t.onDetails,children:"Details"}),e(k.Item,{icon:e(ue,{size:14}),onClick:()=>ve(o.file),children:"Copy URL"}),e(k.Item,{icon:e(ge,{size:14}),onClick:()=>we(o.file),children:"Download"}),t.canManage&&e(C,{children:[e(k.Item,{icon:e(ze,{size:14}),onClick:t.onRename,children:"Rename"}),e(k.Item,{icon:e(he,{size:14}),onClick:t.onMove,children:"Move"}),e(k.Item,{color:"red",icon:e(O,{size:14}),onClick:t.onDelete,children:"Delete"})]})]})}function ut(t){let o=t.asset;return!t.searching||o.parent===t.folder?null:e("button",{className:"AssetBrowser__nameCell__path",title:"Go to folder",onClick:a=>{a.stopPropagation(),t.onNavigate(o.parent)},children:["in ",Ke(o.parent,t.folder)]})}function gt(t){let o=t.asset.modifiedAt||t.asset.createdAt,a=t.asset.modifiedBy||t.asset.createdBy||"",l=o&&typeof o.toMillis=="function"?o.toMillis():0;return e("div",{className:"AssetBrowser__modifiedCell",children:[a&&e(_t,{email:a,size:20}),e("span",{children:l?He(l):"\u2014"})]})}function Bt(t){let[o,a]=i(""),[l,r]=i(!1);async function _(){r(!0),await M(async()=>{let d=await Qe(t.parent,o);a(""),t.onCreated(d.name)}),r(!1)}return e(U,{opened:t.opened,onClose:t.onClose,title:"New folder",size:"sm",centered:!0,children:e("form",{className:"AssetBrowser__modalForm",onSubmit:d=>{d.preventDefault(),_()},children:[e(j,{"data-autofocus":!0,placeholder:"Folder name",value:o,onChange:d=>a(d.currentTarget.value)}),e(g,{type:"submit",color:"dark",loading:l,disabled:!o,children:"Create"})]})})}function yt(t){let[o,a]=i(t.asset.name),[l,r]=i(!1);async function _(){r(!0),await M(async()=>{await Ze(t.asset,o),t.onRenamed()}),r(!1)}return e(U,{opened:!0,onClose:t.onClose,title:`Rename ${t.asset.type}`,size:"sm",centered:!0,children:e("form",{className:"AssetBrowser__modalForm",onSubmit:d=>{d.preventDefault(),_()},children:[e(j,{"data-autofocus":!0,value:o,onChange:d=>a(d.currentTarget.value)}),e(g,{type:"submit",color:"dark",loading:l,disabled:!o,children:"Rename"})]})})}function Ct(t){let o=t.assets,[a,l]=i(o[0]?.parent||""),[r,_]=i([]),[d,x]=i(!0),[v,m]=i(!1);T(()=>{x(!0),M(async()=>{let n=await ke(a);_(n.filter(f=>f.type==="folder"))}).then(()=>x(!1))},[a]);let B=o.filter(n=>n.type==="folder").map(n=>oe(n.parent,n.name));function h(n){return B.some(f=>n===f||n.startsWith(`${f}/`))}async function F(){m(!0);let n=[],f=0;for(let N of o)try{await et(N,a),f+=1}catch(S){console.error(`failed to move ${N.name}:`,S),n.push(N.name)}m(!1),n.length>0&&b({title:"Move failed",message:`Failed to move: ${n.join(", ")}`,color:"red",autoClose:!1}),f>0&&b({message:o.length===1?`Moved "${o[0].name}" to ${a||"Assets"}.`:`Moved ${f} item(s) to ${a||"Assets"}.`,color:"green"}),t.onMoved()}return e(U,{opened:!0,onClose:t.onClose,title:o.length===1?`Move "${o[0].name}"`:`Move ${o.length} items`,size:"md",centered:!0,children:e("div",{className:"AssetBrowser__moveModal",children:[e(Te.Breadcrumbs,{folder:a,onNavigate:l}),e("div",{className:"AssetBrowser__moveModal__folders",children:d?e(te,{color:"gray",size:"sm"}):r.length===0?e("div",{className:"AssetBrowser__moveModal__empty",children:"No subfolders."}):r.map(n=>{let f=oe(n.parent,n.name);return e("button",{className:"AssetBrowser__moveModal__folder",disabled:h(f),onClick:()=>l(f),children:[e(De,{size:16,stroke:"1.5"}),e("span",{children:n.name}),e(Fe,{size:14})]},n.id)})}),e(g,{color:"dark",fullWidth:!0,loading:v,disabled:o.every(n=>n.parent===a),onClick:()=>F(),children:"Move here"})]})})}var kt=20;function Mt(t){let o=t.assets,[a,l]=i(!1),[r,_]=i(null),d=o.filter(m=>m.type==="file"),x=o.some(m=>m.type==="folder");T(()=>{d.length===0||d.length>kt||Promise.all(d.map(m=>_e(m.id))).then(m=>{let B=new Set(m.flat().map(h=>h.id));_(B.size)}).catch(()=>_(null))},[o.map(m=>m.id).join(",")]);async function v(){l(!0);let m=[],B=0;for(let h of o)try{await de(h),B+=1}catch(F){console.error(`failed to delete ${h.name}:`,F),m.push(h.name)}l(!1),m.length>0&&b({title:"Delete failed",message:`Failed to delete: ${m.join(", ")}. Note that folders must be empty before they can be deleted.`,color:"red",autoClose:!1}),B>0&&b({message:o.length===1?`Deleted "${o[0].name}".`:`Deleted ${B} item(s).`,color:"green"}),t.onDeleted()}return e(U,{opened:!0,onClose:t.onClose,title:o.length===1?`Delete ${o[0].type}?`:`Delete ${o.length} items?`,size:"sm",centered:!0,children:e("div",{className:"AssetBrowser__deleteModal",children:[e("div",{className:"AssetBrowser__deleteModal__text",children:["Are you sure you want to delete"," ",o.length===1?e("b",{children:o[0].name}):e("b",{children:[o.length," items"]})," ","from the asset manager?",d.length>0&&e(C,{children:[" ","The underlying files are not deleted from GCS, and docs that currently use the assets keep their copy of the files."]}),x&&e(C,{children:" Folders must be empty before they can be deleted."})]}),r!==null&&r>0&&e("div",{className:"AssetBrowser__deleteModal__warning",children:[o.length===1?"This asset is":"These assets are"," ","currently used in ",r," doc(s). Those docs will no longer receive updates when the asset changes."]}),e("div",{className:"AssetBrowser__deleteModal__buttons",children:[e(g,{variant:"default",onClick:t.onClose,disabled:a,children:"Cancel"}),e(g,{color:"red",loading:a,onClick:()=>v(),children:"Delete"})]})]})})}function Ft(t){let o=t.assets,[a,l]=i(!1);async function r(){l(!0);let _=[],d=0;for(let x of o)try{let v=x.file,m=await ce(x,!0);await me(m,{previousFile:v}),d+=1}catch(v){console.error(`failed to disable alt text for ${x.name}:`,v),_.push(x.name)}l(!1),_.length>0&&b({title:"Failed to disable alt text",message:`Failed to update: ${_.join(", ")}`,color:"red",autoClose:!1}),d>0&&b({message:`Disabled alt text for ${d} file(s).`,color:"green"}),t.onDone()}return e(U,{opened:!0,onClose:t.onClose,title:"Disable alt text?",size:"sm",centered:!0,children:e("div",{className:"AssetBrowser__deleteModal",children:[e("div",{className:"AssetBrowser__deleteModal__text",children:["Disable alt text for ",e("b",{children:[o.length," file(s)"]}),"? The alt text input is hidden in docs that use these assets and their embedded alt text is cleared. Alt text can be re-enabled per asset from its details."]}),e("div",{className:"AssetBrowser__deleteModal__buttons",children:[e(g,{variant:"default",onClick:t.onClose,disabled:a,children:"Cancel"}),e(g,{color:"dark",loading:a,onClick:()=>r(),children:"Disable alt text"})]})]})})}export{Te as a};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as y,f as L}from"./chunk-KRNQ6L35.js";import{b as R,c as l,g as d,h as C,n as m,o as x,q as _,w as T,x as p}from"./chunk-VD6G5NV4.js";function f(n,o){let t=n.translationLanguages||{},a=String(o).toLowerCase();for(let[e,s]of Object.entries(t))if(e.toLowerCase()===a)return s;return o}function b(n,o){let t=[];for(let a of o){let e=f(n,a);t.includes(e)||t.push(e)}return t}function w(n,o){let t=n.locales||["en"],a=String(o).toLowerCase(),e=[];for(let s of t)(String(s).toLowerCase()===a||f(n,s).toLowerCase()===a)&&e.push(s);return e}function O(n,o,t){for(let a of w(n,t)){let e=o[a];if(typeof e=="string"&&e)return e}return""}function A(){let n=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db;return R(o,"Projects",n,"Translations")}async function B(n){let o=A(),t=n?.tags?d(o,C("tags","array-contains-any",n.tags)):d(o),a=await x(t),e={};return a.forEach(s=>{let r=s.id;e[r]=s.data()}),e}async function D(n){let o=window.__ROOT_CTX.rootConfig.projectId,t=window.firebase.db,a=l(t,"Projects",o,"Translations",n);return(await m(a)).data()}async function G(n,o){let t=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,e=l(a,"Projects",t,"Translations",n),s={};for(let r in o){if(r==="tags"){s.tags=o.tags;continue}for(let i of S(r))s[i]=o[r]}console.log("updating translations: ",s),await _(e,s),L("translations.save",{metadata:{hash:n},throttle:5*y.minute,throttleId:n})}async function N(n,o){let t=o?.mode??"replace",a=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,s=500;for(let r=0;r<n.length;r+=s){let i=p(e);n.slice(r,r+s).forEach(({hash:g,tags:u})=>{let c=l(e,"Projects",a,"Translations",g);t==="union"?i.update(c,{tags:T(...u)}):i.update(c,{tags:u})}),await i.commit()}}async function P(n){return k(I(n))}async function k(n){let t=new TextEncoder().encode(n),a=await crypto.subtle.digest("SHA-1",t);return Array.from(new Uint8Array(a)).map(r=>r.toString(16).padStart(2,"0")).join("")}function I(n){return String(n).trim().split(`
|
|
2
|
-
`).map(t=>v(t)).join(`
|
|
3
|
-
`)}function v(n){return String(n).trimEnd().replace(/ $/,"")}var j=new Map;function M(n){let o=j.get(n);if(o)return o;let t=n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,"."),a=new RegExp(`^${t}$`,"i");return j.set(n,a),a}function W(n){return(window.__ROOT_CTX.excludeLocalesFromTranslations||[]).some(t=>M(t).test(n))}function J(n){let t=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"];for(let a of t)if(String(a).toLowerCase()===n.toLowerCase())return a;return null}function K(n){let o=window.__ROOT_CTX.rootConfig.i18n||{};return f(o,n)}function Q(n){let o=window.__ROOT_CTX.rootConfig.i18n||{};return b(o,n)}function S(n){let o=window.__ROOT_CTX.rootConfig.i18n||{};return w(o,n)}function V(n,o){let t=window.__ROOT_CTX.rootConfig.i18n||{};return O(t,n,o)}async function Y(n,o){let t=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,e=500,s=await Promise.all(n.map(async r=>({hash:await P(r.source),locales:r.locales,source:r.source})));for(let r=0;r<s.length;r+=e){let i=p(a),h=s.slice(r,r+e);for(let g of h){let u=l(a,"Projects",t,"Translations",g.hash),c={source:g.source};for(let[E,X]of Object.entries(g.locales))for(let F of S(E))c[F]=I(X);o?.tags?.length&&(c.tags=T(...o.tags)),i.set(u,c,{merge:!0})}await i.commit()}L("translations.batch_save",{metadata:{count:n.length}})}export{A as a,B as b,D as c,G as d,N as e,P as f,I as g,W as h,J as i,K as j,Q as k,S as l,V as m,Y as n};
|
|
File without changes
|