PageSourceSearch

https://nicheretail.com/assets/WorkshopSWOTTool-JJOM9xtm.js

js nicheretail.com collected 2026-10-05 01:14:12 UTC 10,295 bytes, 5 lines download raw bytes

1import{j as e}from"./vendor-query-CX6kXpPt.js";import{aA as se,s as F,B as m,V as G,aI as te,I as H,D as re,e as ae,aJ as oe,f as ne,i as A,h as K,T as Q,Z as U,a1 as E,a2 as I,a3 as O,aH as le,u as L,Q as ie}from"./index-QfuKfl9m.js";import{r as h}from"./vendor-react-9c9vGjwA.js";import{S as ce}from"./WorkshopSkeletons-DHrMH6lB.js";import{u as de}from"./useSessionState-DYrva4dJ.js";import{a as ue,u as he,r as me}from"./useVTOLongTermIssues-CawyBQ-_.js";import{r as pe}from"./undoable-coverage-yMudzUAs.js";import{P as J}from"./PolishButton-CnVrqKiW.js";import{C as ge}from"./crosshair-4M05il__.js";import{E as xe}from"./eraser-CBcHVRWM.js";import{C as Z}from"./chart-pie-CJAUsps4.js";import{S as X}from"./strikethrough-Bl_yrS6W.js";import"./vendor-supabase-DrACM_MH.js";import"./vendor-radix-DhfCpOlC.js";import"./vendor-charts-BM6lVqmw.js";import"./vendor-date-Bf3HPMEs.js";import"./resolveCompanyDepartmentId-Dyjfx9G2.js";import"./useRealtimeCollection-D1l3YLOD.js";import"./rowSync-Dx_YRBAj.js";import"./resilientWrite-D_KnXRfP.js";const w={strengths:{label:"Strengths",short:"S",color:"bg-green-500/5",borderColor:"border-green-500/40"},weaknesses:{label:"Weaknesses",short:"W",color:"bg-red-500/5",borderColor:"border-red-500/40"},opportunities:{label:"Opportunities",short:"O",color:"bg-blue-500/5",borderColor:"border-blue-500/40"},threats:{label:"Threats",short:"T",color:"bg-yellow-500/5",borderColor:"border-yellow-500/40"}},V=["strengths","weaknesses","opportunities","threats"],fe={strengths:"Add strength...",weaknesses:"Add weakness...",opportunities:"Add opportunity...",threats:"Add threat..."},N=o=>{const n=o.startsWith("~~"),c=o.endsWith("~~")&&o.length>2,p=n;return{text:n?o.slice(2,c?-2:void 0):o,struck:p}},Y=(o,n)=>n?`~~${o}~~`:o;function we({section:o,items:n,layout:c,onUpdate:p,onMoveItem:D,onSendToLongTerm:S,onSendToShortTerm:W,onDragStart:z,onDrop:j,onDragEnd:T}){const[k,b]=h.useState(""),[C,g]=h.useState(null),[x,d]=h.useState(""),[B,f]=h.useState(null),M=h.useRef(null),y=w[o],R=c==="grid",$=()=>{const t=k.trim();t&&(p([...n,t]),b(""),setTimeout(()=>M.current?.focus(),0))},_=t=>p(n.filter((r,i)=>i!==t)),P=t=>{const r=[...n],{text:i,struck:u}=N(r[t]);r[t]=u?i:Y(i,!0),p(r)},q=t=>{g(t),d(N(n[t]).text)},s=t=>{const r=x.trim();if(!r)_(t);else{const i=[...n],u=N(i[t]).struck;i[t]=Y(r,u),p(i)}g(null)},a=V.filter(t=>t!==o);return e.jsxs("div",{className:G("rounded-lg border p-4",y.borderColor,y.color),onDragOver:t=>t.preventDefault(),onDrop:t=>{t.preventDefault(),f(null),j(o,n.length)},children:[e.jsx("h4",{className:"font-semibold text-sm mb-3",children:y.label}),e.jsx("div",{className:"space-y-0.5",children:n.map((t,r)=>{const{text:i,struck:u}=N(t),v=B===r;return e.jsxs("div",{className:G("group flex items-center gap-2 py-1.5 px-2 rounded-md hover:bg-muted/50 transition-all cursor-grab active:cursor-grabbing",v&&"ring-1 ring-[hsl(221,100%,45%)] bg-muted/30"),draggable:!0,onDragStart:l=>{l.dataTransfer.effectAllowed="move",z(o,r)},onDragOver:l=>{l.preventDefault(),l.stopPropagation(),f(r)},onDragLeave:()=>f(null),onDrop:l=>{l.preventDefault(),l.stopPropagation(),f(null),j(o,r)},onDragEnd:()=>{f(null),T()},children:[e.jsx(te,{className:"w-3 h-3 text-muted-foreground shrink-0"}),C===r?e.jsxs(e.Fragment,{children:[e.jsx(H,{value:x,onChange:l=>d(l.target.value),onBlur:()=>s(r),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),s(r)),l.key==="Escape"&&g(null)},className:"h-7 text-sm flex-1",autoFocus:!0}),e.jsx(J,{value:x,onAccept:l=>d(l),context:`workshop_swot_${o}_edit`,size:"xs",className:"shrink-0"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:G("text-sm flex-1 min-w-0 cursor-text",u&&"line-through text-muted-foreground"),onClick:()=>q(r),children:i}),R?e.jsxs(re,{children:[e.jsx(ae,{asChild:!0,children:e.jsx(m,{variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(oe,{className:"w-3.5 h-3.5"})})}),e.jsxs(ne,{align:"end",children:[a.map(l=>e.jsxs(A,{onClick:()=>D(t,o,l),children:[e.jsx("span",{className:"font-bold mr-2 w-4 text-center",children:w[l].short})," Move to ",w[l].label]},l)),e.jsx(K,{}),e.jsxs(A,{onClick:()=>S(i),children:[e.jsx(Z,{className:"w-3.5 h-3.5 mr-2"})," Long-Term Issue"]}),e.jsxs(A,{onClick:()=>W(i),children:[e.jsx(Q,{className:"w-3.5 h-3.5 mr-2"})," L10 Issue"]}),e.jsx(K,{}),e.jsxs(A,{onClick:()=>P(r),children:[e.jsx(X,{className:"w-3.5 h-3.5 mr-2"})," Strikethrough"]}),e.jsxs(A,{className:"text-destructive",onClick:()=>_(r),children:[e.jsx(U,{className:"w-3.5 h-3.5 mr-2"})," Delete"]})]})]}):e.jsxs("div",{className:"opacity-0 group-hover:opacity-100 flex items-center gap-0.5 shrink-0 transition-opacity",children:[a.map(l=>e.jsxs(E,{children:[e.jsx(I,{asChild:!0,children:e.jsx(m,{variant:"ghost",size:"icon",className:"h-5 w-5 text-xs font-bold",onClick:()=>D(t,o,l),children:w[l].short})}),e.jsxs(O,{className:"text-xs",children:["Move to ",w[l].label]})]},l)),e.jsxs(E,{children:[e.jsx(I,{asChild:!0,children:e.jsx(m,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>S(i),children:e.jsx(Z,{className:"w-3 h-3"})})}),e.jsx(O,{className:"text-xs",children:"Long-Term Issue"})]}),e.jsxs(E,{children:[e.jsx(I,{asChild:!0,children:e.jsx(m,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>W(i),children:e.jsx(Q,{className:"w-3 h-3"})})}),e.jsx(O,{className:"text-xs",children:"L10 Issue"})]}),e.jsxs(E,{children:[e.jsx(I,{asChild:!0,children:e.jsx(m,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>P(r),children:e.jsx(X,{className:"w-3 h-3"})})}),e.jsx(O,{className:"text-xs",children:"Strikethrough"})]}),e.jsxs(E,{children:[e.jsx(I,{asChild:!0,children:e.jsx(m,{variant:"ghost",size:"icon",className:"h-5 w-5 text-destructive",onClick:()=>_(r),children:e.jsx(U,{className:"w-3 h-3"})})}),e.jsx(O,{className:"text-xs",children:"Delete"})]})]})]})]},r)})}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(H,{ref:M,value:k,onChange:t=>b(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),$())},placeholder:fe[o],className:"h-8 text-sm flex-1"}),e.jsx(J,{value:k,onAccept:t=>b(t),context:`workshop_swot_${o}_add`,size:"xs",className:"shrink-0"}),e.jsx(m,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:$,disabled:!k.trim(),children:e.jsx(le,{className:"w-4 h-4"})})]})]})}function Ve({contactId:o}){const[n,c]=h.useState({strengths:[],weaknesses:[],opportunities:[],threats:[]}),[p,D]=h.useState(!0),[S,W]=de(`ws-${o}-swot-layout`,"grid"),[z,j]=h.useState(null),T=h.useRef(null),{addLongTermIssue:k}=ue(o),b=se(),{debouncedSync:C}=he(o,["vto"]);h.useEffect(()=>{pe("swot"),me("swot")},[]);const g=s=>s?s.includes("<p>")||s.includes("<br")?s.replace(/<p>/gi,`
2`).replace(/<\/p>/gi,"").replace(/<br\s*\/?>/gi,`
3`).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&nbsp;/g," ").split(`
4`).map(t=>
4t.replace(/^[\s•\- -  - ]+/,"").trim()).filter(Boolean):s.split(`
5`).map(a=>a.replace(/^[\s•\- -  - ]+/,"").trim()).filter(Boolean):[],x=s=>s.length===0?null:s.map(a=>`<p>• ${a}</p>`).join("");h.useEffect(()=>{(async()=>{const{data:s}=await F.from("contact_vto").select("swot_strengths, swot_weaknesses, swot_opportunities, swot_threats").eq("contact_id",o).maybeSingle();s&&c({strengths:g(s.swot_strengths),weaknesses:g(s.swot_weaknesses),opportunities:g(s.swot_opportunities),threats:g(s.swot_threats)}),D(!1)})()},[o]);const d=h.useCallback(s=>{T.current&&clearTimeout(T.current),T.current=setTimeout(async()=>{await F.from("contact_vto").update({swot_strengths:x(s.strengths),swot_weaknesses:x(s.weaknesses),swot_opportunities:x(s.opportunities),swot_threats:x(s.threats),updated_at:new Date().toISOString()}).eq("contact_id",o),C()},800)},[o,C]),B=(s,a)=>{const t={...n},r={...n,[s]:a};if(c(r),d(r),a.length<t[s].length){const i=t[s].find(u=>!a.includes(u));b?.pushAction({label:`Delete ${w[s].label}: ${(i||"").slice(0,30)}`,undo:async()=>{c(t),d(t)},redo:async()=>{c(r),d(r)}})}},f=V.some(s=>n[s].some(a=>N(a).struck)),M=()=>{if(!f||!window.confirm("Permanently delete all struck-through SWOT items?"))return;const s={...n},a=V.reduce((t,r)=>(t[r]=n[r].filter(i=>!N(i).struck),t),{});c(a),d(a),b?.pushAction({label:"Delete all SWOT strikethroughs",undo:async()=>{c(s),d(s)},redo:async()=>{c(a),d(a)}}),L.success("Deleted all struck-through SWOT items")},y=(s,a,t)=>{const r={...n,[a]:n[a].filter(i=>i!==s),[t]:[...n[t],s]};c(r),d(r),L.success(`Moved to ${w[t].label}`)},R=(s,a)=>{j({fromSection:s,fromIdx:a})},$=(s,a)=>{if(!z)return;const{fromSection:t,fromIdx:r}=z,i=n[t][r];if(!i){j(null);return}if(t===s){const u=[...n[t]];u.splice(r,1),u.splice(a,0,i);const v={...n,[t]:u};c(v),d(v)}else{const u=n[t].filter((je,ee)=>ee!==r),v=[...n[s]];v.splice(a,0,i);const l={...n,[t]:u,[s]:v};c(l),d(l),L.success(`Moved to ${w[s].label}`)}j(null)},_=()=>j(null),P=async s=>{await k(s),L.success("Added to Long-Term Issues")},q=async s=>{const{data:a}=await ie();await F.from("issues").insert({title:s,contact_id:o,is_long_term:!1,created_by:a.user?.id}),L.success("Added to L10 Issues"),C()};return p?e.jsx(ce,{}):e.jsxs("div",{className:"w-full px-4 py-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ge,{className:"w-5 h-5 text-[hsl(var(--ws-highlight-color))]"}),e.jsx("h3",{className:"font-semibold text-sm",children:"SWOT Analysis"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(m,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5",onClick:M,disabled:!f,children:[e.jsx(xe,{className:"w-3 h-3"}),"Delete all strikethroughs"]}),e.jsx(m,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1.5 text-muted-foreground",onClick:()=>W(s=>s==="grid"?"list":"grid"),children:S==="grid"?"List View":"Grid View"})]})]}),e.jsx("div",{className:`grid gap-4 ${S==="list"?"grid-cols-1":"grid-cols-1 md:grid-cols-2"}`,children:V.map(s=>e.jsx(we,{section:s,items:n[s],layout:S,onUpdate:a=>B(s,a),onMoveItem:y,onSendToLongTerm:P,onSendToShortTerm:q,onDragStart:R,onDrop:$,onDragEnd:_},s))}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-3",children:"Changes auto-save. Drag items to reorder or move between quadrants."})]})}export{Ve as WorkshopSWOTTool};

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.