1import{W as pt,jm as Tr,ie as ze,j as t,bI as k,r as y,S as ne,a1 as Xt,bW as xt,bx as dn,b8 as Zt,V as Er,gK as Pr,aZ as ms,n as ps,F as ht,A as Ce,bU as es,Y as cn,Z as un,$ as mn,bk as Ar,gW as pn,a0 as xn,g as Ir,b1 as Fr,aW as Mr,ax as hn,L as fn,eJ as bn,jB as gn,jg as vn,ji as yn,jA as jn,k as ie,_ as _e,s as Nn,by as xs,ay as wn,aF as kn,ag as hs,bA as Sn,ad as Cn,af as Dr,ae as _n,G as Tn,T as En,O as Pn,Q as An,bw as In,p as tt,h as Fn,j5 as Mn,lW as Dn,lX as Ln,eK as Rn,bL as On,bM as $n,bN as Bn,c1 as Lr,lY as Hn,lZ as Un,b5 as zn,l_ as be}from"./index-DNBzpCbc.js";import{Q as Rr,S as Or,U as $r,V as Wn,W as Gn,X as ts,Y as ss,Z as Kn,_ as Qn,$ as qn,a0 as Yn,a1 as Vn,a2 as He,a3 as Br,a4 as Hr,a5 as Jn,a6 as sr,a7 as We,a8 as rr,a9 as Xn,aa as fs,ab as Zn,ac as bs,ad as ar,ae as Ur,T as te,N as rs,af as eo,ag as to,ah as so,ai as ro,aj as Ht,ak as ao,al as zr,am as no,an as Wr,ao as Gr,ap as oo,aq as io,ar as lo,as as co,at as uo,au as nr,av as mo,aw as Ut,ax as zt,ay as po,az as xo,aA as Wt,aB as $e,aC as Gt,aD as ho,aE as fo,aF as it,aG as bo,aH as or,aI as ir,aJ as go,aK as vo,aL as yo,aM as lr,aN as jo,aO as No,aP as wo,aQ as ko}from"./cover-document-templates-CiH5XGb_.js";import{b as So}from"./cover-pick-lists-BrT1TjHG.js";import{c as dr}from"./cover-menu-query-keys-BponkbWV.js";import{u as Co,i as _o,a as To,E as Eo,N as Po,m as Ao}from"./index-COWzUQg5.js";import{C as Io,i as Fo,c as Mo,U as Do,A as Lo,a as Ro,b as Oo,T as $o}from"./index-D64hnP9b.js";import{T as Kr}from"./tag-BLiaMQqW.js";import{B as Bo,I as Ho}from"./italic-zSnDqYdu.js";import{U as gs}from"./user-plus-DG1v9hts.js";import{S as Uo}from"./share-2-DiXChCoq.js";import{F as Qr}from"./folder-DjaYZu2o.js";import{u as zo,a as cr,K as Wo,P as Go,D as Ko,c as Qo,C as qo}from"./core.esm-BgcLwLwE.js";import{s as Yo,S as Vo,v as Jo,u as Xo}from"./sortable.esm-CZG1QOAY.js";import{S as Zo}from"./sticky-note-oD0tr-MW.js";import{S as ei}from"./switch-BXai0--o.js";import{M as ti}from"./minus-mCTcsBbJ.js";import{U as si}from"./undo-2-DOr7WS3v.js";import{R as ri}from"./redo-2-CjAIFja-.js";const ai=pt("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);const ni=pt("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);const qr=pt("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]);const oi=pt("Paintbrush",[["path",{d:"m14.622 17.897-10.68-2.913",key:"vj2p1u"}],["path",{d:"M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z",key:"18tc5c"}],["path",{d:"M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15",key:"ytzfxy"}]]),ii=[{id:"save-as-template",label:"Save as template",action:"stub"},{id:"attach-to-event",label:"Attach to event",action:"stub"},{id:"preview",label:"Preview",action:"preview"}],vs=5,li="cover.print-preview.recent";function ys(e){return e==="account"?["account"]:e==="contact"?["contact"]:e==="lead"?["lead"]:e==="proposal"?["proposal"]:["event","proposal"]}function di(e){const s=ys(e);return s.length===1&&s[0]==="account"?{searchPlaceholder:"Search accounts...",allHeading:"ALL ACCOUNTS",availableLabel:r=>`${r} account${r===1?"":"s"} available`,subtitle:"Select an account to populate merge fields and preview the print"}:s.length===1&&s[0]==="contact"?{searchPlaceholder:"Search contacts...",allHeading:"ALL CONTACTS",availableLabel:r=>`${r} contact${r===1?"":"s"} available`,subtitle:"Select a contact to populate merge fields and preview the print"}:s.length===1&&s[0]==="lead"?{searchPlaceholder:"Search leads...",allHeading:"ALL LEADS",availableLabel:r=>`${r} lead${r===1?"":"s"} available`,subtitle:"Select a lead to populate merge fields and preview the print"}:s.length===1&&s[0]==="proposal"?{searchPlaceholder:"Search proposals...",allHeading:"ALL PROPOSALS",availableLabel:r=>`${r} proposal${r===1?"":"s"} available`,subtitle:"Select a proposal to populate merge fields and preview the print"}:{searchPlaceholder:"Search events...",allHeading:"ALL EVENTS",availableLabel:r=>`${r} event${r===1?"":"s"} available`,subtitle:"Select an event to populate merge fields and preview the print"}}function ci(e,s,r){const a=ys(r).join("+")||"event";return`${li}.${e||"org"}.${s||"user"}.${a}`}function ui(e,s=vs){if(!e)return[];try{const r=JSON.parse(e);return Array.isArray(r)?r.filter(a=>
1typeof a=="string"&&a.length>0).slice(0,s):[]}catch{return[]}}function mi(e,s,r=vs){return[s,...e.filter(a=>a!==s)].slice(0,r)}function ue(e){if(!e)return"";const s=e.match(/^(\d{4})-(\d{2})-(\d{2})/),r=s?new Date(Date.UTC(Number(s[1]),Number(s[2])-1,Number(s[3]))):new Date(e);return Number.isNaN(r.getTime())?"":r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}function ve(e){return e==null||Number.isNaN(e)?"":`$${(e/100).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function ft(e){const s=(e||"").trim();return s==="Definite"||s==="Confirmed"?{status:s,statusLabel:"Confirmed",statusTone:"confirmed"}:s==="Confirming"||s==="Tentative"?{status:s,statusLabel:"Tentative",statusTone:"tentative"}:s==="Prospective"||s==="Pending"||s==="Created"?{status:s,statusLabel:"Pending",statusTone:"pending"}:s?{status:s,statusLabel:s,statusTone:"neutral"}:{status:"",statusLabel:"",statusTone:"neutral"}}function ur(e,s){const r=s.trim().toLowerCase();return r?e.filter(a=>a.name.toLowerCase().includes(r)||a.client.toLowerCase().includes(r)):e}function pi(e,s){const r=new Map(e.map(a=>[a.id,a]));return s.map(a=>r.get(a)).filter(a=>!!a).slice(0,vs)}function xi(e,s){return e?e.replace(/\{\{\s*([^}]+?)\s*\}\}/g,(r,a)=>s[a]??""):""}function Pe(e){const s={};for(const[r,a]of Object.entries(e))a==null||a===""||(s[r]=String(a));return s}function Yr(e,s){const r=ft(e.status),a=e.startAt||"",n=e.contactName||e.accountName||"",o=ze(e);return{id:e.id,entity:"event",name:e.name,client:n,dateIso:a,dateLabel:ue(a),...r,values:Pe({event_name:e.name,event_number:e.eventNumber,event_category:e.category,event_theme:e.theme,event_date:ue(e.startAt),event_time:e.startAt,event_start:e.startAt,event_end:e.endAt,event_status:r.statusLabel,sales_rep:e.salesRepName,event_min_guests:e.guests?.min,event_est_guests:e.guests?.est??void 0,event_actual_guests:e.guests?.act??void 0,minimum_spend:ve(e.minimumSpend),payment_method:e.paymentMethod,event_reference:o,event_source:o,business_type:e.businessType,operation:e.operation,event_coordinator:e.coordinator,billing_contact:e.billingContactName||e.billingContact,event_account:e.accountName,booking_contact:e.contactName,site_contact:e.siteContactName,event_total_billed:ve(e.totalBilled),event_total_paid:ve(e.totalPaid),account_name:e.accountName,company_name:e.accountName,booking_contact_name:e.contactName,...s})}}function as(e){const s=ft(e.status),r=e.contactName||e.accountName||e.leadName||"",a=ze(e);return{id:e.id,entity:"proposal",name:e.name,client:r,dateIso:e.eventDate,dateLabel:ue(e.eventDate),...s,values:Pe({event_name:e.name,event_number:e.proposalNumber,event_reference:a,event_source:a,event_date:ue(e.eventDate),event_status:s.statusLabel,sales_rep:e.salesRepName,event_account:e.accountName,booking_contact:e.contactName,event_total_billed:ve(e.totalBilled),event_total_paid:ve(e.totalPaid),account_name:e.accountName,company_name:e.accountName,booking_contact_name:e.contactName})}}function hi(e){const s=Tr(e),r=ze(e),a=ft(s),n=e.accountName;return{id:e.id,entity:"account",name:e.accountName,client:n,dateIso:e.updatedAt||e.createdAt||"",dateLabel:ue(e.updatedAt||e.createdAt),status:s||"",statusLabel:s||a.statusLabel,statusTone:"neutral",values:Pe({company_name:e.accountName,account_name:e.accountName,account_number:e.accountName,account_category:s,account_type:s,account_reference:r,source:r,account_email:e.email,account_phone:e.phone,account_phone2:e.secondaryPhone,account_cellular:e.mobilePhone,account_fax:e.fax,website:e.website,address1:e.address1,address2:e.address2,city:e.city,state_province:e.stateProvince,postal_code:e.postalCode,county:e.county,country:e.country,billing_address1:e.billingAddress1,billing_address2:e.billingAddress2,billing_city:e.b
1illingCity,billing_state_province:e.billingStateProvince,billing_postal_code:e.billingPostalCode,primary_contact:e.primaryContactName})}}function fi(e){const s=[e.firstName,e.lastName].filter(Boolean).join(" "),r=ze(e);return{id:e.id,entity:"contact",name:s,client:e.primaryAccountName||"",dateIso:e.updatedAt||e.createdAt||"",dateLabel:ue(e.updatedAt||e.createdAt),status:"",statusLabel:"",statusTone:"neutral",values:Pe({booking_contact_name:s,booking_contact_salutation:e.salutation,booking_contact_first_name:e.firstName,booking_contact_last_name:e.lastName,booking_contact_title:e.title,booking_contact_phone:e.phone,booking_contact_mobile:e.mobilePhone||e.cellular,booking_contact_secondary_phone:e.secondaryPhone,booking_contact_fax:e.fax,booking_contact_email:e.email,booking_contact_address1:e.address1,booking_contact_address2:e.address2,booking_contact_city:e.city,booking_contact_state:e.stateProvince,booking_contact_postal:e.postalCode,booking_contact_county:e.county,booking_contact_country:e.country,booking_contact_number:e.contactNumber,booking_contact_reference:r,booking_contact_source:r,booking_contact_sales_rep:e.salesRepName,contact_name:s,contact_salutation:e.salutation,contact_first_name:e.firstName,contact_last_name:e.lastName,contact_title:e.title,contact_email:e.email,contact_phone:e.phone,contact_mobile:e.mobilePhone||e.cellular,contact_secondary_phone:e.secondaryPhone,contact_fax:e.fax,contact_address1:e.address1,contact_address2:e.address2,contact_city:e.city,contact_state:e.stateProvince,contact_postal:e.postalCode,contact_county:e.county,contact_country:e.country,contact_number:e.contactNumber,contact_reference:r,contact_source:r,contact_sales_rep:e.salesRepName,contact_primary_account:e.primaryAccountName,contact_tenant:e.tenantName,account_name:e.primaryAccountName,company_name:e.primaryAccountName})}}function bi(e){const s=[e.firstName,e.lastName].filter(Boolean).join(" ")||e.company||"Lead",r=ft(e.status),a=Tr(e),n=ze(e);return{id:e.id,entity:"lead",name:s,client:e.company||"",dateIso:e.updatedAt||e.createdAt||"",dateLabel:ue(e.updatedAt||e.createdAt),...r,values:Pe({booking_contact_name:s,booking_contact_first_name:e.firstName,booking_contact_last_name:e.lastName,booking_contact_salutation:e.salutation,booking_contact_title:e.title,booking_contact_phone:e.phone,booking_contact_email:e.email,booking_contact_address1:e.address1,company_name:e.company,account_name:e.company,lead_name:s,lead_salutation:e.salutation,lead_first_name:e.firstName,lead_last_name:e.lastName,lead_title:e.title,lead_email:e.email,lead_phone:e.phone,lead_company:e.company,lead_status:r.statusLabel,lead_address1:e.address1,lead_address2:e.address2,lead_city:e.city,lead_state:e.stateProvince,lead_postal:e.postalCode,lead_county:e.county,lead_country:e.country,lead_reference:n,lead_source:n,event_source:n,lead_category:a,lead_type:a,lead_description:e.description,lead_coordinator:e.coordinator,lead_sales_rep:e.salesRepName,lead_potential_spend:ve(e.potentialSpend),lead_tenant:e.tenantName})}}function Vr(e){if(!e)return{};const s=e.venueSnapshot?.name||e.siteSnapshot?.name;return Pe({subevent_name:e.name,subevent_type:e.type,subevent_date:ue(e.date),subevent_start:e.startTime,subevent_end:e.endTime,subevent_min_guests:e.guests?.min,subevent_est_guests:e.guests?.est??void 0,subevent_actual_guests:e.guests?.act??void 0,subevent_location:s,subevent_setup_style:e.setupStyle,subevent_setup_time:e.setupTime,subevent_teardown_time:e.teardownTime})}function gi(e,s){if(!s?.event)return e.values;const r=Yr(s.event,Vr(s.subevents?.[0]));return{...e.values,...r.values}}function vi(e,s){if(!s?.proposal)return e.values;const r=as(s.proposal);return{...e.values,...r.values,...Vr(s.subevents?.[0])}}const yi=[{id:"mock-smithfield",entity:"event",name:"Smithfield Wedding Reception",client:"Emily & James Smithfield",dateIso:"2025-03-15",dateLabel:"Mar 15, 2025",status:"Definite",statusLabel:"Confirmed",statusTone:"confirmed",mock:!0,values:{event_name:"Smithfield Wedding Reception",event_date:"Mar 15, 2025",event_status:"Confirmed",booking_contact_name:"Emily & James Smithfield",account_name:"Emily & James Smithfield",company_name:"Emily & James Smithfield"}},{id:"mock-obrien",entity:"event",name:"O'Brien 50th Birthday Gala",client:"The O'Brien Family",dateIso:"2025-04-12",dateLabel:"Apr 12, 2025",status:"Confirming",statusLabel:"Tentative",statusTone:"tentative",mock:!0,values:{event_name:"O'Brien 50th Birthday Gala",event_date:"Apr 12, 2025",event_status:"Tentative",booking_contact_name:"The O'Brien Family",account_name:"The O'Brien Family"}},{id:"mock-hargrove",entity:"event",name:"Hargrove Corporate Dinner",client:"Hargrove Industries",dateIso:"2025-05-08",dateLabel:"May 8, 2025",status:"Definite",statusLabel:"Confirmed",statusTone:"confirmed",mock:!0,values:{event_name:"Hargrove Corporate Dinner",event_date:"May 8, 2025",event_status:"Confirmed",booking_contact_name:"Hargrove Industries",account_name:"Hargrove Industries"}},{id:"mock-chen",entity:"event",name:"Chen Rehearsal Dinner",client:"The Chen Family",dateIso:"2025-06-20",dateLabel:"Jun 20, 2025",status:"Definite",statusLabel:"Confirmed",statusTone:"confirmed",mock:!0,values:{event_name:"Chen Rehearsal Dinner",event_date:"Jun 20, 2025",event_status:"Confirmed",booking_contact_name:"The Chen Family",account_name:"The Chen Family"}},{id:"mock-patel",entity:"event",name:"Patel Anniversary Brunch",client:"Priya & Arjun Patel",dateIso:"2025-07-03",dateLabel:"Jul 3, 2025",status:"Prospective",statusLabel:"Pending",statusTone:"pending",mock:!0,values:{event_name:"Patel Anniversary Brunch",event_date:"Jul 3, 2025",event_status:"Pending",booking_contact_name:"Priya & Arjun Patel",account_name:"Priya & Arjun Patel"}}];function ji(e){return ys(e).includes("event")?yi:[]}function Be(e,s){return s.length>0?s:ji(e)}const Jr=8,ut="cover.printDesigner.snapToObjects";function ns(e,s,r,a){return s<r?r-s:a<e?e-a:0}function Xr(e,s){if(!e)return!0;const r=Math.abs(e.delta),a=Math.abs(s.delta);return a<r-.01?!0:Math.abs(a-r)>.01?!1:s.sameSide!==e.sameSide?s.sameSide:s.gap<e.gap}function mr(e,s,r,a,n,o){const i=e+s;let u=null;for(const d of r){const c=a==="x"?d.x:d.y,f=a==="x"?d.width:d.height,b=c+f,j=a==="x"?ns(o.y,o.y+o.height,d.y,d.y+d.height):ns(o.x,o.x+o.width,d.x,d.x+d.width),g=[[c-e,c,!0],[b-i,b,!0],[b-e,b,!1],[c-i,c,!1]];for(const[S,$,B]of g){if(Math.abs(S)>n)continue;const N={delta:S,position:$,sameSide:B,gap:j,other:d};Xr(u,N)&&(u=N)}}return u}function os(e,s,r,a){const n=a.filter(i=>{const u=e==="x"?i.x:i.y,d=e==="x"?i.width:i.height;return Math.abs(u-s)<=.5||Math.abs(u+d-s)<=.5}),o=[r,...n];return e==="x"?{orientation:"vertical",position:s,from:Math.min(...o.map(i=>i.y)),to:Math.max(...o.map(i=>i.y+i.height))}:{orientation:"horizontal",position:s,from:Math.min(...o.map(i=>i.x)),to:Math.max(...o.map(i=>i.x+i.width))}}function Zr(e,s,r=Jr){const a=mr(e.x,e.width,s,"x",r,e),n=mr(e.y,e.height,s,"y",r,e),o=e.x+(a?.delta??0),i=e.y+(n?.delta??0),u={...e,x:o,y:i},d=[];return a&&d.push(os("x",a.position,u,s)),n&&d.push(os("y",n.position,u,s)),{x:o,y:i,guides:d}}function Ni(e,s,r,a){const n=a?.threshold??Jr,o=a?.minWidth??1,i=s.includes("w"),u=s.includes("e");if(!i&&!u)return{...e,guides:[]};const d=i?e.x:e.x+e.width;let c=null;for(const b of r){const j=ns(e.y,e.y+e.height,b.y,b.y+b.height),g=[[b.x,i],[b.x+b.width,u]];for(const[S,$]of g){const B=S-d;
1if(Math.abs(B)>n||(i?e.x+e.width-S:S-e.x)<o)continue;const A={delta:B,position:S,sameSide:$,gap:j,other:b};Xr(c,A)&&(c=A)}}if(!c)return{...e,guides:[]};const f=i?{...e,x:c.position,width:e.x+e.width-c.position}:{...e,width:c.position-e.x};return{...f,guides:[os("x",c.position,f,r)]}}function wi(e,s,r){const a=new Set(s),n=e.filter(b=>a.has(b.id));if(n.length<2)return e;const o=Math.min(...n.map(b=>b.x)),i=Math.min(...n.map(b=>b.y)),u=Math.max(...n.map(b=>b.x+b.width)),d=Math.max(...n.map(b=>b.y+b.height)),c=(o+u)/2,f=(i+d)/2;return e.map(b=>{if(!a.has(b.id))return b;switch(r){case"left":return{...b,x:o};case"right":return{...b,x:u-b.width};case"center":return{...b,x:c-b.width/2};case"top":return{...b,y:i};case"bottom":return{...b,y:d-b.height};case"middle":return{...b,y:f-b.height/2};default:return b}})}function ea(e){const s=e?.trim();return s?`${ut}:${s}`:ut}function pr(e){return e==null||e===""?!0:e==="1"||e==="true"||e==="on"}function ki(e){return e?"1":"0"}function Si(e,s){try{if(s){const a=e.local?.getItem(ea(s));if(a!=null)return pr(a)}const r=e.session?.getItem(ut);return r!=null?pr(r):!0}catch{return!0}}function Ci(e,s,r){const a=ki(s);try{e.session?.setItem(ut,a),r&&e.local?.setItem(ea(r),a)}catch{}}const _i=["list","compact","cards","grid","cols-2","cols-3","custom","numbered","checklist"],Ti=[{id:"list",label:"List",icon:"list"},{id:"compact",label:"Compact",icon:"compact"},{id:"cards",label:"Cards",icon:"cards"},{id:"grid",label:"Grid",icon:"grid"},{id:"cols-2",label:"2 Cols",icon:"cols-2"},{id:"cols-3",label:"3 Cols",icon:"cols-3"},{id:"custom",label:"Custom",icon:"custom"},{id:"numbered",label:"Numbered",icon:"numbered"},{id:"checklist",label:"Checklist",icon:"checklist"}],ta=8,Ei=1,bt=Gn.map(e=>({key:e.key,label:e.label})),gt=Wn.map(e=>({key:e.key,label:e.label})),vt=[{key:"site_name",label:"Site Name"},{key:"address",label:"Address"},{key:"city",label:"City"},{key:"phone",label:"Phone"},{key:"email",label:"Email"},{key:"contact",label:"Contact"},{key:"notes",label:"Notes"}],yt=[{key:"venue_name",label:"Venue Name"},{key:"address",label:"Address"},{key:"rooms",label:"Rooms"},{key:"capacity",label:"Capacity"},{key:"phone",label:"Phone"},{key:"notes",label:"Notes"}],jt=[{key:"guest_name",label:"Guest Name"},{key:"party_size",label:"Party Size"},{key:"table",label:"Table"},{key:"meal",label:"Meal"},{key:"notes",label:"Notes"}],Nt=[{key:"shift_name",label:"Shift Name"},{key:"position",label:"Position"},{key:"staff_name",label:"Staff Name"},{key:"start_time",label:"Start Time"},{key:"end_time",label:"End Time"},{key:"hours",label:"Hours"}],sa=$r.map(e=>({key:e.key,label:e.label}));function Ge(e){return e==="event-details"?bt:e==="subevents"?gt:e==="site-locations"?vt:e==="venues"?yt:e==="guest-lists"?jt:e==="shifts-staff"?Nt:sa}function Kt(e){return e.kind==="menu-items"||e.kind==="section"}function Pi(e){return e.kind==="shape"||e.kind==="image"}function js(e,s=3){return e==="grid"||e==="cols-2"?2:e==="cols-3"?3:e==="custom"?wt(s):1}function wt(e){return Number.isFinite(e)?Math.min(ta,Math.max(Ei,Math.round(e))):3}function Ns(e,s=3){const a=Ge(e).map(o=>o.key),n=o=>{const i=o.slice(0,s);for(;i.length<s;)i.push("");return i};return e==="menu-items"||e==null?[n(["item_name","price","quantity"]),n(["description"])]:[n(a.slice(0,s)),n(a.slice(s,s+Math.min(2,s)))]}function ra(e,s,r){const a=wt(s);return(e&&e.length>0?e:Ns(r,a)).map(o=>{const i=o.slice(0,a);for(;i.length<a;)i.push("");return i})}function lt(e){return e==="compact"||e==="grid"?10:e==="cards"||e==="cols-2"||e==="cols-3"?6:e==="custom"?4:3}function Ai(e,s=2){return e==="compact"?28:e==="grid"?56:e==="cards"?92:e==="custom"?Math.max(28,s*22+10):72}const Ii=32,Fi=16,Mi=8;function Qt(e,s,r=0,a){const n=js(e.layoutMode,e.customColumnCount),o=Ai(e.layoutMode,e.customRows?.length??2),i=a==null||e.layoutMode==="custom"?1:Math.max(1,Math.ceil(Math.max(0,a)/2)),u=a==null||e.layoutMode==="custom"?o:Math.max(o,i*18+12),d=Math.ceil(Math.max(1,s)/n)+r,f=(e.groupBySubevent?Or(e.subeventHeaderFields):"")?28:0;return Ii+Fi+f+d*(u+Mi)}function K(e,s,r){return`{{${e}_${s}_${r}}}`}function Di(e,s){return Array.from({length:s},(r,a)=>{const n=a+1;return e==="event-details"?{id:`event-${n}`,index:n,title:n===1?"{{event_name}}":`Event ${n}`,details:"{{event_date}} · {{event_time}}",meta:["{{event_status}}","{{event_est_guests}} guests"],values:Object.fromEntries(bt.map(o=>[o.key,`{{${o.key}}}`]))}:e==="subevents"?{id:`subevent-${n}`,index:n,title:`{{subevent_${n}_name}}`,details:K("subevent",n,"start")+" â "+K("subevent",n,"end"),meta:[K("subevent",n,"location")],values:Object.fromEntries(gt.map(o=>[o.key,K("subevent",n,o.key)]))}:e==="site-locations"?{id:`site-${n}`,index:n,title:K("site",n,"name"),details:K("site",n,"address"),meta:[K("site",n,"phone")],values:Object.fromEntries(vt.map(o=>[o.key,K("site",n,o.key)]))}:e==="venues"?{id:`venue-${n}`,index:n,title:K("venue",n,"name"),details:K("venue",n,"address"),meta:[K("venue",n,"capacity")],values:Object.fromEntries(yt.map(o=>[o.key,K("venue",n,o.key)]))}:e==="guest-lists"?{id:`guest-${n}`,index:n,title:K("guest",n,"name"),details:K("guest",n,"meal"),meta:[K("guest",n,"table")],values:Object.fromEntries(jt.map(o=>[o.key,K("guest",n,o.key)]))}:e==="shifts-staff"?{id:`shift-${n}`,index:n,title:K("shift",n,"name"),details:K("shift",n,"staff_name"),meta:[K("shift",n,"position")],values:Object.fromEntries(Nt.map(o=>[o.key,K("shift",n,o.key)]))}:{id:`item-${n}`,index:n,title:`Item ${n}`,details:`{{item_${n}_description}}`,meta:["Category","Allergens","Calories"],price:`{{item_${n}_price}}`,values:Object.fromEntries(sa.map(o=>o.key==="item_name"?[o.key,`Item ${n}`]:o.key==="description"?[o.key,`{{item_${n}_description}}`]:o.key==="price"?[o.key,`{{item_${n}_price}}`]:[o.key,`{{item_${n}_${o.key}}}`]))}})}function Li(e,s,r){const a=e.findIndex(u=>u.id===s);if(a<0)return e;const n=e.slice(),[o]=n.splice(a,1);if(r==="back")return[o,...n];if(r==="front")return[...n,o];if(r==="backward"){const u=Math.max(0,a-1);return n.splice(u,0,o),n}const i=Math.min(n.length,a+1);return n.splice(i,0,o),n}function aa(e,s){return e.x<s.x+s.width&&e.x+e.width>s.x&&e.y<s.y+s.height&&e.y+e.height>s.y}function is(e,s){return s.filter(r=>Pi(r)&&aa(e,r))}
1function na(e,s){let r=0,a=0;const n=e.x+e.width/2;for(const o of s){if(!aa(e,o))continue;o.x+o.width/2<=n?r=Math.max(r,Math.min(e.width*.7,o.x+o.width-e.x)):a=Math.max(a,Math.min(e.width*.7,e.x+e.width-o.x))}return{left:Math.max(0,r),right:Math.max(0,a)}}function xr(e,s,r){if(s.length===0)return 0;const{left:a,right:n}=na(e,s);return a+n<=0?0:(a+n)/Math.max(1,e.width)>.35&&js(r)===1?1:0}const oa="application/x-print-upload",Ri=50*1024*1024,Oi=".png,.jpg,.jpeg,.svg,.pdf,image/png,image/jpeg,image/svg+xml,application/pdf",$i=["image/png","image/jpeg","image/jpg","image/svg+xml","application/pdf"],Bi=4,Hi=[{id:"instagram",label:"Instagram",detail:"Import from gallery"},{id:"google-drive",label:"Google Drive",detail:"Browse Drive files"},{id:"dropbox",label:"Dropbox",detail:"Access Dropbox folders"},{id:"google-photos",label:"Google Photos",detail:"Import from albums"},{id:"onedrive",label:"Microsoft OneDrive",detail:"Browse OneDrive files"},{id:"unsplash",label:"Unsplash",detail:"Free stock photos"}];function st(e){return`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(e)}`}const rt=Date.UTC(2026,8,16,18,0,0),Ui=[{id:"upload-logo-primary",name:"logo-primary.png",mime:"image/png",uploadedAt:rt+4e3,naturalWidth:240,naturalHeight:240,src:st('<svg xmlns="http://www.w3.org/2000/svg" width="240" height="240"><rect width="240" height="240" rx="24" fill="#EFF6FF"/><circle cx="120" cy="110" r="46" fill="none" stroke="#1D4ED8" stroke-width="8"/><path d="M72 168h96" stroke="#1D4ED8" stroke-width="8" stroke-linecap="round"/></svg>')},{id:"upload-venue-photo",name:"venue-photo.jpg",mime:"image/jpeg",uploadedAt:rt+3e3,naturalWidth:240,naturalHeight:240,src:st('<svg xmlns="http://www.w3.org/2000/svg" width="240" height="240"><rect width="240" height="240" fill="#FFF7ED"/><circle cx="120" cy="120" r="28" fill="#F97316" opacity=".35"/><circle cx="78" cy="92" r="22" fill="#FB7185" opacity=".35"/><circle cx="162" cy="92" r="22" fill="#FBBF24" opacity=".35"/><circle cx="78" cy="148" r="22" fill="#FBBF24" opacity=".35"/><circle cx="162" cy="148" r="22" fill="#FB7185" opacity=".35"/></svg>')},{id:"upload-menu-bg",name:"menu-bg.svg",mime:"image/svg+xml",uploadedAt:rt+2e3,naturalWidth:240,naturalHeight:240,src:st('<svg xmlns="http://www.w3.org/2000/svg" width="240" height="240"><circle cx="120" cy="120" r="110" fill="#ECFDF5"/><path d="M120 36c42 36 48 108 0 168-48-60-42-132 0-168z" fill="#059669" opacity=".28"/></svg>')},{id:"upload-floral-border",name:"floral-border.png",mime:"image/png",uploadedAt:rt+1e3,naturalWidth:240,naturalHeight:160,src:st('<svg xmlns="http://www.w3.org/2000/svg" width="240" height="160"><rect width="240" height="160" fill="#FDF2F8"/><circle cx="40" cy="80" r="18" fill="#FB7185" opacity=".4"/><circle cx="120" cy="80" r="18" fill="#F472B6" opacity=".4"/><circle cx="200" cy="80" r="18" fill="#FB7185" opacity=".4"/></svg>')}];function zi(e){if(!e)return null;try{const s=JSON.parse(e);return!s.id||!s.src||!s.name?null:{id:s.id,name:s.name,src:s.src,uploadedAt:s.uploadedAt,mime:s.mime,naturalWidth:s.naturalWidth,naturalHeight:s.naturalHeight}}catch{return null}}function Wi(e){if((e.size??0)>Ri)return!1;const s=(e.type||"").toLowerCase();if($i.includes(s))return!0;const r=(e.name||"").toLowerCase();return[".png",".jpg",".jpeg",".svg",".pdf"].some(a=>r.endsWith(a))}function Gi(e){const s=(e.mime||"").toLowerCase();return s==="application/pdf"?!1:s.startsWith("image/")?!0:e.name.toLowerCase().endsWith(".pdf")?!1:!!e.src}function Ki(e){return[...e].sort((s,r)=>(r.uploadedAt??0)-(s.uploadedAt??0))}function Qi(e,s){const r=Ki(e);return s?r:r.slice(0,Bi)}function qi(e){return{width:Math.round(e.width*.28),height:Math.round(e.width*.28)}}function Yi(e,s,r=24){const a=Math.max(1,e.width),n=Math.max(1,e.height),o=Math.max(1,s.width-r*2),i=Math.max(1,s.height-r*2);if(a<=o&&n<=i)return{width:Math.round(a),height:Math.round(n)};const u=Math.min(o/a,i/n);return{width:Math.max(1,Math.round(a*u)),height:Math.max(1,Math.round(n*u))}}function Vi(e,s){return e.naturalWidth&&e.naturalHeight?Yi({width:e.naturalWidth,height:e.naturalHeight},s):qi(s)}function Ji(e="menu-items"){return{layoutMode:"list",customColumnCount:3,customRows:Ns(e,3),showDividers:!1,alternateRowTint:!1,wrapTextAroun
1dObject:!1}}function ia(e,s){const r=_i.includes(e?.layoutMode)?e.layoutMode:"list",a=wt(e?.customColumnCount??3);return{layoutMode:r,customColumnCount:a,customRows:ra(e?.customRows,a,s??e?.sectionType),showDividers:!!e?.showDividers,alternateRowTint:!!e?.alternateRowTint,wrapTextAroundObject:!!e?.wrapTextAroundObject}}function la(e){return e==="cards"||e==="grid"}const Xi={"menu-items":{title:"Menu Items",fields:$r.map(e=>e.key)},"event-details":{title:"Event Details",fields:bt.map(e=>e.key)},subevents:{title:"Subevents",fields:gt.map(e=>e.key)},"site-locations":{title:"Site Locations",fields:vt.map(e=>e.key)},venues:{title:"Venues",fields:yt.map(e=>e.key)},"guest-lists":{title:"Guest Lists",fields:jt.map(e=>e.key)},"shifts-staff":{title:"Shifts and Staff",fields:Nt.map(e=>e.key)}};function Zi(e="menu-items"){const s=Ji(e),r=Xi[e];return{...Rr(),...s,title:r.title,sectionType:e,fields:r.fields}}const ws="application/x-print-tool",el=["rect","circle","triangle","star"],tl=["straight","dashed","decorative"],sl=["solid","dashed","dotted"],ke={fill:"#E2E8F0",borderColor:"#334155",borderWidth:2,borderStyle:"solid"},Te={thickness:2,color:"#111827",align:"center",variant:"straight"},rl={thickness:12,color:"#F97316",align:"center",variant:"decorative"},ge={fontFamily:"Inter",fontSize:16,bold:!1,italic:!1,align:"left",color:"#1E293B",letterSpacing:0,lineHeight:1.4,opacity:1},ls=[{id:"text",label:"Text",working:!0},{id:"pen",label:"Pen",working:!1},{id:"brush",label:"Brush",working:!1}],ds=[{id:"rect",label:"Rect"},{id:"circle",label:"Circle"},{id:"triangle",label:"Triangle"},{id:"star",label:"Star"}],cs=[{id:"straight",label:"Straight Line"},{id:"dashed",label:"Dashed Line"},{id:"decorative",label:"Decorative Bar"}],al=["#FEF08A","#BFDBFE","#BBF7D0","#FBCFE8","#E9D5FF","#FECACA"],nl=["n","s","e","w","ne","nw","se","sw"],ol=["e","w"];function il(e){return e==="line"?ol:e==="menu-items"||e==="section"?["e","w"]:nl}function ll(e){return e==="line"?{minWidth:40,minHeight:16}:e==="shape"?{minWidth:40,minHeight:40}:e==="text"?{minWidth:64,minHeight:28}:e==="image"?{minWidth:48,minHeight:48}:e==="menu-items"||e==="section"?{minWidth:160,minHeight:72}:{minWidth:80,minHeight:28}}function dl(e){return{width:Math.round(e.width*.42),height:56}}function cl(e){return{width:Math.round(e.width*.5),height:Math.round(e.height*.5)}}function ul(e,s=Te.thickness){return{width:e.width,height:Math.max(24,s+16)}}function ml(e){return e==="dashed"?{...Te,variant:"dashed"}:e==="decorative"?{...rl}:{...Te,variant:"straight"}}function pl(e,s){return s==="line"?{x:e.width/2,y:Math.round(e.height*.25)}:{x:e.width/2,y:e.height/2}}function Ue(e,s){const r=Math.min(Math.max(1,e.width),s.width),a=Math.min(Math.max(1,e.height),s.height);return{x:Math.max(0,Math.min(e.x,s.width-r)),y:Math.max(0,Math.min(e.y,s.height-a)),width:r,height:a}}function dt(e,s,r,a){return a?.fullWidth?Ue({x:0,y:e.y-s.height/2,width:r.width,height:s.height},r):Ue({x:e.x-s.width/2,y:e.y-s.height/2,width:s.width,height:s.height},r)}function da(e,s,r){return r==="left"?0:r==="right"?Math.max(0,s-e):Math.max(0,Math.round((s-e)/2))}function xl(e,s,r,a,n,o){const i=o?.minWidth??40,u=o?.minHeight??24;let{x:d,y:c,width:f,height:b}=e;s.includes("e")&&(f=e.width+r),s.includes("s")&&(b=e.height+a),s.includes("w")&&(d=e.x+r,f=e.width-r),s.includes("n")&&(c=e.y+a,b=e.height-a);const j=(s.includes("n")||s.includes("s"))&&(s.includes("e")||s.includes("w"));if(o?.lockAspect&&j&&e.width>0&&e.height>0){const g=e.width/e.height;Math.abs(f-e.width)>=Math.abs(b-e.height)?(b=f/g,s.includes("n")&&(c=e.y+e.height-b)):(f=b*g,s.includes("w")&&(d=e.x+e.width-f))}return f<i&&(s.includes("w")&&(d=e.x+e.width-i),f=i,o?.lockAspect&&e.width>0&&e.height>0&&(b=f*(e.height/e.width),s.includes("n")&&(c=e.y+e.height-b))),b<u&&(s.includes("n")&&(c=e.y+e.height-u),b=u,o?.lockAspect&&e.width>0&&e.height>0&&(f=b*(e.width/e.height),s.includes("w")&&(d=e.x+e.width-f))),Ue({x:d,y:c,width:f,height:b},n)}function hl(e){if(!e)return null;try{const s=JSON.parse(e);return s.kind==="text"?{kind:"text"}:s.kind==="shape"&&s.shapeKind&&el.includes(s.shapeKind)?{kind:"shape",shapeKind:s.shapeKind}:s.kind==="line"&&s.lineKind&&tl.includes(s.lineKind)?{kind:"line",lineKind:s.lineKind}:null}catch{return null}}function fl(e,s,r){const a=r??pl(s,e.kind);
1if(e.kind==="shape")return{kind:"shape",...dt(a,cl(s),s),shapeKind:e.shapeKind??"rect",shapeStyle:{...ke}};if(e.kind==="line"){const o=ml(e.lineKind??"straight"),i=dt(a,ul(s,o.thickness),s,{fullWidth:!0});return{kind:"line",...i,x:da(i.width,s.width,o.align),lineStyle:o}}return{kind:"text",...dt(a,dl(s),s),text:"Text"}}function re(e,s){const r=s.trim().toLowerCase();return r?e.toLowerCase().includes(r):!0}function bl(e){const s=e.trim().toLowerCase();return s?{draw:ls.some(r=>re(r.label,s)||re("draw",s)),shapes:ds.some(r=>re(r.label,s)||re("shape",s)),lines:cs.some(r=>re(r.label,s)||re("line",s))}:{draw:!0,shapes:!0,lines:!0}}function Ee(e,s){const r=Ge(e).map(i=>i.key);if(!s||s.length===0)return r;const a=new Set(r),n=[],o=new Set;for(const i of s)!a.has(i)||o.has(i)||(n.push(i),o.add(i));for(const i of r)o.has(i)||n.push(i);return n}function gl(e,s,r){const a=e.indexOf(s),n=e.indexOf(r);if(a<0||n<0||a===n)return[...e];const o=e.slice(),[i]=o.splice(a,1);return o.splice(n,0,i),o}function ks(e,s){const r=new Set(s),a=e.filter(n=>r.has(n));for(const n of s)a.includes(n)||a.push(n);return a}function vl(e){return ks(Ee(e.sectionType,e.fieldOrder),e.fields)}function yl(e,s,r){const a=gl(Ee(e.sectionType,e.fieldOrder),s,r);return a.join("\0")===Ee(e.sectionType,e.fieldOrder).join("\0")?e:{...e,fieldOrder:a,fields:ks(a,e.fields)}}function jl(e,s){const r=Ee(e.sectionType,e.fieldOrder),a=e.fields.includes(s)?e.fields.filter(n=>n!==s):[...e.fields,s];return{...e,fields:ks(r,a)}}function hr(e,s){const r=Ee(e.sectionType,e.fieldOrder);return{...e,fields:s?[...r]:[]}}function Ae(e){return Object.fromEntries(e.map(s=>[s.key,""]))}function ye(e,s,r,a){return{id:e,index:s,title:r||`Item ${s}`,details:a.description||a.address||"",meta:[],price:a.price,values:a}}function at(e){return e==null?"":e?"Yes":"No"}function qt(e){return e==null||Number.isNaN(e)?"":ve(e)}function Nl(e,s){if(!e||!s)return"";const r=u=>{const d=/^(\d{1,2}):(\d{2})/.exec(u.trim());return d?Number(d[1])*60+Number(d[2]):null},a=r(e),n=r(s);if(a==null||n==null)return"";let o=n-a;o<0&&(o+=1440);const i=o/60;return Number.isInteger(i)?String(i):String(Math.round(i*100)/100)}function wl(e){const s=Number.isFinite(e.qty)&&Number.isFinite(e.priceSnapshot)?Math.round(e.qty*e.priceSnapshot):void 0;return{item_name:e.name||"",description:e.description||"",price:qt(e.priceSnapshot),quantity:Number.isFinite(e.qty)?String(e.qty):"",total:s==null?"":qt(s),category:e.category||e.group||"",allergens:Array.isArray(e.allergens)?e.allergens.filter(Boolean).join(", "):"",calories:"",course:e.group||"",revenue_type:e.revenueTypeName||"",prep_area:e.prepArea||"",vendor:e.vendor||"",unit:e.unit||"",cost:qt(e.cost),account_code:e.accountCode||"",prep_time:e.prepTimeMinutes==null?"":String(e.prepTimeMinutes),spice_level:"",menu_title:"",item_type:"",default_quantity:e.serves==null?"":String(e.serves),minimum_quantity:e.minimumQuantity==null?"":String(e.minimumQuantity),packing_unit:e.packingUnit||"",qty_per_packing_unit:e.qtyPerPackingUnit==null?"":String(e.qtyPerPackingUnit),link_quantity_to_guests:at(e.linkQuantityToGuestCount),exempt_tax:at(e.exemptTax),exempt_service_charge:at(e.exemptServiceCharge),exempt_gratuity:at(e.exemptGratuity)}}function kl(e,s){return s==="category"?e.category||e.group||"":s==="prepArea"?e.prepArea??null:s==="vendor"?e.vendor??null:null}function Sl(e,s){if(s.excludeWithoutQuantities&&!(e.qty>0))return!1;for(const r of s.filters||[]){if(!r.value)continue;const a=kl(e,r.key);if(a==null)continue;const n=a.toLowerCase()===r.value.trim().toLowerCase();if(r.operator==="does-not-equal"?n:!n)return!1}return!0}function Cl(e,s){const r=e.venueSnapshot?.name||e.siteSnapshot?.name||e.roomName||"",a={...Ae(gt),subevent_name:e.name||"",subevent_type:e.type||"",subevent_date:ue(e.date),subevent_start:e.startTime||"",subevent_end:e.endTime||"",subevent_min_guests:e.guests?.min==null?"":String(e.guests.min),subevent_est_guests:e.guests?.est==null?"":String(e.guests.est),subevent_actual_guests:e.guests?.act==null?"":String(e.guests.act),subevent_location:r,subevent_setup_style:e.setupStyle||"",subevent_setup_time:e.setupTime==null?"":String(e.setupTime),subevent_teardown_time:e.teardownTime==null?"":String(e.teardownTime)}
1;return ye(e.id||`subevent-${s}`,s,a.subevent_name,a)}function _l(e){const s=[],r=new Set;for(const a of e){const n=a.siteSnapshot;if(!n?.id||r.has(n.id))continue;r.add(n.id);const o={...Ae(vt),site_name:n.name||"",address:[n.address1,n.address2].filter(Boolean).join(", "),city:n.city||"",phone:n.phone||"",email:n.email||"",contact:n.contactPerson||"",notes:n.directions||""};s.push(ye(`site-${n.id}`,s.length+1,o.site_name,o))}return s}function Tl(e){const s=new Map;for(const r of e){const a=r.venueSnapshot;if(!a?.id)continue;const n=s.get(a.id)??{name:a.name||"",capacity:a.capacity==null?"":String(a.capacity),rooms:new Set},o=r.roomName||r.roomNumber;o&&n.rooms.add(o),s.set(a.id,n)}return[...s.entries()].map(([r,a],n)=>ye(`venue-${r}`,n+1,a.name,{...Ae(yt),venue_name:a.name,rooms:[...a.rooms].join(", "),capacity:a.capacity}))}function El(e){return e.map((s,r)=>{const a=[s.firstName,s.lastName].filter(Boolean).join(" "),n={...Ae(jt),guest_name:a,table:s.table||"",meal:s.meal||"",notes:s.dietaryNotes||""};return ye(s.id||`guest-${r+1}`,r+1,a,n)})}function Pl(e){const s=[];for(const r of e){const a=r.assignments?.length?r.assignments:[void 0];for(const n of a){const o=n?.timeIn||r.timeIn||"",i=n?.timeOut||r.timeOut||"",u={...Ae(Nt),shift_name:r.role||"",position:n?.positionName||r.role||"",staff_name:n?.employeeName||"",start_time:o,end_time:i,hours:Nl(o,i)};s.push(ye(`${r.id}-${s.length+1}`,s.length+1,u.shift_name,u))}}return s}function Al(e,s){const r=e.sectionType||"menu-items";if(r==="menu-items")return s.menuItems?s.menuItems.filter(a=>Sl(a,e)).map((a,n)=>{const o=wl(a);return ye(a.id||`menu-${n+1}`,n+1,o.item_name,o)}):null;if(r==="event-details"){const a={...Ae(bt),...s.values};return[ye("event-details",1,a.event_name||"Event",a)]}return r==="subevents"?s.subevents?s.subevents.map((a,n)=>Cl(a,n+1)):null:r==="site-locations"?s.subevents?_l(s.subevents):null:r==="venues"?s.subevents?Tl(s.subevents):null:r==="guest-lists"?s.guestList?El(s.guestList):null:r==="shifts-staff"&&s.shifts?Pl(s.shifts):null}function Il(e){if(!Array.isArray(e))return null;const s=[];for(const r of e){if(!r||typeof r!="object")continue;const a=r;typeof a.name=="string"&&s.push({...a,id:typeof a.id=="string"?a.id:`menu-${s.length+1}`,name:a.name,qty:Number(a.qty)||0,priceSnapshot:Number(a.priceSnapshot)||0})}return s}function Fl(e){if(!e||typeof e!="object")return null;const s=e;return!s.event&&!s.proposal?null:{event:s.event,proposal:s.proposal,subevents:Array.isArray(s.subevents)?s.subevents:[],shifts:Array.isArray(s.shifts)?s.shifts:[]}}function Ml(e){const s={values:e.values};return e.menuItems!=null&&(s.menuItems=e.menuItems),e.detail&&(s.subevents=e.detail.subevents,s.shifts=e.detail.shifts,s.guestList=e.detail.event?.guestList??[]),s}function Dl({section:e,selected:s,element:r,siblings:a,liveSections:n,mergedValues:o}){const i=e?ts(e):void 0;if(!i)return null;const u=i.groupBySubevent?Or(i.subeventHeaderFields,o):"",d=ia(i,i.sectionType),c=n?Al(i,n):null,f=c??Di(i.sectionType,lt(d.layoutMode)),b=vl(i);if(c&&c.length===0&&i.suppressWhenEmpty)return null;const j=js(d.layoutMode,d.customColumnCount),g=i.cornerRadius,S=i.headerStyle,$=i.fields.length,B=d.wrapTextAroundObject&&r&&a?is(r,a.filter(A=>A.id!==r.id)):[],N=d.wrapTextAroundObject&&r?na(r,B):{left:0,right:0};return t.jsxs("div",{className:k("flex h-full w-full flex-col overflow-hidden bg-card",s&&"ring-0"),style:{borderRadius:g,background:i.backgroundColor,border:i.showBorders?"1px solid #E2E8F0":"1px solid #E5E7EB",fontFamily:i.fontFamily},"data-testid":"print-menu-items-block","data-layout":d.layoutMode,children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 text-[11px] font-semibold tracking-wide text-white",style:{background:S==="gradient"?`linear-gradient(90deg, ${i.accentColor}, ${i.accentColor}99)`:S==="minimal"||S==="sidebar"?"transparent":i.accentColor,color:S==="minimal"||S==="sidebar"?"#334155":"#fff",borderBottom:S==="minimal"?`2px solid ${i.accentColor}`:void 0,borderLeft:S==="sidebar"?`6px solid ${i.accentColor}`:void 0,borderRadius:S==="solid"||S==="gradient"?`${g}px ${g}px 0 0`:0},children:[t.jsx("span",{children:i.title.toUpperCase()}),t.jsxs("span",{className:"rounded-full bg-card/20 px-2 py-0.5 text-[10px] font-medium",children:[$," Fields"]})]}),t.jsxs("div",{className:k("min-h-0 flex-1 px-3 py-2",c&&"overflow-y-auto"),style:{paddingLeft:12+N.left,paddingRight:12+N.right},"data-testid":"print-section-items","data-field-order":b.join(","),children:[u&&t.jsx("div",{"data-testid":"print-subevent-group-header",className:"mb-2 rounded-md px-2 py-1 text-[11px] font-semibold text-foreground",style:{background:`${i.accentColor}22`},children:u}),d.layoutMode==="custom"?t.jsx(Rl,{items:f,columns:d.customColumnCount,rows:d.customRows,type:i.sectionType,showDividers:d.showDividers,alternateRowTint:d.alternateRowTint,tint:i.accentColor}):t.jsx("div",{className:"grid",style:{gridTemplateColumns:`repeat(${j}, minmax(0, 1fr))`,gap:la(d.layoutMode)?8:d.layoutMode==="compact"?2:6},children:f.map(A=>t.jsx(Ll,{item:A,mode:d.layoutMode,radius:g,fields:b},A.id))}),i.insertSummaryRow&&t.jsxs("div",{className:"mt-2 flex justify-between pt-1 text-[12px] font-semibold text-foreground",children:[t.jsx("span",{children:"Menu Revenue Total"}),t.jsx("span",{children:"{{menu_revenue_total}}"})]})]})]})}function Ll({item:e,mode:s,radius:r,fields:a}){const n=la(s);return t.jsxs("div",{"data-testid":`print-section-item-${e.index}`,"data-field-order":a.join(","),className:k("flex items-start gap-2",s==="compact"?"py-0.5":"",n&&"border border-border bg-card px-2.5 py-2 shadow-sm",s==="list"&&"border-b border-border pb-2 last:border-0 last:pb-0"),style:{borderRadius:n?Math.max(4,r-2):void 0},children:[s==="numbered"&&t.jsxs("span",{className:"w-4 shrink-0 text-[12px] font-semibold text-muted-foreground","data-testid":"print-section-number",children:[e.index,"."]}),s==="checklist"&&t.jsx("span",{className:"mt-0.5 h-3.5 w-3.5 shrink-0 rounded-full border border-border","data-testid":"print-section-check"}),t.jsx("div",{className:"grid min-w-0 flex-1",style:{gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:s==="compact"?2:4,gridAutoFlow:"row"},"data-testid":"print-section-field-grid",children:a.map((o,i)=>t.jsx("span",{"data-testid":`print-section-field-${e.index}-${o}`,"data-field-key":o,"data-field-index":i,className:k("truncate",i===0?"text-[13px] font-semibold text-foreground":"text-[11px] text-muted-foreground",s==="compact"&&"text-[12px]"),children:e.values[o]||""},o))})]})}function Rl({items:e,columns:s,rows:r,type:a,showDividers:n,alternateRowTint:o,tint:i}){const u=Ge(a),d=c=>u.find(f=>f.key===c)?.label||c;return t.jsxs("div",{className:"space-y-0","data-testid":"print-section-custom",children:[t.jsx("div",{className:"mb-1 grid text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",style:{gridTemplateColumns:`repeat(${s}, minmax(0, 1fr))`,gap:8},children:r[0]?.map((c,f)=>t.jsx("span",{children:c?d(c):""},`${c}-${f}`))}),e.map((c,f)=>t.jsx("div",{"data-testid":`print-section-item-${c.index}`,className:k(n&&"border-b border-border"),style:{background:o&&f%2===1?`${i}14`:void 0},children:r.map((b,j)=>t.jsx("div",{className:"grid py-1 text-[12px] text-foreground",style:{gridTemplateColumns:`repeat(${s}, minmax(0, 1fr))`,gap:8},children:b.map((g,S)=>t.jsx("span",{className:k("truncate",j===0&&S===0&&"font-semibold"),children:g&&c.values[g]||""},`${c.id}-${j}-${S}`))},`${c.id}-${j}`))},c.id))]})}const fr={n:{cursor:"ns-resize",className:"left-1/2 top-0 -translate-x-1/2 -translate-y-1/2"},s:{cursor:"ns-resize",className:"left-1/2 bottom-0 -translate-x-1/2 translate-y-1/2"},e:{cursor:"ew-resize",className:"right-0 top-1/2 translate-x-1/2 -translate-y-1/2"},w:{cursor:"ew-resize",className:"left-0 top-1/2 -translate-x-1/2 -translate-y-1/2"},ne:{cursor:"nesw-resize",className:"right-0 top-0 translate-x-1/2 -translate-y-1/2"},nw:{cursor:"nwse-resize",className:"left-0 top-0 -translate-x-1/2 -translate-y-1/2"},se:{cursor:"nwse-resize",className:"right-0 bottom-0 translate-x-1/2 translate-y-1/2"},sw:{cursor:"nesw-resize",className:"left-0 bottom-0 -translate-x-1/2 translate-y-1/2"}};function Ss({page:e,pagePx:s,zoom:r,elements:a,selectedId:n,selectedIds:o,snapEnabled:i=!1,onSelect:u,onMove:d,onMoveMany:c,onResize:f,onDropField:b,onDropTool:j,onDropUpload:g,onChangeText:S,mergedValues:$,liveSections:B,interactive:N=!0,embedded:A=!1}){const Q=y.useRef(null),[P,W]=y.useState([]),O=r/100,R=o??(n?[n]:[]),J=R[R.length-1]??null,M=(T,C)=>{const D=Q.current?.getBoundingClientRect();return D?{x:(T-D.left)/O,y:(C-D.top)/O}:{x:0,y:0}},E=T=>{if(!N)return;T.preventDefault();const C=M(T.clientX,T.clientY),D=hl(T.dataTransfer.getData(ws));if(D){j?.(D,C.x,C.y);return}const z=zi(T.dataTransfer.getData(oa));if(z){g?.(z,C.x,C.y);return}const _=T.dataTransfer.getData("application/x-print-merge-field")||T.dataTransfer.getData("text/plain");_&&b(_,C.x,C.y)};return A?t.jsx("div",{ref:Q,"data-testid":"print-designer-page",className:"cover-print-page relative min-h-[320px] w-full bg-card",style:{width:s.width*O,height:s.height*O},onMouseDown:T=>{T.stopPropagation(),N&&u(null)},onDragOver:T=>{N&&(T.preventDefault(),T.dataTransfer.dropEffect="copy")},onDrop:E,children:t.jsxs("div",{className:"absolute inset-0 origin-top-left",style:{width:s.width,height:s.height,transform:`scale(${O})`},children:[a.map(T=>t.jsx(gr,{element:T,siblings:a,selected:N&&R.includes(T.id),showHandles:N&&J===T.id,selectedIds:R,snapEnabled:i,pagePx:s,onSelect:u,onMove:d,onMoveMany:c,onResize:f,onChangeText:S,pointOnPage:M,setGuides:W,mergedValues:$,liveSections:B,interactive:N},T.id)),t.jsx(vr,{guides:P})]})}):t.jsx("div",{className:"flex-1 min-w-0 overflow-auto bg-[hsl(var(--cover-muted))]","data-testid":"print-designer-canvas-scroll",onMouseDown:()=>{N&&u(null)},children:t.jsx("div",{className:"min-h-full min-w-full flex items-start justify-center px-10 py-8",children:t.jsxs("div",{style:{width:s.width*O},children:[t.jsxs("div",{className:"mb-2 flex items-baseline gap-2 text-[11px] text-foreground",children:[t.jsx("span",{className:"font-medium text-foreground",children:"Page 1"}),t.jsx("span",{children:e.label})]}),t.jsx("div",{ref:Q,"data-testid":"print-designer-page",className:"cover-print-page relative bg-card shadow-[0_18px_50px_rgba(15,23,42,0.12)]",style:{width:s.width*O,height:s.height*O,outline:"1px solid #93C5FD"},onMouseDown:T=>T.stopPropagation(),onDragOver:T=>{N&&(T.preventDefault(),T.dataTransfer.dropEffect="copy")},onDrop:E,children:t.jsxs("div",{className:"absolute inset-0 origin-top-left",style:{width:s.width,height:s.height,transform:`scale(${O})`},children:[a.map(T=>t.jsx(gr,{element:T,siblings:a,selected:N&&R.includes(T.id),showHandles:N&&J===T.id,selectedIds:R,snapEnabled:i,pagePx:s,onSelect:u,onMove:d,onMoveMany:c,onResize:f,onChangeText:S,pointOnPage:M,setGuides:W,mergedValues:$,liveSections:B,interactive:N},T.id)),t.jsx(vr,{guides:P})]})}),t.jsx("div",{className:"sr-only",children:ss(e)})]})})})}function br(e,s,r,a){if(a){a(e,s);return}const n=e[0];n&&r(n.id,n.x,n.y,s)}function gr({element:e,siblings:s,selected:r,showHandles:a,selectedIds:n,snapEnabled:o,pagePx:i,onSelect:u,onMove:d,onMoveMany:c,onResize:f,onChangeText:b,pointOnPage:j,setGuides:g,mergedValues:S,liveSections:$,interactive:B}){const N=P=>{if(P.preventDefault(),P.stopPropagation(),!B)return;const W=P.shiftKey||P.metaKey||P.ctrlKey;let O;if(W){if(n.includes(e.id)){u(e.id,{additive:!0});return}
1O=[...n,e.id],u(e.id,{additive:!0})}else n.includes(e.id)?O=n:(O=[e.id],u(e.id));const R=new Map;for(const z of O){const _=s.find(H=>H.id===z);_&&R.set(z,{x:_.x,y:_.y})}R.set(e.id,{x:e.x,y:e.y});const J=s.filter(z=>!R.has(z.id)),M=j(P.clientX,P.clientY);let E=!1,T=[...R.entries()].map(([z,_])=>({id:z,x:_.x,y:_.y}));const C=z=>{const _=j(z.clientX,z.clientY),H=e.x+(_.x-M.x),Z=e.y+(_.y-M.y),se=o?Zr({x:H,y:Z,width:e.width,height:e.height},J):{x:H,y:Z,guides:[]},G=se.x-e.x,X=se.y-e.y;(Math.abs(_.x-M.x)>.5||Math.abs(_.y-M.y)>.5)&&(E=!0),g(se.guides),T=[...R.entries()].map(([le,ee])=>({id:le,x:ee.x+G,y:ee.y+X})),br(T,!1,d,c)},D=()=>{if(window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",D),g([]),!E){!W&&n.length>1&&n.includes(e.id)&&u(e.id);return}T.some(_=>{const H=R.get(_.id);return H!=null&&(Math.abs(_.x-H.x)>.01||Math.abs(_.y-H.y)>.01)})&&br(T,!0,d,c)};window.addEventListener("mousemove",C),window.addEventListener("mouseup",D)},A=(P,W)=>{P.preventDefault(),P.stopPropagation();const O=j(P.clientX,P.clientY),R={x:e.x,y:e.y,width:e.width,height:e.height},J=ll(e.kind),M=e.kind==="image"&&W.length===2,E=s.filter(_=>_.id!==e.id);let T=!1,C=R;const D=_=>{const H=j(_.clientX,_.clientY),Z=xl(R,W,H.x-O.x,H.y-O.y,i,{...J,lockAspect:M}),se=o?Ni(Z,W,E,{minWidth:J.minWidth}):{...Z,guides:[]},{guides:G,...X}=se;C=Ue(X,i),(Math.abs(H.x-O.x)>.5||Math.abs(H.y-O.y)>.5)&&(T=!0),g(G.filter(le=>le.orientation!=="vertical"||Math.abs(C.x-le.position)<=.5||Math.abs(C.x+C.width-le.position)<=.5)),f(e.id,C,!1)},z=()=>{window.removeEventListener("mousemove",D),window.removeEventListener("mouseup",z),g([]);const _=Math.abs(C.x-R.x)>.01||Math.abs(C.y-R.y)>.01||Math.abs(C.width-R.width)>.01||Math.abs(C.height-R.height)>.01;T&&_&&f(e.id,C,!0)};window.addEventListener("mousemove",D),window.addEventListener("mouseup",z)},Q=il(e.kind);return t.jsxs("div",{"data-testid":`print-el-${e.id}`,className:k("absolute",r&&"z-10"),style:{left:e.x,top:e.y,width:e.width,height:e.height},onMouseDown:N,children:[e.kind==="merge-field"?t.jsx(Ul,{element:e,selected:r,mergedValues:S}):e.kind==="text"?t.jsx(Ol,{element:e,selected:r&&B,onChangeText:B?b:void 0,mergedValues:S}):e.kind==="shape"?t.jsx($l,{element:e}):e.kind==="line"?t.jsx(Hl,{element:e}):e.kind==="image"?t.jsx(Bl,{element:e}):t.jsx(Dl,{section:e.section,selected:r,element:e,siblings:s,liveSections:$,mergedValues:S}),r&&t.jsx("div",{className:"pointer-events-none absolute inset-0 border-2 border-blue-500",children:a&&Q.map(P=>t.jsx("button",{type:"button","data-testid":`print-handle-${P}`,className:k("pointer-events-auto absolute h-2.5 w-2.5 rounded-full border-2 border-blue-500 bg-card",fr[P].className),style:{cursor:fr[P].cursor},onMouseDown:W=>A(W,P)},P))})]})}function vr({guides:e}){return t.jsx(t.Fragment,{children:e.map((s,r)=>t.jsx("div",{"data-testid":"print-snap-guide","data-orientation":s.orientation,className:"pointer-events-none absolute z-30 bg-fuchsia-500",style:s.orientation==="vertical"?{left:s.position,top:s.from,width:1,height:Math.max(s.to-s.from,1)}:{top:s.position,left:s.from,height:1,width:Math.max(s.to-s.from,1)}},`${s.orientation}-${s.position}-${r}`))})}function Ol({element:e,selected:s,onChangeText:r,mergedValues:a}){const n=e.style,o=a?xi(e.text,a):e.text||"Text";return t.jsx("div",{className:"h-full w-full overflow-hidden px-2 py-1","data-testid":`print-text-${e.id}`,style:{fontFamily:n.fontFamily,fontSize:n.fontSize,fontWeight:n.bold?700:400,fontStyle:n.italic?"italic":"normal",color:n.color,letterSpacing:`${n.letterSpacing}px`,lineHeight:n.lineHeight,opacity:n.opacity,textAlign:n.align},children:s?t.jsx("textarea",{"data-testid":"print-text-content",value:e.text??"",onChange:i=>r?.(e.id,i.target.value),onMouseDown:i=>i.stopPropagation(),className:"h-full w-full resize-none bg-transparent outline-none"}):t.jsx("div",{className:"whitespace-pre-wrap",children:o})})}function $l({element:e}){const s=e.shapeStyle,r=e.shapeKind||"rect",a=r==="triangle"?"polygon(50% 0%, 0% 100%, 100% 100%)":r==="star"?"polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%)":void 0;return t.jsx("div",{"data-testid":`print-shape-${e.id}`,"data-shape":r,className:"h-full w-full",style:{background:s?.fill||"#E2E8F0",border:`${s?.borderWidth??2}px ${s?.borderStyle||"solid"} ${s?.borderColor||"#334155"}`,borderRadius:r==="circle"?"9999px":4,clipPath:a}})}function Bl({element:e}){return t.jsx("img",{src:e.imageSrc,alt:e.imageName||"Upload","data-testid":`print-image-${e.id}`,className:"h-full w-full object-contain",draggable:!1})}function Hl({element:e}){const s=e.lineStyle,r=s?.variant||"straight",a=s?.thickness??2,n=s?.color||"#111827";return t.jsx("div",{className:"flex h-full w-full items-center","data-testid":`print-line-${e.id}`,"data-line":r,children:r==="decorative"?t.jsx("div",{className:"w-full rounded-sm",style:{height:a,background:`linear-gradient(90deg, #FDE047, ${n})`}}):t.jsx("div",{className:"w-full",style:{borderTop:`${a}px ${r==="dashed"?"dashed":"solid"} ${n}`}})})}function Ul({element:e,selected:s,mergedValues:r}){const a=e.style,n=e.fieldKey?r?.[e.fieldKey]:void 0;return t.jsx("div",{className:k("h-full w-full rounded-full px-3 flex items-center gap-2 overflow-hidden",s?"bg-blue-50":"bg-sky-50/80"),style:{fontFamily:a.fontFamily,fontSize:a.fontSize,fontWeight:a.bold?700:500,fontStyle:a.italic?"italic":"normal",color:a.color,letterSpacing:`${a.letterSpacing}px`,lineHeight:a.lineHeight,opacity:a.opacity,justifyContent:a.al
1ign==="center"?"center":a.align==="right"?"flex-end":"flex-start",textAlign:a.align},children:n!=null&&n!==""?t.jsx("span",{className:"truncate","data-testid":"print-merge-value",children:n}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"truncate",children:e.fieldLabel}),t.jsx("span",{className:"truncate font-mono text-[11px] opacity-70",children:e.fieldToken})]})})}const zl=Po.create({name:"image",inline:!0,group:"inline",atom:!0,addAttributes(){return{src:{default:null},alt:{default:""}}},parseHTML(){return[{tag:"img[src]"}]},renderHTML({HTMLAttributes:e}){return["img",Ao(e,{class:"inline-block max-h-16 align-middle"})]}}),Wl=$o.extend({addAttributes(){return{...this.parent?.(),fontSize:{default:null,parseHTML:e=>e.style.fontSize||null,renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}});function Gl({title:e,onClose:s}){return t.jsxs("div",{className:"flex items-center justify-between px-4 pb-3 pt-4",children:[t.jsx("h2",{className:"text-[13px] font-semibold tracking-[0.14em] text-foreground",children:e}),t.jsx("button",{type:"button",onClick:s,className:"h-6 w-6 rounded-md text-muted-foreground hover:bg-accent hover:text-foreground","aria-label":`Close ${e}`,children:"Ã"})]})}function ct({label:e,onRemove:s}){return t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-[hsl(var(--cover-user-accent))] px-2.5 py-0.5 text-[11px] font-medium text-white","data-testid":"email-recipient-chip",children:[t.jsx("span",{className:"truncate",children:e}),s&&t.jsx("button",{type:"button",onClick:s,className:"text-white/80 hover:text-white","aria-label":`Remove ${e}`,children:t.jsx(Zt,{className:"h-3 w-3"})})]})}function Yt({label:e,placeholder:s,recipients:r,testId:a,onChange:n}){const[o,i]=y.useState(""),u=(d=o)=>{const c=sr(r,d);c!==r&&(n(c),i(""))};return t.jsxs("div",{className:"space-y-2","data-testid":a,children:[t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:e}),t.jsxs("div",{className:"flex min-h-9 flex-wrap items-center gap-1.5 rounded-lg border border-border bg-card px-2 py-1.5 focus-within:border-[hsl(var(--cover-user-accent))]",children:[r.map(d=>t.jsx(ct,{label:d.label,onRemove:()=>n(Br(r,d.id))},d.id)),t.jsx("input",{value:o,onChange:d=>i(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),u())},onBlur:()=>u(),placeholder:r.length?"":s,"data-testid":`${a}-input`,className:"min-w-[8rem] flex-1 bg-transparent text-[12px] text-foreground outline-none placeholder:text-muted-foreground"})]}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:Jn.map(d=>t.jsx("button",{type:"button","data-testid":`${a}-suggest-${d.id}`,onClick:()=>n(sr(r,d.kind==="list"?d.label:d.value)),className:"rounded-full bg-[hsl(var(--cover-user-accent-subtle))] px-2.5 py-1 font-mono text-[10px] text-[hsl(var(--cover-user-accent-text))] hover:bg-[hsl(var(--cover-user-accent-soft))]",children:d.label},d.id))})]})}function Kl({html:e,onChange:s}){const r=y.useRef(null),a=Co({extensions:[_o,To,Wl,Io.configure({types:["textStyle"]}),Fo.configure({types:["textStyle"]}),Mo.configure({types:["heading","paragraph"]}),zl],content:e||"",editorProps:{attributes:{class:"min-h-[92px] px-3 py-2 text-[12px] leading-relaxed text-foreground focus:outline-none [&_p]:my-0.5","data-testid":"email-signature-editor"}},onUpdate({editor:o}){s(o.getHTML())}});y.useEffect(()=>{!a||a.isDestroyed||e!==a.getHTML()&&a.commands.setContent(e||"",{emitUpdate:!1})},[a,e]);const n=o=>k("flex h-7 w-7 items-center justify-center rounded-md",o?"bg-[hsl(var(--cover-user-accent-subtle))] text-[hsl(var(--cover-user-accent-text))]":"text-muted-foreground hover:bg-accent");return t.jsxs("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"email-signature-box",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 border-b border-border bg-muted/60 px-1.5 py-1",children:[t.jsx("button",{type:"button",className:n(!!a?.isActive("bold")),onClick:()=>a?.chain().focus().toggleBold().run(),"aria-label":"Bold",children:t.jsx(Bo,{className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button",className:n(!!a?.isActive("italic")),onClick:()=>a?.chain().focus().toggleItalic().run(),"aria-label":"Italic",children:t.jsx(Ho,{className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button",className:n(!!a?.isActive("underline")),onClick:()=>a?.chain().focus().toggleUnderline().run(),"aria-label":"Underline",children:t.jsx(Do,{
1className:"h-3.5 w-3.5"})}),t.jsx("span",{className:"mx-1 h-4 w-px bg-border"}),t.jsx("button",{type:"button",className:n(!!a?.isActive({textAlign:"left"})),onClick:()=>a?.chain().focus().setTextAlign("left").run(),"aria-label":"Align left",children:t.jsx(Lo,{className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button",className:n(!!a?.isActive({textAlign:"center"})),onClick:()=>a?.chain().focus().setTextAlign("center").run(),"aria-label":"Align center",children:t.jsx(Ro,{className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button",className:n(!!a?.isActive({textAlign:"right"})),onClick:()=>a?.chain().focus().setTextAlign("right").run(),"aria-label":"Align right",children:t.jsx(Oo,{className:"h-3.5 w-3.5"})}),t.jsxs("select",{className:"ml-1 h-7 rounded-md border border-border bg-card px-1 text-[11px] text-foreground","data-testid":"email-signature-size",defaultValue:"13px",onChange:o=>a?.chain().focus().setMark("textStyle",{fontSize:o.target.value}).run(),children:[t.jsx("option",{value:"11px",children:"11"}),t.jsx("option",{value:"13px",children:"13"}),t.jsx("option",{value:"16px",children:"16"}),t.jsx("option",{value:"20px",children:"20"})]}),t.jsx("select",{className:"h-7 max-w-[7rem] rounded-md border border-border bg-card px-1 text-[11px] text-foreground","data-testid":"email-signature-font",defaultValue:"Inter",onChange:o=>a?.chain().focus().setFontFamily(o.target.value).run(),children:We.map(o=>t.jsx("option",{value:o,children:o},o))}),t.jsx("input",{type:"color","aria-label":"Text color","data-testid":"email-signature-color",className:"h-7 w-7 cursor-pointer rounded-md border border-border bg-card p-0.5",onChange:o=>a?.chain().focus().setColor(o.target.value).run()}),t.jsx("button",{type:"button",className:n(!1),onClick:()=>r.current?.click(),"aria-label":"Insert image",children:t.jsx(dn,{className:"h-3.5 w-3.5"})}),t.jsx("input",{ref:r,type:"file",accept:"image/*",className:"hidden","data-testid":"email-signature-image",onChange:o=>{const i=o.target.files?.[0];if(o.target.value="",!i)return;const u=new FileReader;u.onload=()=>{const d=typeof u.result=="string"?u.result:"";d&&a?.chain().focus().insertContent({type:"image",attrs:{src:d,alt:i.name}}).run()},u.readAsDataURL(i)}})]}),t.jsx(Eo,{editor:a})]})}function Ql({settings:e,helperQuery:s,onHelperQuery:r,onChange:a,onClose:n}){const[o,i]=y.useState(!1),u=y.useRef(null),d=c=>a({...e,...c});return t.jsxs("div",{className:"flex h-full flex-col","data-testid":"print-email-settings-pane",children:[t.jsx(Gl,{title:"EMAIL SETTINGS",onClose:n}),t.jsx("div",{className:"px-4",children:t.jsxs("label",{className:"relative block",children:[t.jsx(ne,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-blue-500"}),t.jsx("input",{value:s,onChange:c=>r(c.target.value),placeholder:"Help me create my perfect print...","data-testid":"email-settings-helper",className:"h-9 w-full rounded-full border border-border bg-muted pl-9 pr-3 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-[hsl(var(--cover-user-accent))] focus:bg-card focus:outline-none"})]})}),t.jsxs("div",{className:"flex-1 space-y-5 overflow-y-auto px-4 py-4",children:[t.jsx(Yt,{label:"TO",placeholder:"Add recipient...",recipients:e.to,testId:"email-to",onChange:c=>d({to:c})}),t.jsx(Yt,{label:"CC",placeholder:"Add Cc recipient...",recipients:e.cc,testId:"email-cc",onChange:c=>d({cc:c})}),t.jsx(Yt,{label:"BCC",placeholder:"Add Bcc recipient...",recipients:e.bcc,testId:"email-bcc",onChange:c=>d({bcc:c})}),t.jsxs("div",{className:"space-y-2","data-testid":"email-subject",children:[t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"SUBJECT LINE"}),t.jsx("input",{value:e.subject,onChange:c=>d({subject:c.target.value}),"data-testid":"email-subject-input",className:"h-9 w-full rounded-lg border border-border bg-card px-3 text-[12px] text-foreground focus:border-[hsl(var(--cover-user-accent))] focus:outline-none"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:Kn.map(c=>t.jsx("button",{type:"button","data-testid":`email-subject-suggest-${c.replace(/[{}]/g,"")}`,onClick:()=>d({subject:Qn(e.subject,c)}),className:"rounded-full bg-[hsl(var(--cover-user-accent-subtle))] px-2.5 py-1 font-mono text-[10px] text-[hsl(var(--cover-user-accent-text))] hover:bg-[hsl(var(--cover-user-accent-soft))]",children:c},c))})]}),t.jsxs("div",{className:"space-y-2","data-testid":"email-attachments",children:[t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"ATTACHMENTS"}),t.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Select files from this event to attach"}),t.jsx("div",{className:"space-y-1.5",children:e.attachments.map(c=>t.jsxs("button",{type:"button","data-testid":`email-attachment-${c.id}`,onClick:()=>d({attachments:qn(e.attachments,c.id)}),className:k("flex w-full items-center justify-between rounded-lg border px-3 py-2 text-left text-[12px]",c.selected?"border-[hsl(var(--cover-user-accent))] bg-[hsl(var(--cover-user-accent-subtle)/0.7)] text-foreground":"border-border bg-card text-foreground hover:bg-muted"),children:[t.jsx("span",{className:"truncate",children:c.name}),c.selected&&t.jsx(Xt,{className:"h-4 w-4 text-[hsl(var(--cover-user-accent-text))]"})]},c.id))}),t.jsx("button",{type:"button","data-testid":"email-upload-attachment",onClick:()=>u.current?.click(),className:"flex h-9 w-full items-center justify-center rounded-lg border border-dashed border-[hsl(var(--cover-user-accent-border))] text-[12px] font-medium text-[hsl(var(--cover-user-accent-text))] hover:bg-[hsl(var(--cover-user-accent-subtle))]",children:"+ Upload custom attachment"}),t.jsx("input",{ref:u,type:"file",className:"hidden","data-testid":"email-upload-attachment-input",onChange:c=>{const f=c.target.files?.[0];c.target.value="",f&&d({attachments:Yn(e.attachments,f.name)}
1)}})]}),t.jsxs("div",{className:"space-y-2","data-testid":"email-signature",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"SIGNATURE"}),o?t.jsx("button",{type:"button",onClick:()=>i(!1),className:"text-[12px] font-medium text-[hsl(var(--cover-user-accent-text))]","data-testid":"email-signature-done",children:"Done"}):t.jsx("button",{type:"button",onClick:()=>i(!0),className:"text-[12px] font-medium text-[hsl(var(--cover-user-accent-text))]","data-testid":"email-signature-edit",children:"Edit"})]}),o?t.jsx(Kl,{html:e.signatureHtml,onChange:c=>d({signatureHtml:c})}):t.jsx("div",{className:"rounded-lg border border-border bg-card px-3 py-2 text-[12px] leading-relaxed text-foreground","data-testid":"email-signature-preview",dangerouslySetInnerHTML:{__html:e.signatureHtml}})]}),t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"SEND SETTINGS"}),t.jsxs("label",{className:"block space-y-1.5","data-testid":"email-from-name",children:[t.jsx("span",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"FROM NAME"}),t.jsx("input",{value:e.fromName,onChange:c=>d({fromName:c.target.value}),"data-testid":"email-from-name-input",className:"h-9 w-full rounded-lg border border-border bg-card px-3 text-[12px] text-foreground focus:border-[hsl(var(--cover-user-accent))] focus:outline-none"})]}),t.jsxs("label",{className:"block space-y-1.5","data-testid":"email-reply-to",children:[t.jsx("span",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"REPLY-TO"}),t.jsx("input",{value:e.replyTo,onChange:c=>d({replyTo:c.target.value}),placeholder:"Optional reply-to address","data-testid":"email-reply-to-input",className:"h-9 w-full rounded-lg border border-border bg-card px-3 text-[12px] text-foreground focus:border-[hsl(var(--cover-user-accent))] focus:outline-none"})]})]})]})}function ql({recordType:e,settings:s,page:r,zoom:a,elements:n,selectedId:o,selectedIds:i,snapEnabled:u=!1,showCc:d,showBcc:c,onShowCc:f,onShowBcc:b,onChange:j,onOpenMergeFields:g,onSelect:S,onMove:$,onMoveMany:B,onResize:N,onDropField:A,onDropTool:Q,onChangeText:P}){const W=a/100,O=Vn(e),R=He-32,J=s.attachments.filter(M=>M.selected);return t.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-[hsl(var(--cover-muted))]","data-testid":"email-designer-canvas",children:t.jsx("div",{className:"flex min-h-full items-start justify-center px-8 py-8",children:t.jsx("div",{style:{width:He*W},children:t.jsxs("div",{className:"origin-top-left overflow-hidden rounded-xl bg-card shadow-[0_18px_50px_rgba(15,23,42,0.12)]",style:{width:He,transform:`scale(${W})`},"data-testid":"email-template-card",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 bg-[hsl(var(--cover-user-accent))] px-4 py-2.5 text-white",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(xt,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"truncate text-[13px] font-semibold","data-testid":"email-canvas-title",children:O})]}),t.jsx("span",{className:"shrink-0 text-[11px] text-blue-100",children:"Attachments, merge fields & recipients reflect this record type"})]}),t.jsxs("div",{className:"space-y-3 px-4 py-4",children:[t.jsxs("div",{className:"flex items-center gap-3 text-[12px]",children:[t.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:"From"}),t.jsx("span",{className:"text-foreground","data-testid":"email-canvas-from",children:s.fromAddress})]}),t.jsxs("div",{className:"flex items-center gap-3 text-[12px]",children:[t.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:"To"}),t.jsx("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5","data-testid":"email-canvas-to",children:s.to.map(M=>t.jsx(ct,{label:M.label,onRemove:()=>j({...s,to:Br(s.to,M.id)})},M.id))}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2 text-[12px] font-medium text-[hsl(var(--cover-user-accent-text))]",children:[t.jsx("button",{type:"button",onClick:f,"data-testid":"email-canvas-cc",children:"Cc"}),t.jsx("button",{type:"button",onClick:b,"data-testid":"email-canvas-bcc",children:"Bcc"})]})]}),(d||s.cc.length>0)&&t.jsxs("div",{className:"flex items-center gap-3 text-[12px]","data-testid":"email-canvas-cc-row",children:[t.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:"Cc"}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[s.cc.map(M=>t.jsx(ct,{label:M.label},M.id)),s.cc.length===0&&t.jsx("span",{className:"text-muted-foreground",children:"None"})]})]}),(c||s.bcc.length>0)&&t.jsxs("div",{className:"flex items-center gap-3 text-[12px]","data-testid":"email-canvas-bcc-row",children:[t.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:"Bcc"}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[s.bcc.map(M=>t.jsx(ct,{label:M.label},M.id)),s.bcc.length===0&&t.jsx("span",{className:"text-muted-foreground",children:"None"})]})]}),t.jsxs("div",{className:"flex items-center gap-3 text-[12px]",children:[t.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:"Subject"}),t.jsx("input",{value:s.subject,onChange:M=>j({...s,subject:M.target.value}),"data-testid":"email-canvas-subject",className:"min-w-0 flex-1 border-0 bg-transparent text-[12px] text-foreground outline-none"}),t.jsxs("button",{type:"button",onClick:g,"data-testid":"email-canvas-merge-fields",className:"inline-flex shrink-0 items-center gap-1 text-[12px] font-medium text-[hsl(var(--cover-user-accent-text))]",children:[t.jsx(Kr,{className:"h-3.5 w-3.5"}),"Merge Fields"]})]}),J.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":"email-canvas-attachments",children:J.map(M=>t.jsx("span",{className:"rounded-full bg-muted px-2.5 py-0.5 text-[10px] text-muted-foreground",children:M.name},M.id))})]}),t.jsx("div",{className:"border-t border-border",children:t.jsx(Ss,{page:r,pagePx:{width:R,height:Hr},zoom:100,elements:n,selectedId:o,selectedIds:i,snapEnabled:u,onSelect:S,onMove:$,onMoveMany:B,onResize:N,onDropField:A,onDropTool:Q,onChangeText:P,embedded:!0})})]})})})})}const Yl={event:Ce,proposal:ht,account:ps,contact:ms,lead:gs,"quick-order":Pr},Vl={event:"bg-blue-50 text-blue-600",proposal:"bg-violet-50 text-violet-600",account:"bg-teal-50 text-teal-700",contact:"bg-sky-50 text-sky-700",lead:"bg-amber-50 text-amber-700","quick-order":"bg-orange-50 text-orange-600"};function ca({step:e,recordType:s,name:r,output:a,onRecordType:n,onName:o,onOutput:i,onBack:u,onNext:d,onCancel:c,onCreate:f,mode:b="create"}){return t.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-background/55 p-4","data-testid":"print-new-modal","data-mode":b,children:t.jsx("div",{className:"w-[640px] max-w-full overflow-hidden rounded-2xl bg-card shadow-2xl",children:e===1?t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"bg-gradient-to-r from-blue-600 to-indigo-500 px-6 pb-5 pt-5 text-white",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.16em] text-blue-100",children:"STEP 1 OF 2"}),t.jsx("h3",{className:"mt-1 text-xl font-semibold",children:"What kind of record
1is this for?"}),t.jsx("p",{className:"mt-1 text-[12px] text-blue-100",children:"This determines which merge fields and sections are available."})]}),t.jsx("button",{type:"button",onClick:c,className:"text-white/80","aria-label":"Close",children:"Ã"})]}),t.jsx("div",{className:"mt-4 h-1 overflow-hidden rounded-full bg-card/20",children:t.jsx("div",{className:"h-full w-1/2 bg-card"})})]}),t.jsx("div",{className:"max-h-[420px] space-y-2 overflow-y-auto px-5 py-5",children:Xn.map(j=>{const g=Yl[j.id],S=s===j.id;return t.jsxs("button",{type:"button",onClick:()=>n(j.id),"aria-pressed":S,"data-testid":`print-record-type-${j.id}`,className:k("flex w-full items-center gap-3 rounded-xl border px-4 py-3 text-left",S?"border-[hsl(var(--cover-user-accent))] bg-[hsl(var(--cover-user-accent-subtle)/0.6)]":"border-border hover:border-border"),children:[t.jsx("span",{className:k("flex h-10 w-10 items-center justify-center rounded-lg",Vl[j.id]),children:t.jsx(g,{className:"h-5 w-5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block text-[14px] font-semibold text-foreground",children:j.label}),t.jsx("span",{className:"block text-[12px] text-muted-foreground",children:j.description})]}),t.jsx("span",{className:k("h-4 w-4 rounded-full border",S?"border-4 border-[hsl(var(--cover-user-accent))]":"border-border")})]},j.id)})}),t.jsxs("footer",{className:"flex items-center justify-between border-t border-border px-5 py-4",children:[t.jsx("button",{type:"button",onClick:c,className:"text-[13px] text-muted-foreground",children:"Cancel"}),t.jsx("button",{type:"button",onClick:d,disabled:!s,"data-testid":"print-new-next",className:k("h-9 rounded-lg px-4 text-[13px] font-medium",s?"bg-[hsl(var(--cover-user-accent))] text-white":"bg-border text-muted-foreground"),children:"Next"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"bg-gradient-to-r from-blue-600 to-indigo-500 px-6 pb-5 pt-5 text-white",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("button",{type:"button",onClick:u,className:"mt-1 text-white/80","aria-label":"Back",children:t.jsx(Er,{className:"h-4 w-4"})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.16em] text-blue-100",children:"STEP 2 OF 2"}),t.jsx("h3",{className:"mt-1 text-xl font-semibold",children:"What are you designing?"}),t.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[12px] text-blue-100",children:[t.jsx("span",{className:"rounded-full bg-[hsl(var(--cover-user-accent)/0.4)] px-2 py-0.5 text-white",children:fs(s??void 0)}),t.jsx("span",{children:"Choose output format"})]})]})]}),t.jsx("button",{type:"button",onClick:c,className:"text-white/80","aria-label":"Close",children:"Ã"})]}),t.jsx("div",{className:"mt-4 h-1 overflow-hidden rounded-full bg-card/20",children:t.jsx("div",{className:"h-full w-full bg-card"})})]}),t.jsxs("div",{className:"space-y-4 px-5 py-5",children:[t.jsxs("label",{className:"block text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:["DESIGN NAME",t.jsx("input",{value:r,onChange:j=>o(j.target.value),placeholder:"e.g. Smithfield Wedding BEO","data-testid":"print-design-name",className:"mt-1 h-10 w-full rounded-xl border border-border px-3 text-[13px] font-normal normal-case tracking-normal text-foreground"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"OUTPUT FORMAT"}),t.jsx("div",{className:"grid grid-cols-2 gap-3",children:Zn.map(j=>{const g=bs(a)===j.id,S=b==="edit",$=j.id==="email"?xt:es;return t.jsxs("button",{type:"button",onClick:()=>{S||i(j.id)},disabled:S,"aria-disabled":S?!0:void 0,"aria-pressed":g,"data-testid":`print-output-${j.id}`,className:k("rounded-xl border p-4 text-left",g?"border-[hsl(var(--cover-user-accent))] bg-[hsl(var(--cover-user-accent-subtle)/0.5)]":"border-border",S&&"disabled:opacity-100"),children:[t.jsxs("div",{className:"relative mb-3 h-16 overflow-hidden rounded-lg bg-muted",children:[j.id==="email"?t.jsxs("div",{className:"absolute inset-3 overflow-hidden rounded bg-card shadow-sm",children:[t.jsxs("div",{className:"flex h-3 items-center gap-0.5 bg-accent px-1.5",children:[t.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-border"})]}),t.jsx("div",{className:"mx-2 mt-2 h-1.5 w-3/4 rounded bg-border"}
1),t.jsx("div",{className:"mx-2 mt-1 h-1 w-1/2 rounded bg-accent"})]}):t.jsx("div",{className:"absolute inset-3 rounded bg-card shadow-sm",children:t.jsxs("div",{className:"mx-2 mt-2 space-y-1",children:[t.jsx("div",{className:"h-1 w-5/6 rounded bg-border"}),t.jsx("div",{className:"h-1 w-2/3 rounded bg-accent"}),t.jsx("div",{className:"h-1 w-3/4 rounded bg-accent"})]})}),t.jsx("span",{className:"absolute bottom-1.5 right-1.5 flex h-6 w-6 items-center justify-center rounded-full bg-card shadow-sm",children:t.jsx($,{className:"h-3.5 w-3.5 text-[hsl(var(--cover-user-accent-text))]"})})]}),t.jsx("div",{className:"text-[14px] font-semibold text-foreground",children:j.label}),t.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:j.description}),t.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:j.meta})]},j.id)})}),b==="edit"&&t.jsx("p",{className:"mt-2 text-[12px] text-muted-foreground","data-testid":"print-output-locked",children:"Output type can't be changed after creation"})]})]}),t.jsxs("footer",{className:"flex items-center justify-between border-t border-border px-5 py-4",children:[t.jsx("button",{type:"button",onClick:c,className:"text-[13px] text-muted-foreground",children:"Cancel"}),t.jsx("button",{type:"button",onClick:f,disabled:!ar(r,a),"data-testid":"print-create-design",className:k("inline-flex h-9 items-center gap-1.5 rounded-lg px-4 text-[13px] font-medium",ar(r,a)?"bg-[hsl(var(--cover-user-accent))] text-white":"bg-border text-muted-foreground"),children:b==="edit"?"Save Changes":t.jsxs(t.Fragment,{children:[t.jsx(qr,{className:"h-3.5 w-3.5"}),"Create Design"]})})]})]})})})}function Jl({current:e,onSelect:s,onCustom:r}){const a=rr.filter(o=>o.group==="standard"),n=rr.filter(o=>o.group==="stationery");return t.jsxs("div",{className:"w-72 rounded-xl border border-border bg-card p-2 shadow-xl","data-testid":"print-page-size-menu",children:[t.jsx("div",{className:"px-2 py-1 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"STANDARD PAPER"}),a.map(o=>t.jsxs("button",{type:"button",onClick:()=>s(o),"data-testid":`print-page-size-${o.id}`,className:k("flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-[12px]",e.id===o.id?"bg-[hsl(var(--cover-user-accent-subtle))] text-[hsl(var(--cover-user-accent-text))]":"text-foreground hover:bg-muted"),children:[t.jsx("span",{children:o.label}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:ss(o)})]},o.id)),t.jsx("div",{className:"mt-2 px-2 py-1 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"EVENT STATIONERY"}),n.map(o=>t.jsxs("button",{type:"button",onClick:()=>s(o),"data-testid":`print-page-size-${o.id}`,className:k("flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-[12px]",e.id===o.id?"bg-[hsl(var(--cover-user-accent-subtle))] text-[hsl(var(--cover-user-accent-text))]":"text-foreground hover:bg-muted"),children:[t.jsx("span",{children:o.label}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:ss(o)})]},o.id)),t.jsx("button",{type:"button",onClick:r,"data-testid":"print-custom-dimensions",className:"mt-2 flex h-9 w-full items-center justify-center gap-1 rounded-lg border border-dashed border-border text-[12px] text-muted-foreground",children:"+ Custom dimensions..."})]})}function Xl({width:e,height:s,unit:r,onWidth:a,onHeight:n,onUnit:o,onBack:i,onApply:u}){return t.jsxs("div",{className:"w-72 rounded-xl border border-border bg-card p-4 shadow-xl","data-testid":"print-custom-size",children:[t.jsxs("div",{className:"mb-3 flex items-center gap-2 text-[11px] font-semibold tracking-[0.14em] text-foreground",children:[t.jsx("button",{type:"button",onClick:i,"aria-label":"Back",children:t.jsx(Er,{className:"h-4 w-4"})}),"CUSTOM DIMENSIONS"]}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsxs("label",{className:"flex-1 text-[10px] font-semibold tracking-[0.12em] text-muted-foreground",children:["WIDTH",t.jsx("input",{value:e,onChange:d=>a(d.target.value),placeholder:"e.g. 8.5",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px] font-normal normal-case tracking-normal text-foreground"})]}),t.jsx("span",{className:"pb-2 text-muted-foreground",children:"Ã"}),t.jsxs("label",{className:"flex-1 text-[10px] font-semibold tracking-[0.12em] text-muted-foreground",children:["HEIGHT",t.jsx("input",{value:s,onChange:d=>n(d.target.value),placeholder:"e.g. 11",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px] font-normal normal-case tracking-normal text-foreground"})]})]}),t.jsx("div",{className:"mt-3 flex overflow-hidden rounded-lg border border-border",children:["in","mm","px"].map(d=>t.jsx("button",{type:"button",onClick:()=>o(d),className:k("h-8 flex-1 text-[12px]",r===d?"bg-[hsl(var(--cover-user-accent))] text-white":"bg-card text-muted-foreground"),children:d},d))}),t.jsx("button",{type:"button",onClick:u,"data-testid":"print-apply-custom-size",className:"mt-3 h-9 w-full rounded-lg bg-[hsl(var(--cover-user-accent-soft))] text-[13px] font-medium text-[hsl(var(--cover-user-accent-text))]",children:"Apply Custom Size"})]})}function Zl(e){return!e||e==="proposal"?"event":e}function ed(e,s){return s==="event"&&e==="proposal"?"proposal":s}function ua(e){return e.replace(/ · Page \d+$/,"")}function ma(e,s){const r=e.match(/ · Page \d+$/)?.[0]??"";return`${s}${r}`}function Se(e){const s=e.match(/^(tpl_[a-f0-9]{28})(?:~\d{1,2})?$/);return s?s[1]:null}function td(e,s){return{name:e.name.trim(),recordType:e.recordType,outputFormat:bs(s)}}function sd(e,s){return{...e,name:ma(e.name,s.name),recordType:s.recordType,outputFormat:s.outputFormat}}function rd(e){return{title:"Delete print?",description:`Delete ${ua(e)}? This cannot be undone.`,confirmLabel:"Delete",cancelLabel:"Cancel",destructive:!0}}async function ad(e,s){try{const r=await e.json();if(typeof r.error=="string"&&r.error.trim())return r.error}catch{}return s}
1async function nd(e,s,r,a){const n=td(r,a),o=Se(s);if(!o)return{status:"local",body:n};const i=await e("PUT",`${te}/${o}`,n);return i.ok?{status:"saved",body:n}:{status:"error",message:await ad(i,"Could not update this print.")}}async function od(e,s,r){if(!await e(rd(r.name)))return"cancelled";const n=Se(r.id);return n?(await s("DELETE",`${te}/${n}`)).ok?"deleted":"error":"local"}function id({project:e,onClose:s,onSaved:r}){const[a,n]=y.useState(1),[o,i]=y.useState(Zl(e.recordType)),[u,d]=y.useState(ua(e.name)),c=bs(e.outputFormat);return t.jsx(ca,{mode:"edit",step:a,recordType:o,name:u,output:c,onRecordType:i,onName:d,onOutput:()=>{},onBack:()=>n(1),onNext:()=>{o&&n(2)},onCancel:s,onCreate:()=>{const f=Ur({name:u,recordType:o,outputFormat:c});f&&r({name:f.name,recordType:ed(e.recordType,f.recordType),outputFormat:c})}})}async function yr(e){if(e.status!=="fulfilled"||!e.value.ok)return null;try{return await e.value.json()}catch{return null}}const ld={"save-as-template":qr,"attach-to-event":pn,preview:Ar},dd={confirmed:"bg-emerald-50 text-emerald-700",tentative:"bg-amber-50 text-amber-700",pending:"bg-violet-50 text-violet-700",neutral:"bg-muted text-muted-foreground"},cd={event:Ce,proposal:Ce,account:ps,contact:ms,lead:gs},ud={event:"bg-sky-100 text-sky-600",proposal:"bg-sky-100 text-sky-600",account:"bg-teal-100 text-teal-700",contact:"bg-sky-100 text-sky-700",lead:"bg-amber-100 text-amber-700"};function md(e){const s=bn({limit:200}),r=gn({limit:200}),a=vn({limit:200}),n=yn({limit:200}),o=jn({limit:200});return y.useMemo(()=>{if(e==="account")return{sources:Be(e,a.accounts.map(hi)),loading:a.loading};if(e==="contact")return{sources:Be(e,n.contacts.map(fi)),loading:n.loading};if(e==="lead")return{sources:Be(e,o.leads.map(bi)),loading:o.loading};if(e==="proposal")return{sources:Be(e,r.proposals.map(as)),loading:r.loading};const i=[...s.events.map(u=>Yr(u)),...r.proposals.map(as)];return{sources:Be(e,i),loading:s.loading||r.loading}},[a.accounts,a.loading,n.contacts,n.loading,s.events,s.loading,o.leads,o.loading,r.loading,r.proposals,e])}function pd({onPreview:e}){return t.jsxs(cn,{children:[t.jsx(un,{asChild:!0,children:t.jsxs("button",{type:"button","data-testid":"print-share-button",className:"inline-flex h-8 items-center gap-1 rounded-lg bg-[hsl(var(--cover-user-accent))] px-3 text-[12px] font-medium text-white",children:[t.jsx(Uo,{className:"h-3.5 w-3.5"}),"Share"]})}),t.jsx(mn,{align:"end",className:"w-56 rounded-xl p-1.5","data-testid":"print-share-menu",children:ii.map(s=>{const r=ld[s.id];return t.jsxs(xn,{"data-testid":`print-share-${s.id}`,className:"rounded-lg px-2.5 py-2 text-[13px]",onSelect:()=>{s.action==="preview"&&e()},children:[t.jsx(r,{className:"h-4 w-4 text-muted-foreground"}),s.label]},s.id)})})]})}function xd({recordType:e,designName:s,page:r,elements:a,onClose:n}){const{user:o}=Ir(),{selectedLocationId:i}=Fr(),u=di(e),d=ci(o?.enterpriseId||i||void 0,o?.id,e),[c,f]=y.useState(""),[b,j]=y.useState(null),[g,S]=y.useState(()=>typeof window>"u"?[]:ui(window.localStorage.getItem(d))),[$,B]=y.useState(!1),[N,A]=y.useState(null),{sources:Q,loading:P}=md(e),W=y.useMemo(()=>ur(Q,c),[c,Q]),O=y.useMemo(()=>ur(pi(Q,g),c),[c,g,Q]),R=Q.find(E=>E.id===b)||null,J=E=>{const T=mi(g,E);S(T);try{window.localStorage.setItem(d,JSON.stringify(T))}catch{}},M=async(E=R)=>{if(E){B(!0),J(E.id);try{let T=E.values,C;if((E.entity==="event"||E.entity==="proposal")&&!E.mock){const D=E.entity==="proposal"?"proposals":"events",z=encodeURIComponent(E.id),[_,H]=await Promise.allSettled([ie("GET",`/api/cover/${D}/${z}`),ie("GET",`/api/cover/${D}/${z}/menu`)]),Z=Fl(await yr(_)),se=Il(await yr(H));Z?.event?T=gi(E,Z):Z?.proposal&&(T=vi(E,Z)),C=Ml({values:T,detail:Z,menuItems:se??[]})}A({source:E,values:T,liveSections:C})}catch{A({source:E,values:E.values})}finally{B(!1)}}};if(N){const E=rs(r);return t.jsxs("div",{className:"fixed inset-0 z-[90] flex flex-col bg-background/80 backdrop-blur-sm","data-testid":"print-live-preview",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-card px-5 py-3 text-foreground",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[15px] font-semibold",children:s}),t.jsxs("div",{className:"text-[12px] text-muted-foreground",children:["Preview with ",N.source.name]})]}),t.jsx("button",{type:"button",onClick:n,"aria-label":"Close preview","data-testid":"print-live-preview-close",className:"rounded-md p-1 text-muted-foreground hover:bg-muted",children:t.jsx(Zt,{className:"h-4 w-4"})})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Ss,{page:r,pagePx:E,zoom:100,elements:a,selectedId:null,onSelect:()=>{},onMove:()=>{},onResize:()=>{},onDropField:()=>{},mergedValues:N.values,liveSections:N.liveSections,interactive:!1})})]})}return t.jsx("div",{className:"fixed inset-0 z-[90] flex items-center justify-center bg-background/55 p-4 backdrop-blur-[2px]","data-testid":"print-preview-live-modal",children:t.jsxs("div",{className:"flex max-h-[min(720px,90vh)] w-[560px] max-w-full flex-col overflow-hidden rounded-2xl bg-card shadow-[0_24px_80px_rgba(15,23,42,0.28)]",children:[t.jsxs("header",{className:"flex items-start justify-between px-6 pb-3 pt-5",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-[20px] font-semibold tracking-tight text-foreground",children:"Preview with live data"}),t.jsx("p",{className:"mt-1 text-[13px] text-muted-foreground",children:u.subtitle})]}),t.jsx("button",{type:"button",onClick:n,"aria-label":"Close","data-testid":"print-preview-close",className:"rounded-md p-1 text-muted-foreground hover:bg-muted",children:t.jsx(Zt,{className:"h-4 w-4"})})]}),t.jsx("div",{className:"px-6 pb-3",children:t.jsxs("label",{className:"relative block",children:[t.jsx(Mr,{className:"pointer-events-none absolute left-3.5 to
1p-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx("input",{value:c,onChange:E=>f(E.target.value),placeholder:u.searchPlaceholder,"data-testid":"print-preview-search",className:"h-10 w-full rounded-full border border-border bg-card pl-10 pr-4 text-[13px] text-foreground outline-none placeholder:text-muted-foreground focus:border-[hsl(var(--cover-user-accent))] focus:ring-2 focus:ring-[hsl(var(--cover-user-accent)/0.4)]"})]})}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-2",children:[P&&t.jsx("div",{className:"px-4 py-8 text-center text-[12px] text-muted-foreground",children:"Loadingâ¦"}),!P&&O.length>0&&t.jsxs("section",{className:"mb-2","data-testid":"print-preview-recent",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-4 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",children:[t.jsx(hn,{className:"h-3 w-3"}),"Recently used"]}),O.map(E=>t.jsx(jr,{source:E,selected:b===E.id,onSelect:()=>j(E.id),onPreview:()=>{M(E)}},`recent-${E.id}`))]}),t.jsxs("section",{"data-testid":"print-preview-all",children:[t.jsx("div",{className:"px-4 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",children:u.allHeading}),!P&&W.length===0&&t.jsx("div",{className:"px-4 py-8 text-center text-[12px] text-muted-foreground",children:c?"No matches.":"No records yet."}),W.map(E=>t.jsx(jr,{source:E,selected:b===E.id,onSelect:()=>j(E.id),onPreview:()=>{M(E)}},E.id))]})]}),t.jsxs("footer",{className:"flex items-center justify-between border-t border-border px-6 py-4",children:[t.jsx("div",{className:"text-[12px] text-muted-foreground","data-testid":"print-preview-count",children:u.availableLabel(W.length)}),t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("button",{type:"button",onClick:n,"data-testid":"print-preview-cancel",className:"text-[13px] font-semibold text-foreground",children:"Cancel"}),t.jsxs("button",{type:"button",disabled:!R||$,onClick:()=>{M()},"data-testid":"print-preview-submit",className:k("inline-flex h-9 items-center rounded-lg px-4 text-[13px] font-medium",R&&!$?"bg-[hsl(var(--cover-user-accent))] text-white":"bg-muted text-muted-foreground"),children:[$&&t.jsx(fn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Preview"]})]})]})]})})}function jr({source:e,selected:s,onSelect:r,onPreview:a}){const n=cd[e.entity],o=[e.client,e.dateLabel].filter(Boolean).join(" · ");return t.jsxs("button",{type:"button",onClick:r,onDoubleClick:a,"data-testid":`print-preview-row-${e.id}`,className:k("flex w-full items-center gap-3 border-b border-border/70 px-4 py-3 text-left last:border-b-0",s?"bg-[hsl(var(--cover-user-accent-subtle)/0.8)]":"hover:bg-muted/60"),children:[t.jsx("span",{className:k("flex h-9 w-9 shrink-0 items-center justify-center rounded-full",ud[e.entity]),children:t.jsx(n,{className:"h-4 w-4"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-[13px] font-semibold text-foreground",children:e.name}),t.jsx("span",{className:"block truncate text-[12px] text-muted-foreground",children:o||"â"})]}),e.statusLabel&&t.jsx("span",{className:k("shrink-0 rounded-md px-2 py-0.5 text-[11px] font-medium",dd[e.statusTone]),children:e.statusLabel})]})}function Ie({title:e,onClose:s}){return t.jsxs("div",{className:"flex items-center justify-between px-4 pt-4 pb-3",children:[t.jsx("h2",{className:"text-[13px] font-semibold tracking-[0.14em] text-foreground",children:e}),t.jsx("button",{type:"button",onClick:s,className:"h-6 w-6 rounded-md text-muted-foreground hover:bg-accent hover:text-muted-foreground","aria-label":`Close ${e}`,children:"Ã"})]})}function Ke({value:e,onChange:s,placeholder:r,testId:a}){return t.jsx("div",{className:"px-4",children:t.jsxs("label",{className:"relative block",children:[t.jsx(ne,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-blue-500"}),t.jsx("input",{value:e,onChange:n=>s(n.target.value),placeholder:r,"data-testid":a,className:"h-9 w-full rounded-full border border-border bg-muted pl-9 pr-3 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-[hsl(var(--cover-user-accent))] focus:bg-card focus:outline-none"})]})})}const hd=["absolute right-1.5 top-1.5 z-10 flex gap-1","opacity-0 pointer-events-none","group-hover:pointer-events-auto group-hover:opacity-100","group-focus-within:
1pointer-events-auto group-focus-within:opacity-100","max-[600px]:pointer-events-auto max-[600px]:opacity-100","[@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100"].join(" ");function fd({project:e,selected:s,onSelect:r,onEdit:a,onDelete:n}){return t.jsxs("div",{className:"group relative","data-testid":`print-tile-${e.id}`,children:[t.jsxs("button",{type:"button",onClick:()=>r(e),"data-testid":`print-project-${e.id}`,className:k("flex w-full items-center gap-3 rounded-xl border px-2.5 py-2 text-left",s?"border-[hsl(var(--cover-events-accent))] bg-[hsl(var(--cover-events-accent-soft))]":"border-transparent hover:bg-muted"),children:[t.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-white",style:{background:e.color},children:e.kind==="folder"?t.jsx(Qr,{className:"h-5 w-5"}):t.jsx(ht,{className:"h-5 w-5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-[13px] font-medium text-foreground",children:e.name}),t.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:e.kind==="folder"?e.updatedLabel:`${fs(e.recordType)} · ${zr(e.outputFormat)}`}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground",children:[e.kind==="design"?e.updatedLabel:"",e.sharedBy?` · ${e.sharedBy}`:""]})]}),e.shared&&t.jsx(wn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),e.kind==="design"&&t.jsxs("div",{className:hd,"data-testid":`print-tile-actions-${e.id}`,children:[t.jsxs("button",{type:"button","aria-label":`Edit ${e.name}`,"data-testid":`print-tile-edit-${e.id}`,onClick:o=>{o.stopPropagation(),a?.(e)},className:"inline-flex h-7 items-center gap-1 rounded-md bg-card px-2 text-[11px] font-medium text-foreground shadow-sm ring-1 ring-border hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--cover-user-accent))]",children:[t.jsx(kn,{className:"h-3 w-3"}),"Edit"]}),t.jsxs("button",{type:"button","aria-label":`Delete ${e.name}`,"data-testid":`print-tile-delete-${e.id}`,onClick:o=>{o.stopPropagation(),n?.(e)},className:"inline-flex h-7 items-center gap-1 rounded-md bg-card px-2 text-[11px] font-medium text-rose-600 shadow-sm ring-1 ring-border hover:bg-rose-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-400",children:[t.jsx(hs,{className:"h-3 w-3"}),"Delete"]})]})]})}function bd({projects:e,tab:s,query:r,selectedId:a,onTab:n,onQuery:o,onSelect:i,onNew:u,onClose:d,onEdit:c,onDelete:f}){const b=eo(e,s,r);return t.jsxs("div",{className:"flex h-full flex-col","data-testid":"print-projects-pane",children:[t.jsx(Ie,{title:"PROJECTS",onClose:d}),t.jsx(Ke,{value:r,onChange:o,placeholder:"Help me find a project...",testId:"print-projects-search"}),t.jsx("div",{className:"px-4 pt-3",children:t.jsxs("button",{type:"button",onClick:u,"data-testid":"print-new-design",className:"flex h-10 w-full items-center justify-center gap-1.5 rounded-xl border border-dashed border-[hsl(var(--cover-events-accent))] bg-[hsl(var(--cover-events-accent-soft))] text-[13px] font-medium text-[hsl(var(--cover-events-accent))] hover:brightness-95",children:[t.jsx(_e,{className:"h-3.5 w-3.5"}),"New Design"]})}),t.jsx("div",{className:"mt-3 flex gap-5 border-b border-border px-4",children:to.map(j=>t.jsx("button",{type:"button",onClick:()=>n(j),"data-testid":`print-projects-tab-${j}`,className:k("pb-2 text-[12px] font-medium capitalize",s===j?"border-b-2 border-[hsl(var(--cover-user-accent))] text-[hsl(var(--cover-user-accent-text))]":"text-muted-foreground"),children:j},j))}),t.jsx("div",{className:"flex-1 space-y-4 overflow-y-auto px-4 py-3",children:b.map(j=>t.jsxs("div",{className:"space-y-2","data-testid":j.kind==="group"?`print-project-group-${j.id}`:"print-project-folders",children:[j.kind==="group"&&t.jsx("div",{className:"px-1 text-[11px] font-semibold tracking-[0.12em] text-muted-foreground",children:j.label}),j.projects.map(g=>t.jsx(fd,{project:g,selected:a===g.id,onSelect:i,onEdit:c,onDelete:f},g.id))]},j.kind==="group"?j.id:"folders"))})]})}function gd({query:e,onQuery:s,onClose:r}){const a=so.filter(n=>!e||n.name.toLowerCase().includes(e.toLowerCase()));return t.jsxs("div",{className:"flex h-full flex-col","data-testid":"print-templates-pane",children:[t.jsx(Ie,{title:"TEMPLATES",onClose:r}
1),t.jsx(Ke,{value:e,onChange:s,placeholder:"Help me find the perfect template...",testId:"print-templates-search"}),t.jsx("div",{className:"px-4 pt-3",children:t.jsxs("button",{type:"button","data-testid":"print-blank-print",className:"flex h-10 w-full items-center justify-center gap-1.5 rounded-xl border border-dashed border-[hsl(var(--cover-events-accent))] bg-[hsl(var(--cover-events-accent-soft))] text-[13px] font-medium text-[hsl(var(--cover-events-accent))]",children:[t.jsx(_e,{className:"h-3.5 w-3.5"}),"Blank Print"]})}),t.jsx("div",{className:"px-4 pt-4 text-[11px] font-semibold tracking-[0.14em] text-muted-foreground",children:"TEMPLATES"}),t.jsx("div",{className:"grid grid-cols-2 gap-3 overflow-y-auto px-4 py-3",children:a.map(n=>t.jsxs("div",{className:"space-y-1.5","data-testid":`print-template-${n.id}`,children:[t.jsx("div",{className:"flex aspect-[3/4] items-center justify-center rounded-lg border border-border px-3 text-center text-[12px] font-medium",style:{background:n.accent,color:n.accent==="#1E3A5F"?"#fff":"#334155"},children:n.name}),t.jsx("div",{className:"text-[11px] text-muted-foreground",children:n.name})]},n.id))})]})}function vd({query:e,onQuery:s,onClose:r,recordType:a}){const n=ro(no(a),e),[o,i]=y.useState({}),u=e.trim().length>0,d=c=>{u||i(f=>({...f,[c]:!f[c]}))};return t.jsxs("div",{className:"flex h-full flex-col","data-testid":"print-merge-fields-pane",children:[t.jsx(Ie,{title:"MERGE FIELDS",onClose:r}),t.jsx(Ke,{value:e,onChange:s,placeholder:"Help me find the right merge field...",testId:"print-merge-search"}),t.jsx("div",{className:"flex-1 space-y-4 overflow-y-auto px-4 py-3",children:n.map(c=>{const f=u||!o[c.id],b=`print-merge-group-panel-${c.id}`;return t.jsxs("section",{"data-testid":`print-merge-group-${c.id}`,children:[t.jsxs("button",{type:"button","aria-expanded":f,"aria-controls":b,"data-testid":`print-merge-group-toggle-${c.id}`,onClick:()=>d(c.id),onKeyDown:j=>{j.key!=="Enter"&&j.key!==" "&&j.key!=="Spacebar"||(j.preventDefault(),d(c.id))},className:k("mb-2 flex w-full items-center justify-between rounded-md px-2 py-1 text-left text-[11px] font-semibold",c.accent==="purple"?"bg-[hsl(var(--cover-proposals-accent-soft))] text-[hsl(var(--cover-proposals-accent))]":"bg-[hsl(var(--cover-events-accent-soft))] text-[hsl(var(--cover-events-accent))]"),children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[t.jsx(Nn,{className:k("h-3.5 w-3.5 shrink-0 transition-transform",f&&"rotate-90"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:c.label})]}),t.jsx("span",{className:"rounded-full bg-[hsl(var(--cover-surface)/0.8)] px-1.5 text-[10px]",children:c.fields.length})]}),f&&t.jsx("div",{id:b,className:"grid grid-cols-2 gap-2",children:c.fields.map(j=>t.jsx(yd,{field:j},j.key))})]},c.id)})})]})}function yd({field:e}){return t.jsxs("button",{type:"button",draggable:!0,"data-testid":`print-merge-field-${e.key}`,onDragStart:s=>{s.dataTransfer.setData("application/x-print-merge-field",e.key),s.dataTransfer.setData("text/plain",e.key),s.dataTransfer.effectAllowed="copy"},className:"rounded-lg border border-[hsl(var(--cover-border))] bg-[hsl(var(--cover-muted))] px-2.5 py-2 text-left hover:border-[hsl(var(--cover-events-accent))]",children:[t.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:e.label}),t.jsx("div",{className:"truncate font-mono text-[10px] text-muted-foreground",children:e.token})]})}function jd({query:e,category:s,onQuery:r,onCategory:a,onAddMenuItems:n,onAddSection:o,onClose:i}){const u=Ht.filter(d=>{if(s!=="All"&&d.category!==s)return!1;if(!e)return!0;const c=e.toLowerCase();return d.title.toLowerCase().includes(c)||d.description.toLowerCase().includes(c)});return t.jsxs("div",{className:"flex h-full flex-col","data-testid":"print-sections-pane",children:[t.jsx(Ie,{title:"SECTIONS",onClose:i}),t.jsx(Ke,{value:e,onChange:r,placeholder:"Help me add a section...",testId:"print-sections-search"}),t.jsxs("div",{className:"px-4 pt-3 space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("span",{className:"flex-1 rounded-lg border border-border px-2 py-1.5 text-[11px] text-muted-foreground",children:["Event sections (",Ht.length,")"]}),t.jsxs("span",{className:"flex-1 rounded-lg border border-border px-2 py-1.5 text-[11px] text-muted-foreground",children:["All sections (",Ht.length,")"]})]}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:ao.map(d=>t.jsx("button",{type:"button",onClick:()=>a(d),className:k("rounded-full px-2.5 py-1 text-[11px]",s===d?"bg-[hsl(var(--cover-user-accent))] text-white":"bg-accent text-muted-foreground"),children:d},d))})]}),t.jsx("div",{className:"flex-1 space-y-3 overflow-y-auto px-4 py-3",children:u.map(d=>t.jsxs("div",{className:"rounded-xl border border-border bg-card p-3","data-testid":`print-section-${d.id}`,children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:d.title}),t.jsx("div",{className:"text-[11px] text-muted-foreground",children:d.category})]}),d.id==="menu-items"?t.jsx(Mr,{className:"h-3.5 w-3.5 text-amber-600"}):t.jsx(Ce,{className:"h-3.5 w-3.5 text-[hsl(var(--cover-user-accent-text))]"})]}),t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:d.description}),d.badges.length>0&&t.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:d.badges.map(c=>t.jsx("span",{className:"rounded-full bg-amber-50 px-2 py-0.5 text-[10px] font-medium text-amber-700",children:c},c))}),t.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:d.fields.map(c=>t.jsx("span",{className:"rounded bg-accent px-1.5 py-0.5 text-[10px] text-muted-foreground",children:c},c))}),d.working?t.jsxs("button",{type:"button",onClick:()=>{d.id==="menu-items"?n():o(d.id)},"data-testid":d.id==="menu-items"?"print-add-menu-items":`print-add-section-${d.id}`,className:"mt-3 flex h-8 w-full items-center justify-center gap-1 rounded-lg bg-[hsl(var(--cover-user-accent))] text-[12px] font-medium text-white hover:brightness-90",children:[t.jsx(_e,{className:"h-3.5 w-3.5"}),"Add to Print"]}):t.jsx("div",{className:"mt-3 h-8 rounded-lg border border-dashed border-border text-center text-[11px] leading-8 text-muted-foreground",children:"Coming later"})]},d.id))})]})}function Nd({rail:e,onClose:s}){const r={elements:"ELEMENTS",tools:"TOOLS",uploads:"UPLOADS","brand-kit":"BRAND KIT","cai-ai":"CAI AI"}[e];return t.jsxs("div",{className:"flex h-full flex-col","data-testid":`print-deferred-${e}`,children:[t.jsx(Ie,{title:r,onClose:s}),t.jsx("div",{className:"px-4 pt-6 text-[12px] text-muted-foreground",children:"Available in a later pass."})]})}function wd({id:e}){const s=e==="instagram"?"bg-rose-50 text-rose-500":e==="google-drive"?"bg-amber-50 text-amber-600":e==="dropbox"?"bg-sky-50 text-sky-600":e==="google-photos"?"bg-emerald-50 text-emerald-600":e==="onedrive"?"bg-blue-50 text-blue-600":"bg-muted text-muted-foreground";return t.jsx("span",{className:k("flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-[11px] font-semibold",s),children:e==="instagram"?"Ig":e==="google-drive"?"Gd":e==="dropbox"?"Db":e==="google-photos"?"Gp":e==="onedrive"?"Od":"Un"})}function kd({uploads:e,query:s,onQuery:r,onPlace:a,onUploadFiles:n,onClose:o}){const i=y.useRef(null),[u,d]=y.useState(!1),[c,f]=y.useState({}),b=e.filter(g=>!s||g.name.toLowerCase().includes(s.toLowerCase())),j=Qi(b,u);return t.jsxs("div",{className:"flex h-full flex-col","data-testid":"print-uploads-
1pane",children:[t.jsx(Ie,{title:"UPLOADS",onClose:o}),t.jsx(Ke,{value:s,onChange:r,placeholder:"Help me find an image...",testId:"print-uploads-search"}),t.jsxs("div",{className:"flex-1 space-y-5 overflow-y-auto px-4 py-4",children:[t.jsxs("button",{type:"button","data-testid":"print-upload-files",onClick:()=>i.current?.click(),onDragOver:g=>{g.preventDefault(),g.dataTransfer.dropEffect="copy"},onDrop:g=>{g.preventDefault(),g.dataTransfer.files?.length&&n(g.dataTransfer.files)},className:"flex w-full flex-col items-center justify-center gap-1 rounded-xl border border-dashed border-border bg-muted/40 px-3 py-6 text-center hover:border-[hsl(var(--cover-user-accent))] hover:bg-[hsl(var(--cover-user-accent-subtle)/0.4)]",children:[t.jsx(xs,{className:"h-5 w-5 text-muted-foreground"}),t.jsx("span",{className:"text-[13px] font-medium text-foreground",children:"Upload files"}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:"PNG, JPG, SVG, PDF up to 50MB"})]}),t.jsx("input",{ref:i,type:"file",accept:Oi,multiple:!0,className:"hidden","data-testid":"print-upload-input",onChange:g=>{g.target.files?.length&&n(g.target.files),g.target.value=""}}),t.jsxs("section",{children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"RECENT UPLOADS"}),t.jsx("button",{type:"button","data-testid":"print-uploads-see-all",onClick:()=>d(g=>!g),className:"text-[11px] text-[hsl(var(--cover-user-accent-text))] hover:underline",children:u?"See less":"See all"})]}),t.jsx("div",{className:"grid grid-cols-2 gap-3",children:j.map(g=>t.jsxs("button",{type:"button",draggable:!0,"data-testid":`print-upload-${g.id}`,onClick:()=>a(g),onDragStart:S=>{S.dataTransfer.setData(oa,JSON.stringify(g)),S.dataTransfer.setData("text/plain",g.id),S.dataTransfer.effectAllowed="copy"},className:"space-y-1.5 text-left",children:[Gi(g)?t.jsx("img",{src:g.src,alt:g.name,className:"aspect-square w-full rounded-lg border border-border object-cover"}):t.jsx("span",{className:"flex aspect-square w-full items-center justify-center rounded-lg border border-border bg-muted",children:t.jsx(ht,{className:"h-6 w-6 text-muted-foreground"})}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:g.name})]},g.id))})]}),t.jsxs("section",{"data-testid":"print-connect-apps",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"CONNECT APPS"}),t.jsx("div",{className:"space-y-2",children:Hi.map(g=>t.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-border px-2.5 py-2","data-testid":`print-connect-app-${g.id}`,children:[t.jsx(wd,{id:g.id}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-[12px] font-medium text-foreground",children:g.label}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:g.detail})]}),t.jsx("button",{type:"button","data-testid":`print-connect-${g.id}`,onClick:()=>f(S=>({...S,[g.id]:!S[g.id]})),className:"h-7 shrink-0 rounded-full border border-border px-2.5 text-[11px] font-medium text-foreground hover:bg-muted",children:c[g.id]?"Connected":"Connect"})]},g.id))})]})]})]})}function Sd({saving:e,name:s,onSave:r}){const[a,n]=y.useState(!1),[o,i]=y.useState(""),u=()=>{const c=s.trim();if(!c){i(""),n(!0);return}r(c)},d=()=>{const c=o.trim();!c||e||(n(!1),r(c))};return t.jsxs("div",{className:"relative flex shrink-0 items-center gap-2",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-[12px] font-medium text-amber-700","data-testid":"print-dirty",role:"status",children:[t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500","aria-hidden":!0}),"Unsaved"]}),t.jsxs("button",{type:"button",onClick:u,disabled:e,"data-testid":"print-save",className:"inline-flex h-8 items-center gap-1 rounded-lg bg-[hsl(var(--cover-user-accent))] px-3 text-[12px] font-medium text-white hover:brightness-95 disabled:opacity-50",children:[t.jsx(Sn,{className:"h-3.5 w-3.5"}),e?"Savingâ¦":"Save"]}),a&&t.jsxs("form",{role:"dialog","aria-label":"Name this print","data-testid":"print-save-name",className:"absolute right-0 top-9 z-30 w-64 max-w-[calc(100vw-2rem)] rounded-xl border border-border bg-card p-3 shadow-lg",onSubmit:c=>{c.preventDefault(),d()},children:[t.jsx("label",{className:"block text-[11px] font-semibold text-muted-foreground",htmlFor:"print-save-name-input",children:"Name this print"}),t.jsx("input",{id:"print-save-name-input",value:o,autoFocus:!0,onChange:c=>i(c.target.value),"data-testid":"print-save-name-input",className:"mt-1 h-8 w-full rounded-md border border-border px-2 text-[12px] text-foreground focus:outline-none"}),t.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:()=>n(!1),className:"h-7 rounded-md px-2 text-[12px] text-muted-foreground hover:bg-accent",children:"Cancel"}),t.jsx("button",{type:"submit","data-testid":"print-save-name-confirm",disabled:!o.trim(),className:"h-7 rounded-md bg-[hsl(var(--cover-user-accent))] px-2 text-[12px] font-medium text-white disabled:opacity-40",children:"Save"})]})]})]})}const pa=".png,.jpg,.jpeg,.svg,image/png,image/jpeg,image/svg+xml",Cd=pa,Nr=["heading","subheading","body"],_d=["#111827","#C4A574","#FFFFFF","#2563EB"],xa={heading:"Playfair Display",subheading:"Montserrat",body:"Inter"},Td=[{id:"asset-primary-logo",name:"Primary Logo",src:""},{id:"asset-all-logos",name:"All Logos",src:""},{id:"asset-icon-mark",name:"Icon mark",src:""},{id:"asset-watermark",name:"Watermark",src:""},{id:"asset-pattern",name:"Pattern",src:""},{id:"asset-texture",name:"Texture",src:""}],Ed=[{id:"palette",label:"Generate brand palette from logo"},{id:"fonts",label:"Suggest complementary fonts"}],Pd=["#0F172A","#B45309","#F8FAFC","#0F766E"],Ad={heading:"Cormorant Garamond",subheading:"Raleway",body:"Lato"};function Id(){return{logo:null,colors:[..._d],fonts:{...xa},assets:Td.map(e=>({...e}))}}function ha(e,s){const r=s.trim();if(!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(r))return e;const a=r.toUpperCase();return e.some(n=>n.toUpperCase()===a)?e:[...e,r]}function Fd(e,s){return s==="palette"?{...e,colors:Md(e.colors,[...Pd])}:{...e,fonts:{...Ad}}}function Md(e,s){return s.reduce((r,a)=>ha(r,a),e)}function nt(e){const s=e.colors.find(r=>r.toUpperCase()!=="#FFFFFF")||e.colors[0]||"#334155";return{fontFamily:e.fonts.body||xa.body,color:s}}function Dd(e,s){if(!e.logo?.src)return null;const r=Math.round(Math.min(180,s.width*.22)),a=Math.round(r*.62);return{kind:"image",x:Math.round((s.width-r)/2),y:36,width:r,height:a,imageSrc:e.logo.src,imageName:e.logo.name}}function Ld({title:e,onClose:s}){return t.jsxs("div",{className:"flex items-center justify-between px-4 pt-4 pb-3",children:[t.jsx("h2",{className:"text-[13px] font-semibold tracking-[0.14em] text-foreground",children:e}),t.jsx("button",{type:"button",onClick:s,className:"h-6 w-6 rounded-md text-muted-foreground hover:bg-accent hover:text-muted-foreground","aria-label":`Close ${e}`,children:"Ã"})]})}function wr(e,s){const r=new FileReader;r.onload=()=>{typeof r.result=="string"&&s(r.result,e.name)}
1,r.readAsDataURL(e)}const kr={heading:"Heading",subheading:"Subheading",body:"Body"};function Rd({kit:e,query:s,onQuery:r,onChange:a,onClose:n}){const o=y.useRef(null),i=y.useRef(null),u=y.useRef(null),d=s.trim().toLowerCase(),c=!d||"logo".includes(d),f=!d||"color".includes(d)||"brand colors".includes(d),b=!d||"font".includes(d)||Nr.some(N=>kr[N].toLowerCase().includes(d)),j=!d||"asset".includes(d)||e.assets.some(N=>N.name.toLowerCase().includes(d)),g=(N,A)=>{a({...e,logo:{id:"brand-logo",name:A,src:N}})},S=N=>{a({...e,colors:ha(e.colors,N)})},$=(N,A)=>{a({...e,fonts:{...e.fonts,[N]:A}})},B=(N,A)=>{const Q={id:`asset-${Date.now()}`,name:A,src:N};a({...e,assets:[Q,...e.assets.filter(P=>P.src||P.id!==Q.id)]})};return t.jsxs("div",{className:"flex h-full flex-col","data-testid":"print-brand-kit-pane",children:[t.jsx(Ld,{title:"BRAND KIT",onClose:n}),t.jsx("div",{className:"px-4",children:t.jsxs("label",{className:"relative block",children:[t.jsx(ne,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-blue-500"}),t.jsx("input",{value:s,onChange:N=>r(N.target.value),placeholder:"Help me with my brand assets...","data-testid":"print-brand-kit-search",className:"h-9 w-full rounded-full border border-border bg-muted pl-9 pr-3 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-[hsl(var(--cover-user-accent))] focus:bg-card focus:outline-none"})]})}),t.jsxs("div",{className:"flex-1 space-y-5 overflow-y-auto px-4 py-4",children:[c&&t.jsxs("section",{children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"LOGO"}),t.jsx("button",{type:"button","data-testid":"print-brand-logo-action",onClick:()=>o.current?.click(),className:"text-[11px] font-medium text-[hsl(var(--cover-user-accent-text))] hover:underline",children:e.logo?.src?"Replace":"Upload"})]}),t.jsx("button",{type:"button","data-testid":"print-brand-logo-drop",onClick:()=>o.current?.click(),className:"flex w-full flex-col items-center justify-center gap-1 rounded-xl border border-dashed border-border bg-muted/40 px-3 py-6 text-center hover:border-[hsl(var(--cover-user-accent))]",children:e.logo?.src?t.jsx("img",{src:e.logo.src,alt:e.logo.name,className:"h-16 w-auto rounded-md object-contain","data-testid":"print-brand-logo-thumb"}):t.jsxs(t.Fragment,{children:[t.jsx(xs,{className:"h-5 w-5 text-muted-foreground"}),t.jsx("span",{className:"text-[13px] font-medium text-foreground",children:"Upload your logo"})]})}),t.jsx("input",{ref:o,type:"file",accept:pa,className:"hidden","data-testid":"print-brand-logo-input",onChange:N=>{const A=N.target.files?.[0];A&&wr(A,g),N.target.value=""}})]}),f&&t.jsxs("section",{children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"BRAND COLORS"}),t.jsx("button",{type:"button","data-testid":"print-brand-color-add",onClick:()=>u.current?.click(),className:"text-[11px] font-medium text-[hsl(var(--cover-user-accent-text))] hover:underline",children:"Add"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.colors.map(N=>t.jsx("button",{type:"button","data-testid":`print-brand-color-${N}`,className:"h-8 w-8 rounded-full border border-border",style:{background:N},"aria-label":N},N)),t.jsx("button",{type:"button","data-testid":"print-brand-color-plus",onClick:()=>u.current?.click(),className:"flex h-8 w-8 items-center justify-center rounded-full border border-dashed border-border text-muted-foreground hover:border-[hsl(var(--cover-user-accent))]","aria-label":"Add brand color",children:t.jsx(_e,{className:"h-3.5 w-3.5"})})]}),t.jsx("input",{ref:u,type:"color",className:"sr-only","data-testid":"print-brand-color-input",onChange:N=>S(N.target.value)})]}),b&&t.jsxs("section",{children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"BRAND FONTS"}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Change"})]}),t.jsx("div",{className:"space-y-2",children:Nr.map(N=>t.jsxs("label",{className:"block rounded-xl border border-border px-3 py-2",children:[t.jsx("span",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:kr[N]}),t.jsx("select",{value:e.fonts[N],"data-testid":`print-brand-font-${N}
1`,onChange:A=>$(N,A.target.value),className:"mt-1 h-8 w-full bg-transparent text-[13px] text-foreground outline-none",style:{fontFamily:e.fonts[N]},children:We.map(A=>t.jsx("option",{value:A,children:A},A))})]},N))})]}),j&&t.jsxs("section",{children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"BRAND ASSETS"}),t.jsx("button",{type:"button","data-testid":"print-brand-asset-upload",onClick:()=>i.current?.click(),className:"text-[11px] font-medium text-[hsl(var(--cover-user-accent-text))] hover:underline",children:"Upload"})]}),t.jsx("div",{className:"grid grid-cols-3 gap-2",children:e.assets.map(N=>t.jsxs("div",{className:"space-y-1","data-testid":`print-brand-asset-${N.id}`,children:[t.jsx("div",{className:"flex aspect-square items-center justify-center rounded-lg border border-border bg-muted/50",children:N.src?t.jsx("img",{src:N.src,alt:N.name,className:"h-full w-full rounded-lg object-cover"}):t.jsx("span",{className:"h-6 w-6 rounded bg-muted"})}),t.jsx("div",{className:"truncate text-[10px] text-muted-foreground",children:N.name})]},N.id))}),t.jsx("input",{ref:i,type:"file",accept:Cd,className:"hidden","data-testid":"print-brand-asset-input",onChange:N=>{const A=N.target.files?.[0];A&&wr(A,B),N.target.value=""}})]}),t.jsxs("section",{className:"rounded-xl border border-border bg-muted/30 p-3","data-testid":"print-brand-cai",children:[t.jsx("div",{className:"mb-2 text-[12px] font-medium text-foreground",children:"Enhance with Cai"}),t.jsx("div",{className:"space-y-1.5",children:Ed.map(N=>t.jsxs("button",{type:"button","data-testid":`print-brand-cai-${N.id}`,onClick:()=>a(Fd(e,N.id)),className:"flex w-full items-center gap-2 rounded-lg px-1 py-1 text-left text-[12px] text-muted-foreground hover:bg-card hover:text-foreground",children:[t.jsx(ne,{className:"h-3.5 w-3.5 text-blue-500"}),N.label]},N.id))})]})]})]})}const Od="Hi! I'm Cai. I can help you design your prints â suggest layouts, choose fonts and colors, add event branding, or build out a template from scratch. What are you working on?",$d="Ask Cai anything about your design...",Bd="Cai is an AI assistant â responses are suggestions",us=[{id:"place-card",label:"Place card layout"},{id:"name-badge",label:"Name badge template"},{id:"gala-typography",label:"Gala typography"},{id:"garden-palette",label:"Garden palette"},{id:"cocktail-menu",label:"Cocktail menu"},{id:"dark-mood",label:"Dark mood scheme"},{id:"rustic-wedding",label:"Rustic wedding"},{id:"dinner-program",label:"Dinner program"}],Hd={"place-card":"I laid out a simple place card â guest name centered over a table line. Resize or swap in merge fields next.","name-badge":"Here's a name-badge starter: a rounded plate with name and role. Drop merge fields on top when you're ready.","gala-typography":"I set a gala title stack in Playfair with a supporting line. Tweak size from Properties if you want it larger.","garden-palette":"Garden palette applied â sage and cream blocks plus an event title. Use these as your background accents.","cocktail-menu":"A cocktail-menu skeleton is on the page: heading plus three drink lines. Add prices or descriptions as you like.","dark-mood":"Dark mood scheme is in: a charcoal band and light type. Keep body copy light so it stays readable.","rustic-wedding":"Rustic wedding pair names with a gold rule. Swap the names or drop merge fields for each event.","dinner-program":"Dinner program started with a title and three courses. Add times or wine pairings from Tools."};function Ud(){return[{id:"cai-hello",role:"cai",text:Od}]}function fa(e){const s=e.trim().toLowerCase();if(!s)return null;const r=us.find(n=>n.id===s||n.label.toLowerCase()===s);return r?r.id:us.find(n=>s.includes(n.label.toLowerCase())||n.label.toLowerCase().includes(s))?.id??null}function zd(e){const s=fa(e);return s?Hd[s]:"I can sketch a layout from a quick prompt, or keep describing the print you want â place cards, menus, badges, and programs all work."}function q(e={}){return{...ge,...e}}function Wd(e,s){const r=Math.round(s.width*.12),a=s.width-r*2,n=Math.round(s.width/2);return e==="place-card"?[{kind:"text",x:r,y:Math.round(s.height*.38),width:a,height:48,text:"Guest Name",style:q({fontFamily:"Playfair Display",fontSize:28,align:"center",bold:!0})},{kind:"line",x:r,y:Math.round(s.height*.48),width:a,height:16,lineStyle:{...Te}},{kind:"text",x:r,y:Math.round(s.height*.52),width:a,height:28,text:"Table 12",style:q({fontFamily:"Inter",fontSize:14,align:"center",color:"#64748B"})}]:e==="name-badge"?[{kind:"shape",x:r,y:Math.round(s.height*.32),width:a,height:160,shapeKind:"rect",shapeStyle:{...ke,fill:"#EFF6FF",borderColor:"#1D4ED8"}}
1,{kind:"text",x:r+16,y:Math.round(s.height*.36),width:a-32,height:44,text:"Jordan Hale",style:q({fontFamily:"Montserrat",fontSize:26,bold:!0,align:"center"})},{kind:"text",x:r+16,y:Math.round(s.height*.44),width:a-32,height:28,text:"Event Captain",style:q({fontFamily:"Inter",fontSize:14,align:"center",color:"#1D4ED8"})}]:e==="gala-typography"?[{kind:"text",x:r,y:Math.round(s.height*.2),width:a,height:64,text:"Autumn Gala",style:q({fontFamily:"Playfair Display",fontSize:40,bold:!0,align:"center"})},{kind:"text",x:r,y:Math.round(s.height*.3),width:a,height:32,text:"An evening of celebration",style:q({fontFamily:"Playfair Display",fontSize:16,italic:!0,align:"center",color:"#64748B"})}]:e==="garden-palette"?[{kind:"shape",x:0,y:0,width:s.width,height:88,shapeKind:"rect",shapeStyle:{...ke,fill:"#ECFDF5",borderWidth:0,borderColor:"#ECFDF5"}},{kind:"shape",x:0,y:s.height-72,width:s.width,height:72,shapeKind:"rect",shapeStyle:{...ke,fill:"#D1FAE5",borderWidth:0,borderColor:"#D1FAE5"}},{kind:"text",x:r,y:110,width:a,height:40,text:"Garden Reception",style:q({fontFamily:"Playfair Display",fontSize:28,color:"#065F46",align:"center"})}]:e==="cocktail-menu"?[{kind:"text",x:r,y:72,width:a,height:40,text:"Cocktails",style:q({fontFamily:"Playfair Display",fontSize:28,align:"center",bold:!0})},{kind:"text",x:r,y:130,width:a,height:28,text:"House Spritz",style:q({align:"center"})},{kind:"text",x:r,y:164,width:a,height:28,text:"Smoked Old Fashioned",style:q({align:"center"})},{kind:"text",x:r,y:198,width:a,height:28,text:"Garden Collins",style:q({align:"center"})}]:e==="dark-mood"?[{kind:"shape",x:0,y:0,width:s.width,height:140,shapeKind:"rect",shapeStyle:{...ke,fill:"#111827",borderWidth:0,borderColor:"#111827"}},{kind:"text",x:r,y:48,width:a,height:48,text:"Evening Service",style:q({fontFamily:"Playfair Display",fontSize:30,color:"#F8FAFC",align:"center"})}]:e==="rustic-wedding"?[{kind:"text",x:r,y:Math.round(s.height*.34),width:a,height:40,text:"Avery & Morgan",style:q({fontFamily:"Playfair Display",fontSize:30,align:"center"})},{kind:"line",x:n-80,y:Math.round(s.height*.42),width:160,height:16,lineStyle:{...Te,color:"#C4A574",thickness:3}},{kind:"text",x:r,y:Math.round(s.height*.46),width:a,height:28,text:"Together with their families",style:q({fontFamily:"Inter",fontSize:13,align:"center",color:"#78716C"})}]:[{kind:"text",x:r,y:64,width:a,height:40,text:"Dinner Program",style:q({fontFamily:"Playfair Display",fontSize:28,align:"center",bold:!0})},{kind:"text",x:r,y:128,width:a,height:28,text:"First Course",style:q({align:"center"})},{kind:"text",x:r,y:162,width:a,height:28,text:"Entrée",style:q({align:"center"})},{kind:"text",x:r,y:196,width:a,height:28,text:"Dessert",style:q({align:"center"})}]}function Gd(e,s,r=Date.now()){const a=s.trim();return a?[...e,{id:`user-${r}`,role:"user",text:a},{id:`cai-${r}`,role:"cai",text:zd(a)}]:e}function Kd({title:e,onClose:s}){return t.jsxs("div",{className:"flex items-center justify-between px-4 pt-4 pb-3",children:[t.jsxs("h2",{className:"flex items-center gap-2 text-[13px] font-semibold tracking-[0.14em] text-foreground",children:[t.jsx(ne,{className:"h-3.5 w-3.5 text-blue-500"}),e]}),t.jsx("button",{type:"button",onClick:s,className:"h-6 w-6 rounded-md text-muted-foreground hover:bg-accent hover:text-muted-foreground","aria-label":`Close ${e}`,children:"Ã"})]})}function Qd({messages:e,draft:s,onDraft:r,onSubmit:a,onPrompt:n,onClose:o}){return t.jsxs("div",{className:"flex h-full flex-col","data-testid":"print-cai-pane",children:[t.jsx(Kd,{title:"CAI AI",onClose:o}),t.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto px-4 pb-3",children:[t.jsx("div",{className:"space-y-2",children:e.map(i=>t.jsx("div",{"data-testid":`print-cai-message-${i.role}`,className:k("rounded-xl border px-3 py-2 text-[12px] leading-5",i.role==="cai"?"border-border bg-card text-foreground":"ml-6 border-[hsl(var(--cover-user-accent-border))] bg-[hsl(var(--cover-user-accent-subtle))] text-foreground"),children:i.text},i.id))}),t.jsxs("section",{children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"QUICK PROMPTS"}),t.jsx("div",{className:"grid grid-cols-2 gap-2",children:us.map(i=>t.jsx("button",{type:"button","data-testid":`print-cai-prompt-${i.id}`,onClick:()=>n(i.label),className:"rounded-full border border-border bg-card px-2.5 py-1.5 text-left text-[11px] text-foreground hover:border-[hsl(var(--cover-user-accent))] hover:bg-[hsl(var(--cover-user-accent-subtle)/0.5)]",children:i.label},i.id))})]})]}),t.jsxs("div",{className:"border-t border-border px-4 py-3",children:[t.jsx("form",{onSubmit:i=>{i.preventDefault(),a(s)},children:t.jsxs("label",{className:"relative block",children:[t.jsx(ne,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-blue-500"}),t.jsx("input",{value:s,onChange:i=>r(i.target.value),placeholder:$d,"data-testid":"print-cai-ask",className:"h-9 w-full rounded-full border border-border bg-muted pl-9 pr-3 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-[hsl(var(--cover-user-accent))] focus:bg-card focus:outline-none"})]})}),t.jsx("p",{className:"mt-2 text-[10px] text-muted-foreground",children:Bd})]})]})}function qd({section:e,onChange:s}){const r=Ge(e.sectionType),a=new Map(r.map(u=>[u.key,u.label])),n=Ee(e.sectionType,e.fieldOrder),o=zo(cr(Go,{activationConstraint:{distance:6}}),cr(Wo,{coordinateGetter:Yo})),i=u=>{const d=u.over?.id;!d||d===u.active.id||s(yl(e,String(u.active.id),String(d)))};return t.jsxs("div",{"data-testid":"print-section-field-list",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[t.jsxs("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:["Fields ",e.fields.length,"/",r.length]}),t.jsxs("div",{className:"flex gap-2 text-[11px] text-[hsl(var(--cover-user-accent-text))]",children:[t.jsx("button",{type:"button","data-testid":"print-fields-all",onClick:()=>s(hr(e,!0)),children:"All"}),t.jsx("button",{type:"button","data-testid":"print-fields-none",onClick:()=>s(hr(e,!1)),children:"None"})]})]}),t.jsx(Ko,{sensors:o,collisionDetection:Qo,onDragEnd:i,children:t.jsx(Vo,{items:n,strategy:Jo,children:t.jsx("div",{className:"space-y-1",children:n.map(u=>t.jsx(Yd,{fieldKey:u,label:a.get(u)||u,enabled:e.fields.includes(u),onToggle:()=>s(jl(e,u))},u))})})})]})}function Yd({fieldKey:e,label:s,enabled:r,onToggle:a}){const{attributes:n,listeners:o,setNodeRef:i,transform:u,transition:d,isDragging:c}=Xo({id:e});return t.jsxs("div",{ref:i,style:{transform:qo.Transform.toString(u),transition:d},className:k("flex items-center justify-between gap-2 rounded-md px-1 py-0.5 text-[12px] text-foreground",c&&"relative z-10 bg-card o
1pacity-80 shadow-md"),"data-testid":`print-field-row-${e}`,"data-field-key":e,children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("button",{type:"button",...n,...o,"aria-label":`Drag ${s} to reorder`,className:"flex min-h-11 min-w-11 cursor-grab touch-none items-center justify-center rounded-lg text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary active:cursor-grabbing","data-testid":`print-field-drag-${e}`,children:t.jsx(Cn,{className:"pointer-events-none h-4 w-4","aria-hidden":"true"})}),t.jsx("span",{className:"truncate",children:s})]}),t.jsx("button",{type:"button",role:"switch","aria-checked":r,"aria-label":`${r?"Hide":"Show"} ${s}`,"data-testid":`print-field-toggle-${e}`,onClick:a,className:k("h-5 w-9 shrink-0 rounded-full p-0.5",r?"bg-amber-500":"bg-border"),children:t.jsx("span",{className:k("block h-4 w-4 rounded-full bg-card transition",r&&"ml-4")})})]})}const Vd={type:"Menu Item Type",category:"Menu Item Category",prepArea:"Prep Area",vendor:"Vendor",hiddenStatus:"Hidden Status"},Jd={type:"All Types",category:"All Categories",prepArea:"All Prep Areas",vendor:"All Vendors",hiddenStatus:"All Items"},Xd={type:"Type",category:"Category",prepArea:"Prep Area",vendor:"Vendor"};function Sr(e,s,r){const n={...e.find(o=>o.key===s)||{key:s,operator:"equals",value:""},...r,key:s};return e.some(o=>o.key===s)?e.map(o=>o.key===s?n:o):[...e,n]}
1function Zd({style:e,onChange:s,onClose:r}){const a=e||Wr;return t.jsxs("div",{className:"flex h-full flex-col","data-testid":"print-field-properties",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 pt-4 pb-3",children:[t.jsx("h2",{className:"text-[13px] font-semibold tracking-[0.14em] text-foreground",children:"PROPERTIES"}),t.jsx("button",{type:"button",onClick:r,className:"h-6 w-6 text-muted-foreground",children:"Ã"})]}),t.jsx("div",{className:"px-4",children:t.jsxs("label",{className:"relative block",children:[t.jsx(ne,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-blue-500"}),t.jsx("input",{placeholder:"Help me style this element...",className:"h-9 w-full rounded-full border border-border bg-muted pl-9 pr-3 text-[12px] placeholder:text-muted-foreground"})]})}),t.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto px-4 py-4",children:[t.jsxs("section",{children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"TEXT"}),t.jsx("label",{className:"block text-[11px] text-muted-foreground",children:"Font Family"}),t.jsx("select",{value:a.fontFamily,onChange:n=>s({...a,fontFamily:n.target.value}),"data-testid":"print-font-family",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]",children:We.map(n=>t.jsx("option",{value:n,children:n},n))}),t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"number",min:8,max:72,value:a.fontSize,onChange:n=>s({...a,fontSize:Number(n.target.value)||13}),"data-testid":"print-font-size",className:"h-9 w-16 rounded-lg border border-border px-2 text-[13px]"}),t.jsx("button",{type:"button","data-testid":"print-font-bold",onClick:()=>s({...a,bold:!a.bold}),className:k("h-9 w-9 rounded-lg border text-sm font-bold",a.bold?"border-[hsl(var(--cover-user-accent))] bg-[hsl(var(--cover-user-accent-subtle))] text-[hsl(var(--cover-user-accent-text))]":"border-border"),children:"B"}),t.jsx("button",{type:"button","data-testid":"print-font-italic",onClick:()=>s({...a,italic:!a.italic}),className:k("h-9 w-9 rounded-lg border text-sm italic",a.italic?"border-[hsl(var(--cover-user-accent))] bg-[hsl(var(--cover-user-accent-subtle))] text-[hsl(var(--cover-user-accent-text))]":"border-border"),children:"I"})]}),t.jsx("div",{className:"mt-2 flex overflow-hidden rounded-lg border border-border",children:["left","center","right"].map(n=>t.jsx("button",{type:"button","data-testid":`print-align-${n}`,onClick:()=>s({...a,align:n}),className:k("h-8 flex-1 text-[11px] capitalize",a.align===n?"bg-[hsl(var(--cover-user-accent))] text-white":"bg-card text-muted-foreground"),children:n},n))})]}),t.jsxs("section",{children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"COLOR"}),t.jsx("div",{className:"grid grid-cols-8 gap-1.5",children:Gr.map(n=>t.jsx("button",{type:"button",onClick:()=>s({...a,color:n}),"data-testid":`print-swatch-${n}`,className:k("h-5 w-5 rounded-sm border",a.color===n?"ring-2 ring-[hsl(var(--cover-user-accent)/0.4)]":"border-border"),style:{background:n}},n))}),t.jsx("input",{value:a.color,onChange:n=>s({...a,color:n.target.value}),placeholder:"#334155","data-testid":"print-custom-color",className:"mt-2 h-9 w-full rounded-lg border border-border px-2 font-mono text-[12px]"})]}),t.jsxs("section",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"text-[11px] text-muted-foreground",children:["Letter Spacing",t.jsx("input",{type:"number",value:a.letterSpacing,onChange:n=>s({...a,letterSpacing:Number(n.target.value)||0}),className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]"})]}),t.jsxs("label",{className:"text-[11px] text-muted-foreground",children:["Line Height",t.jsx("input",{type:"number",step:"0.1",value:a.lineHeight,onChange:n=>s({...a,lineHeight:Number(n.target.value)||1.5}),className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]"})]})]}),t.jsxs("label",{className:"block text-[11px] text-muted-foreground",children:["Opacity",t.jsx("input",{type:"range",min:.1,max:1,step:.
105,value:a.opacity,onChange:n=>s({...a,opacity:Number(n.target.value)}),className:"mt-2 w-full"})]})]})]})}function ec({section:e,element:s,lists:r,tab:a,onTab:n,onChange:o,onElementChange:i,onLayer:u,onDelete:d,onClose:c}){return t.jsxs("div",{className:"flex h-full flex-col","data-testid":"print-section-properties",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 pt-4 pb-3",children:[t.jsx("h2",{className:"text-[13px] font-semibold tracking-[0.14em] text-foreground",children:"PROPERTIES"}),t.jsx("button",{type:"button",onClick:c,className:"h-6 w-6 text-muted-foreground",children:"Ã"})]}),t.jsx("div",{className:"px-4",children:t.jsxs("label",{className:"relative block",children:[t.jsx(ne,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-blue-500"}),t.jsx("input",{placeholder:"Help me style this element...",className:"h-9 w-full rounded-full border border-border bg-muted pl-9 pr-3 text-[12px] placeholder:text-muted-foreground"})]})}),t.jsx("div",{className:"mt-3 flex border-b border-border px-2",children:["fields","style","layout"].map(f=>t.jsx("button",{type:"button",onClick:()=>n(f),"data-testid":`print-section-tab-${f}`,className:k("flex-1 pb-2 text-[12px] font-medium capitalize",a===f?"border-b-2 border-amber-500 text-amber-700":"text-muted-foreground"),children:f},f))}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:[a==="fields"&&t.jsx(sc,{section:e,lists:r,onChange:o}),a==="style"&&t.jsx(rc,{section:e,onChange:o}),a==="layout"&&t.jsx(ac,{section:e,element:s,onChange:o,onElementChange:i,onLayer:u,onDelete:d})]})]})}function tc({selected:e,onChange:s}){const[r,a]=y.useState(!1),n=uo(e),o=n.filter(i=>e.includes(i.key)).map(i=>i.label).join(", ")||"None";return t.jsxs("div",{className:"relative mt-1",children:[t.jsxs("button",{type:"button","data-testid":"print-subevent-header-fields","aria-expanded":r,"aria-haspopup":"listbox",onClick:()=>a(i=>!i),className:"flex h-9 w-full items-center justify-between rounded-lg border border-border bg-card px-2 text-left text-[12px] font-normal text-foreground",children:[t.jsx("span",{className:"truncate",children:o}),t.jsx(Dr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),r&&t.jsx("div",{role:"listbox","aria-label":"Subevent Group Header Fields","data-testid":"print-subevent-header-fields-menu",className:"mt-1 space-y-1 rounded-lg border border-border bg-card p-2",children:n.map(i=>t.jsxs("label",{className:"flex items-center gap-2 text-[12px] font-normal text-foreground",children:[t.jsx("input",{type:"checkbox",checked:e.includes(i.key),"data-testid":`print-subevent-header-field-${i.key}`,onChange:u=>{const d=u.target.checked?[...e,i.key]:e.filter(c=>c!==i.key);s(d)}}),i.label]},i.key))})]})}function sc({section:e,lists:s,onChange:r}){const a=ts(e),n=o=>r(ts(o));return t.jsxs("div",{className:"space-y-4","data-testid":"print-section-fields",children:[t.jsxs("label",{className:"block text-[11px] font-medium text-muted-foreground",children:["Section Title",t.jsx("input",{value:a.title,onChange:o=>n({...a,title:o.target.value}),"data-testid":"print-section-title",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px] text-foreground"})]}),(a.sectionType==="menu-items"||!a.sectionType)&&t.jsxs(t.Fragment,{children:[t.jsxs("section",{"data-testid":"print-display-options",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"DISPLAY OPTIONS"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:"flex items-center gap-2 text-[12px] text-foreground",children:[t.jsx("input",{type:"checkbox",checked:a.insertSummaryRow,onChange:o=>n({...a,insertSummaryRow:o.target.checked}),"data-testid":"print-insert-summary"}),"Insert Summary Row"]}),t.jsxs("label",{className:"flex items-center gap-2 text-[12px] text-foreground",children:[t.jsx("input",{type:"checkbox",checked:a.suppressWhenEmpty,onChange:o=>n({...a,suppressWhenEmpty:o.target.checked}),"data-testid":"print-suppress-when-empty"}),"Suppress Table When Empty"]})]})]}),t.jsxs("section",{"data-testid":"print-filter-options",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"FILTER OPTIONS"}),t.jsxs("label",{className:"mb-2 flex items-center gap-2 text-[12px] text-foreground",children:[t.jsx("input",{type:"checkbox",checked:a.excludeWithoutQuantities,onChange:o=>n({...a,excludeWithoutQuantities:o.target.checked}),"data-testid":"print-exclude-without-quantities"}),"Exclude Items Without Quantities"]}),t.jsx("div",{className:"space-y-2",children:oo.map(o=>{const i=a.filters.find(d=>d.key===o)||{operator:"equals",value:""},u=o==="hiddenStatus"?["True","False"]:s[o];return t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"text-[11px] font-medium text-muted-foreground",children:Vd[o]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("select",{value:i.operator,onChange:d=>{const c=Sr(a.filters,o,{operator:d.target.value});n({...a,filters:c})},"data-testid":`print-filter-op-${o}`,className:"h-8 flex-1 rounded-md border border-border px-1 text-[11px]",children:[t.jsx("option",{value:"equals",children:"equals"}),t.jsx("option",{value:"does-not-equal",children:"does not equal"})]}),t.jsxs("select",{value:i.value,onChange:d=>{const c=Sr(a.filters,o,{value:d.target.value});n({...a,filters:c})},"data-testid":`print-filter-value-${o}`,className:"h-8 flex-1 rounded-md border border-border px-1 text-[11px]",children:[t.jsx("option",{value:"",children:Jd[o]}),u.map(d=>t.jsx("option",{value:d,children:d},d))]})]})]},o)})})]}),t.jsxs("section",{"data-testid":"print-grouping-options",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"GROUPING"}),t.jsxs("label",{className:"flex items-center gap-2 text-[12px] text-foreground",children:[t.jsx("input",{type:"checkbox",checked:a.groupBySubevent,onChange:o=>n({...a,groupBySubevent:o.target.checked}),"data-testid":"print-group-by-subevent"}),"Group by Subevent"]}),t.jsxs("label",{className:"mt-3 block text-[11px] font-medium text-muted-foreground",children:["Subevent Group Header Fields",t.jsx(tc,{selected:a.subeventHeaderFields,onChange:o=>n({...a,subeventHeaderFields:o})})]}),t.jsxs("label",{className:"mt-3 block text-[11px] font-medium text-muted-foreground",children:["Within Subevent, Group By",t.jsxs("select",{value:a.secondaryGroupBy,onChange:o=>n({...a,secondaryGroupBy:o.target.value}),"data-testid":"print-secondary-group",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[12px] font-normal text-foreground",children:[t.jsx("option",{value:"",children:"None"}),io.map(o=>t.jsx("option",{value:o,children:Xd[o]},o))]})]}),t.jsxs("label",{className:"mt-2 flex items-center gap-2 text-[12px] text-foreground",children:[t.jsx("input",{type:"checkbox",checked:a.addSummaryRow,onChange:o=>n({...a,addSummaryRow:o.target.checked}),"data-testid":"print-add-summary-row"}),"Add Summary Row"]})]})]}),t.jsx(qd,{section:a,onChange:r})]})}function rc({section:e,onChange:s}){return t.jsxs("div",{className:"space-y-4","data-testid":"print-section-style",children:[t.jsxs("label",{className:"flex items-center gap-2 text-[12px] text-foreground",children:[t.jsx("input",{type:"checkbox",checked:e.showBorders,onChange:r=>s({...e,showBorders:r.target.checked})}),"Show Borders"]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"HEADER STYLE"}),t.jsx("div",{className:"grid grid-cols-4 gap-2",children:[["solid","Solid"],["gradient","Gradient"],["minimal","Minimal"],["sidebar","Side bar"]].map(([r,a])=>t.jsx("button",{type:"button",onClick:()=>s({...e,headerStyle:r}),className:k("rounded-lg border px-1 py-2 text-[10px]",e.headerStyle===r?"border-amber-500 bg-amber-50":"border-border"),children:a},r))})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"ACCENT COLOR"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:lo.map(r=>
1t.jsx("button",{type:"button",onClick:()=>s({...e,accentColor:r}),className:k("h-6 w-6 rounded-full border",e.accentColor===r?"ring-2 ring-amber-500":"border-border"),style:{background:r}},r))})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"BACKGROUND"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:co.map(r=>t.jsx("button",{type:"button",onClick:()=>s({...e,backgroundColor:r}),className:k("h-6 w-6 rounded-full border",e.backgroundColor===r?"ring-2 ring-amber-500":"border-border"),style:{background:r}},r))})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"FONT FAMILY"}),t.jsx("div",{className:"grid grid-cols-2 gap-2",children:We.map(r=>t.jsx("button",{type:"button",onClick:()=>s({...e,fontFamily:r}),className:k("rounded-lg border px-2 py-1.5 text-[11px]",e.fontFamily===r?"border-amber-500":"border-border"),style:{fontFamily:r},children:r},r))})]}),t.jsxs("label",{className:"block text-[11px] text-muted-foreground",children:["Corner Radius",t.jsx("input",{type:"range",min:0,max:24,value:e.cornerRadius,onChange:r=>s({...e,cornerRadius:Number(r.target.value)}),className:"mt-2 w-full"}),t.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[e.cornerRadius,"px"]})]})]})}function ac({section:e,element:s,onChange:r,onElementChange:a,onLayer:n,onDelete:o}){const i=ia(e,e.sectionType),u=Ge(e.sectionType),d=(c,f)=>{a({...s,[c]:Number.isFinite(f)?f:0})};return t.jsxs("div",{className:"space-y-4","data-testid":"print-section-layout",children:[t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"LAYOUT MODE"}),t.jsx("div",{className:"grid grid-cols-3 gap-2",children:Ti.map(c=>t.jsxs("button",{type:"button","data-testid":`print-layout-${c.id}`,onClick:()=>r({...e,layoutMode:c.id}),className:k("flex flex-col items-center gap-1 rounded-lg border px-1 py-2 text-[10px]",i.layoutMode===c.id?"border-[hsl(var(--cover-user-accent))] bg-[hsl(var(--cover-user-accent-subtle))] text-[hsl(var(--cover-user-accent-text))]":"border-border text-muted-foreground"),children:[t.jsx(nc,{icon:c.icon}),c.label]},c.id))}),i.layoutMode==="custom"&&t.jsxs("div",{className:"space-y-3","data-testid":"print-layout-custom",children:[t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"COLUMNS"}),t.jsx("div",{className:"flex flex-wrap gap-1",children:Array.from({length:ta},(c,f)=>f+1).map(c=>t.jsx("button",{type:"button","data-testid":`print-custom-cols-${c}`,onClick:()=>{const f=wt(c);r({...e,customColumnCount:f,customRows:ra(e.customRows?.length?e.customRows:Ns(e.sectionType,f),f,e.sectionType)})},className:k("h-7 w-7 rounded-md border text-[11px]",i.customColumnCount===c?"border-[hsl(var(--cover-user-accent))] bg-[hsl(var(--cover-user-accent-subtle))] text-[hsl(var(--cover-user-accent-text))]":"border-border text-muted-foreground"),children:c},c))}),t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"ROW FIELDS"}),t.jsx("div",{className:"space-y-2",children:i.customRows.map((c,f)=>t.jsxs("div",{className:"space-y-1","data-testid":`print-custom-row-${f}`,children:[t.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["Row ",f+1]}),t.jsx("div",{className:"grid gap-1",style:{gridTemplateColumns:`repeat(${i.customColumnCount}, minmax(0, 1fr))`},children:c.map((b,j)=>t.jsxs("select",{value:b,"data-testid":`print-custom-field-${f}-${j}`,onChange:g=>{const S=i.customRows.map(($,B)=>B===f?$.map((N,A)=>A===j?g.target.value:N):$);r({...e,customRows:S})},className:"h-8 w-full rounded-md border border-border px-1 text-[10px]",children:[t.jsx("option",{value:"",children:"â"}),u.map(g=>t.jsx("option",{value:g.key,children:g.label},g.key))]},`${f}-${j}`))})]},f))}),t.jsx("button",{type:"button","data-testid":"print-custom-add-row",onClick:()=>r({...e,customRows:[...i.customRows,Array.from({length:i.customColumnCount},()=>"")]}),className:"text-[11px] font-medium text-[hsl(var(--cover-user-accent-text))]",children:"+ Add row"}),i.customRows.length>1&&t.jsx("button",{type:"button","data-testid":"print-custom-remove-row",onClick:()=>r({...e,customRows:i.customRows.slice(0,-1)}),className:"ml-3 text-[11px] text-muted-foreground",children:"Remove last row"}),t.jsxs("label",{className:"flex items-center gap-2 text-[12px] text-foreground",children:[t.jsx("input",{type:"checkbox",checked:i.showDividers,"data-testid":"print-show-dividers",onChange:c=>r({...e,showDividers:c.target.checked})}),"Show dividers between items"]}),t.jsxs("label",{className:"flex items-center gap-2 text-[12px] text-foreground",children:[t.jsx("input",{type:"checkbox",checked:i.alternateRowTint,"data-testid":"print-alternate-tint",onCh
1ange:c=>r({...e,alternateRowTint:c.target.checked})}),"Alternate row tint"]})]}),t.jsxs("section",{"data-testid":"print-position-size",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"POSITION & SIZE"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"text-[11px] text-muted-foreground",children:["X",t.jsx("input",{type:"number",value:Math.round(s.x),onChange:c=>d("x",Number(c.target.value)),"data-testid":"print-pos-x",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]"})]}),t.jsxs("label",{className:"text-[11px] text-muted-foreground",children:["Y",t.jsx("input",{type:"number",value:Math.round(s.y),onChange:c=>d("y",Number(c.target.value)),"data-testid":"print-pos-y",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]"})]}),t.jsxs("label",{className:"text-[11px] text-muted-foreground",children:["W",t.jsx("input",{type:"number",value:Math.round(s.width),onChange:c=>d("width",Number(c.target.value)),"data-testid":"print-pos-w",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]"})]}),t.jsxs("label",{className:"text-[11px] text-muted-foreground",children:["H",t.jsx("input",{type:"number",value:Math.round(s.height),onChange:c=>d("height",Number(c.target.value)),"data-testid":"print-pos-h",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]"})]})]})]}),t.jsxs("button",{type:"button",onClick:o,"data-testid":"print-delete-section",className:"flex h-9 w-full items-center justify-center gap-2 rounded-lg border border-red-200 text-[12px] font-medium text-red-600",children:[t.jsx(hs,{className:"h-3.5 w-3.5"}),"Delete Section"]}),t.jsx(Cs,{wrapText:i.wrapTextAroundObject,onWrap:c=>r({...e,wrapTextAroundObject:c}),onLayer:n})]})}function Cs({wrapText:e,onWrap:s,onLayer:r}){return t.jsxs("div",{className:"space-y-2","data-testid":"print-layer-order",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"LAYER ORDER"}),s&&t.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-foreground",children:[t.jsx("input",{type:"checkbox",checked:!!e,"data-testid":"print-wrap-text",onChange:a=>s(a.target.checked)}),"Wrap text around object"]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button","data-testid":"print-layer-back",onClick:()=>r("back"),className:"h-8 flex-1 rounded-md border border-border text-[10px]",children:"Back"}),t.jsx("button",{type:"button","data-testid":"print-layer-backward",onClick:()=>r("backward"),className:"flex h-8 w-8 items-center justify-center rounded-md border border-border","aria-label":"Send backward",children:t.jsx(Dr,{className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button","data-testid":"print-layer-forward",onClick:()=>r("forward"),className:"flex h-8 w-8 items-center justify-center rounded-md border border-border","aria-label":"Bring forward",children:t.jsx(_n,{className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button","data-testid":"print-layer-front",onClick:()=>r("front"),className:"h-8 flex-1 rounded-md border border-border text-[10px]",children:"Front"})]})]})}function nc({icon:e}){const s="h-0.5 rounded-sm bg-current";if(e==="compact")return t.jsxs("span",{className:"flex h-5 w-7 flex-col justify-center gap-0.5",children:[t.jsx("span",{className:s}),t.jsx("span",{className:s}),t.jsx("span",{className:s})]});if(e==="cards")return t.jsx("span",{className:"h-4 w-7 rounded-sm border border-current"});if(e==="grid")return t.jsxs("span",{className:"grid h-4 w-7 grid-cols-2 gap-0.5",children:[t.jsx("span",{className:"rounded-[1px] border border-current"}),t.jsx("span",{className:"rounded-[1px] border border-current"})]});if(e==="cols-2"||e==="cols-3"){const r=e==="cols-3"?3:2;return t.jsx("span",{className:"flex h-4 w-7 gap-0.5",children:Array.from({length:r},(a,n)=>t.jsx("span",{className:"flex-1 rounded-[1px] border border-current"},n))})}return e==="custom"?t.jsx("span",{className:"grid h-4 w-7 grid-cols-3 gap-px",children:Array.from({length:6},(r,a)=>t.jsx("span",{className:"border border-current"},a))}):e==="numbered"?t.jsx("span",{className:"text-[11px] font-semibold leading-none",children:"1."}):e==="checklist"?t.jsx("span",{className:"h-3 w-3 rounded-full border border-current"}):t.jsxs("span",{className:"flex h-5 w-7 flex-col justify-center gap-0.5",children:[t.jsx("span",{className:k(s,"w-full")}),t.jsx("span",{className:k(s,"w-4/5")}),t.jsx("span",{className:k(s,"w-full")})]})}function kt({onClose:e,children:s}){return t.jsxs("div",{className:"flex h-full flex-col","data-testid":"print-tool-properties",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 pt-4 pb-3",children:[t.jsx("h2",{className:"text-[13px] font-semibold tracking-[0.14em] text-foreground",children:"PROPERTIES"}),t.jsx("button",{type:"button",onClick:e,className:"h-6 w-6 text-muted-foreground","aria-label":"Close properties",children:"Ã"})]}),t.jsx("div",{className:"px-4",children:t.jsxs("label",{className:"relative block",children:[t.jsx(ne,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-blue-500"}),t.jsx("input",{placeholder:"Help me style this element...",className:"h-9 w-full rounded-full border border-border bg-muted pl-9 pr-3 text-[12px] placeholder:text-muted-foreground"})]})}),t.jsx("div",{className:"flex-1 space-y-4 overflow-y-auto px-4 py-4",children:s})]})}
1function mt({value:e,onChange:s,testId:r}){return t.jsxs("div",{children:[t.jsx("input",{value:e,onChange:a=>s(a.target.value),"data-testid":r,className:"mb-2 h-9 w-full rounded-lg border border-border px-2 font-mono text-[12px]"}),t.jsx("div",{className:"grid grid-cols-8 gap-1.5",children:Gr.map(a=>t.jsx("button",{type:"button",onClick:()=>s(a),"data-testid":`${r}-swatch-${a}`,className:k("h-5 w-5 rounded-sm border",e===a?"ring-2 ring-[hsl(var(--cover-user-accent)/0.4)]":"border-border"),style:{background:a}},a))})]})}function St({element:e,onChange:s}){const r=(a,n)=>{s({...e,[a]:Number.isFinite(n)?n:0})};return t.jsxs("section",{"data-testid":"print-position-size",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"POSITION & SIZE"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"text-[11px] text-muted-foreground",children:["X",t.jsx("input",{type:"number",value:Math.round(e.x),onChange:a=>r("x",Number(a.target.value)),"data-testid":"print-pos-x",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]"})]}),t.jsxs("label",{className:"text-[11px] text-muted-foreground",children:["Y",t.jsx("input",{type:"number",value:Math.round(e.y),onChange:a=>r("y",Number(a.target.value)),"data-testid":"print-pos-y",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]"})]}),t.jsxs("label",{className:"text-[11px] text-muted-foreground",children:["W",t.jsx("input",{type:"number",value:Math.round(e.width),onChange:a=>r("width",Number(a.target.value)),"data-testid":"print-pos-w",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]"})]}),t.jsxs("label",{className:"text-[11px] text-muted-foreground",children:["H",t.jsx("input",{type:"number",value:Math.round(e.height),onChange:a=>r("height",Number(a.target.value)),"data-testid":"print-pos-h",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]"})]})]})]})}function Ct({onDelete:e}){return t.jsxs("button",{type:"button",onClick:e,"data-testid":"print-delete-element",className:"flex h-9 w-full items-center justify-center gap-2 rounded-lg border border-red-200 text-[12px] font-medium text-red-600",children:[t.jsx(hs,{className:"h-3.5 w-3.5"}),"Delete Element"]})}function oc({element:e,onChange:s,onDelete:r,onClose:a}){const n=e.style||ge,o=i=>s({...e,style:i});return t.jsxs(kt,{onClose:a,children:[t.jsxs("section",{"data-testid":"print-text-properties",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"TEXT"}),t.jsx("label",{className:"block text-[11px] text-muted-foreground",children:"Font Family"}),t.jsx("select",{value:n.fontFamily,onChange:i=>o({...n,fontFamily:i.target.value}),"data-testid":"print-font-family",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]",children:We.map(i=>t.jsx("option",{value:i,children:i},i))}),t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"number",min:8,max:72,value:n.fontSize,onChange:i=>o({...n,fontSize:Number(i.target.value)||16}),"data-testid":"print-font-size",className:"h-9 w-16 rounded-lg border border-border px-2 text-[13px]"}),t.jsx("button",{type:"button","data-testid":"print-font-bold",onClick:()=>o({...n,bold:!n.bold}),className:k("h-9 w-9 rounded-lg border text-sm font-bold",n.bold?"border-[hsl(var(--cover-user-accent))] bg-[hsl(var(--cover-user-accent-subtle))] text-[hsl(var(--cover-user-accent-text))]":"border-border"),children:"B"}),t.jsx("button",{type:"button","data-testid":"print-font-italic",onClick:()=>o({...n,italic:!n.italic}),className:k("h-9 w-9 rounded-lg border text-sm italic",n.italic?"border-[hsl(var(--cover-user-accent))] bg-[hsl(var(--cover-user-accent-subtle))] text-[hsl(var(--cover-user-accent-text))]":"border-border"),children:"I"})]}),t.jsx("div",{className:"mt-2 flex overflow-hidden rounded-lg border border-border",children:["left","center","right"].map(i=>t.jsx("button",{type:"button","data-testid":`print-align-${i}`,onClick:()=>o({...n,align:i}),className:k("h-8 flex-1 text-[11px] capitalize",n.align===i?"bg-[hsl(var(--cover-user-accent))] text-white":"bg-card text-muted-foreground"),children:i},i))}),t.jsx("div",{className:"mt-3 text-[11px] text-muted-foreground",children:"Color"}),t.jsx(mt,{value:n.color,onChange:i=>o({...n,color:i}),testId:"print-text-color"}),t.jsxs("label",{className:"mt-3 block text-[11px] text-muted-foreground",children:["Letter Spacing",t.jsx("input",{type:"range",min:0,max:10,step:.5,value:n.letterSpacing,onChange:i=>o({...n,letterSpacing:Number(i.target.value)}),"data-testid":"print-letter-spacing",className:"mt-2 w-full"}),t.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[n.letterSpacing,"px"]})]}),t.jsxs("label",{className:"mt-2 block text-[11px] text-muted-foreground",children:["Line Height",t.jsx("input",{type:"number",step:"0.1",value:n.lineHeight,onChange:i=>o({...n,lineHeight:Number(i.target.value)||1.4}),"data-testid":"print-line-height",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]"})]}),t.jsxs("label",{className:"mt-2 block text-[11px] text-muted-foreground",children:["Opacity",t.jsx("input",{type:"range",min:.1,max:1,step:.
105,value:n.opacity,onChange:i=>o({...n,opacity:Number(i.target.value)}),"data-testid":"print-text-opacity",className:"mt-2 w-full"}),t.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[Math.round(n.opacity*100),"%"]})]})]}),t.jsx(St,{element:e,onChange:s}),t.jsx(Ct,{onDelete:r})]})}function ic({element:e,onChange:s,onDelete:r,onLayer:a,onClose:n}){const o=e.shapeStyle||ke,i=u=>s({...e,shapeStyle:u});return t.jsxs(kt,{onClose:n,children:[t.jsxs("section",{"data-testid":"print-shape-properties",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"SHAPE"}),t.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Fill"}),t.jsx(mt,{value:o.fill,onChange:u=>i({...o,fill:u}),testId:"print-shape-fill"}),t.jsx("div",{className:"mt-3 text-[11px] text-muted-foreground",children:"Border"}),t.jsx(mt,{value:o.borderColor,onChange:u=>i({...o,borderColor:u}),testId:"print-shape-border"}),t.jsxs("label",{className:"mt-3 block text-[11px] text-muted-foreground",children:["Border Size",t.jsx("input",{type:"number",min:0,max:24,value:o.borderWidth,onChange:u=>i({...o,borderWidth:Number(u.target.value)||0}),"data-testid":"print-shape-border-width",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]"})]}),t.jsx("div",{className:"mt-3 text-[11px] text-muted-foreground",children:"Border Style"}),t.jsx("div",{className:"mt-1 flex overflow-hidden rounded-lg border border-border",children:sl.map(u=>t.jsx("button",{type:"button","data-testid":`print-shape-border-style-${u}`,onClick:()=>i({...o,borderStyle:u}),className:k("h-8 flex-1 text-[11px] capitalize",o.borderStyle===u?"bg-[hsl(var(--cover-user-accent))] text-white":"bg-card text-muted-foreground"),children:u},u))})]}),t.jsx(St,{element:e,onChange:s}),a&&t.jsx(Cs,{onLayer:a}),t.jsx(Ct,{onDelete:r})]})}function lc({element:e,onChange:s,onDelete:r,onLayer:a,onClose:n}){return t.jsxs(kt,{onClose:n,children:[t.jsxs("section",{"data-testid":"print-image-properties",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"IMAGE"}),t.jsx("div",{className:"text-[12px] text-foreground",children:e.imageName||"Upload"}),e.imageSrc&&t.jsx("img",{src:e.imageSrc,alt:e.imageName||"Upload",className:"mt-2 h-24 w-full rounded-md border border-border object-cover"})]}),t.jsx(St,{element:e,onChange:s}),t.jsx(Cs,{onLayer:a}),t.jsx(Ct,{onDelete:r})]})}function dc({element:e,pageWidth:s,onChange:r,onDelete:a,onClose:n}){const o=e.lineStyle||Te,i=(u,d=e.x)=>{const c=Math.max(24,u.thickness+16);r({...e,lineStyle:u,x:d,height:c})};return t.jsxs(kt,{onClose:n,children:[t.jsxs("section",{"data-testid":"print-line-properties",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"LINE"}),t.jsxs("label",{className:"block text-[11px] text-muted-foreground",children:["Thickness",t.jsx("input",{type:"number",min:1,max:48,value:o.thickness,onChange:u=>i({...o,thickness:Number(u.target.value)||1}),"data-testid":"print-line-thickness",className:"mt-1 h-9 w-full rounded-lg border border-border px-2 text-[13px]"})]}),t.jsx("div",{className:"mt-3 text-[11px] text-muted-foreground",children:"Color"}),t.jsx(mt,{value:o.color,onChange:u=>i({...o,color:u}),testId:"print-line-color"}),t.jsx("div",{className:"mt-3 text-[11px] text-muted-foreground",children:"Alignment"}),t.jsx("div",{className:"mt-1 flex overflow-hidden rounded-lg border border-border",children:["left","center","right"].map(u=>t.jsx("button",{type:"button","data-testid":`print-line-align-${u}`,onClick:()=>i({...o,align:u},da(e.width,s,u)),className:k("h-8 flex-1 text-[11px] capitalize",o.align===u?"bg-[hsl(var(--cover-user-accent))] text-white":"bg-card text-muted-foreground"),children:u},u))})]}),t.jsx(St,{element:e,onChange:r}),t.jsx(Ct,{onDelete:a})]})}function cc({title:e,onClose:s}){return t.jsxs("div",{className:"flex items-center justify-between px-4 pt-4 pb-3",children:[t.jsx("h2",{className:"text-[13px] font-semibold tracking-[0.14em] text-foreground",children:e}),t.jsx("button",{type:"button",onClick:s,className:"h-6 w-6 rounded-md text-muted-foreground hover:bg-accent hover:text-muted-foreground","aria-label":`Close ${e}`,children:"Ã"})]})}function Cr({testId:e,label:s,payload:r,disabled:a,onPlace:n,children:o}){return t.jsxs("button",{type:"button","data-testid":e,draggable:!a&&!!r,disabled:a,onClick:()=>{r&&n(r)},onDragStart:i=>{r&&(i.dataTransfer.setData(ws,JSON.stringify(r)),i.dataTransfer.setData("text/plain",r.kind),i.dataTransfer.effectAllowed="copy")},className:k("flex aspect-square flex-col items-center justify-center gap-1 rounded-xl border border-border bg-card text-foreground shadow-sm",a?"cursor-default opacity-60":"hover:border-[hsl(var(--cover-user-accent))] hover:bg-[hsl(var(--cover-user-accent-subtle)/0.4)]"),children:[o,t.jsx("span",{className:"text-[11px] font-medium",children:s})]})}function uc({kind:e}){return e==="circle"?t.jsx("span",{className:"h-7 w-7 rounded-full border-2 border-border"}):e==="triangle"?t.jsx("span",{className:"h-7 w-8 bg-card",style:{clipPath:"pol
1ygon(50% 8%, 6% 92%, 94% 92%)"}}):e==="star"?t.jsx("span",{className:"h-7 w-7 bg-card",style:{clipPath:"polygon(50% 2%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%)"}}):t.jsx("span",{className:"h-6 w-6 rounded-sm border-2 border-border"})}function mc({kind:e}){return e==="dashed"?t.jsx("span",{className:"block h-px w-full border-t border-dashed border-border"}):e==="decorative"?t.jsx("span",{className:"block h-2.5 w-full rounded-sm",style:{background:"linear-gradient(90deg, #FDE047, #F97316)"}}):t.jsx("span",{className:"block h-px w-full bg-card"})}function pc({query:e,onQuery:s,onPlace:r,onClose:a}){const n=bl(e),o=n.draw&&ls.some(d=>re(d.label,e)),i=n.shapes&&ds.some(d=>re(d.label,e)),u=n.lines&&cs.some(d=>re(d.label,e));return t.jsxs("div",{className:"flex h-full flex-col","data-testid":"print-tools-pane",children:[t.jsx(cc,{title:"TOOLS",onClose:a}),t.jsx("div",{className:"px-4",children:t.jsxs("label",{className:"relative block",children:[t.jsx(ne,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-blue-500"}),t.jsx("input",{value:e,onChange:d=>s(d.target.value),placeholder:"Help me with a design tool...","data-testid":"print-tools-search",className:"h-9 w-full rounded-full border border-border bg-muted pl-9 pr-3 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-[hsl(var(--cover-user-accent))] focus:bg-card focus:outline-none"})]})}),t.jsxs("div",{className:"flex-1 space-y-5 overflow-y-auto px-4 py-4",children:[o&&t.jsxs("section",{"data-testid":"print-tools-draw",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"DRAW"}),t.jsx("div",{className:"grid grid-cols-3 gap-2",children:ls.filter(d=>re(d.label,e)).map(d=>t.jsx(Cr,{testId:`print-tool-${d.id}`,label:d.label,payload:d.id==="text"?{kind:"text"}:null,disabled:!d.working,onPlace:r,children:d.id==="text"?t.jsx("span",{className:"text-[22px] font-semibold leading-none",children:"T"}):d.id==="pen"?t.jsx(Tn,{className:"h-5 w-5"}):t.jsx(oi,{className:"h-5 w-5"})},d.id))})]}),i&&t.jsxs("section",{"data-testid":"print-tools-shapes",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"SHAPES"}),t.jsx("div",{className:"grid grid-cols-4 gap-2",children:ds.filter(d=>re(d.label,e)).map(d=>t.jsx(Cr,{testId:`print-tool-shape-${d.id}`,label:d.label,payload:{kind:"shape",shapeKind:d.id},onPlace:r,children:t.jsx(uc,{kind:d.id})},d.id))})]}),u&&t.jsxs("section",{"data-testid":"print-tools-lines",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"LINES"}),t.jsx("div",{className:"space-y-2",children:cs.filter(d=>re(d.label,e)).map(d=>t.jsx("button",{type:"button","data-testid":`print-tool-line-${d.id}`,draggable:!0,onClick:()=>r({kind:"line",lineKind:d.id}),onDragStart:c=>{const f={kind:"line",lineKind:d.id};c.dataTransfer.setData(ws,JSON.stringify(f)),c.dataTransfer.setData("text/plain","line"),c.dataTransfer.effectAllowed="copy"},className:"flex h-10 w-full items-center rounded-xl border border-border bg-card px-3 hover:border-[hsl(var(--cover-user-accent))] hover:bg-[hsl(var(--cover-user-accent-subtle)/0.4)]",children:t.jsx(mc,{kind:d.id})},d.id))})]}),!e&&t.jsxs(t.Fragment,{children:[t.jsx("section",{children:t.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-border px-3 py-2 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"font-semibold tracking-[0.14em]",children:"FONTS"}),t.jsx("span",{children:"â¾"})]})}),t.jsxs("section",{"data-testid":"print-tools-stickies",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"STICKIES"}),t.jsx("div",{className:"grid grid-cols-3 gap-2",children:al.map(d=>t.jsx("div",{className:"flex aspect-square items-center justify-center rounded-xl border border-border",style:{background:d},children:t.jsx(Zo,{className:"h-4 w-4 text-muted-foreground/70"})},d))})]}),t.jsx("section",{children:t.jsx("div",{className:"rounded-xl border border-border px-3 py-2 text-[12px] text-muted-foreground",children:"Signature Field"})})]})]})]})}function xc({enabled:e,onChange:s}){return t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border px-4 py-3","data-testid":"print-snap-to-objects",children:[t.jsx("label",{htmlFor:"print-snap-to-objects-switch",className:"text-[12px] font-medium text-foreground",children:"Snap to Objects"}),t.jsx(ei,{id:"print-snap-to-objects-switch",checked:e,onCheckedChange:s,"data-testid":"print-snap-toggle","aria-label":"Snap to Objects"})]})}const hc=[{action:"top",label:"Align Top",testId:"print-object-align-top"},{action:"middle",label:"Align Center (vertical)",testId:"print-object-align-middle"},{action:"bottom",label:"Align Bottom",testId:"print-object-align-bottom"},{action:"left",label:"Align Left",testId:"print-object-align-left"},{action:"center",label:"Align Center (horizontal)",testId:"print-object-align-center"},{action:"right",label:"Align Right",testId:"print-object-align-right"}];function fc(e,s){const r=s===1?8:11;return e==="left"?[7,7+r]:e==="right"?[17-r,17]:e==="center"?[12-r/2,12+r/2]:e==="top"?[7,7+r]:e==="bottom"?[17-r,17]:[12-r/2,12+r/2]}function bc({action:e}){const s=e==="left"||e==="center"||e==="right",r=e==="left"||e==="top"?4:e==="right"||e==="bottom"?20:12;return t.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4 w-4","aria-hidden":"true",children:[s?t.jsx("path",{d:`M${r} 3v18`,stroke:"currentColor",strokeWidth:"1.6"}):t.jsx("path",{d:`M3 ${r}h18`,stroke:"currentColor",strokeWidth:"1.6"}),[0,1,2].map(a=>{const[n,o]=fc(e,a),i=7+a*5,u=s?`M${n} ${i}H${o}`:`M${i} ${n}V${o}`;return t.jsx("path",{d:u,stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"},a)})]})}function gc({onAlign:e}){return t.jsxs("div",{className:"border-t border-border px-4 py-3","data-testid":"print-object-align",children:[t.jsx("div",{className:"mb-2 text-[10px] font-semibold tracking-[0.14em] text-muted-foreground",children:"ALIGN"}),t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:hc.map((s,r)=>t.jsxs("span",{className:"contents",children:[r===3&&t.jsx("span",{className:"mx-1 h-6 w-px bg-border","aria-hidden":"true"}),t.jsxs(En,{children:[t.jsx(Pn,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":s.label,title:s.label,"data-testid":s.testId,onClick:()=>e(s.action),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-border text-foreground hover:bg-accent",children:t.jsx(bc,{action:s.action})})}),t.jsx(An,{side:"top",children:s.label})]})]},s.action))})]})}const vc={event:Ce,proposal:ht,account:ps,contact:ms,lead:gs,"quick-order":Pr};function _r({type:e,className:s}){const r=vc[e]??Ce;return t.jsx(r,{className:s})}function yc(e){return e==="quick-order"?"bg-orange-100 text-orange-700":e==="account"?"bg-teal-100 text-teal-800":e==="contact"?"bg-[hsl(var(--cover-user-accent-soft))] text-[hsl(var(--cover-user-accent-text))]":e==="lead"?"bg-amber-100 text-amber-800":"bg-[hsl(var(--cover-user-accent-soft))] text-[hsl(var(--cover-user-accent-text))]"}const jc={email:xt,projects:Qr,templates:zn,"merge-fields":Kr,sections:Un,elements:ni,tools:Hn,uploads:xs,"brand-kit":ai,"cai-ai":ne,properties:Lr};function ot(e){const s=e.outputFormat||"print-pdf",r=e.recordType||"event";return{id:e.id,name:e.name,recordType:r,outputFormat:s,page:ko(s),elements:[],zoom:s==="email"?100:85,email:s==="email"?it(r):void 0}}const Vt=(e,s)=>`${e}~${s}`;function me(e){const s=e.match(/^(tpl_[a-f0-9]{28})~(\d{1,2})$/);return s?{templateId:s[1],page:Number(s[2])}:null}function Jt(e){const s=e instanceof Error?e.message:"Try again.",r=s.indexOf("{");
1if(r>=0)try{const n=JSON.parse(s.slice(r));if(typeof n.error=="string"&&n.error.trim())return n.error}catch{}return s.replace(/^\d+:\s*/,"").trim()||"Try again."}function Nc(){const e=typeof window>"u"?"":window.location.hash.split("?")[1]||window.location.search.slice(1),s=new URLSearchParams(e).get("template");return s&&/^tpl_[a-f0-9]{28}$/.test(s)?s:null}function Hc(){const[e,s]=y.useState(nr),[r,a]=y.useState("all"),[n,o]=y.useState(""),[i,u]=y.useState(""),[d,c]=y.useState(""),[f,b]=y.useState(""),[j,g]=y.useState(""),[S,$]=y.useState(""),[B,N]=y.useState(Ui),[A,Q]=y.useState(""),[P,W]=y.useState(Id),[O,R]=y.useState(""),[J,M]=y.useState(Ud),[E,T]=y.useState("All"),[C,D]=y.useState("projects"),[z,_]=y.useState(!0),[H,Z]=y.useState(!0),se=mo(nr),[G,X]=y.useState([ot(se)]),[le,ee]=y.useState(se.id),[ba,de]=y.useState([]),{user:_t}=Ir(),_s=In(),[Qe,Ts]=y.useState(!0),[Es,Tt]=y.useState(Wr),[ga,Ps]=y.useState("fields"),[va,Fe]=y.useState(!1),[Et,je]=y.useState(null),[ya,Pt]=y.useState(1),[qe,As]=y.useState(null),[At,It]=y.useState(""),[Is,Ft]=y.useState(Ut()),[ja,Fs]=y.useState(!1),[Na,Ye]=y.useState(!1),[Ms,wa]=y.useState(""),[Ds,ka]=y.useState(""),[Ls,Sa]=y.useState("in"),[Ca,Rs]=y.useState(!1),[_a,Ta]=y.useState(""),[Ea,Pa]=y.useState(!1),[Aa,Ia]=y.useState(!1),[Me,Os]=y.useState([[ot(se)]]),[pe,Mt]=y.useState(0);y.useEffect(()=>{Ts(Si({local:window.localStorage,session:window.sessionStorage},_t?.id))},[_t?.id]);const Fa=l=>{Ts(l),Ci({local:window.localStorage,session:window.sessionStorage},l,_t?.id)},{isLoading:Ma,selectedLocationId:ce,selectedTenantId:oe}=Fr(),Ve=!Ma&&!!ce&&!!oe,$s=tt({queryKey:["/api/cover/settings/revenue-types",ce,oe],enabled:Ve,queryFn:async({signal:l})=>(await ie("GET","/api/cover/settings/revenue-types",void 0,{signal:l})).json()}),Bs=tt({queryKey:dr("/api/cover/admin/menu-categories",ce,oe),enabled:Ve}),Hs=So(),Us=tt({queryKey:dr("/api/cover/admin/menu-items",ce,oe),enabled:Ve}),Ne=Fn(),Je=tt({queryKey:[te,"print",ce,oe],enabled:Ve,queryFn:async()=>{const l=await ie("GET",`${te}?kind=print`);return l.ok?l.json():[]}}),Dt=y.useMemo(()=>(Je.data||[]).flatMap(l=>Array.from({length:Math.max(1,l.pageCount)},(m,x)=>({id:Vt(l.id,x),kind:"design",name:l.pageCount>1?`${l.name} · Page ${x+1}`:l.name,recordType:l.recordType||"event",outputFormat:l.outputFormat==="email"?"email":"print-pdf",updatedLabel:po(l.origin),sharedBy:"Your team",shared:!0,color:zt(l.recordType||"event")}))),[Je.data]),Da=y.useMemo(()=>[...Dt,...e.filter(l=>!Dt.some(m=>m.id===l.id))],[Dt,e]),xe=y.useRef({}),[Lt,De]=y.useState("idle"),[La,Ra]=y.useState(0),[zs,Ws]=y.useState(!1),Gs=async(l,m)=>{const x=me(l);if(!x)return;if(G.some(L=>L.id===l)){ee(l),D("projects");return}const p=await Ne.fetchQuery({queryKey:[te,x.templateId,oe],queryFn:async()=>(await ie("GET",`${te}/${x.templateId}`)).json()}),h=p.pages?.[x.page];if(!h)return;const v=p.outputFormat==="email"?"email":"print-pdf",I={id:l,name:m||(p.pages.length>1?`${p.name} · Page ${x.page+1}`:p.name),recordType:p.recordType||"event",outputFormat:v,page:h.pageSize,elements:h.elements,zoom:v==="email"?100:85,email:v==="email"?p.email??it(p.recordType||"event"):void 0};xe.current[l]=Wt(I),X(L=>{const U=[...L.filter(ae=>ae.id!==l),I];return Xe(U),U}),ee(l),D(v==="email"?"email":"projects")},Ks=y.useRef(!1);y.useEffect(()=>{const l=Nc();!l||Ks.current||!Je.data||(Ks.current=!0,Gs(Vt(l,0)).catch(()=>{}))},[Je.data]),y.useEffect(()=>{const l=G.flatMap(x=>{const p=me(x.id),h=xe.current[x.id];if(!p||!h)return[];const v=xo(h,x);return v?[{design:x,parsed:p,plan:v}]:[]});if(!l.length)return;De("saving");const m=setTimeout(async()=>{try{for(const{design:x,parsed:p,plan:h}of l){if(h.elements&&!(await ie("PUT",`${te}/${p.templateId}/pages/${p.page}`,{elements:x.elements})).ok)throw new Error("save failed");if((h.name!==void 0||h.email)&&!(await ie("PUT",`${te}/${p.templateId}`,{...h.name!==void 0?{name:h.name}:{},...h.email?{email:h.email}:{}})).ok)throw new Error("save failed");if(xe.current[x.id]=Wt(x),h.name!==void 0){const v=h.name;s(I=>I.map(L=>me(L.id)?.templateId===p.templateId?{...L,name:v}:L)),Ne.setQueryData([te,"print",ce,oe],I=>I?.map(L=>L.id===p.templateId?{...L,name:v}:L))}}De("saved")}catch{De("error"),setTimeout(()=>Ra(x=>x+1),5e3)}},900);return()=>clearTimeout(m)},[G,Ne,ce,oe,La]);const Qs=G.some(l=>$e(l.id));y.useEffect(()=>{if(!Qs)return;const l=m=>{m.preventDefault(),m.returnValue=""};return window.addEventListener("beforeunload",l),()=>window.removeEventListener("beforeunload",l)},[Qs]);const Oa=y.useMemo(()=>{const l=Gt($s.data).map(h=>
1h.name).filter(Boolean),m=Gt(Bs.data).map(h=>h.name).filter(Boolean),x=ho(Hs.data,{id:"menu-prep-area",name:"Prep Area",group:"Menu Items"}),p=fo(Gt(Us.data).map(h=>h.vendor));return{type:l.length?l:[...Dn],category:m.length?m:Ln.map(h=>h.name),prepArea:x.length?x:[...Mn],vendor:p,hiddenStatus:["True","False"]}},[Bs.data,Us.data,Hs.data,$s.data]),w=G.find(l=>l.id===le)||G[0],we=ba.filter(l=>w.elements.some(m=>m.id===l)),Rt=we[we.length-1]??null,F=w?.elements.find(l=>l.id===Rt)||null,he=w.outputFormat==="email",qs=w.email??it(w.recordType),Y=he?{width:He-32,height:Hr}:rs(w.page),$a=bo(w.outputFormat),Xe=l=>{const x=[...Me.slice(0,pe+1),l].slice(-40);Os(x),Mt(x.length-1)},fe=(l,m=!0)=>{const x=G.map(p=>p.id===w.id?{...p,...l}:p);X(x),m&&Xe(x)},V=(l,m=!0)=>fe({elements:l},m),Ze=l=>{const m=Qe?Zr(l,w.elements):null,x=m?{...l,x:m.x,y:m.y}:l;return{...l,...Ue(x,Y)}},et=(l,m=!1)=>{const x=new Map(l.map(p=>[p.id,p]));V(w.elements.map(p=>{const h=x.get(p.id);return h?{...p,x:h.x,y:h.y}:p}),m)},Ba=l=>{const m=wi(w.elements,we,l);m.some((p,h)=>p.x!==w.elements[h]?.x||p.y!==w.elements[h]?.y)&&V([...m])},Ha=l=>{if(l.kind==="folder")return;if(me(l.id)){Gs(l.id,l.name).catch(()=>De("error"));return}const m=G.find(h=>h.id===l.id);if(m){ee(m.id),D(m.outputFormat==="email"?"email":C==="email"?"projects":C);return}const x=ot(l),p=[...G,x];X(p),ee(x.id),D(x.outputFormat==="email"?"email":"projects"),Xe(p)},Le=()=>{Pt(1),As(null),It(""),Ft(Ut())},Ua=()=>{const l=Ur({name:At,recordType:qe,outputFormat:Is});if(!l)return;const m=l.outputFormat,x=l.page,p=m==="email"?{width:He-32}:rs(x),h=nt(P),v=Dd(P,p),I=`design-${Date.now()}`,L={id:I,name:l.name,recordType:l.recordType,outputFormat:m,page:x,elements:v?[{id:`image-${I}`,kind:"image",x:v.x,y:v.y,width:v.width,height:v.height,imageSrc:v.imageSrc,imageName:v.imageName,style:{...ge,fontFamily:P.fonts.heading,color:h.color}}]:[],zoom:m==="email"?100:85,email:l.email};Tt(Bt=>({...Bt,fontFamily:h.fontFamily,color:h.color}));const U={id:I,kind:"design",name:L.name,recordType:l.recordType,outputFormat:m,updatedLabel:"Just now",
1shared:!1,color:zt(l.recordType)};s(Bt=>[U,...Bt]);const ae=[...G,L];X(ae),ee(I),Xe(ae),Fe(!1),Le(),D(m==="email"?"email":"projects")},za=(l,m)=>{const x=Se(l.id),p=h=>h===l.id||x!=null&&Se(h)===x;x&&Ne.setQueryData([te,"print",ce,oe],h=>h?.map(v=>v.id===x?{...v,name:m.name,recordType:m.recordType,outputFormat:m.outputFormat}:v)),s(h=>h.map(v=>p(v.id)?{...v,name:ma(v.name,m.name),recordType:m.recordType,outputFormat:m.outputFormat,color:zt(m.recordType)}:v)),X(h=>h.map(v=>{if(!p(v.id))return v;const I=sd(v,m),L=xe.current[v.id];return L&&(xe.current[v.id]={...L,name:I.name}),I}))},Wa=async(l,m)=>{try{const x=await nd((p,h,v)=>ie(p,h,v),l.id,m,l.outputFormat);if(x.status==="error"){be({title:"Print not updated",description:x.message,variant:"destructive"});return}za(l,x.body),je(null),be({title:"Print updated",description:lr(x.body.name,x.body.outputFormat)})}catch(x){be({title:"Print not updated",description:Jt(x),variant:"destructive"})}},Ga=async l=>{if(l.kind!=="design")return;const m=Se(l.id),x=p=>p===l.id||m!=null&&Se(p)===m;try{const p=await od(_s,(h,v)=>ie(h,v),l);if(p==="cancelled")return;if(p==="error"){be({title:"Print not deleted",description:"Try again.",variant:"destructive"});return}m&&Ne.setQueryData([te,"print",ce,oe],h=>h?.filter(v=>v.id!==m)),s(h=>h.filter(v=>!x(v.id))),je(h=>h&&x(h.id)?null:h),X(h=>{const v=h.filter(L=>x(L.id)?(delete xe.current[L.id],!1):!0);if(v.length)return ee(L=>v.some(U=>U.id===L)?L:v[0].id),v;const I=ot(se);return ee(I.id),[I]})}catch(p){be({title:"Print not deleted",description:Jt(p),variant:"destructive"})}},Ka=async l=>{const m=G.find(p=>p.id===le);if(!m||!$e(m.id)||zs)return;const x=m.id;Ws(!0);try{const p=await ie("POST",te,{name:l,recordType:m.recordType,outputFormat:m.outputFormat,page:m.page,elements:m.elements,...m.outputFormat==="email"?{email:m.email??it(m.recordType)}:{}}),h=await p.json().catch(()=>({}));if(!p.ok)throw new Error(typeof h.error=="string"?h.error:"Could not save this print.");const v=typeof h.id=="string"?h.id:"";if(!/^tpl_[a-f0-9]{28}$/.test(v))throw new Error("Could not save this print.");const I=Vt(v,0);xe.current[I]=Wt({...m,name:l});const L=U=>U.id===x?{...U,id:I,name:l}:U;X(U=>U.map(L)),Os(U=>U.map(ae=>ae.map(L))),ee(U=>U===x?I:U),s(U=>U.map(ae=>ae.id===x?{...ae,id:I,name:l,updatedLabel:"Saved",shared:!0,sharedBy:ae.sharedBy||"Your team"}:ae)),De("saved"),be({title:"Print saved",description:lr(l,m.outputFormat)}),Ne.invalidateQueries({queryKey:[te,"print"]})}catch(p){be({title:"Print not saved",description:Jt(p),variant:"destructive"})}finally{Ws(!1)}},Ys=(l,m,x)=>{const p=jo(w.recordType).find(U=>U.key===l);if(!p)return;const h=No(Y.width),v=Ze({x:Math.max(16,Math.min(m-h/2,Y.width-h-16)),y:Math.max(16,Math.min(x-16,Y.height-40)),width:h,height:36}),I={id:`field-${Date.now()}`,kind:"merge-field",...v,fieldKey:p.key,fieldLabel:p.label,fieldToken:p.token,style:{...Es}},L=[...w.elements,I];V(L),de([I.id]),D("properties"),_(!0)},Ot=(l,m,x)=>{const p=fl(l,Y,m!=null&&x!=null?{x:m,y:x}:void 0),h=Ze({x:p.x,y:p.y,width:p.width,height:p.height}),v={id:`${p.kind}-${Date.now()}`,kind:p.kind,x:h.x,y:h.y,width:h.width,height:h.height,text:p.text,shapeKind:p.shapeKind,shapeStyle:p.shapeStyle,lineStyle:p.lineStyle,style:{...ge,fontFamily:l.kind==="text"?P.fonts.heading:ge.fontFamily,color:nt(P).color}};V([...w.elements,v]),de([v.id]),D("properties"),_(!0)},Vs=l=>{const m=l.trim();if(!m)return;M(v=>Gd(v,m)),R("");const x=fa(m);if(!x)return;const p=Date.now(),h=Wd(x,Y).map((v,I)=>({id:`cai-${x}-${p}-${I}`,kind:v.kind,x:v.x,y:v.y,width:v.width,height:v.height,text:v.text,shapeKind:v.shapeKind,shapeStyle:v.shapeStyle,lineStyle:v.lineStyle,style:v.style??{...ge}}));h.length!==0&&(V([...w.elements,...h]),de([h[0].id]))},Js=(l="menu-items")=>{const m=Math.min(Y.width-48,Math.round(Y.width*.72)),x=nt(P),p={...l==="menu-items"?Rr():Zi(l),fontFamily:P.fonts.body,accentColor:P.colors.find(I=>I.toUpperCase()!=="#FFFFFF")||x.color},h=Ze({x:Math.round((Y.width-m)/2),y:Math.round(Y.height*.22),width:m,height:Qt(p,lt(p.layoutMode),0,p.fields.length)}),v={id:`section-${Date.now()}`,kind:l==="menu-items"?"menu-items":"section",...h,style:{...Es},section:p};V([...w.elements,v]),de([v.id]),D("properties"),Ps("layout")},Qa=()=>Js("menu-items"),Xs=(l,m,x)=>{const p=Vi(l,Y),h=m!=null&&x!=null?{x:m,y:x}:{x:Y.width/2,y:Y.height/2},v=Ze(dt(h,p,Y)),I={id:`image-${Date.now()}`,kind:"image",...v,imageSrc:l.src,imageName:l.name,style:{...ge}};V([...w.elements,I]),de([I.id]),D("properties"),_(!0)},qa=l=>{Array.from(l).forEach(m=>{if(!Wi(m))return;const x=new FileReader;x.onload=()=>{const p=typeof x.result=="string"?x.result:"",h={id:`upload-${Date.now()}-${m.name}`,name:m.name,src:p,mime:m.type,uploadedAt:Date.now()},v=L=>{N(U=>[L,...U])};if(m.type==="application/pdf"||m.name.toLowerCase().endsWith(".pdf")||!p){v
1(h);return}const I=new Image;I.onload=()=>v({...h,naturalWidth:I.naturalWidth,naturalHeight:I.naturalHeight}),I.onerror=()=>v(h),I.src=p},x.readAsDataURL(m)})},Ya=l=>{Tt(l),!(!F||F.kind!=="merge-field")&&V(w.elements.map(m=>m.id===F.id?{...m,style:l}:m),!1)},Re=l=>{V(w.elements.map(m=>m.id===l.id?l:m),!1)},Oe=()=>{F&&(V(w.elements.filter(l=>l.id!==F.id)),de(l=>l.filter(m=>m!==F.id)))},Va=l=>{if(!F||!Kt(F))return;const m=l.wrapTextAroundObject?is(F,w.elements.filter(p=>p.id!==F.id)):[],x=Qt(l,lt(l.layoutMode),xr(F,m,l.layoutMode),l.fields.length);V(w.elements.map(p=>p.id===F.id?{...p,section:l,height:x}:p),!1)},$t=l=>{F&&V(Li(w.elements,F.id,l))},Zs=(l,m,x=!1)=>{V(w.elements.map(p=>{if(p.id!==l)return p;if(!Kt(p)||!p.section)return{...p,...m};const h=p.section.wrapTextAroundObject?is({...p,...m},w.elements.filter(v=>v.id!==l)):[];return{...p,...m,height:Qt(p.section,lt(p.section.layoutMode),xr({...p,...m},h,p.section.layoutMode),p.section.fields.length)}}),x)},er=l=>{fe({page:l}),Fs(!1),Ye(!1)},Ja=()=>{const l=Number(Ms),m=Number(Ds);!l||!m||l<=0||m<=0||er(wo(l,m,Ls))},Xa=()=>{if(pe<=0)return;const l=pe-1;Mt(l),X(Me[l])},Za=()=>{if(pe>=Me.length-1)return;const l=pe+1;Mt(l),X(Me[l])},en=async l=>{const m=G.find(p=>p.id===l);if(!m||G.length<=1||$e(m.id)&&!await _s({title:"Discard unsaved design?",confirmLabel:"Yes, Discard",cancelLabel:"Cancel",destructive:!0}))return;const x=G.filter(p=>p.id!==l);x.length!==0&&(X(x),le===l&&ee(x[0].id))},tn=z&&C,sn=C==="properties"&&F?.kind==="merge-field",rn=C==="properties"&&!!F&&Kt(F),an=C==="properties"&&F?.kind==="text",nn=C==="properties"&&F?.kind==="shape",on=C==="properties"&&F?.kind==="line",ln=C==="properties"&&F?.kind==="image",tr=(l,m)=>{if(!l){de([]);return}de(p=>m?.additive?p.includes(l)?p.filter(h=>h!==l):[...p,l]:[l]),w.elements.find(p=>p.id===l)&&(D("properties"),_(!0))};return t.jsxs(Rn,{children:[t.jsxs("div",{className:"-mb-16 flex h-[calc(100dvh-76px)] min-h-[640px] min-w-0 max-w-full flex-col overflow-x-hidden bg-[hsl(var(--cover-canvas))] text-[hsl(var(--cover-text))]","data-testid":"print-designer",children:[t.jsxs("div",{className:"flex min-h-12 w-full max-w-full shrink-0 flex-wrap items-center gap-x-3 gap-y-2 border-b border-border bg-card px-4 py-1.5","data-testid":"print-designer-header",children:[t.jsxs("div",{className:"flex min-w-0 max-w-[20rem] items-center gap-3 max-xl:order-1 max-xl:grow xl:max-w-none xl:flex-none",children:[he?t.jsx(xt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):t.jsx(es,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),t.jsx("input",{value:or(w.name,w.recordType,w.outputFormat,!!me(w.id)),onChange:l=>fe({name:l.target.value},!1),readOnly:he,className:"min-w-0 w-full border-0 bg-transparent text-[13px] font-medium text-foreground focus:outline-none xl:w-auto xl:min-w-[18rem]","data-testid":"print-design-title"})]}),he?t.jsxs("button",{type:"button","data-testid":"print-page-size",className:"inline-flex h-8 shrink-0 items-center gap-1 rounded-lg border border-border px-2.5 text-[12px] text-foreground max-xl:order-3",children:[ir(w.page,w.outputFormat),t.jsx("span",{className:"text-muted-foreground",children:"â¾"})]}):t.jsxs(On,{open:ja,onOpenChange:l=>{Fs(l),l||Ye(!1)},children:[t.jsx($n,{asChild:!0,children:t.jsxs("button",{type:"button","data-testid":"print-page-size",className:"inline-flex h-8 shrink-0 items-center gap-1 rounded-lg border border-border px-2.5 text-[12px] text-foreground max-xl:order-3",children:[ir(w.page,w.outputFormat),t.jsx("span",{className:"text-muted-foreground",children:"â¾"})]})}),t.jsx(Bn,{align:"start",className:"w-auto border-0 p-0 shadow-none",children:Na?t.jsx(Xl,{width:Ms,height:Ds,unit:Ls,onWidth:wa,onHeight:ka,onUnit:Sa,onBack:()=>Ye(!1),onApply:Ja}):t.jsx(Jl,{current:w.page,onSelect:er,onCustom:()=>Ye(!0)})})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1 text-[12px] text-muted-foreground max-xl:order-3",children:[t.jsx("button",{type:"button",onClick:()=>fe({zoom:Math.max(40,w.zoom-5)},!1),className:"h-7 w-7 rounded-md hover:bg-accent","aria-label":"Zoom out",children:t.jsx(ti,{className:"mx-auto h-3.5 w-3.5"})}),t.jsxs("span",{className:"w-10 text-center",children:[w.zoom,"%"]}),t.jsx("button",{type:"button",onClick:()=>fe({zoom:Math.min(160,w.zoom+5)},!1),className:"h-7 w-7 rounded-md hover:bg-accent","aria-label":"Zoom in",children:t.jsx(_e,{className:"mx-auto h-3.5 w-3.5"})})]}),t.jsx("div",{className:"mx-auto flex shrink-0 items-center gap-2 max-xl:order-4",children:he?t.jsxs("div",{className:"inline-flex items-center rounded-full border border-border bg-muted p-0.5 text-[11px] font-medium","data-testid":"email-view-toggle",children:[t.jsx("span",{className:"rounded-full bg-card px-3 py-1 text-foreground shadow-sm",children:"Email"}),t.jsx("span",{className:"px-3 py-1 text-muted-foreground",children:"Email Template"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:k("inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium",yc(w.recordType)),children:[t.jsx(_r,{type:w.recordType,className:"h-3 w-3"}),fs(w.recordType)]}),t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-accent px-2.5 py-1 text-[11px] font-medium text-muted-foreground",children:[t.jsx(es,{className:"h-3 w-3"}),zr(w.outputFormat)]})]})}),t.jsx("button",{type:"button",onClick:Xa,disabled:pe<=0,className:"h-8 w-8 shrink-0 rounded-md text-muted-foreground hover:bg-accent disabled:opacity-30 max-xl:order-5","aria-label":"Undo",children:t.jsx(si,{className:"mx-auto h-4 w-4"})}),t.jsx("button",{type:"button",onClick:Za,disabled:pe>=Me.length-1,className:"h-8 w-8 shrink-0 rounded-md text-muted-foreground hover:bg-accent disabled:opacity-30 max-xl:order-5","aria-label":"Redo",children:t.jsx(ri,{className:"mx-auto h-4 w-4"})}),$e(w.id)&&t.jsx("div",{className:"shrink-0 max-xl:order-2","data-testid":"print-designer-save-cluster",children:t.jsx(Sd,{saving:zs,name:w.name,onSave:l=>{Ka(l)}})}),t.jsxs("button",{type:"button","data-testid":"print-preview",className:"inline-flex h-8 shrink-0 items-center gap-1 rounded-lg border border-border px-3 text-[12px] text-muted-foreground max-xl:order-6",children:[t.jsx(Ar,{className:"h-3.5 w-3.5"}),"Preview"]}),me(w.id)&&t.jsx("span",{className:k("inline-flex shrink-0 items-center gap-1 text-[12px] font-medium max-xl:order-2",Lt==="error"?"text-destructive":"text-emerald-600"),"data-testid":"template-saved",role:"status",children:Lt==="saving"?"Savingâ¦":Lt==="error"?"Not saved yet · retrying":t.jsxs(t.Fragment,{children:[t.jsx(Xt,{className:"h-3.5 w-3.5"}),"Saved for your team"]})}),he&&!$e(w.id)&&!me(w.id)&&t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-[12px] font-medium text-emerald-600 max-xl:order-2","data-testid":"email-saved",children:[t.jsx(Xt,{className:"h-3.5 w-3.5"}),"Saved"]}),t.jsx("div",{className:"shrink-0 max-xl:order-6","data-testid":"print-designer-secondary-actions",children:t.jsx(pd,{onPreview:()=>Rs(!0)})})]}),t.jsxs("div",{className:"flex h-10 min-w-0 shrink-0 items-center gap-1 overflow-x-auto border-b border-border bg-card px-3","data-testid":"print-designer-tabs",children:[G.map(l=>t.jsxs("button",{type:"button",onClick:()=>{ee(l.id),de([]),D(l.outputFormat==="email"?"email":C==="email"?"projects":C)},"data-testid":`print-tab-${l.id}`,className:k("inline-flex h-8 items-center gap-2 rounded-t-md border-b-2 px-3 text-[12px]",l.id===w.id?"border-[hsl(var(--cover-user-accent))] bg-[hsl(var(--cover-user-accent-subtle)/0.7)] text-foreground":"border-transparent text-muted-foreground hover:bg-muted"),children:[t.jsx(_r,{type:l.recordType,className:k("h-3.5 w-3.5",l.recordType==="quick-order"?"text-orange-500":"text-muted-foreground")}),t.jsx("span",{className:"max-w-[12rem] truncate",children:or(l.name,l.recordType,l.outputFormat,!!me(l.id))}),G.length>1&&t.jsx("span",{role:"button","data-testid":`print-tab-close-${l.id}`,onClick:m=>{m.stopPropagation(),en(l.id)},className:"text-muted-foreground hover:text-foreground",children:"Ã"})]},l.id)),t.jsxs("button",{type:"button",onClick:()=>{je(null),Le(),Fe(!0)},"data-testid":"print-new-tab",className:"ml-1 inline-flex h-8 items-center gap-1 rounded-md px-2 text-[12px] text-[hsl(var(--cover-user-accent-text))] hover:bg-[hsl(var(--cover-user-accent-subtle))]",children:[t.jsx(_e,{className:"h-3.5 w-3.5"})," New"]})]}),t.jsxs("div",{className:"flex min-h-0 flex-1",children:[t.jsxs("aside",{className:"flex shrink-0 flex-col border-r border-border bg-card","data-testid":"print-rail","data-expanded":H?"true":"false",style:{width:H?go:vo},children:[t.jsx("div",{className:"flex-1 space-y-1 overflow-y-auto py-2",children:$a.map(l=>{const m=jc[l.id],x=C===l.id;return t.jsxs("button",{type:"button",onClick:()=>{D(l.id),_(!0)},"data-testid":`print-rail-${l.id}`,className:k("mx-2 rounded-lg",H?"flex w-[calc(100%-16px)] items-center gap-2 px-2.5 py-2 text-left text-[12px]":"flex w-[56px] flex-col items-center gap-1 py-2 text-[10px]",x?"bg-[hsl(var(--cover-user-accent-subtle))] text-[hsl(var(--cover-user-accent-text))]":"text-muted-foreground hover:bg-muted"),children:[t.jsx(m,{className:"h-4 w-4 shrink-0"}),H?l.label:t.jsx("span",{className:"sr-only",children:l.label})]},l.id)})}),t.jsxs("button",{type:"button",onClick:()=>{D("properties"),_(!0)},"data-testid":"print-rail-properties",className:k("mx-2 mb-1 rounded-lg",H?"flex items-center gap-2 px-2.5 py-2 text-left text-[12px]":"flex flex-col items-center gap-1 py-2 text-[10px]",C==="properties"?"bg-[hsl(var(--cover-user-accent-subtle))] text-[hsl(var(--cover-user-accent-text))]":"text-muted-foreground hover:bg-muted"),children:[t.jsx(Lr,{className:"h-4 w-4 shrink-0"}),H?"Properties":t.jsx("span",{className:"sr-only",children:"Properties"})]}),t.jsx("button",{type:"button",onClick:()=>Z(l=>!l),"data-testid":"print-rail-toggle",className:"m-2 flex h-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted","aria-label":H?"Collapse sidebar":"Expand sidebar",children:t.jsx("span",{className:"text-[13px] tracking-tight",children:H?"<<":">>"})})]}),tn&&t.jsxs("aside",{className:"flex h-full min-h-0 w-[320px] shrink-0 flex-col border-r border-border bg-card",children:[C==="properties"&&t.jsx(xc,{enabled:Qe,onChange:Fa}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[C==="email"&&t.jsx(Ql,{settings:qs,helperQuery:_a,onHelperQuery:Ta,onChange:l=>fe({email:l}),onClose:()=>_(!1)}),C==="projects"&&t.jsx(bd,{projects:Da,tab:r,query:n,selectedId:w.id,onTab:a,onQuery:o,onSelect:Ha,onNew:()=>{je(null),Le(),Fe(!0)},onEdit:l=>{Fe(!1),Le(),je(l)},onDelete:l=>{Ga(l)},onClose:()=>_(!1)}),C==="templates"&&t.jsx(gd,{query:i,onQuery:u,onClose:()=>_(!1)}),C==="merge-fields"&&t.jsx(vd,{query:d,onQuery:c,onClose:()=>_(!1),recordType:w.recordType}),C==="sections"&&t.jsx(jd,{query:f,category:E,onQuery:b,onCategory:T,onAddMenuItems:Qa,onAddSection:Js,onClose:()=>_(!1)}),C==="uploads"&&t.jsx(kd,{uploads:B,query:S,onQuery:$,onPlace:l=>Xs(l),onUploadFiles:qa,onClose:()=>_(!1)}),C==="tools"&&t.jsx(pc,{query:j,onQuery:g,onPlace:l=>Ot(l),onClose:()=>_(!1)}),sn&&F&&t.jsx(Zd,{style:F.style,onChange:Ya,onClose:()=>_(!1)}),rn&&F?.section&&t.jsx(ec,{section:F.section,element:F,lists:Oa,tab:ga,onTab:Ps,onChange:Va,onElementChange:Re,onLayer:$t,onDelete:Oe,onClose:()=>_(!1)}),an&&F&&t.jsx(oc,{element:F,onChange:Re,onDelete:Oe,onClose:()=>_(!1)}),nn&&F&&t.jsx(ic,{element:F,onChange:Re,onDelete:Oe,onLayer:$t,onClose:()=>_(!1)}),ln&&F&&t.jsx(lc,{element:F,onChange:Re,onDelete:Oe,onLayer:$t,onClose:()=>_(!1)}),on&&F&&t.jsx(dc,{element:F,pageWidth:Y.width,onChange:Re,onDelete:Oe,onClose:()=>_(!1)}),C==="properties"&&!F&&t.jsx("div",{className:"p-4 text-[12px] text-muted-foreground",children:"Select a field, section, or tool on the page to edit its properties."}),C==="brand-kit"&&t.jsx(Rd,{kit:P,query:A,onQuery:Q,onChange:l=>{W(l);const m=nt(l);Tt(x=>({...x,fontFamily:m.fontFamily,color:m.color}))},onClose:()=>_(!1)}),C==="cai-ai"&&t.jsx(Qd,{messages:J,draft:O,onDraft:R,onSubmit:Vs,onPrompt:Vs,onClose:()=>_(!1)}),C==="elements"&&t.jsx(Nd,{rail:C,onClose:()=>_(!1)})]}),C==="properties"&&we.length>=2&&t.jsx(gc,{onAlign:Ba})]}),t.jsx("div",{className:"flex min-w-0 flex-1 flex-col",children:he?t.jsx(ql,{recordType:w.recordType,settings:qs,page:w.page,zoom:w.zoom,elements:w.elements,selectedId:Rt,selectedIds:we,snapEnabled:Qe,showCc:Ea,showBcc:Aa,onShowCc:()=>{Pa(!0),D("email"),_(!0)},onShowBcc:()=>{Ia(!0),D("email"),_(!0)},onChange:l=>fe({email:l}),onOpenMergeFields:()=>{D("merge-fields"),_(!0)},onSelect:tr,onMove:(l,m,x,p)=>et([{id:l,x:m,y:x}],p),onMoveMany:et,onResize:Zs,onDropField:Ys,onDropTool:(l,m,x)=>Ot(l,m,x),onChangeText:(l,m)=>V(w.elements.map(x=>x.id===l?{...x,text:m}:x),!1)}):t.jsxs(t.Fragment,{children:[t.jsx(Ss,{page:w.page,pagePx:Y,zoom:w.zoom,elements:w.elements,selectedId:Rt,selectedIds:we,snapEnabled:Qe,onSelect:tr,onMove:(l,m,x,p)=>et([{id:l,x:m,y:x}],p),onMoveMany:et,onResize:Zs,onDropField:Ys,onDropTool:(l,m,x)=>Ot(l,m,x),onDropUpload:(l,m,x)=>Xs(l,m,x),onChangeText:(l,m)=>V(w.elements.map(x=>x.id===l?{...x,text:m}:x),!1)}),t.jsxs("div",{className:"flex items-center justify-center gap-2 border-t border-border bg-[hsl(var(--cover-canvas))] py-3",children:[t.jsx("span",{className:"rounded-full bg-[hsl(var(--cover-user-accent))] px-3 py-1 text-[12px] font-medium text-white",children:"Page 1"}),t.jsx("button",{type:"button",className:"rounded-full border border-border bg-card px-3 py-1 text-[12px] text-muted-foreground",children:"+ Add Page"})]})]})})]})]}),va&&t.jsx(ca,{step:ya,recordType:qe,name:At,output:Is,onRecordType:As,onName:It,onOutput:l=>{const m=yo(At,qe,l);Ft(m.outputFormat),It(m.name)}
1,onBack:()=>Pt(1),onNext:()=>{qe&&(Ft(Ut()),Pt(2))},onCancel:()=>{Fe(!1),Le()},onCreate:Ua}),Et&&t.jsx(id,{project:Et,onClose:()=>je(null),onSaved:l=>{Wa(Et,l)}}),Ca&&t.jsx(xd,{recordType:w.recordType,designName:w.name,page:w.page,elements:w.elements,onClose:()=>Rs(!1)})]})}export{Hc as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.