PageSourceSearch

https://quallie.ai/_next/static/chunks/8271.451b5d0f6881a756.js

js quallie.ai collected 2026-10-05 01:09:03 UTC 45,838 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8271],{1642:()=>{},18271:(e,t,n)=>{"use strict";n.r(t),n.d(t,{blockPosition:()=>e8,default:()=>e7,pendingRangeAt:()=>e5,pendingRangeFor:()=>e3});var l=n(95155),r=n(12115),a=n(10478),o=n(28661),i=n(65531),s=n(656);n(50429),n(1642),n(57349);var c=n(62928),d=n(27e3),u=n(85853),p=n(10685),f=n(31166),m=n(60945),h=n(7831),x=n(12801),b=n(78079),g=n(97787);function v(e,t){let n=new Map(e.map(e=>[e.id,e]));for(let e of t){var l;let t=null==(l=e.participant_name)?void 0:l.trim();!t||n.has(e.participant_id)||n.set(e.participant_id,{id:e.participant_id,name:t})}return[...n.values()].sort((e,t)=>e.name.localeCompare(t.name))}function y(e){var t;return null!=(t=e.participants)?t:e.images}let k=["upload","stock","participants"],j={upload:"Upload",stock:"Stock photos",participants:"Participants",link:"Link"};function C(e){let{reportId:t,onPick:n,onClose:a,sources:o=k}=e,i=o.length>0?o:k,[s,c]=(0,r.useState)(i[0]),[p,C]=(0,r.useState)(!1),[N,I]=(0,r.useState)(null),[S,A]=(0,r.useState)(null),[E,P]=(0,r.useState)(""),[M,T]=(0,r.useState)(""),[L,R]=(0,r.useState)([]),[_,B]=(0,r.useState)(!1),[F,O]=(0,r.useState)(!1),[z,U]=(0,r.useState)([]),[q,D]=(0,r.useState)(0),[W,H]=(0,r.useState)(!1),[Q,J]=(0,r.useState)(!1),[V,X]=(0,r.useState)(""),[Y,G]=(0,r.useState)(""),[K,$]=(0,r.useState)(null),[Z,ee]=(0,r.useState)([]);(0,r.useEffect)(()=>A(null),[s]);let et=(0,r.useRef)(0);(0,r.useEffect)(()=>{if("participants"!==s)return;let e=++et.current;return H(!0),J(!1),A(null),(0,x.Lp)(t,{participantId:null!=K?K:void 0,q:Y||void 0}).then(t=>{et.current===e&&(U(t.images),D(t.omitted),ee(e=>v(e,y(t))),J(!0),H(!1))},t=>{et.current===e&&(U([]),D(0),A((0,h.u1)(t,"Those photos could not be loaded.")),H(!1))}),()=>{et.current+=1}},[s,t,K,Y]);let en=async()=>{let e=et.current;H(!0),A(null);try{let n=await (0,x.Lp)(t,{participantId:null!=K?K:void 0,q:Y||void 0,offset:z.length});if(et.current!==e)return;U(e=>[...e,...n.images]),D(n.omitted),ee(e=>v(e,y(n)))}catch(t){if(et.current!==e)return;A((0,h.u1)(t,"Those photos could not be loaded."))}finally{et.current===e&&H(!1)}},el=async e=>{C(!0),A(null);try{let{url:l,caption:r}=await (0,x._I)(t,e);n(l,{caption:r})}catch(e){A((0,h.u1)(e,"That photo could not be added."))}finally{C(!1)}},er=async e=>{C(!0),I(0),A(null);try{(0,g.Dr)(e),n(await (0,b.z)(t,e,I))}catch(e){A((0,h.u1)(e,"That file could not be uploaded."))}finally{C(!1),I(null)}},ea=async()=>{let e=M.trim();if(e){B(!0),A(null);try{let{results:n}=await (0,x._S)(t,e);R(n),O(!0)}catch(e){A((0,h.u1)(e,"That search could not be completed."))}finally{B(!1)}}},eo=async e=>{C(!0),A(null);try{let{url:l}=await (0,x.zm)(t,e);n(l)}catch(e){A((0,h.u1)(e,"That photo could not be added."))}finally{C(!1)}};return(0,l.jsx)(u.A,{isOpen:!0,onClose:a,slotsUnpadded:!0,bodyFill:!0,
1className:"max-w-[760px] w-[760px] !h-[580px]",header:(0,l.jsxs)("div",{className:"flex h-14 flex-shrink-0 items-center gap-3 border-b border-border px-5",children:[(0,l.jsx)("h2",{className:"flex-1 text-[15px] font-semibold leading-tight text-foreground",children:"Insert image"}),(0,l.jsx)("button",{type:"button","aria-label":"Close",onClick:a,className:"flex h-8 w-8 items-center justify-center rounded-md text-muted hover:bg-offwhite",children:(0,l.jsx)(d.US,{size:"md"})})]}),footer:(0,l.jsxs)("div",{className:"flex h-16 flex-shrink-0 items-center justify-between border-t border-border bg-surface px-4",children:[(0,l.jsx)("div",{className:"text-[13px] font-medium text-muted",children:S&&"participants"!==s?(0,l.jsx)("span",{className:"text-danger",children:S}):"stock"===s?(0,l.jsxs)("span",{children:["Photos provided by"," ",(0,l.jsx)("a",{href:"https://www.pexels.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold text-accent hover:underline",children:"Pexels"})]}):null!==N?"Uploading ".concat(Math.round(100*N),"%"):""}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(f.A,{variant:"secondary",onClick:a,children:"Cancel"}),"link"===s?(0,l.jsx)(f.A,{variant:"primary",disabled:!E.trim(),onClick:()=>{let e=E.trim();if(!/^https?:\/\//i.test(e))return void A("Enter a link that starts with http:// or https://");n(e)},children:"Insert"}):null]})]}),children:(0,l.jsxs)("div",{className:"flex flex-1 min-h-0",children:[(0,l.jsx)("div",{className:"w-[204px] flex-shrink-0 overflow-y-auto border-r border-border bg-surface-hover px-2 py-3",children:(0,l.jsx)("div",{className:"pb-1",children:i.map(e=>(0,l.jsx)("button",{type:"button",onClick:()=>c(e),"aria-pressed":s===e,className:"mb-px flex w-full items-center rounded-md px-2.5 py-1.5 text-left text-[12px] leading-tight transition-colors ".concat(s===e?"bg-info-surface font-semibold text-accent":"font-medium text-foreground hover:bg-border/50"),children:j[e]},e))})}),(0,l.jsx)("div",{className:"stock"===s||"participants"===s?"flex flex-1 min-w-0 flex-col overflow-hidden":"flex flex-1 min-w-0 items-center justify-center p-8",children:"upload"===s?(0,l.jsxs)("label",{className:"flex h-48 w-full cursor-pointer flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-border text-[13px] text-muted hover:bg-surface-hover ".concat(p?"pointer-events-none opacity-60":""),children:[(0,l.jsx)("span",{className:"font-medium text-foreground",children:p?"Uploading...":"Choose a picture"}),(0,l.jsx)("span",{children:"PNG, JPEG, GIF or WebP"}),(0,l.jsx)("input",{type:"file",accept:g.W0.join(","),className:"hidden",disabled:p,onChange:e=>{var t;let n=null==(t=e.target.files)?void 0:t[0];e.target.value="",n&&er(n)}})]}):"stock"===s?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("form",{className:"flex flex-shrink-0 gap-2 px-6 pt-6",onSubmit:e=>{e.preventDefault(),ea()},children:[(0,l.jsx)(m.A,{name:"stockQuery",type:"search",value:M,onChange:T,placeholder:"Search stock photos",disabled:_}),(0,l.jsx)(f.A,{type:"submit",variant:"secondary",disabled:!M.trim()||_,children:_?"Searching...":"Search"})]}),(0,l.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 pb-6",children:F&&!_&&0===L.length?(0,l.jsx)("p",{className:"mt-4 text-[13px] text-muted",children:"No photos found. Try a different search."}):(0,l.jsx)("div",{className:"mt-4 grid grid-cols-3 gap-3",children:L.map(e=>(0,l.jsx)("button",{type:"button",disabled:p,onClick:()=>eo(e.stockId),className:"aspect-square overflow-hidden rounded-lg border border-border ".concat(p?"pointer-events-none opacity-60":"hover:opacity-90"),children:(0,l.jsx)("img",{src:e.thumbUrl,alt:e.description,loading:"lazy",className:"h-full w-full object-cover"})},e.stockId))})})]}):"participants"===s?(0,l.jsx)(w,{images:z,omitted:q,loading:W,loaded:Q,busy:p,error:S,query:V,onQueryChange:X,onSubmitQuery:()=>G(V.trim()),participants:Z,participantId:K,onPickParticipant:$,filtered:null!=K||Y.length>0,onPickImage:el,onLoadMore:en}):(0,l.jsxs)("div",{className:"w-full",children:[(0,l.jsx)(m.A,{name:"imageUrl",type:"text",value:E,onChange:P,placeholder:"https://"}),(0,l.jsx)("p",{className:"mt-2 text-[12px] text-faint",children:"Paste a link to a picture. It loads from wherever it is hosted."})]})})]})})}function w(e){var t,n,a;let{images:o,omitted:i,loading:s,loaded:c,busy:u,error:h,query:x,onQueryChange:b,onSubmitQuery:g,participants:v,participantId:y,onPickParticipant:k,filtered:j,onPickImage:C,onLoadMore:w}=e,[N,I]=(0,r.useState)(!1),[S,A]=(0,r.useState)("");(0,r.useEffect)(()=>{N||A("")},[N]);let E=y&&null!=(n=null==(t=v.find(e=>e.id===y))?void 0:t.name)?n:null,P=!(a={loaded:c,imageCount:o.length,filtered:j}).loaded||a.imageCount>0?"none":a.filtered?"no-match":"project-empty";return(0,l.jsxs)("div",{className:"flex flex-1 min-h-0 flex-col",children:[(0,l.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-2 border-b border-border px-4 pt-3 pb-2.5",children:[(0,l.jsxs)(p.Ay,{open:N,onOpenChange:I,placement:"bottom-start",role:"dialog","aria-label":"Filter by participant",undoScope:"own",panelClassName:"w-64 roun
1ded-lg border border-border bg-surface p-2 shadow-lg",trigger:(0,l.jsxs)("button",{type:"button","aria-haspopup":"dialog","aria-expanded":N,onClick:()=>I(e=>!e),className:"inline-flex h-9 items-center gap-1.5 rounded-full border px-3 text-[12px] transition-colors ".concat(y?"border-accent bg-info-surface font-semibold text-accent":"border-border bg-surface font-medium text-foreground hover:bg-surface-hover"),children:[(0,l.jsx)(d.zm,{size:"sm"}),(0,l.jsx)("span",{children:"Participant"}),y&&E?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("span",{className:"text-accent",children:"\xb7"}),(0,l.jsx)("span",{className:"max-w-[120px] truncate",children:E}),(0,l.jsx)("span",{role:"button",tabIndex:0,"aria-label":"Clear participant filter",onClick:e=>{e.stopPropagation(),k(null)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),e.stopPropagation(),k(null))},className:"ml-0.5 inline-flex h-4 w-4 items-center justify-center rounded-full bg-accent-surface",children:(0,l.jsx)(d.US,{className:"h-2.5 w-2.5"})})]}):null]}),children:[(0,l.jsx)(m.A,{name:"participantMenuSearch",type:"search",value:S,onChange:A,placeholder:"Find a participant"}),(0,l.jsx)("div",{className:"mt-2 max-h-56 overflow-y-auto",children:(function(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)):[...e]})(v,S).map(e=>(0,l.jsx)("button",{type:"button",onClick:()=>{k(e.id),I(!1)},className:"flex w-full items-center rounded-md px-2 py-1.5 text-left text-[12px] font-medium text-foreground hover:bg-surface-hover",children:(0,l.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.name})},e.id))})]}),(0,l.jsxs)("form",{className:"flex flex-1 gap-2",onSubmit:e=>{e.preventDefault(),g()},children:[(0,l.jsx)(m.A,{name:"entryImageQuery",type:"search",value:x,onChange:b,placeholder:"Search participant photos"}),(0,l.jsx)(f.A,{type:"submit",variant:"secondary",disabled:s,children:s?"Searching...":"Search"})]})]}),(0,l.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:[h?(0,l.jsx)("p",{role:"alert",className:"mb-3 text-[13px] font-medium text-danger",children:h}):null,"project-empty"===P?(0,l.jsx)("p",{className:"text-[13px] text-muted",children:"This project has no participant photos yet."}):"no-match"===P?(0,l.jsx)("p",{className:"text-[13px] text-muted",children:"No photos matched. Try a different search."}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"grid grid-cols-3 gap-3",children:o.map(e=>{let t=function(e){var t,n,l;let r=function(e){var t,n,l,r;let a=null!=(l=null==(t=e.participant_name)?void 0:t.trim())?l:"",o=null!=(r=null==(n=e.task_name)?void 0:n.trim())?r:"";return a?o?"".concat(a).concat(" \xb7 ").concat(o):a:""}(e);if(r)return r;let a=null==(t=e.file_name)?void 0:t.trim();if(a)return a;let o=null!=(l=null==(n=e.description)?void 0:n.replace(/\s+/g," ").trim())?l:"";return o.length>48?"".concat(o.slice(0,48).trimEnd(),"..."):o||"Participant photo"}(e);return(0,l.jsxs)("button",{type:"button",disabled:u,onClick:()=>C(e.entry_id),className:"flex flex-col overflow-hidden rounded-lg border border-border text-left ".concat(u?"pointer-events-none opacity-60":"hover:opacity-90"),children:[(0,l.jsx)("span",{className:"block aspect-square w-full bg-surface-hover",children:e.thumb_url?(0,l.jsx)("img",{src:e.thumb_url,alt:t,loading:"lazy",className:"h-full w-full object-cover"}):null}),(0,l.jsx)("span",{className:"block truncate px-2 py-1.5 text-[12px] font-medium text-foreground",children:t})]},e.entry_id)})}),i>0?(0,l.jsx)("div",{className:"mt-4 flex justify-center",children:(0,l.jsx)(f.A,{variant:"secondary",disabled:s,onClick:w,children:s?"Loading...":"Show more"})}):null]})]})]})}var N=n(22454),I=n(37684),S=n(20808),A=n(62025);let E=[{id:"library",label:"Quallie.Ai clips"},{id:"upload",label:"Upload"},{id:"embed",label:"Embed link"}];function P(e){let{projectId:t,reportId:n,onInsert:a,onClose:o,mode:i="insert"}=e,[s,c]=(0,r.useState)("library"),[p,b]=(0,r.useState)(new Set),[v,y]=(0,r.useState)(""),[k,j]=(0,r.useState)(!1),[C,w]=(0,r.useState)(null),[P,M]=(0,r.useState)(null),{data:T,isLoading:L,error:R}=(0,N.I)({queryKey:S.qk.reportClipPicker(t),queryFn:()=>(0,h.nr)("/projects/".concat(t,"/clips/grid?page=1&page_size=500")),staleTime:3e4}),_=(0,r.useMemo)(()=>{var e;return(null!=(e=null==T?void 0:T.sections)?e:[]).flatMap(e=>{var t;return null!=(t=e.clips)?t:[]})},[T]),B=(0,r.useMemo)(()=>L?[]:_.filter(e=>"COVER_SLIDE"!==e.kind&&!e.parent_reel_id),[_,L]),F=(0,r.useMemo)(()=>{var e;return(null!=(e=null==T?void 0:T.sections)?e:[]).map(e=>({id:e.id,name:e.name}))},[T]);(0,r.useEffect)(()=>M(null),[s]);let O=async e=>{j(!0),w(0),M(null);try{(0,g.C3)(e);let{url:t,contentType:l}=await (0,x.WK)(n,e,w);a([{type:function(e){let t=(e||"").split(";")[0].trim().toLowerCase();return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"file"}(l),props:{url:t}}])}catch(e){M((0,h.u1)(e,"That file could not be uploaded."))}finally{j(!1),w(null)}},z=(0,l.jsxs)("div",{className:"pb-1",children:[E.map(e=>(0,l.jsx)("button",{type:"button",onClick:()=>c(e.id),"aria-pressed":s===e.id,className:"mb-px flex w-full items-center rounded-md px-2.5 py-1.5 text-left text-[12px] leading-tight transition-colors ".concat(s===e.id?"bg-info-surface font-semibold text-accent":"font-medium text-foreground hover:bg-border/50"),children:e.label},e.id)),(0,l.jsx)("div",{className:"my-2 h-px bg-border"})]});return(0,l.jsx)(u.A,{isOpen:!0,onClose:o,slotsUnpadded:!0,bodyFill:!0,
1className:"max-w-[760px] w-[760px] !h-[580px]",header:(0,l.jsxs)("div",{className:"flex h-14 flex-shrink-0 items-center gap-3 border-b border-border px-5",children:[(0,l.jsx)("h2",{className:"flex-1 text-[15px] font-semibold leading-tight text-foreground",children:"Insert clips"}),(0,l.jsx)("button",{type:"button","aria-label":"Close",onClick:o,className:"flex h-8 w-8 items-center justify-center rounded-md text-muted hover:bg-offwhite",children:(0,l.jsx)(d.US,{size:"md"})})]}),footer:(0,l.jsxs)("div",{className:"flex h-16 flex-shrink-0 items-center justify-between border-t border-border bg-surface px-4",children:[(0,l.jsx)("div",{className:"text-[13px] font-medium text-muted",children:P?(0,l.jsx)("span",{className:"text-danger",children:P}):"library"===s?0===p.size?"Select clips to insert":"".concat(p.size," clip").concat(1===p.size?"":"s"," selected"):null!==C?"Uploading ".concat(Math.round(100*C),"%"):""}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(f.A,{variant:"secondary",onClick:o,children:"Cancel"}),"library"===s?(0,l.jsx)(f.A,{variant:"primary",disabled:0===p.size,onClick:()=>{let e=B.filter(e=>p.has(e.id)).map(e=>(0,A.YT)(e));e.length>0&&a(e)},children:"replace"===i?"Replace":p.size?"Insert ".concat(p.size," clip").concat(1===p.size?"":"s"):"Insert clips"}):"embed"===s?(0,l.jsx)(f.A,{variant:"primary",disabled:!v.trim(),onClick:()=>{let e=v.trim();if(!/^https?:\/\//i.test(e))return void M("Enter a link that starts with http:// or https://");a([{type:"video",props:{url:e}}])},children:"Insert"}):null]})]}),children:"library"===s?(0,l.jsx)(I.A,{clips:B,sections:F,selected:p,onToggle:e=>b(t=>(function(e,t,n){if("replace"===n)return e.has(t)?new Set:new Set([t]);let l=new Set(e);return l.has(t)?l.delete(t):l.add(t),l})(t,e,i)),railHeader:z,badgeFor:e=>"REEL"===e.kind?"Reel":null,emptyMessage:L?"Loading clips...":"This project has no clips yet. Create clips from a transcript first.",gridError:R?"Clips could not be loaded. Close this dialog and try again.":null}):(0,l.jsxs)("div",{className:"flex flex-1 min-h-0",children:[(0,l.jsx)("div",{className:"w-[204px] flex-shrink-0 overflow-y-auto border-r border-border bg-surface-hover px-2 py-3",children:z}),(0,l.jsx)("div",{className:"flex flex-1 min-w-0 items-center justify-center p-8",children:"upload"===s?(0,l.jsxs)("label",{className:"flex h-48 w-full cursor-pointer flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-border text-[13px] text-muted hover:bg-surface-hover ".concat(k?"pointer-events-none opacity-60":""),children:[(0,l.jsx)("span",{className:"font-medium text-foreground",children:k?"Uploading...":"Choose a file"}),(0,l.jsx)("span",{children:"Video, audio, images and documents"}),(0,l.jsx)("input",{type:"file",accept:[...g.xo].join(","),className:"hidden",disabled:k,onChange:e=>{var t;let n=null==(t=e.target.files)?void 0:t[0];e.target.value="",n&&O(n)}})]}):(0,l.jsxs)("div",{className:"w-full",children:[(0,l.jsx)(m.A,{name:"embedUrl",type:"text",value:v,onChange:y,placeholder:"https://"}),(0,l.jsx)("p",{className:"mt-2 text-[12px] text-faint",children:"Paste a link to a video. It plays from wherever it is hosted."})]})})]})})}var M=n(11310),T=n(26327),L=n(46866),R=n(16514),_=n(27406),B=n(23779),F=n(70609),O=n(88744),z=n(50493),U=n(34772),q=n(82743),D=n(19591),W=n(6956);function H(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function Q(e){let{bands:t,onChangeSubscribe:n}=e,a=(0,r.useRef)(null),o=(0,r.useRef)(null),i=(0,r.useRef)(new Map),s=(0,r.useRef)(new Map),c=(0,r.useRef)(new Map),d=(0,r.useRef)(0),u=(0,r.useRef)(0),p=(0,r.useId)(),f=(0,r.useCallback)(()=>{let e=a.current,n=null==e?void 0:e.parentElement;if(!e||!n)return;let l=e.getBoundingClientRect().top,r=e.getBoundingClientRect().width,d=c.current,f=!1,m=new Set;for(let e of t){var h,x;let t=i.current.get(e.sectionId);if(!t)continue;m.add(e.sectionId);let a=n.querySelectorAll('[data-band-section="'.concat((x=e.sectionId,"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(x):x.replace(/["\\]/g,"\\$&")),'"]'));if(0===a.length){t.style.display="none";continue}t.style.display="";let o=a[0].getBoundingClientRect(),c=a[a.length-1].getBoundingClientRect().bottom-o.top;t.style.top="".concat(o.top-l,"px"),t.style.height="".concat(c,"px");let u=s.current.get(e.sectionId),p=!!(null==u?void 0:u.naturalWi
1dth),b=p?r*u.naturalHeight/u.naturalWidth:0;if(u&&p){let n=function(e){let{width:t,bandHeight:n,naturalWidth:l,naturalHeight:r}=e;if(!l||!r||!(t>0))return{top:0,short:!1};let a=t*r/l;return{top:Math.min(0,(n-a)/2),short:n-a>.5}}({width:r,bandHeight:"whole"===e.fit?Math.max(c,b):c,naturalWidth:u.naturalWidth,naturalHeight:u.naturalHeight});u.style.top="".concat(n.top,"px"),n.short?t.dataset.bandPhotoShort="":delete t.dataset.bandPhotoShort}if("whole"!==e.fit){d.delete(e.sectionId)&&(f=!0);continue}if(!p)continue;let g=null!=(h=d.get(e.sectionId))?h:0,v=function(e){let{needed:t,measured:n,applied:l}=e;return!Number.isFinite(t)||t<=0?0:Math.max(0,t-(n-l))}({needed:b,measured:c,applied:g});Math.abs(v-g)>.5&&(d.set(e.sectionId,v),f=!0)}for(let e of[...d.keys()])m.has(e)||(d.delete(e),f=!0);if(!f)return;let b=new Set(t.filter(e=>e.markerOnly).map(e=>e.sectionId));cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{o.current&&(o.current.textContent=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set,l=[],r='.report-band-doc[data-band-doc="'.concat(H(t),'"]');for(let[t,a]of e){if(a<=.5)continue;let e=a/2,o='[data-band-section="'.concat(H(t),'"]'),i=n.has(t)?"".concat(o,'[data-band-first="true"]'):"".concat(o,'[data-band-first="true"] + ').concat(o);l.push("".concat(r," ").concat(i,"{--band-grow-top:").concat(e,"px}")),l.push("".concat(r," ").concat(o,'[data-band-last="true"]{--band-grow-bottom:').concat(e,"px}"))}return l.join("\n")}(d,p,b))})},[t,p]),m=(0,r.useCallback)(()=>{cancelAnimationFrame(d.current),d.current=requestAnimationFrame(f)},[f]);(0,r.useLayoutEffect)(()=>{var e;let t=null==(e=a.current)?void 0:e.parentElement;if(!t)return;t.setAttribute("data-band-doc",p),f();let n=new ResizeObserver(()=>f());return n.observe(t),()=>{n.disconnect(),cancelAnimationFrame(d.current),cancelAnimationFrame(u.current)}},[f,p]);let h=(0,r.useRef)(f);return((0,r.useEffect)(()=>{h.current=f},[f]),(0,r.useEffect)(()=>{var e;null==(e=document.fonts)||e.ready.then(()=>h.current()).catch(()=>{})},[]),(0,r.useEffect)(()=>{0===t.length&&c.current.clear()},[t.length]),(0,r.useEffect)(()=>n(m),[n,m]),0===t.length)?null:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("style",{ref:o}),(0,l.jsx)("div",{ref:a,className:"report-band-layer","aria-hidden":"true",children:t.map(e=>(0,l.jsx)("div",{ref:t=>{t?i.current.set(e.sectionId,t):i.current.delete(e.sectionId)},className:"report-band-backdrop","data-band-fit":e.fit,"data-band-overlay":e.overlay,children:(0,l.jsx)("img",{ref:t=>{t?s.current.set(e.sectionId,t):s.current.delete(e.sectionId)},src:e.url,alt:"",draggable:!1,decoding:"async",onLoad:m})},e.sectionId))})]})}var J=n(48333),V=n(39734);function X(e){return(null==e?void 0:e.type)==="paragraph"&&Array.isArray(e.content)&&0===e.content.length}function Y(e,t){let n=(0,D.S)(e).find(e=>e.blockIds.includes(t));if(!n)return null;let l=n.blockIds,r=l.indexOf(t),a=X(e.find(e=>e.id===t)),o=a?l.slice(0,r):l.slice(0,r+1),i=l.slice(r+1),s=a?[t]:[],c=()=>({tone:n.tone,customColor:n.customColor,imageMediaId:n.imageMediaId,imageFit:n.imageFit,overlay:n.overlay,padding:n.padding});if(0===o.length)return null===n.sectionId?0===i.length?null:{removeIds:s,afterId:t,cap:c()}:i.length>0?{removeIds:s,afterId:i[i.length-1],cap:null}:{removeIds:s,afterId:n.sectionId,cap:null};return{removeIds:s,afterId:o[o.length-1],cap:i.length>0?c():null}}function G(e,t,n){if(!e.setTextCursorPosition)return;let l=t.slice(0,n).find(t=>{var n,l,r,a;return"sectionBreak"!==t.type&&(n=t.type,(null==(a=e.schema)||null==(r=a.blockSchema)||null==(l=r[n])?void 0:l.content)!=="none")});l&&e.setTextCursorPosition(l.id,"start")}function K(e,t,n){let l=Y(e.document,t);if(!l){if(X(e.document.find(e=>e.id===t))){let l=[];e.transact(()=>{l=e.insertBlocks(n,t,"after"),e.removeBlocks([t])}),G(e,l,n.length);return}G(e,e.insertBlocks(n,t,"after"),n.length);return}let r=[];e.transact(()=>{let t=l.cap?[...n,{type:"sectionBreak",props:l.cap}]:n;r=e.insertBlocks(t,l.afterId,"after"),l.removeIds.length>0&&e.removeBlocks(l.removeIds)}),G(e,r,n.length)}var $=n(21578);function Z(e){let{open:t,onCancel:n,onConfirm:r}=e;return(0,l.jsxs)(u.A,{isOpen:t,onClose:n,portal:!0,className:"max-w-sm",children:[(0,l.jsx)("h2",{className:"text-base font-semibold text-foreground",children:"Delete this section?"}),(0,l.jsx)("p",{className:"mt-2 text-sm text-muted",children:"Everything inside it goes too. You can undo this."}),(0,l.jsxs)("div",{className:"mt-6 flex justify-end gap-2",children:[(0,l.jsx)(f.A,{variant:"tertiary",size:"sm",onClick:n,children:"Cancel"}),(0,l.jsx)(f.A,{variant:"primary",size:"sm",onClick:r,children:"Delete"})]})]})}var ee=n(37737),et=n(6273),en=n(44413),el=n(93955),er=n(26649),ea=n(79917),eo=n(10718),ei=n(25574),es=n(20723),ec=n(21564),ed=n(31461),eu=n(997
176),ep=n(54047),ef=n(7329),em=n(23064),eh=n(32667),ex=n(69755);let eb=null;function eg(){return eb||(eb=new ed.E),eb}function ev(e){var t;let n=(0,r.useContext)(eu.v4),{data:l}=(0,N.I)({...(0,ef.xO)(),enabled:e&&!!n,retry:!1},null!=n?n:eg());return null!=(t=null==l?void 0:l.current_workspace_id)?t:null}async function ey(e,t){if(!e.row||!t)return{body:e.body,band:{...e.band,imageMediaId:""}};try{let{blocks:n,band:l}=await (0,em.P7)(t,e.row.id);return{body:n,band:l}}catch(e){return null}}var ek=n(3005),ej=n(44942),eC=n(54223);let ew={"--foreground":"#3a3837","--border":"#e5e7eb","--accent":"#0a7cff","--accent-foreground":"#ffffff","--canvas":"#ebf5ff","--canvas-border":"#ddeeff","--info-surface":"#ebf5ff","--muted":"#696a66","--surface":"#ffffff"},eN="flex-1 border-t border-dashed border-[#d6d3d1]",eI={paddingInline:"max(0px, 50cqw - var(--band-measure) / 2)"},eS={key:"blank-section",name:"Blank section",description:"An empty band to fill yourself",band:{},body:[],source:"builtin",row:null};function eA(e){let{catalogue:t,showComponents:n,onInsertBlank:a,onInsertPreset:o,onInsertLayout:i,busy:s=!1}=e,[c,d]=(0,r.useState)(!1),u=e=>{d(!1),e()};return(0,l.jsx)("div",{"data-add-section":"",style:eI,children:(0,l.jsx)("div",{className:"px-[50px]",children:(0,l.jsxs)("div",{className:"flex items-center gap-3 px-1 py-4",children:[(0,l.jsx)("span",{"aria-hidden":"true",className:eN}),(0,l.jsx)(p.Ay,{open:c,onOpenChange:d,placement:"bottom",role:"dialog","aria-label":"Add a section",wrapperClassName:"relative flex",panelClassName:"flex w-[min(42rem,calc(100vw-32px))] flex-col rounded-lg border border-neutral-200 bg-white p-4 text-neutral-900 shadow-lg",constrainHeight:!0,trigger:(0,l.jsx)("button",{type:"button",onClick:()=>d(!c),"data-test":"add-section",className:"flex h-[30px] shrink-0 items-center justify-center rounded-[999px] border border-solid border-[rgba(28,25,23,0.08)] bg-[rgba(255,255,255,0.96)] px-[14px] shadow-[0_1px_2px_rgba(28,25,23,0.06),0_4px_14px_rgba(28,25,23,0.08)] text-xs font-medium text-[#292524] hover:bg-[#f5f5f4] focus:outline-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#292524]",children:"+ Add section"}),children:(0,l.jsx)(eE,{catalogue:t,showComponents:n,busy:s,onInsertBlank:()=>u(a),onInsertPreset:e=>u(()=>o(e)),onInsertLayout:e=>u(()=>i(e))})}),(0,l.jsx)("span",{"aria-hidden":"true",className:eN})]})})})}function eE(e){let{catalogue:t,showComponents:n,busy:a,onInsertBlank:o,onInsertPreset:i,onInsertLayout:s}=e,c=function(e){let t=(0,r.useContext)(eu.v4),n=ev(e),{data:l,isLoading:a,error:o}=(0,N.I)({...(0,ep.Fq)(null!=n?n:""),enabled:e&&!!t&&null!==n},null!=t?t:eg());return{layouts:null!=l?l:[],isLoading:a,error:o}}(n);return(0,l.jsxs)("div",{"data-add-section-gallery":"",className:"flex min-h-0 flex-col",style:ew,children:[(0,l.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Add a section"}),(0,l.jsxs)("div",{"data-add-section-scroll":"",className:"mt-4 min-h-0 flex-1 space-y-6 overflow-y-auto",children:[(0,l.jsx)(ej.I6,{id:"sections",headingId:"add-section-group-sections",title:eC.Pg.title,subtitle:eC.Pg.subtitle,count:t.length+1,children:(0,l.jsxs)("ul",{className:eC.IA,children:[(0,l.jsx)(eC.sd,{entry:eS,busy:a,pending:!1,onApply:o}),t.map(e=>(0,l.jsx)(eC.sd,{entry:e,busy:a,pending:!1,onApply:()=>i(e)},e.key))]})}),n?(0,l.jsxs)(ej.I6,{id:"components",headingId:"add-section-group-components",title:eC.xJ.title,subtitle:eC.xJ.subtitle,count:c.layouts.length,children:[c.isLoading?(0,l.jsx)("div",{className:"flex justify-center py-8",children:(0,l.jsx)(ek.A,{})}):null,c.error?(0,l.jsx)("p",{className:"text-xs text-red-600",children:(0,h.u1)(c.error,"Could not load the component library.")}):null,c.isLoading||c.error||0!==c.layouts.length?null:(0,l.jsx)("p",{className:"py-8 text-center text-sm text-muted",children:"No components yet. Save a design you like and it will show up here."}),(0,l.jsx)("ul",{className:eC.IA,children:c.layouts.map(e=>(0,l.jsx)(eC.dC,{layout:e,busy:a,pending:!1,onApply:()=>s(e)},e.id))})]}):null]})]})}var eP=n(7993),eM=n(77571),eT=n(77173),eL=n(72890),eR=n(83380),e_=n(95779);function eB(){let[e,t]=(0,r.useState)(null);(0,r.useEffect)(()=>(0,e_.C)(t),[]);let n=()=>t(null);return(0,l.jsx)(u.A,{isOpen:null!==e,onClose:n,scrollable:!1,portal:!0,className:"max-w-5xl h-[90vh]",children:null!==e&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-shrink-0 items-start justify-between gap-3 border-b border-border px-4 py-3",children:[(0,l.jsx)("div",{className:"min-w-0 truncate text-sm font-semibold text-foreground",children:e.name}),(0,l.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-1",children:[(0,l.jsx)(eT.A,{label:"Download file",onClick:()=>{(0,eL.V)(e.url,e.name)},children:(0,l.jsx)(d.s3,{})}),(0,l.jsx)(eT.A,{label:"Close file",onClick:n,children:(0,l.jsx)(d.US,{})})]})]}),(0,l.jsx)("div",{className:"min-h-0 flex-1",children:(0,eR.Wz)(e.kind)?(0,l.jsx)(eM.K,{url:e.url,fileName:e.name,page:null,pageCount:null,chrome:"full"}):(0,l.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-4 px-6 text-center",children:[(0,l.jsx)("p",{className:"text-sm text-muted",children:"Preview isn't available for this file type"}),(0,l.jsx)(f.A,{variant:"secondary",onClick:()=>{(0,eL.V)(e.url,e.name)},children:"Download"})]})})]})})}
1var eF=n(27211),eO=n(8412),ez=n(21660),eU=n(38681),eq=n(32351),eD=n(8970);function eW(){let e=(0,i.h)(),t=(0,i.p)(ez.f),n=(0,r.useRef)(void 0),l=(0,r.useRef)(void 0),a=(0,r.useRef)(void 0),o=(0,r.useRef)(void 0);return(0,r.useEffect)(()=>{let r=t.store,i=()=>{if(!n.current)return;let e=o.current;n.current=void 0,l.current=void 0,o.current=void 0,(0,eD.l_)(void 0),e&&r.setState(()=>e)},s=t=>{if(!e.isEditable)return void i();if(n.current&&function(e){let t=e?1===e.nodeType?e:e.parentElement:null;return!!(null==t?void 0:t.closest(".bn-side-menu"))&&!t.closest("[data-report-cell-side-menu]")}(t.target))return;let o=function(e){try{let t=e.prosemirrorView;return(null==t?void 0:t.dom)?t:void 0}catch(e){return}}(e);if(!o)return void i();let s=function(e,t){for(let n of Array.from(e.dom.querySelectorAll(".report-columns"))){let l=n.closest('[data-node-type="blockContainer"]');if(!l||l.closest(".bn-editor")!==e.dom)continue;let r=l.getBoundingClientRect();if(t<r.top||t>r.bottom)continue;let a=l.getAttribute("data-id");if(a)return{blockId:a,rect:r,grid:n}}}(o,t.clientY);if(!s)return void i();let c=n.current,d=t.clientX;if(c&&c.rowBlockId===s.blockId){if(d<c.frontierX)c.frontierX=d;else if(d>c.frontierX+12)return void i()}else{if(!(d>=s.rect.left-64&&d<=s.rect.left+2)&&!function(e,t){let n=e.grid.getBoundingClientRect();if(t<n.left||t>n.right)return!1;for(let n of Array.from(e.grid.children)){let e=n.getBoundingClientRect();if(t>=e.left&&t<=e.right)return!1}return!0}(s,d)&&!(e=>{var t;let n=r.state;return!!n&&n!==a.current&&n.show&&(null==(t=n.block)?void 0:t.type)==="columns"&&n.block.id===e})(s.blockId))return void i();i(),n.current={rowBlockId:s.blockId,frontierX:d},(0,eD.l_)({rowBlockId:s.blockId})}((t,n)=>{var o,s,c;let d=e.getBlock(n.blockId);if(!d){let e=l.current;i(),e&&r.state===e&&r.setState(()=>({...e,show:!1}));return}let u=t.dom.firstElementChild;if(!u)return i();let p=u.getBoundingClientRect().x,f=l.current;f&&f===r.state&&f.block.id===d.id&&(o=f.referencePos,s=n.rect,o.x===p&&o.y===s.y&&o.width===s.width&&o.height===s.height)||(l.current=c={show:!0,referencePos:new DOMRect(p,n.rect.y,n.rect.width,n.rect.height),block:d},a.current=c,r.setState(()=>c))})(o,s)},c=()=>i(),d=r.subscribe(e=>{let{currentVal:t}=e,n=l.current;n&&t!==n&&(t!==a.current&&(o.current=t),r.setState(()=>n))});return document.addEventListener("mousemove",s,!0),window.addEventListener("scroll",c,!0),()=>{document.removeEventListener("mousemove",s,!0),window.removeEventListener("scroll",c,!0),d(),n.current=void 0,l.current=void 0,o.current=void 0,(0,eD.l_)(void 0)}},[e,t]),null}var eH=n(88757),eQ=n(21459);let eJ={display:"contents"};function eV(e){let t=(0,i.m)(ez.f,{selector:e=>null==e?void 0:e.block}),n=null==t?void 0:t.props,r=(null==t?void 0:t.type)==="quote"?(0,eq.Op)(null==n?void 0:n.size):void 0,a=(null==t?void 0:t.type)==="paragraph"?(0,eU.q4)(null==n?void 0:n.size):void 0,o=(0,eQ.Sq)(null==t?void 0:t.type,n);return(0,l.jsx)("div",{style:eJ,"data-quote-size":r,"data-paragraph-size":a,"data-size-step":o,children:(0,l.jsx)(s.pg,{...e,dragHandleMenu:eH.A})})}function eX(){return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.p4,{sideMenu:eV}),(0,l.jsx)(eW,{})]})}var eY=n(77268);let eG="Sections",eK=["section","preset","template"];function e$(){return[{type:"sectionBreak"},{type:"paragraph"}]}let eZ=new Map,e0=[...k,"link"],e1=["upload","stock"],e2=[...e1,"link"];function e3(e,t){return e?e5(e.state.selection,t):null}function e5(e,t){if(e.empty)return null;let n=e.$head;for(let r=1;r<=n.depth;r+=1){var l;let a=n.node(r);if("blockContainer"===a.type.name){if(a.attrs.id!==t||(null==(l=a.firstChild)?void 0:l.type.name)==="columns")return null;if((0,R.D)(a))return{kind:"block",from:n.before(r),to:n.after(r)};return{kind:"inline",from:e.from,to:e.to}}}return null}function e8(e,t){let n=e.firstChild;if(!n||"blockGroup"!==n.type.name)return null;let l=1,r=null;return n.forEach(e=>{let n=l;l+=e.nodeSize,null===r&&e.attrs.id===t&&(r=n)}),r}let e4=(0,l.jsx)("svg",{width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,l.jsx)("path",{d:"M21 11.5a8.38 8.38 0 0 1-9 8.4 8.5 8.5 0 0 1-3.8-.9L3 21l1.9-5.2A8.4 8.4 0 0 1 12 3.1a8.38 8.38 0 0 1 9 8.4Z"})}),e6=(0,l.jsxs)("svg",{width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,l.jsx)("path",{d:"M21 11.5a8.38 8.38 0 0 1-9 8.4 8.5 8.5 0 0 1-3.8-.9L3 21l1.9-5.2A8.4 8.4 0 0 1 12 3.1a8.38 8.38 0 0 1 9 8.4Z"}),(0,l.jsx)("circle",{cx:"12",cy:"9.8",r:"2"}),(0,l.jsx)("path",{d:"M8.6 15.4c.7-1.5 1.9-2.3 3.4-2.3s2.7.8 3.4 2.3"})]});function e7(e){var t;let{theme:n,mediaContext:u,editable:p,initialContent:f,onChange:m,onUploadFile:h,onUploadFileSilent:x,projectId:b,isTemplate:g=!1,pages:v,activePageId:y,onNavigatePage:k,backTo:j,onCreatePage:w,collaboration:I,seedDoc:S,seedContent:E,onReady:R,onSourcePanelOpenChange:H,workspaceFonts:X,fontBaseUrl:G,startComment:ed,commentAnchors:ep,commentsOpen:ef,commentComposerOpen:eb}=e;(0,r.useEffect)(()=>(function(e){function t(t){var n=e,l=t.target;let r=[];for(let e of Array.from(n.querySelectorAll("video, audio")))e===l||e.paused||(e.pause(),r.push(e))}return e.addEventListener("play",t,!0),()=>e.removeEventListener("play",t,!0)})(document),[]);let ek=null!=n?n:ei.bY,ej=(0,r.useMemo)(()=>
1{if(I||!f||0===f.length)return;let e=(0,z.c)(f,q.ZU,q.b0,c.Q_);return e.length>0?e:void 0},[f,I]),eC=(0,r.useRef)(null),ew=(0,r.useMemo)(()=>h?(0,eY.s)(h,()=>eC.current):void 0,[h]),eN=(0,i.i)((0,T.y)({schema:q.Qh,collaboration:I,initialContent:ej,uploadFile:ew,resolveFileUrl:async e=>(0,ei.aN)(e,u),resolveBandImage:e=>(0,ei.aN)(e,u),getEditor:()=>eC.current}),[null==I?void 0:I.fragment,null==I?void 0:I.provider,I?p:null]);(0,r.useEffect)(()=>{eC.current=eN},[eN]);let eI=!!I,eS=p&&eI,eE=(0,r.useCallback)(e=>{"undo"===e?eN.undo():eN.redo()},[eN]);(0,r.useEffect)(()=>{if(!eS)return;let e=e=>{let t=(0,_.ay)(e);t&&(0,_.jd)(e.target)&&(e.preventDefault(),eE(t))};return document.addEventListener("keydown",e,{capture:!0}),()=>document.removeEventListener("keydown",e,{capture:!0})},[eE,eS]),(0,r.useEffect)(()=>{if(m)return eN.onChange(e=>m(e.document),!1)},[eN,m]);let eM=(0,r.useRef)(null),[eT,eL]=(0,r.useState)([]),eR="editor"===u.kind?u.reportId:u.shareToken,e_=(0,r.useCallback)(e=>(0,ei.aN)(e,u),[u.kind,eR]);(0,r.useEffect)(()=>{let e=()=>{let e=(0,D.S)(eN.document),t=new Set,n=[];for(let l of e){if(null===l.sectionId||t.has(l.sectionId))continue;let e=(0,W.oH)(l,e_);e&&(t.add(l.sectionId),n.push({sectionId:l.sectionId,url:e,fit:l.imageFit,overlay:l.overlay,markerOnly:0===l.blockIds.length}))}let l=JSON.stringify(n);l!==eM.current&&(eM.current=l,eL(n))};return e(),eN.onChange(()=>e())},[eN,e_]);let ez=(0,r.useCallback)(e=>eN.onChange(()=>e()),[eN]),eU=(0,r.useRef)(!1);(0,r.useEffect)(()=>{if(S&&null!=E&&!eU.current){if((0,U.H6)(S).size>0){eU.current=!0;return}eU.current=!0,function(e,t,n,l,r){if((0,U.H6)(t).size>0||function(e){for(let t of[...e.share.keys()])if(t.startsWith("page:")&&e.getXmlFragment(t).length>0)return!0;return!1}(t))return;let a=(0,O._J)(n),o=new Map;for(let t of a.pages){let n=(0,z.c)(t.content,l,r,c.Q_);if(0!==n.length)try{(0,B.Mc)(e,n,new F.JA().getXmlFragment("trial")),o.set(t.id,n)}catch(e){console.error("[report seed] page ".concat(t.id," content could not be converted"),e)}}let i=new F.JA;i.transact(()=>{let t=(0,U.H6)(i),n=null;for(let s of a.pages){var l,r;let a=(0,U.Bq)(n,null);n=a;let c={title:s.title,order:a,color:null!=(l=s.color)?l:null,showInNav:null==(r=s.showInNav)||r},d=new F.T5;for(let[e,t]of Object.entries(c))d.set(e,t);t.set(s.id,d);let u=o.get(s.id);u&&(0,B.Mc)(e,u,(0,U.o3)(i,s.id))}}),F.QE(t,F.PR(i))}(eN,S,E,q.ZU,q.b0)}},[S,E,eN]);let eq=(0,r.useCallback)(()=>{try{let e=eN.prosemirrorView;return(null==e?void 0:e.dom)?e:null}catch(e){return null}},[eN]),eD=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{null!==eD.current&&clearTimeout(eD.current)},[]);let eW=(0,r.useCallback)(e=>{let t=eq();if(!t)return!1;let n=e8(t.state.doc,e);if(null===n)return!1;let l=t.nodeDOM(n);return l instanceof HTMLElement&&l.scrollIntoView({behavior:"smooth",block:"center"}),null!==eD.current&&clearTimeout(eD.current),(0,L.uD)(t,e),eD.current=setTimeout(()=>{eD.current=null,(0,L.uD)(eq(),null)},L.AP),!0},[eq]);(0,r.useEffect)(()=>{if(R)return R({project:e=>({version:2,pages:(0,U.t6)(e).map(t=>({id:t.id,title:t.title,color:t.color,showInNav:t.showInNav,content:(0,B.ud)(eN,(0,U.o3)(e,t.id))}))}),duplicatePage:(e,t,n)=>(function(e,t,n,l){let r=(0,O.v)((0,B.ud)(e,(0,U.o3)(t,n)));if(0===r.length||(0,U.o3)(t,l).length>0)return;let a=new F.JA;(0,B.Mc)(e,r,(0,U.o3)(a,l)),F.QE(t,F.PR(a))})(eN,e,t,n),revealBlock:eW}),()=>R(null)},[eN,R,eW]);let[eH,eQ]=(0,r.useState)(null),eJ=(0,r.useRef)(null),[eV,e5]=(0,r.useState)(!1),e7=(0,r.useRef)(null),e9=p&&(!!b||g),te=(0,r.useCallback)((e,t)=>{var n;if(!b)return void e([(0,A.YT)({id:""})]);eJ.current=e,eQ({mode:null!=(n=null==t?void 0:t.mode)?n:"insert"})},[b]),tt=(0,r.useCallback)(e=>{eQ(null);let t=eJ.current;eJ.current=null,null==t||t(e)},[]),tn="editor"===u.kind?u.reportId:"",[tl,tr]=(0,r.useState)(null),ta=(0,r.useRef)(null),to=(0,r.useCallback)((e,t)=>{var n;ta.current=e,tr({allowLink:null!=(n=null==t?void 0:t.allowLink)&&n})},[]),ti=(0,r.useCallback)((e,t)=>{tr(null);let n=ta.current;ta.current=null,null==n||n(e,t)},[]),ts=(0,r.useCallback)(()=>{tr(null),ta.current=null},[]),tc=function(e){let t=(0,r.useContext)(eu.v4),n=ev(e),{data:l}=(0,N.I)({...(0,em.WL)(n),enabled:e&&!!t&&null!==n},null!=t?t:eg());return(0,r.useMemo)(()=>{var e;return e=null!=l?l:[],(0,ex.QG)(ex.vQ,e)},[l])}(p),td=(0,r.useCallback)(async(e,t)=>{let n=await ey(e,tn);if(!n)return;let l=function(e,t,n,l){let r={type:"sectionBreak",...n.band};return(0,eh.s)((0,ex.ok)([r,...n.body,...l?[{type:"sectionBreak",tone:"surface",padding:"none"},{type:"paragraph",text:""}]:[]],t),"builtin"===e.source)}(e,ek,n,function(e,t){let n=(0,D.S)(e.document),l=n[n.length-1];if(!(null==l?void 0:l.blockIds.includes(t)))return!1;let r=Y(e.document,t);return null===r||null===r.cap}(eN,t));l&&K(eN,t,l)},[eN,tn,ek]),[tu,tp]=(0,r.useState)(!1),tf=(0,r.useCallback)(()=>{let e=eN.document[eN.document.length-1];e&&K(eN,e.id,e$())},[eN]),tm=(0,r.useCallback)(e=>{let t=eN.document[eN.document.length-1];t&&(tp(!0),td(e,t.id).finally(()=>tp(!1)))},[eN,td]),th=(0,r.useCallback)(e=>{var t,n;let l=eN.document[eN.document.length-1];if(!l)return;let r=(t=e.html,n=e.slots,(0,eh.s)([{type:"sectionBreak"},{type:"html",html:t,slots:n},{type:"paragraph",text:""}],!0));r&&K(eN,l.id,r)},[eN]),[tx,tb]=(0,r.useState)(null),tg=(0,r.useCallback)(e=>{tb(e)},[]),tv=(0,r.useCallback)(()=>tb(null),[]),ty=(0,r.useCallback)(()=>
1{if(null===tx)return;let e=(0,$.T)(eN.document,tx);e.length>0&&eN.transact(()=>eN.removeBlocks(e)),tb(null)},[tx,eN]),tk=(0,r.useCallback)(async e=>{let t=(0,er.uO)((0,s.HN)(eN),eN,p),n=(0,er.qv)(t,e=>p&&tn?[{...e,onItemClick:()=>{let e=eN.getTextCursorPosition().block.id;to((t,n)=>(0,V.C)(eN,e,(0,ea.a)(t,n)),{allowLink:!0})}}]:e?[e]:[]),l=(0,er.kJ)(n,e=>{var t,n,l,r,a,o,i,s,c,d,u;let f=[];return e9&&(f.push({title:"Clips",subtext:b?"Insert from Quallie.Ai, upload, or embed":"Add a clip placeholder a report will fill in",group:null!=(t=null==e?void 0:e.group)?t:er.fO,icon:null==e?void 0:e.icon,aliases:["clip","clips","video","reel","quote","media"],onItemClick:()=>{let e=eN.getTextCursorPosition().block.id;te(t=>{(0,V.v)(eN,e,t)})}}),f.push({title:"Mind map",subtext:b?"Add a mind map from this project":"Add a mind map placeholder a report will fill in",group:null!=(n=null==e?void 0:e.group)?n:er.fO,icon:el.Uf,aliases:["mind map","mindmap","themes","map"],onItemClick:()=>{let e=eN.getTextCursorPosition().block.id;if(!b)return void(0,V.C)(eN,e,(0,J.os)(""));e7.current=e,e5(!0)}})),p&&(f.push({title:"Columns",subtext:"Side-by-side columns that hold any block",group:null!=(l=null==e?void 0:e.group)?l:er.fO,icon:el.Un,aliases:["columns","split"],onItemClick:()=>{(0,V.C)(eN,eN.getTextCursorPosition().block.id,{type:"columns"})}}),f.push({title:"Card",subtext:"A white panel that holds any block",group:null!=(r=null==e?void 0:e.group)?r:er.fO,icon:el.$v,aliases:["card","panel","box","callout","tile"],onItemClick:()=>{(0,V.C)(eN,eN.getTextCursorPosition().block.id,{type:"columns",props:{cols:(0,ee.ud)((0,ee.Ni)()),style:"panel"}})}}),g||(f.push({title:"Custom component",subtext:"Describe a chart or visual and AI builds it",group:null!=(a=null==e?void 0:e.group)?a:er.fO,icon:el.Un,aliases:["component","custom","chart","html","visual"],onItemClick:()=>{(0,V.C)(eN,eN.getTextCursorPosition().block.id,{type:"html"})}}),f.push({title:"Layout",subtext:"Start from a saved layout and type your words in",group:null!=(o=null==e?void 0:e.group)?o:er.fO,icon:el.Un,aliases:["layout","library","saved","design"],onItemClick:()=>{let e="undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():"".concat(Math.floor(1e9*Math.random()).toString(36)).concat(Math.floor(1e9*Math.random()).toString(36));(0,ec.Y)(e,"layouts"),(0,V.C)(eN,eN.getTextCursorPosition().block.id,{id:e,type:"html"})}})),f.push({title:"Ask",subtext:"Let readers ask questions about this research",group:null!=(i=null==e?void 0:e.group)?i:er.fO,icon:e4,aliases:["ask","chat","question","ai"],onItemClick:()=>{(0,V.C)(eN,eN.getTextCursorPosition().block.id,{type:"askBlock"})}}),f.push((0,er.T9)(eN,null!=(s=null==e?void 0:e.group)?s:er.fO,e6)),f.push({title:"Page card",subtext:"A card that links to another page",group:null!=(c=null==e?void 0:e.group)?c:er.fO,icon:el.fU,aliases:["page","card","nav","link","tile"],onItemClick:()=>{(0,V.C)(eN,eN.getTextCursorPosition().block.id,{type:"navCard"})}}),f.push({title:"Participant card",subtext:"A card for one participant, opening their transcript",group:null!=(d=null==e?void 0:e.group)?d:er.fO,icon:el.D_,aliases:["participant","person","persona","card","transcript"],onItemClick:()=>{(0,V.C)(eN,eN.getTextCursorPosition().block.id,{type:"participantCard"})}}),f.push({title:"Tag",subtext:"A small coloured label, inline",group:null!=(u=null==e?void 0:e.group)?u:er.fO,icon:el.rT,aliases:["tag","label","pill","badge","chip"],onItemClick:()=>{eN.insertInlineContent([{type:"tag",props:{color:en.yy[0]},content:et.F}," "])}})),f}),r=[];if(p)for(let e of(r.push({title:"Section",subtext:"Start a full-width band with its own background",group:eG,icon:el.Ix,aliases:["section","preset","template","band","break","background"],onItemClick:()=>{K(eN,eN.getTextCursorPosition().block.id,e$())}}),tc))r.push({title:e.name,subtext:e.description,group:eG,icon:(0,el.R1)(e),aliases:"saved"===e.source?eK:[...eK,e.key],onItemClick:()=>{td(e,eN.getTextCursorPosition().block.id)}});let o=(0,er.Ed)([...(0,er.Ti)(l),...r]),i=o.filter(e=>e.group!==eG),c=o.filter(e=>e.group===eG),d=0;
1i.forEach((e,t)=>{"Basic blocks"===e.group&&(d=t+1)});let u=[...i.slice(0,d),...c,...i.slice(d)];return(0,a.l)((0,er.Ed)((0,er.Ti)(u)),e)},[eN,p,e9,b,g,te,to,tn,tc,td]),tj=v.find(e=>e.id===y),tC=(0,r.useMemo)(()=>(0,ei.TO)(ek,tj),[ek,tj]),[tw,tN]=(0,r.useState)(null),tI=(0,r.useMemo)(()=>{if(ed)return e=>{tN(e3(eq(),e.blockId)),ed(e)}},[ed,eq]),tS=(0,r.useMemo)(()=>({mediaContext:u,editable:p,accent:(0,ei._Y)(ek,tj),theme:ek,fonts:X,uploadFile:h,uploadFileSilent:x,openInsertMedia:e9?te:void 0,openImagePicker:p&&tn?to:void 0,confirmDeleteSection:p?tg:void 0,projectId:b,isTemplate:g,pages:v,activePageId:y,onNavigatePage:k,onCreatePage:w,bandVars:tC,undoDocument:eS?eE:void 0,setSourcePanelOpen:H,startComment:tI,commentAnchors:ep,commentsOpen:ef}),[u,p,ek,X,tj,h,x,b,g,e9,te,to,tn,tg,v,y,k,w,tC,eS,eE,H,tI,ep,ef]);return(0,r.useEffect)(()=>{(0,L.EK)(eq(),null!=ep?ep:eZ)},[eq,ep]),(0,r.useEffect)(()=>{(0,L.qk)(eq(),tw)},[eq,tw]),(0,r.useEffect)(()=>{ef&&!1!==eb||tN(null)},[ef,eb]),(0,l.jsxs)(es.x.Provider,{value:tS,children:[(0,l.jsxs)("div",{className:"report-surface w-full text-neutral-900","data-comments-open":ef?"true":"false",style:{...(0,ei.gc)(ek),...(0,eP.J2)(X),...tC,backgroundColor:(0,ei.nk)(ek)},children:[(0,l.jsx)(eP.Ay,{fonts:X,baseUrl:G}),j?(0,l.jsx)("div",{className:"report-band-title pt-8",children:(0,l.jsx)("div",{className:"px-[50px]",children:(0,l.jsxs)("button",{type:"button",onClick:()=>k(j.id),className:"-ml-1 flex max-w-full items-center gap-1.5 rounded px-1 py-1 text-sm font-medium text-neutral-500 hover:bg-neutral-100 hover:text-neutral-800",children:[(0,l.jsx)(d.A6,{size:"md",className:"shrink-0"}),(0,l.jsxs)("span",{className:"truncate",children:["Back to ",j.title]})]})})}):null,(0,l.jsxs)("div",{className:"report-band-doc px-2 py-6".concat(j?"":" report-band-doc--lead"),children:[(0,l.jsx)(Q,{bands:eT,onChangeSubscribe:ez}),(0,l.jsxs)(o.NP,{editor:eN,editable:p,theme:"light",slashMenu:!1,filePanel:!1,formattingToolbar:!1,sideMenu:!1,children:[(0,l.jsx)(s.$W,{filePanel:eF.A}),(0,l.jsx)(eB,{}),(0,l.jsx)(eO.Ay,{editor:eN,theme:ek,fonts:X}),(0,l.jsx)(eX,{}),(0,l.jsx)(s.ge,{triggerCharacter:"/",getItems:tk,floatingUIOptions:eo._})]}),p?(0,l.jsx)(eA,{catalogue:tc,showComponents:!g,onInsertBlank:tf,onInsertPreset:tm,onInsertLayout:th,busy:tu}):null]})]}),eH&&b?(0,l.jsx)(P,{projectId:b,reportId:tn,mode:eH.mode,onInsert:tt,onClose:()=>{eQ(null),eJ.current=null}}):null,tl&&tn?(0,l.jsx)(C,{reportId:tn,sources:(t=tl.allowLink,g?t?e2:e1:t?e0:void 0),onPick:ti,onClose:ts}):null,eV&&b?(0,l.jsx)(M.A,{projectId:b,reportId:"editor"===u.kind?u.reportId:"",onSelect:e=>{e5(!1);let t=e7.current;e7.current=null,t&&(0,V.C)(eN,t,(0,J.os)(e))},onClose:()=>{e5(!1),e7.current=null}}):null,(0,l.jsx)(Z,{open:null!==tx,onCancel:tv,onConfirm:ty})]})}},50429:()=>{},57349:()=>{}}]);

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.