PageSourceSearch

https://betterness.ai/_next/static/chunks/59815-02f7b07580e9591a.js

js betterness.ai collected 2026-10-05 02:51:34 UTC 221,951 bytes, 1 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="31b5f198-1925-43b6-a56d-685d6c95279d",e._sentryDebugIdIdentifier="sentry-dbid-31b5f198-1925-43b6-a56d-685d6c95279d")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[59815],{61436:function(e,t,r){r.d(t,{$Z:function(){return v},Uo:function(){return j}});var n=r(57437),s=r(2265),i=r(30166),o=r(32489),a=r(99397),l=r(73247),d=r(62157),c=r(94457);let u=(0,i.default)(()=>r.e(57414).then(r.bind(r,57414)).then(e=>({default:e.Chrome})),{loadableGenerated:{webpack:()=>[null]},ssr:!1}),m=/^#[0-9A-Fa-f]{6}$/,p=new Set(["helvetica","helvetica neue","arial","georgia","times new roman","courier new","sf mono","sfmono-regular","system-ui","sans-serif","serif","monospace","inherit"]),f=new Set;function h(e){if("undefined"==typeof document)return;let t=e.trim(),r=t.toLowerCase();if(t.length<2||p.has(r)||f.has(r))return;f.add(r);let n="gf-".concat(r.replace(/[^a-z0-9]+/g,"-"));if(document.getElementById(n))return;let s=document.createElement("link");s.id=n,s.rel="stylesheet",s.href="https://fonts.googleapis.com/css2?family=".concat(encodeURIComponent(t),":wght@400;600;700&display=swap"),document.head.appendChild(s)}let x=["Inter","Helvetica Neue","Helvetica","Arial","Roboto","Open Sans","Lato","Montserrat","Poppins","Raleway","Work Sans","Nunito","Source Sans 3","Oswald","Playfair Display","Merriweather","Georgia","Times New Roman","Libre Baskerville","Lora","PT Serif","DM Sans","DM Serif Display","Space Grotesk","Sora","Manrope","Satoshi","General Sans","GT America","Neue Haas Grotesk","Avenir","Futura","Garamond","Bodoni","Didot","Courier New","SF Mono","SFMono-Regular","IBM Plex Sans","IBM Plex Mono","Rubik","Karla","Archivo","Bebas Neue","Cormorant Garamond"],b={light:{pill:"border-black/10 bg-white shadow-[0_2px_8px_rgba(16,16,17,0.06)]",swatchBorder:"border-black/10",hexText:"text-[#575757]",fontSpecimen:"text-[#101011]",fontName:"text-[#575757]",remove:"border border-black/10 bg-white text-[#8a8a8a] hover:text-[#101011]",addBtn:"border border-black/10 bg-white text-[#575757] hover:border-[#101011] hover:text-[#101011]",pop:"z-[1000] w-64 p-2 bg-white border-black/10 text-[#101011] shadow-[0_18px_50px_rgba(16,16,17,0.18)]",searchWrap:"border-black/10 bg-white",searchInput:"text-[#101011] placeholder:text-[#a3a3a3]",optHover:"hover:bg-[#f3f3f3]",optActive:"bg-[#f3f3f3]",optName:"text-[#101011]",muted:"text-[#8a8a8a]"},dark:{pill:"border-stroke-soft bg-elevation-0 shadow-sm",swatchBorder:"border-stroke-soft",hexText:"text-secondary",fontSpecimen:"text-primary",fontName:"text-secondary",remove:"border border-stroke-soft bg-elevation-0 text-tertiary hover:text-primary",addBtn:"border border-stroke-soft bg-elevation-minus2 text-secondary hover:border-stroke-hard hover:text-primary",pop:"z-[1000] w-64 p-2 bg-elevation-minus1 border-stroke-medium text-primary",searchWrap:"border-stroke-soft bg-elevation-0",searchInput:"text-primary placeholder:text-tertiary",optHover:"hover:bg-elevation-0",optActive:"bg-elevation-0",optName:"text-primary",muted:"text-tertiary"}},y="absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-full opacity-0 shadow-sm transition group-hover:opacity-100 focus:opacity-100";function g(e){let{value:t,onSelect:r,open:i,onOpenChange:o,trigger:a}=e,[l,c]=(0,s.useState)(t);return(0,s.useEffect)(()=>{c(t)},[t,i]),(0,n.jsx)(d.J,{open:i,onOpenChange:o,side:"bottom",align:"start",className:"z-[1000] border-0 bg-transparent p-0 shadow-none",trigger:a,content:(0,n.jsx)(u,{color:l,inputType:"hexa",showAlpha:!1,onChange:e=>{let t=e.hex.toUpperCase();c(t),m.test(t)&&r(t)}})})}function v(e){let{colors:t,onChange:r,tone:i,disabled:l,labels:d}=e,u=b[i],[m,p]=(0,s.useState)(null);return(0,n.jsxs)("div",{className:"mt-2.5 flex flex-wrap items-center gap-2",children:[t.map((e,s)=>(0,n.jsxs)("div",{className:"group relative",children:[(0,n.jsx)(g,{value:e,open:!l&&m===s,onOpenChange:e=>p(e?s:null),onSelect:e=>r(t.map((t,r)=>
1r===s?e:t)),trigger:(0,n.jsxs)("span",{className:(0,c.cn)("inline-flex items-center gap-2 rounded-full border py-1 pl-1 pr-3",u.pill,l?"cursor-not-allowed opacity-50":"cursor-pointer"),children:[(0,n.jsx)("span",{"aria-hidden":!0,className:(0,c.cn)("h-6 w-6 rounded-full border",u.swatchBorder),style:{backgroundColor:/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^rgba?\(/i.test(e)||/^hsla?\(/i.test(e)?e:"#000000"}}),(0,n.jsx)("span",{className:(0,c.cn)("font-mono text-xs",u.hexText),children:e})]})}),l?null:(0,n.jsx)("button",{type:"button","aria-label":d.removeColor,onClick:e=>{e.stopPropagation(),p(null),r(t.filter((e,t)=>t!==s))},className:(0,c.cn)(y,u.remove),children:(0,n.jsx)(o.Z,{className:"h-3 w-3"})})]},s)),l?null:(0,n.jsxs)("button",{type:"button",onClick:()=>{r([...t,"#000000"]),p(t.length)},className:(0,c.cn)("inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium transition",u.addBtn),children:[(0,n.jsx)(a.Z,{className:"h-3.5 w-3.5"}),d.addColor]})]})}function w(e){let{tone:t,labels:r,value:i,onSelect:o,trigger:a}=e,u=b[t],[m,p]=(0,s.useState)(!1),[f,y]=(0,s.useState)(""),g=f.trim(),v=(0,s.useMemo)(()=>x.filter(e=>!g||e.toLowerCase().includes(g.toLowerCase())),[g]),w=x.some(e=>e.toLowerCase()===g.toLowerCase()),j=e=>{o(e),p(!1),y("")};return(0,s.useEffect)(()=>{m&&v.forEach(h)},[m,v]),(0,n.jsx)(d.J,{open:m,onOpenChange:p,side:"bottom",align:"start",className:u.pop,trigger:a,content:(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:(0,c.cn)("mb-2 flex items-center gap-2 rounded-full border px-3 py-1.5",u.searchWrap),children:[(0,n.jsx)(l.Z,{className:(0,c.cn)("h-3.5 w-3.5 shrink-0",u.muted)}),(0,n.jsx)("input",{autoFocus:!0,value:f,onChange:e=>y(e.target.value),placeholder:r.fontSearchPlaceholder,className:(0,c.cn)("min-w-0 flex-1 bg-transparent text-xs outline-none",u.searchInput)})]}),(0,n.jsxs)("div",{className:"max-h-56 overflow-y-auto",children:[g&&!w?(0,n.jsx)("button",{type:"button",onClick:()=>j(g),className:(0,c.cn)("flex w-full items-center rounded-lg px-2.5 py-2 text-left text-xs",u.optHover,u.muted),children:r.useCustomFont(g)}):null,v.map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>j(e),className:(0,c.cn)("flex w-full items-center rounded-lg px-2.5 py-2 text-left",u.optHover,i===e&&u.optActive),children:(0,n.jsx)("span",{className:(0,c.cn)("truncate text-sm",u.optName),style:{fontFamily:"'".concat(e,"', sans-serif")},children:e})},e))]})]})})}function j(e){let{fonts:t,onChange:r,tone:i,disabled:l,labels:d,editInPlace:u=!0}=e,m=b[i];(0,s.useEffect)(()=>{t.forEach(h)},[t]);let p=e=>(0,n.jsxs)("span",{className:(0,c.cn)("inline-flex items-center gap-3 rounded-2xl border px-4 py-2.5",m.pill,l?"cursor-not-allowed opacity-50":u?"cursor-pointer":"cursor-default"),children:[(0,n.jsx)("span",{"aria-hidden":!0,className:(0,c.cn)("font-display text-lg font-semibold",m.fontSpecimen),style:{fontFamily:"'".concat(e,"', sans-serif")},children:"Aa"}),(0,n.jsx)("span",{className:(0,c.cn)("min-w-0 truncate text-sm",m.fontName),style:{fontFamily:"'".concat(e,"', sans-serif")},children:e})]});return(0,n.jsxs)("div",{className:"mt-2.5 flex flex-wrap items-center gap-2",children:[t.map((e,s)=>(0,n.jsxs)("div",{className:"group relative",children:[u&&!l?(0,n.jsx)(w,{tone:i,labels:d,value:e,onSelect:e=>r(t.map((t,r)=>r===s?e:t)),trigger:p(e)}):p(e),l?null:(0,n.jsx)("button",{type:"button","aria-label":d.removeFont,onClick:e=>{e.stopPropagation(),r(t.filter((e,t)=>t!==s))},className:(0,c.cn)(y,m.remove),children:(0,n.jsx)(o.Z,{className:"h-3 w-3"})})]},s)),l?null:(0,n.jsx)(w,{tone:i,labels:d,onSelect:e=>r([...t,e]),trigger:(0,n.jsxs)("span",{className:(0,c.cn)("inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium transition",m.addBtn),children:[(0,n.jsx)(a.Z,{className:"h-3.5 w-3.5"}),d.addFont]})})]})}},74679:function(e,t,r){r.d(t,{eX:function(){return ec}});var n=r(57437),s=r(9585),i=r(2265),o=r(38706),a=r(82023),l=r(30401),d=r(88156),c=r(82431),u=r(76865),m=r(91723),p=r(69076),f=r(51817),h=r(32489),x=r(40875),b=r(45675),y=r(60417),g=r(78541),v=r(94457),w=r(12124),j=r(92581),k=r(57031);let N=[{key:"current_role_title",sectionId:"identity",kind:"text"},{key:"professional_role_type",sectionId:"role_responsibilities",kind:"list"},{key:"offers",sectionId:null,kind:"text"},{key:"brand_voice",sectionId:"communication_style",kind:"text"},{key:"positioning",sectionId:"communication_style",kind:"text"},{key:"shaping_roles_projects",sectionId:"domain_knowledge",kind:"text"},{key:"hidden_professional_journey",sectionId:"domain_knowledge",kind:"text"}],_=[{sectionId:"communication_style",field:"context_portfolio_communication_style_md",summaryField:"context_portfolio_communication_style_summary_html"},{sectionId:"current_priorities",field:"context_portfolio_current_priorities_md",summaryField:"context_portfolio_current_priorities_summary_html"},{sectionId:"goals_priorities",field:"context_portfolio_goals_priorities_md",summaryField:"context_portfolio_goals_priorities_summary_html"},{sectionId:"domain_knowledge",field:"context_portfolio_domain_knowledge_md",summaryField:"context_portfolio_domain_knowledge_summary_html"}];function C(e){let t=e.trim();return!!t&&!/[{][^}]+[}]/.test(t)&&/[?¿]$/.test(t)&&!/\b(?:i read|i just read|i looked at|your whole site)\b/i.test(t)}function T(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:null}let S=/^no grounded facts captured yet\b/i;function L(e){let t=e.trim();if(!t)return!1;let r=t.replace(/^(?:#{1,6}[^\n]*\n+)+/,"").replace(/^[⚑⚠✓✅\s]+/,"").trim();return r.length>0&&!S.test(r)}function I(e){return"string"==typeof e?L(e):!!Array.isArray(e)&&e.some(e=>"string"==typeof e&&L(e))}function A(e){let t=JSON.stringify(null!=e?e:null),r=2166136261,n=3735928559;for(let e=0;e<t.length;e++){let s=t.charCodeAt(e);r=Math.imul(r^s,16777619)>>>0,n=Math.imul(n,31)+s>>>0}return"".concat(r.toString(16).padStart(8,"0")).concat(n.toString(16).padStart(8,"0"))}function F(e){if("string"==typeof e)return e.trim().length>0;if(Array.isArray(e))return e.length>0;if(e&&"object"==typeof e){var t,r,n,s;return(null!==(n=null===(t=e.arrayString)||void 0===t?void 0:t.length)&&void 0!==n?n:0)>0||(null!==(s=null===(r=e.others)||void 0===r?void 0:r.length)&&void 0!==s?s:0)>0}return null!=e&&""!==e}function E(e){var t,r;let n=N.find(t=>t.key===e);return n?n.sectionId:null!==(r=null===(t=_.find(t=>t.field===e))||void 0===t?void 0:t.sectionId)&&void 0!==r?r:null}[...N.map(e=>e.key),..._.map(e=>e.field)];var M=r(36410),P=r(7555);async function R(e){try{return(await fetch("/api/betterness-one/business-profile",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({patchData:e})})).ok}catch(e){return!1}}async function D(e){try{return(await fetch("/api/betterness-one/business-profile",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:"section",sectionId:e.id,fieldNames:e.seedFacts.map(e=>e.field)})})).ok}catch(e){return!1}}
1let B=[{id:"identity",fileName:"identity.md",fieldName:"context_portfolio_identity_md",summaryFieldName:"context_portfolio_identity_summary_html",seedFacts:[{field:"current_role_title",fieldToken:"currentRoleTitle"},{field:"business_name",fieldToken:"businessName"},{field:"category",fieldToken:"category"},{field:"market",fieldToken:"market"},{field:"website_url",fieldToken:"websiteUrl"},{field:"social_profile_urls",fieldToken:"socialProfileUrls"}]},{id:"role_responsibilities",fileName:"role-and-responsibilities.md",fieldName:"context_portfolio_role_responsibilities_md",summaryFieldName:"context_portfolio_role_responsibilities_summary_html",seedFacts:[{field:"professional_role_type",fieldToken:"professionalRoleType"},{field:"business_ownership_status",fieldToken:"businessOwnershipStatus"},{field:"employee_count",fieldToken:"employeeCount"},{field:"enjoyed_work_types",fieldToken:"enjoyedWorkTypes"},{field:"draining_work_types",fieldToken:"drainingWorkTypes"}]},{id:"current_priorities",fileName:"current-projects.md",fieldName:"context_portfolio_current_priorities_md",summaryFieldName:"context_portfolio_current_priorities_summary_html",seedFacts:[{field:"primary_goal",fieldToken:"primaryGoal"},{field:"growth_priority_outcomes",fieldToken:"growthPriorityOutcomes"},{field:"growth_priority_why",fieldToken:"growthPriorityWhy"},{field:"six_to_twelve_month_success",fieldToken:"sixToTwelveMonthSuccess"},{field:"growth_obstacles",fieldToken:"growthObstacles"}]},{id:"team_relationships",fileName:"team-and-relationships.md",fieldName:"context_portfolio_team_relationships_md",summaryFieldName:"context_portfolio_team_relationships_summary_html",seedFacts:[{field:"professional_support",fieldToken:"professionalSupp
1ort"},{field:"voices_followed",fieldToken:"voicesFollowed"},{field:"support_wishes",fieldToken:"supportWishes"},{field:"most_valuable_help_right_now",fieldToken:"mostValuableHelpRightNow"}]},{id:"tools_systems",fileName:"tools-and-systems.md",fieldName:"context_portfolio_tools_systems_md",summaryFieldName:"context_portfolio_tools_systems_summary_html",seedFacts:[{field:"business_tools_used",fieldToken:"businessToolsUsed"},{field:"well_managed_systems",fieldToken:"wellManagedSystems"},{field:"messy_systems",fieldToken:"messySystems"},{field:"shareable_data_sources",fieldToken:"shareableDataSources"},{field:"open_to_business_data_sharing",fieldToken:"openToBusinessDataSharing"}]},{id:"communication_style",fileName:"communication-style.md",fieldName:"context_portfolio_communication_style_md",summaryFieldName:"context_portfolio_communication_style_summary_html",seedFacts:[{field:"brand_voice",fieldToken:"brandVoice"},{field:"positioning",fieldToken:"positioning"},{field:"proof_points",fieldToken:"proofPoints"},{field:"marketing_trust_challenge",fieldToken:"marketingTrustChallenge"},{field:"channels",fieldToken:"channels"}]},{id:"goals_priorities",fileName:"priorities-and-outcomes.md",fieldName:"context_portfolio_goals_priorities_md",summaryFieldName:"context_portfolio_goals_priorities_summary_html",seedFacts:[{field:"primary_goal",fieldToken:"primaryGoal"},{field:"coaching_help_areas",fieldToken:"coachingHelpAreas"},{field:"ai_help_targets",fieldToken:"aiHelpTargets"},{field:"professional_frustration",fieldToken:"professionalFrustration"}]},{id:"preferences_constraints",fileName:"preferences-and-constraints.md",fieldName:"context_portfolio_preferences_constraints_md",summaryFieldName:"context_portfolio_preferences_constraints_summary_html",seedFacts:[{field:"business_data_sharing_comfort",fieldToken:"businessDataSharingComfort"},{field:"ai_marketing_data_sharing_comfort",fieldToken:"aiMarketingDataSharingComfort"},{field:"open_to_improve_ai_workflows",fieldToken:"openToImproveAiWorkflows"},{field:"technical_workflow_comfort",fieldToken:"technicalWorkflowComfort"}]},{id:"domain_knowledge",fileName:"domain-knowledge.md",fieldName:"context_portfolio_domain_knowledge_md",summaryFieldName:"context_portfolio_domain_knowledge_summary_html",seedFacts:[{field:"shaping_roles_projects",fieldToken:"shapingRolesProjects"},{field:"hidden_professional_journey",fieldToken:"hiddenProfessionalJourney"},{field:"professional_health_scores",fieldToken:"professionalHealthScores"},{field:"ai_business_use_cases",fieldToken:"aiBusinessUseCases"}]},{id:"decision_log",fileName:"decision-log.md",fieldName:"context_portfolio_decision_log_md",summaryFieldName:"context_portfolio_decision_log_summary_html",seedFacts:[{field:"has_existing_ai_workflows",fieldToken:"hasExistingAiWorkflows"},{field:"existing_ai_workflows_usage",fieldToken:"existingAiWorkflowsUsage"},{field:"existing_ai_workflows_location",fieldToken:"existingAiWorkflowsLocation"},{field:"uses_ai_development_tools",fieldToken:"usesAiDevelopmentTools"},{field:"ai_development_tools",fieldToken:"aiDevelopmentTools"}]}],Z=["current_priorities","team_relationships","preferences_constraints","communication_style"],O={current_role_title:"currentRoleTitle",professional_role_type:"professionalRoleType",offers:"offers",brand_voice:"brandVoice",positioning:"positioning",shaping_roles_projects:"shapingRolesProjects",hidden_professional_journey:"hiddenProfessionalJourney"};function H(e){if(null==e)return"";if("string"==typeof e)return e.trim();if("number"==typeof e||"boolean"==typeof e)return String(e);if(Array.isArray(e))return e.map(e=>H(e)).filter(Boolean).join(", ");if("object"==typeof e){if(Array.isArray(e.arrayString)||Array.isArray(e.others)){var t,r;return[...null!==(t=e.arrayString)&&void 0!==t?t:[],...null!==(r=e.others)&&void 0!==r?r:[]].map(e=>H(e)).filter(Boolean).join(", ")}return Object.entries(e).map(e=>{let[t,r]=e,n=H(r);return n?"".concat(t,": ").concat(n):""}).filter(Boolean).join("; ")}return""}function U(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:null}function z(e){return Array.isArray(e)?e.filter(e=>!!U(e)):[]}function K(e){return"string"==typeof e?e.trim():""}function q(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];for(let e of t){let t=H(e);if(t)return t}return""}function W(e){return(0,j.V)(e)}function $(e){return(0,j.s)(e)}function V(e){return e.replace(/<\s*(strong|b)\s*>([\s\S]*?)<\/\s*\1\s*>/gi,"**$2**").replace(/<\s*(em|i)\s*>([\s\S]*?)<\/\s*\1\s*>/gi,"*$2*").replace(/<[^>]+>/g,"").replace(/&nbsp;/gi," ").replace(/&amp;/gi,"&").replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&#0*39;|&apos;/gi,"'").replace(/[ \t]+/g," ").trim()}function G(e){return"number"==typeof e&&Number.isFinite(e)?e:null}async function J(){let e=await fetch("/api/betterness-one/business-profile",{cache:"no-store"});if(!e.ok)return null;let t=await e.json();return(null==t?void 0:t.values)?t.values:null}function X(e){let t=K(e);if(!t)return null;let r=new Date(t);return Number.isNaN(r.getTime())?null:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}).format(r)}function Y(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Q(e){return e.replace(/<\s*(script|style|iframe|object|embed|link|meta|base|form|svg)\b[\s\S]*?(<\/\s*\1\s*>
1|$)/gi,"").replace(/[\s/]on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/(?:javascript|vbscript)\s*:/gi,"").replace(/data\s*:\s*(?:text\/html|image\/svg|text\/javascript|application\/javascript)/gi,"")}function ee(e){return/[⚑⚠]/.test(e)||/\((?:needs[ -]confirmation|unconfirmed)\)/i.test(e)||/(?:^|\n)\s*(?:[-*]\s+)?(?:needs[ -](?:confirmation|you)|unconfirmed)\s*:/im.test(e)||/<(?:p|li|h[1-6])\b[^>]*>\s*(?:needs[ -](?:confirmation|you)|unconfirmed)\s*:/i.test(e)?"needs_you":/[✓✅]/.test(e)||/\((?:source[ -]backed|confirmed)\)/i.test(e)||/#confirmed\b/i.test(e)||/(?:^|\n)\s*(?:[-*]\s+)?(?:source[ -]backed|confirmed)\s*:/im.test(e)||/<(?:p|li|h[1-6])\b[^>]*>\s*(?:source[ -]backed|confirmed)\s*:/i.test(e)?"confirmed":null}function et(e){return e.replace(/[✓✅⚑⚠]/g,"").replace(/\((?:source[ -]backed|needs[ -]confirmation|confirmed|unconfirmed)\)/gi,"").replace(/#confirmed\b/gi,"").replace(/(^|\n)(\s*(?:[-*]\s+)?)(?:source[ -]backed|needs[ -](?:confirmation|you)|unconfirmed|confirmed)\s*:\s*/gim,"$1$2").replace(/(<(?:p|li|h[1-6])\b[^>]*>\s*)(?:source[ -]backed|needs[ -](?:confirmation|you)|unconfirmed|confirmed)\s*:\s*/gi,"$1").replace(/[ \t]+(?=<)/g,"").replace(/[ \t]{2,}/g," ").trim()}function er(e){return Y(e).replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>")}function en(e){return e.replace(/^[-*#\s]+/,"").replace(/\*\*/g,"").replace(/\s+/g," ").trim().toLowerCase()}let es=new Set(["about","also","because","business","context","from","have","that","their","there","these","this","what","when","with","your"]);function ei(e){return e.replace(/[*#`]/g," ").replace(/[^a-z0-9]+/g," ").replace(/\s+/g," ").trim().toLowerCase()}function eo(e,t){let r=e.split(/\r?\n/),n=[],s=!1,i=(e,r)=>{let n=en(e);return n&&(null==t?void 0:t.has(n))?"<mark>".concat(r,"</mark>"):r},o=()=>{s&&(n.push("</ul>"),s=!1)};for(let e of r){let t=e.trim();if(!t){o();continue}let r=t.match(/^(#{1,4})\s+(.+)$/);if(r){o();let e=Math.min(r[1].length+1,4);n.push("<h".concat(e,">").concat(i(t,er(r[2])),"</h").concat(e,">"));continue}let a=t.match(/^[-*]\s+(.+)$/);if(a){s||(n.push("<ul>"),s=!0),n.push("<li>".concat(i(t,er(a[1])),"</li>"));continue}o(),n.push("<p>".concat(i(t,er(t)),"</p>"))}return o(),n.join("")}function ea(e,t){var r,n,s;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=null!==(r=i.maxLines)&&void 0!==r?r:6,a=new Set(e.split(/\r?\n/).map(en).filter(Boolean)),l=t.split(/\r?\n/).map((e,t)=>({raw:e,index:t,normalized:en(e)})).filter(e=>{let{raw:t,normalized:r}=e;return r&&!a.has(r)&&function(e){let t=e.trim();return!(!t||/^#{1,6}\s+/.test(t)||/^(Grounded facts|Inferences and hypotheses|Decisions and rationale|Preferences, constraints, and boundaries|Open questions|Provenance)$/i.test(t)||/^[-*]\s*(Source|Confidence|Notes|Source documents|Source document IDs):/i.test(t))&&ei(t).length>=10}(t)}),d=new Set(ei(null!==(n=i.focusText)&&void 0!==n?n:"").split(" ").filter(e=>e.length>=4&&!es.has(e))),c=d.size>0?l.map(e=>{let t=new Set(ei(e.raw).split(" ").filter(Boolean)),r=Array.from(d).reduce((e,r)=>e+(t.has(r)?1:0),0);return{...e,score:r}}).filter(e=>e.score>0).sort((e,t)=>t.score-e.score||e.index-t.index).slice(0,o).sort((e,t)=>e.index-t.index):[],u=null!==(s=i.fallbackToChangedLines)&&void 0!==s?s:0===d.size;return eo(t,new Set((c.length?c:u?l.slice(0,o):[]).map(e=>{let{normalized:t}=e;return t})))}function el(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}function ed(e,t){var r,n;let s=function(e){let t=e.parentElement;for(;t;){let{overflowY:e}=getComputedStyle(t);if(("auto"===e||"scroll"===e)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}(e);if(!s)return;let i=e.getBoundingClientRect(),o=s.getBoundingClientRect(),a=s.scrollTop+i.top-o.top,l="center"===t?a-Math.max(0,(s.clientHeight-i.height)/2):a-16;s.scrollTo({top:Math.max(0,l),behavior:(null===(r=(n=window).matchMedia)||void 0===r?void 0:r.call(n,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth"})}function ec(){var e,t,r,S,L,er,en,es,ei,ec,eu,em,ep,ef;let{files:eh=B,liveInterviewIds:ex=Z,filesNamespace:eb="b1Profile",importsNamespace:ey="b1Profile",showLiveInterview:eg=!0,hideInterviewDisclaimer:ev=!1,showObjectivesNav:ew=!0,chrome:ej,loadValues:ek=J,saveValues:eN=R,onResetSection:e_=D,interviewEndpoint:eC="/api/betterness-one/business-profile/interview",importMode:eT="business",render
1SectionBody:eS,footerSlot:eL,refreshToken:eI=0,registerFlush:eA}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},eF=(0,o.T)("b1Profile"),eE=(0,o.T)("b1Objectives"),eM=(0,o.T)(eb),eP=(0,o.T)(ey),eR=(0,o.T)("b1Profile.fields"),[eD,eB]=(0,i.useState)({}),[eZ,eO]=(0,i.useState)(!0),[eH,eU]=(0,i.useState)("idle"),[ez,eK]=(0,i.useState)(!1),[eq,eW]=(0,i.useState)(!1),[e$,eV]=(0,i.useState)(!1),[eG,eJ]=(0,i.useState)(null),[eX,eY]=(0,i.useState)(null),[eQ,e0]=(0,i.useState)(null),[e1,e2]=(0,i.useState)(null),[e3,e5]=(0,i.useState)(new Set),[e4,e6]=(0,i.useState)(new Set),[e7,e8]=(0,i.useState)({}),[e9,te]=(0,i.useState)({}),[tt,tr]=(0,i.useState)(""),[tn,ts]=(0,i.useState)(""),[ti,to]=(0,i.useState)(!1),[ta,tl]=(0,i.useState)(0),[td,tc]=(0,i.useState)("confirming"),[tu,tm]=(0,i.useState)(""),[tp,tf]=(0,i.useState)(""),[th,tx]=(0,i.useState)(!1),[tb,ty]=(0,i.useState)(0),[tg,tv]=(0,i.useState)(null),[tw,tj]=(0,i.useState)(null),[tk,tN]=(0,i.useState)(""),[t_,tC]=(0,i.useState)(null),[tT,tS]=(0,i.useState)(new Set),[tL,tI]=(0,i.useState)("idle"),[tA,tF]=(0,i.useState)(null),tE=(0,i.useRef)(null),tM=(0,i.useRef)(null),tP=(0,i.useRef)(new Map),tR=(0,i.useRef)(new Map),tD=(0,i.useRef)(new Map),tB=(0,i.useRef)(null),tZ=(0,i.useRef)([]),tO=(0,i.useRef)({}),tH=(0,i.useRef)(null),tU=(0,i.useRef)(null),tz=(0,i.useRef)(new Map),tK=(0,i.useRef)(new Map),tq=(0,i.useCallback)(async()=>{let e=await ek();if(e){let t=tO.current,r=z(t[k.N_]),n=new Set(r.map(e=>K(e.sectionId))),s={...e,...t,[k.N_]:[...r,...z(e[k.N_]).filter(e=>!n.has(K(e.sectionId)))].slice(0,120)};eB(s),tH.current&&(tH.current=s)}return e},[ek]);(0,i.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await ek();!e&&t&&eB(t)}catch(e){}finally{e||eO(!1)}})(),()=>{e=!0,tE.current&&clearTimeout(tE.current),tP.current.forEach(e=>clearTimeout(e)),tP.current.clear(),tR.current.forEach(e=>clearTimeout(e)),tR.current.clear(),tD.current.forEach(e=>clearTimeout(e)),tD.current.clear()}},[ek]);let tW=(0,i.useRef)(eI);(0,i.useEffect)(()=>{tW.current!==eI&&(tW.current=eI,tq().catch(()=>{}))},[tq,eI]);let t$=(0,i.useCallback)((e,t,r)=>{te(r=>({...r,[e]:t}));let n=tD.current.get(e);if(n&&clearTimeout(n),!r)return;let s=setTimeout(()=>{te(t=>{let r={...t};return delete r[e],r}),tD.current.delete(e)},r);tD.current.set(e,s)},[]),tV=(0,i.useCallback)(e=>{e6(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),tG=(0,i.useCallback)(e=>{e6(t=>{if(!t.has(e))return t;let r=new Set(t);return r.delete(e),r})},[]),tJ=(0,i.useCallback)(function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4e4;tG(e),e8(r=>({...r,[e]:t}));let n=tR.current.get(e);n&&clearTimeout(n);let s=setTimeout(()=>{e8(t=>{let r={...t};return delete r[e],r}),tR.current.delete(e)},r);tR.current.set(e,s)},[tG]),tX=(0,i.useCallback)(e=>{let t=Array.from(new Set(e.filter(Boolean)));if(t.length)for(let e of(t.forEach(e=>tG(e)),e5(e=>{let r=new Set(e);return t.forEach(e=>r.add(e)),r}),t)){let t=tP.current.get(e);t&&clearTimeout(t);let r=setTimeout(()=>{e5(t=>{let r=new Set(t);return r.delete(e),r}),tP.current.delete(e)},1800);tP.current.set(e,r)}},[tG]),tY=(0,i.useCallback)(e=>t=>{t?tz.current.set(e,t):tz.current.delete(e)},[]),tQ=(0,i.useCallback)(e=>t=>{t?tK.current.set(e,t):tK.current.delete(e)},[]),t0=(0,i.useCallback)(e=>{let t=tz.current.get(e);t&&(ed(t,"start"),eY(e))},[]);(0,i.useEffect)(()=>{if(eZ)return;let e=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&eY(t.target.id)},{rootMargin:"-20% 0px -70% 0px",threshold:0});return tz.current.forEach(t=>e.observe(t)),()=>e.disconnect()},[eZ]);let t1=(0,i.useMemo)(()=>new Set(eh.flatMap(e=>{var t;return null!==(t=e.selfPersistedFields)&&void 0!==t?t:[]})),[eh]),t2=(0,i.useCallback)(async e=>{let t=(async()=>{try{let t=await eN(function(e,t){if(0===t.size)return e;let r={};for(let[n,s]of Object.entries(e))t.has(n)||(r[n]=s);return r}(e,t1));return eU(t?"saved":"error"),t&&(tO.current={},tH.current===e&&(tH.current=null)),t}catch(e){return eU("error"),!1}})();tU.current=t;try{return await t}finally{tU.current===t&&(tU.current=null)}},[eN,t1]),t3=(0,i.useCallback)(e=>{tE.current&&clearTimeout(tE.current),eU("saving"),tH.current=e,tE.current=setTimeout(()=>{var t;tE.current=null,t2(null!==(t=tH.current)&&void 0!==t?t:e)},600)},[t2]),t5=(0,i.useCallback)(async()=>{tU.current&&await tU.current.catch(()=>!1),tE.current&&(clearTimeout(tE.current),tE.current=null);let e=tH.current;e&&(tH.current=null,await t2(e))},[t2]);(0,i.useEffect)(()=>(null==eA||eA(t5),()=>null==eA?void 0:eA(null)),[t5,eA]);let t4=(0,i.useCallback)(e=>{eB(t=>{let r={...t,...e,[k.HL]:new Date().toISOString()};return t3(r),r})},[t3]),t6=(0,i.useMemo)(()=>new Set(z(eD[k.N_]).filter(e=>"owner_edited"===K(e.status)).map(e=>
1K(e.sectionId)).filter(Boolean)),[eD]),t7=(0,i.useMemo)(()=>new Set(z(eD[k.N_]).filter(e=>["owner_cleared","owner_reset"].includes(K(e.status))).map(e=>K(e.sectionId)).filter(Boolean)),[eD]),t8=(0,i.useMemo)(()=>"business"===eT?function(e){var t,r;let n=T(e);if(!n)return null;let s=T(null===(t=T(n.unapproved_context_proposals))||void 0===t?void 0:t.b1_extraction_assets);if(!s||"pending_review"!==s.status)return null;let i=function(e){var t;let r=null===(t=T(e))||void 0===t?void 0:t.context_portfolio_update_lineage,n=new Set;for(let e of Array.isArray(r)?r:[]){let t=T(e),r="string"==typeof(null==t?void 0:t.status)?t.status:"",s="string"==typeof(null==t?void 0:t.sectionId)?t.sectionId:"";s&&("owner_cleared"===r||"owner_reset"===r)&&n.add(s)}return n}(n),o=function(e){var t,r,n;let s=null===(t=T(null===(r=T(e))||void 0===r?void 0:r.extraction_proposal_review))||void 0===t?void 0:t.reviewed,i={};for(let[e,t]of Object.entries(null!==(n=T(s))&&void 0!==n?n:{}))"string"==typeof t&&(i[e]=t);return i}(n),a=(e,t)=>o[e]!==A(t),l={},d=new Set;for(let{key:e,sectionId:t}of N)!I(s[e])||!a(e,s[e])||t&&i.has(t)||F(n[e])||(l[e]=s[e],t&&d.add(t));for(let e of _)!I(s[e.field])||!a(e.field,s[e.field])||i.has(e.sectionId)||F(n[e.field])||(l[e.field]=s[e.field],"string"==typeof(r=s[e.summaryField])&&r.replace(/<[^>]+>/g,"").trim().length>0&&(l[e.summaryField]=s[e.summaryField]),d.add(e.sectionId));return 0===Object.keys(l).length?null:{proposal:s,fingerprint:A(Object.keys(l).sort().map(e=>[e,l[e]])),values:l,sectionIds:Array.from(d)}}(eD):null,[eD,eT]),t9=(0,i.useMemo)(()=>{var e;return new Set(null!==(e=null==t8?void 0:t8.sectionIds)&&void 0!==e?e:[])},[t8]),re=(0,i.useMemo)(()=>{if(!t8)return[];let e=[];for(let n of N){var t,r;n.key in t8.values&&!F(eD[n.key])&&e.push({key:n.key,label:eR(null!==(t=O[n.key])&&void 0!==t?t:n.key),value:et("string"==typeof(r=t8.values[n.key])?r.trim():Array.isArray(r)?r.filter(e=>"string"==typeof e&&e.trim().length>0).map(e=>e.trim()).join(", "):"")})}for(let t of _)t.field in t8.values&&(F(eD[t.field])||e.push({key:t.field,label:eM("files.".concat(t.sectionId,".title")),value:et(function(e){var t,r;let n=e.split("\n").map(e=>e.trim()),s=n.find(e=>e&&!e.startsWith("#")),i=null===(t=n.find(e=>e.startsWith("#")))||void 0===t?void 0:t.replace(/^#+\s*/,""),o=(null!==(r=null!=s?s:i)&&void 0!==r?r:"").replace(/\*\*/g,"").replace(/^[-*]\s+/,"");return o.length>160?"".concat(o.slice(0,157),"…"):o}(K(t8.values[t.field])))}));return e},[t8,eD,eR,eM]),rt=null!==(e=null==t8?void 0:t8.fingerprint)&&void 0!==e?e:null;(0,i.useEffect)(()=>{rt&&(tS(new Set),tI("idle"),tF(null))},[rt]);let rr=(0,i.useMemo)(()=>{let e=eh.map(e=>({file:e,started:function(e,t,r){if(e.startedCheck)return e.startedCheck(t);if(r.ownerCleared)return!1;if(r.ownerEdited)return!0;let n=W(t[e.fieldName]),s=$(t[e.summaryFieldName])||K(t[e.summaryFieldName]);return"needs_you"!==ee([n,s].filter(Boolean).join("\n"))&&(e.seedFacts.some(e=>!!H(t[e.field]))||!!n||!!s)}(e,eD,{ownerEdited:t6.has(e.id),ownerCleared:t7.has(e.id)})}));return{stats:e,completed:e.filter(e=>e.started).length,total:eh.length}},[eh,eD,t7,t6]),rn=(0,i.useMemo)(()=>ex.map(e=>eh.find(t=>t.id===e)).filter(e=>!!e),[eh,ex]),rs=(0,i.useMemo)(()=>{let e=q(eD.business_name,eD.display_name),t=q(eD.current_role_title,eD.professional_role_type);return{businessName:e,ownerRole:t,category:q(eD.category),market:q(eD.market),signal:q(eD.offers,eD.proof_points,eD.positioning,eD.brand_voice)}},[eD]),ri=(0,i.useMemo)(()=>[rs.businessName,rs.ownerRole,rs.category,rs.market,rs.signal].filter(Boolean).slice(0,5),[rs]),ro=(0,i.useMemo)(()=>{var e;let t=U(eD[k.G5]),r=z(eD.context_portfolio_import_log),n=K(null==t?void 0:t.status),s=n?t:r[0],i=K(null==s?void 0:s.status)||n,o=U(eD[k.SO]),a="imported"===i||"restored"===i?null!==(e=X(null==s?void 0:s.importedAt))&&void 0!==e?e:X(null==t?void 0:t.lastImportedAt):null,l=K(null==s?void 0:s.finishedAt)||K(null==s?void 0:s.importedAt),d=(null==o?void 0:o.enabled)===!0?X(o.nextRefreshAt):null,c=Array.isArray(null==s?void 0:s.attachmentNames)?s.attachmentNames.length:0;return{status:i,source:K(null==s?void 0:s.source),importId:K(null==s?void 0:s.importId),lastImportedAt:a,finishedAtRaw:l,nextRefreshAt:d,attachmentCount:c,sectionsUpdated:G(null==s?void 0:s.sectionsUpdated),sectionsPendingReview:G(null==s?void 0:s.sectionsPendingReview),progressStage:K(null==s?void 0:s.progressStage),progressCurrent:G(null==s?void 0:s.progressCurrent),progressTotal:G(null==s?void 0:s.progressTotal),progressPercent:G(null==s?void 0:s.progressPercent),error:K(null==s?void 0:s.error)}}
1,[eD]),ra=(0,i.useMemo)(()=>{if(!ro.finishedAtRaw)return!1;let e=new Date(ro.finishedAtRaw).getTime();return!Number.isNaN(e)&&Date.now()-e<9e4},[ro.finishedAtRaw]);(0,i.useEffect)(()=>{if(!eq&&"running"!==ro.status)return;let e=!1,t=async()=>{try{let t=await tq(),r=U(null==t?void 0:t[k.G5]),n=K(null==r?void 0:r.status);!e&&n&&"running"!==n&&eW(!1)}catch(e){}};t();let r=setInterval(()=>{t()},3e3);return()=>{e=!0,clearInterval(r)}},[ro.status,eq,tq]);let rl=(0,i.useCallback)(e=>{let t=e.toLowerCase();return t?"manual"===t?eP("imports.manualSource"):"interview"===t?eF("sources.interviewTitle"):eP("imports.aiHistorySource"):eP("imports.importedContextSource")},[eF,eP]),rd=rl(ro.source),rc=(0,i.useMemo)(()=>({preparing:eP("imports.status.progressStages.preparing"),analyzing_files:eP("imports.status.progressStages.analyzingFiles"),checking_gaps:eP("imports.status.progressStages.checkingGaps"),synthesizing_context:eP("imports.status.progressStages.synthesizingContext"),ready_for_review:eP("imports.status.progressStages.readyForReview"),complete:eP("imports.status.progressStages.complete")}),[eP]),ru=(0,i.useMemo)(()=>{let e=U(eD[k.CZ]),t=z(null==e?void 0:e.sections);return{status:K(null==e?void 0:e.status),source:K(null==e?void 0:e.source),importId:K(null==e?void 0:e.importId),workflowId:K(null==e?void 0:e.workflowId),createdAt:X(null==e?void 0:e.createdAt),createdAtRaw:K(null==e?void 0:e.createdAt),batches:z(null==e?void 0:e.batches),sections:t,graphNotes:Array.isArray(null==e?void 0:e.graphNotes)?e.graphNotes.filter(e=>"string"==typeof e&&e.trim().length>0):[],sectionTitles:t.map(e=>K(e.title)||K(e.id)).filter(Boolean)}},[eD]),rm=(0,i.useMemo)(()=>new Set(ru.sections.map(e=>K(e.id)).filter(Boolean)),[ru.sections]),rp=eq||"running"===ro.status,rf=ru.sections.length>0;(0,i.useEffect)(()=>{if(!rp||tw||eQ)return;let e=0,t=window.setInterval(()=>{if((e+=5e3)>18e4){window.clearInterval(t);return}"saving"!==eH&&tq().catch(()=>{})},5e3);return()=>window.clearInterval(t)},[tw,rp,eQ,tq,eH]);let rh=rp?(ep=ro.progressPercent,ef=eq?5:10,Math.max(0,Math.min(100,Math.round(null!=ep?ep:ef)))):0,rx=null!==(t=rc[ro.progressStage])&&void 0!==t?t:rc.preparing,rb=null!==(r=ro.progressCurrent)&&void 0!==r?r:0,ry=null!==(L=null!==(S=ro.progressTotal)&&void 0!==S?S:ro.attachmentCount)&&void 0!==L?L:0,rg=[ro.status,ro.importId,ro.finishedAtRaw,ru.importId,ru.createdAtRaw].filter(Boolean).join(":"),rv=eG!==rg&&(eq||"running"===ro.status||rf||"failed"===ro.status||"imported"===ro.status&&ra),rw=rl(ru.source),rj=(0,i.useCallback)(()=>{let e=document.getElementById("context-import-review");e&&ed(e,"center")},[]),rk=X(eD[k.HL]),rN=(0,i.useMemo)(()=>z(eD[k.MI]),[eD]);(0,i.useEffect)(()=>{if(eZ)return;let e=new Map;for(let t of eh)e.set(t.id,[W(eD[t.fieldName]),$(eD[t.summaryFieldName])||K(eD[t.summaryFieldName])].join("\n---\n"));let t=tB.current;tB.current=e,t&&tX(eh.filter(r=>{var n,s;let i=null!==(n=t.get(r.id))&&void 0!==n?n:"",o=null!==(s=e.get(r.id))&&void 0!==s?s:"";return i!==o&&o.trim().length>0}).map(e=>e.id))},[eh,tX,eD,eZ]),(0,i.useEffect)(()=>{tX(Array.from(rm))},[tX,rm]);let r_=(0,i.useCallback)(()=>{if(!ru.sections.length)return;let e=new Date().toISOString(),t=z(eD[k.MI]),r=[],n=z(eD[k.N_]),s=new Map;for(let e of ru.sections){let t=K(e.field);if(!t)continue;let r=s.get(t);(!r||K(e.markdown).length>K(r.markdown).length)&&s.set(t,e)}let i={[k.CZ]:null,[k.G5]:{status:"imported",source:ru.source,importId:ru.importId,workflowId:ru.workflowId,importedAt:e,finishedAt:e,sectionsUpdated:s.size,sectionsPendingReview:0,graphNotes:ru.graphNotes}};for(let t of ru.sections){let o=K(t.field);if(o&&s.get(o)!==t)continue;let a=K(t.summaryField),l=K(t.markdown),d=K(t.summaryHtml),c=K(t.id),u=Array.isArray(t.sourceDocumentIds)?t.sourceDocumentIds.filter(e=>"string"==typeof e&&e.trim().length>0):[],m=Array.isArray(t.sourceFileNames)?t.sourceFileNames.filter(e=>"string"==typeof e&&e.trim().length>0):[];o&&l&&(i[o]=l),a&&d&&(i[a]=d),c&&o&&(r.push({id:c,title:K(t.title)||c,field:o,summaryField:a,beforeMarkdown:K(eD[o]),beforeSummaryHtml:K(eD[a]),afterMarkdown:l,afterSummaryHtml:d,confidence:K(t.confidence),provenanceNotes:K(t.provenanceNotes),sourceDocumentIds:u,sourceFileNames:m}),n.unshift({sectionId:c,field:o,summaryField:a,source:ru.source,importId:ru.importId,workflowId:ru.workflowId,sourceDocumentIds:u,sourceFileNames:m,updatedAt:e,status:"approved_by_owner"}))}i[k.MI]=[{id:"ctxver_".concat(Date.now()),createdAt:e,reason:"import_approved",source:ru.source,importId:ru.importId,workflowId:ru.workflowId,sections:r},...t].slice(0,30),i[k.N_]=n.slice(0,120);let o={...i,[k.HL]:e};for(let e of(t4(o),tX(r.map(e=>K(e.id))),r)){let t=K(e.id),r=K(e.beforeMarkdown),n=K(e.afterMarkdown);
1t&&n&&n!==r&&tJ(t,ea(r,n),2500)}eN(o).catch(()=>{})},[tX,eD,ru,eN,tJ,t4]),rC=(0,i.useCallback)(()=>{t4({[k.CZ]:null})},[t4]),rT=(0,i.useCallback)(async e=>{if(!t8||"applying"===tL)return;let t=re.map(e=>e.key).filter(e=>!tT.has(e));if("approve"!==e||0!==t.length){tI("applying");try{await t5();let r=await fetch("/api/betterness-one/business-profile/proposals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify("approve"===e?{action:e,fields:t,fingerprint:t8.fingerprint}:{action:e,fingerprint:t8.fingerprint})});if(!r.ok&&409!==r.status)throw Error("proposal_review_".concat(r.status));let n=await r.json().catch(()=>null),s=Array.isArray(null==n?void 0:n.appliedFields)?n.appliedFields.filter(e=>"string"==typeof e):[],i=Array.isArray(null==n?void 0:n.skippedFields)?n.skippedFields.filter(e=>"string"==typeof e):[];await tq(),"approve"===e&&r.ok&&tX(s.map(E).filter(e=>!!e)),r.ok?"approve"===e&&0===s.length&&i.length>0?tF("skipped"):tF(null):tF((null==n?void 0:n.error)==="proposal_changed"?"changed":"already_reviewed"),tI("idle")}catch(e){tI("error")}}},[t8,re,tX,t5,tT,tL,tq]),rS=(0,i.useCallback)(e=>{let t=z(e.sections);if(!t.length)return;let r=new Date().toISOString(),n={[k.HL]:r,[k.G5]:{status:"restored",source:K(e.source),importId:K(e.importId),workflowId:K(e.workflowId),importedAt:r,finishedAt:r,sectionsUpdated:t.length,sectionsPendingReview:ru.sections.length}},s=[];for(let e of t){let t=K(e.id),r=K(e.field),i=K(e.summaryField);r&&(n[r]=K(e.beforeMarkdown)),i&&(n[i]=K(e.beforeSummaryHtml)),t&&s.push(t)}t4(n),tX(s),eV(!1)},[tX,ru.sections.length,t4]),rL=(0,i.useCallback)(e=>{let t=e.seedFacts.map(e=>{let t=H(eD[e.field]);return t?"<p><strong>".concat(Y(eR(e.fieldToken)),":</strong> ").concat(Y(t),"</p>"):""}).filter(Boolean).join(""),r=eM("files.".concat(e.id,".question"));return t||(C(r)?"<p>".concat(Y(r),"</p>"):"")},[eD,eR,eM]),rI=(0,i.useCallback)(e=>{let t=e=>({html:e,source:"owner"}),r=e7[e.id];if(r)return t(Q(et(r)));let n=et(W(eD[e.fieldName]));if(n.trim())return t(Q(eo(n)));let s=Q(et($(eD[e.summaryFieldName])||K(eD[e.summaryFieldName])));if(s.trim())return t(s);if(t7.has(e.id))return{html:"",source:"empty"};let i=Q(et(rL(e)));return i.trim()?{html:i,source:"draft"}:{html:"",source:"empty"}},[rL,eD,e7,t7]),rA=(0,i.useCallback)(e=>{if(e0(null),tw===e.id)return;tG(e.id);let t=W(eD[e.fieldName]),r=$(eD[e.summaryFieldName])||K(eD[e.summaryFieldName]);tN(t||function(e){let t;if(!e||!e.trim())return"";let r=[],n=/<\s*(h[1-6]|p|li)\b[^>]*>([\s\S]*?)<\/\s*\1\s*>/gi;for(;null!==(t=n.exec(e));){let e=t[1].toLowerCase(),n=V(t[2].replace(/<br\s*\/?>/gi,"\n"));if(n){if("h"===e[0]){let t=Math.min(Number(e[1]),6);r.push("".concat("#".repeat(t)," ").concat(n))}else"li"===e?r.push("- ".concat(n)):r.push(n)}}return r.length?r.join("\n\n"):V(e)}(r)||""),tj(e.id)},[tw,tG,eD]),rF=(0,i.useCallback)(e=>{let t=eM("files.".concat(e.id,".question"));return C(t)?t:""},[eM]),rE=(0,i.useCallback)(()=>{tj(null),tN("")},[]),rM=(0,i.useCallback)(async e=>(eU("saving"),await eN(e))?(tO.current={},eB(t=>({...t,...e,[k.HL]:new Date().toISOString()})),eU("saved"),!0):(eU("error"),!1),[eN]),rP=(0,i.useCallback)(async e=>{let t=tk.trim(),r=new Date().toISOString(),n=z(eD[k.N_]),s={[e.fieldName]:t,[e.summaryFieldName]:Q(eo(t)),[k.N_]:[{sectionId:e.id,field:e.fieldName,summaryField:e.summaryFieldName,source:"manual",updatedAt:r,status:t?"owner_edited":"owner_cleared"},...n.filter(t=>K(t.sectionId)!==e.id)].slice(0,120)};await rM(s)&&(tj(null),tN(""))},[tk,eD,rM]),rR=(0,i.useCallback)(async e=>{eU("saving");try{if(!await e_(e))throw Error("section_purge_failed");tO.current={};let t=await ek();t&&eB(t),eU("saved"),tC(null),tj(null),tN("")}catch(e){eU("error")}},[ek,e_]),rD=(0,i.useMemo)(()=>{let e=[];for(let t of eh)for(let r of t.seedFacts){let t=H(eD[r.field]);t&&e.push("".concat(eR(r.fieldToken),": ").concat(t))}return e.slice(0,30)},[eh,eD,eR]),rB=(0,i.useCallback)(async(e,t)=>{to(!0),tr(null!=t?t:""),ts("");let r=e.seedFacts.map(e=>{let t=H(eD[e.field]);return t?"".concat(eR(e.fieldToken),": ").concat(t):""}).filter(Boolean);try{var n,s;let i=await fetch(eC,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"question",sectionTitle:null!==(n=e.interviewTitle)&&void 0!==n?n:eM("files.".concat(e.id,".title")),sectionPurpose:null!==(s=e.interviewPurpose)&&void 0!==s?s:eM("files.".concat(e.id,".description")),known:r,answered:tZ.current,graphSummary:rD,currentContext:[W(eD[e.fieldName]),$(eD[e.summaryFieldName])||K(eD[e.summaryFieldName])].filter(
1Boolean).join("\n\n"),focusQuestion:t})}),o=i.ok?await i.json():null;tr("string"==typeof(null==o?void 0:o.question)&&o.question.trim()?o.question.trim():t||eM("files.".concat(e.id,".question")))}catch(r){tr(t||eM("files.".concat(e.id,".question")))}finally{to(!1)}},[eD,rD,eC,eR,eM]),rZ=(0,i.useCallback)(async(e,t)=>{tx(!0),tm(""),tf("");let r=e.seedFacts.map(e=>{let t=H(eD[e.field]);return t?"".concat(eR(e.fieldToken),": ").concat(t):""}).filter(Boolean);try{var n,s;let i=await fetch(eC,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"question",sectionTitle:null!==(n=e.interviewTitle)&&void 0!==n?n:eM("files.".concat(e.id,".title")),sectionPurpose:null!==(s=e.interviewPurpose)&&void 0!==s?s:eM("files.".concat(e.id,".description")),known:r,answered:t,graphSummary:rD,currentContext:[W(eD[e.fieldName]),$(eD[e.summaryFieldName])||K(eD[e.summaryFieldName])].filter(Boolean).join("\n\n"),interviewStyle:"ploy_live_onboarding"})}),o=i.ok?await i.json():null;tm("string"==typeof(null==o?void 0:o.question)&&o.question.trim()?o.question.trim():eM("files.".concat(e.id,".question")))}catch(t){tm(eM("files.".concat(e.id,".question")))}finally{tx(!1)}},[eD,rD,eC,eR,eM]),rO=(0,i.useCallback)(e=>{e2(e),tX([e]),tM.current&&clearTimeout(tM.current),tM.current=setTimeout(()=>e2(null),900)},[tX]),rH=(0,i.useCallback)(e=>"## ".concat(eF("template.interviewNotes"),"\n- ").concat(e),[eF]),rU=(0,i.useCallback)((e,t)=>{let r=e.trim(),n=rH(t);return r?"".concat(r,"\n\n").concat(n):n},[rH]),rz=(0,i.useCallback)(async e=>{var t,r,n;let s=e.seedFacts.map(e=>{let t=H(eD[e.field]);return t?"".concat(eR(e.fieldToken),": ").concat(t):""}).filter(Boolean),i=eD[e.summaryFieldName],o=W(eD[e.fieldName]),a=null!==(t=tZ.current[tZ.current.length-1])&&void 0!==t?t:"",l="string"==typeof i&&i.trim()?Q(i):"";if(a){let t=rU(o,a);return t4({[e.fieldName]:t,[e.summaryFieldName]:Q("".concat(l,"<p>").concat(Y(a),"</p>"))}),rO(e.id),!0}try{let t=await fetch(eC,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"synthesize",sectionTitle:null!==(r=e.interviewTitle)&&void 0!==r?r:eM("files.".concat(e.id,".title")),sectionPurpose:null!==(n=e.interviewPurpose)&&void 0!==n?n:eM("files.".concat(e.id,".description")),known:s,answered:tZ.current,currentMarkdown:o,currentHtml:l})}),i=t.ok?await t.json():null,d=(0,j.V)(null==i?void 0:i.markdown),c=Q((0,j.s)(null==i?void 0:i.summaryHtml));if(d||c){let t=d||o,r=c||Q(eo(t)),n={[e.summaryFieldName]:r};return t&&(n[e.fieldName]=t),t4(n),t&&t!==o&&tJ(e.id,ea(o,t,{focusText:a,maxLines:3,fallbackToChangedLines:!1})),rO(e.id),!0}throw Error("empty synthesis")}catch(t){if(a){let t=o?rU(o,a):"";return t?(t4({[e.fieldName]:t,[e.summaryFieldName]:Q(eo(t))}),tJ(e.id,ea(o,t,{focusText:a,maxLines:3,fallbackToChangedLines:!1}))):t4({[e.summaryFieldName]:Q("".concat(l,"<p>").concat(Y(a),"</p>"))}),rO(e.id),!0}}return!1},[rU,rO,eD,eC,tJ,eR,eM,t4]),rK=(0,i.useCallback)((e,t)=>{let r=t.trim();if(!r)return;tZ.current=[...tZ.current,r].slice(-12);let n=ta+1;if(tl(n),t$(e.id,"updating"),rz(e).then(t=>{t$(e.id,t?"updated":"needs_attention",t?5e3:void 0)}),n>=5){tr(""),ts("");return}rB(e)},[rB,ta,t$,rz]),rq=(0,i.useCallback)(()=>{let e=rn[0];tc("asking"),ty(0),tv(null),e&&rZ(e,tZ.current)},[rZ,rn]),rW=(0,i.useCallback)(()=>{tX(eh.filter(e=>e.seedFacts.some(e=>!!H(eD[e.field]))).map(e=>e.id)),tv("updated"),window.setTimeout(()=>rq(),450)},[eh,tX,eD,rq]),r$=(0,i.useCallback)(()=>{let e=eh.find(e=>"identity"===e.id);tc("fixing"),tv(null),e&&rZ(e,tZ.current)},[rZ,eh]),rV=(0,i.useCallback)(()=>{let e=tb+1,t=rn[e];if(tv(null),!t){tc("done"),tm("");return}ty(e),rZ(t,tZ.current)},[rZ,rn,tb]),rG=(0,i.useCallback)(e=>{let t=e.trim();if(!t)return;let r="fixing"===td?eh.find(e=>"identity"===e.id):rn[tb];r&&(tZ.current=[...tZ.current,t].slice(-12),tv("updating"),rz(r).then(e=>{if(tv(e?"updated":"needs_attention"),"fixing"===td){window.setTimeout(()=>rq(),e?700:1200);return}let t=tb+1,r=rn[t];window.setTimeout(()=>{if(!r){tc("done"),tm("");return}ty(t),rZ(r,tZ.current)},e?700:1200)}))},[rZ,eh,rn,td,tb,rq,rz]),rJ=(0,i.useCallback)((e,t)=>{null===tw&&(tZ.current=[],tl(0),tG(e.id),e0(e.id),rB(e,t),window.setTimeout(()=>{let t=tK.current.get(e.id),r=tz.current.get(el(e.id)),n=null!=t?t:r;n&&ed(n,"center")},80))},[tw,tG,rB]),rX=(0,i.useCallback)(e=>{if(eQ===e.id){e0(null);return}rJ(e)},[eQ,rJ]),rY=(0,i.useCallback)(async()=>{eK(!1),"agent"!==eT&&eW(!0);try{await tq()}catch(e){}},[eT,tq]),rQ=(0,i.useCallback)(async()=>{"agent"!==eT&&eW(!0),await tq()},[eT,tq]);(0,i.useEffect)(()=>
1{if(!tt){ts("");return}ts("");let e=0,t=setInterval(()=>{e=Math.min(e+2,tt.length),ts(tt.slice(0,e)),e>=tt.length&&clearInterval(t)},18);return()=>clearInterval(t)},[tt]),(0,i.useEffect)(()=>{if(!tu){tf("");return}tf("");let e=0,t=setInterval(()=>{e=Math.min(e+2,tu.length),tf(tu.slice(0,e)),e>=tu.length&&clearInterval(t)},18);return()=>clearInterval(t)},[tu]);let r0=rr.total>0?Math.round(rr.completed/rr.total*100):0,r1=t_&&null!==(er=eh.find(e=>e.id===t_))&&void 0!==er?er:null;return eZ?(0,n.jsx)("div",{className:"flex items-center justify-center py-16 text-tertiary",children:(0,n.jsx)(s.c,{shape:"form"})}):(0,n.jsxs)("div",{className:"rounded-2xl border border-stroke-soft bg-elevation-minus1 p-4 sm:p-6",children:[(0,n.jsx)(P.s,{isOpen:null!==r1,title:r1?eF("reset.title",{section:eM("files.".concat(r1.id,".title"))}):"",description:r1?eF("reset.description",{section:eM("files.".concat(r1.id,".title"))}):"",confirmLabel:eF("reset.confirm"),cancelLabel:eF("editing.cancel"),onCancel:()=>tC(null),onConfirm:()=>{r1&&rR(r1)}}),ez?(0,n.jsx)(g.Z9,{mode:eT,onClose:()=>eK(!1),onComplete:rY,onImportQueued:rQ}):null,(0,n.jsxs)("div",{className:"flex gap-6",children:[(0,n.jsxs)("aside",{className:"sticky top-4 hidden w-[220px] flex-shrink-0 self-start lg:block",children:[(0,n.jsxs)("div",{className:"w-full rounded-xl border border-stroke-soft bg-elevation-minus1 p-4",children:[(0,n.jsxs)("div",{className:"mb-4",children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,n.jsx)("span",{className:"font-mono text-[0.7rem] font-semibold uppercase tracking-[0.14em] text-selection-typography",children:null!==(en=null==ej?void 0:ej.title)&&void 0!==en?en:eF("title")}),(0,n.jsxs)("span",{className:"text-xs text-secondary",children:[rr.completed,"/",rr.total]})]}),(0,n.jsx)("div",{className:"h-2 w-full rounded-full bg-elevation-0",children:(0,n.jsx)("div",{className:"h-full rounded-full bg-selection-typography transition-all duration-300",style:{width:"".concat(r0,"%")}})})]}),(0,n.jsxs)("nav",{className:"flex flex-col gap-0.5",children:[rr.stats.map(e=>{let{file:t,started:r}=e,s=el(t.id),i=eX===s,o=e3.has(t.id),d=rm.has(t.id)||t9.has(t.id);return(0,n.jsxs)("button",{type:"button",onClick:()=>{tG(t.id),t0(s)},className:(0,v.cn)("flex w-full items-center gap-2 rounded-lg border px-3 py-2 text-left text-sm transition-all duration-500",o?"border-stroke-selection/50 bg-selection-bg/10 font-medium text-primary":d?"border-transparent font-medium text-primary":"border-transparent text-secondary hover:bg-elevation-0/50 hover:text-primary",i&&!o?"bg-elevation-1 font-medium text-primary":""),children:[(0,n.jsx)("span",{className:"flex-1 truncate",children:eM("files.".concat(t.id,".title"))}),d?(0,n.jsx)("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full border-[1.5px] border-stroke-selection bg-selection-bg/40",children:(0,n.jsx)(a.Z,{className:"h-2.5 w-2.5 text-selection-typography"})}):r?(0,n.jsx)("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full border-[1.5px] border-stroke-selection",children:(0,n.jsx)(l.Z,{className:"h-2.5 w-2.5 text-selection-typography"})}):null]},t.id)}),ew?(0,n.jsx)("button",{type:"button",onClick:()=>{let e=document.getElementById("objectives");e&&ed(e,"start")},className:"flex w-full items-center gap-2 rounded-lg border border-transparent px-3 py-2 text-left text-sm text-secondary transition-all hover:bg-elevation-0/50 hover:text-primary",children:(0,n.jsx)("span",{className:"flex-1 truncate",children:eE("title")})}):null]})]}),(0,n.jsxs)("div",{className:"mt-3 rounded-xl border border-stroke-soft bg-elevation-minus1 p-3",children:[(0,n.jsxs)("div",{className:"mb-3 flex items-center -space-x-2",children:[[{src:"/images/landing/chatgpt-logo.png",label:eP("imports.providers.chatgpt")},{src:"/images/landing/claude-logo.png",label:eP("imports.providers.claude")},{src:"/images/landing/gemini-logo.png",label:eP("imports.providers.gemini")}].map(e=>(0,n.jsx)("img",{src:e.src,alt:e.label,className:"h-7 w-7 rounded-full border border-stroke-soft bg-elevation-0 object-cover"},e.src)),(0,n.jsx)("span",{className:"flex h-7 w-7 items-center justify-center rounded-full border border-stroke-soft bg-elevation-0 text-[0.65rem] font-semibold text-tertiary",children:eP("imports.providers.otherShort")})]}),(0,n.jsx)("p",{className:"text-sm font-semibold text-primary",children:eP("imports.contextTitle")}),(0,n.jsx)("p",{className:"mt-1 text-xs leading-5 text-secondary",children:eP("imports.contextBody")}),(0,n.jsx)("p",{className:"mt-2 text-[0.7rem] leading-4 text-tertiary",children:eP("imports.timeSaved")}),(0,n.jsxs)("div",{className:"mt-3 rounded-lg border border-stroke-soft bg-elevation-0 px-3 py-2",children:[(0,n.jsx)("p",{className:"text-[0.68rem] font-semibold uppercase tracking-[0.14em] text-tertiary",children:eP("imports.logTitle")}),(0,n.jsx)("p",{className:"mt-1 text-xs text-secondary",children:rp?eP("imports.logRunning"):rf?eP("imports.logPending"):"imported"===ro.status?eP("imports.logImported",{count:null!==(es=ro.sectionsUpdated)&&void 0!==es?es:0}):ro.lastImportedAt?eP("imports.lastImported",{date:ro.lastImportedAt}):eP("imports.neverImported")}),(0,n.jsx)("p",{className:"mt-1 text-[0.7rem] text-tertiary",children:rp?eP("imports.logRunningDetail",{c
1ount:ro.attachmentCount||0}):rf?eP("imports.logPendingDetail",{count:ru.sections.length||ro.sectionsPendingReview||0,source:rw||rd||eP("imports.unknownSource")}):ro.lastImportedAt&&"imported"===ro.status?eP("imports.sourceSummary",{source:rd,count:null!==(ei=ro.sectionsUpdated)&&void 0!==ei?ei:0}):eP("imports.logIdleDetail")}),ro.lastImportedAt&&!rp?(0,n.jsx)("p",{className:"mt-1 text-[0.7rem] text-tertiary",children:eP("imports.lastImported",{date:ro.lastImportedAt})}):null,ro.attachmentCount>0?(0,n.jsx)("p",{className:"mt-1 text-[0.7rem] text-tertiary",children:eP("imports.attachmentSummary",{count:ro.attachmentCount})}):null,rp||rf?null:(0,n.jsx)("p",{className:"mt-1 text-[0.7rem] text-tertiary",children:ro.nextRefreshAt?eP("imports.nextRefresh",{date:ro.nextRefreshAt}):eP("imports.noReminder")})]}),(0,n.jsxs)("button",{type:"button",onClick:()=>eK(!0),className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg border border-stroke-soft bg-elevation-0 px-3 py-2 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:[(0,n.jsx)(d.Z,{className:"h-3.5 w-3.5"}),eP("imports.openImport")]})]})]}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"mb-2 flex flex-col-reverse gap-2 border-b border-stroke-soft/40 pb-3 sm:flex-row sm:items-start sm:justify-between sm:gap-3 md:pr-[84px]",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"font-display text-xl font-bold text-primary",children:null!==(ec=null==ej?void 0:ej.title)&&void 0!==ec?ec:eF("title")}),(0,n.jsxs)("p",{className:"mt-1 text-sm text-secondary",children:[null!==(eu=null==ej?void 0:ej.knowsLabel)&&void 0!==eu?eu:eF("knowsLabel")," \xb7 ",r0,"%"]})]}),(0,n.jsxs)("div",{className:"relative flex shrink-0 items-center gap-2 self-end sm:self-auto",children:["idle"!==eH?(0,n.jsxs)("div",{className:"flex items-center gap-2 rounded-full border border-stroke-soft bg-elevation-minus1 px-3 py-1 text-xs text-secondary",children:["saving"===eH?(0,n.jsx)(c.Z,{className:"h-3.5 w-3.5 animate-spin"}):null,"saved"===eH?(0,n.jsx)(l.Z,{className:"h-3.5 w-3.5 text-interactive-success"}):null,"error"===eH?(0,n.jsx)(u.Z,{className:"h-3.5 w-3.5 text-destructive"}):null,(0,n.jsx)("span",{children:"saving"===eH?eF("saving"):"saved"===eH?eF("saved"):eF("saveError")})]}):null,(0,n.jsxs)("button",{type:"button",onClick:()=>eV(e=>!e),className:"inline-flex items-center gap-2 rounded-full border border-stroke-soft bg-elevation-minus1 px-3 py-1.5 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:[(0,n.jsx)(m.Z,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{children:rk?eF("portfolio.contextSavedAt",{date:rk}):eF("portfolio.contextNotSaved")}),rN.length>0?(0,n.jsx)("span",{className:"rounded-full bg-elevation-0 px-1.5 py-0.5 text-[0.65rem] text-tertiary",children:rN.length}):null]}),e$?(0,n.jsxs)("div",{className:"absolute right-0 top-10 z-20 w-[340px] rounded-xl border border-stroke-soft bg-elevation-minus2 p-3 shadow-xl",children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"font-mono text-[0.68rem] font-semibold uppercase tracking-[0.14em] text-tertiary",children:eF("portfolio.versionHistory")}),(0,n.jsx)("p",{className:"mt-1 text-xs text-secondary",children:eF("portfolio.versionHistoryBody")})]}),(0,n.jsx)("button",{type:"button",onClick:()=>eV(!1),className:"rounded-full border border-stroke-soft px-2 py-1 text-[0.7rem] text-secondary transition hover:text-primary",children:eF("portfolio.closeVersions")})]}),rN.length>0?(0,n.jsx)("div",{className:"max-h-[280px] space-y-2 overflow-y-auto pr-1",children:rN.map(e=>{var t;let r=z(e.sections);return(0,n.jsxs)("div",{className:"rounded-lg border border-stroke-soft bg-elevation-0 p-3",children:[(0,n.jsx)("p",{className:"text-xs font-semibold text-primary",children:null!==(t=X(e.createdAt))&&void 0!==t?t:eF("portfolio.unknownSnapshotDate")}),(0,n.jsx)("p",{className:"mt-1 text-[0.7rem] leading-4 text-tertiary",children:eF("portfolio.versionMeta",{count:r.length,source:rl(K(e.source))})}),(0,n.jsxs)("button",{type:"button",onClick:()=>rS(e),className:"mt-2 inline-flex items-center gap-1.5 rounded-full border border-stroke-soft px-2.5 py-1 text-[0.7rem] font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:[(0,n.jsx)(p.Z,{className:"h-3 w-3"}),eF("portfolio.restoreVersion")]})]},K(e.id)||K(e.createdAt))})}):(0,n.jsx)("p",{className:"rounded-lg border border-stroke-soft bg-elevation-0 p-3 text-xs leading-5 text-secondary",children:eF("portfolio.noVersions")})]}):null]})]}),eg?(0,n.jsx)("div",{className:"mb-4 rounded-xl border border-stroke-selection bg-elevation-0 p-4",children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stroke-soft bg-elevation-minus2",children:(0,n.jsx)(a.Z,{className:"h-4 w-4 text-selection-typography"})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)("p",{className:"font-mono text-xs font-semibold uppercase tracking-[0.16em] text-tertiary",children:eF("liveInterview.eyebrow")}),(0,n.jsx)("span",{className:"rounded-full border border-stroke-soft bg-elevation-minus2 px-2 py-0.5 text-[0.68rem] font-semibold text-secondary",children:eF("liveInterview.progress",{percent:r0})})]}),"confirming"===td?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{className:"mt-2 max-w-3xl text-base leading-7 text-primary",children:tu||eF("liveInterview.thinking")}),ri.length>0?(0,n.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:ri.map(e=>(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-stroke-soft bg-elevation-minus2 px-3 py-1.5 text-xs text-secondary",children:[(0,n.jsx)(l.Z,{className:"h-3.5 w-3.5 text-selection-typography"}),e]},e))}):null,(0,n.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[(0,n.jsxs)("button",{type:"button",onClick:rW,className:"inline-flex items-center gap-2 rounded-full bg-interactive-primary px-4 py-2 text-sm font-semibold text-on-interactive-primary transition hover:opacity-90",children:[(0,n.jsx)(l.Z,{className:"h-4 w-4"}),eF("liveInterview.confirm")]}),(0,n.jsx)("button",{type:"button",onClick:r$,className:"inline-flex items-center gap-2 rounded-full border border-stroke-soft bg-elevation-minus2 px-4 py-2 text-sm font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:eF("liveInterview.fix")})]})]}):"done"===td?(0,n.jsx)("p",{className:"mt-2 max-w-2xl text-base leading-7 text-primary",children:eF("liveInterview.done")}):(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(w.r,{question:tu,typedQuestion:tp,loading:th,onSubmit:rG,placeholder:eF("liveInterview.placeholder"),skipLabel:eF("liveInterview.skip"),finishLabel:eF("liveInterview.finishLater"),onSkip:rV,onFinish:()=>tc("done"),submitStatus:tg,thinkingLabel:eF("liveInterview.thinking"),statusLabels:{updated:eF("liveInterview.updated"),needsAttention:eF("interview.acceptance.needsAttention"),updating:eF("liveInterview.updating")}})})]})]})}):null,rv?(0,n.jsx)("div",{className:(0,v.cn)("mb-4 rounded-xl border px-4 py-3","failed"===ro.status?"border-destructive/40 bg-caution-primary/20":"imported"===ro.status||rf?"border-stroke-selection bg-selection-bg/20":"border-stroke-hard bg-elevation-0"),children:(0,n.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,n.jsx)("div",{className:"mt-0.5 flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full border border-stroke-soft bg-elevation-minus2",children:"failed"===ro.status?(0,n.jsx)(u.Z,{className:"h-4 w-4 text-destructive"}):rf?(0,n.jsx)(a.Z,{className:"h-4 w-4 text-selection-typography"}):"imported"===ro.status?(0,n.jsx)(l.Z,{className:"h-4 w-4 text-selection-typography"}):(0,n.jsx)(f.Z,{className:"h-4 w-4 animate-spin text-selection-typography"})}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"font-mono text-[0.68rem] font-semibold uppercase tracking-[0.16em] text-tertiary",children:eP("imports.statusEyebrow")}),(0,n.jsx)("h3",{className:"mt-1 font-display text-base font-semibold text-primary",children:"failed"===ro.status?eP("imports.status.failedTitle"):rf?eP("imports.status.reviewTitle"):"imported"===ro.status?eP("imports.status.importedTitle"):eP("imports.status.processingTitle")}),(0,n.jsx)("p",{className:"mt-1 text-sm leading-5 text-secondary",children:"failed"===ro.status?eP("imports.status.failedBody"):rf?eP("imports.status.reviewBody",{count:ru.sections.length||ro.sectionsPendingReview||0,fileCount:ro.attachmentCount||0}):"imported"===ro.status?eP("imports.status.importedBody",{count:null!==(em=ro.sectionsUpdated)&&void 0!==em?em:0}):eP("imports.status.processingBody",{count:ro.attachmentCount||0})}),ro.lastImportedAt?(0,n.jsx)("p",{className:"mt-1 text-xs text-tertiary",children:eP("imports.lastImported",{date:ro.lastImportedAt})}):null,rp?(0,n.jsxs)("div",{className:"mt-3 max-w-xl",children:[(0,n.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-3 text-[0.72rem] text-tertiary",children:[(0,n.jsx)("span",{children:rx}),(0,n.jsx)("span",{children:ry>0?eP("imports.status.progressFiles",{current:rb,total:ry}):eP("imports.status.progressPercent",{percent:rh})})]}),(0,n.jsx)("div",{className:"h-1.5 overflow-hidden rounded-full bg-elevation-minus2",children:(0,n.jsx)("div",{className:"h-full rounded-full bg-selection-typography transition-all duration-500",style:{width:"".concat(rh,"%")}})})]}):null]})]}),(0,n.jsxs)("div",{className:"flex flex-shrink-0 gap-2",children:[rf?(0,n.jsx)("button",{type:"button",onClick:rj,className:"rounded-full border border-stroke-selection bg-elevation-minus2 px-3 py-2 text-xs font-semibold text-primary transition hover:bg-selection-bg/20",children:eP("imports.status.reviewAction")}):null,"failed"===ro.status?(0,n.jsx)("button",{type:"button",onClick:()=>eK(!0),className:"rounded-full bg-interactive-primary px-3 py-2 text-xs font-semibold text-on-interactive-primary transition hover:opacity-90",children:eP("imports.status.tryAgain")}):null,rp?null:(0,n.jsx)("button",{type:"button",onClick:()=>eJ(rg),className:"rounded-full border border-stroke-soft bg-elevation-minus2 p-2 text-tertiary transition hover:border-stroke-hard hover:text-primary","aria-label":eP("imports.status.dismiss"),title:eP("imports.status.dismiss"),children:(0,n.jsx)(h.Z,{className:"h-4 w-4"})})]})]})}):null,t8&&re.length>0?(0,n.jsxs)("div",{id:"extraction-proposal-review",className:"mb-4 rounded-xl border border-stroke-selection/60 bg-selection-bg/10 px-4 py-3",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"font-mono text-[0.68rem] font-semibold uppercase tracking-[0.16em] text-selection-typography",children:eF("extractionReview.eyebrow")}),(0,n.jsx)("h3",{className:"mt-1 font-display text-base font-semibold text-primary",children:eF("extractionReview.title")}),(0,n.jsx)("p",{className:"mt-1 text-sm leading-5 text-secondary",children:eF("extractionReview.body")})]}),(0,n.jsx)("ul",{className:"mt-3 flex flex-col gap-1.5",children:re.map(e=>(0,n.jsxs)("li",{className:"flex items-start gap-2",children:[(0,n.jsx)("input",{type:"checkbox",id:"extraction-proposal-".concat(el(e.key)),checked:!tT.has(e.key),onChange:()=>tS(t=>{let r=new Set(t);return r.has(e.key)?r.delete(e.key):r.add(e.key),r}),className:"mt-0.5 h-4 w-4 shrink-0 accent-[var(--color-fill-brand,currentColor)]","aria-label":eF("extractionReview.toggleAria",{field:e.label})}),(0,n.jsxs)("label",{htmlFor:"extraction-proposal-".concat(el(e.key)),className:"min-w-0 cursor-pointer text-sm leading-5 text-secondary",children:[(0,n.jsxs)("span",{className:"font-semibold text-primary",children:[e.label,":"]}
1)," ",e.value]})]},e.key))}),(0,n.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>rT("approve"),disabled:"applying"===tL||re.every(e=>tT.has(e.key)),className:"inline-flex items-center gap-2 rounded-full bg-interactive-primary px-3 py-2 text-xs font-semibold text-on-interactive-primary transition hover:opacity-90 disabled:opacity-50",children:["applying"===tL?(0,n.jsx)(f.Z,{className:"h-3.5 w-3.5 animate-spin"}):(0,n.jsx)(l.Z,{className:"h-3.5 w-3.5"}),"applying"===tL?eF("extractionReview.applying"):eF("extractionReview.approve")]}),(0,n.jsx)("button",{type:"button",onClick:()=>rT("dismiss"),disabled:"applying"===tL,className:"rounded-full border border-stroke-soft bg-elevation-minus2 px-3 py-2 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary disabled:opacity-50",children:eF("extractionReview.dismiss")}),"error"===tL?(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs font-semibold text-warning",role:"status",children:[(0,n.jsx)(u.Z,{className:"h-3.5 w-3.5"}),eF("extractionReview.error")]}):null]})]}):null,tA?(0,n.jsxs)("div",{id:"extraction-proposal-outcome",role:"status",className:"mb-4 inline-flex items-center gap-2 rounded-xl border border-warning/40 bg-caution-primary/20 px-4 py-2 text-xs font-semibold text-warning",children:[(0,n.jsx)(u.Z,{className:"h-3.5 w-3.5 shrink-0"}),eF("extractionReview.".concat("skipped"===tA?"partial":"changed"===tA?"changed":"alreadyReviewed"))]}):null,ru.sections.length>0?(0,n.jsx)("div",{id:"context-import-review",className:"mb-4 rounded-xl border border-warning/40 bg-caution-primary/20 px-4 py-3",children:(0,n.jsx)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"font-mono text-[0.68rem] font-semibold uppercase tracking-[0.16em] text-warning",children:eP("imports.reviewEyebrow")}),(0,n.jsx)("h3",{className:"mt-1 font-display text-base font-semibold text-primary",children:eP("imports.reviewTitle",{count:ru.sections.length})}),(0,n.jsx)("p",{className:"mt-1 text-sm leading-5 text-secondary",children:eP("imports.reviewBody",{source:rw||eP("imports.unknownSource")})}),(0,n.jsxs)("p",{className:"mt-2 text-xs text-tertiary",children:[ru.sectionTitles.join(", "),ru.createdAt?" \xb7 ".concat(ru.createdAt):""]}),ru.batches.length>0?(0,n.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:ru.batches.slice(0,3).map(e=>{var t,r;return(0,n.jsx)("span",{className:"rounded-full border border-stroke-soft bg-elevation-minus2 px-2 py-1 text-[0.68rem] text-tertiary",children:eP("imports.pendingBatch",{date:null!==(t=X(e.createdAt))&&void 0!==t?t:eF("portfolio.unknownSnapshotDate"),count:null!==(r=G(e.sectionsPendingReview))&&void 0!==r?r:0})},K(e.id)||K(e.createdAt))})}):null]})})}):null,ru.sections.length>0?(0,n.jsxs)("div",{className:"sticky top-0 z-20 mb-3 flex flex-wrap items-center gap-3 rounded-xl border border-stroke-soft bg-elevation-1/95 px-4 py-2.5 shadow-sm backdrop-blur",children:[(0,n.jsx)(a.Z,{className:"h-4 w-4 shrink-0 text-selection-typography","aria-hidden":!0}),(0,n.jsx)("p",{className:"min-w-0 flex-1 text-xs font-medium text-primary",children:eP("imports.reviewTitle",{count:ru.sections.length})}),(0,n.jsx)("button",{type:"button",onClick:rC,className:"rounded-full border border-stroke-soft bg-elevation-minus2 px-3 py-1.5 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:eP("imports.reviewDiscard")}),(0,n.jsx)("button",{type:"button",onClick:r_,className:"rounded-full bg-interactive-primary px-3 py-1.5 text-xs font-semibold text-on-interactive-primary transition hover:opacity-90",children:eP("imports.approveAll")})]}):null,(0,n.jsx)("div",{className:"flex flex-col gap-4",children:rr.stats.map(e=>{var t;let{file:r,started:s}=e,i=el(r.id),o=eQ===r.id,d=tw===r.id,c=!o&&null!==tw,m=o&&ta>=5,h=e3.has(r.id),g=rm.has(r.id)||t9.has(r.id),w=null!==(t=null==eS?void 0:eS(r))&&void 0!==t?t:null,j=null!==w,{html:k,source:N}=rI(r),_="owner"!==N,C=ee([W(eD[r.fieldName]),$(eD[r.summaryFieldName])||K(eD[r.summaryFieldName])].filter(
1Boolean).join("\n")),T=null!=C?C:t6.has(r.id)?"confirmed":s||t9.has(r.id)?null:"needs_you",S=e9[r.id],L=e4.has(r.id);return(0,n.jsxs)("section",{id:i,ref:tY(i),className:(0,v.cn)("scroll-mt-4 rounded-xl border p-5 transition-all duration-500",h?"border-stroke-selection/50 bg-selection-bg/10":"border-transparent bg-elevation-minus2"),children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>tV(r.id),"aria-expanded":!L,"aria-controls":"".concat(i,"-body"),title:L?eF("portfolio.expandSection"):eF("portfolio.collapseSection"),className:"group flex min-w-0 items-center gap-2 rounded-lg text-left transition hover:opacity-80",children:[(0,n.jsx)(x.Z,{className:(0,v.cn)("h-4 w-4 shrink-0 text-tertiary transition-transform duration-200 group-hover:text-secondary",L&&"-rotate-90"),"aria-hidden":!0}),(0,n.jsx)("h3",{className:"min-w-0 font-display text-lg font-semibold text-primary",children:eM("files.".concat(r.id,".title"))}),(0,n.jsx)("span",{className:"sr-only",children:L?eF("portfolio.expandSection"):eF("portfolio.collapseSection")})]}),L?null:(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[j?null:(0,n.jsxs)("button",{type:"button",onClick:()=>rA(r),"aria-label":eF("editing.edit"),title:eF("editing.edit"),className:"inline-flex items-center gap-2 rounded-full border border-stroke-soft bg-elevation-minus2 p-2 text-sm font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary sm:px-3 sm:py-2",children:[(0,n.jsx)(b.Z,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:eF("editing.edit")})]}),(0,n.jsxs)("button",{type:"button",onClick:()=>tC(r.id),"aria-label":eF("reset.action"),title:eF("reset.action"),className:"inline-flex items-center gap-2 rounded-full border border-stroke-soft bg-elevation-minus2 p-2 text-sm font-semibold text-secondary transition hover:border-destructive hover:text-destructive sm:px-3 sm:py-2",children:[(0,n.jsx)(p.Z,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:eF("reset.action")})]}),j?null:(0,n.jsxs)("button",{type:"button",onClick:()=>rX(r),disabled:c,"aria-expanded":o,"aria-label":eF("interviewMe"),title:c?eF("interview.blockedByEditing"):eF("interviewMe"),className:(0,v.cn)("inline-flex items-center gap-2 rounded-full p-2 text-sm font-semibold transition disabled:cursor-not-allowed disabled:opacity-50 sm:px-4 sm:py-2",o?"bg-elevation-0 text-primary":"bg-interactive-primary text-on-interactive-primary hover:opacity-90 disabled:hover:opacity-50"),children:[(0,n.jsx)(a.Z,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:eF("interviewMe")})]})]})]}),(0,n.jsxs)("div",{id:"".concat(i,"-body"),hidden:L,children:[(0,n.jsx)("p",{className:"mt-1 text-sm leading-6 text-tertiary",children:eM("files.".concat(r.id,".description"))}),j?w:null,j?null:(0,n.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[g?(0,n.jsx)(M.C,{color:"primary",children:eF("provenance.aiFilled")}):null,T?(0,n.jsx)(M.C,{color:"needs_you"===T?"warning":"success",children:"needs_you"===T?eF("provenance.needsYou"):eF("provenance.confirmed")}):null]}),!j&&o?(0,n.jsxs)("div",{ref:tQ(r.id),className:"mt-4 rounded-xl border border-stroke-soft bg-elevation-0 p-4",children:[(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("p",{className:"font-mono text-xs uppercase tracking-[0.16em] text-tertiary",children:eF("interview.interviewer")}),(0,n.jsx)("p",{className:"shrink-0 font-mono text-xs uppercase tracking-[0.16em] text-tertiary",children:m?eF("interview.complete"):eF("interview.remaining",{count:5-ta})})]}),(0,n.jsx)("p",{className:"mt-2 min-h-[1.75rem] max-w-2xl text-base leading-7 text-primary",children:m?eF("interview.completeDetail"):ti&&!tn?(0,n.jsx)("span",{className:"text-tertiary",children:"…"}):(0,n.jsxs)(n.Fragment,{children:[tn,tn.length<tt.length?(0,n.jsx)("span",{className:"ml-0.5 inline-block animate-pulse text-tertiary",children:"▋"}):null]})}),m?(0,n.jsx)("button",{type:"button",onClick:()=>e0(null),className:"mt-3 rounded-full border border-stroke-soft bg-elevation-minus2 px-4 py-2 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:eF("interview.closeComplete")}
1):(0,n.jsx)("div",{className:"mt-3",children:(0,n.jsx)(y.x,{lockedAgentId:"betti",hideRealtimeVoice:!0,hideDisclaimer:ev,borderlessComposer:!0,hideLimitBanner:!0,onSubmitCapture:e=>rK(r,e),placeholder:eF("interview.placeholder")})}),S?(0,n.jsxs)("div",{className:(0,v.cn)("mt-3 inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs font-semibold","updated"===S?"border-stroke-selection bg-selection-bg/20 text-selection-typography":"needs_attention"===S?"border-warning/40 bg-caution-primary/20 text-warning":"border-stroke-soft bg-elevation-minus2 text-secondary"),role:"status","aria-live":"polite",children:["updated"===S?(0,n.jsx)(l.Z,{className:"h-3.5 w-3.5"}):"needs_attention"===S?(0,n.jsx)(u.Z,{className:"h-3.5 w-3.5"}):(0,n.jsx)(f.Z,{className:"h-3.5 w-3.5 animate-spin"}),(0,n.jsx)("span",{children:"updated"===S?eF("interview.acceptance.updated",{section:eM("files.".concat(r.id,".title"))}):"needs_attention"===S?eF("interview.acceptance.needsAttention"):eF("interview.acceptance.updating")})]}):null]}):null,!j&&d?(0,n.jsxs)("div",{className:"mt-4 rounded-lg border border-stroke-medium bg-elevation-0 p-3",children:[(0,n.jsx)("textarea",{value:tk,onChange:e=>tN(e.target.value),"aria-label":eF("editing.editorAria",{section:eM("files.".concat(r.id,".title"))}),autoFocus:!0,rows:8,className:"w-full resize-y bg-transparent px-1 py-1 text-base leading-7 text-primary outline-none placeholder:text-tertiary",placeholder:rF(r)||eF("editing.placeholder")}),(0,n.jsxs)("div",{className:"mt-3 flex justify-end gap-2 border-t border-stroke-soft pt-3",children:[(0,n.jsx)("button",{type:"button",onClick:rE,className:"rounded-full border border-stroke-soft px-3 py-1.5 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:eF("editing.cancel")}),(0,n.jsx)("button",{type:"button",onClick:()=>rP(r),className:"rounded-full bg-interactive-primary px-3 py-1.5 text-xs font-semibold text-on-interactive-primary transition hover:opacity-90",children:eF("editing.save")})]})]}):j?null:(0,n.jsxs)("div",{"aria-label":eF("portfolio.summaryAria"),className:(0,v.cn)("mt-4 min-h-[96px] rounded-lg border border-stroke-soft px-4 py-3 text-base leading-7 transition-all duration-500 [&_h2]:mb-3 [&_h2]:font-display [&_h2]:text-xl [&_h2]:font-semibold [&_h2]:text-primary [&_h3]:mb-2 [&_h3]:mt-6 [&_h3]:font-mono [&_h3]:text-xs [&_h3]:font-semibold [&_h3]:uppercase [&_h3]:tracking-[0.16em] [&_h3]:text-tertiary [&_p]:mb-3 [&_strong]:text-primary","[&_mark]:rounded-md [&_mark]:bg-selection-bg/25 [&_mark]:px-1 [&_mark]:text-primary [&_mark]:underline [&_mark]:decoration-2 [&_mark]:decoration-selection-typography [&_mark]:underline-offset-4",_?"text-tertiary":"text-secondary",e1===r.id?"bg-elevation-1 ring-2 ring-selection-typography":"bg-elevation-minus1 ring-1 ring-transparent"),children:[(0,n.jsx)("div",{dangerouslySetInnerHTML:{__html:k}}),_?(0,n.jsx)("p",{className:"mt-3",children:eF("editing.placeholder")}):null]},"".concat(r.id,"-").concat(k.length,"-").concat(k.slice(0,40)))]})]},r.id)})}),eL]})]})]})}},12124:function(e,t,r){r.d(t,{r:function(){return d}});var n=r(57437);r(2265);var s=r(30401),i=r(76865),o=r(51817),a=r(60417),l=r(94457);function d(e){let{question:t,typedQuestion:r,loading:d=!1,placeholder:c,onSubmit:u,skipLabel:m,finishLabel:p,onSkip:f,onFinish:h,submitStatus:x,statusLabels:b,thinkingLabel:y,className:g}=e;return(0,n.jsxs)("div",{className:g,children:[(0,n.jsx)("p",{className:"mt-2 min-h-[1.75rem] max-w-3xl text-base leading-7 text-primary",children:d&&!r?(0,n.jsx)("span",{className:"text-tertiary",children:null!=y?y:""}):(0,n.jsxs)(n.Fragment,{children:[r,r.length<t.length?(0,n.jsx)("span",{className:"ml-0.5 inline-block animate-pulse text-tertiary",children:"▋"}):null]})}),(0,n.jsx)("div",{className:"mt-3",children:(0,n.jsx)(a.x,{lockedAgentId:"betti",hideRealtimeVoice:!0,borderlessComposer:!0,hideLimitBanner:!0,onSubmitCapture:u,placeholder:c})}),(0,n.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[m&&f?(0,n.jsx)("button",{type:"button",onClick:f,className:"rounded-full border border-stroke-soft bg-elevation-minus2 px-3 py-1.5 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:m}):null,p&&h?(0,n.jsx)("button",{type:"button",onClick:h,className:"rounded-full border border-stroke-soft bg-elevation-minus2 px-3 py-1.5 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:p}):null,x&&b?(0,n.jsxs)("span",{className:(0,l.cn)("inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs font-semibold","updated"===x?"border-stroke-selection bg-selection-bg/20 text-selection-typography":"needs_attention"===x?"border-warning/40 bg-caution-primary/20 text-warning":"border-stroke-soft bg-elevation-minus2 text-secondary"),role:"status","aria-live":"polite",children:["updated"===x?(0,n.jsx)(s.Z,{className:"h-3.5 w-3.5"}):"needs_attention"===x?(0,n.jsx)(i.Z,{className:"h-3.5 w-3.5"}):(0,n.jsx)(o.Z,{className:"h-3.5 w-3.5 animate-spin"}),"updated"===x?b.updated:"needs_attention"===x?b.needsAttention:b.updating]}):null]})]})}},74376:function(e,t,r){r.d(t,{$b:function(){return eU}});
1var n=r(57437),s=r(9585),i=r(4639),o=r(2265),a=r(38706),l=r(53113),d=r(32489),c=r(51817),u=r(76865),m=r(30401),p=r(96362),f=r(48736),h=r(88156),x=r(82023),b=r(92451),y=r(82431),g=r(91723),v=r(45675),w=r(67782),j=r(92735),k=r(69076),N=r(83229),_=r(76858);r(26142);var C=r(38407);function T(e){return"string"==typeof e?e.trim():""}function S(e){return T(e.fileName)||T(e.title)||T(e.name)||T(e.id)}function L(e){return/^https?:\/\//i.test(e)}function I(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch(e){return""}}function A(e,t){let r=S(e);if(!r)return t;if(!L(r))return r;let n=I(r);try{let e=new URL(r).pathname.replace(/^\/+|\/+$/g,"").replace(/[-_]+/g," ");return e?"".concat(n," / ").concat(e):n||r}catch(e){return n||r}}var F=r(60417),E=r(78541),M=r(11877),P=r(92581);function R(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}let D={"grounded facts":"What we know","inferences and hypotheses":"What this means","decisions and rationale":"Decisions and boundaries","preferences, constraints, and boundaries":"Preferences and boundaries","rules and decisions":"Do's and don'ts","how this should be used downstream":"How to use it","examples and references":"Examples","asset lineage":"Source files and assets","open questions":"Questions to confirm"},B=new Set(["provenance"]),Z=new Set(["asset lineage","brand materials","evidence","evidence list","source files","source files and assets","source evidence","supporting evidence","visual assets"]),O=/^https?:\/\/\S+$/i,H=/^(?:hash\s*:\s*)?(?:sha(?:-?1|-?224|-?256|-?384|-?512)?\s*:\s*)?[a-f0-9]{32,}$/i,U=/!\[[^\]]*\]\([^)]+\)/i,z=/<img\b[^>]*>/i,K=/(?:^|[\s([`"'])(?:[^\s/\\()[\]`"']+[\\/])*[^\s/\\()[\]`"']+\.(?:avif|eps|fig|gif|heic|jpe?g|mov|mp4|otf|pdf|png|psd|svg|tiff?|webm|webp|woff2?)(?:$|[\s)\],;:`"'])/i,q=[/\btreat this as (?:a )?starter context\b/i,/\bprove it when\b/i,/\bproposed from .*pending owner\b/i,/\bpending owner\b/i,/\bbefore running to your brief\b/i,/\bnot synthesized for memories before running to your brief\b/i,/\bdo not paste\/extract\b/i,/\bdo not paste extracted crawl paragraphs\b/i,/\bcrop word in brand guide sections\b/i,/\bpending owner review\b/i];function W(e){return e.replace(/\*\*/g,"").replace(/`/g,"").replace(/\s+/g," ").trim().toLowerCase()}function $(e){let t=(function(e){let t=e.match(/^?\s*---\r?\n[\s\S]*?\r?\n---\s*(?:\r?\n|$)/);return t?e.slice(t[0].length):e})((0,P.V)(e)).split(/\r?\n/),r=[],n=0,s=!1;for(let e of t){let t=e.match(/^(#{1,6})\s+(.+?)\s*$/);if(t){let e=t[1].length;if(n&&e<=n&&(n=0),n)continue;if(Z.has(W(t[2]))){n=e,s=!1;continue}}else if(n)continue;let i=e.replace(/[*_`>#]/g," ").replace(/\s+/g," ").trim();if(/^evidence(?:\s+list)?\s*:$/i.test(i)){s=!0;continue}if(s){if(!i||/^(?:[-*+]\s+|\d+[.)]\s+)/.test(e.trim()))continue;s=!1}if(!function(e){let t=e.replace(/[*_`>#-]/g," ").replace(/\s+/g," ").trim(),r=e.trim().replace(/^(?:[-*+]\s+|>\s*)/,"").replace(/^[`_*]+|[`_*]+$/g,"").replace(/^</,"").replace(/[>.,;:]$/,"");return q.some(e=>e.test(t))||/^confidence\s*:/i.test(t)||/^evidence\s*:/i.test(t)||U.test(e)||z.test(e)||K.test(e)||O.test(r)||H.test(r)}(e)){if(t){let e=[...r].reverse().find(e=>e.trim().length>0),n=null==e?void 0:e.match(/^(#{1,6})\s+(.+?)\s*$/);if(n&&W(n[2])===W(t[2]))continue}r.push(e)}}return r.join("\n").replace(/\n{3,}/g,"\n\n").trim()}function V(e){let t=$(e).split(/\r?\n/),r=[],n=0;for(let e of t){let t=e.match(/^(#{1,6})\s+(.+?)\s*$/);if(t){var s;let e=t[1].length,i=t[2].trim(),o=W(i);if(n&&e<=n&&(n=0),n)continue;if(B.has(o)){n=e;continue}if(/\.md$/i.test(o)){n=0;continue}let a=null!==(s=D[o])&&void 0!==s?s:i;r.push("".concat(t[1]," ").concat(a));continue}n||r.push(e.replace(/\bEditorial doctrine for podcast\/video content:/gi,"Podcast and video rule:").replace(/\bEditorial authenticity doctrine:/gi,"Editing rule:").replace(/\bB1 UX\/text doctrine\b/gi,"Product text rule").replace(/\bNorth-star content thesis for B1:/gi,"Main content direction:").replace(/\bCaption beat logic \(a concrete voice artifact\):/gi,"Caption style rule:").replace(/\bWhere it belongs in Library:/gi,"Where to save it:").replace(/\bUsage:/gi,"How to use it:").replace(/\s+\((?:Inference|Hypothesis)[^)]*\)/gi,""))}return r.join("\n").replace(/\n{3,}/g,"\n\n").trim()}let G=/^#[0-9A-Fa-f]{6}$/,J=/colou?rs?|colou?r\s+palette|palette|typograph(?:y|ies)|type|fonts?|typefaces?/i;
1r(61436);var X=r(94457),Y=r(64207),Q=r(46414),ee=r(7555),et=r(84959);function er(e){let t=Error("brand_guide_request_failed");return t.status=e,t}function en(e){if(!(e instanceof Error))return!0;let t=e.status;return"number"!=typeof t||t>=500}function es(e){let t=M.X0.get(e);if(!t)throw Error("Missing Brand Guide section ".concat(e));return t}function ei(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return{...es(e),...r,childSectionIds:t}}let eo=[ei("brand_basics",["brand_basics"]),ei("visual_identity",["visual_identity","logos_assets","imagery_motion"],{fileName:"visual-system.md"}),ei("voice_messaging",["voice_messaging"]),ei("social_channels",["social_channels","email_newsletter","podcast_youtube","campaign_templates"],{fileName:"channels-and-content.md"}),ei("brand_rules_decisions",["brand_rules_decisions"])],ea=new Map(eo.flatMap(e=>e.childSectionIds.map(t=>[t,e.id])));function el(e){var t;return null!==(t=ea.get(e))&&void 0!==t?t:e}function ed(e){return"childSectionIds"in e&&Array.isArray(e.childSectionIds)?[...e.childSectionIds]:[e.id]}function ec(e){return"sections.".concat(e.i18nKey,".title")}function eu(e){return"sections.".concat(e.i18nKey,".description")}let em={brand_basics:"ownerReadable.sectionTitles.whoWeAre",visual_identity:"ownerReadable.sectionTitles.look",voice_messaging:"ownerReadable.sectionTitles.voice",social_channels:"ownerReadable.sectionTitles.content",brand_rules_decisions:"ownerReadable.sectionTitles.rules"};function ep(e){var t;return null!==(t=em[e.id])&&void 0!==t?t:ec(e)}function ef(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}function eh(e){return Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e&&!Array.isArray(e)):[]}function ex(e){return Array.isArray(e)?e.map(e=>eb(e)).filter(Boolean):[]}function eb(e){return"string"==typeof e?e.trim():""}function ey(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function eg(e){let t=eb(e);if(!t)return null;let r=new Date(t);return Number.isNaN(r.getTime())?null:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}).format(r)}function ev(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}function ew(e){if("undefined"==typeof document)return e;let t=document.createElement("template");t.innerHTML=e;let r=new Set(["B","BR","CODE","DIV","EM","H1","H2","H3","H4","H5","H6","I","LI","OL","P","HR","STRONG","TABLE","TBODY","TD","TH","THEAD","TR","UL"]),n=new Set(["SCRIPT","STYLE","IFRAME","OBJECT","EMBED","LINK","META","BASE","FORM","SVG"]),s=e=>{if(e.nodeType===Node.TEXT_NODE){var t;return document.createTextNode(null!==(t=e.textContent)&&void 0!==t?t:"")}if(e.nodeType!==Node.ELEMENT_NODE)return null;let i=e.tagName.toUpperCase();if(n.has(i))return null;let o=Array.from(e.childNodes).map(e=>s(e)).filter(e=>!!e);if(!r.has(i)){let e=document.createDocumentFragment();return o.forEach(t=>e.appendChild(t)),e}let a=document.createElement(i.toLowerCase());return o.forEach(e=>a.appendChild(e)),a},i=document.createElement("div");return Array.from(t.content.childNodes).forEach(e=>{let t=s(e);t&&i.appendChild(t)}),i.innerHTML}function ej(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/`([^`]+)`/g,"<code>$1</code>")}function ek(e){return/^\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)+\|?$/.test(e)}function eN(e){return e.replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>e.trim())}function e_(e){let t=V(e).split(/\r?\n/),r=[],n=!1,s=()=>{n&&(r.push("</ul>"),n=!1)};for(let e=0;e<t.length;e+=1){let i=t[e].trim();if(!i){s();continue}if(i.startsWith("|")&&e+1<t.length&&ek(t[e+1].trim())){s();let n=eN(i),o=[],a=e+2;for(;a<t.length&&t[a].trim().startsWith("|");)o.push(eN(t[a].trim())),a+=1;r.push("<table><thead><tr>"),n.forEach(e=>r.push("<th>".concat(ej(e),"</th>"))),r.push("</tr></thead><tbody>"),o.forEach(e=>{r.push("<tr>"),n.forEach((t,n)=>{var s;return r.push("<td>".concat(ej(null!==(s=e[n])&&void 0!==s?s:""),"</td>"))}),r.push("</tr>")}),r.push("</tbody></table>"),e=a-1;continue}if(/^(?:-{3,}|_{3,}|\*{3,})$/.test(i)){s(),r.push("<hr>");continue}let o=i.match(/^(#{1,4})\s+(.+)$/);if(o){s();let e=Math.min(o[1].length+1,4);r.push("<h".concat(e,">").concat(ej(o[2]),"</h").concat(e,">"));continue}let a=i.match(/^[-*]\s+(.+)$/);if(a){n||(r.push("<ul>"),n=!0),r.push("<li>".concat(ej(a[1]),"</li>"));continue}let l=i.match(/^\d+[.)]\s+(.+)$/);if(l){s(),r.push("<p>".concat(ej(l[1]),"</p>"));continue}s(),r.push("<p>".concat(ej(i),"</p>"))}return s(),ew(r.join(""))}function eC(e){var t,r,n;let s=null===(t=e.match(/^\s*([✓⚑])\s*/))||void 0===t?void 0:t[1],i=e.replace(/[✓⚑]\s*/g,""),o=Array.from(new Set(null!==(r=i.match(/#[0-9A-Fa-f]{6}\b/g))&&void 0!==r?r:[])).map(e=>e.toUpperCase()),a=Array.from(new Set((null!==(n=i.match(/https?:\/\/[^\s)\]>]+/gi))&&void 0!==n?n:[]).map(e=>e.replace(/[.,;:!?]+$/,""))));return{text:i.replace(/https?:\/\/[^\s)\]>]+/gi,"").replace(/\s{2,}/g," ").replace(/\s+([.,;:!?])/g,"$1").replace(/\bPrimary owned source\b/gi,"Main source").replace(/\bGTM motion\b/gi,"How we reach customers").replace(/\bclaim strength\b/gi,"how strong a claim is").replace(/\bsource-backed\b/gi,"confirmed by a source").trim(),provenance:"✓"===s?"confirmed":"⚑"===s?"needs_owner":null,colors:o,urls:a}}function eT(e){let{text:t}=e;return t?(0,n.jsx)("span",{dangerouslySetInnerHTML:{__html:ej(t)}}):null}function eS(e){let{markdown:t}=e,r=(0,o.useMemo)(()=>(function(e){let t=[],r=[],n=!1,s=V(e).split(/\r?\n/);for(let e=0;e<s.length;e+=1){var i;let o=s[e].trim();if(!o)continue;if(/^(?:-{3,}|_{3,}|\*{3,})$/.test(o)){n?n=!1:t.push({id:"divider-".concat(e),kind:"divider",text:"",provenance:null,colors:[],urls:[]});continue}let a=o.match(/^(#{1,4})\s+(.+)$/);if(a){let r=/(?:questions? to confirm|what needs owner confirmation|needs owner|open questions?)/i.test(a[2]);if(n=r,!r){let r=eC(a[2]);t.push({id:"heading-".concat(e),kind:"heading",level:a[1].length,...r})}continue}if(o.startsWith("|")&&e+1<s.length&&ek(s[e+1].trim())){let i=e,a=[eN(o)],l=e+2;for(;
1l<s.length&&s[l].trim().startsWith("|");)a.push(eN(s[l].trim())),l+=1;if(e=l-1,n){a.slice(1).forEach((e,t)=>{let n=eC(e.filter(Boolean).join(" — "));n.text&&r.push({id:"question-table-".concat(i,"-").concat(t),kind:"text",...n})});continue}t.push({id:"table-".concat(i),kind:"table",text:"",provenance:null,colors:[],urls:[],tableRows:a});continue}let l=o.match(/^(?:[-*]|\d+[.)])\s+(.+)$/),d=eC(null!==(i=null==l?void 0:l[1])&&void 0!==i?i:o);if(!d.text&&!d.colors.length&&!d.urls.length)continue;let c={id:"line-".concat(e),kind:l?"bullet":"text",...d};(n||"needs_owner"===d.provenance)&&c.text?r.push(c):t.push(c)}return{items:t,questions:r}})(t),[t]);return(0,n.jsx)("div",{className:"space-y-3",children:(0,n.jsx)("div",{className:"space-y-2",children:r.items.map(e=>{var t;if("divider"===e.kind)return(0,n.jsx)("hr",{className:"my-4 border-stroke-soft"},e.id);if("table"===e.kind&&(null===(t=e.tableRows)||void 0===t?void 0:t.length)){let[t,...r]=e.tableRows;return(0,n.jsx)("div",{className:"overflow-x-auto rounded-lg border border-stroke-soft",children:(0,n.jsxs)("table",{className:"w-full border-collapse text-left text-sm",children:[(0,n.jsx)("thead",{className:"bg-elevation-minus2 text-primary",children:(0,n.jsx)("tr",{children:t.map((t,r)=>(0,n.jsx)("th",{className:"border-b border-stroke-soft px-3 py-2 font-semibold",children:(0,n.jsx)(eT,{text:eC(t).text})},"".concat(e.id,"-head-").concat(r)))})}),(0,n.jsx)("tbody",{children:r.map((r,s)=>(0,n.jsx)("tr",{className:"border-b border-stroke-soft last:border-b-0",children:t.map((t,i)=>{var o;let a=eC(null!==(o=r[i])&&void 0!==o?o:"");return(0,n.jsx)("td",{className:"min-w-[10rem] px-3 py-2 align-top text-secondary",children:(0,n.jsx)("div",{className:"flex flex-wrap items-start gap-2",children:(0,n.jsx)(eT,{text:a.text})})},"".concat(e.id,"-").concat(s,"-").concat(i))})},"".concat(e.id,"-row-").concat(s)))})]})},e.id)}return"heading"===e.kind?(0,n.jsx)(Q.x,{as:"h4",variant:1===e.level?"h3":"title",className:1===e.level?"pt-2":"pt-3",children:(0,n.jsx)(eT,{text:e.text})},e.id):(0,n.jsx)("div",{className:(0,X.cn)("min-w-0","bullet"===e.kind&&"border-l border-stroke-soft pl-3"),children:(0,n.jsx)("div",{className:"flex flex-wrap items-start gap-2 text-sm leading-6 text-secondary",children:(0,n.jsx)("span",{className:"min-w-0 flex-1",children:(0,n.jsx)(eT,{text:e.text})})})},e.id)})})})}function eL(e,t){return function(e,t){let r=(0,P.V)(e);if(!t)return r.replace(/\n{3,}/g,"\n\n").trim();let n=t.replace(/\.md$/i,""),s="(?:".concat(R(t),"|").concat(R(n),")");return r.replace(RegExp("^\\s*#{1,6}\\s+[`\"']?".concat(s,"[`\"']?\\s+(?=#{1,6}\\s+)"),"im"),"").replace(RegExp("^\\s*#{1,6}\\s+[`\"']?".concat(s,"[`\"']?\\s*$\\n?"),"im"),"").replace(RegExp("^\\s*[`\"']?".concat(s,"[`\"']?\\s*$\\n?"),"im"),"").replace(/\n{3,}/g,"\n\n").trim()}($(e),t)}function eI(e,t){var r,n,s;let i=ef(e);return eL((0,P.V)(null!==(s=null!==(n=null!==(r=i.markdown)&&void 0!==r?r:i.content)&&void 0!==n?n:i.md)&&void 0!==s?s:e),null==t?void 0:t.fileName)}function eA(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return/\.(png|jpe?g|webp|gif|svg)$/i.test(e)||/\.(png|jpe?g|webp|gif|svg)(\?|$)/i.test(t)||/^image\//i.test(r)}function eF(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return/\.(mp4|mov|webm|m4v)$/i.test(e)||/\.(mp4|mov|webm|m4v)(\?|$)/i.test(t)||/^video\//i.test(r)}function eE(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return/\.pdf$/i.test(e)||/\.pdf(\?|$)/i.test(t)||/pdf/i.test(r)}function eM(e){var t;let r=eb(e.originalFileUrl)||eb(e.fileUrl)||eb(e.uri)||eb(e.sourceUrl);if(r)return null!==(t=(0,C.kM)(r))&&void 0!==t?t:r;let n=S(e);return L(n)?n:""}function eP(e){let{src:t,alt:r,className:s}=e;return(0,n.jsxs)("div",{className:(0,X.cn)("relative isolate overflow-hidden bg-gradient-to-br from-selection-bg via-elevation-minus1 to-elevation-0",s),children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"absolute -right-10 -top-10 h-32 w-32 rounded-full border border-stroke-selection/40"}),(0,n.jsx)("span",{"aria-hidden":"true",className:"absolute -bottom-14 -left-10 h-40 w-40 rounded-full border border-stroke-selection/20"}),(0,n.jsx)("span",{"aria-hidden":"true",className:"absolute left-6 top-6 h-px w-12 bg-interactive-success/70"}),(0,n.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-4 text-center",children:[(0,n.jsx)("span",{className:"flex h-11 w-11 items-center justify-center rounded-full border border-stroke-selection/50 bg-elevation-minus2/70 text-selection-typography shadow-sm",children:(0,n.jsx)(l.Z,{className:"h-5 w-5"})}),(0,n.jsx)("span",{className:"mt-3 max-w-[85%] truncate text-xs font-semibold text-secondary",children:r})]}),(0,n.jsx)(Y.u,{src:t,alt:r,hideOnError:!0,skeleton:!1,className:"relative z-10 h-full w-full bg-elevation-0 object-contain"})]})}function eR(e){let t=eb(e.sourceUrl)||eb(e.uri);if(t)return t;let r=S(e);return L(r)?r:""}function eD(e){return eb(e.documentType)||eb(e.fileType)||eb(e.type)}function eB(e){let t=S(e),r=eM(e),n=eD(e);return!function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return/\.(md|markdown|txt|json|csv)$/i.test(e)||/markdown|plain|json|csv/i.test(t)}
1(t,n)&&(!!(eA(t,r,n)||eF(t,r,n)||eE(t,r,n)||function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return/\.fig$/i.test(e)||/figma\.com/i.test(t)||/figma/i.test(r)}(t,r,n)||function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return/\.(ttf|otf|woff2?)$/i.test(e)||/\.(ttf|otf|woff2?)(\?|$)/i.test(t)||/font/i.test(r)}(t,r,n)||function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return/\.(pptx?|key)$/i.test(e)||/\.(pptx?|key)(\?|$)/i.test(t)||/presentation|powerpoint|keynote/i.test(r)}(t,r,n)||function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return/\.(docx?|pages)$/i.test(e)||/\.(docx?|pages)(\?|$)/i.test(t)||/msword|officedocument|document/i.test(r)}(t,r,n)||function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return/\.zip$/i.test(e)||/\.zip(\?|$)/i.test(t)||/zip|archive/i.test(r)}(t,r,n))||/brand|logo|asset|guideline|figma|website|url|link|source/i.test(n)&&!!(t||r))}function eZ(e){let t=eb(e.id),r=eb(e.originalFileUrl)||eb(e.fileUrl),n=eR(e);return r?"preview":t&&!L(t)?"library":n?"external":"none"}function eO(e){let{sectionTitle:t,files:r,onClose:s,onAddFiles:i,uploadStatus:x="idle",uploadMessage:b}=e,y=(0,a.T)("workCreate.brandDnaPanel"),g="uploading"===x,v="partial"===x,[w,j]=(0,o.useState)(!1),[k,N]=(0,o.useState)(null),_=k?S(k)||y("files.fileFallback"):"",C=k?eM(k):"",T=k?eD(k)||y("files.fileTypeFallback"):"",F=!!k&&eA(_,C,T),E=!!k&&eE(_,C,T),M=!!k&&eF(_,C,T),P=!!(C&&L(C)&&!F&&!E&&!M),R=(0,o.useCallback)(e=>{"none"!==eZ(e)&&N(e)},[]),D=(0,o.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Array.from(e.dataTransfer.types).includes("Files")&&!g&&(e.dataTransfer.dropEffect="copy",j(!0))},[g]),B=(0,o.useCallback)(e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||j(!1)},[]),Z=(0,o.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),j(!1),!g&&e.dataTransfer.files.length>0&&i(e.dataTransfer.files)},[g,i]);return(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-overlay/60 px-4 py-6 safe-area-top safe-area-bottom safe-area-left safe-area-right",children:(0,n.jsxs)("div",{className:(0,X.cn)("max-h-[82vh] w-full max-w-3xl overflow-hidden rounded-2xl border bg-elevation-minus1 shadow-2xl transition-colors",w?"border-stroke-selection ring-1 ring-stroke-selection":"border-stroke-soft"),onDragOver:D,onDragLeave:B,onDrop:Z,children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-4 border-b border-stroke-soft px-5 py-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"font-mono text-[0.68rem] font-semibold uppercase tracking-[0.16em] text-selection-typography",children:y("files.eyebrow")}),(0,n.jsx)("h3",{className:"mt-1 font-display text-xl font-bold text-primary",children:y("files.title",{section:t})}),(0,n.jsx)("p",{className:"mt-1 text-sm leading-5 text-secondary",children:y("files.body")})]}),(0,n.jsx)("button",{type:"button",onClick:s,className:"rounded-full border border-stroke-soft bg-elevation-minus2 p-2 text-tertiary transition hover:border-stroke-hard hover:text-primary","aria-label":y("files.close"),children:(0,n.jsx)(d.Z,{className:"h-4 w-4"})})]}),(0,n.jsxs)("div",{className:"max-h-[56vh] overflow-y-auto px-5 py-4",children:["idle"!==x?(0,n.jsx)("div",{className:(0,X.cn)("mb-4 rounded-xl border px-4 py-3","error"===x?"border-status-error/50 bg-status-error/10":"border-selection-typography/45 bg-selection-typography/10"),children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)("div",{className:"mt-0.5 rounded-full bg-elevation-minus2 p-2",children:g?(0,n.jsx)(c.Z,{className:"h-4 w-4 animate-spin text-selection-typography"}):"error"===x?(0,n.jsx)(u.Z,{className:"h-4 w-4 text-status-error"}):(0,n.jsx)(m.Z,{className:"h-4 w-4 text-selection-typography"})}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-sm font-semibold text-primary",children:g?y("files.statusUploadingTitle"):"error"===x?y("files.statusErrorTitle"):v?y("files.statusPartialTitle"):y("files.statusQueuedTitle")}),(0,n.jsx)("p",{className:"mt-1 text-xs leading-5 text-secondary",children:b||(g?y("files.statusUploadingBody"):"error"===x?y("files.statusErrorBody"):v?y("files.statusPartialBody"):y("files.statusQueuedBody"))})]})]})}):null,k?(0,n.jsxs)("div",{className:"mb-4 overflow-hidden rounded-xl border border-stroke-soft bg-elevation-minus2",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b border-stroke-soft px-3 py-2",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"truncate text-sm font-semibold text-primary",children:_}),(0,n.jsx)("p",{className:"text-xs capitalize text-tertiary",children:T})]}),(0,n.jsx)("button",{type:"button",onClick:()=>N(null),className:"rounded-full border border-stroke-soft p-1.5 text-tertiary transition hover:border-stroke-hard hover:text-primary","aria-label":y("files.closePreview"),children:(0,n.jsx)(d.Z,{className:"h-3.5 w-3.5"})})]}),(0,n.jsx)("div",{className:"bg-elevation-minus1 p-3",children:C&&F?(0,n.jsx)(eP,{src:C,alt:_,className:"aspect-video max-h-[44vh] w-full rounded-lg"}):C&&E?(0,n.jsx)("iframe",{src:C,title:_,className:"h-[44vh] w-full rounded-lg border border-stroke-soft bg-elevation-0"}):C&&M?(0,n.jsx)("video",{src:C,controls:!0,className:"max-h-[44vh] w-full rounded-lg bg-elevation-0"}):C&&P?(0,n.jsx)("iframe",{src:C,title:_,className:"h-[44vh] w-full rounded-lg border border-stroke-soft bg-elevation-0"}):(0,n.jsx)("div",{className:"rounded-lg border border-stroke-soft bg-elevation-0 px-4 py-8 text-center text-sm text-secondary",children:y("files.previewUnavailable")})})]}):null,r.length>0?(0,n.jsx)("div",{className:"grid gap-3 sm:grid-cols-2",children:r.map((e,t)=>{let r=A(e,y("files.fileFallback")),s=eM(e),i=eD(e)||y("files.fileTypeFallback"),o=eA(r,s,i),a=eZ(e),d=I(eR(e));return(0,n.jsxs)("div",{className:"overflow-hidden rounded-xl border border-stroke-soft bg-elevation-minus2",children:[o?s?(0,n.jsx)(eP,{src:s,alt:r,className:"aspect-video w-full"}):(0,n.jsx)("div",{className:"flex aspect-video items-center justify-center bg-elevation-0",children:(0,n.jsx)(l.Z,{className:"h-6 w-6 text-tertiary"})}):null,(0,n.jsxs)("div",{className:"p-3",children:[(0,n.jsx)("p",{className:"truncate text-sm font-semibold text-primary",children:r}),(0,n.jsxs)("p",{className:"mt-1 flex items-center gap-1.5 text-xs capitalize text-tertiary",children:["external"===a&&d?(0,n.jsx)("img",{src:"https://www.google.com/s2/favicons?domain=".concat(encodeURIComponent(d),"&sz=32"),alt:"",className:"h-3.5 w-3.5 rounded-sm"}):"external"===a?(0,n.jsx)(p.Z,{className:"h-3.5 w-3.5"}):o?(0,n.jsx)(l.Z,{className:"h-3.5 w-3.5"}):(0,n.jsx)(f.Z,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{children:"external"===a&&d?d:i})]}),"none"!==a?(0,n.jsxs)("button",{type:"button",onClick:()=>R(e),className:"mt-3 inline-flex items-center gap-1.5 rounded-full border border-stroke-soft px-2.5 py-1 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:[(0,n.jsx)(f.Z,{className:"h-3.5 w-3.5"}),y("files.preview")]}):null,"processing"===eb(e.status)?(0,n.jsxs)("p",{className:"mt-2 inline-flex items-center gap-1.5 text-xs text-tertiary",children:[(0,n.jsx)(c.Z,{className:"h-3 w-3 animate-spin"}),y("files.processingSource")]}):null]})]},"".concat(r,":").concat(t))})}):(0,n.jsxs)("div",{className:(0,X.cn)("rounded-xl border border-dashed px-4 py-8 text-center text-sm transition-colors",w?"border-stroke-selection bg-selection-bg/20 text-selection-typography":"border-stroke-soft bg-elevation-minus2 text-secondary"),children:[(0,n.jsx)(h.Z,{className:"mx-auto mb-2 h-5 w-5"}),(0,n.jsx)("p",{className:"font-semibold text-primary",children:g?y("files.uploadingEmpty"):"queued"===x?y("files.queuedEmpty"):y("files.dropTitle")}),g||"queued"===x?null:(0,n.jsx)("p",{className:"mt-1 text-xs leading-5 text-secondary",children:y("files.dropDescription")})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2 border-t border-stroke-soft px-5 py-4",children:[(0,n.jsx)("button",{type:"button",onClick:s,className:"rounded-full border border-stroke-soft bg-elevation-minus2 px-4 py-2 text-sm font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:y("files.close")}),(0,n.jsxs)("label",{className:(0,X.cn)("inline-flex cursor-pointer items-center gap-2 rounded-full bg-interactive-primary px-4 py-2 text-sm font-semibold text-on-interactive-primary transition hover:opacity-90",g?"pointer-events-none opacity-70":""),children:[g?(0,n.jsx)(c.Z,{className:"h-4 w-4 animate-spin"}):(0,n.jsx)(h.Z,{className:"h-4 w-4"}),g?y("files.addingFiles"):y("files.addFiles"),(0,n.jsx)("input",{type:"file",multiple:!0,className:"sr-only",disabled:g,accept:".pdf,.doc,.docx,.ppt,.pptx,.key,.png,.jpg,.jpeg,.webp,.gif,.svg,.fig,.zip,.mp4,.mov,.m4v,.webm,.ttf,.otf,.w
1off,.woff2,application/pdf,image/png,image/jpeg,image/webp,image/gif,image/svg+xml,video/mp4,video/quicktime,video/webm,font/ttf,font/otf,font/woff,font/woff2",onChange:e=>{i(e.currentTarget.files),e.currentTarget.value=""}})]})]})]})})}async function eH(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[e],s=await fetch("/api/betterness-one/work/brand-dna",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({sectionId:e,markdown:t,summaryHtml:r,replacedSectionIds:n})});if(!s.ok)throw er(s.status);return(await s.json()).brandDna}function eU(e){var t,r,C,I,P,R,D,B,Z,O,H,U;let{onBack:z,onUpdated:K}=e,q=(0,a.T)("workCreate.brandDnaPanel"),W=(0,a.T)("b1Profile.brandReport"),$=(0,o.useRef)(K),[Y,Q]=(0,o.useState)(null),[ei,ea]=(0,o.useState)(null),[em,ej]=(0,o.useState)(!0),[ek,eN]=(0,o.useState)("idle"),[eC,eT]=(0,o.useState)(null),[eA,eF]=(0,o.useState)(!1),[eE,eM]=(0,o.useState)(!1),[eP,eD]=(0,o.useState)(!1),[eZ,eU]=(0,o.useState)(null),[ez,eK]=(0,o.useState)(null),[eq,eW]=(0,o.useState)(new Set),[e$,eV]=(0,o.useState)(null),[eG,eJ]=(0,o.useState)(null),[eX,eY]=(0,o.useState)({}),[eQ,e0]=(0,o.useState)({}),[e1,e2]=(0,o.useState)({}),[e3,e5]=(0,o.useState)({}),[e4,e6]=(0,o.useState)(null),[e7,e8]=(0,o.useState)(""),[e9,te]=(0,o.useState)(""),[tt,tr]=(0,o.useState)(null),[tn,ts]=(0,o.useState)(!1),[ti,to]=(0,o.useState)(!1),[ta,tl]=(0,o.useState)({}),[td,tc]=(0,o.useState)(""),[tu,tm]=(0,o.useState)(null),[tp,tf]=(0,o.useState)(!1),[th,tx]=(0,o.useState)(""),[tb,ty]=(0,o.useState)(!1),tg=(0,o.useRef)(new Map),tv=(0,o.useRef)(new Map),tw=(0,o.useRef)(new Map),tj=(0,o.useRef)(null),tk=(0,o.useRef)(new Map),tN=(0,o.useRef)(null),t_=(0,o.useRef)([]),tC=(0,o.useRef)(null);(0,o.useEffect)(()=>{$.current=K},[K]);let tT=(0,o.useCallback)(async()=>{eT(null);try{var e,t,r;let n=await fetch("/api/betterness-one/work/brand-dna",{cache:"no-store"});if(!n.ok)throw Error("failed_to_load");let s=await n.json();Q(s.brandDna),to((null===(e=s.permissions)||void 0===e?void 0:e.manageSettings)===!0),null===(t=$.current)||void 0===t||t.call($,s.brandDna);try{let e=await fetch("/api/betterness-one/brand-intelligence",{cache:"no-store"});if(e.ok){let t=await e.json().catch(()=>null),n=null==t?void 0:null===(r=t.record)||void 0===r?void 0:r.leadReport,s="string"==typeof(null==n?void 0:n.slug)?n.slug.trim():"",i=!!s&&"string"==typeof(null==n?void 0:n.publicUrl)&&n.publicUrl.trim().length>0;ea(i?"/strategic-report/reports/".concat(encodeURIComponent(s)):null)}}catch(e){ea(null)}return s.brandDna}catch(e){return eT(q("errors.load")),null}finally{ej(!1)}},[q]);(0,o.useEffect)(()=>{tT();let e=tw.current,t=tk.current;return()=>{e.forEach(e=>clearTimeout(e)),e.clear(),t.forEach(e=>clearTimeout(e)),t.clear()}},[tT]);let tS=(0,o.useMemo)(()=>ef(null==Y?void 0:Y.analysis),[null==Y?void 0:Y.analysis]),tL=(0,o.useMemo)(()=>ef(null==Y?void 0:Y.sourceSummary),[null==Y?void 0:Y.sourceSummary]),tI=(0,o.useMemo)(()=>ef(tS.brand_foundation_sections),[tS]),tA=(0,o.useMemo)(()=>{let e=ef(tS.brand_foundation_pending_import),t=eh(e.sections);return{status:eb(e.status),source:eb(e.source),importId:eb(e.importId),workflowId:eb(e.workflowId),createdAt:eg(e.createdAt),createdAtRaw:eb(e.createdAt),sections:t,batches:eh(e.batches),conflicts:eh(e.conflicts)}},[tS]),tF=(0,o.useMemo)(()=>ef(tS.brand_foundation_import_status),[tS]),tE=(0,o.useMemo)(()=>eh(tL.brand_foundation_import_log),[tL]),tM=(0,o.useMemo)(()=>eh(tL.brand_foundation_source_documents),[tL]);(0,o.useMemo)(()=>ef(tL.brand_foundation_evidence_summary),[tL]);let tP=(0,o.useMemo)(()=>eh(tL.brand_foundation_versions),[tL]),tR=(0,o.useMemo)(()=>ef(tL.brand_foundation_refresh_reminder),[tL]),tD=!0===tR.enabled?eg(tR.nextRefreshAt):null,tB=(0,o.useCallback)(function(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],r=M.X0.get(e);if(!r)return"";let n=eI(ef(tI[r.id]),r);return(0,M.US)(n,e3[r.id],t)},[tI,e3]),tZ=(0,o.useCallback)(e=>{let t=new Set(ed(e));return tA.sections.filter(e=>t.has(eb(e.id)))},[tA.sections]),tO=(0,o.useCallback)(function(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],r=ed(e),n=tB(e.id,t);if(r.length>1&&n&&r.slice(1).some(e=>{let t=M.X0.get(e);return!!t&&n.includes(q(ec(t)))}))return eL(n,e.fileName);let s=r.flatMap(n=>{let s=M.X0.get(n);if(!s)return[];let i=tB(n,t);return i?1===r.length?[eL(i,e.fileName)]:["## ".concat(q(ec(s)),"\n\n").concat(V(i))]:[]});return eL(s.join("\n\n---\n\n"),e.fileName)},[tB,q]),tH=(0,o.useCallback)(e=>{let t=ed(e),r=tZ(e).flatMap(r=>{var n;let s=eb(r.id),i=null!==(n=M.X0.get(s))&&void 0!==n?n:e,o=eI(r,i);return o?1===t.length?[eL(o,e.fileName)]:["## ".concat(q(ec(i)),"\n\n").concat(V(o))]:[]});return eL(r.join("\n\n---\n\n"),e.fileName)},[tZ,q]),tU=(0,o.useMemo)(()=>{let e=[];for(let t of eo){let r=tO(t);r&&e.push("".concat(q(ep(t)),": ").concat(r.slice(0,800)))}return e.slice(0,24)},[tO,q]),tz=(0,o.useMemo)(()=>{var e;
1return e={approvedById:tI,pendingSections:tA.sections},eo.map(t=>{let r=t.childSectionIds;return e.pendingSections.some(e=>r.includes(eb(e.id)))?{section:t,status:"needs_review"}:{section:t,status:r.some(t=>!!eI(ef(e.approvedById[t]),es(t)))?"approved":"not_started"}})},[tI,tA.sections]),tK=(0,o.useMemo)(()=>new Set(tz.filter(e=>"needs_review"===e.status).map(e=>e.section.id)),[tz]),tq=(0,o.useMemo)(()=>({stats:tz,completed:tz.filter(e=>"approved"===e.status).length,total:eo.length}),[tz]),tW=Math.round(tq.completed/tq.total*100),t$=eb(tF.status),tV=eP||"running"===t$,tG=tA.sections.length>0,tJ=tV?(H=ey(tF.progressPercent),U=eP?5:10,null===H?U:Math.max(0,Math.min(100,Math.round(H)))):0,tX=null!==(C=ey(tF.progressCurrent))&&void 0!==C?C:0,tY=null!==(I=ey(tF.progressTotal))&&void 0!==I?I:0,tQ=[t$,eb(tF.importId),eb(tF.finishedAt),tA.importId,tA.createdAtRaw].filter(Boolean).join(":"),t0=eZ!==tQ&&(tV||"failed"===t$),t1=(0,o.useMemo)(()=>[...tP.map(e=>{var t,r;return{key:eb(e.id)||eb(e.createdAt)||eb(e.updatedAt),date:null!==(t=eg(e.createdAt))&&void 0!==t?t:eg(e.updatedAt),detail:eb(e.source)||eb(e.label)||q("history.approvedSnapshot"),count:null!==(r=ey(e.sections))&&void 0!==r?r:ey(e.sectionCount)}}),...tE.map(e=>{var t,r,n;return{key:eb(e.importId)||eb(e.importedAt)||eb(e.finishedAt),date:null!==(r=null!==(t=eg(e.importedAt))&&void 0!==t?t:eg(e.finishedAt))&&void 0!==r?r:eg(e.createdAt),detail:q("history.importedSource"),count:null!==(n=ey(e.sectionsUpdated))&&void 0!==n?n:ey(e.sectionsPendingReview)}})].filter(e=>e.date).slice(0,8),[tE,q,tP]),t2=(0,o.useCallback)(e=>{let t=Array.from(new Set(e.filter(Boolean)));if(t.length)for(let e of(eW(e=>{let r=new Set(e);return t.forEach(e=>r.add(e)),r}),t)){let t=tw.current.get(e);t&&clearTimeout(t);let r=setTimeout(()=>{eW(t=>{let r=new Set(t);return r.delete(e),r}),tw.current.delete(e)},1800);tw.current.set(e,r)}},[]);(0,o.useEffect)(()=>{if(!Y)return;let e=new Map;for(let t of eo)e.set(t.id,tO(t,!1));let t=tN.current;tN.current=e,t&&t2(eo.filter(r=>{var n,s,i;return(null!==(n=t.get(r.id))&&void 0!==n?n:"")!==(null!==(s=e.get(r.id))&&void 0!==s?s:"")&&(null!==(i=e.get(r.id))&&void 0!==i?i:"").length>0}).map(e=>e.id))},[Y,tO,t2]),(0,o.useEffect)(()=>{t2(Array.from(tK))},[t2,tK]),(0,o.useEffect)(()=>{if(!eP&&"running"!==t$)return;let e=!1,t=async()=>{let t=await tT(),r=eb(ef(null==t?void 0:t.analysis).brand_foundation_import_status&&ef(ef(null==t?void 0:t.analysis).brand_foundation_import_status).status);!e&&r&&"running"!==r&&eD(!1)};t();let r=setInterval(()=>void t(),3e3);return()=>{e=!0,clearInterval(r)}},[t$,tT,eP]),(0,o.useEffect)(()=>{let e=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&eK(t.target.id)},{rootMargin:"-20% 0px -70% 0px",threshold:0});return tg.current.forEach(t=>e.observe(t)),()=>e.disconnect()},[em]);let t3=(0,o.useCallback)(e=>t=>{t?tg.current.set(e,t):tg.current.delete(e)},[]),t5=(0,o.useCallback)(e=>t=>{t?tv.current.set(e,t):tv.current.delete(e)},[]),t4=(0,o.useCallback)((e,t,r)=>{tl(r=>({...r,[e]:t}));let n=tk.current.get(e);if(n&&clearTimeout(n),!r)return;let s=setTimeout(()=>{tl(t=>{let r={...t};return delete r[e],r}),tk.current.delete(e)},r);tk.current.set(e,s)},[]),t6=(0,o.useCallback)(e=>{let t=tg.current.get(e);t&&(t.scrollIntoView({behavior:"smooth",block:"start"}),eK(e))},[]),t7=(0,o.useCallback)(async()=>{eD(!0),await tT()},[tT]),t8=(0,o.useCallback)(async()=>{eF(!1),await tT()},[tT]),t9=(0,o.useCallback)(async(e,t)=>{if(!(null==t?void 0:t.length))return;eY(t=>({...t,[e.id]:"uploading"})),e0(t=>{let r={...t};return delete r[e.id],r}),eT(null);let r=Array.from(t),n=[],s=[];for(let t of r)try{var i,o,a,l;let r=new FormData;r.append("file",t),r.append("section_id",e.id),r.append("section_title",q(ep(e))),r.append("source_lane","documents");let s=await fetch("/api/betterness-one/work/brand-dna/sources/upload",{method:"POST",body:r}),d=await s.json().catch(()=>({})),c=null!==(i=d.knowledgeDocumentId)&&void 0!==i?i:d.knowledge_document_id;if(!s.ok||!c)throw Error(d.error||d.details||q("files.fileUploadUnknownReason"));n.push({knowledgeDocumentId:c,name:d.filename||d.title||t.name,fileUrl:null!==(o=d.fileUrl)&&void 0!==o?o:null,mimeType:null!==(l=null!==(a=d.mimeType)&&void 0!==a?a:t.type)&&void 0!==l?l:null})}catch(e){s.push({name:t.name,reason:e instanceof Error&&e.message?e.message:q("files.fileUploadUnknownReason")})}if(!n.length){eY(t=>
1({...t,[e.id]:"error"})),e0(t=>{var r,n;return{...t,[e.id]:1===s.length?q("files.uploadErrorWithReason",{file:(null===(r=s[0])||void 0===r?void 0:r.name)||q("files.fileUploadUnknownFile"),reason:(null===(n=s[0])||void 0===n?void 0:n.reason)||q("files.fileUploadUnknownReason")}):q("files.uploadError")}}),eD(!1);return}e2(t=>{var r;return{...t,[e.id]:[...n.map(t=>({id:t.knowledgeDocumentId,fileName:t.name,title:t.name,documentType:t.mimeType||"brand_file",originalFileUrl:t.fileUrl||"",sectionId:e.id,source:"brand_file",status:"processing"})),...null!==(r=t[e.id])&&void 0!==r?r:[]]}});let d=s.length?q("files.uploadPartial",{stored:n.length,total:r.length,failed:s.length}):"";eY(t=>({...t,[e.id]:s.length?"partial":"queued"})),e0(t=>{let r={...t};return d?r[e.id]=d:delete r[e.id],r}),eD(!0);try{await fetch("/api/betterness-one/work/brand-dna/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"other",source_lane:"documents",source_inputs:{contextNote:["Section upload for ".concat(q(ep(e)),"."),"Analyze these source files for this Brand Guide section first.","If the evidence clearly belongs in another section too, include that as downstream notes rather than silently changing approved sections."].join(" ")},file_types:[e.id],attachment_names:n.map(e=>e.name),knowledge_document_ids:n.map(e=>e.knowledgeDocumentId)})}).then(async e=>{if(!e.ok)throw Error("section_import_failed")});try{await tT()}catch(e){}}catch(t){eY(t=>({...t,[e.id]:"error"})),e0(t=>({...t,[e.id]:q("files.importStartError",{count:n.length})}));return}},[tT,q]),re=(0,o.useCallback)(async(e,t)=>{eN("saving");let r=!1;try{var n;let s=await fetch("/api/betterness-one/work/brand-dna/import/decision",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({decision:e,sectionIds:t})});if(!s.ok)throw Error("failed_to_decide");let i=await s.json();Q(i.brandDna),null===(n=$.current)||void 0===n||n.call($,i.brandDna),r=!0,eT(null),"apply"===e&&t2((t&&t.length?t:tA.sections.map(e=>eb(e.id))).map(el))}catch(e){eT(q(en(e)?"errors.transientSave":"errors.save"))}finally{eN(r?"saved":"error")}},[t2,tA.sections,q]),rt=(0,o.useCallback)(e=>{let t=ed(e),r=new Set(t),n=t.map(e=>ef(tI[e])),s=tA.sections.filter(e=>r.has(eb(e.id)));return[...[...new Set([...n.flatMap(e=>[...ex(e.sourceFileNames),...eh(e.sourceFileNames).map(e=>eb(e.name)).filter(Boolean),...eh(e.assetReferences).map(e=>eb(e.name)).filter(Boolean)]),...s.flatMap(e=>[...ex(e.sourceFileNames),...eh(e.sourceFileNames).map(e=>eb(e.name)).filter(Boolean),...eh(e.assetReferences).map(e=>eb(e.name)).filter(Boolean)]),...tM.filter(e=>r.has(eb(e.sectionId))).map(e=>eb(e.fileName)||eb(e.title)||eb(e.id)).filter(Boolean)])].slice(0,16).map(e=>"Source or asset: ".concat(e)),...[...n.map(e=>eb(e.provenanceNotes)),...s.map(e=>eb(e.provenanceNotes))].filter(Boolean).map(e=>"Provenance note: ".concat(e))].slice(0,30)},[tI,tA.sections,tM]),rr=(0,o.useCallback)(e=>{let t=ed(e),r=new Set(t),n=t.map(e=>ef(tI[e])),s=tA.sections.filter(e=>r.has(eb(e.id))),i=new Set([...n.flatMap(e=>[...ex(e.sourceDocumentIds),...eh(e.sourceDocumentIds).map(e=>eb(e.id)).filter(Boolean)]),...s.flatMap(e=>[...ex(e.sourceDocumentIds),...eh(e.sourceDocumentIds).map(e=>eb(e.id)).filter(Boolean)])]),o=new Set([...n.flatMap(e=>[...ex(e.sourceFileNames),...eh(e.sourceFileNames).map(e=>eb(e.name)||eb(e)).filter(Boolean),...eh(e.assetReferences).map(e=>eb(e.name)).filter(Boolean)]),...s.flatMap(e=>[...ex(e.sourceFileNames),...eh(e.sourceFileNames).map(e=>eb(e.name)||eb(e)).filter(Boolean),...eh(e.assetReferences).map(e=>eb(e.name)).filter(Boolean)])]),a=new Map;[...n,...s].forEach(e=>{eh(e.assetReferences).forEach(e=>{let t=eb(e.name),r=eb(e.thumbnailUrl)||eb(e.url);t&&!a.has(t)&&a.set(t,r)})});let l=t.flatMap(e=>{var t;return null!==(t=e1[e])&&void 0!==t?t:[]}),d=tM.filter(e=>{let t=eb(e.id),n=eb(e.fileName)||eb(e.title),s=eR(e),a=eb(e.sectionId);return a?r.has(a):t&&i.has(t)||n&&o.has(n)||s&&o.has(s)}).filter(eB),c=new Map;[...d,...l.filter(eB)].forEach(e=>{let t=eb(e.id)||eb(e.fileName)||eb(e.title);
1t&&!c.has(t)&&c.set(t,e)});let u=Array.from(o).filter(e=>!c.has(e)).filter(e=>a.has(e)||L(e));return Array.from(c.values()).concat(u.map(e=>({fileName:e,documentType:"asset_reference",...a.get(e)?{fileUrl:a.get(e)}:{}})).filter(eB)).slice(0,24)},[tI,e1,tA.sections,tM]),rn=(0,o.useCallback)(async function(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[e.id];eN("saving");let s=!1;try{var i;let o=await eH(e.id,t,r,n);return Q(o),null===(i=$.current)||void 0===i||i.call($,o),s=!0,eT(null),t2([e.id]),e5(t=>{let r={...t};return delete r[e.id],r}),!0}catch(e){return eT(q(en(e)?"errors.transientSave":"errors.save")),!1}finally{eN(s?"saved":"error")}},[t2,q]),rs=(0,o.useCallback)((e,t)=>{e6(e.id),te(""),e8(t)},[]),ri=(0,o.useCallback)(()=>{e6(null),e8(""),te("")},[]),ro=(0,o.useCallback)(async(e,t)=>{let r=eL(e7,e.fileName);if(r===t){ri();return}await rn(e,r,ew(e_(r)),e.childSectionIds)&&ri()},[ri,rn,e7]),ra=(0,o.useCallback)(async(e,t,r)=>{let n=eL(e7,e.fileName);if(n===t){await re("apply",r),ri();return}await rn(e,n,ew(e_(n)),e.childSectionIds)&&(await re("discard",r),ri())},[ri,re,rn,e7]),rl=(0,o.useCallback)(async e=>{eN("saving"),ts(!0);let t=!1;try{var r;let n=await fetch("/api/betterness-one/work/brand-dna",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:"section",sectionId:e.id,replacedSectionIds:e.childSectionIds})});if(!n.ok)throw er(n.status);let s=await n.json();if(tj.current!==e.id)return;Q(s.brandDna),null===(r=$.current)||void 0===r||r.call($,s.brandDna),t=!0,eT(null),t2([e.id,...e.childSectionIds]),tr(null),ri()}catch(e){eT(q(en(e)?"errors.transientSave":"errors.save"))}finally{ts(!1),eN(t?"saved":"error")}},[ri,t2,q]);(0,o.useEffect)(()=>{tj.current=tt},[tt]),(0,o.useCallback)(async(e,t,r)=>{let n=eL(function(e,t,r){let n=Array.from(new Set(t.map(e=>e.trim().toUpperCase()).filter(e=>G.test(e)))),s=Array.from(new Set(r.map(e=>e.trim()).filter(Boolean))),i=(function(e,t){let r=t.flags.replace(/[gy]/g,""),n=t.source,s=new RegExp("(?:^|\\n)##[ \\t]+(?:".concat(n,")[^\\n]*\\n(?:(?!\\n## )[\\s\\S])*"),"g".concat(r));return e.replace(s,"")})(e,J).replace(/^[ \t]*[-*]?[ \t]*(?:colors?|fonts?|typefaces?|typography)\b[^\n]*:[^\n]*$\n?/gim,"").replace(/\n{3,}/g,"\n\n").replace(/\s+$/,""),o=[];return(n.length&&o.push("".concat("## Colors","\n\n").concat(n.map(e=>"- ".concat(e)).join("\n"))),s.length&&o.push("".concat("## Type","\n\n").concat(s.map(e=>"- Font: ".concat(e)).join("\n"))),o.length)?[i,...o].filter(Boolean).join("\n\n"):i}(tB(e.id,!1).replace(/^(?:\s*#{1,2}[ \t]+[^\n]*\n+)+/,""),t,r),e.fileName),s=ew(e_(n));await rn(e,n,s)},[tB,rn]);let rd=(0,o.useCallback)(async function(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];ty(!0),tc(""),tm(null),tx("");try{let n=await fetch("/api/betterness-one/work/brand-dna/interview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"question",sectionId:e.id,sectionTitle:q(ep(e)),sectionPurpose:q(eu(e)),answered:t_.current,currentMarkdown:tO(e),pendingMarkdown:tH(e),brandSummary:tU,sourceSummary:rt(e),questionId:null==t?void 0:t.questionId,questionText:null==t?void 0:t.questionText,disposition:null==t?void 0:t.disposition,answer:null==t?void 0:t.answer,retry:r})}),s=await n.json().catch(()=>null),i=null==s?void 0:s.question,o="string"==typeof i?i.trim():"string"==typeof(null==i?void 0:i.text)?i.text.trim():"",a="object"==typeof i&&i&&"string"==typeof i.id?i.id:null;n.ok&&o?(tf(!1),tm(a),tc(o)):tf(!0)}catch(e){tf(!0)}finally{ty(!1)}},[tU,tO,tH,rt,q]),rc=(0,o.useCallback)(async(e,t)=>{try{return(await fetch("/api/betterness-one/work/brand-dna/interview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"question",sectionId:e.id,questionId:tu,questionText:td,disposition:t,resolveOnly:!0})})).ok}catch(e){return!1}},[td,tu]),ru=(0,o.useCallback)(async(e,t)=>{var r,n;let s=tO(e),i=null!==(r=t_.current[t_.current.length-1])&&void 0!==r?r:"";try{let r=await fetch("/api/betterness-one/work/brand-dna/interview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"synthesize",sectionId:e.id,sectionTitle:q(ep(e)),sectionPurpose:q(eu(e)),answered:t_.current,currentMarkdown:s,pendingMarkdown:tH(e),brandSummary:tU,sourceSummary:rt(e),replacedSectionIds:e.childSectionIds,questionId:null==t?void 0:t.questionId,questionText:null==t?void 0:t.questionText,disposition:t?"answered":void 0,answer:null==t?void 0:t.answer})}),i=r.ok?await r.json():null;if(null==i?void 0:i.brandDna)return Q(i.brandDna),null===(n=$.current)||void 0===n||n.call($,i.brandDna),eN("saved"),t2([e.id]),!0;throw Error(r.ok?"empty_brand_synthesis":"synthesis_http_".concat(r.status))}catch(t){return console.error("[brand-dna] section synthesis failed",{sectionId:e.id,hadAnswer:!!i,reason:t instanceof Error?t.message:"unknown"}),eT(q("errors.save")),!1}},[tU,tO,t2,tH,rt,q]),rm=(0,o.useCallback)((e,t)=>{let r=t.trim();if(!r)return;let n=td?"".concat(td,"\nOwner answer: ").concat(r):r;t_.current=[...t_.current,n].slice(-12),t4(e.id,"updating"),ru(e,{questionId:tu,questionText:td,answer:r}).then(async t=>{t4(e.id,t?"updated":"needs_attention",t?5e3:void 0),t&&await rd(e)})},[rd,td,tu,t4,ru]);(0,o.useCallback)((e,t)=>{tC.current!==e.id&&(t_.current=[]),tC.current=e.id,eV(e.id),ty(!0),fetch("/api/betterness-one/work/brand-dna/interview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"question",sectionId:e.id,questionText:t,disposition:"focused",resolveOnly:!0})}).then(async e=>{var t,r;let n=e.ok?await e.json():null,s="string"==typeof(null==n?void 0:null===(t=n.question)||void 0===t?void 0:t.id)?n.question.id:"",i="string"==typeof(null==n?void 0:null===(r=n.question)||void 0===r?void 0:r.text)?n.question.text.trim():"";if(!s||!i)throw Error("focused question was not persisted");tf(!1),tm(s),tc(i),tx(i)}).catch(()=>{eT(q("errors.save"))}).finally(()=>{ty(!1)}),window.setTimeout(()=>{var t;let r=tv.current.get(e.id),n=tg.current.get(ev(e.id));null===(t=null!=r?r:n)||void 0===t||t.scrollIntoView({behavior:"smooth",block:"start"})},80)},[q]);let rp=(0,o.useCallback)(e=>{if(e$===e.id){rc(e,"dismissed").then(e=>{e?(eV(null),tc(""),tm(null),tx("")):eT(q("errors.save"))});return}t_.current=[],tC.current=e.id,eV(e.id),rd(e),window.setTimeout(()=>{var t;let r=tv.current.get(e.id),n=tg.current.get(ev(e.id));null===(t=null!=r?r:n)||void 0===t||t.scrollIntoView({behavior:"smooth",block:"start"})},80)}
1,[rd,e$,rc,q]),rf=(0,o.useCallback)(e=>{rd(e,{disposition:"skipped",questionId:tu,questionText:td})},[rd,td,tu]),rh=(0,o.useCallback)(e=>{rc(e,"completed").then(e=>{if(!e){eT(q("errors.save"));return}eV(null),tc(""),tm(null),tx("")})},[rc,q]);(0,o.useEffect)(()=>{if(!td){tx("");return}tx("");let e=0,t=setInterval(()=>{e=Math.min(e+2,td.length),tx(td.slice(0,e)),e>=td.length&&clearInterval(t)},18);return()=>clearInterval(t)},[td]);let rx=null!==(P=eg(tF.importedAt))&&void 0!==P?P:eg(tF.finishedAt),rb=eg(null==Y?void 0:Y.updatedAt),ry=eG?eo.find(e=>e.id===eG):void 0,rg=ry?rr(ry):[],rv=tt&&null!==(R=eo.find(e=>e.id===tt))&&void 0!==R?R:null;return(0,n.jsxs)("div",{className:"relative min-h-0 flex-1 overflow-y-auto bg-elevation-minus2 p-4 sm:p-6",children:[(0,n.jsx)(ee.s,{isOpen:null!==rv,title:rv?q("reset.title",{section:q(ep(rv))}):"",description:rv?q("reset.description",{section:q(ep(rv))}):"",confirmLabel:q("reset.confirm"),cancelLabel:q("ownerReadable.cancel"),isConfirming:tn,onCancel:()=>tr(null),onConfirm:()=>{rv&&rl(rv)}}),eA?(0,n.jsx)(E.Z9,{mode:"brand",onClose:()=>eF(!1),onComplete:t8,onImportQueued:t7}):null,ry?(0,n.jsx)(eO,{sectionTitle:q(ec(ry)),files:rg,onClose:()=>eJ(null),uploadStatus:eX[ry.id],uploadMessage:eQ[ry.id],onAddFiles:e=>void t9(ry,e)}):null,(0,n.jsxs)("div",{className:"mx-auto flex w-full max-w-7xl gap-6 rounded-2xl border border-stroke-soft bg-elevation-minus1 p-3 sm:p-6",children:[(0,n.jsxs)("aside",{className:"sticky top-4 hidden w-[220px] flex-shrink-0 self-start lg:block",children:[(0,n.jsxs)("div",{className:"rounded-xl border border-stroke-soft bg-elevation-minus1 p-4",children:[(0,n.jsxs)("div",{className:"mb-4",children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,n.jsx)("span",{className:"font-mono text-[0.7rem] font-semibold uppercase tracking-[0.14em] text-selection-typography",children:q("foundationTitle")}),(0,n.jsxs)("span",{className:"text-xs text-secondary",children:[tq.completed,"/",tq.total]})]}),(0,n.jsx)("div",{className:"h-2 w-full rounded-full bg-elevation-0",children:(0,n.jsx)("div",{className:"h-full rounded-full bg-selection-typography transition-all duration-300",style:{width:"".concat(tW,"%")}})})]}),(0,n.jsx)("nav",{className:"flex flex-col gap-0.5",children:tq.stats.map(e=>{let{section:t,status:r}=e,s=ev(t.id),i=ez===s,o=eq.has(t.id),a="needs_review"===r;return(0,n.jsxs)("button",{type:"button",onClick:()=>t6(s),className:(0,X.cn)("flex w-full items-center gap-2 rounded-lg border px-3 py-2 text-left text-sm transition-all duration-500",o?"border-stroke-selection/50 bg-selection-bg/10 font-medium text-primary":a?"border-transparent font-medium text-primary":"border-transparent text-secondary hover:bg-elevation-0/50 hover:text-primary",i&&!o?"bg-elevation-1 font-medium text-primary":""),children:[(0,n.jsx)("span",{className:"flex-1 truncate",children:q(ep(t))}),a?(0,n.jsx)("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full border-[1.5px] border-stroke-selection bg-selection-bg/40",children:(0,n.jsx)(x.Z,{className:"h-2.5 w-2.5 text-selection-typography"})}):"approved"===r?(0,n.jsx)("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full border-[1.5px] border-stroke-selection",children:(0,n.jsx)(m.Z,{className:"h-2.5 w-2.5 text-selection-typography"})}):null]},t.id)})})]}),(0,n.jsxs)("div",{className:"mt-3 rounded-xl border border-stroke-soft bg-elevation-minus1 p-3",children:[(0,n.jsxs)("div",{className:"mb-3 flex items-center -space-x-2",children:[[{src:"/images/landing/chatgpt-logo.png",label:q("imports.providers.chatgpt")},{src:"/images/landing/claude-logo.png",label:q("imports.providers.claude")},{src:"/images/landing/gemini-logo.png",label:q("imports.providers.gemini")}].map(e=>(0,n.jsx)("img",{src:e.src,alt:e.label,className:"h-7 w-7 rounded-full border border-stroke-soft bg-elevation-0 object-cover"},e.src)),(0,n.jsx)("span",{className:"flex h-7 w-7 items-center justify-center rounded-full border border-stroke-soft bg-elevation-0 text-[0.65rem] font-semibold text-tertiary",children:"+"})]}),(0,n.jsx)("p",{className:"text-sm font-semibold text-primary",children:q("imports.contextTitle")}),(0,n.jsx)("p",{className:"mt-1 text-xs leading-5 text-secondary",children:q("imports.contextBody")}),(0,n.jsx)("p",{className:"mt-2 text-[0.7rem] leading-4 text-tertiary",children:q("imports.timeSaved")}),(0,n.jsxs)("div",{className:"mt-3 rounded-lg border border-stroke-soft bg-elevation-0 px-3 py-2",children:[(0,n.jsx)("p",{className:"text-[0.68rem] font-semibold uppercase tracking-[0.14em] text-tertiary",children:q("imports.logTitle")}),(0,n.jsx)("p",{className:"mt-1 text-xs text-secondary",children:tV?q("imports.logRunning"):tG?q("imports.logPending"):rx?q("imports.lastImported",{date:rx}):q("imports.neverImported")}),(0,n.jsx)("p",{className:"mt-1 text-[0.7rem] text-tertiary",children:tE.length>0?q("imports.sourceSummary",{count:null!==(B=null!==(D=ey(null===(t=tE[0])||void 0===t?void 0:t.sectionsUpdated))&&void 0!==D?D:ey(null===(r=tE[0])||void 0===r?void 0:r.sectionsPendingReview))&&void 0!==B?B:0}):q("imports.logIdleDetail")}),tD?(0,n.jsx)("p",{className:"mt-1 text-[0.7rem] text-tertiary",children:q("imports.nextRefresh",{date:tD})}):null]}),(0,n.jsxs)("button",{type:"button",onClick:()=>eF(!0),className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg border border-stroke-soft bg-elevation-0 px-3 py-2 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:[(0,n.jsx)(h.Z,{className:"h-3.5 w-3.5"}),q("imports.openImport")]})]})]}),(0,n.jsxs)("main",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"mb-4 rounded-xl border border-stroke-soft bg-elevation-minus1 p-3 lg:hidden",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"font-mono text-[0.68rem] font-semibold uppercase tracking-[0.14em] text-selection-typography",children:q("foundationTitle")}),(0,n.jsxs)("p",{className:"mt-1 text-xs text-secondary",children:[tq.completed,"/",tq.total]})]}),(0,n.jsx)("div",{className:"h-2 min-w-[112px] flex-1 rounded-full bg-elevation-0",children:(0,n.jsx)("div",{className:"h-full rounded-full bg-selection-typography transition-all duration-300",style:{width:"".concat(tW,"%")}})})]}),(0,n.jsx)("nav",{className:"-mx-1 mt-3 flex snap-x gap-2 overflow-x-auto px-1 pb-1","aria-label":q("foundationTitle"),children:tq.stats.map(e=>{let{section:t,status:r}=e,s=ev(t.id),i=ez===s,o="needs_review"===r;return(0,n.jsxs)("button",{type:"button",onClick:()=>t6(s),className:(0,X.cn)("flex min-w-[150px] snap-start items-center gap-2 rounded-lg border px-3 py-2 text-left text-xs transition",o?"border-stroke-soft bg-elevation-0 font-medium text-primary":i?"border-stroke-selection bg-elevation-1 font-medium text-primary":"border-stroke-soft bg-elevation-0 text-secondary"),children:[(0,n.jsx)("span",{className:"flex-1 truncate",children:q(ep(t))}),o?(0,n.jsx)("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-full border-[1.5px] border-stroke-selection bg-selection-bg/40",children:(0,n.jsx)(x.Z,{className:"h-2.5 w-2.5 text-selection-typography"})}):"approved"===r?(0,n.jsx)("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-full border-[1.5px] border-stroke-selection",children:(0,n.jsx)(m.Z,{className:"h-2.5 w-2.5 text-selection-typography"})}):null]},t.id)})})]}),(0,n.jsxs)("div",{className:"mb-4 flex flex-col gap-3 border-b border-stroke-soft/40 pb-4 sm:flex-row sm:items-start sm:justify-between md:pr-[84px]",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,n.jsx)("button",{type:"button",onClick:z,className:"mt-0.5 inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full border border-stroke-soft bg-elevation-minus1 text-secondary transition hover:border-stroke-hard hover:text-primary","aria-label":q("back"),
1children:(0,n.jsx)(b.Z,{className:"h-4 w-4"})}),(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"font-display text-xl font-bold text-primary",children:q("title")}),(0,n.jsxs)("p",{className:"mt-1 text-sm text-secondary",children:[q("knowsLabel")," \xb7 ",tW,"%"]})]})]}),(0,n.jsxs)("div",{className:"flex w-full flex-wrap items-center gap-2 sm:w-auto sm:shrink-0",children:[ei?(0,n.jsxs)("a",{href:ei,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-2 rounded-full border border-stroke-selection bg-selection-bg/20 px-3 py-1.5 text-xs font-semibold text-primary transition hover:bg-selection-bg/30",children:[W("viewReport"),(0,n.jsx)(p.Z,{className:"h-3.5 w-3.5"})]}):null,"idle"!==ek?(0,n.jsxs)("div",{className:"flex items-center gap-2 rounded-full border border-stroke-soft bg-elevation-minus1 px-3 py-1 text-xs text-secondary",children:["saving"===ek?(0,n.jsx)(y.Z,{className:"h-3.5 w-3.5 animate-spin"}):null,"saved"===ek?(0,n.jsx)(m.Z,{className:"h-3.5 w-3.5 text-interactive-success"}):null,"error"===ek?(0,n.jsx)(u.Z,{className:"h-3.5 w-3.5 text-destructive"}):null,(0,n.jsx)("span",{children:"saving"===ek?q("saving"):"saved"===ek?q("saved"):q("saveError")})]}):null,(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>eM(e=>!e),className:(0,X.cn)("inline-flex items-center gap-2 rounded-full border bg-elevation-minus1 px-3 py-1.5 text-xs font-semibold text-secondary transition hover:text-primary",eE?"border-stroke-selection text-primary":"border-stroke-soft hover:border-stroke-hard"),"aria-expanded":eE,children:[(0,n.jsx)(g.Z,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{children:rb?q("contextSavedAt",{date:rb}):q("contextNotSaved")}),t1.length>0?(0,n.jsx)("span",{className:"rounded-full bg-elevation-0 px-1.5 py-0.5 text-[0.65rem] text-tertiary",children:t1.length}):null]}),eE?(0,n.jsxs)("div",{className:"absolute right-0 top-10 z-20 w-[320px] rounded-xl border border-stroke-soft bg-elevation-minus2 p-4 shadow-2xl",children:[(0,n.jsxs)("div",{className:"mb-3 flex items-start justify-between gap-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"font-mono text-[0.68rem] font-semibold uppercase tracking-[0.16em] text-tertiary",children:q("history.title")}),(0,n.jsx)("p",{className:"mt-1 text-xs leading-5 text-secondary",children:q("history.body")})]}),(0,n.jsx)("button",{type:"button",onClick:()=>eM(!1),className:"rounded-full border border-stroke-soft bg-elevation-minus1 px-2 py-1 text-xs text-secondary transition hover:border-stroke-hard hover:text-primary",children:q("history.close")})]}),t1.length>0?(0,n.jsx)("div",{className:"space-y-2",children:t1.map((e,t)=>(0,n.jsxs)("div",{className:"rounded-lg border border-stroke-soft bg-elevation-0 px-3 py-2",children:[(0,n.jsx)("p",{className:"text-sm font-semibold text-primary",children:e.date}),(0,n.jsx)("p",{className:"mt-0.5 text-xs text-secondary",children:e.count?q("history.entryWithCount",{source:e.detail,count:e.count}):e.detail})]},e.key||"".concat(e.date,":").concat(t)))}):(0,n.jsx)("div",{className:"rounded-lg border border-stroke-soft bg-elevation-0 px-3 py-3 text-xs text-secondary",children:q("history.empty")})]}):null]})]})]}),eC?(0,n.jsxs)("div",{className:"mb-4 flex items-center gap-2 rounded-xl border border-destructive/30 bg-caution-primary/20 px-3 py-2 text-sm text-primary",children:[(0,n.jsx)(u.Z,{className:"h-4 w-4 text-destructive"}),eC]}):null,t0?(0,n.jsx)("div",{className:(0,X.cn)("mb-4 rounded-xl border px-4 py-3","failed"===t$?"border-destructive/40 bg-caution-primary/20":tG||"imported"===t$?"border-stroke-selection bg-selection-bg/20":"border-stroke-hard bg-elevation-0"),children:(0,n.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,n.jsx)("div",{className:"mt-0.5 flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full border border-stroke-soft bg-elevation-minus2",children:"failed"===t$?(0,n.jsx)(u.Z,{className:"h-4 w-4 text-destructive"}):tG?(0,n.jsx)(x.Z,{className:"h-4 w-4 text-selection-typography"}):"imported"===t$?(0,n.jsx)(m.Z,{className:"h-4 w-4 text-selection-typography"}):(0,n.jsx)(c.Z,{className:"h-4 w-4 animate-spin text-selection-typography"})}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"font-mono text-[0.68rem] font-semibold uppercase tracking-[0.16em] text-tertiary",children:q("imports.statusEyebrow")}),(0,n.jsx)("h3",{className:"mt-1 font-display text-base font-semibold text-primary",children:"failed"===t$?q("imports.status.failedTitle"):tG?q("imports.status.reviewTitle"):"imported"===t$?q("imports.status.importedTitle"):q("imports.status.processingTitle")}),(0,n.jsx)("p",{className:"mt-1 text-sm leading-5 text-secondary",children:"failed"===t$?q("imports.status.failedBody"):tG?q("imports.status.reviewBody",{count:tA.sections.length}):"imported"===t$?q("imports.status.importedBody",{count:null!==(Z=ey(tF.sectionsUpdated))&&void 0!==Z?Z:0}):q("imports.status.processingBody",{count:null!==(O=ey(tF.progressTotal))&&void 0!==O?O:0})}),tV?(0,n.jsxs)("div",{className:"mt-3 max-w-xl",children:[(0,n.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-3 text-[0.72rem] text-tertiary",children:[(0,n.jsx)("span",{children:q("imports.status.progressStages.".concat(eb(tF.progressStage)||"preparing"))}),(0,n.jsx)("span",{children:tY>0?q("imports.status.progressFiles",{current:tX,total:tY}):q("imports.status.progressPercent",{percent:tJ})})]}),(0,n.jsx)("div",{className:"h-1.5 overflow-hidden rounded-full bg-elevation-minus2",children:(0,n.jsx)("div",{className:"h-full rounded-full bg-selection-typography transition-all duration-500",style:{width:"".concat(tJ,"%")}})})]}):null]})]}),(0,n.jsxs)("div",{className:"flex flex-shrink-0 gap-2",children:[tG?(0,n.jsx)("button",{type:"button",onClick:()=>{var e;return null===(e=document.getElementById("brand-import-review"))||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})},className:"rounded-full border border-stroke-selection bg-elevation-minus2 px-3 py-2 text-xs font-semibold text-primary transition hover:bg-selection-bg/20",children:q("imports.status.reviewAction")}):null,"failed"===t$?(0,n.jsx)("button",{type:"button",onClick:()=>eF(!0),className:"rounded-full bg-interactive-primary px-3 py-2 text-xs font-semibold text-on-interactive-primary transition hover:opacity-90",children:q("imports.status.tryAgain")}):null,tV?null:(0,n.jsx)("button",{type:"button",onClick:()=>eU(tQ),className:"rounded-full border border-stroke-soft bg-elevation-minus2 p-2 text-tertiary transition hover:border-stroke-hard hover:text-primary","aria-label":q("imports.status.dismiss"),title:q("imports.status.dismiss"),children:(0,n.jsx)(d.Z,{className:"h-4 w-4"})})]})]})}):null,tA.sections.length>0?(0,n.jsx)("div",{id:"brand-import-review",className:"mb-4 rounded-xl border border-warning/40 bg-caution-primary/20 px-4 py-3",children:(0,n.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,n.jsx)("h3",{className:"font-display text-base font-semibold text-primary",children:q("imports.reviewTitle")}),(0,n.jsx)("span",{className:"text-xs text-secondary",children:q("imports.reviewEach")})]})}):null,tA.sections.length>0?(0,n.jsxs)("div",{className:"sticky top-0 z-20 mb-3 flex flex-wrap items-center gap-3 rounded-xl border border-stroke-soft bg-elevation-1/95 px-4 py-2.5 shadow-sm backdrop-blur",children:[(0,n.jsx)(x.Z,{className:"h-4 w-4 shrink-0 text-selection-typography","aria-hidden":!0}),(0,n.jsx)("p",{className:"min-w-0 flex-1 text-xs font-medium text-primary",children:q("imports.pendingCount",{count:tA.sections.length})}),(0,n.jsx)("button",{type:"button",onClick:()=>
1void re("discard"),className:"rounded-full border border-stroke-soft bg-elevation-minus2 px-3 py-1.5 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:q("draft.discard")}),(0,n.jsx)("button",{type:"button",onClick:()=>void re("apply"),className:"rounded-full bg-interactive-primary px-3 py-1.5 text-xs font-semibold text-on-interactive-primary transition hover:opacity-90",children:q("imports.approveAll")})]}):null,em?(0,n.jsxs)("div",{className:"flex items-center gap-2 py-16 text-sm text-secondary",children:[(0,n.jsx)(s.c,{shape:"form"}),q("loading")]}):(0,n.jsx)("div",{className:"flex flex-col gap-4 xl:flex-row xl:items-start",children:(0,n.jsx)("div",{className:"min-w-0 flex-1 space-y-4",children:eo.map(e=>{var t,r;let s=ev(e.id),o=tO(e,!1),a=tZ(e),d=a[0],p=tH(e),h=a.map(e=>eb(e.id)).filter(Boolean),b=d?p:o,y=d&&(ex(d.sourceFileNames)[0]||eh(d.sourceFileNames).map(e=>eb(e.name)).find(Boolean)||tA.source)||q("draft.sourceFallback"),g=(t=rr(e),r=q("files.fileFallback"),t.map(e=>{let t=S(e),n=T(e.id),s=L(t)&&!n?t:"";return{key:n||s||A(e,r),label:A(e,r),href:s,isImage:/\.(png|jpe?g|webp|gif|svg)$/i.test(t)}}).filter((e,t,r)=>!!e.label&&r.findIndex(t=>t.key===e.key)===t).slice(0,8)),C=eq.has(e.id),I=e$===e.id,E=ta[e.id];return(0,n.jsxs)("section",{id:s,ref:t3(s),className:(0,X.cn)("flex flex-col rounded-xl border bg-elevation-minus2 p-4 transition-all duration-500 sm:p-5",C?"border-stroke-selection/50 ring-1 ring-stroke-selection/40":"border-stroke-soft"),children:[(0,n.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("h3",{className:"font-display text-lg font-bold text-primary",children:q(ep(e))}),(0,n.jsx)("p",{className:"mt-1 text-sm leading-5 text-secondary",children:q(eu(e))})]}),(0,n.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-2",children:[!d&&o&&e4!==e.id?(0,n.jsxs)("button",{type:"button",onClick:()=>rs(e,o),className:"inline-flex items-center gap-2 rounded-full bg-interactive-primary px-3 py-2 text-xs font-semibold text-on-interactive-primary transition hover:opacity-90",children:[(0,n.jsx)(v.Z,{className:"h-3.5 w-3.5"}),q("ownerReadable.edit")]}):null,d||o?null:(0,n.jsxs)("button",{type:"button",onClick:()=>rp(e),"aria-expanded":I,className:"inline-flex items-center gap-2 rounded-full bg-interactive-primary px-3 py-2 text-xs font-semibold text-on-interactive-primary transition hover:opacity-90",children:[(0,n.jsx)(x.Z,{className:"h-3.5 w-3.5"}),q("interviewMe")]}),b||o&&ti?(0,n.jsxs)("details",{className:"group relative",children:[(0,n.jsx)("summary",{className:"flex h-8 w-8 cursor-pointer list-none items-center justify-center rounded-full border border-stroke-soft text-secondary transition hover:border-stroke-hard hover:text-primary","aria-label":q("menu.label"),children:(0,n.jsx)(w.Z,{className:"h-4 w-4"})}),(0,n.jsxs)("div",{className:"absolute right-0 top-10 z-20 w-48 rounded-xl border border-stroke-soft bg-elevation-minus1 p-1.5 shadow-2xl",children:[b?(0,n.jsxs)("button",{type:"button",onClick:()=>(function(e,t){let r=new Blob([t||""],{type:"text/markdown;charset=utf-8"});(0,i.l)(r,e).catch(e=>console.warn("[brand-dna] download failed",e))})(e.fileName,b),className:"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-xs text-secondary transition hover:bg-elevation-0 hover:text-primary",children:[(0,n.jsx)(j.Z,{className:"h-3.5 w-3.5"}),q("downloadMd")]}):null,b?(0,n.jsxs)("button",{type:"button",onClick:()=>rp(e),className:"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-xs text-secondary transition hover:bg-elevation-0 hover:text-primary",children:[(0,n.jsx)(x.Z,{className:"h-3.5 w-3.5"}),q("interviewMe")]}):null,o&&ti?(0,n.jsxs)("button",{type:"button",onClick:()=>tr(e.id),className:"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-xs text-secondary transition hover:bg-elevation-0 hover:text-destructive",children:[(0,n.jsx)(k.Z,{className:"h-3.5 w-3.5"}),q("reset.action")]}):null]})]}):null]})]}),I?(0,n.jsxs)("div",{ref:t5(e.id),className:"order-2 mt-3 rounded-xl border border-stroke-soft bg-elevation-0 p-3",children:[(0,n.jsx)("p",{className:"font-mono text-xs uppercase tracking-[0.16em] text-tertiary",children:q("interview.interviewer")}),(0,n.jsx)("p",{className:"mt-2 min-h-[1.75rem] max-w-2xl text-base leading-7 text-primary",children:tp?(0,n.jsx)("span",{className:"text-secondary",children:q("interview.unavailable")}):tb&&!th?(0,n.jsx)("span",{className:"text-tertiary",children:"..."}):(0,n.jsxs)(n.Fragment,{children:[th,th.length<td.length?(0,n.jsx)("span",{className:"ml-0.5 inline-block animate-pulse text-tertiary",children:"|"}):null]})}),tp?null:(0,n.jsx)("div",{className:"mt-3",children:(0,n.jsx)(F.x,{lockedAgentId:"betti",hideRealtimeVoice:!0,borderlessComposer:!0,hideLimitBanner:!0,onSubmitCapture:t=>rm(e,t),placeholder:q("interview.placeholder")})}),(0,n.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[tp?(0,n.jsx)("button",{type:"button",onClick:()=>void rd(e,void 0,!0),disabled:tb,className:"inline-flex items-center rounded-full border border-stroke-soft bg-elevation-minus2 px-3 py-1.5 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary disabled:cursor-not-allowed disabled:opacity-50",children:q("interview.retry")}):(0,n.jsx)("button",{type:"button",onClick:()=>rf(e),disabled:tb,className:"inline-flex items-center rounded-full border border-stroke-soft bg-elevation-minus2 px-3 py-1.5 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary disabled:cursor-not-allowed disabled:opacity-50",children:q("interview.skipQuestion")}),(0,n.jsx)("button",{type:"button",onClick:()=>rh(e),className:"inline-flex items-center rounded-full border border-stroke-soft bg-elevation-minus2 px-3 py-1.5 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:q("interview.done")})]}),E?(0,n.jsxs)("div",{className:(0,X.cn)("mt-3 inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs font-semibold","updated"===E?"border-stroke-selection bg-selection-bg/20 text-selection-typography":"needs_attention"===E?"border-warning/40 bg-caution-primary/20 text-warning":"border-stroke-soft bg-elevation-minus2 text-secondary"),role:"status","aria-live":"polite",children:["updated"===E?(0,n.jsx)(m.Z,{className:"h-3.5 w-3.5"}):"needs_attention"===E?(0,n.jsx)(u.Z,{className:"h-3.5 w-3.5"}):(0,n.jsx)(c.Z,{className:"h-3.5 w-3.5 animate-spin"}),(0,n.jsx)("span",{children:"updated"===E?q("interview.acceptance.updated",{section:q(ep(e))}):"needs_attention"===E?q("interview.acceptance.needsAttention"):q("interview.acceptance.updating")})]}):null]}):null,(0,n.jsx)("div",{className:"mt-5 rounded-xl bg-elevation-minus1 p-4",children:e4===e.id?(0,n.jsxs)("div",{children:[(0,n.jsx)("textarea",{value:e7,onChange:e=>e8(e.target.value),rows:12,"aria-label":q("editableSectionLabel",{section:q(ep(e))}),className:"w-full resize-y rounded-lg border border-stroke-medium bg-elevation-minus2 px-3 py-3 text-sm leading-6 text-primary outline-none transition focus:border-stroke-hover"}),(0,n.jsxs)("div",{className:"mt-3 flex justify-end gap-2",children:[(0,n.jsx)("button",{type:"button",onClick:ri,className:"rounded-full border border-stroke-soft px-3 py-2 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:q("ownerReadable.cancel")}),(0,n.jsxs)("button",{type:"button",onClick:()=>void(d?ra(e,p,h):ro(e,o)),disabled:"saving"===ek,className:"inline-flex items-center gap-2 rounded-full bg-interactive-primary px-3 py-2 text-xs font-semibold text-on-interactive-primary transition hover:opacity-90 disabled:opacity-50",children:[(0,n.jsx)(N.Z,{className:"h-3.5 w-3.5"}),q("ownerReadable.save")]})]})]}):d?(0,n.jsxs)("div",{className:(0,X.cn)("transition-all duration-500",C&&"rounded-lg bg-selection-bg/15 ring-2 ring-stroke-selection"),children:[(0,n.jsxs)("div",{className:"-mx-4 -mt-4 mb-4 flex flex-col gap-2 rounded-t-xl border-b border-warning/40 bg-caution-primary/20 px-4 py-2.5 sm:flex-row sm:items-center sm:justify-between",children:[(0,n.jsx)("p",{className:"text-xs font-semibold text-primary",children:q("draft.fromSource",{source:y})}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,n.jsx)("button",{type:"button",onClick:()=>void re("apply",h),className:"rounded-full bg-interactive-primary px-3 py-1.5 text-xs font-semibold text-on-interactive-primary transition hover:opacity-90",children:q("draft.approve")}),(0,n.jsx)("button",{type:"button",onClick:()=>rs(e,p),className:"rounded-full border border-stroke-soft bg-elevation-minus2 px-3 py-1.5 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:q("ownerReadable.edit")}),(0,n.jsx)("button",{type:"button",onClick:()=>void re("discard",h),className:"rounded-full border border-stroke-soft bg-elevation-minus2 px-3 py-1.5 text-xs font-semibold text-secondary transition hover:border-destructive hover:text-destructive",children:q("draft.discard")})]})]}),(0,n.jsx)(eS,{markdown:p})]}):o?(0,n.jsx)("div",{className:(0,X.cn)("transition-all duration-500",C&&"rounded-lg bg-selection-bg/15 ring-2 ring-stroke-selection"),children:(0,n.jsx)(eS,{markdown:o})}):(0,n.jsxs)("div",{className:"flex flex-col items-start gap-3 py-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,n.jsx)("p",{className:"text-sm text-secondary",children:q("emptySection")}),(0,n.jsx)("button",{type:"button",onClick:()=>eF(!0),className:"rounded-full border border-stroke-soft px-3 py-1.5 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:q("empty.import")})]})}),g.length>0?(0,n.jsx)("div",{className:"order-2 mt-3 flex flex-wrap gap-2",children:g.map(t=>{let r="inline-flex items-center gap-1.5 rounded-full border border-stroke-soft bg-elevation-minus1 px-2.5 py-1 text-[0.7rem] text-secondary transition hover:border-stroke-hard hover:text-primary",s=t.isImage?(0,n.jsx)(l.Z,{className:"h-3 w-3"}):(0,n.jsx)(f.Z,{className:"h-3 w-3"});return t.href?(0,n.jsxs)("a",{href:t.href,target:"_blank",rel:"noreferrer",className:r,children:[s,t.label]},t.key):(0,n.jsxs)("button",{type:"button",onClick:()=>eJ(e.id),className:r,children:[s,t.label]},t.key)})}):null,["visual_identity","social_channels"].includes(e.id)?(0,n.jsxs)("button",{type:"button",onClick:()=>(0,et.navigateSPA)("library","/library"),className:"order-3 mt-3 inline-flex items-center gap-1 text-xs text-tertiary transition hover:text-primary",children:[q("libraryAssets"),(0,n.jsx)(_.Z,{className:"h-3.5 w-3.5"})]}):null]},e.id)})})})]})]})]})}},78541:function(e,t,r){r.d(t,{Z9:function(){return Y}});var n=r(57437),s=r(9585),i=r(2265),o=r(38706),a=r(76010),l=r(54887),d=r(82222),c=r(70094),u=r(76357),m=r(44925),p=r(69879),f=r(30401),h=r(78867),x=r(88156),b=r(48736),y=r(32489),g=r(51817),v=r(76858),w=r(21419),j=r(706),k=r(14565),N=r(46414),_=r(11877),C=r(94457),T=r(27151),S=r(85830);let L=["source","files","input","preview","refresh"],I=new Set(["soul","memory","health"]);function A(e){if(1===e.length&&e[0])return e[0].fileType;let t=e.map(e=>e.fileType);return t.some(e=>I.has(e))?"soul":t.includes("history")?"history":"preferences"}let F=["identity","role_responsibilities","current_priorities","team_relationships","tools_systems","communication_style","goals_priorities","preferences_constraints","domain_knowledge","decision_log"],E={identity:{labelKey:"business.templates.identity.label",descriptionKey:"business.templates.identity.description",recommended:!0,promptKey:"business.templates.identity.prompt"},role_responsibilities:{labelKey:"business.templates.roleResponsibilities.label",descriptionKey:"business.templates.roleResponsibilities.description",recommended:!0,promptKey:"business.templates.roleResponsibilities.prompt"},current_priorities:{labelKey:"business.templates.currentPriorities.label",descriptionKey:"business.templates.currentPriorities.description",recommended:!0,promptKey:"business.templates.currentPriorities.prompt"},team_relationships:{labelKey:"business.templates.teamRelationships.label",descriptionKey:"business.templates.teamRelationships.description",recommended:!0,promptKey:"business.templates.teamRelationships.prompt"},tools_systems:{labelKey:"business.templates.toolsSystems.label",descriptionKey:"business.templates.toolsSystems.description",recommended:!0,promptKey:"business.templates.toolsSystems.prompt"},communication_style:{labelKey:"business.templates.communicationStyle.label",descriptionKey:"business.templates.communicationStyle.de
1scription",recommended:!0,promptKey:"business.templates.communicationStyle.prompt"},goals_priorities:{labelKey:"business.templates.goalsPriorities.label",descriptionKey:"business.templates.goalsPriorities.description",recommended:!0,promptKey:"business.templates.goalsPriorities.prompt"},preferences_constraints:{labelKey:"business.templates.preferencesConstraints.label",descriptionKey:"business.templates.preferencesConstraints.description",recommended:!0,promptKey:"business.templates.preferencesConstraints.prompt"},domain_knowledge:{labelKey:"business.templates.domainKnowledge.label",descriptionKey:"business.templates.domainKnowledge.description",recommended:!0,promptKey:"business.templates.domainKnowledge.prompt"},decision_log:{labelKey:"business.templates.decisionLog.label",descriptionKey:"business.templates.decisionLog.description",recommended:!0,promptKey:"business.templates.decisionLog.prompt"}};function M(e){return F.includes(e)?E[e]:null}let P=_.Nh;function R(e){let t=_.X0.get(e);return t?{labelKey:"brand.templates.".concat(t.i18nKey,".label"),descriptionKey:"brand.templates.".concat(t.i18nKey,".description"),recommended:!1,promptKey:"brand.templates.".concat(t.i18nKey,".prompt")}:null}function D(e){let{currentStep:t,mode:r}=e,s=(0,o.T)("settings.profile.importWizard"),i="brand"===r?["input","refresh"]:L,a=i.indexOf(t),l="done"===t?i.length-1:Math.max(0,a);return(0,n.jsx)("div",{className:"flex items-center justify-center gap-0 px-8 py-5",children:i.map((e,t)=>{let o=t<l,a=t===l;return(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:(0,C.cn)("w-3 h-3 rounded-full border-2 shrink-0 transition-colors",o&&"bg-interactive-primary border-interactive-primary",a&&"border-interactive-primary bg-transparent",t>l&&"border-stroke-medium bg-transparent"),children:a&&(0,n.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-interactive-primary m-[1px]"})}),(0,n.jsx)("span",{className:(0,C.cn)("text-xs whitespace-nowrap",a||o?"text-primary":"text-tertiary"),children:"brand"===r?s("brand.steps.".concat(e)):s("steps.".concat(e))})]}),t<i.length-1&&(0,n.jsx)("div",{className:(0,C.cn)("w-16 h-px mx-3",t<l?"bg-interactive-primary":"bg-stroke-medium")})]},e)})})}let B={chatgpt:(0,n.jsx)(function(e){let{className:t}=e;return(0,n.jsx)("svg",{className:t,viewBox:"0 0 42 42",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:(0,n.jsx)("path",{d:"M39.2342 17.19C40.1931 14.3301 39.8629 11.1971 38.3295 8.59576C36.0235 4.60576 31.3876 2.55301 26.8601 3.51901C24.8459 1.26413 21.9521-0.0181802 18.9184 0.000194806C14.2904-0.0103052 10.1842 2.95069 8.76045 7.32657C5.78743 7.93163 3.2212 9.78094 1.7195 12.402C-0.603703 16.3815-0.07408 21.3979 3.02969 24.8104C2.07083 27.6703 2.40101 30.8033 3.93441 33.4046C6.24045 37.3946 10.8763 39.4474 15.4038 38.4814C17.4167 40.7363 20.3118 42.0186 23.3455 41.9989C27.9761 42.0107 32.0837 39.0471 33.5074 34.6673C36.4804 34.0622 39.0467 32.2129 40.5484 29.5918C42.8689 25.6123 42.338 20.5999 39.2355 17.1874L39.2342 17.19ZM23.3482 39.2544C21.4952 39.2571 19.7003 38.6126 18.2778 37.4327C18.3425 37.3986 18.4548 37.3369 18.5274 37.2923L26.9433 32.4623C27.3738 32.2194 27.638 31.764 27.6354 31.2718V19.4816L31.1921 21.5226C31.2304 21.5409 31.2555 21.5777 31.2608 21.6197V31.3834C31.2555 35.7251 27.7172 39.2453 23.3482 39.2544ZM6.33158 32.0318C5.40309 30.4384 5.06894 28.5707 5.38724 26.7581C5.44932 26.7949 5.55894 26.8618 5.63686 26.9064L14.0527 31.7364C14.4793 31.9845 15.0076 31.9845 15.4355 31.7364L25.7097 25.8407V29.9226C25.7123 29.9646 25.6925 30.0053 25.6595 30.0315L17.1525 34.9127C13.3633 37.0809 8.52403 35.7921 6.3329 32.0318H6.33158ZM4.11667 13.7762C5.0412 12.1802 6.50064 10.9596 8.23875 10.3256C8.23875 10.3978 8.23479 10.5251 8.23479 10.6144V20.2757C8.23215 20.7666 8.4963 21.222 8.92554 21.4648L19.1997 27.3593L15.6429 29.4002C15.6072 29.4238 15.5623 29.4278 15.5227 29.4107L7.01441 24.5256C3.23309 22.3494 1.93611 17.5418 4.11535 13.7775L4.11667 13.7762ZM33.3397 20.5343L23.0655 14.6385L26.6223 12.5989C26.658 
112.5753 26.7029 12.5713 26.7425 12.5884L35.2508 17.4696C39.0388 19.6444 40.3371 24.4599 38.1486 28.2242C37.2227 29.8176 35.7646 31.0382 34.0278 31.6734V21.7234C34.0318 21.2325 33.7689 20.7784 33.341 20.5343H33.3397ZM36.8793 15.2396C36.8172 15.2016 36.7076 15.1359 36.6297 15.0913L28.2138 10.2613C27.7872 10.0133 27.2589 10.0133 26.831 10.2613L16.5569 16.1571V12.0752C16.5542 12.0332 16.574 11.9925 16.6071 11.9663L25.114 7.08901C28.9033 4.91682 33.7478 6.20963 35.9323 9.97651C36.8555 11.5673 37.1897 13.4297 36.8767 15.2396H36.8793ZM14.6233 22.5148L11.0652 20.4739C11.0269 20.4555 11.0018 20.4188 10.9965 20.3768V10.6131C10.9991 6.26607 14.548 2.74332 18.9223 2.74594C20.7727 2.74594 22.5637 3.39169 23.9861 4.56769C23.9214 4.60182 23.8104 4.66351 23.7365 4.70813L15.3206 9.53813C14.8901 9.78094 14.6259 10.2351 14.6286 10.7273L14.6233 22.5122V22.5148ZM16.5555 18.3752L21.132 15.7489L25.7084 18.3739V23.6252L21.132 26.2502L16.5555 23.6252V18.3752Z"})})},{className:"w-8 h-8 text-primary"}),claude:(0,n.jsx)(function(e){let{className:t}=e;return(0,n.jsx)("svg",{className:t,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,n.jsx)("path",{d:"M7.84658 26.6001L15.7175 22.1865L15.8498 21.8032L15.7175 21.59H15.3339L14.0185 21.509L9.52124 21.3875L5.62091 21.2255L1.84212 21.0231L0.891351 20.8206L0 19.6464L0.0918371 19.0606L0.891351 18.5234L2.0366 18.6233L4.56749 18.7961L8.36518 19.0579L11.1203 19.2199L15.2016 19.6437H15.8498L15.9417 19.3818L15.7202 19.2199L15.5473 19.0579L11.6173 16.3963L7.36309 13.5835L5.13472 11.9638L3.93004 11.1432L3.3223 10.3739L3.0603 8.69483L4.15423 7.49089L5.62361 7.59077L5.99905 7.69065L7.48734 8.8352L10.6665 11.2944L14.818 14.3501L15.4258 14.8549L15.6689 14.6821L15.6986 14.5607L15.4258 14.1045L13.1677 10.0256L10.7583 5.87664L9.686 4.1571L9.40239 3.12593C9.30245 2.70212 9.22952 2.3458 9.22952 1.91119L10.4747 0.221354L11.1635 0L12.8246 0.221354L13.5242 0.828724L14.556 3.18801L16.228 6.90242L18.821 11.953L19.58 13.4512L19.9851 14.8387L20.1364 15.2625H20.3984V15.0196L20.6118 12.1744L21.0061 8.68134L21.3897 4.1868L21.522 2.92077L22.1487 1.4037L23.3939 0.583076L24.3663 1.04738L25.1658 2.19193L25.055 2.93157L24.5796 6.01971L23.6478 10.8571L23.04 14.0964H23.3939L23.799 13.6915L25.4386 11.5157L28.1937 8.07397L29.4091 6.70806L30.8272 5.19908L31.7375 4.48104H33.458L34.7248 6.36253L34.1576 8.30612L32.3857 10.552L30.9163 12.4551L28.8095 15.2895L27.4941 17.557L27.6156 17.7379L27.929 17.7082L32.6882 16.6959L35.2596 16.2316L38.328 15.7052L39.7164 16.3531L39.8676 17.0117L39.322 18.3588L36.0402 19.1686L32.1912 19.9379L26.4596 21.293L26.3894 21.3443L26.4704 21.4442L29.0526 21.6871L30.1573 21.7465H32.8611L37.8959 22.1217L39.2113 22.991L40 24.0545L39.8676 24.8644L37.8419 25.8955L35.1084 25.2477L28.7285 23.7306L26.5406 23.1853H26.2381V23.3662L28.0613 25.1478L31.4025 28.163L35.5865 32.0502L35.7999 33.0112L35.2623 33.7697L34.6951 33.6888L31.019 30.9246L29.6009 29.6801L26.3894 26.978H26.176V27.2614L26.9161 28.3439L30.8245 34.2151L31.0271 36.0157L30.7435 36.6014L29.7306 36.9551L28.6177 36.7526L26.3299 33.543L23.9692 29.9285L22.065 26.6892L21.8327 26.8214L20.709 38.9175L20.1823 39.5357L18.9668 40L17.9539 39.2307L17.4164 37.9862L17.9539 35.5271L18.6022 32.3175L19.1289 29.7665L19.6043 26.5974L19.8879 25.5446L19.869 25.4744L19.6367 25.5041L17.2463 28.7839L13.6106 33.6942L10.734 36.7715L10.0452 37.0441L8.85138 36.426L8.96212 35.3219L9.62928 34.3393L13.6106 29.2779L16.0119 26.1412L17.5623 24.3299L17.5515 24.068H17.4597L6.885 30.9299L5.00236 31.1729L4.19205 30.4144L4.29198 29.1699L4.67553 28.765L7.85468 26.5785L7.84388 26.5893L7.84658 26.6001Z",fill:"#D97757"})})},{className:"w-8 h-8"}),gemini:(0,n.jsx)(function(e){let{className:t}=e;return(0,n.jsxs)("svg",{className:t,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,n.jsxs)("g",{clipPath:"url(#gClip)",children:[(0,n.jsx)("mask",{id:"gMask",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"-1",y:"0",width:"21",height:"20",children:(0,n.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.65636 15.4301C9.1677 16.5961 9.42337 17.8421 9.42337 19.1678C9.42337 17.8421 9.6708 16.5961 10.166 15.4301C10.677 14.2641 11.3639 13.2498 12.2264 12.3872C13.0892 
111.5247 14.1033 10.8458 15.2693 10.3506C16.4353 9.83949 17.6815 9.58394 19.007 9.58394C17.6815 9.58394 16.4353 9.33635 15.2693 8.84115C14.1033 8.33004 13.0892 7.64318 12.2264 6.78064C11.3639 5.91807 10.677 4.90378 10.166 3.73773C9.6708 2.57168 9.42337 1.32577 9.42337 0C9.42337 1.32577 9.1677 2.57168 8.65636 3.73773C8.1615 4.90378 7.48246 5.91807 6.62 6.78064C5.75754 7.64318 4.7431 8.33004 3.57706 8.84115C2.41101 9.33635 1.16524 9.58394-0.160645 9.58394C1.16524 9.58394 2.41101 9.83949 3.57706 10.3506C4.7431 10.8458 5.75754 11.5247 6.62 12.3872C7.48246 13.2498 8.1615 14.2641 8.65636 15.4301Z",fill:"white"})}),(0,n.jsx)("g",{mask:"url(#gMask)",children:(0,n.jsx)("path",{d:"M173.256-170.486H-138.222V86.0521H173.256V-170.486Z",fill:"url(#gGrad)"})})]}),(0,n.jsxs)("defs",{children:[(0,n.jsxs)("linearGradient",{id:"gGrad",x1:"-100.472",y1:"48.8285",x2:"53.8928",y2:"11.3684",gradientUnits:"userSpaceOnUse",children:[(0,n.jsx)("stop",{stopColor:"#439DDF"}),(0,n.jsx)("stop",{offset:"0.524208",stopColor:"#4F87ED"}),(0,n.jsx)("stop",{offset:"0.781452",stopColor:"#9476C5"}),(0,n.jsx)("stop",{offset:"0.888252",stopColor:"#BC688E"}),(0,n.jsx)("stop",{offset:"1",stopColor:"#D6645D"})]}),(0,n.jsx)("clipPath",{id:"gClip",children:(0,n.jsx)("rect",{width:"19.0909",height:"19.0909",fill:"white"})})]})]})},{className:"w-8 h-8"}),other:(0,n.jsx)(d.Z,{className:"w-8 h-8 text-secondary"})};function Z(e){let{selected:t,onSelect:r,mode:s,brandSourceLane:i,onSelectBrandSourceLane:a}=e,l=(0,o.T)("settings.profile.importWizard"),f=(0,o.T)("settings.profile.importWizard.sources"),h=["chatgpt","claude","gemini","other"];if("brand"===s){let e=[{id:"ai",icon:(0,n.jsx)(d.Z,{className:"h-7 w-7 text-secondary"}),label:l("brand.sourceLanes.ai.label"),description:l("brand.sourceLanes.ai.description")},{id:"documents",icon:(0,n.jsx)(c.Z,{className:"h-7 w-7 text-secondary"}),label:l("brand.sourceLanes.documents.label"),description:l("brand.sourceLanes.documents.description")},{id:"website",icon:(0,n.jsx)(u.Z,{className:"h-7 w-7 text-secondary"}),label:l("brand.sourceLanes.website.label"),description:l("brand.sourceLanes.website.description")},{id:"figma",icon:(0,n.jsx)(m.Z,{className:"h-7 w-7 text-secondary"}),label:l("brand.sourceLanes.figma.label"),description:l("brand.sourceLanes.figma.description")},{id:"connections",icon:(0,n.jsx)(p.Z,{className:"h-7 w-7 text-secondary"}),label:l("brand.sourceLanes.connections.label"),description:l("brand.sourceLanes.connections.description")}];return(0,n.jsxs)("div",{children:[(0,n.jsx)(N.x,{as:"h3",variant:"h1",className:"mb-1",children:l("brand.source.title")}),(0,n.jsx)("p",{className:"mb-6 text-sm leading-6 text-secondary",children:l("brand.source.description")}),(0,n.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:e.map(e=>{let t=i===e.id;return(0,n.jsxs)("button",{type:"button",onClick:()=>{a(e.id),"ai"!==e.id&&r("other")},className:(0,C.cn)("flex min-h-[118px] items-start gap-3 rounded-xl border p-4 text-left transition-all",t?"border-stroke-selection bg-selection-bg/10":"border-stroke-medium bg-elevation-minus2 hover:border-stroke-hard"),children:[(0,n.jsx)("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-full border border-stroke-soft bg-elevation-0",children:e.icon}),(0,n.jsxs)("span",{className:"min-w-0",children:[(0,n.jsx)("span",{className:"block text-sm font-semibold text-primary",children:e.label}),(0,n.jsx)("span",{className:"mt-1 block text-xs leading-5 text-secondary",children:e.description})]})]},e.id)})}),"ai"===i?(0,n.jsxs)("div",{className:"mt-5",children:[(0,n.jsx)("p",{className:"mb-2 text-xs font-semibold uppercase tracking-[0.14em] text-tertiary",children:l("brand.source.aiProviderLabel")}),(0,n.jsx)("div",{className:"grid grid-cols-2 gap-3",children:h.map(e=>{let s=j.Jm[e],i=t===e,o="other"===e?f("other"):s.label;return(0,n.jsxs)("button",{type:"button",onClick:()=>r(e),className:(0,C.cn)("flex flex-col items-center justify-center gap-3 rounded-xl border p-5 transition-all",i?"border-stroke-selection bg-selection-bg/10":"border-stroke-medium bg-elevation-minus2 hover:border-stroke-hard"),children:[B[e],(0,n.jsx)("span",{className:"text-sm font-medium text-primary",children:o})]},e)})})]}):null]})}return(0,n.jsxs)("div",{children:[(0,n.jsx)(N.x,{as:"h3",variant:"h1",className:"mb-1",children:l("business"===s||"agent"===s?"business.source.title":"source.title")}),(0,n.jsx)("p",{className:"text-sm text-secondary mb-6",children:l("business"===s||"agent"===s?"business.source.description":"source.description")}),(0,n.jsx)("div",{className:"grid grid-cols-2 gap-3",children:h.map(e=>{let s=j.Jm[e],i=t===e,o="other"===e?f("other"):s.label;return(0,n.jsxs)("button",{onClick:()=>r(e),className:(0,C.cn)("flex flex-col items-center justify-center gap-3 p-6 rounded-xl border transition-all",i?"border-interactive-success bg-interactive-success/5":"border-stroke-medium bg-elevation-minus2 hover:border-stroke-hard"),children:[B[e],(0,n.jsx)("span",{className:"text-sm font-medium text-primary",children:o})]},e)})})]})}function O(e){let{source:t,selected:r,onToggle:s,onSelectAll:a,mode:l}=e,d=(0,o.T)("settings.profile.importWizard"),c=(0,o.T)("settings.profile.importWizard.templates"),u=(0,o.T)("spaceAgentPortfolio"),m=(0,i.useMemo)(()=>"brand"===l?P.flatMap(e=>{let r=R(e);return r?{source:t,fileType:e,label:d(r.labelKey),description:d(r.descriptionKey),recommended:r.recommended,prompt:d(r.promptKey)}:[]}):"agent"===l?j.fb.map(e=>{let{fileType:r}=e;return{source:t,fileType:r,label:u("files.".concat(r,".title")),description:u("files.".concat(r,".description")),recommended:!0,prompt:u("files.".concat(r,".question"))}}):"business"===l?F.map(e=>{let r=E[e];return{source:t,fileType:e,label:d(r.labelKey),description:d(r.descriptionKey),recommended:r.recommended,prompt:d(r.promptKey)}}):(0,j.IP)(t),[l,t,d,u]),p=m.map(e=>e.fileType),f=p.every(e=>r.has(e)),h=(e,t)=>{if("business"===l||"brand"===l||"agent"===l)return e[t];let r="".concat(e.source,"_").concat(e.fileType,".").concat(t);return c.has(r)?c(r):e[t]};return(0,n.jsxs)("div",{children:[(0,n.jsx)(N.x,{as:"h3",variant:"h1",className:"mb-1",children:"brand"===l?d("brand.files.title"):"business"===l||"agent"===l?d("business.files.title"):d("files.title")}),(0,n.jsxs)("div",{className:"mb-6 flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[(0,n.jsx)("p",{className:"text-sm text-secondary",children:"brand"===l?d("brand.files.description"):"business"===l||"agent"===l?d("business.files.description"):d("files.description")}),(0,n.jsx)("button",{type:"button",onClick:()=>a(f?[]:p),className:"inline-flex items-center justify-center rounded-full border border-stroke-medium px-3 py-1.5 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:f?d("files.clearAll"):d("files.selectAll")})]}),(0,n.jsx)("div",{className:"space-y-1",children:m.map(e=>
1{let t=r.has(e.fileType);return(0,n.jsxs)("div",{onClick:()=>s(e.fileType),className:"flex items-center gap-3 py-3 px-1 cursor-pointer border-b border-stroke-soft last:border-b-0 hover:bg-elevation-minus2/50 transition-colors rounded",children:[(0,n.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,n.jsx)(w.X,{checked:t,onChange:()=>s(e.fileType)})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("span",{className:(0,C.cn)("text-sm font-medium",t?"text-interactive-success":"text-primary"),children:h(e,"label")}),(0,n.jsx)("p",{className:"text-xs text-secondary mt-0.5",children:h(e,"description")})]}),"personal"===l&&e.recommended&&(0,n.jsx)("span",{className:"text-xs px-2.5 py-1 rounded-full border border-stroke-medium text-secondary font-medium shrink-0",children:d("files.bestResults")})]},e.fileType)})})]})}function H(e){let t=new Date;return t.setDate(t.getDate()+e),t.toISOString()}function U(e){return e<1024?"".concat(e," B"):e<1048576?"".concat(Math.round(e/1024)," KB"):"".concat((e/1048576).toFixed(1)," MB")}function z(e){return"".concat(e.name,"-").concat(e.size,"-").concat(e.lastModified,"-").concat(Math.random().toString(36).slice(2))}function K(e,t){let r=[],n=e.trim();for(let e of(n&&r.push("## Pasted assistant response\n\n".concat(n)),t)){let t=e.content.trim();t&&r.push("## Uploaded context file: ".concat(e.name,"\n\n").concat(t))}return r.join("\n\n---\n\n")}let q={unauthorized:"unauthorized",workspace_required:"workspaceRequired",missing_import_text:"missingImportText",extraction_failed:"extractionFailed",empty_extraction:"emptyExtraction",agent_not_found:"agentNotFound"};function W(e){var t,r,s,l,d,c;let{source:u,onChangeSource:m,brandSourceLane:p,onChangeBrandSourceLane:f,brandSourceInputs:h,fileInputs:x,onChangeMarkdown:b,onChangeBrandSourceInput:y,uploadedBusinessFiles:g,onUploadBusinessFiles:v,onRemoveBusinessFile:w,lastImportDate:k,mode:_}=e,L=(0,o.T)("settings.profile.importWizard"),I=(0,o.T)("spaceAgentPortfolio"),A=(0,a.bU)(),{settings:F}=(0,T.kP)(),E=j.Jm[u],P=(0,i.useMemo)(()=>"business"!==_?[]:x.flatMap(e=>{let t=M(e.fileType);return t?[{source:u,fileType:e.fileType,label:L(t.labelKey),description:L(t.descriptionKey),recommended:t.recommended,prompt:L(t.promptKey)}]:[]}),[x,_,u,L]),D=(0,i.useMemo)(()=>"agent"!==_?[]:x.flatMap(e=>
1j.fb.find(t=>t.fileType===e.fileType)?[{source:u,fileType:e.fileType,label:I("files.".concat(e.fileType,".title")),description:I("files.".concat(e.fileType,".description")),recommended:!0,prompt:I("files.".concat(e.fileType,".question"))}]:[]),[x,_,u,I]),Z=(0,i.useMemo)(()=>"brand"!==_?[]:x.flatMap(e=>{let t=R(e.fileType);return t?[{source:u,fileType:e.fileType,label:L(t.labelKey),description:L(t.descriptionKey),recommended:t.recommended,prompt:L(t.promptKey)}]:[]}),[x,_,u,L]);if("brand"===_){let e="ai"===p,t=e?E.label:L("brand.input.sourcesLabel"),i=function(e,t,r,n){let s=r.map((e,t)=>{let r=R(e.fileType);return r?"".concat(t+1,". ").concat(e.label,"\n").concat(n(r.promptKey)):""}).filter(Boolean).join("\n\n");return n("brand.input.combinedPrompt",{source:t,providerGuidance:n("brand.input.providerGuidance.".concat(e)),selectedSections:s,targetFiles:n("brand.input.targetFiles")})}(u,t,Z,L);return(0,n.jsxs)("div",{children:[(0,n.jsx)(N.x,{as:"h3",variant:"h1",className:"mb-1",children:L("brand.input.title")}),(0,n.jsx)("p",{className:"text-sm text-secondary mb-6",children:L("brand.input.description")}),(0,n.jsxs)("div",{className:"mb-5 inline-flex rounded-full border border-stroke-soft bg-elevation-minus2 p-1",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{f("documents"),m("other")},className:(0,C.cn)("rounded-full px-4 py-2 text-sm font-semibold transition",e?"text-secondary hover:text-primary":"bg-interactive-primary text-on-interactive-primary"),children:L("brand.input.sourcesTab")}),(0,n.jsx)("button",{type:"button",onClick:()=>f("ai"),className:(0,C.cn)("rounded-full px-4 py-2 text-sm font-semibold transition",e?"bg-interactive-primary text-on-interactive-primary":"text-secondary hover:text-primary"),children:L("brand.input.aiTab")})]}),e?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"mb-5 rounded-xl border border-stroke-soft bg-elevation-minus2 p-4",children:[(0,n.jsx)("p",{className:"mb-2 text-xs font-semibold uppercase tracking-[0.14em] text-tertiary",children:L("brand.source.aiProviderLabel")}),(0,n.jsx)("div",{className:"grid grid-cols-2 gap-2",children:["chatgpt","claude","gemini","other"].map(e=>{let t=j.Jm[e],r=u===e,s="other"===e?L("sources.other"):t.label;return(0,n.jsxs)("button",{type:"button",onClick:()=>m(e),className:(0,C.cn)("flex items-center justify-center gap-2 rounded-xl border px-3 py-3 text-sm font-semibold transition-all",r?"border-stroke-selection bg-selection-bg/10 text-primary":"border-stroke-soft bg-elevation-0 text-secondary hover:border-stroke-hard hover:text-primary"),children:[(0,n.jsx)("span",{className:"flex h-5 w-5 items-center justify-center",children:B[e]}),s]},e)})})]}),(0,n.jsx)($,{sourceLabel:t,fileTypeLabel:L("brand.input.singlePromptTitle"),index:0,total:1,promptText:i,value:null!==(s=null===(r=x[0])||void 0===r?void 0:r.markdown)&&void 0!==s?s:"",onChange:e=>b(-1,e),pasteLabel:L("brand.input.pasteResponseLabel",{source:t}),pastePlaceholder:L("brand.input.pasteResponsePlaceholder",{source:t})}),(0,n.jsx)(V,{mode:"brandAi",files:g,onUpload:v,onRemove:w})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(V,{mode:"brand",files:g,onUpload:v,onRemove:w}),(0,n.jsxs)("label",{className:"mt-4 block rounded-xl border border-stroke-soft bg-elevation-minus2 p-4",children:[(0,n.jsx)("span",{className:"block text-sm font-semibold text-primary",children:L("brand.input.linksNoteLabel")}),(0,n.jsx)("span",{className:"mt-1 block text-xs leading-5 text-secondary",children:L("brand.input.linksNoteHelp")}),(0,n.jsx)("textarea",{value:h.contextNote,onChange:e=>y("contextNote",e.target.value),placeholder:L("brand.input.linksNotePlaceholder"),className:"mt-3 min-h-[96px] w-full resize-none rounded-xl border border-stroke-medium bg-elevation-0 px-3 py-2 text-sm text-primary outline-none transition focus:border-stroke-hard"})]})]})]})}if("business"===_||"agent"===_){let e="agent"===_?function(e,t,r,n){let s=r.map((e,t)=>"".concat(t+1,". ").concat(e.label,"\n").concat(e.prompt)).join("\n\n"),i=j.fb.filter(e=>r.some(t=>t.fileType===e.fileType)).map(e=>e.fileName).join(", ");
1return n("business.input.combinedPrompt",{source:t,providerGuidance:n("business.input.providerGuidance.".concat(e)),selectedSections:s,targetFiles:i})}(u,E.label,D,L):function(e,t,r,n){let s=r.map((e,t)=>{let r=M(e.fileType);return r?"".concat(t+1,". ").concat(e.label,"\n").concat(n(r.promptKey)):""}).filter(Boolean).join("\n\n");return n("business.input.combinedPrompt",{source:t,providerGuidance:n("business.input.providerGuidance.".concat(e)),selectedSections:s,targetFiles:n("business.input.targetFiles")})}(u,E.label,P,L);return(0,n.jsxs)("div",{children:[(0,n.jsx)(N.x,{as:"h3",variant:"h1",className:"mb-1",children:L("business.input.title")}),(0,n.jsx)("p",{className:"text-sm text-secondary mb-6",children:L("business.input.description")}),(0,n.jsx)($,{sourceLabel:E.label,fileTypeLabel:L("business.input.singlePromptTitle"),index:0,total:1,promptText:e,value:null!==(d=null===(l=x[0])||void 0===l?void 0:l.markdown)&&void 0!==d?d:"",onChange:e=>b(-1,e),pasteLabel:L("business.input.pasteResponseLabel",{source:E.label}),pastePlaceholder:L("business.input.pasteResponsePlaceholder",{source:E.label})}),(0,n.jsx)(V,{files:g,onUpload:v,onRemove:w})]})}let O=x.map(e=>(0,j.t4)(u,e.fileType)).filter(e=>!!e),H=function(e,t,r,n){if(!t||isNaN(new Date(t).getTime()))return e;let s=(0,S.f1)(n,(0,S.ei)()),i=(0,S.j0)(t,s,r||"en",{month:"long",day:"numeric",year:"numeric"});return"".concat(e,"\n\nIMPORTANT: I last exported my profile on ").concat(i,". Please focus on:\n- NEW information from our conversations since ").concat(i,"\n- Changes to existing info (weight, goals, medications, routines, etc.)\n- Any corrections to what you previously shared\n\nYou can include unchanged info too, but prioritize what's new or different since ").concat(i,".")}((0,j.W5)(O),k,A,null==F?void 0:F.timezone),U=1===x.length&&x[0]?j.Tu[x[0].fileType].label:L("input.combinedPromptTitle");return(0,n.jsxs)("div",{children:[(0,n.jsx)(N.x,{as:"h3",variant:"h1",className:"mb-1",children:L("input.title")}),(0,n.jsx)("p",{className:"text-sm text-secondary mb-6",children:L("input.description")}),(0,n.jsx)($,{sourceLabel:E.label,fileTypeLabel:U,index:0,total:1,promptText:H,value:null!==(c=null===(t=x[0])||void 0===t?void 0:t.markdown)&&void 0!==c?c:"",onCh
1ange:e=>b(-1,e)})]})}function $(e){let{sourceLabel:t,fileTypeLabel:r,index:s,total:a,promptText:l,value:d,onChange:c,pasteLabel:u,pastePlaceholder:m}=e,p=(0,o.T)("settings.profile.importWizard"),[x,b]=(0,i.useState)(!1),y=(0,i.useCallback)(async()=>{await navigator.clipboard.writeText(l),b(!0),setTimeout(()=>b(!1),2e3)},[l]);return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,n.jsx)(N.x,{as:"h4",variant:"title",children:r}),a>1&&(0,n.jsxs)("span",{className:"text-sm text-secondary",children:[s+1,"/",a]})]}),(0,n.jsxs)("div",{className:"mb-3",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,n.jsx)("label",{className:"text-xs font-medium text-secondary",children:p("input.promptFor",{source:t})}),(0,n.jsxs)("button",{onClick:y,className:"flex items-center gap-1 text-xs text-interactive-primary hover:text-interactive-primary/80 transition-colors",children:[x?(0,n.jsx)(f.Z,{className:"w-3 h-3"}):(0,n.jsx)(h.Z,{className:"w-3 h-3"}),p(x?"input.copied":"input.copy")]})]}),(0,n.jsx)("div",{className:"p-3 rounded-xl bg-elevation-minus2 text-xs text-secondary whitespace-pre-wrap max-h-[180px] overflow-y-auto leading-relaxed",children:l})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-xs font-medium text-secondary block mb-1.5",children:null!=u?u:p("input.pasteResponseLabel",{source:t})}),(0,n.jsx)("textarea",{value:d,onChange:e=>c(e.target.value),placeholder:null!=m?m:p("input.pasteResponsePlaceholder",{source:t}),className:"w-full h-[120px] p-3 rounded-xl border border-stroke-medium bg-elevation-minus2 text-sm text-primary placeholder:text-tertiary/40 resize-none focus:outline-none focus:border-stroke-hard transition-colors"})]})]})}function V(e){let{mode:t="business",files:r,onUpload:s,onRemove:a}=e,l=(0,o.T)("settings.profile.importWizard"),[d,c]=(0,i.useState)(!1),u=(0,i.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Array.from(e.dataTransfer.types).includes("Files")&&(e.dataTransfer.dropEffect="copy",c(!0))},[]),m=(0,i.useCallback)(e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||c(!1)},[]),p=(0,i.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),c(!1),e.dataTransfer.files.length>0&&s(e.dataTransfer.files)},[s]);return(0,n.jsxs)("div",{className:(0,C.cn)("mt-5 rounded-xl border p-4 transition-colors",d?"border-stroke-selection bg-selection-bg/10":"border-stroke-soft bg-elevation-minus2"),onDragOver:u,onDragLeave:m,onDrop:p,children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-sm font-semibold text-primary",children:"brand"===t?l("brand.input.uploadTitle"):"brandAi"===t?l("brand.input.aiUploadTitle"):l("business.input.uploadTitle")}),(0,n.jsx)("p",{className:"mt-1 text-xs leading-5 text-secondary",children:"brand"===t?l("brand.input.uploadDescription"):"brandAi"===t?l("brand.input.aiUploadDescription"):l("business.input.uploadDescription")})]}),(0,n.jsxs)("label",{className:"inline-flex shrink-0 cursor-pointer items-center gap-2 rounded-lg border border-stroke-soft bg-elevation-0 px-3 py-2 text-xs font-semibold text-secondary transition hover:border-stroke-hard hover:text-primary",children:[(0,n.jsx)(x.Z,{className:"h-3.5 w-3.5"}),"brand"===t?l("brand.input.uploadButton"):"brandAi"===t?l("brand.input.aiUploadButton"):l("business.input.uploadButton"),(0,n.jsx)("input",{type:"file",multiple:!0,accept:"brand"===t?".md,.markdown,.txt,.json,.csv,.pdf,.doc,.docx,.ppt,.pptx,.key,.png,.jpg,.jpeg,.webp,.gif,.svg,.fig,.zip,.mp4,.mov,.m4v,.webm,.ttf,.otf,.woff,.woff2,text/markdown,text/plain,application/json,text/csv,application/pdf,image/png,image/jpeg,image/webp,image/gif,image/svg+xml,video/mp4,video/quicktime,video/webm,font/ttf,font/otf,font/woff,font/woff2":".md,.markdown,.txt,.json,.csv,text/markdown,text/plain,application/json,text/csv",className:"sr-only",onChange:e=>{s(e.currentTarget.files),e.currentTarget.value=""}})]})]}),(0,n.jsxs)("div",{className:(0,C.cn)("mt-3 rounded-lg border border-dashed px-3 py-3 text-center text-xs transition-colors",d?"border-stroke-selection bg-selection-bg/20 text-selection-typography":"border-stroke-soft bg-elevation-0 text-tertiary"),children:[(0,n.jsx)(x.Z,{className:"mx-auto mb-1 h-4 w-4"}),(0,n.jsx)("span",{className:"font-semibold text-primary",children:"brand"===t?l("brand.input.dropTitle"):"brandAi"===t?l("brand.input.aiDropTitle"):l("business.input.dropTitle")}),(0,n.jsx)("span",{className:"ml-1 text-secondary",children:"brand"===t?l("brand.input.dropDescription"):"brandAi"===t?l("brand.input.aiDropDescription"):l("business.input.dropDescription")})]}),r.length>0?(0,n.jsx)("div",{className:"mt-3 space-y-2",children:r.map(e=>(0,n.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-stroke-soft bg-elevation-0 px-3 py-2 text-xs text-secondary",children:[(0,n.jsx)(b.Z,{className:"h-3.5 w-3.5 shrink-0 text-tertiary"}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate text-primary",children:e.name}),e.knowledgeDocumentId?(0,n.jsx)("span",{className:"shrink-0 rounded-full border border-stroke-soft px-2 py-0.5 text-[0.65rem] text-tertiary",children:l("brand.input.storedInLibrary")}):null,(0,n.jsx)("span",{className:"shrink-0 text-tertiary",children:U(e.size)}),(0,n.jsx)("button",{type:"button",onClick:()=>a(e.id),className:"shrink-0 rounded-full p-1 text-tertiary transition hover:bg-elevation-minus1 hover:text-primary","aria-label":"business"===t?l("business.input.removeUpload",{name:e.name}):l("brand.input.removeUpload",{name:e.name}),children:(0,n.jsx)(y.Z,{className:"h-3.5 w-3.5"})})]},e.id))}):null]})}function G(e){let{facts:t,dimensions:r,excluded:i,onToggle:a,loading:l}=e,d=(0,o.T)("settings.profile.importWizard");if(l)return(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 gap-3",children:[(0,n.jsx)(s.c,{shape:"form"}),(0,n.jsx)("p",{className:"text-sm text-secondary",children:d("preview.extracting")})]});if(0===t.length)return(0,n.jsxs)("div",{className:"text-center py-8",children:[(0,n.jsx)("p",{className:"text-sm text-secondary",children:d("preview.empty")}),(0,n.jsx)("p",{className:"text-xs text-tertiary mt-1",children:d("preview.emptyHint")})]});let c=Object.keys(r).sort();return(0,n.jsxs)("div",{children:[(0,n.jsx)(N.x,{as:"h3",variant:"h1",className:"mb-1",children:d("preview.title")}),(0,n.jsx)("p",{className:"text-sm text-secondary mb-6",children:d("preview.subtitle",{count:t.length})}),(0,n.jsx)("div",{className:"space-y-6 max-h-[450px] overflow-y-auto pr-1",children:c.map(e=>{let t=r[e],s=e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase());return(0,n.jsxs)("div",{children:[(0,n.jsx)(N.x,{as:"h4",variant:"title",className:"mb-3",children:s}),(0,n.jsx)("div",{className:"divide-y divide-stroke-soft",children:t.map(e=>{var t;let r=i.has(e.field_key),s=function(e){if(null==e)return"(none)";if("boolean"==typeof e)return e?"Yes":"No";if("number"==typeof e)return String(e);if("string"==typeof e)return e;if(Array.isArray(e)){if(0===e.length)return"(none)";if("object"==typeof e[0]&&null!==e[0]&&"ingredient"in e[0]){let t=e.map(e=>e.ingredient);return"".concat(t.slice(0,3).join(", ")).concat(t.length>3?" +".concat(t.length-3," more"):"")}return e.join(", ")}return JSON.stringify(e)}(e.value);return(0,n.jsxs)("button",{onClick:()=>a(e.field_key),className:(0,C.cn)("w-full flex items-start gap-3 py-3 px-1 text-left transition-colors",r?"opacity-40":"hover:bg-elevation-minus2/50"),children:[(0,n.jsx)("span",{className:"mt-0.5",onClick:e=>e.stopPropagation(),children:(0,n.jsx)(w.X,{checked:!r,onChange:()=>a(e.field_key)})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-interactive-success",children:null!==(t=e.label)&&void 0!==t?t:e.field_key}),(0,n.jsx)("p",{className:"text-xs text-secondary mt-0.5 truncate",children:s})]}),(0,n.jsx)("span",{className:(0,C.cn)("text-[10px] px-2 py-0.5 rounded-full font-medium shrink-0 mt-0.5",e.is_new?"bg-interactive-success text-on-interactive-primary":"border border-stroke-medium text-secondary"),children:e.is_new?d("preview.badgeNew"):d("preview.badgeUpdate")})]},e.field_key)})})]},e)})})]})}function J(e){let{value:t,onChange:r,mode:s}=e,i=(0,o.T)("settings.profile.importWizard"),a=[{label:i("refresh.option30"),value:30},{label:i("refresh.option60"),value:60,recommended:"business"===s||"brand"===s},{label:i("refresh.option90"),value:90},{label:i("refresh.optionNever"),value:null}];return(0,n.jsxs)("div",{children:[(0,n.jsx)(N.x,{as:"h3",variant:"h1",className:"mb-1",children:"brand"===s?i("brand.refresh.title"):"business"===s?i("business.refresh.title"):i("refresh.title")}),(0,n.jsx)("p",{className:"text-sm text-secondary mb-6",children:"brand"===s?i("brand.refresh.description"):"business"===s?i("business.refresh.description"):i("refresh.description")}),(0,n.jsx)("div",{className:"space-y-2",children:a.map(e=>{let s=t===e.value;return(0,n.jsxs)("button",{onClick:()=>r(e.value),className:(0,C.cn)("w-full p-3 rounded-xl border text-left transition-all flex items-center gap-3",s?"border-interactive-primary bg-interactive-primary/10":"border-stroke-medium bg-elevation-minus2 hover:border-stroke-hard"),children:[(0,n.jsx)("div",{className:(0,C.cn)("w-4 h-4 rounded-full border flex items-center justify-center",s?"border-interactive-primary":"border-stroke-medium"),children:s&&(0,n.jsx)("div",{className:"w-2 h-2 rounded-full bg-interactive-primary"})}),(0,n.jsx)("span",{className:(0,C.cn)("text-sm",s?"text-interactive-primary font-medium":"text-primary"),children:e.label}),e.recommended?(0,n.jsx)("span",{className:"ml-auto rounded-full border border-stroke-selection/50 bg-selection-bg/20 px-2 py-0.5 text-[0.65rem] font-semibold uppercase tracking-[0.12em] text-selection-typography",children:i("refresh.bestResults")}):null]},e.label)})})]})}function X(e){let{factsCount:t,mode:r}=e,s=(0,o.T)("settings.profile.importWizard");return(0,n.jsxs)("div",{className:"text-center py-12",children:[(0,n.jsx)("div",{className:"w-14 h-14 roun
1ded-full bg-interactive-success/15 flex items-center justify-center mx-auto mb-4",children:(0,n.jsx)(f.Z,{className:"w-7 h-7 text-interactive-success"})}),(0,n.jsx)(N.x,{as:"h3",variant:"h1",className:"mb-2",children:s("brand"===r?"brand.done.title":"business"===r?"business.done.title":"done.title")}),(0,n.jsx)("p",{className:"text-sm text-secondary",children:s("brand"===r?"brand.done.subtitle":"business"===r?"business.done.subtitle":"done.subtitle",{count:t})}),(0,n.jsx)("p",{className:"text-xs text-tertiary mt-1",children:s("brand"===r?"brand.done.hint":"business"===r?"business.done.hint":"done.hint")})]})}function Y(e){let{onClose:t,onComplete:r,onImportQueued:s,initialSource:a,initialFileType:d,lastImportDate:c,mode:u="personal"}=e,m=(0,o.T)("settings.profile.importWizard"),p=(0,o.T)("spaceAgentImportErrors"),[f,h]=(0,i.useState)(()=>a?d?"input":"files":"brand"===u?"input":"source"),[x,b]=(0,i.useState)(null!=a?a:"brand"===u?"other":null),[w,j]=(0,i.useState)(()=>"brand"===u?"documents":"ai"),[_,C]=(0,i.useState)({websiteUrl:"",figmaUrl:"",connectionUrl:"",contextNote:""}),[T,S]=(0,i.useState)(()=>d?new Set([d]):"brand"===u?new Set(P):new Set),[L,I]=(0,i.useState)(()=>d?[{fileType:d,markdown:""}]:"brand"===u?[{fileType:P[0],markdown:""}]:[]),[F,E]=(0,i.useState)([]),[M,R]=(0,i.useState)([]),[B,$]=(0,i.useState)({}),[V,Y]=(0,i.useState)(new Set),[Q,ee]=(0,i.useState)(()=>"business"===u||"brand"===u?60:null),[et,er]=(0,i.useState)(0),[en,es]=(0,i.useState)(!1),[ei,eo]=(0,i.useState)(""),[ea,el]=(0,i.useState)(""),ed=(0,i.useMemo)(()=>Object.values(_).some(e=>e.trim().length>0),[_]),ec=(0,i.useMemo)(()=>{var e,t;return!!K(null!==(t=null===(e=L[0])||void 0===e?void 0:e.markdown)&&void 0!==t?t:"",F)},[L,F]),eu=(0,i.useCallback)(()=>{I(Array.from(T).map(e=>({fileType:e,markdown:""})))},[T]),em=(0,i.useCallback)(async e=>{if(null==e?void 0:e.length){es(!0),eo(""),el("");try{if("brand"===u&&"ai"!==w){var t,r,n,s;let i=Array.from(e),o=[],a=[];for(let e of i)try{let n=new FormData;n.append("file",e);let s=await fetch("/api/betterness-one/work/brand-dna/sources/upload",{method:"POST",body:n}),i=await s.json().catch(()=>null),a=null!==(r=null!==(t=null==i?void 0:i.knowledgeDocumentId)&&void 0!==t?t:null==i?void 0:i.knowledge_document_id)&&void 0!==r?r:null;if(!s.ok||!a)throw Error((null==i?void 0:i.details)||(null==i?void 0:i.error)||"upload_failed");o.push({id:z(e),name:(null==i?void 0:i.filename)||(null==i?void 0:i.title)||e.name,size:e.size,content:"",knowledgeDocumentId:a,sourceType:"library"})}catch(t){a.push({name:e.name,reason:t instanceof Error?t.message:"upload_failed"})}if(o.length&&E(e=>[...e,...o]),a.length>0){let e=a[0];eo(o.length>0?m("brand.errors.fileUploadPartial",{stored:o.length,total:i.length}):m("brand.errors.fileUploadFailedWithReason",{file:null!==(n=null==e?void 0:e.name)&&void 0!==n?n:m("brand.errors.fileUploadUnknownFile"),reason:null!==(s=null==e?void 0:e.reason)&&void 0!==s?s:m("brand.errors.fileUploadUnknownReason")}))}return}let i=await Promise.all(Array.from(e).map(async e=>({id:z(e),name:e.name,size:e.size,content:await e.text(),sourceType:"local"})));E(e=>[...e,...i])}catch(e){eo("brand"===u?m("brand.errors.fileUploadFailed"):m("business.errors.fileReadFailed"))}finally{es(!1)}}},[w,u,m]),ep=(0,i.useCallback)(e=>{E(t=>t.filter(t=>t.id!==e))},[]),ef=(0,i.useCallback)(async()=>{if(x){es(!0),eo(""),el("");try{var e,t,n,i,o,a,l,d,c,f;if("brand"===u){let e=[function(e,t){let r=[];"ai"!==e&&r.push("- Brand source lane: ".concat(e));let n=t.websiteUrl.trim(),s=t.figmaUrl.trim(),i=t.connectionUrl.trim(),o=t.contextNote.trim();return n&&r.push("- Website URL: ".concat(n)),s&&r.push("- Figma or design URL: ".concat(s)),i&&r.push("- Connected source or workspace URL: ".concat(i)),o&&r.push("- Source note: ".concat(o)),r.length?"## Brand source context\n\n".concat(r.join("\n")):""}(w,_),function(e,t){let r=[],n=e.trim();for(let e of(n&&r.push("## Pasted assistant response\n\n".concat(n)),t)){if(e.knowledgeDocumentId){r.push(["## Uploaded Library asset: ".concat(e.name),"- Library document id: ".concat(e.knowledgeDocumentId),"- Size: ".concat(U(e.size)),"- Note: The original file is stored in the Betterness One Library. Use the Library document id for lineage."].join("\n"));continue}let t=e.content.trim();t&&r.push("## Uploaded brand source file: ".concat(e.name,"\n\n").concat(t))}return r.join("\n\n---\n\n")}(null!==(n=null===(t=L[0])||void 0===t?void 0:t.markdown)&&void 0!==n?n:"",F)].filter(
1Boolean).join("\n\n---\n\n"),r=F.map(e=>e.knowledgeDocumentId).filter(e=>!!e);if(!e&&0===r.length)throw Error(m("brand.errors.emptyResponse"));let i=await fetch("/api/betterness-one/work/brand-dna/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:x,source_lane:w,source_inputs:_,file_types:Array.from(T),attachment_names:F.map(e=>e.name),knowledge_document_ids:r,raw_markdown:e})}),o=await i.json().catch(()=>({}));if(!i.ok)throw Error((d=null==o?void 0:o.error,"string"!=typeof d?m("brand.errors.importFailed"):"missing_import_text"===d?m("brand.errors.emptyResponse"):"brand_import_temporal_unavailable"===d||"backend_not_configured"===d?m("brand.errors.importUnavailable"):m("brand.errors.importFailed")));let a=Object.values(_).filter(e=>e.trim()).length;er(T.size+F.length+a),await (null==s?void 0:s()),h("refresh");return}if("business"===u||"agent"===u){let e=K(null!==(o=null===(i=L[0])||void 0===i?void 0:i.markdown)&&void 0!==o?o:"",F);if(!e)throw Error(m("business.errors.emptyResponse"));let t=await fetch("agent"===u?"/api/betterness-one/work/space/agent/import":"/api/betterness-one/business-profile/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:x,file_types:Array.from(T),attachment_names:F.map(e=>e.name),raw_markdown:e})}),n=await t.json().catch(()=>({}));if(!t.ok){let e="string"==typeof(null==n?void 0:n.error)?n.error:"unknown";throw el(e),console.error("[B1 context import] request failed",{code:e,stage:"agent"===u?"space_agent_import":"business_profile_import",status:t.status}),Error("agent"===u?(c=null==n?void 0:n.error,"string"==typeof c&&c in q?p(q[c]):p("importFailed")):(f=null==n?void 0:n.error,"string"!=typeof f?m("business.errors.importFailed"):"missing_import_text"===f?m("business.errors.emptyResponse"):"context_import_temporal_unavailable"===f||"backend_not_configured"===f?m("business.errors.importUnavailable"):m("business.errors.importFailed")))}if(er(T.size+F.length),await (null==s?void 0:s()),"agent"===u){r();return}h("refresh");return}let b=null!==(a=null===(e=L[0])||void 0===e?void 0:e.markdown.trim())&&void 0!==a?a:"";if(!b)throw Error(m("input.emptyResponse"));let y=A(L),g=await fetch("/api/profile-import/extract",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdown:b,source:x,file_type:y,preview_only:!0})});if(!g.ok)throw Error("Extraction failed");let v=await g.json();if(v.error)throw Error(v.error);let j=await fetch("/api/profile-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:x,file_type:y,raw_markdown:b})});if(!j.ok)throw Error("Failed to save import record");let{import:k}=await j.json();L[0]&&(L[0].importId=k.id),await fetch("/api/profile-import/".concat(k.id),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"previewed",extracted_facts_json:JSON.stringify(v.facts||[]),facts_count:v.facts_count||0})});let N=new Map;for(let e of v.facts||[])N.set(e.field_key,e);let C=Array.from(N.values()),S={};for(let e of C){let t=null!==(l=e.dimension)&&void 0!==l?l:"other";S[t]=[...S[t]||[],e]}R(C),$(S),h("preview")}catch(e){eo(e instanceof Error?e.message:"Extraction failed")}finally{es(!1)}}},[_,w,L,u,r,s,T,x,m,p,F]),eh=(0,i.useCallback)(async()=>{if(x){es(!0),eo("");try{let e=0;for(let t of L){if(!t.markdown.trim()||!t.importId)continue;let r=await fetch("/api/profile-import/extract",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdown:t.markdown,source:x,file_type:A(L),preview_only:!1,excluded_fields:Array.from(V),import_id:t.importId})});if(!r.ok)throw Error("Confirm failed");let n=await r.json();e+=n.stored||0,await fetch("/api/profile-import/".concat(t.importId),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"confirmed",facts_count:n.facts_count||0,refresh_interval_days:Q})})}if(Q)try{await fetch("/api/profile-import/schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:x,refresh_interval_days:Q})})}catch(e){console.warn("[ImportWizard] Failed to create refresh cron job:",e)}er(e),h("done")}catch(e){eo(e instanceof Error?e.message:"Confirmation failed")}finally{es(!1)}}},[x,V,L,Q]),ex=(0,i.useCallback)(async()=>{es(!0),eo("");try{let e=new Date().toISOString(),t=Q?{enabled:!0,intervalDays:Q,nextRefreshAt:H(Q),source:null!=x?x:"other",updatedAt:e}:{enabled:!1,intervalDays:null,nextRefreshAt:null,source:null!=x?x:"other",updatedAt:e};if(!(await fetch("/api/betterness-one/work/brand-dna",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshReminder:t})})).ok)throw Error(m("brand.errors.reminderFailed"));h("done")}catch(e){eo(e instanceof Error?e.message:m("brand.errors.reminderFailed"))}finally{es(!1)}},[Q,x,m]),eb=(0,i.useCallback)(async()=>
1{if(x){es(!0),eo("");try{let e=Q?{enabled:!0,intervalDays:Q,nextRefreshAt:H(Q),source:x,updatedAt:new Date().toISOString()}:{enabled:!1,intervalDays:null,nextRefreshAt:null,source:x,updatedAt:new Date().toISOString()};if(!(await fetch("/api/betterness-one/business-profile",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({patchData:{context_portfolio_refresh_reminder:e}})})).ok)throw Error(m("business.errors.reminderFailed"));h("done")}catch(e){eo(e instanceof Error?e.message:m("business.errors.reminderFailed"))}finally{es(!1)}}},[Q,x,m]),ey=(0,i.useCallback)(()=>{switch(f){case"source":x&&h("files");break;case"files":T.size>0&&(eu(),h("input"));break;case"input":("brand"===u?L.some(e=>e.markdown.trim())||F.length>0||ed:"business"===u||"agent"===u?ec:L.some(e=>e.markdown.trim()))&&ef();break;case"preview":h("refresh");break;case"refresh":"business"===u?eb():"brand"===u?ex():eh();break;case"done":r()}},[f,x,T,L,eu,ef,eh,eb,ex,u,r,F.length,ed,ec]),eg=(0,i.useCallback)(()=>{switch(f){case"files":h("source");break;case"input":h("files");break;case"preview":h("input");break;case"refresh":h("business"===u||"brand"===u||"agent"===u?"input":"preview")}},[u,f]),ev=(()=>{switch(f){case"source":return!!x;case"files":return T.size>0;case"input":return"brand"===u?L.some(e=>e.markdown.trim())||F.length>0||ed:"business"===u||"agent"===u?ec:L.some(e=>e.markdown.trim());case"preview":return M.length>0;case"refresh":case"done":return!0}})(),ew=(()=>{switch(f){case"input":return"brand"===u?m("actions.importBrand"):"business"===u||"agent"===u?m("actions.importContext"):m("actions.extract");case"preview":return m("actions.continue");case"refresh":return"brand"===u?m("actions.finish"):"business"===u?m("actions.saveReminder"):m("actions.confirmImport");case"done":return m("actions.close");default:return m("actions.next")}})();return(0,l.createPortal)((0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-6",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-overlay/60 backdrop-blur-sm",onClick:t}),(0,n.jsxs)("div",{className:"relative w-full h-full max-w-[1100px] max-h-[90vh] rounded-2xl bg-elevation-minus2 border border-stroke-soft flex flex-col overflow-hidden shadow-xl",children:[(0,n.jsx)("div",{className:"h-1.5 w-full shrink-0",style:{background:"linear-gradient(270deg, #FFFFFF -43.25%, #EAECEA -22.87%, #E3ECE7 -16.08%, #D7EDE0 -10.99%, #C6EFD6 -5.89%, #B0F0CA -2.5%, #95F2BA 0.9%, #74F5A7 2.6%, #4FF892 5.99%, #26FB7A 7.69%, #00FF65 9.39%, #00FC66 19.58%, #00F56C 24.67%, #00EA75 28.07%, #2AE365 31.46%, #94D43D 38.25%, #FFC515 45.04%, #FDC124 46.74%, #F8B84E 48.44%, #F0A991 53.53%, #E696EC 58.63%, #E492FF 60.33%, #E492FF 70.51%, #E492FF 72.21%, #E496FE 73.91%, #E6B0F8 77.3%, #E8C6F3 80.7%, #EAD7F0 85.79%, #EBE3ED 92.59%, #FFFFFF 101.08%, #ECECEC 126.54%)"}}),(0,n.jsxs)("div",{className:"flex items-center justify-between shrink-0",children:[(0,n.jsx)("div",{className:"flex-1",children:(0,n.jsx)(D,{currentStep:f,mode:u})}),(0,n.jsx)("button",{onClick:t,className:"p-3 mr-2 text-tertiary hover:text-primary transition-colors",children:(0,n.jsx)(y.Z,{className:"w-5 h-5"})})]}),ei&&(0,n.jsx)("div",{className:"mx-8 mb-2 p-3 rounded-xl bg-interactive-destructive/10 border border-interactive-destructive/20","data-import-error-code":ea||void 0,children:(0,n.jsx)(N.x,{variant:"bodyStrong",className:"text-destructive",children:ei})}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto px-8 pb-6 flex flex-col items-center",children:(0,n.jsxs)("div",{className:"w-full max-w-2xl",children:["source"===f&&(0,n.jsx)(Z,{selected:x,onSelect:b,mode:u,brandSourceLane:w,onSelectBrandSourceLane:j}),"files"===f&&x&&(0,n.jsx)(O,{source:x,selected:T,onToggle:e=>{S(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},onSelectAll:e=>S(new Set(e)),mode:u}),"input"===f&&x&&(0,n.jsx)(W,{source:x,onChangeSource:b,brandSourceLane:w,onChangeBrandSourceLane:j,brandSourceInputs:_,fileInputs:L,uploadedBusinessFiles:F,onUploadBusinessFiles:em,onRemoveBusinessFile:ep,onChangeBrandSourceInput:(e,t)=>{C(r=>({...r,[e]:t}))},onChangeMarkdown:(e,t)=>{I(r=>{if(e<0)return r.map(e=>({...e,markdown:t}));let n=[...r];return n[e]={...n[e],markdown:t},n})},lastImportDate:c,mode:u}),"preview"===f&&(0,n.jsx)(G,{facts:M,dimensions:B,excluded:V,onToggle:e=>{Y(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},loading:en}),"refresh"===f&&(0,n.jsx)(J,{value:Q,onChange:ee,mode:u}),"done"===f&&(0,n.jsx)(X,{factsCount:et,mode:u})]})}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-3 px-8 py-4 border-t border-stroke-soft shrink-0",children:["source"!==f&&"done"!==f&&(0,n.jsx)(k.z,{variant:"ghost",onClick:eg,children:m("actions.back")}),(0,n.jsxs)(k.z,{variant:"primary",onClick:ey,disabled:!ev||en&&"preview"!==f,children:[en&&"preview"!==f&&(0,n.jsx)(g.Z,{className:"w-4 h-4 animate-spin"}),ew,"done"!==f&&!en&&(0,n.jsx)(v.Z,{className:"w-4 h-4"})]})]})]})]}),document.body)}},89564:function(e,t,r){r.d(t,{Q:function(){return i}});var n=r(57437),s=r(94457);function i(e){let{children:t,className:r,scrollable:i=!0}=e;return(0,n.jsxs)("div",{className:(0,s.cn)("flex aspect-[1512/1030] min-h-0 min-w-0 max-h-full max-w-full flex-col items-center",r),children:[(0,n.jsx)("div",{className:"flex min-h-0 w-[87%] flex-1 flex-col rounded-t-[14px] bg-gradient-to-b from-[#e3e4e6] via-[#cfd1d4] to-[#b9bbbe] p-[3px] pb-0 shadow-2xl",children:(0,n.jsx)("div",{className:"flex min-h-0 flex-1 flex-col rounded-t-[11px] bg-black px-[7
1px] pt-[7px]",children:(0,n.jsxs)("div",{className:"mock-screen relative flex min-h-0 flex-1 flex-col overflow-hidden rounded-t-[5px] bg-white",children:[(0,n.jsx)("div",{className:(0,s.cn)("min-h-0 flex-1 overflow-x-hidden overscroll-contain [-webkit-overflow-scrolling:touch]",i?"overflow-y-auto":"overflow-hidden"),children:t}),(0,n.jsx)("span",{"aria-hidden":!0,className:"pointer-events-none absolute left-1/2 top-0 flex h-[3%] min-h-[10px] w-[11%] -translate-x-1/2 items-center justify-center rounded-b-[6px] bg-black",children:(0,n.jsx)("span",{className:"size-[3px] rounded-full bg-[#2e2e33]"})})]})})}),(0,n.jsx)("div",{className:"relative h-[3.8%] w-full rounded-b-[10px] rounded-t-[2px] bg-gradient-to-b from-[#e3e4e6] via-[#cfd1d4] to-[#9fa1a4] shadow-2xl",children:(0,n.jsx)("span",{"aria-hidden":!0,className:"absolute left-1/2 top-0 h-[55%] w-[11%] -translate-x-1/2 rounded-b-[8px] bg-[#b9bbbe]"})})]})}},1690:function(e,t,r){r.d(t,{N:function(){return d}});var n=r(57437),s=r(2265),i=r(4988),o=r(62926),a=r(94457);function l(e){let{inset:t,faded:r}=e,s=(0,a.cn)("text-white transition-opacity duration-500",!t&&"mix-blend-difference",r&&"opacity-0");return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:(0,a.cn)("text-[11px] font-semibold tabular-nums",s),children:new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",hour12:!1}).format(new Date)}),(0,n.jsxs)("span",{className:(0,a.cn)("flex items-center gap-1",s),children:[(0,n.jsx)(i.Z,{className:"h-2.5 w-2.5",strokeWidth:2.5}),(0,n.jsx)(o.Z,{className:"h-2.5 w-2.5",strokeWidth:2.5}),(0,n.jsxs)("span",{className:"flex items-center",children:[(0,n.jsx)("span",{className:"flex h-[9px] w-[17px] items-center rounded-[3px] border border-white/70 p-[1.5px]",children:(0,n.jsx)("span",{className:"block h-full w-4/5 rounded-[1px] bg-white"})}),(0,n.jsx)("span",{className:"ml-[1px] h-[3px] w-[1.5px] rounded-r-[0.5px] bg-white/70"})]})]}),(0,n.jsx)("span",{className:"absolute left-1/2 top-[7px] h-[22px] w-[73px] -translate-x-1/2 rounded-full bg-black"})]})}function d(e){let{children:t,className:r,scrollable:i=!0,statusBar:o="overlay"}=e,[d,c]=(0,s.useState)(!1),u="inset"===o;return(0,n.jsxs)("div",{className:(0,a.cn)("relative flex aspect-[248/521] w-auto min-w-0 min-h-0 max-w-full flex-col rounded-[40px] bg-gradient-to-b from-[#e3e4e6] via-[#cfd1d4] to-[#b9bbbe] p-[4px] shadow-2xl",r),children:[(0,n.jsx)("span",{"aria-hidden":!0,className:"absolute -left-[2px] top-[20.4%] h-[3.5%] w-[3px] rounded-l-md bg-[#c3c5c8]"}),(0,n.jsx)("span",{"aria-hidden":!0,className:"absolute -left-[2px] top-[26.2%] h-[5.4%] w-[3px] rounded-l-md bg-[#c3c5c8]"}),(0,n.jsx)("span",{"aria-hidden":!0,className:"absolute -left-[2px] top-[33%] h-[5.4%] w-[3px] rounded-l-md bg-[#c3c5c8]"}),(0,n.jsx)("span",{"aria-hidden":!0,className:"absolute -right-[2px] top-[42.6%] h-[11.7%] w-[3px] rounded-r-md bg-[#c3c5c8]"}),(0,n.jsx)("div",{className:"flex min-h-0 flex-1 flex-col rounded-[36px] bg-black p-[6px]",children:(0,n.jsxs)("div",{className:"mock-screen relative flex min-h-0 flex-1 flex-col overflow-hidden rounded-[30px] bg-white font-sans",children:[u?(0,n.jsx)("div",{"aria-hidden":!0,className:"relative z-10 flex h-9 shrink-0 items-center justify-between bg-black px-5",children:(0,n.jsx)(l,{inset:!0,faded:!1})}):null,(0,n.jsx)("div",{className:(0,a.cn)("min-h-0 flex-1 overflow-x-hidden overscroll-contain [-webkit-overflow-scrolling:touch]",i?"overflow-y-auto":"overflow-hidden"),onScrollCapture:e=>{let t=e.target;t.scrollHeight-t.clientHeight<=1||c(t.scrollTop>8)},children:t}),u?null:(0,n.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 top-0 flex h-9 items-center justify-between px-5",children:(0,n.jsx)(l,{inset:!1,faded:d})}),(0,n.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 bottom-0 flex h-5 items-center justify-center",children:(0,n.jsx)("div",{className:"h-1 w-24 rounded-full bg-white mix-blend-difference"})})]})})]})}},11877:function(e,t,r){r.d(t,{Nh:function(){return s},US:function(){return o},X0:function(){return i}});let n=[{id:"brand_basics",i18nKey:"brandBasics",title:"Brand basics",fileName:"brand-basics.md",docType:"both",description:"Who the brand is, who it serves, what it promises, and what generic brand guidance would miss."},{id:"voice_messaging",i18nKey:"voiceMessaging",title:"Voice and messaging",fileName:"voice-and-messaging.md",docType:"voice",description:"How the business sounds, core messages, phrases to use, phrases to avoid, and claim boundaries."},{id:"visual_identity",i18nKey:"visualIdentity",title:"Visual identity",fileName:"visual-identity.md",docType:"design",description:"Color, type, layout, spacing, texture, contrast, and the brand recognizable visual feel."}
1,{id:"logos_assets",i18nKey:"logosAssets",title:"Logos and assets",fileName:"logos-and-assets.md",docType:"design",description:"Approved logos, product marks, variants, where to use each one, and source/location lineage."},{id:"imagery_motion",i18nKey:"imageryMotion",title:"Imagery and motion",fileName:"imagery-and-motion.md",docType:"design",description:"Photography, illustration, video, reel, motion, overlay, filter, and editing rules."},{id:"social_channels",i18nKey:"socialChannels",title:"Social channels",fileName:"social-channels.md",docType:"voice",description:"How the brand behaves on Instagram, LinkedIn, X/Twitter, TikTok, and other social surfaces."},{id:"email_newsletter",i18nKey:"emailNewsletter",title:"Email and newsletter",fileName:"email-and-newsletter.md",docType:"voice",description:"Newsletter voice, structure, subject-line taste, calls to action, and content cadence."},{id:"podcast_youtube",i18nKey:"podcastYoutube",title:"Podcast, YouTube, and long-form",fileName:"podcast-youtube-and-long-form.md",docType:"both",description:"Podcast, YouTube, long-form, show packaging, thumbnails, clips, titles, and distribution style."},{id:"campaign_templates",i18nKey:"campaignTemplates",title:"Campaign patterns and templates",fileName:"campaign-patterns-and-templates.md",docType:"both",description:"Reusable campaign formats, content systems, offers, launch patterns, and Figma/template needs."},{id:"brand_rules_decisions",i18nKey:"brandRulesDecisions",title:"Rules and decisions",fileName:"rules-and-decisions.md",docType:"both",description:"Durable decisions, no-go rules, approvals, open questions, inspirations, competitors, and constraints."}],s=n.map(e=>e.id),i=new Map(n.map(e=>[e.id,e]));function o(e,t){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];return r&&null!=t?t:e}},92581:function(e,t,r){function n(e){return e.trim().replace(/^```(?:json|markdown|html)?\s*|\s*```$/g,"").trim()}function s(e,t,r){var i,o;let a=null!==(i=r.depth)&&void 0!==i?i:0;if(a>5||null==e)return"";if("string"==typeof e){let i=n(e);if(!i)return"";let o=function(e){let t=n(e);try{let e=JSON.parse(t);return e&&"object"==typeof e&&!Array.isArray(e)?e:null}catch(r){let e=t.match(/\{[\s\S]*\}/);if(!e)return null;try{let t=JSON.parse(e[0]);return t&&"object"==typeof t&&!Array.isArray(t)?t:null}catch(e){return null}}}(i);if(o)return s(o,t,{allowPlainText:!1,depth:a+1})||(r.allowPlainText&&!i.startsWith("{")?i:"");if(i.startsWith("{")){let e=function(e,t){for(let r of t){let t=e.match(RegExp('"'.concat(r,'"\\s*:\\s*"((?:\\\\.|[^"\\\\])*)"'),"i"));if(null==t?void 0:t[1])return function(e){try{return JSON.parse('"'.concat(e,'"'))}
1catch(t){return e.replace(/\\n/g,"\n").replace(/\\"/g,'"').replace(/\\\\/g,"\\").trim()}}(t[1])}return""}(i,t);if(e)return s(e,t,{allowPlainText:!0,depth:a+1})||e}return r.allowPlainText&&!i.startsWith("{")?i:""}if("object"==typeof e&&!Array.isArray(e))for(let r of t){let n="string"==typeof(o=e[r])?o.trim():"";if(n)return s(n,t,{allowPlainText:!0,depth:a+1})||n;let i=s(e[r],t,{allowPlainText:!0,depth:a+1});if(i)return i}return""}function i(e){return s(e,["markdown","content","md"],{allowPlainText:!0})}function o(e){return s(e,["summaryHtml","html","summary"],{allowPlainText:!0})}r.d(t,{V:function(){return i},s:function(){return o}})},26142:function(e,t,r){r.d(t,{i:function(){return s}});var n=r(38407);async function s(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12;try{let t=await fetch("/api/knowledge?media=1&logo=1&limit=".concat(e),{cache:"no-store"});if(!t.ok)return[];let r=await t.json(),s=Array.isArray(null==r?void 0:r.documents)?r.documents:[],i=new Set;return s.map(e=>{var t,r,s;return{id:String(e.id),url:null!==(r=(0,n.kM)(e.original_file_url))&&void 0!==r?r:String(null!==(t=e.original_file_url)&&void 0!==t?t:""),title:String(null!==(s=e.title)&&void 0!==s?s:"")}}).filter(e=>{let t=e.url||e.id;return!(!t||i.has(t))&&(i.add(t),!0)})}catch(e){return[]}}},706:function(e,t,r){r.d(t,{IP:function(){return i},Jm:function(){return a},Tu:function(){return d},W5:function(){return l},fb:function(){return n},t4:function(){return o}});let n=[{fileType:"identity",fileName:"identity.md"},{fileType:"help",fileName:"help.md"},{fileType:"voice",fileName:"voice.md"},{fileType:"boundaries",fileName:"boundaries.md"}],s=[{source:"chatgpt",fileType:"soul",label:"Profile Summary",description:"A comprehensive overview of who you are based on your conversations.",recommended:!0,prompt:"I'm switching to a new AI assistant. Please create a comprehensive profile document about me based on everything you know from our conversations. Include:\n\n## About Me\nName, age, location, occupation, personality traits, communication preferences\n\n## Health & Wellness\nHealth goals, conditions, exercise routine, diet, supplements, medications, sleep\n\n## Lifestyle\nDaily routines, family situation, stress levels, mental health, wearable devices\n\n## Preferences\nHow I like to receive information, topics I care about, things I've asked about frequently\n\nBe specific — use real details from our conversations, not generic placeholders. Format as markdown."},{source:"chatgpt",fileType:"memory",label:"Memory Export",description:"Everything ChatGPT remembers about you from the Memory feature.",recommended:!0,prompt:"Please list everything you currently have stored in your memory about me. Include every single detail — health data, preferences, personal info, goals, routines, anything you've saved. Format each memory as a bullet point. Don't summarize or group — just dump everything."},{source:"chatgpt",fileType:"health",label:"Health Profile",description:"Focused export of health, fitness, and medical information.",recommended:!1,prompt:"Based on our conversations, create a detailed health profile for me. Include:\n\n## Physical Stats\nHeight, weight, age, body composition if known\n\n## Medical History\nConditions, diagnoses, surgeries, family health history\n\n## Medications & Supplements\nEverything I take, with dosages if you know them\n\n## Exercise & Fitness\nWorkout routine, activities, fitness goals, equipment\n\n## Diet & Nutrition\nEating patterns, restrictions, allergies, preferences\n\n## Sleep & Recovery\nSleep schedule, quality issues, devices I track with\n\n## Mental Health\nStress factors, coping strategies, therapy, meditation\n\nBe specific with real details from our chats. Format as markdown."},{source:"chatgpt",fileType:"preferences",label:"Communication Preferences",description:"How you like to interact — tone, detail level, topics.",recommended:!1,prompt:"Describe my communication preferences based on our interactions:\n\n- How do I prefer responses? (concise vs detailed, casual vs formal)\n- What topics do I frequently ask about?\n- What frustrates me in conversations?\n- What format do I prefer? (lists, paragraphs, step-by-step)\n- Am I usually in a hurry or do I like to explore topics deeply?\n- Any patterns you've noticed in how I ask questions?\n\nBe specific — base this on actual patterns from our conversations."}
1,{source:"chatgpt",fileType:"history",label:"Conversation Themes",description:"Summary of major topics and themes from your chat history.",recommended:!1,prompt:"Summarize the major themes and topics from our conversation history:\n\n- What are the top 5-10 topics I ask about most?\n- Any ongoing projects or goals I've been working on?\n- Key decisions I've made or am considering?\n- Recurring questions or concerns?\n\nKeep it factual and specific to what we've actually discussed."},{source:"claude",fileType:"soul",label:"Profile Summary",description:"A comprehensive overview based on your Claude conversations.",recommended:!0,prompt:"I'm moving to a new AI platform. Please compile everything you know about me into a structured profile document:\n\n## About Me\nName, age, location, job, personality, how I communicate\n\n## Health & Wellness\nHealth goals, conditions, exercise habits, diet, supplements, medications, sleep patterns\n\n## Lifestyle\nRoutines, family, stress, mental health, devices/wearables\n\n## Preferences\nHow I like information presented, topics I care about, my values\n\nUse specific details from our conversations. Markdown format please."},{source:"claude",fileType:"memory",label:"Key Facts",description:"All specific facts and details Claude knows about you.",recommended:!0,prompt:"List every specific fact you know about me from our conversations. Include personal details, health info, preferences, goals, routines, family, work — everything. One bullet point per fact. Don't filter or summarize — include all of it."},{source:"claude",fileType:"health",label:"Health Profile",description:"Health-focused export from your Claude conversations.",recommended:!1,prompt:"Create a detailed health profile based on what you know about me:\n\n## Physical Stats & Body Composition\n## Medical History & Conditions\n## Medications & Supplements (with dosages)\n## Exercise & Fitness Routine\n## Diet, Nutrition & Allergies\n## Sleep Patterns & Recovery\n## Mental Health & Stress Management\n\nUse real details from our conversations. Format as markdown."},{source:"claude",fileType:"preferences",label:"Communication Preferences",description:"Your interaction style and preferences.",recommended:!1,prompt:"Describe my communication preferences based on our interactions — response length, formality, topics I focus on, what format I prefer, and any patterns you've noticed in how I engage."},{source:"claude",fileType:"history",label:"Conversation Themes",description:"Major topics from your Claude chat history.",recommended:!1,prompt:"Summarize the top themes from our conversations: what I ask about most, ongoing projects/goals, recurring concerns, and key decisions I've discussed."},{source:"gemini",fileType:"soul",label:"Profile Summary",description:"Comprehensive profile from your Gemini conversations.",recommended:!0,prompt:"I'm switching to a new AI assistant. Based on everything you know about me from our conversations, create a comprehensive profile:\n\n## About Me\nName, age, location, occupation, personality\n\n## Health & Wellness\nHealth goals, conditions, exercise, diet, supplements, medications, sleep\n\n## Lifestyle\nDaily routines, family, stress, mental health, wearable devices\n\n## Preferences\nCommunication style preferences, frequent topics, values\n\nUse real details from our chats. Markdown format."},{source:"gemini",fileType:"memory",label:"Saved Information",description:"Everything Gemini has saved about you.",recommended:!0,prompt:"List every piece of information you have stored or remember about me. Include all personal details, health data, preferences, goals — everything. One bullet point per fact. Be thorough."},{source:"gemini",fileType:"health",label:"Health Profile",description:"Health-focused export from Gemini.",recommended:!1,prompt:"Create a detailed health and wellness profile based on our conversations. Cover: physical stats, medical history, medications/supplements with dosages, exercise routine, diet/allergies, sleep, and mental health. Use specific details, markdown format."},{source:"gemini",fileType:"preferences",label:"Communication Preferences",description:"Your interaction style as observed by Gemini.",recommended:!1,prompt:"Describe how I prefer to communicate based on our conversations — response style, detail level, format preferences, and any patterns you've noticed."},{source:"gemini",fileType:"history",label:"Conversation Themes",description:"Major topics from your Gemini history.",recommended:!1,prompt:"Summarize the main themes from our conversations: top topics, ongoing goals/projects, recurring questions, and key decisions."},{source:"other",fileType:"soul",label:"Profile Summary",description:"A generic profile export prompt for any AI assistant.",recommended:!0,prompt:"I'm switching to a new AI assistant. Please create a comprehensive profile about me based on our conversations:\n\n## About Me\nName, age, location, occupation, personality, communication style\n\n## Health & Wellness\nGoals, conditions, exercise, diet, supplements, medications, sleep\n\n## Lifestyle\nRoutines, family, stress, mental health, wearable devices\n\n## Preferences\nHow I like information presented, topics I care about\n\nUse specific details from our conversations. Markdown format."}
1,{source:"other",fileType:"memory",label:"Memory Dump",description:"Export all stored facts about you.",recommended:!0,prompt:"List every fact you know or remember about me. One bullet point per fact — personal details, health, preferences, goals, everything. Be thorough."},{source:"other",fileType:"health",label:"Health Profile",description:"Health-focused export.",recommended:!1,prompt:"Create a detailed health profile about me: physical stats, medical history, medications/supplements with dosages, exercise, diet/allergies, sleep, and mental health. Markdown format."},{source:"other",fileType:"preferences",label:"Communication Preferences",description:"Your interaction style.",recommended:!1,prompt:"Describe my communication preferences based on our interactions — response style, detail level, format preferences, and patterns you've noticed."},{source:"other",fileType:"history",label:"Conversation Themes",description:"Major topics summary.",recommended:!1,prompt:"Summarize the main themes from our conversations: top topics, ongoing goals, recurring questions, key decisions."}];function i(e){return s.filter(t=>t.source===e)}function o(e,t){return s.find(r=>r.source===e&&r.fileType===t)}let a={chatgpt:{label:"ChatGPT",icon:"\uD83D\uDFE2",color:"text-green-400"},claude:{label:"Claude",icon:"\uD83D\uDFE0",color:"text-orange-400"},gemini:{label:"Gemini",icon:"\uD83D\uDD35",color:"text-blue-400"},other:{label:"Other AI",icon:"\uD83E\uDD16",color:"text-tertiary"}};function l(e){if(0===e.length)return"";if(1===e.length)return e[0].prompt;let t=e.map((e,t)=>"### ".concat(t+1,". ").concat(e.label,"\n").concat(e.prompt)).join("\n\n");return"I'm moving to a new AI assistant and I want to bring everything you know about me with me. Produce ONE markdown document that covers every numbered section below, in order.\n\nRules:\n- Use a level-2 heading for each section, titled exactly as numbered below.\n- Answer each section fully, following that section's own instructions.\n- Be specific: real names, dates, numbers, dosages, brands, and routines wherever you know them.\n- Never invent. If you don't know something, leave it out rather than guessing.\n- Health facts belong only in the sections that ask for them. Do not infer medical or health data from my communication style or from the topics I discuss.\n\n".concat(t)}let d={soul:{label:"Profile Summary",description:"Comprehensive overview of who you are"},memory:{label:"Memory Export",description:"All stored facts and details"},health:{label:"Health Profile",description:"Health, fitness, and medical data"},preferences:{label:"Communication Style",description:"How you like to interact"},history:{label:"Conversation Themes",description:"Major topics and interests"},identity:{label:"Business Basics",description:"Who the business serves and why it exists"},role_responsibilities:{label:"Your Role",description:"What the owner/operator owns and where Bett-i should help"},current_priorities:{label:"What Matters Now",description:"Current work, blockers, campaigns, and next priorities"},team_relationships:{label:"People and Partners",description:"Team, collaborators, partners, customers, and decision patterns"},tools_systems:{label:"Tools and Data",description:"Channels, systems, automations, and data sources"},communication_style:{label:"Voice and Style",description:"Brand voice, owner voice, taste, and on-brand boundaries"},goals_priorities:{label:"Goals and Success",description:"Business goals, outcomes, constraints, and success metrics"},preferences_constraints:{label:"Rules and Boundaries",description:"Privacy, approvals, budget, risk, and operating constraints"},domain_knowledge:{label:"Industry Context",description:"Market, category, trust, competition, and wellness point of view"},decision_log:{label:"Key Decisions",description:"Durable decisions, rationale, tradeoffs, and open questions"},brand_basics:{label:"Brand Basics",description:"Who the brand is, who it serves, and what it promises"},voice_messaging:{label:"Voice and Messaging",description:"How the brand sounds and what it should say"},visual_identity:{label:"Visual Identity",description:"Colors, type, layout, and recognizable visual feel"},logos_assets:{label:"Logos and Assets",description:"Approved marks, variants, source files, and usage rules"},imagery_motion:{label:"Imagery and Motion",description:"Photos, video, overlays, filters, reels, and motion style"},social_channels:{label:"Social Channels",description:"How the brand shows up across social platforms"},email_newsletter:{label:"Email and Newsletter",description:"Newsletter voice, structure, cadence, and calls to action"},podcast_youtube:{label:"Podcast and YouTube",description:"Long-form, clips, thumbnails, titles, and distribution style"},campaign_templates:{label:"Campaign Patterns",description:"Reusable c
1ampaign formats, offers, and templates"},brand_rules_decisions:{label:"Rules and Decisions",description:"No-go rules, approvals, inspirations, competitors, and open questions"},help:{label:"What We Help With",description:"The problems the agent solves and who it serves"},voice:{label:"Voice and Style",description:"How the agent sounds and its tone boundaries"},boundaries:{label:"Boundaries",description:"What the agent must not do or claim, and when to hand off"}}}}]);

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.