1import{r as n,j as e}from"./vendor-react-CjtdLP_L.js";import{a as Ja}from"./skill-attribution-B63CkjKI.js";import{L as ua,g as ut,b as yi}from"./index-DpJDnEHE.js";import{b as wi,u as ue,a as Oe}from"./vendor-query-Dm6IpjeQ.js";import{L as ws,c as Te,a as Xa,d as ki,b as Ni}from"./ledger-CR3N8AXT.js";import{a as Ze}from"./api-error-message-C03AM46c.js";import{P as Si,c as Pi,a as Ci,o as Ti,l as Ii,p as Di,i as Li,k as Jt,q as Za,j as Ri}from"./languageDetection-pnolG1oX.js";import{I as de,b as Ei,v as es,p as ma,u as Ai,r as ts,c as Fi,h as _i,a as as,S as Mi}from"./prompt-score-zynwKfto.js";import{S as zi,D as Ui}from"./SEO-BQ6_qkGs.js";import{a9 as $i,p as ha,aa as Oi,u as Ki,$ as ss,_ as qi,ab as mt}from"./useAuth-BOD9I5M3.js";import{u as ks}from"./index-CTrG49eW.js";import{B as h}from"./button-CgHkADzY.js";import{p as Xt,r as Wi,A as Qi,J as is}from"./JurisdictionFlag-pnpFg1M0.js";import{K as Hi,a5 as Bi,N as Vi,a6 as Gi}from"./Navigation-BihYueM1.js";import{u as Yi}from"./useAuthGate-CbR14_wN.js";import{u as Et,i as p,I as tt,E as pe,S as Ji,e as Xi,A as Zi}from"./AuthModal-XlKB8C9v.js";import{a as oe,q as F}from"./queryClient-CAqhRfHG.js";import{F as er}from"./Footer-i6iw7uTD.js";import{r as tr,R as ar,a as sr}from"./RubricBadge-Bzeu8V43.js";import{F as ir}from"./FeedbackButtons-BOKVBqd6.js";import{F as rr}from"./FeedbackIcon-BSscZfcF.js";import{u as nr,S as lr}from"./ShareDialog-Bc8SrO6p.js";import{a as x}from"./utils-09jiQjc0.js";import{B as H,b as Zt,a as ea}from"./badge-C1_E7bcS.js";import{D as Ns,f as or,c as Ss,d as Ps,g as cr}from"./dialog-BmoBvzwc.js";import{f as et}from"./format-display-title-B__cDUCD.js";import{u as qe}from"./vendor-i18n-B-dTb0jX.js";import{b9 as dr,D as ft,L as ye,E as Cs,j as pr,ak as fa,O as ur,r as Fe,S as Ts,aP as mr,bZ as hr,b_ as xr,am as fr,o as ga,a as gr,g as vr,aT as br,w as Is,bu as rs,G as ns,ay as jr,W as yr,ad as wr,_ as Ke,d as kr,q as Nr,aK as Ds,l as Sr,Z as Pr,A as Cr,F as ta,f as aa,bK as Tr,b$ as Xe,b1 as Ir,aj as sa,X as ht,n as ls,m as os,x as Dr,b2 as ia,c0 as Lr,c1 as Rr,az as cs,I as Er,a_ as Ar,a9 as Fr}from"./vendor-icons-CEtKkbCp.js";import{S as _r}from"./ShareLinkSheet-CPu_tehk.js";import{T as Ls}from"./textarea-DFjcW1kC.js";import{D as Mr,a as zr,b as Ur,e as $r,d as Or,c as Kr}from"./dropdown-menu-YjUv8fUk.js";import{u as qr}from"./useTileUpdateListener-BvQFUS8M.js";import{S as Wr,b as Qr,c as Hr,s as Br,e as Vr,d as Gr}from"./vendor-react-icons-C3u-PHNU.js";import{S as Yr}from"./SarvamIcon-De_a9IwZ.js";import{S as Jr}from"./categories-C1hOYFnK.js";import{S as Xr,a as Zr,b as en,c as tn,d as an}from"./select-ypFJox8d.js";import{f as ra,g as na,h as la,T as ds}from"./workspace-account-requests-DGgpqxXh.js";import{U as sn}from"./UpgradeBanner-D3aFJgwl.js";import{u as rn}from"./useCustomPlatforms-G_FlZRfu.js";import{C as nn}from"./chip-BYlQls2d.js";import{S as ln}from"./SecurityBadge-DiBKZkIi.js";import{S as on,a as cn,b as dn}from"./SecureScanReportCard-Cg4h-kCE.js";import{S as pn}from"./SharedArrivalJoinPrompt-3ROZEI-q.js";import{B as un}from"./BrandIcon-SNc4vegW.js";import{A as mn,m as Rs}from"./vendor-motion-DcfotHwo.js";import{g as hn}from"./platform-invocation-CU8J6FvP.js";import{t as xn}from"./telemetry-28uAHTar.js";import{r as fn,m as gn,O as vn,d as bn,L as ps,f as jn,s as yn,a as wn,b as us,p as kn,n as Nn,c as Sn,e as Pn}from"./skill-downloads-D0SOTZ93.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./index-DYd1AhEw.js";import"./index-DMBtqBCC.js";import"./index-CfHttwlL.js";import"./index-Bnm5UW7A.js";import"./index-CaH9w3gZ.js";import"./public-product-facts-DAmplUKb.js";import"./consent-D3s5Yi52.js";import"./index-DC01emjG.js";import"./workspace-context-CmD3Vyun.js";import"./index-CXo7hDKg.js";import"./auth-return-to-JRaTzEJL.js";import"./index-CFQO6bFv.js";import"./Logo-Dtk25poC.js";import"./BeaconMark-BfuppPGY.js";import"./app-chrome-Chb-SQcU.js";import"./beacon-access-LXtv0J6t.js";import"./workspace-route-transition-Dap2JeOj.js";import"./WorkspacePreferences-CMsTGmr9.js";import"./supabase--Raqy1d_.js";import"./share-analytics-EOpSDkM1.js";import"./index-NncAJq6c.js";import"./index-Bl7FDrSo.js";import"./index-D8gd2y9N.js";import"./beacon-request-Bo3SWsEZ.js";import"./useCountryDiscount-Dvd2i3oO.js";import"./security-references-CGtyBTnB.js";import"./prompeteer-brand-DVsJ2OA0.js";const Cn=["pages","prompts","shares","personalPrompts","publishedPrompts","purchases","data"],Tn=i=>i&&typeof i=="object"?i.prompt&&typeof i.prompt=="object"?i.prompt.id:i.id:void 0;function xa(i,o){if(!i||!o||typeof i!="object")return i;if(Array.isArray(i)){let l=!1;const m=[];for(const v of i){if(Tn(v)===o){l=!0;continue}const I=xa(v,o);I!==v&&(l=!0),m.push(I)}return l?m:i}let c=!1;const d={...i};for(const l of Cn){if(i[l]===void 0)continue;const m=xa(i[l],o);m!==i[l]&&(d[l]=m,c=!0)}return c?d:i}const In=new Set(["personal-prompts-infinite","vault-unified-data","/api/prompt-library/personal","/api/prompts/shared-by-me"]);function Dn(i,o){o&&i.setQueriesData({predicate:c=>Array.isArray(c.queryKey)&&In.has(String(c.queryKey[0]))},c=>xa(c,o))}function Ln({isOpen:i,onClose:o,prompt:c}){const{t:d}=qe(),[l,m]=n.useState(""),[v,I]=n.useState(""),[P,E]=n.useState(!1),[D,C]=n.useState(null),[u,j]=n.useState(!1),y=n.useRef(null),U=n.useRef(null),W=n.useRef(null),{toast:L}=Et(),A=wi(),Z=`/api/prompts/${c?.id}/shares`,{data:ge,isLoading:fe,isFetching:Q}=ue({queryKey:[Z],enabled:i&&!!c?.id}),{data:J}=ue({queryKey:["/api/enterprise-company/team-members"],enabled:i,staleTime:1e3*60*5}),_=J?.members||[],B=_.filter(f=>{if(!l.trim())return!0;const S=l.toLowerCase();return f.email.toLowerCase().includes(S)||f.displayName.toLowerCase().includes(S)}),V=f=>{m(f.email),j(!1),I("")};n.useEffect(()=>{const f=S=>{W.current&&!W.current.contains(S.target)&&y.current&&!y.current.contains(S.target)&&j(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const k=Oe({mutationFn:async f=>await oe("/api/prompts/share","POST",{promptId:c?.id,email:f,shareType:"email"}),onSuccess:f=>{f.success!==!1?(E(!0),L({title:"Content shared!",description:`Successfully shared with ${l}`}
1),A.invalidateQueries({queryKey:[Z]}),A.invalidateQueries({queryKey:["/api/prompts/shared-by-me"]}),A.invalidateQueries({predicate:S=>{const T=S.queryKey;return Array.isArray(T)&&T[0]==="vault-unified-data"}}),U.current&&clearTimeout(U.current),U.current=setTimeout(()=>{U.current=null,m(""),E(!1)},1500)):I(f.error||"Failed to share content")},onError:f=>{const S=Ze(f,"Failed to share. Please try again.");I(S),L({title:"Share failed",description:S,variant:"destructive"})}}),s=Oe({mutationFn:async f=>await oe(`/api/prompts/share/${f}`,"DELETE"),onMutate:async f=>{C(f),await A.cancelQueries({queryKey:[Z]});const S=A.getQueryData([Z]);if(S){const T=S.shares.filter(X=>X.id!==f);A.setQueryData([Z],{...S,shares:T})}return{previousShares:S,shareId:f}},onSuccess:(f,S,T)=>{C(null),f.success!==!1?(L({title:"Share revoked",description:"User can no longer access this content"}),A.invalidateQueries({queryKey:[Z]}),A.invalidateQueries({queryKey:["/api/prompts/shared-by-me"]}),A.invalidateQueries({predicate:X=>{const te=X.queryKey;return Array.isArray(te)&&te[0]==="vault-unified-data"}})):(T?.previousShares&&A.setQueryData([Z],T.previousShares),L({title:"Unshare failed",description:f.error||"Failed to revoke share",variant:"destructive"}))},onError:(f,S,T)=>{C(null),T?.previousShares&&A.setQueryData([Z],T.previousShares);const X=Ze(f,"Failed to revoke share. Please try again.");L({title:"Unshare failed",description:X,variant:"destructive"})}});n.useEffect(()=>()=>{U.current&&clearTimeout(U.current)},[]),n.useEffect(()=>{i||(U.current&&(clearTimeout(U.current),U.current=null),m(""),I(""),E(!1),C(null))},[i]);const ve=f=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f),$=()=>{if(I(""),!l.trim()){I("Please enter an email address");return}if(!ve(l)){I("Please enter a valid email address");return}k.mutate(l.trim())},M=f=>{s.mutate(f)},R=f=>{f.key==="Enter"&&!k.isPending&&$()},ce=f=>{if(f.sharedWith){const{firstName:S,lastName:T,email:X}=f.sharedWith;return S||T?`${S||""} ${T||""}`.trim():X}return f.recipientEmail||"Unknown user"},K=f=>f.sharedWith?.email?f.sharedWith.email:f.recipientEmail||"",be=f=>{const S=new Date(f);return S.toLocaleDateString("en-US",{month:"short",day:"numeric",year:S.getFullYear()!==new Date().getFullYear()?"numeric":void 0})},we=ge?.shares||[];return e.jsx(Ns,{open:i,onOpenChange:f=>{f||o()},children:e.jsxs(or,{className:"flex max-w-md flex-col gap-0 overflow-hidden p-0","aria-modal":"true","data-testid":"dialog-share-user",overlayProps:{"data-testid":"share-user-dialog-backdrop"},onOpenAutoFocus:f=>{f.preventDefault(),y.current?.focus()},children:[e.jsxs("div",{className:"flex items-start gap-3 border-b border-[var(--public-hairline)] px-5 pb-4 pt-5 sm:px-6",children:[e.jsx("span",{className:p.tile,"aria-hidden":"true",children:e.jsx(dr,{className:"h-5 w-5 text-[var(--public-ink-2)]"})}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[e.jsx(Ss,{className:p.h3,children:d("shareWithUser.sharePrompt")}),e.jsx(Ps,{className:p.small,children:d("shareWithUser.shareDescription")})]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-y-auto px-5 pb-6 pt-4 sm:px-6",children:[c&&e.jsxs("div",{className:"rounded-[var(--public-radius-control)] border border-[var(--public-hairline)] bg-[var(--public-surface-2)] p-3",children:[e.jsx("p",{className:x(p.metaCaps,"mb-1"),children:d("shareWithUser.sharing")}),e.jsx("p",{className:"truncate text-[14px] font-medium text-[var(--public-ink)]",children:c.title?et(c.title):d("shareWithUser.untitledPrompt")})]}),we.length>0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ft,{className:"h-4 w-4 text-[var(--public-ink-3)]","aria-hidden":"true"}),e.jsx("span",{className:"text-[13px] font-medium text-[var(--public-ink)]",children:d("shareWithUser.currentlySharedWith",{count:we.length})}),Q&&e.jsx(ye,{className:"h-3 w-3 animate-spin text-[var(--public-ink-3)] motion-reduce:animate-none","aria-hidden":"true"})]}),e.jsx("div",{className:"max-h-32 divide-y divide-[var(--public-hairline)] overflow-y-auto rounded-[var(--public-radius-control)] border border-[var(--public-hairline)]",children:we.map(f=>e.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2","data-testid":`share-item-${f.id}`,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"truncate text-[14px] font-medium text-[var(--public-ink)]",children:ce(f)}),f.seenAt?e.jsxs(H,{job:"verification",size:"xs","data-testid":`status-viewed-${f.id}`,children:[e.jsx(Cs,{className:"h-3 w-3","aria-hidden":"true"}),d("shareWithUser.viewed")]}):e.jsxs(H,{job:"status",size:"xs","data-testid":`status-pending-${f.id}`,children:[e.jsx(pr,{className:"h-3 w-3","aria-hidden":"true"}),d("shareWithUser.pending")]})]}),e.jsxs("p",{className:x(p.meta,"truncate"),children:[K(f)," · ",be(f.createdAt)]})]}),e.jsx(h,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>M(f.id),disabled:D===f.id,"aria-label":d("shareWithUser.revokeAccess"),title:d("shareWithUser.revokeAccess"),className:"shrink-0 hover:text-[var(--public-danger)]","data-testid":`button-unshare-${f.id}`,children:D===f.id?e.jsx(ye,{className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}):e.jsx(fa,{"aria-hidden":"true"})})]},f.id))})]}),fe&&e.jsxs("div",{className:x(p.small,"flex items-center justify-center gap-2 py-3"),children:[e.jsx(ye,{className:"h-4 w-4 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsx("span",{children:d("shareWithUser.loadingShares")}
1)]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{htmlFor:"share-email",className:"text-[13px] font-medium text-[var(--public-ink)]",children:we.length>0?d("shareWithUser.shareWithAnother"):d("shareWithUser.recipientEmail")}),e.jsxs("div",{className:"relative",children:[e.jsx(tt,{ref:y,id:"share-email",type:"email",startIcon:e.jsx(ur,{}),value:l,onChange:f=>{m(f.target.value),I(""),_.length>0&&j(!0)},onFocus:()=>{_.length>0&&j(!0)},onKeyDown:R,placeholder:d("shareWithUser.emailPlaceholder"),disabled:k.isPending||P,"aria-invalid":v?!0:void 0,"aria-describedby":v?"share-email-error":void 0,"data-testid":"input-share-email",autoComplete:"off"}),u&&B.length>0&&e.jsxs("div",{ref:W,className:"absolute left-0 right-0 top-full z-10 mt-1 max-h-48 overflow-y-auto rounded-[var(--public-radius-control)] border border-[var(--public-hairline)] bg-[var(--public-ground)] shadow-lift",children:[e.jsx("div",{className:"border-b border-[var(--public-hairline)] px-3 py-1.5",children:e.jsxs("span",{className:x(p.metaCaps,"flex items-center gap-1"),children:[e.jsx(ft,{className:"h-3 w-3","aria-hidden":"true"}),d("shareWithUser.teamMembers","Team Members")]})}),B.map(f=>e.jsxs(h,{type:"button",variant:"ghost",onClick:()=>V(f),className:"h-auto min-h-0 w-full justify-start gap-3 rounded-none px-3 py-2.5 text-left font-normal",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-full bg-[var(--public-surface-2)]",children:f.profileImageUrl?e.jsx("img",{src:f.profileImageUrl,alt:"",className:"h-8 w-8 rounded-full object-cover"}):e.jsx("span",{className:"text-[11px] font-semibold text-[var(--public-ink-2)]",children:f.displayName.split(" ").map(S=>S[0]).join("").slice(0,2).toUpperCase()})}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:"truncate text-[14px] font-medium text-[var(--public-ink)]",children:f.displayName}),e.jsx("span",{className:x(p.meta,"truncate"),children:f.email})]})]},f.id))]})]}),e.jsx("span",{id:"share-email-error",children:e.jsx(de,{status:v?{anchor:"share",tone:"error",message:v}:null})})]}),e.jsx(h,{type:"button",fullWidth:!0,onClick:$,disabled:k.isPending||P||!l.trim(),"data-testid":"button-share-user-submit",children:k.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsx("span",{children:d("shareWithUser.sharingInProgress")})]}):P?e.jsxs(e.Fragment,{children:[e.jsx(Fe,{"aria-hidden":"true"}),e.jsx("span",{children:d("shareWithUser.sharedSuccessfully")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ts,{"aria-hidden":"true"}),e.jsx("span",{children:d("shareWithUser.sharePromptButton")})]})}),e.jsx("p",{className:x(p.meta,"text-center"),children:d("shareWithUser.incomingTabInfo")})]})]})})}const Rn=[["Save changes","â + Enter"],["Undo","â + Z"],["Redo","â + â§ + Z"],["Find & Replace","â + F"],["Close dialog","Esc"],["Show shortcuts","?"]],ms="flex items-center gap-0.5 rounded-[var(--public-radius-control)] border border-[var(--public-hairline)] bg-[var(--public-ground)] p-0.5";function En({isOpen:i,onClose:o,onSave:c,promptText:d,promptId:l,versionsApiPath:m,isSaving:v=!1,saveError:I=null}){const[P,E]=n.useState(d),[D,C]=n.useState(16),[u,j]=n.useState(!1),[y,U]=n.useState(!1),[W,L]=n.useState(!1),[A,Z]=n.useState(""),[ge,fe]=n.useState(""),[Q,J]=n.useState([]),[_,B]=n.useState(0),[V,k]=n.useState([]),[s,ve]=n.useState(""),[$,M]=n.useState([]),[R,ce]=n.useState([]),K=n.useRef(null),be=n.useRef(null),{toast:we}=Et(),f=n.useMemo(()=>V.find(b=>b.text===P)?.label||"Original",[V,P]),S=()=>{K.current&&be.current&&(be.current.scrollTop=K.current.scrollTop)};n.useEffect(()=>{const g=localStorage.getItem("prompt-editor-font-size");g&&C(parseInt(g,10));const b=localStorage.getItem("prompt-editor-line-numbers");b&&j(b==="true")},[]);const T=m||`/api/prompts/${l}/versions`,{data:X}=ue({queryKey:["prompt-versions",l,m],queryFn:async()=>l?await oe(T,"GET"):{versions:[]},enabled:i&&!!l,staleTime:0});n.useEffect(()=>{i&&(X?.versions&&X.versions.length>0?k(X.versions):k([{text:d,timestamp:Date.now(),label:"Original"}]))},[i,d,X]);const te=n.useRef(null);n.useEffect(()=>{if(!i){te.current=null;return}const g=te.current===null,b=te.current;E(O=>g||O===b?d:O),g&&(M([]),ce([])),te.current=d},[i,d]),n.useEffect(()=>{if(!i||!P)return;const g=setInterval(()=>{const O=`prompt-editor-draft-${d.substring(0,50).replace(/[^a-zA-Z0-9]/g,"")}`;localStorage.setItem(O,P),localStorage.setItem(`${O}-timestamp`,Date.now().toString());const De=new Date().toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});ve(De);const jt=Object.keys(localStorage).filter(Le=>Le.startsWith("prompt-editor-draft-")&&!Le.endsWith("-timestamp")).sort().reverse();jt.length>
15&&jt.slice(5).forEach(Le=>{localStorage.removeItem(Le),localStorage.removeItem(`${Le}-timestamp`)})},5e3);return()=>clearInterval(g)},[i,P,d]),n.useEffect(()=>{if(!i)return;const g=b=>{if((b.metaKey||b.ctrlKey)&&b.key==="f"&&(b.preventDefault(),U(!0)),(b.metaKey||b.ctrlKey)&&b.key==="z"&&!b.shiftKey&&$.length>0){b.preventDefault();const O=$[$.length-1];ce(ae=>[...ae,P]),E(O),M(ae=>ae.slice(0,-1))}if(((b.metaKey||b.ctrlKey)&&b.key==="z"&&b.shiftKey||(b.metaKey||b.ctrlKey)&&b.key==="y")&&R.length>0){b.preventDefault();const O=R[R.length-1];M(ae=>[...ae,P]),E(O),ce(ae=>ae.slice(0,-1))}b.key==="?"&&b.shiftKey&&(b.preventDefault(),L(O=>!O))};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[i,$,R,P]);const se=n.useMemo(()=>{const g=P.length,b=P.trim().split(/\s+/).filter(De=>De.length>0).length,O=P.split(` 2`).length,ae=Math.ceil(b/200);return{chars:g,words:b,lines:O,readingTime:ae}},[P]),ee=n.useMemo(()=>u?Array.from({length:se.lines},(g,b)=>b+1).join(` 3`):"",[u,se.lines]);n.useEffect(()=>{if(!A){J([]),B(0);return}const g=new RegExp(A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi"),b=[];let O;for(;(O=g.exec(P))!==null;)b.push(O.index);J(b),B(0),b.length>0&&K.current&&setTimeout(()=>{if(K.current&&b.length>0){const ae=b[0];K.current.focus(),K.current.setSelectionRange(ae,ae+A.length);const De=parseInt(window.getComputedStyle(K.current).lineHeight)||20,Me=P.substring(0,ae).split(` 4`).length;K.current.scrollTop=Math.max(0,(Me-3)*De)}},100)},[A,P]);const ie=P.length>5e4,Ie=async()=>{if(ie||v)return;try{await c(P)}catch{return}const g={text:P,timestamp:Date.now(),label:`V${V.length}`};k(b=>[...b,g]),M([]),ce([]),o()},_e=g=>{const b=P;b!==g&&b!==$[$.length-1]&&M(O=>[...O,b].slice(-50)),E(g),R.length>0&&ce([])},We=g=>{_e(g.target.value)},gt=g=>{(g.metaKey||g.ctrlKey)&&g.key==="Enter"&&(g.preventDefault(),Ie())},Re=()=>{v||(E(d),M([]),ce([]),o())},st=()=>{if($.length>0){const g=$[$.length-1];ce(b=>[...b,P]),E(g),M(b=>b.slice(0,-1))}},Qe=()=>{if(R.length>0){const g=R[R.length-1];M(b=>[...b,P]),E(g),ce(b=>b.slice(0,-1))}},it=g=>{const b=Math.max(12,Math.min(20,D+g));C(b),localStorage.setItem("prompt-editor-font-size",b.toString())},He=()=>{const g=!u;j(g),localStorage.setItem("prompt-editor-line-numbers",g.toString())},rt=g=>{_e(g.text),we({title:"Version Restored",description:`Restored to ${g.label}`})},At=()=>{if(Q.length===0)return;const g=Q[_],b=P.substring(0,g),O=P.substring(g+A.length);_e(b+ge+O),B(0)},vt=()=>{if(!A)return;const g=new RegExp(A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi"),b=P.replace(g,ge);_e(b),J([]),B(0),we({title:"Replaced All",description:`Replaced ${Q.length} occurrence(s)`})},bt=g=>{if(Q.length===0)return;let b;if(g==="next"?b=(_+1)%Q.length:b=(_-1+Q.length)%Q.length,B(b),K.current){const O=Q[b];K.current.focus(),K.current.setSelectionRange(O,O+A.length);const ae=parseInt(window.getComputedStyle(K.current).lineHeight)||20,De=P.substring(0,O).split(` 5`).length;K.current.scrollTop=(De-3)*ae}};return e.jsx(Ns,{open:i,onOpenChange:g=>{g||Re()},children:e.jsxs(cr,{className:"gap-0 overflow-hidden p-0","aria-modal":"true","data-testid":"dialog-edit-prompt",onOpenAutoFocus:g=>{g.preventDefault(),K.current?.focus()},onEscapeKeyDown:g=>{v?g.preventDefault():y&&(g.preventDefault(),U(!1))},onPointerDownOutside:g=>g.preventDefault(),children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-[var(--public-hairline)] px-3 py-2 md:px-8 md:py-4",children:[e.jsxs("div",{className:"flex min-w-0 flex-col",children:[e.jsx(Ss,{className:"text-[18px] font-semibold leading-tight tracking-[-0.02em] text-[var(--public-ink)] md:text-[22px]",children:"Edit Prompt"}),e.jsx(Ps,{className:"sr-only",children:"Edit the prompt text, then save or cancel."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 md:gap-2",children:[e.jsxs("div",{className:ms,children:[e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:st,disabled:$.length===0,"aria-label":"Undo",title:`Undo${$.length>0?` (${$.length} changes)`:""}`,"data-testid":"button-undo",children:e.jsx(mr,{"aria-hidden":"true"})}),e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:Qe,disabled:R.length===0,"aria-label":"Redo",title:`Redo${R.length>0?` (${R.length} changes)`:""}`,"data-testid":"button-redo",children:e.jsx(hr,{"aria-hidden":"true"})})]}),e.jsxs("div",{className:x(ms,"hidden sm:flex"),children:[e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:()=>it(-2),disabled:D<=12,"aria-label":"Decrease font size",title:"Decrease font size",className:"font-mono text-[12px]","data-testid":"button-font-decrease",children:"A-"}),e.jsx("span",{className:x(p.meta,"px-1"),"aria-hidden":"true",children:"A"}),e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:()=>it(2),disabled:D>=20,"aria-label":"Increase font size",title:"Increase font size",className:"font-mono text-[12px]","data-testid":"button-font-increase",children:"A+"})]}),e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:He,selected:u,"aria-pressed":u,"aria-label":"Line numbers",title:"Toggle line numbers",className:"hidden md:inline-flex","data-testid":"button-line-numbers",children:e.jsx(xr,{"aria-hidden":"true"})}),e.jsxs(Mr,{children:[e.jsx(zr,{asChild:!0,children:e.jsxs(h,{variant:"outline",size:"sm","aria-label":`Version history, ${f}`,title:"Version history","data-testid":"button-version-history",children:[e.jsx(fr,{"aria-hidden":"true"}),e.jsx("span",{className:"hidden font-mono text-[12px] md:inline",children:f}),e.jsx(ga,{"aria-hidden":"true"})]})}
5),e.jsxs(Ur,{align:"end",className:"w-[min(18rem,calc(100vw-2rem))]",children:[e.jsx($r,{className:p.metaCaps,children:"Version History"}),e.jsx(Or,{}),e.jsx("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:V.map((g,b)=>e.jsxs(Kr,{onSelect:()=>rt(g),className:"flex min-h-11 items-center justify-between gap-3","data-testid":`button-version-${g.label.toLowerCase().replace(" ","-")}`,children:[e.jsxs("span",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-[14px] font-semibold text-[var(--public-ink)]",children:g.label}),e.jsx("span",{className:p.meta,children:new Date(g.timestamp).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})})]}),P===g.text&&e.jsx(Fe,{className:"h-4 w-4 shrink-0 text-[var(--public-ink)]","aria-label":"Current"})]},b))})]})]}),e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:()=>U(!y),selected:y,"aria-pressed":y,"aria-label":"Find and replace",title:"Find & Replace (Cmd/Ctrl+F)","data-testid":"button-find-replace",children:e.jsx(gr,{"aria-hidden":"true"})}),e.jsxs(Si,{open:W,onOpenChange:L,children:[e.jsx(Pi,{asChild:!0,children:e.jsx(h,{variant:"ghost",size:"icon-sm","aria-label":"Keyboard shortcuts",title:"Keyboard shortcuts (?)","data-testid":"button-shortcuts",children:e.jsx(vr,{"aria-hidden":"true"})})}),e.jsxs(Ci,{align:"end",className:"w-[min(24rem,calc(100vw-2rem))] p-0",children:[e.jsx("p",{className:"border-b border-[var(--public-hairline)] px-4 py-2 text-[14px] font-semibold text-[var(--public-ink)]",children:"Keyboard Shortcuts"}),e.jsx("dl",{className:"flex max-h-80 flex-col gap-2.5 overflow-y-auto px-4 py-3",children:Rn.map(([g,b])=>e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("dt",{className:p.small,children:g}),e.jsx("dd",{children:e.jsx("kbd",{className:"rounded-[calc(var(--public-radius-control)/2)] border border-[var(--public-hairline-strong)] bg-[var(--public-surface-2)] px-2 py-1 font-mono text-[11px] text-[var(--public-ink)]",children:b})})]},g))})]})]})]})]}),y&&e.jsx("div",{className:"border-b border-[var(--public-hairline)] bg-[var(--public-surface-2)] px-3 py-2 md:px-8",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(tt,{type:"text",value:A,onChange:g=>Z(g.target.value),placeholder:"Find...","aria-label":"Find",className:"h-10 flex-1 sm:h-9","data-testid":"input-find",autoFocus:!0}),e.jsx(tt,{type:"text",value:ge,onChange:g=>fe(g.target.value),placeholder:"Replace...","aria-label":"Replace with",className:"h-10 flex-1 sm:h-9","data-testid":"input-replace"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(h,{variant:"outline",size:"compact",onClick:()=>bt("prev"),disabled:Q.length===0,"aria-label":"Previous match","data-testid":"button-prev-match",children:"â"}),e.jsx(h,{variant:"outline",size:"compact",onClick:()=>bt("next"),disabled:Q.length===0,"aria-label":"Next match","data-testid":"button-next-match",children:"â"}),e.jsx("span",{className:x(p.meta,"px-2"),children:Q.length>0?`${_+1}/${Q.length}`:"0/0"}),e.jsx(h,{variant:"outline",size:"compact",onClick:At,disabled:Q.length===0,"data-testid":"button-replace-one",children:"Replace"}),e.jsx(h,{variant:"outline",size:"compact",onClick:vt,disabled:Q.length===0,"data-testid":"button-replace-all",children:"All"})]})]})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-3 py-2 md:px-8 md:py-4",children:e.jsxs("div",{className:"flex h-full gap-1 md:gap-2",children:[u&&e.jsx("div",{className:"hidden min-w-[2rem] select-none border-r border-[var(--public-hairline)] pr-2 text-right md:block md:pr-3",style:{fontSize:`${Math.max(12,D-2)}px`},"aria-hidden":"true",children:e.jsx("pre",{ref:be,className:"h-full overflow-y-hidden whitespace-pre font-mono leading-relaxed text-[var(--public-ink-3)]",style:{paddingTop:"12px",paddingBottom:"12px"},children:ee})}),e.jsx(Ls,{ref:K,value:P,onChange:We,onKeyDown:gt,onScroll:S,placeholder:"Enter your prompt text here...","aria-label":"Prompt text",style:{fontSize:`${D}px`},className:"h-full min-h-0 flex-1 resize-none bg-[var(--public-paper)] px-3 py-2 leading-relaxed md:px-4 md:py-3","data-testid":"textarea-prompt-content"})]})}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-[var(--public-hairline)] bg-[var(--public-ground)] px-3 py-2 md:gap-3 md:px-8 md:py-4",children:[e.jsxs("div",{className:x(p.meta,"flex flex-wrap items-center gap-2 md:gap-3"),children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-[var(--public-ink)]",children:se.chars.toLocaleStr
5ing()})," chars"]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-[var(--public-ink)]",children:se.words.toLocaleString()})," words"]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-[var(--public-ink)]",children:se.lines.toLocaleString()})," lines"]}),e.jsx("span",{className:"hidden sm:inline","aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"hidden sm:inline",children:["~",e.jsx("span",{className:"font-semibold text-[var(--public-ink)]",children:se.readingTime})," min read"]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden md:inline","aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"hidden italic md:inline",children:["Draft saved at ",s]})]}),ie&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{className:"font-medium text-[var(--public-danger)]","data-testid":"text-error-char-limit",children:"Exceeds 50,000 limit"})]})]}),e.jsx(de,{status:I?{anchor:"editor",tone:"error",message:I}:null,"data-testid":"editor-save-error"}),e.jsxs("div",{className:"flex flex-col-reverse justify-end gap-2 sm:flex-row sm:gap-3",children:[e.jsx(h,{type:"button",variant:"outline",onClick:Re,disabled:v,className:"w-full sm:w-auto","data-testid":"button-cancel",children:"Cancel"}),e.jsx(h,{type:"button",onClick:Ie,disabled:ie||v||P.trim()==="",className:"w-full sm:w-auto","data-testid":"button-save",children:v?e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}),"Saving..."]}):"Save Changes"})]})]})]})})}function hs(i,o){return o?(i?.qualityScore??i?.metadata?.skillScore)!=null:!1}function An({record:i,isLoading:o=!1}){const{t:c}=qe(),d=Ei(i),l=[{id:"before",label:c("privatePdp.before","Before"),detail:c("privatePdp.scoreOriginalInput","Your original input"),value:d.before},...d.hasEnhancement?[{id:"enhanced",label:c("privatePdp.scoreEnhanced","Enhanced"),detail:c("privatePdp.scoreRefinedInput","Input after refinement"),value:d.enhanced}]:[],{id:"after",label:c("privatePdp.after","After"),detail:c("privatePdp.scoreGeneratedPrompt","Generated prompt"),value:d.after}];return e.jsxs("section",{className:x(p.card,"flex flex-col gap-4 p-5"),"data-testid":"score-section","aria-busy":o,children:[e.jsx(pe,{children:c("create.promptScore","Prompt Score")}),e.jsx("dl",{className:"flex flex-col divide-y divide-[var(--public-hairline)]","data-testid":"prompt-quality-comparison",children:l.map(m=>e.jsxs("div",{className:"flex items-center justify-between gap-3 py-3 first:pt-0","data-testid":`prompt-score-${m.id}`,children:[e.jsxs("dt",{className:"flex min-w-0 flex-col gap-1",children:[e.jsx("span",{className:"text-[14px] font-semibold text-[var(--public-ink)]",children:m.label}),e.jsx("span",{className:"text-[12px] leading-relaxed text-[var(--public-ink-2)]",children:m.detail})]}),e.jsx("dd",{className:"shrink-0 text-right tabular-nums",children:m.value!==null?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:m.id==="after"?"text-[30px] font-[620] leading-none text-[var(--public-accent)]":"text-[18px] font-semibold text-[var(--public-ink)]","data-testid":m.id==="after"?"prompt-score-value":void 0,children:Math.round(m.value)}),e.jsx("span",{className:"ml-0.5 font-mono text-[11px] text-[var(--public-ink-2)]",children:"/100"})]}):e.jsx("span",{className:"text-[12px] text-[var(--public-ink-2)]",children:o?c("privatePdp.scoreCalculating","Scoringâ¦"):c("privatePdp.scoreUnavailable","Not scored")})})]},m.id))}),d.difference!==null&&e.jsx("p",{className:"text-[13px] font-medium text-[var(--public-ink)]","data-testid":"prompt-score-change",children:c("privatePdp.scorePointChange","{{change}} points from your original input",{change:`${d.difference>0?"+":""}${d.difference}`})}),e.jsxs("p",{className:"text-[12px] leading-relaxed text-[var(--public-ink-2)]",role:o?"status":void 0,children:[d.method==="promptiq"?c("privatePdp.scorePromptIqFallback","After is a saved PromptIQ estimate. Comparable stage scores are not available yet."):c("privatePdp.scoreMethod","AI estimates of prompt quality, using the same criteria. These do not score the AI response."),o&&` ${c("privatePdp.scoreLoadingStages","Calculating missing stage scoresâ¦")}`]})]})}const Fn=new Set(["ai","it","api","mcp","llm","seo","ui","ux"]),_n={chatgpt:"ChatGPT"};function Es(i){const o=i.trim()||"MCP Client",c=_n[o.toLowerCase()];
5return c||o.split(/[_\s-]+/u).filter(Boolean).map(d=>{const l=d.toLowerCase();return Fn.has(l)?l.toUpperCase():l.charAt(0).toUpperCase()+l.slice(1)}).join(" ")}function xs(i){const o=i.metadata??{},c=i.generationSource??(typeof o.generationSource=="string"?o.generationSource:null),d=typeof o.source=="string"?o.source:null;if(c==="mcp"||d==="mcp"){const l=i.mcpClientType??(typeof o.mcpClientType=="string"?o.mcpClientType:null)??null,m=l?.trim().toLowerCase()??"";return{kind:"mcp",label:m!==""&&m!=="unknown"&&m!=="other"?"Generated in "+Es(l):"Generated via MCP",description:"AI-generated prompt created through an MCP client"}}return c==="web"||i.userInput?{kind:"web",label:"Generated in Prompeteer.ai",description:"AI-generated prompt created in Create"}:d==="user_import"?{kind:"imported",label:"Imported Prompt",description:"Your original prompt imported into your Drive"}:{kind:"unknown",label:"",description:""}}function Mn(i){return i.isTeamPrompt?{href:"/vault?tab=teams",label:"Teams",notFoundLabel:"Back to Teams"}:i.isSkillHubRoute?{href:"/skills-hub",label:"Skills Hub",notFoundLabel:"Back to Skills Hub"}:{href:"/vault",label:"Drive",notFoundLabel:"Back to Drive"}}function zn(i){return"https://chatgpt.com"}function Un(i){return"https://claude.ai"}function $n(i){return"https://gemini.google.com/app"}function On(i){return"https://www.perplexity.ai/"}function Kn(i){return"https://grok.com"}function qn(i){return"https://www.meta.ai/"}function Wn(i){return"https://indus.sarvam.ai/"}const As=5,Fs="purpose-v2",Qn=i=>["/api/skills/hub/related",i,Fs];function Hn(i){const o=i;return!!o&&typeof o=="object"&&typeof o.id=="string"&&o.id!==""&&typeof o.title=="string"}async function Bn(i,o){const c=await fetch(`/api/skills/hub/${encodeURIComponent(i)}/related?limit=${As}&ranking=${Fs}`,{signal:o});if(!c.ok)throw Object.assign(new Error("Failed to load related skills"),{status:c.status});const d=await c.json();return Array.isArray(d?.related)?d.related.filter(Hn):[]}function Vn(i,o){return ue({queryKey:Qn(i??""),queryFn:({signal:c})=>Bn(i,c),enabled:o&&!!i,staleTime:5*6e4,gcTime:30*6e4,retry:!1,refetchOnWindowFocus:!1})}const fs="mt-5 flex flex-col divide-y divide-[var(--public-hairline)] border-t border-[var(--public-hairline)]",Gn=x("-mx-2 flex min-h-11 flex-col justify-center gap-1 rounded-[var(--public-radius-control)] px-2 py-2","transition-colors duration-color ease-public [@media(hover:hover)]:hover:bg-[var(--public-paper)] motion-reduce:transition-none",p.focus),Yn=x(p.small,"line-clamp-2 font-semibold text-[var(--public-ink)] [overflow-wrap:anywhere]"),Jn=x(p.meta,"line-clamp-2 text-[var(--public-ink-2)] [overflow-wrap:anywhere]"),Xn=x(p.meta,"block overflow-hidden"),Zn="-ms-3 flex flex-wrap items-center gap-y-0.5",el="relative inline-flex min-w-0 max-w-full items-center ps-3";function tl(i,o){return i==="approved"||i==="auto_approved"?{label:o("skillSdp.security.verified","Verified"),className:"text-[var(--public-assurance)]",icon:Is}:i==="flagged"?{label:o("skillSdp.security.flagged","Under Review"),className:"text-[var(--public-highlight-ink)]",icon:rs}:i==="rejected"?{label:o("skillSdp.security.rejected","Rejected"),className:"text-[var(--public-danger)]",icon:rs}:i==="pending"||i==="scanning"?{label:o("skillSdp.security.pending","Review Pending"),className:"text-[var(--public-ink-3)]",icon:ns}:{label:o("skillSdp.security.unscanned","Unscanned"),className:"text-[var(--public-ink-3)]",icon:ns}}function al(i){if(!i)return"en-US";try{return Intl.NumberFormat.supportedLocalesOf([i]).length>0?i:"en-US"}catch{return"en-US"}}function sl(i,o){if(!i)return null;const c=new Date(i);return Number.isNaN(c.getTime())?null:c.toLocaleDateString(o,{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}const il=n.memo(function({sourceSkillId:o,skills:c,loading:d,className:l}){const{t:m,i18n:v}=qe(),I=ks(),P=n.useId(),E=d?[]:c??[];if(!d&&E.length===0)return null;const D=al(v?.resolvedLanguage||v?.language),C=(j,y)=>{$i({sourceSkillId:o,targetSkillId:j.id,targetTitle:j.title,position:y}),ha("skill_related_click",{source_skill_id:o,target_skill_id:j.id,position:y,source:"skill_detail"}),I?.capture("skill_related_click",{source_skill_id:o,target_skill_id:j.id,position:y})},u=j=>{const y=tl(j.securityStatus,m),U=y.icon,W=[];j.category&&W.push(e.jsx("span",{className:"min-w-0 truncate",children:j.category}
5)),W.push(e.jsxs("span",{className:x("inline-flex items-center gap-1 whitespace-nowrap",y.className),children:[e.jsx(U,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),y.label]}));const L=typeof j.downloadCount=="number"&&j.downloadCount>0?j.downloadCount:null,A=j.updatedAt||j.createdAt,Z=sl(A,D);return L!==null?W.push(e.jsxs("span",{className:"whitespace-nowrap tabular-nums",children:[L.toLocaleString(D)," ",m("rail.unit.download",{count:L,defaultValue_one:"download",defaultValue_other:"downloads"})]})):Z&&W.push(e.jsx("time",{dateTime:A??void 0,className:"whitespace-nowrap tabular-nums",children:Z})),W};return e.jsx(on,{"aria-labelledby":P,"aria-busy":d||void 0,"data-testid":"sdp-rail-related",className:l,children:e.jsxs("div",{className:"p-5 sm:p-6",children:[e.jsx(cn,{icon:e.jsx(br,{className:"h-5 w-5 text-[var(--public-second)]",strokeWidth:2,"aria-hidden":"true"}),eyebrow:m("skillSdp.related.eyebrow",{defaultValue:"Related skills"}),eyebrowClassName:"text-[var(--public-second)]",eyebrowId:P,subtitle:m("skillSdp.related.subtitle",{defaultValue:"Similar skills in Skills Hub"})}),d?e.jsx("div",{className:fs,"aria-hidden":"true",children:Array.from({length:As},(j,y)=>e.jsx("div",{className:"py-1",children:e.jsxs("div",{"aria-hidden":"true","data-testid":"related-skill-skeleton",className:"-mx-2 flex min-h-11 flex-col justify-center gap-1 px-2 py-2",children:[e.jsx("span",{className:x(p.small,"block"),children:e.jsx("span",{className:x(p.skeleton,"inline-block h-[0.85em] w-4/5 align-middle")})}),e.jsx("span",{className:x(p.meta,"block"),children:e.jsx("span",{className:x(p.skeleton,"inline-block h-[0.85em] w-1/2 align-middle")})})]})},y))}):e.jsx("ul",{className:fs,children:E.map((j,y)=>{const U=et(j.title)||j.title;return e.jsx("li",{className:"py-1",children:e.jsxs(ua,{href:`/skills-hub/${encodeURIComponent(j.id)}`,onClick:()=>C(j,y),className:Gn,children:[e.jsx("span",{className:Yn,title:U,children:U}),j.description?e.jsx("span",{className:Jn,title:j.description,children:j.description}):null,e.jsx("span",{className:Xn,"data-testid":"related-skill-meta",children:e.jsx("span",{className:Zn,children:u(j).map((W,L)=>e.jsxs("span",{className:el,children:[L>0?e.jsx("span",{"aria-hidden":"true",className:"absolute start-0 w-3 text-center",children:"·"}):null,W]},L))})})]})},j.id)})})]})})}),rl=2e3,nl={zapier:/^https:\/\/(hooks\.zapier\.com\/hooks\/catch\/)/i,make:/^https:\/\/hook\.(eu\d+\.)?make\.com\//i,n8n:/^https:\/\/[^/]*n8n\.(io|cloud)\//i,pipedream:/^https:\/\/[^/]*\.m\.pipedream\.net\//i,gumloop:/^https:\/\/[^/]*gumloop\.com\//i},oa=i=>`https://cdn.simpleicons.org/${i}`,gs=i=>`data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'>${i}</svg>`).replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29")}`,ll={zapier:oa("zapier"),make:oa("make"),n8n:oa("n8n"),gumloop:gs("<path d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z'/><circle cx='12' cy='12' r='3' fill='none' stroke='black' stroke-width='1.5'/><path d='M12 6v2M12 16v2M6 12h2M16 12h2' stroke='black' stroke-width='1.5' stroke-linecap='round'/>"),pipedream:gs("<path d='M4 4h4v4H4V4zm6 0h4v4h-4V4zm6 0h4v4h-4V4zM4 10h4v4H4v-4zm6 0h4v4h-4v-4zm6 0h4v4h-4v-4zM4 16h4v4H4v-4zm6 0h4v4h-4v-4zm6 0h4v4h-4v-4z'/>")},ol=x("inline-flex min-h-11 items-center gap-1.5 font-mono text-[12.5px] font-medium text-[var(--public-ink-2)] underline-offset-4","transition-colors duration-color ease-public hover:text-[var(--public-ink)] hover:underline motion-reduce:transition-none sm:min-h-9",p.focus);function xt({brand:i,label:o,href:c,title:d,"data-testid":l}){return e.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:ol,title:d,"data-testid":l,children:[e.jsx("span",{"aria-hidden":"true",className:"inline-flex shrink-0",children:e.jsx(un,{name:i,prefetchedUrl:ll[i],variant:"mono",size:16,title:o})}),e.jsx("span",{children:o})]})}function cl({prompt:i,platform:o,context:c,metadata:d}){const{t:l}=qe(),[m,v]=n.useState(""),[I,P]=n.useState(!1),[E,D]=n.useState(!1),[C,u]=n.useState(null),[j,y]=n.useState(""),[U,W]=n.useState(""),[L,A]=n.useState(!1),[Z,ge]=n.useState(0),[fe,Q]=n.useState(0),[J,_]=n.useState(null);n.useEffect(()=>{localStorage.removeItem("prompeteer_webhook_url"),localStorage.removeItem("prompeteer_webhook_history")},[]);const B=n.useCallback(S=>{if(!S)return"unknown";const T=S.toLowerCase();return T.includes("zapier.com")||T.includes("hooks.zapier")?"zapier":T.includes("make.com")||T.includes("integromat")?"make":T.includes("n8n.io")||T.includes("n8n.cloud")?"n8n":T.includes("pipedream")?"pipedream":T.includes("gumloop.com")||T.includes("gumloop")?"gumloop":"unknown"},[]),V=n.useMemo(()=>B(m),[m,B]),k=n.useMemo(()=>({zapier:"Zapier",make:"Make",n8n:"n8n",pipedream:"Pipedream",gumloop:"Gumloop",unknown:l("privatePdp.webhookGeneric")})[V],[V,l]),s=n.useMemo(()=>
5{if(!m)return!1;try{const S=new URL(m.trim());return S.protocol==="https:"&&S.hostname.length>0}catch{return!1}},[m]),ve=n.useMemo(()=>{if(!m||!s||V==="unknown")return null;const S=nl[V];return S&&!S.test(m.trim())?l("privatePdp.urlFormatWarning",{provider:k}):null},[m,s,V,k,l]),$=n.useMemo(()=>({prompt:i||"",platform:o||"universal",context:c||"",metadata:{...d,timestamp:new Date().toISOString(),source:"prompeteer",version:"2.0"}}),[i,o,c,d]),M=n.useCallback(async()=>{if(!(!s||E)){D(!0),u(null),y(""),W("");try{const T=await oe("/api/webhook/test","POST",{webhookUrl:m.trim()});_({provider:T.provider||k,timestamp:new Date().toLocaleTimeString(),responseTimeMs:T.responseTimeMs}),u("test-success"),setTimeout(()=>{u(null),_(null)},5e3)}catch(S){let T={};try{if(S.message){const se=S.message.match(/\{.*\}/);se&&(T=JSON.parse(se[0]))}}catch{}const X=T.hint||S.hint||"",te=T.error||S.message||l("privatePdp.connectionFailed");y(te),W(X),u("test-error"),setTimeout(()=>u(null),8e3)}finally{D(!1)}}},[m,s,E,k,l]),R=n.useCallback(async(S=!1)=>{const T=Date.now();if(!S&&T-Z<rl){y(l("privatePdp.rateLimitWait")),u("error"),setTimeout(()=>u(null),2e3);return}if(!s){y(l("privatePdp.invalidUrl")),u("error"),setTimeout(()=>u(null),3e3);return}P(!0),u(null),y(""),W(""),ge(T);const X=2;let te=S?fe+1:0;const se=async()=>{try{return await oe("/api/webhook/send","POST",{webhookUrl:m.trim(),payload:$})}catch(ee){if(te<X&&(ee.message?.includes("timeout")||ee.message?.includes("network")))return te++,Q(te),await new Promise(ke=>setTimeout(ke,1e3*te)),se();throw ee}};try{const ee=await se();Oi({provider:V,platform:o||"universal",promptId:d?.promptId,success:!0}),_({provider:ee?.provider||k,timestamp:new Date().toLocaleTimeString()}),u("success"),Q(0),setTimeout(()=>{u(null),_(null)},4e3)}catch(ee){console.error("Webhook send failed:",ee);let ke={};try{if(ee.message){const Ie=ee.message.match(/\{.*\}/);Ie&&(ke=JSON.parse(Ie[0]))}}catch{}const at=ke.hint||"";let ie=ke.error||"";ie||(ie=l("privatePdp.failedToSend"),ee.message?.includes("404")?ie+=l("privatePdp.error404"):ee.message?.includes("401")||ee.message?.includes("403")?ie+=l("privatePdp.error401"):ee.message?.includes("timeout")?ie+=l("privatePdp.errorTimeout"):ee.message?.includes("network")?ie+=l("privatePdp.errorNetwork"):ie+=ee.message||l("privatePdp.errorDefault")),y(ie),W(at),u("error"),setTimeout(()=>u(null),8e3)}finally{P(!1)}},[m,$,s,Z,fe,k,V,o,d,l]),ce=S=>{S.key==="Enter"&&s&&!I&&R()},K=n.useCallback(()=>{navigator.clipboard.writeText(JSON.stringify($,null,2))},[$]),be=n.useCallback(()=>{v(""),u(null),y(""),W("")},[]),we=C==="error"||C==="test-error",f=C==="success"||C==="test-success";return e.jsxs("div",{className:"flex flex-col gap-4 p-5 sm:p-6",children:[e.jsx(Ji,{as:"h3",title:l("privatePdp.connectToWorkflows"),headingClassName:p.h3}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(tt,{type:"url",value:m,onChange:S=>{v(S.target.value),C&&(u(null),y(""),W(""))},onKeyDown:ce,placeholder:l("privatePdp.pasteWebhookUrl"),"aria-label":l("privatePdp.webhookUrl"),"aria-invalid":m&&!s?!0:void 0,className:m?"pr-12":void 0,"data-testid":"input-webhook-url"}),m&&e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:be,className:"absolute right-1 top-1/2 -translate-y-1/2","aria-label":l("privatePdp.clearUrl"),title:l("privatePdp.clearUrl"),"data-testid":"button-clear-url",children:e.jsx(fa,{"aria-hidden":"true"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{variant:"outline",onClick:M,disabled:E||!s||I,"aria-label":l("privatePdp.testConnection"),"data-testid":"button-test-webhook",children:E?e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsx("span",{children:l("privatePdp.testing")})]}):e.jsxs(e.Fragment,{children:[e.jsx(jr,{"aria-hidden":"true"}),e.jsx("span",{children:l("privatePdp.testConnection")})]})}),e.jsx(h,{onClick:()=>R(!1),disabled:I||!s||E,className:"flex-1 sm:flex-none","aria-label":l("privatePdp.sendToWebhook"),"data-testid":"button-send-webhook",children:I?e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsx("span",{children:fe>0?l("privatePdp.sendingRetry",{count:fe}):l("privatePdp.sending")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ts,{"aria-hidden":"true"}),e.jsx("span",{children:l("privatePdp.send")})]})})]})]}),m&&s&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(H,{job:"status",children:l("privatePdp.webhookBadge",{name:k})}),e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>A(!L),"aria-expanded":L,"data-testid":"button-toggle-preview",children:[L?e.jsx(yr,{"aria-hidden":"true"}):e.jsx(Cs,{"aria-hidden":"true"}),e.jsx("span",{children:l(L?"privatePdp.hidePayload":"privatePdp.previewPayload")})]})]}),ve&&e.jsxs("div",{className:"flex items-start gap-2 rounded-[var(--public-radius-control)] border border-[var(--public-highlight-edge)] bg-[var(--public-highlight-wash)] p-3","data-testid":"url-format-warning",children:[e.jsx(wr,{className:"mt-0.5 h-4 w-4 shrink-0 text-[var(--public-highlight-ink)]","aria-hidden":"true"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-[var(--public-highlight-ink)]",children:ve})]}),L&&e.jsxs("div",{className:"relative rounded-[var(--public-radius-control)] bg-[var(--public-surface-2)] p-3",children:[e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:K,className:"absolute right-1 top-1","aria-label":l("privatePdp.copyPayload"),title:l("privatePdp.copyPayload"),"data-testid":"button-copy-payload",children:e.jsx(Ke,{"aria-hidden":"true"})}),e.jsx("pre",{className:"max-h-32 overflow-auto whitespace-pre-wrap pr-12 font-mono text-[12px] leading-[1.5] text-[var(--public-ink-2)]",children:JSON.stringify($,null,2)})]}),f&&e.jsxs("div",{className:"flex items-center gap-2 rounded-[var(--public-radius-control)] border border-[var(--public-assurance-edge)] bg-[var(--public-assurance-wash)] p-3",role:"status","data-testid":"webhook-status-success",children:[e.jsx(kr,{className:"h-5 w-5 shrink-0 text-[var(--public-assurance)]","aria-hidden":"true"}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsx("p",{className:"text-[14px] font-medium text-[var(--public-ink)]",children:l(C==="test-success"?"privatePdp.connectionSuccessful":"privatePdp.sentSuccessfully")}),J&&e.jsx("p",{className:p.meta,children:C==="test-success"&&J.responseTimeMs?l("privatePdp.connectionSuccessfulDesc",{provider:J.provider,time:J.responseTimeMs}):l("privatePdp.deliveredTo",{provider:J.provider,timestamp:J.timestamp})})]})]}),we&&e.jsxs("div",{className:"flex flex-col overflow-hidden rounded-[var(--public-radius-control)] border border-[var(--public-danger-edge)]",role:"alert","data-testid":"webhook-status-error",children:[e.jsxs("div",{className:"flex items-start gap-2 bg-[var(--public-danger-wash)] p-3",children:[e.jsx(Nr,{className:"mt-0.5 h-5 w-5 shrink-0 text-[var(--public-danger)]","aria-hidden":"true"}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[e.jsx("p",{className:"text-[14px] text-[var(--public-ink)]",children:j}),fe>0&&C==="error"&&e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>R(!0),className:"self-start","data-testid":"button-retry",children:[e.jsx(Ds,{"aria-hidden":"true"}),e.jsx("span",{children:l("privatePdp.retry")})]})]})]}),U&&e.jsxs("div",{className:"flex items-start gap-2 border-t border-[var(--public-hairline)] bg-[var(--public-ground)] px-3 py-2.5","data-testid":"webhook-hint",children:[e.jsx(Sr,{className:"mt-0.5 h-4 w-4 shrink-0 text-[var(--public-highlight-ink)]","aria-hidden":"true"}),e.jsxs("p",{className:"text-[13px] leading-relaxed text-[var(--public-ink-2)]",children:[e.jsxs("span",{className:"font-semibold text-[var(--public-ink)]",children:[l("privatePdp.webhookHint"),":"]})," ",U]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-[var(--public-hairline)] pt-4 sm:flex-row sm:items-center sm:gap-4",children:[e.jsx("span",{className:p.metaCaps,children:l("privatePdp.getWebhooksFrom")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-0",children:[e.jsx(xt,{brand:"zapier",label:"Zapier",href:"https://zapier.com/app/editor",title:l("privatePdp.createZapierWebhook"),"data-testid":"link-zapier"}),e.jsx(xt,{brand:"make",label:"Make",href:"https://www.make.com/en/integrations",title:l("privatePdp.createMakeWebhook"),"data-testid":"link-make"}),e.jsx(xt,{brand:"n8n",label:"n8n",href:"https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.webhook/",title:l("privatePdp.createN8nWebhook"),"data-testid":"link-n8n"}),e.jsx(xt,{brand:"gumloop",label:"Gumloop",href:"https://docs.gumloop.com/getting-started/triggers",title:l("privatePdp.createGumloopWebhook"),"data-testid":"link-gumloop"}),e.jsx(xt,{brand:"pipedream",label:"Pipedream",href:"https://pipedream.com/docs/workflows/building-workflows/triggers/#http",title:l("privatePdp.createPipedreamWebhook"),"data-testid":"link-pipedream"})]})]})]})}function dl(i){if(!i||typeof i!="object")return null;const o=i.responseScores;if(!o||typeof o!="object")return null;const c=o;return c.version!==1||c.method!=="model-response-v1"||!es(c.before)||!es(c.after)||typeof c.explanation!="string"?null:c}const pl=["midjourney","dalle","dall-e","stable-diffusion","leonardo","ideogram","flux","firefly","imagen","krea","playground","nightcafe","artbreeder","suno","udio","elevenlabs","murf","speechify","resemble","runway","pika","kaiber","synthesia","heygen","de
5script","luma","sora","kling","veo","gen-3","dream-machine"];function ul(i){if(!i)return!0;const o=i.toLowerCase().replace(/[_\s-]/g,"");return!pl.some(c=>o.includes(c.replace(/-/g,"")))}const ca="text-[13px] leading-relaxed text-[var(--public-ink-2)]",Rt="mb-1.5 mt-3 font-semibold text-[var(--public-ink)]",ml='<strong class="font-semibold text-[var(--public-ink)]">$1</strong>';function hl(i){const o=i.split(` 6`);return e.jsx("div",{className:"space-y-2",children:o.map((c,d)=>{const l=c.trim();if(l.startsWith("#### "))return e.jsx("h4",{className:x(Rt,"text-[13px]"),children:l.replace(/^####\s*/,"").replace(/\*\*/g,"")},d);if(l.startsWith("### "))return e.jsx("h3",{className:x(Rt,"text-[15px]"),children:l.replace(/^###\s*/,"").replace(/\*\*/g,"")},d);if(l.startsWith("## "))return e.jsx("h2",{className:x(Rt,"text-[15px]"),children:l.replace(/^##\s*/,"").replace(/\*\*/g,"")},d);if(l.startsWith("# "))return e.jsx("h1",{className:x(Rt,"text-[16px]"),children:l.replace(/^#\s*/,"").replace(/\*\*/g,"")},d);if(l.startsWith("- ")||l.startsWith("* ")){const v=Xt.sanitize(l.slice(2).replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),{ALLOWED_TAGS:["strong","em","span"]});return e.jsx("li",{className:x(ca,"ml-4"),dangerouslySetInnerHTML:{__html:v}},d)}if(/^\d+\.\s/.test(l)){const v=Xt.sanitize(l.replace(/^\d+\.\s*/,"").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),{ALLOWED_TAGS:["strong","em","span"]});return e.jsx("li",{className:x(ca,"ml-4 list-decimal"),dangerouslySetInnerHTML:{__html:v}},d)}if(l==="")return e.jsx("div",{className:"h-1.5"},d);const m=Xt.sanitize(l.replace(/\*\*([^*]+)\*\*/g,ml),{ALLOWED_TAGS:["strong","em","span"],ALLOWED_ATTR:["class"]});return e.jsx("p",{className:ca,dangerouslySetInnerHTML:{__html:m}},d)})})}function vs({badge:i,label:o,text:c,copied:d,onCopy:l,copyLabel:m,strong:v=!1}){return e.jsxs("div",{className:x("overflow-hidden rounded-[var(--public-radius-control)] border",v?"border-[var(--public-hairline-strong)]":"border-[var(--public-hairline)]"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--public-hairline)] bg-[var(--public-surface-2)] py-1 pl-4 pr-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(H,{job:"status",children:i}),e.jsx("span",{className:x(p.meta,"truncate",v&&"text-[var(--public-ink)]"),children:o})]}),e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:l,"aria-label":m,title:m,children:d?e.jsx(Fe,{className:"text-[var(--public-assurance)]","aria-hidden":"true"}):e.jsx(Ke,{"aria-hidden":"true"})})]}),e.jsx("div",{className:"custom-scrollbar max-h-[400px] overflow-y-auto p-4",children:hl(c)})]})}function xl({userInput:i,enhancedPrompt:o,promptId:c,category:d,platformId:l,cachedComparison:m}){const{t:v}=qe(),{toast:I}=Et(),[P,E]=n.useState(!1),D=P?null:m,[C,u]=n.useState(!!m),[j,y]=n.useState(!0),[U,W]=n.useState(!1),[L,A]=n.useState(!1),Z=ul(l),{data:ge,isLoading:fe,error:Q,refetch:J}=ue({queryKey:["/api/ai-responses/compare",c,ma(i),ma(o)],queryFn:()=>oe("/api/ai-responses/compare","POST",{userInput:i,enhancedPrompt:o,category:d,promptId:c}),refetchOnWindowFocus:!1,refetchOnReconnect:!1,enabled:Z&&C&&!D&&!!i&&!!o,retry:!1,staleTime:1e3*60*60,gcTime:1e3*60*60*24});if(!Z)return null;const _=D?{beforeResponse:D.beforeResponse,afterResponse:D.afterResponse,enhancementSummary:D.enhancements,improvementMetrics:D.metrics}:ge,B=dl(_?.improvementMetrics);if(!i)return null;const V=async(s,ve)=>{await navigator.clipboard.writeText(s),ve==="before"?(W(!0),setTimeout(()=>W(!1),2e3)):(A(!0),setTimeout(()=>A(!1),2e3)),I({title:v("privatePdp.copiedToClipboard")})},k=_?.enhancementSummary?.length?_.enhancementSummary.slice(0,6):[];return e.jsxs("section",{className:x(p.card,"flex flex-col gap-4 p-5 sm:p-6"),"data-testid":"ai-response-section",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[e.jsx(pe,{children:v("privatePdp.yourAiResponse")}),e.jsx("h3",{className:p.h3,children:v("privatePdp.comparePromptResponses","Compare responses to your original input and generated prompt")})]}),e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:()=>y(!j),"aria-expanded":j,"aria-controls":"ai-response-panel","aria-label":v("privatePdp.yourAiResponse"),className:"shrink-0",children:e.jsx(ga,{className:x("transition-transform duration-transform ease-public motion-reduce:transition-none",j&&"rotate-180"),"aria-hidden":"true"})})]}),e.jsx(mn,{initial:!1,children:j&&e.jsx(Rs.div,{id:"ai-response-panel",initial:{height:0,opacity:0}
6,animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.25,ease:"easeInOut"},className:"overflow-hidden",children:!C&&!D?e.jsxs(h,{onClick:()=>{Hi("generate-complete"),u(!0)},className:"w-full sm:w-auto","data-testid":"button-ai-response-compare",children:[e.jsx(Pr,{"aria-hidden":"true"}),e.jsx("span",{children:v("privatePdp.compareResponsesButton","Compare AI responses")}),e.jsx(Cr,{"aria-hidden":"true"})]}):fe?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-12",role:"status",children:[e.jsx("div",{className:p.tile,children:e.jsx(ye,{className:"h-5 w-5 animate-spin motion-reduce:animate-none","aria-hidden":"true"})}),e.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[e.jsx("p",{className:x(p.small,"text-[var(--public-ink)]"),children:v("privatePdp.generatingAiResponses")}),e.jsx("p",{className:p.meta,children:v("privatePdp.comparingPromptResponses","Generating both responses, then assessing them with the same criteria.")})]})]}):Q?e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-[var(--public-radius-control)] border border-[var(--public-danger-edge)] bg-[var(--public-danger-wash)] p-6 text-center",role:"alert",children:[e.jsx("p",{className:"text-[14px] font-medium text-[var(--public-danger)]",children:v("privatePdp.failedToGenerateComparison")}),e.jsx(h,{variant:"outline",size:"sm",onClick:()=>J(),children:v("privatePdp.tryAgain")})]}):_?e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 rounded-[var(--public-radius-control)] border border-[var(--public-hairline)] p-4","data-testid":"prompt-response-scores",children:[e.jsx(pe,{children:v("privatePdp.promptResponseScore","Prompt Response Score")}),e.jsxs(ws,{children:[e.jsx(Te,{label:v("privatePdp.responseBefore","Before · original input"),suffix:B?"/100":void 0,children:B?B.before:v("privatePdp.scoreUnavailable","Not scored")}),e.jsx(Te,{label:v("privatePdp.responseAfter","After · generated prompt"),suffix:B?"/100":void 0,children:B?B.after:v("privatePdp.scoreUnavailable","Not scored")})]}),e.jsx("p",{className:"text-[12px] leading-relaxed text-[var(--public-ink-2)]",children:v("privatePdp.responseScoreMethod","AI estimates of these example responses: task alignment, completeness, clarity and usefulness. Separate from Prompt Score; results can vary by model and run.")}),B&&e.jsx("p",{className:p.small,children:B.explanation}),!B&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:p.small,children:v("privatePdp.responseScoreMissing","Comparable response scores were not saved for this pair.")}),e.jsx(h,{variant:"outline",size:"sm",onClick:()=>{D?E(!0):J()},children:v("privatePdp.responseScoreRetry","Compare again")})]}),k.length>0&&e.jsxs("div",{className:"flex flex-col gap-2 border-t border-[var(--public-hairline)] pt-3",children:[e.jsx(pe,{children:v("privatePdp.responseDifferences","Observed differences")}),e.jsx("ul",{className:"flex flex-wrap gap-1.5",children:k.map((s,ve)=>e.jsx("li",{children:e.jsx(H,{job:"status",children:s})},ve))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsx(vs,{badge:v("privatePdp.before"),label:v("privatePdp.yourInput"),text:_.beforeResponse,copied:U,onCopy:()=>V(_.beforeResponse,"before"),copyLabel:v("privatePdp.copy")}),e.jsx(vs,{badge:v("privatePdp.after"),label:v("privatePdp.scoreGeneratedPrompt","Generated prompt"),text:_.afterResponse,copied:L,onCopy:()=>V(_.afterResponse,"after"),copyLabel:v("privatePdp.copy"),strong:!0})]})]}):null})})]})}const fl=new Set(["midjourney","mj","dall-e","dall-e-2","dall-e-3","dalle","dalle-3","openai-image","stable-diffusion","sd","sdxl","flux","flux-pro","flux-schnell","ideogram","leonardo","leonardo-ai","black-forest","imagen","imagen-3","recraft","firefly","adobe-firefly","canva","sora","sora-2","openai-sora","runway","runway-gen3","kling","kling-ai","kling-1.5","kling-1.0","pika","pika-labs","heygen","synthesia","synthesia-2","pictory","invideo","lumen5","descript","veo","gemini-veo","suno","suno-ai","suno-ai-v5","elevenlabs","elevenlabs-agents","mubert","soundraw","musicfy","udio","aiva"]),gl=new Set(["image-generation","video-generation","audio-generation"]);function vl(i,o,c){if(i){const d=i.toLowerCase().trim();if(fl.has(d))return!1}if(o){const d=o.toLowerCase().trim();if(gl.has(d))return!1}if(c){const d=c.toLowerCase(),l=["create an image","generate an image","draw a","paint a","photorealistic","ultra-photorealistic","digital art","illustration of","4k resolution","8k resolution","aspect ratio","artstation","concept art","render a","visualize a","photo of"],m=["create a video","generate a video","cinematic shot","camera movement","slow motion","time-lapse","drone shot","scene transition","b-roll","footage of"],v=["create a song","generate music","compose a","audio track","beat drop","melody","lyrics for","instrumental","voice over","narration","podcast intro","jingle"];for(const I of[...l,...m,...v])if(d.includes(I))return!1}return!0}const bl=i=>i&&typeof i=="object"&&"status"in i?Number(i.status):0,da=i=>typeof i=="string"&&i.trim()?i:null;async function jl({promptId:i,promptText:o,language:c,request:d}){try{const m=await d(`/api/prompts/${i}/translation/${c.code}
6`,"GET"),v=m?.found?da(m.translatedText):null;if(v)return v}catch{}let l;try{const m=await d(`/api/prompts/${i}/translate-and-save`,"POST",{targetLanguageCode:c.code,targetLanguageName:c.name});l=da(m?.translatedText)}catch(m){if(![401,403,404].includes(bl(m)))throw m;const v=await d("/api/translate-prompt","POST",{text:o,targetLanguage:c.name,targetLanguageCode:c.code,promptId:i});l=da(v?.translatedText)}if(!l)throw new Error("Translation unavailable");return l}const bs="max-h-[400px] flex-1 overflow-y-auto rounded-[var(--public-radius-control)] border border-[var(--public-hairline)] bg-[var(--public-paper)] p-4",js="whitespace-pre-wrap font-mono text-[14px] leading-[1.6] text-[var(--public-ink)]";function yl({original:i,translationLanguage:o,originalText:c,translation:d,onCopyOriginal:l,onCopyTranslation:m,onRetry:v}){const{t:I}=qe(),P=(E,D,C,u)=>e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{job:"count",children:E.code.toUpperCase()}),e.jsx("span",{className:p.small,children:E.label}),D&&e.jsx("span",{className:"rounded-[var(--public-radius-control)] bg-[var(--public-surface-2)] px-1.5 font-mono text-[10.5px] font-medium leading-[18px] tracking-[0.04em] text-[var(--public-ink-3)]",children:I("create.originalTag","Original")})]}),e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:C,disabled:u,"aria-label":I("privatePdp.copy","Copy"),"data-testid":D?"button-copy-original-prompt":"button-copy-translation-prompt",children:e.jsx(Ke,{"aria-hidden":"true"})})]});return e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2","data-testid":"prompt-version-panes",children:[e.jsxs("div",{className:"flex flex-col gap-2","data-testid":"prompt-version-original",children:[P(i,!0,l,!1),e.jsx("div",{className:bs,children:e.jsx("pre",{className:js,children:c})})]}),e.jsxs("div",{className:"flex flex-col gap-2","data-testid":"prompt-version-translation",children:[P(o,!1,m,d.state!=="ready"),e.jsx("div",{className:bs,children:d.state==="ready"?e.jsx("pre",{className:js,children:d.text}):d.state==="translating"?e.jsxs("div",{className:x(p.small,"flex items-center justify-center gap-2 py-8"),role:"status",children:[e.jsx(ye,{className:"h-5 w-5 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsx("span",{children:I("create.streaming.translating","Translatingâ¦")})]}):e.jsxs("div",{className:"flex flex-col items-center gap-3 py-8 text-center",children:[e.jsx("p",{className:p.small,children:I("privatePdp.translationUnavailable","Translation unavailable")}),e.jsx(h,{variant:"outline",size:"sm",onClick:v,children:I("privatePdp.retry","Retry")})]})})]})]})}function wl(i){const o=i.trim(),c=o.match(/^(```|~~~)([a-zA-Z0-9_+-]*)\s*\n([\s\S]*?)\n\1\s*$/);return c?c[3].trim():o}function kl(i){const o=i.match(/^\s*(```|~~~)(ya?ml)?[ \t]*\n(---\s*\n[\s\S]*?\n---\s*)\n\1[ \t]*(?:\n|$)/i);if(!o)return i;const c=o[3],d=i.slice(o[0].length);return`${c} 7${d}`}function Nl(i){const o=i.match(/^(\s*---\s*\n[\s\S]*?\n---\s*\n)(?:[ \t]*\n)*(```|~~~)(markdown|md)?[ \t]*\n/i);if(!o)return i;const c=o[2],d=o[1],l=i.slice(o[0].length),m=new RegExp(`^${c==="```"?"```":"~~~"}`,"gm");return(l.match(m)||[]).length%2!==0?i:d+l}function Sl(i){const o=i.match(/^(\s*)(---[ \t]*)(\n[\s\S]*?\n)(---[ \t]*)(\n|$)/);if(!o)return i;const c=o[1],d=o[3],l=o[5],m=i.slice(o[0].length);return`${c}---${d}---${l}${m}`}function Pl(i){const o=wl(i),c=kl(o),d=Nl(c);return Sl(d)}function Cl(i,o,c){const d=ue({queryKey:yn(i),queryFn:({signal:j})=>jn(i,j),enabled:o&&!!i,refetchInterval:ps,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,staleTime:ps/2,retry:1}),[l,m]=n.useState(null),[v,I]=n.useState(0),P=n.useMemo(()=>fn(c),[c]),E=d.data??P,D=E.prompeteerDownloadsAll;n.useEffect(()=>{if(!l)return;const j=l.until-Date.now();if(j<=0)return;const y=window.setTimeout(()=>I(U=>U+1),j+10);return()=>window.clearTimeout(y)},[l]);const C=n.useCallback(()=>{!i||!gn(i)||m({value:(D??0)+1,until:Date.now()+vn})},[i,D]);return{figures:n.useMemo(()=>({...E,prompeteerDownloadsAll:bn(D,l)}),[E,D,l,v]),live:d.data!==void 0,recordOwnDownload:C}}function ys(i){if(!i||i.trim().length===0)return 0;const o=i.trim(),c=/[\u4E00-\u9FFF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]/,l=(o.match(new RegExp(c.source,"g"))||[]).length,m=o.split(/\s+/).filter(P=>P.length>0),v=o.replace(/\s+/g,"").length;return l/v>.5?v:m.length}const Tl=i=>{if(!i)return"";const o=[" / "," & "," | "," - "," + "," and "];for(const c of o)if(i.includes(c))return i.split(c)[0].trim();return i},pa="whitespace-pre-wrap font-mono text-[14px] leading-[1.6] text-[var(--public-ink)]";function le({label:i,aside:o,children:c,...d}){return e.jsxs("div",{className:"flex flex-col gap-2",...d,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(pe,{children:i}),o?e.jsx("div",{className:"shrink-0",children:o}):null]}),e.jsx("div",{children:c})]})}function tc(){const i=ks(),[o,c]=ut("/vault/:id"),[d,l]=ut("/vault/prompt/:id"),[m,v]=ut("/vault/skill/:id"),[I,P]=ut("/skills-hub/:id"),[E,D]=ut("/vault/team/:id"),C=!!E,u=D?.id||c?.id||l?.id||v?.id||P?.id,j=!!m||!!I,{user:y}
7=Ki(),{isViewOnly:U,isLoading:W,requireAuth:L,showAuthModal:A,authMode:Z,setAuthMode:ge,closeAuthModal:fe}=Yi(),Q=j&&U,{customPlatform1:J,customPlatform2:_}=rn(),{startRefine:B,isPending:V}=nr(),{toast:k}=Et(),{t:s,i18n:ve}=qe(),[,$]=yi(),{status:M,show:R}=Ai(),ce=n.useCallback(async()=>{if(!(!u||V)&&!L("refine_skill"))try{const r=(await B({refineSourceId:u}))?.session?.id;$(r?`/create-agent?session=${r}`:"/create-agent")}catch(a){k({title:s("common.error",{defaultValue:"Error"}),description:a?.message||"Failed to start refine session",variant:"destructive"}),R("refine","error",`Refine failed. ${Ze(a,"Please try again.")}`)}},[u,V,L,B,$,k,s,R]),K=C||typeof window<"u"&&new URLSearchParams(window.location.search).get("team")==="true",be=Mn({isTeamPrompt:K,isSkillHubRoute:j}),we=n.useRef(null);qr({userId:y?.id||null,enabled:!!y?.id&&!!u,onTileUpdate:(a,r)=>{a===u&&console.log(`ð¼ï¸ [PDP] Tile image updated for current prompt: ${r?.substring(0,50)}...`)}});const[f,S]=n.useState("ai-work"),[T,X]=n.useState(!1),[te,se]=n.useState(!1),[ee,ke]=n.useState(!1),[at,ie]=n.useState(!1),[Ie,_e]=n.useState(""),[We,gt]=n.useState(""),[Re,st]=n.useState([]),[Qe,it]=n.useState(""),[He,rt]=n.useState(""),[At,vt]=n.useState(!1),[bt,g]=n.useState(!1),[b,O]=n.useState(!1),[ae,De]=n.useState(!1),[Me,jt]=n.useState(!0),[Le,va]=n.useState(!1),[_s,ba]=n.useState(!1),[Ms,Ft]=n.useState(!1),[zs,Us]=n.useState(!1),[$s,Ee]=n.useState(!1),[Be,nt]=n.useState({state:"translating"}),[Os,Ks]=n.useState(0),[yt,Ve]=n.useState(null),ja=n.useRef(new Map),wt=n.useRef(null),kt=n.useRef(null),ya=n.useRef(null);n.useRef(null);const wa=n.useRef(null),ka=n.useRef(null),Na=n.useRef(null),{data:lt,isLoading:qs,isFetching:Il}=ue({queryKey:["/api/prompt-library/personal"],enabled:!j,retry:!1,refetchOnWindowFocus:!1,refetchOnMount:!0,staleTime:30*1e3,gcTime:300*1e3}),Nt=n.useMemo(()=>!lt||!u?null:lt.find(a=>a.id===u)||null,[lt,u]);Nt||lt&<.some(a=>a.id===u);const{data:ot,isLoading:Ws}=ue({queryKey:j?["/api/skills/hub",u]:["/api/prompt-library/personal",u,"full"],queryFn:async()=>{if(j){const r=await fetch(`/api/skills/hub/${u}`);if(!r.ok)throw Object.assign(new Error("Failed to fetch skill"),{status:r.status});return r.json()}const a=await fetch(`/api/prompt-library/personal/${u}?full=true`,{credentials:"same-origin"});if(!a.ok)throw new Error("Failed to fetch prompt");return a.json()},enabled:!!u&&!C&&!Q,staleTime:30*1e3,gcTime:60*1e3,retry:(a,r)=>![401,404].includes(r?.status)&&a<2,refetchOnWindowFocus:!1}),{data:me,isLoading:Qs}=ue({queryKey:["/api/squads/vault-item",u],queryFn:async()=>{const a=await fetch(`/api/squads/vault-item/${u}`,{credentials:"same-origin"});if(!a.ok){const r=await a.json();throw new Error(r.error||"Failed to load team prompt")}return a.json()},enabled:C&&!!u,staleTime:30*1e3,gcTime:60*1e3}),_t=n.useMemo(()=>me?{id:me.id,title:me.title,description:me.description||"",content:me.content||void 0,promptText:me.content||void 0,userInput:me.metadata?.userInput,category:me.metadata?.category||"Team Prompt",tags:me.tags||me.metadata?.tags||[],tileImageUrl:me.metadata?.tileImageUrl||null,createdAt:me.createdAt,updatedAt:me.updatedAt}:null,[me]),{data:Ge,isLoading:Hs}=ue({queryKey:["/api/prompts/shared-with-me"],queryFn:async()=>{const a=await fetch("/api/prompts/shared-with-me",{credentials:"same-origin"});if(!a.ok)throw new Error("Failed to fetch shared prompts");return a.json()},enabled:!!y?.id&&!!u&&!j&&!C,staleTime:300*1e3,gcTime:600*1e3}),Mt=n.useMemo(()=>!Ge?.shares||!u?null:Ge.shares.find(r=>r.prompt?.id===u)?.prompt||null,[Ge,u]),zt=n.useMemo(()=>{if(!u)return null;try{if(j)return F.getQueryData(["/api/skills/hub"])?.skills?.find(w=>w.id===u)||null;const a=F.getQueriesData({queryKey:["personal-prompts-infinite"]});for(const[,r]of a)for(const w of r?.pages||[]){const N=w?.prompts?.find(Y=>Y.id===u);if(N)return N}}catch{}return null},[u,j]),St=Q&&!zt,{data:Sa,status:Bs}=ue({queryKey:["/api/skills/hub"],enabled:St,staleTime:300*1e3}),Pa=n.useMemo(()=>!St||!u?null:Sa?.skills?.find(a=>a.id===u)||null,[St,Sa,u]),Ca=Vn(u,j),Ye=n.useMemo(()=>C||!Ge?.shares||!u?!1:Ge.shares.some(a=>a.prompt?.id===u),[Ge,u,C]),Vs=j?ot?.userId??null:null,Ta=j&&(!y?.id||
7Vs!==y.id),q=!Ye&&!Ta;n.useEffect(()=>{const a=ka.current;if(!a||!q)return;let r=0,w=0,N=0,Y=!1;const G=xe=>{Y=!1,r=Date.now();const ne=xe.touches[0];ne&&(w=ne.clientX,N=ne.clientY)},re=xe=>{if(Y)return;const ne=Date.now()-r,Pe=xe.changedTouches[0];if(Pe&&ne<500){const Ce=Math.abs(Pe.clientX-w),pt=Math.abs(Pe.clientY-N);Ce<15&&pt<15&&(Y=!0,xe.preventDefault(),xe.stopPropagation(),Ee(!0))}};return a.addEventListener("touchstart",G,{passive:!0,capture:!0}),a.addEventListener("touchend",re,{passive:!1,capture:!0}),()=>{a.removeEventListener("touchstart",G,{capture:!0}),a.removeEventListener("touchend",re,{capture:!0})}},[q,u]),n.useEffect(()=>{const a=wa.current;if(!a||!q)return;let r=0,w=0,N=0,Y=!1;const G=xe=>{Y=!1,r=Date.now();const ne=xe.touches[0];ne&&(w=ne.clientX,N=ne.clientY)},re=xe=>{if(Y)return;const ne=Date.now()-r,Pe=xe.changedTouches[0];if(Pe&&ne<400){const Ce=Math.abs(Pe.clientX-w),pt=Math.abs(Pe.clientY-N);Ce<12&&pt<12&&(Y=!0,xe.preventDefault(),xe.stopPropagation(),Ee(!0))}};return a.addEventListener("touchstart",G,{passive:!0,capture:!0}),a.addEventListener("touchend",re,{passive:!1,capture:!0}),()=>{a.removeEventListener("touchstart",G,{capture:!0}),a.removeEventListener("touchend",re,{capture:!0})}},[q,u]);const{data:Ia}=ue({queryKey:["/api/billing/subscription/access-state"],enabled:!!y?.id,staleTime:6e4}),{data:Da}=ue({queryKey:["/api/squads"],enabled:!!y?.id,staleTime:3e4}),La=Ia?.accessState?.hasTeamsAccess||Da&&Da.length>0,t=n.useMemo(()=>C&&_t?_t:ot||Nt||Mt||zt||Pa||null,[Nt,ot,Mt,C,_t,zt,Pa]),z=t?.generationSource==="skill"||t?.generationSource==="skill_hub",Je=Cl(u,j,t),Ut=Je.recordOwnDownload,$t=t?.folderId||null,{data:Gs}=ue({queryKey:["/api/prompts/folders"],enabled:!!y?.id&&!!$t,staleTime:30*1e3}),Ys=$t?Gs?.folders?.find(a=>a.id===$t)?.name??null:null,Js=n.useMemo(()=>{const a=Bi(y?.id,t?.id);if(!a)return null;const r=a.artifactType==="skill"?t?.qualityScore??t?.metadata?.skillScore:ts(t)?.value;return typeof r!="number"||!Number.isFinite(r)||r<0||r>100?null:{...a,score:r}},[y?.id,t]),Ra=(()=>{const a=t?.metadata?.optimizationProfile??null;return a?.id?Ti(a.id)?.displayName??a.displayName??null:null})(),Ne=t?.generationSource==="skill"||t?.generationSource==="skill_hub",Se=n.useCallback((a,r)=>{ha(a,r,{sessionId:xn.getSessionId()});const w={skillId:r.prompt_id||"",skillTitle:r.title||"",category:r.category,source:r.source||"skill_detail",userId:y?.id};a==="skill_download"?ss(w):qi(w),i?.capture(a,{skill_id:r.prompt_id,skill_title:r.title,category:r.category,format:r.format,source:r.source}
7),a==="skill_download"&&j&&Ut()},[y?.id,i,j,Ut]),je=n.useMemo(()=>Wi(t?.promptText||t?.content||"",yt?{code:yt.code,label:yt.name}:null),[t?.promptText,t?.content,yt]),ze=n.useMemo(()=>t?.promptText||t?.content||"",[t?.promptText,t?.content]),Xs=n.useMemo(()=>{const a=t?.promptText||t?.content||"";return je&&je.original.code==="en"&&Be.state==="ready"?Be.text:a},[t?.promptText,t?.content,je,Be]),Zs=!t&&(qs||Ws||Hs||C&&Qs||j&&W||St&&Bs==="pending");n.useMemo(()=>{const a=t?.promptIQBreakdown;return a?{quality:a.quality??null,complexity:a.complexity??null,efficiency:a.efficiency??null,optimization:a.optimization??null,effectiveness:a.effectiveness??null}:null},[t]);const Ot=n.useMemo(()=>t?.criticsRatingScore??null,[t]),Pt=n.useMemo(()=>{const a=t?.criticsRatingData;return a?{complexity:a.complexity??null,effectiveness:a.effectiveness??null,quality:a.quality??null}:null},[t]),{data:Dl,isLoading:Ll}=ue({queryKey:["/api/costiq/analyze",u],queryFn:async()=>{if(!t?.content&&!t?.promptText)return null;const a=t.content||t.promptText||"";return(await oe("/api/costiq/analyze","POST",{promptText:a})).analysis},enabled:!!t&&!!(t.content||t.promptText),staleTime:600*1e3,retry:1});n.useEffect(()=>{if(!t||!u)return;(t.promptIQAnalytics||Ot||t.content||t.promptText)&&oe("/api/analytics/insights","POST",{promptId:t.id,promptIQAnalytics:t.promptIQAnalytics,benchmarkRating:Pt?{overallScore:Ot||0,complexity:Pt.complexity||0,impact:Pt.effectiveness||0,quality:Pt.quality||0}:null,promptText:t.content||t.promptText||"",platformId:t.platformId,modelId:t.modelId}).catch(r=>{})},[t?.id,t?.promptIQAnalytics,Ot]);const Kt=Oe({mutationFn:async a=>await oe(`/api/prompts/${a}/quality-scores/regenerate`,"POST",{}),onSuccess:a=>{a?.skipped||(a?.success&&a?.scores?(console.log("â
Quality scores regenerated successfully",a.scores),F.invalidateQueries({queryKey:["/api/prompt-library/personal"]})):(console.warn("â ï¸ Quality score regeneration returned null/error",a),k({title:"Quality scores unavailable",description:"Unable to generate quality scores at this time. This won't affect your content.",variant:"default"})))},onError:a=>{console.error("â Quality score regeneration failed",a),k({title:"Quality scores unavailable",description:"Unable to generate quality scores at this time. This won't affect your content.",variant:"default"})},retry:!1}),Ea=n.useRef(new Set);n.useEffect(()=>{if(!t||!u)return;const a=Fi(t.promptIQAnalytics?.stageScores);!(a&&ts(t)&&(!_i(t)||a.enhanced!==null))&&!z&&ot&&!C&&!Ea.current.has(u)&&t.userInput&&(t.content||t.promptText)&&!Ii(t)&&!Kt.isPending&&(Ea.current.add(u),Kt.mutate(u))},[t?.id,t?.promptIQAnalytics]);const[Aa,qt]=n.useState(!1),Ct=n.useRef(null);n.useEffect(()=>{if(Ve(null),nt({state:"translating"}),qt(!1),Ct.current=t?.id||null,!t?.userInput)return;if(Di(t.userInput)){const r=Li(t.userInput);r&&!Jt(r.code)&&Ve(r)}},[t?.id,t?.userInput]),n.useEffect(()=>{const a=t?.userInput,r=t?.id;if(!a||a.trim().length<3){Ve(null),qt(!0);return}(async()=>{try{console.log(`ð [LANG-DETECT] Starting semantic detection for prompt ${r}...`);const N=await Ri(a);if(Ct.current!==r){console.log(`â ï¸ [LANG-DETECT] Stale result ignored (prompt changed: ${r} â ${Ct.current})`);return}console.log(`â
[LANG-DETECT] Semantic result: ${N.name} (${N.code}) confidence: ${N.confidence}`),N.confidence>.7&&!Jt(N.code)?Ve(N):(Jt(N.code)&&N.confidence>.6,Ve(null))}catch(N){console.warn("â [LANG-DETECT] Semantic detection failed:",N)}finally{Ct.current===r&&(qt(!0),console.log(`â
[LANG-DETECT] Detection complete for ${r}`))}})()},[t?.id,t?.userInput]),n.useEffect(()=>{const a=t?.promptText||t?.content||"";if(!t?.id||!a||!je||!Aa)return;const r=je.translation,w=`${t.id}_${r.code}`,N=ja.current.get(w);if(N){nt({state:"ready",text:N});return}let Y=!1;return nt({state:"translating"}),jl({promptId:t.id,promptText:a,language:{code:r.code,name:r.label},request:oe}).then(G=>{ja.current.set(w,G),Y||nt({state:"ready",text:G})}).catch(G=>{console.warn(`[TRANSLATION] ${r.label} translation failed:`,G),Y||nt({state:"failed"})}),()=>{Y=!0}},[t?.id,t?.promptText,t?.content,je?.translation.code,je?.translation.label,Aa,Os]);const Tt=Oe({mutationFn:async a=>{if(!u)throw new Error("No prompt ID");return C?await oe(`/api/squads/vault-item/${u}`,"PATCH",{...a,expectedUpdatedAt:t?.updatedAt}):await oe(`/api/prompts/${u}/metadata`,"PATCH",a)},onSuccess:()=>{C?(F.invalidateQueries({queryKey:["/api/squads/vault-item",u]}),F.invalidateQueries({queryKey:["/api/squads"]})):F.invalidateQueries({queryKey:["/api/prompt-library/personal"]}),y?.id&&(F.invalidateQueries({queryKey:["vault-unified-data",y.id]}),F.invalidateQueries({queryKey:["vault-counts",y.id]}),F.invalidateQueries({queryKey:["personal-prompts-infinite",y.id]})),k({title:"Updated!",description:C?"Team content has been updated.":"Your prompt or skill has been updated successfully."})},onError:(a,r)=>{const w=r.title!==void 0?"title":r.category!==void 0?"category":r.tags!==void 0?"tags":"description";if(a?.code==="CONFLICT"||a?.message?.includes("modified by another")){k({title:"Edit Conflict",description:"This content was modified by another team member. Refreshing to show latest version.",variant:"destructive"}),R(w,"error","Edit conflict. Another team member changed this; the latest version is loading."),C&&F.invalidateQueries({queryKey:["/api/squads/vault-item",u]});return}k({title:"Update failed",description:"Failed to update. Please try again.",variant:"destructive"}),R(w,"error",`Update failed. ${Ze(a,"Please try again.")}`)}}),Fa=Oe({mutationFn:async a=>{if(!u)throw new Error("No prompt ID");return C?await oe(`/api/squads/vault-item/${u}`,"PATCH",{content:a,expectedUpdatedAt:t?.updatedAt}):await oe(`/api/prompts/${u}/metadata`,"PATCH",{promptText:a})},onSuccess:()=>{C?(F.invalidateQueries({queryKey:["/api/squads/vault-item",u]}),F.invalidateQueries({queryKey:["/api/squads"]})):F.invalidateQueries({queryKey:["/api/prompt-library/personal"],refetchType:"active"}),y?.id&&(F.invalidateQueries({queryKey:["vault-unified-data",y.id]}),F.invalidateQueries({queryKey:["vault-counts",y.id]})),F.invalidateQueries({queryKey:["/api/costiq/analyze",u]}),F.invalidateQueries({queryKey:["/api/insights",u]})},onError:a=>{if(a?.code==="CONFLICT"||a?.message?.includes("modified by another")){k({title:"Edit Conflict",description:"This content was modified by another team member. Refreshing to show latest version.",variant:"destructive"}),C&&F.invalidateQueries({queryKey:["/api/squads/vault-item",u]});return}const r=a?.message||"Failed to save prompt. Please try again.";k({title:"Save failed",description:r,variant:"destructive"})}}),ei=async a=>{try{await Fa.mutateAsync(a)}catch(r){const w=r?.code==="CONFLICT"||r?.message?.includes("modified by another");throw R("editor","error",w?"Edit conflict. Another team member changed this; the latest version is loading.":`Save failed. ${Ze(r,"Please try again.")}`),r}try{C?await F.refetchQueries({queryKey:["/api/squads/vault-item",u]}):await F.refetchQueries({queryKey:["/api/prompt-library/personal"]}),Ee(!1),k({title:"Saved!",description:C?"Team content has been updated.":"Your prompt or skill has been updated successfully."})}catch{Ee(!1)}},ti=Oe({mutationFn:async()=>
7{if(!u)throw new Error("No prompt ID");return await oe(`/api/prompt-library/personal/${u}`,"DELETE")},onSuccess:async()=>{u&&Dn(F,u),F.resetQueries({queryKey:["vault-unified-data",y?.id]}),F.resetQueries({queryKey:["vault-counts",y?.id]}),F.invalidateQueries({queryKey:["personal-prompts-v2"]}),F.invalidateQueries({queryKey:["/api/prompt-library/personal"]}),k({title:"Deleted!",description:"Your prompt or skill has been deleted successfully."}),Us(!0),await new Promise(a=>setTimeout(a,250)),$("/vault?deleted=1")},onError:a=>{k({title:"Delete failed",description:"Failed to delete. Please try again.",variant:"destructive"}),R("delete","error",`Delete failed. ${Ze(a,"Please try again.")}`)}}),Wt=Oe({mutationFn:async()=>{if(!u)throw new Error("No prompt ID");return await oe(`/api/prompts/${u}/fork`,"POST")},onSuccess:async a=>{await F.refetchQueries({queryKey:["/api/prompt-library/personal"]}),y?.id&&(F.invalidateQueries({queryKey:["vault-unified-data",y.id,"personal",0]}),F.invalidateQueries({queryKey:["vault-counts",y.id]}),F.invalidateQueries({queryKey:["vault-unified-data",y.id,"shared-with-me",0]})),F.invalidateQueries({queryKey:["/api/prompts/shared-with-me"]}),k({title:s("privatePdp.savedToPromptDrive","Saved to Drive!"),description:`"${a.forkedPrompt.title}" is now in your Drive.`}),$(`/vault/${a.forkedPrompt.id}`)},onError:()=>{k({title:s("privatePdp.saveFailed","Save failed"),description:s("privatePdp.saveToPromptDriveFailed","Failed to save to your Drive. Please try again."),variant:"destructive"})}}),_a=async()=>{if(Ie.trim()&&Ie!==t?.title)try{await Tt.mutateAsync({title:Ie.trim()})}catch{return}X(!1)},ai=async()=>{if(We.trim()&&We!==t?.description)try{await Tt.mutateAsync({description:We.trim()})}catch{return}se(!1)},si=async()=>{const a=t?.tags||[];if(JSON.stringify([...a].sort())!==JSON.stringify([...Re].sort()))try{await Tt.mutateAsync({tags:Re})}catch{return}ke(!1),rt("")},Ma=()=>{const a=He.trim();a&&!Re.includes(a)&&(st([...Re,a]),rt(""),setTimeout(()=>ya.current?.focus(),0))},ii=a=>{st(Re.filter(r=>r!==a))},za=async()=>{if(Qe&&Qe!==t?.category)try{await Tt.mutateAsync({category:Qe})}catch{return}ie(!1)},ri=()=>{Ft(!0)},ni=async()=>{va(!0);try{await ti.mutateAsync()}catch{va(!1),Ft(!1)}},li=()=>{Ft(!1),requestAnimationFrame(()=>Na.current?.focus())},oi=()=>{mt(t?.id||"unknown","json",y?.id);const a={title:t?.title,description:t?.description,content:t?.content||t?.promptText,category:t?.category,tags:t?.tags,qualityScores:{inputScore:t?.promptIQAnalytics?.oldScore??null,promptScore:t?.promptIQAnalytics?.newScore??null,percentileRanking:t?.promptIQAnalytics?.percentileRanking??null}},r=new Blob([JSON.stringify(a,null,2)],{type:"application/json"}),w=URL.createObjectURL(r),N=document.createElement("a");N.href=w,N.download=`${t?.title||"prompt"}.json`,N.click(),URL.revokeObjectURL(w),k({title:"Exported!",description:"JSON file downloaded successfully."}),Ne?Se("skill_download",{prompt_id:t?.id,title:t?.title,category:t?.category,format:"json",source:"pdp_export",generation_source:t?.generationSource}):ha("prompt_exported",{prompt_id:t?.id,title:t?.title,category:t?.category,format:"json",source:"pdp_export",generation_source:t?.generationSource})},ci=()=>{mt(t?.id||"unknown","md",y?.id);const a=`# ${t?.title} 8 9${t?.description} 10 11## Prompt 12 13${t?.content||t?.promptText}`,r=new Blob([a],{type:"text/markdown"}),w=URL.createObjectURL(r),N=document.createElement("a");N.href=w,N.download=`${t?.title||"prompt"}.md`,N.click(),URL.revokeObjectURL(w),k({title:"Exported!",description:"Markdown file downloaded successfully."}),Ne&&Se("skill_download",{prompt_id:t?.id,title:t?.title,category:t?.category,format:"md",source:"pdp_export",generation_source:t?.generationSource})},di=()=>{mt(t?.id||"unknown","txt",y?.id);const a=`${t?.title} 14 15${t?.description} 16 17${t?.content||t?.promptText}`,r=new Blob([a],{type:"text/plain"}),w=URL.createObjectURL(r),N=document.createElement("a");N.href=w,N.download=`${t?.title||"prompt"}.txt`,N.click(),URL.revokeObjectURL(w),k({title:"Exported!",description:"Text file downloaded successfully."}),Ne&&Se("skill_download",{prompt_id:t?.id,title:t?.title,category:t?.category,format:"txt",source:"pdp_export",generation_source:t?.generationSource})},pi=()=>{mt(t?.id||"unknown","yaml",y?.id);const a=Ce=>JSON.stringify(Ce==null?"":String(Ce)),r=t?.tags??[],w=r.length>0?r.map(Ce=>` - ${a(Ce)}`).join(` 18`):" []",N=t?.content||t?.promptText||"",Y=N.split(` 19`).map((Ce,pt)=>pt===0?Ce:` ${Ce}`).join(`
20`),G=/^\s/.test(N)?"|2":"|",re=`title: ${a(t?.title)} 21description: ${a(t?.description)} 22category: ${a(t?.category)} 23tags: 24${w} 25content: ${G} 26 ${Y}`,xe=new Blob([re],{type:"text/yaml"}),ne=URL.createObjectURL(xe),Pe=document.createElement("a");Pe.href=ne,Pe.download=`${t?.title||"prompt"}.yaml`,Pe.click(),URL.revokeObjectURL(ne),k({title:"Exported!",description:"YAML file downloaded successfully."}),Ne&&Se("skill_download",{prompt_id:t?.id,title:t?.title,category:t?.category,format:"yaml",source:"pdp_export",generation_source:t?.generationSource})},ui=()=>{mt(t?.id||"unknown","agentkit",y?.id);const a={name:t?.title,description:t?.description,prompt:t?.content||t?.promptText,category:t?.category,tags:t?.tags,metadata:{geminiQualityScore:t?.promptIQAnalytics?.newScore??null,percentileRanking:t?.promptIQAnalytics?.percentileRanking??null,platform:t?.platformId,exportedAt:new Date().toISOString()}},r=new Blob([JSON.stringify(a,null,2)],{type:"application/json"}),w=URL.createObjectURL(r),N=document.createElement("a");N.href=w,N.download=`${t?.title||"prompt"}-agentkit.json`,N.click(),URL.revokeObjectURL(w),k({title:"Exported!",description:"AgentKit format downloaded successfully."}),Ne&&Se("skill_download",{prompt_id:t?.id,title:t?.title,category:t?.category,format:"agentkit",source:"pdp_export",generation_source:t?.generationSource})},It=n.useCallback(a=>{const r=navigator.clipboard?.writeText?navigator.clipboard.writeText(ze):Promise.reject(new Error("Clipboard unavailable"));return window.open(a,"_blank","noopener,noreferrer"),r.then(()=>!0,()=>(k({title:"Clipboard access denied",description:"Please copy the content manually before switching to the platform.",variant:"destructive",duration:6e3}),R("run-in","error","Clipboard access denied. Copy the prompt, then paste it in the new tab."),!1))},[ze,k,R]),mi=n.useCallback(async a=>{if(!ze){k({title:"No content",description:"Cannot launch without content.",variant:"destructive"}),R("run-in","error","This prompt has no text to run.");return}let r="",w="",N=!1;const Y=ze.trim().length>2e3;switch(a){case"chatgpt":r=zn(),w="ChatGPT",N=Y;break;case"claude":r=Un(),w="Claude",N=!0;break;case"gemini":r=$n(),w="Gemini";break;case"perplexity":r=On(),w="Perplexity";break;case"grok":r=Kn(),w="Grok",N=!0;break;case"metaai":r=qn(),w="Meta",N=!0;break;case"sarvam":r=Wn(),w="Sarvam",N=!0;break}await It(r)&&k(N?{title:`Running in ${w}...`,description:"Content copied to clipboard. Paste into your favorite AI assistant.",duration:5e3}:{title:`Launching ${w}!`,description:"Content copied to clipboard. Paste into your favorite AI assistant.",duration:4e3}),Ne&&Se("skill_download",{prompt_id:t?.id,title:t?.title,category:t?.category,platform:a,source:"pdp_run_on_platform",generation_source:t?.generationSource})},[ze,k,Ne,t,Se,It,R]),hi=n.useCallback(async(a,r)=>{if(!ze){k({title:"No content",description:"Cannot launch without content.",variant:"destructive"}),R("run-in","error","This prompt has no text to run.");return}await It(r)&&k({title:`Running in ${a}...`,description:"Content copied to clipboard. Paste into your favorite AI assistant.",duration:5e3}),Ne&&Se("skill_download",{prompt_id:t?.id,title:t?.title,category:t?.category,platform:a,source:"pdp_run_on_custom_platform",generation_source:t?.generationSource})},[ze,k,It,R,Ne,Se,t]);if(n.useEffect(()=>{T&&wt.current&&(wt.current.focus(),wt.current.select())},[T]),n.useEffect(()=>{te&&kt.current&&(kt.current.focus(),kt.current.select())},[te]),n.useEffect(()=>{t?.title&&(document.title=`${t.title} - Drive | Prompeteer`)},[t?.title]),n.useEffect(()=>{window.scrollY>0&&window.scrollTo(0,0)},[u]),Zs)return e.jsx("div",{className:"min-h-screen bg-[var(--public-ground)] flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4 h-8 w-8 animate-spin rounded-full border-2 border-[var(--public-hairline-strong)] border-t-[var(--public-ink)] motion-reduce:animate-none","aria-hidden":"true"}),e.jsx("p",{className:p.body,children:j?s("skillSdp.loadingSkill","Loading skill..."):"Loading your prompt..."})]})});if(!t)return e.jsx("div",{className:"min-h-screen bg-[var(--public-ground)] flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ta,{className:"mx-auto mb-4 h-16 w-16 text-[var(--public-ink-3)]","aria-hidden":"true"}),e.jsx("h1",{className:p.title,children:j?s("skillSdp.notFoundTitle","Skill not found"):"Prompt not found"}),e.jsx("p",{className:x(p.lede,"mb-6 mt-3"),children:j?s("skillSdp.notFoundDesc","This skill is not in the Skills Hub, or it has been removed."):"The prompt you're looking for doesn't exist or has been removed."}),e.jsx(h,{asChild:!0,children:e.jsxs(ua,{href:be.href,children:[e.jsx(aa,{"aria-hidden":"true"}),be.notFoundLabel]})})]})});hs(t,z),hs(t,z),xs(t);
26const he=t.promptText||t.content||"",Ae=Q&&!he,xi=()=>{L("skill_instructions")&&ge("signin")},Ue=a=>{if(Ae){L("skill_run_in");return}mi(a)},Qt=(a,r)=>{if(Ae){L("skill_run_in");return}hi(a,r)},$e=z?as(t.metadata):null,Ht=z&&!$e?t.securityStatus:null,ct=$e?$e.verdict==="passed"?"passed":$e.verdict==="blocked"?"blocked":"flagged":Ht==="approved"?"passed":Ht==="rejected"?"blocked":Ht==="flagged"?"flagged":null,Ua=ct==="passed"?s("promptCard.scanPassed","Passed"):ct==="blocked"?s("promptCard.scanBlocked","Blocked"):ct==="flagged"?s("promptCard.scanFlagged","Flagged"):null,fi=ct==="passed"?"assurance":ct==="blocked"?"danger":"highlight",gi=he?`${ys(he).toLocaleString()} ${s("privatePdp.words")} · ${he.length.toLocaleString()} ${s("privatePdp.chars")}`:null,$a=j?Je.figures.prompeteerDownloadsAll:typeof t.downloadCount=="number"?t.downloadCount:null,Bt=j&&Je.figures.npmPackage?Je.figures.npmWeekly:null,Dt=ve.resolvedLanguage||void 0,Oa=Bt!=null?wn(Je.figures.npmWeekEnding,Dt):null,Lt=t.createdAt?new Date(t.createdAt):null,Ka=!!Lt&&!Number.isNaN(Lt.getTime()),qa=j&&!!u,vi=!z&&(Ye||q||!K&&!!La),Wa=Ye&&e.jsx(h,{fullWidth:!0,onClick:()=>Wt.mutate(),disabled:Wt.isPending,"data-testid":"button-action-fork",title:s("privatePdp.saveToPromptDrive"),children:Wt.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsx("span",{children:s("privatePdp.saving")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Tr,{"aria-hidden":"true"}),e.jsx("span",{className:"whitespace-nowrap",children:s("privatePdp.saveToPromptDrive")})]})}),bi=async()=>{if(L("skill_download_sdp"))return;const a=Sn(t?.title),r=()=>Ja(Pl(t?.promptText||t?.content||""),t?.metadata);if(!j||!t?.id){const Y=new Blob([r()],{type:"text/markdown"}),G=URL.createObjectURL(Y),re=document.createElement("a");re.href=G,re.download=a,re.click(),URL.revokeObjectURL(G),k({title:s("skillSdp.skillDownloaded"),description:a});return}const w=await Pn({skillId:t.id,filename:a,fallbackContent:r});if(w==="unauthorized"){L("skill_download_sdp");return}if(w==="failed"){R("download","error","Download failed. Please try again.");return}const N={skillId:t.id,skillTitle:t.title||"",category:t.category,source:"skill_detail",userId:y?.id};w==="server"?(ss(N),i?.capture("skill_download",{skill_id:t.id,skill_title:t.title,category:t.category,format:"skill_md",source:"skill_page"}),Ut()):Se("skill_download",{prompt_id:t.id,title:t.title,category:t.category,format:"skill_md",source:"skill_page_fallback",generation_source:t.generationSource}),k({title:s("skillSdp.skillDownloaded"),description:a})},Vt=a=>{const r=a.length,w=ys(a),N=Math.ceil(w/200);return`${r.toLocaleString()} ${s("privatePdp.chars")} ⢠${w.toLocaleString()} ${s("privatePdp.words")} ⢠${N} ${s("privatePdp.minRead")}`},{scoringRubric:Gt,modalityReasoning:ji}=tr(t?.promptIQAnalytics),Yt=t.metadata?.compliance?.riskLevel,Qa=Yt==="critical"?"danger":Yt==="high"||Yt==="medium"?"highlight":"second",dt=(a,r)=>(navigator.clipboard?.writeText?navigator.clipboard.writeText(a):Promise.reject(new Error("Clipboard unavailable"))).then(()=>!0,()=>(R(r,"error","Copy failed. The browser blocked the clipboard; select the text and copy it."),!1)),Ha=a=>(Ne&&Se("skill_copy",{prompt_id:t.id,title:t.title,category:t.category,source:a,generation_source:t.generationSource}),dt(Ne?Ja(he,t?.metadata):he,a==="pdp_copy_button"?"copy":"copy-workbench")),Ba=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[var(--public-ink-3)]",children:"Category"}),e.jsx("span",{className:"text-[var(--public-ink)]",children:Tl(t.category)||"General"}),q&&e.jsx(Xe,{className:"h-3 w-3 text-[var(--public-ink-3)] opacity-60 sm:opacity-0 sm:group-hover:opacity-100","aria-hidden":"true"})]}),Va=x(Zt({variant:ea("count"),size:"md"}),"group min-h-11 gap-1.5 sm:min-h-0 disabled:cursor-not-allowed",q&&"cursor-pointer hover:border-[var(--public-hairline-strong)]",p.focus),Ga=()=>{q&&(it(t.category),ie(!0))},Ya=e.jsxs(Xr,{value:Qe,onValueChange:a=>it(a),children:[e.jsx(Zr,{className:"h-12 w-full sm:h-10 sm:w-[220px]",children:e.jsx(en,{})}),e.jsx(tn,{className:"max-h-[300px] overflow-y-auto",children:[...Jr].sort((a,r)=>a.localeCompare(r)).map(a=>e.jsx(an,{value:a,children:a},a))})]});return e.jsxs(Rs.div,{ref:we,className:"min-h-screen flex flex-col relative bg-[var(--public-ground)]",initial:{opacity:1}
26,animate:{opacity:zs?0:1},transition:{duration:.25,ease:"easeOut"},"data-testid":"sdp-page",children:[e.jsx("div",{className:"fixed inset-0 bg-[var(--public-ground)]",style:{zIndex:-100}}),e.jsx(zi,{title:`${t.title} | Prompeteer.ai`,description:t.description||"Expert AI prompt from Prompeteer.ai - Your shortcut to expert AI prompts for all major platforms.",image:Ui,url:j?`https://prompeteer.ai/skills-hub/${encodeURIComponent(t.id||u||"")}`:`https://prompeteer.ai/vault/${u}`}),e.jsx(Vi,{}),e.jsx("div",{"data-testid":"sdp-subheader",className:"border-b border-[var(--public-hairline)] bg-[var(--public-ground)]",children:e.jsxs("div",{className:x(p.wrap,"flex flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between"),children:[e.jsx("nav",{"aria-label":"Breadcrumb",className:"min-w-0",children:e.jsxs("ol",{className:x(p.small,"flex min-w-0 items-center gap-1.5"),children:[e.jsx("li",{className:"shrink-0",children:e.jsxs(ua,{href:be.href,className:x(p.textButton,"px-1"),"data-testid":"link-detail-parent",children:[e.jsx(aa,{className:"h-4 w-4","aria-hidden":"true"}),be.label]})}),e.jsx("li",{"aria-hidden":"true",className:"hidden sm:block",children:e.jsx(aa,{className:"h-4 w-4 rotate-180 text-[var(--public-ink-3)]"})}),e.jsx("li",{className:"hidden min-w-0 truncate font-semibold text-[var(--public-ink)] sm:block","aria-current":"page",children:et(t.title)}),K&&e.jsx("li",{className:"shrink-0",children:e.jsxs(H,{job:"status",children:[e.jsx(ft,{className:"h-3 w-3","aria-hidden":"true"}),"Team"]})})]})}),e.jsxs("div",{className:"flex flex-col items-stretch gap-1.5 sm:items-end",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(h,{variant:"outline",size:"sm",onClick:()=>{if(Ae){L("skill_copy");return}Ha("pdp_copy_button").then(a=>{a&&(ba(!0),setTimeout(()=>ba(!1),2e3),k({title:s("privatePdp.copied"),description:s("privatePdp.promptCopied"),duration:2e3}))})},"data-testid":"button-action-copy",title:s("privatePdp.copy"),"aria-label":s("privatePdp.copy"),children:_s?e.jsxs(e.Fragment,{children:[e.jsx(Fe,{className:"text-[var(--public-assurance)]","aria-hidden":"true"}),e.jsx("span",{className:"hidden sm:inline",children:s("privatePdp.copied")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{"aria-hidden":"true"}),e.jsx("span",{className:"hidden sm:inline",children:s("privatePdp.copy")})]})}),!Ye&&!K&&e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>qa?De(!0):vt(!0),"aria-haspopup":"dialog","data-testid":"button-action-share",title:s("privatePdp.shareTitle"),"aria-label":s("privatePdp.shareTitle"),children:[e.jsx(Ir,{"aria-hidden":"true"}),e.jsx("span",{className:"hidden sm:inline",children:s("privatePdp.shareTitle")})]}),e.jsxs(h,{size:"sm",onClick:ce,disabled:V,"aria-label":s("agent.refine.forkCopy"),title:s("agent.refine.forkCopy"),"data-testid":"button-action-refine",className:"hidden sm:inline-flex",children:[V?e.jsx(ye,{className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}):e.jsx(sa,{"aria-hidden":"true"}),s("agent.refine.forkCopy")]})]}),e.jsx(de,{status:M,anchor:"refine",className:"hidden sm:flex","data-testid":"inline-status-refine"}),e.jsx(de,{status:M,anchor:"copy","data-testid":"inline-status-copy"})]})]})}),e.jsx("div",{className:x(p.wrap,"pb-2 pt-6"),children:e.jsx(sn,{})}),e.jsx("main",{className:x(p.wrap,"flex-1 py-6 sm:py-10"),children:e.jsxs("div",{className:"grid grid-cols-1 gap-8 lg:grid-cols-12 lg:gap-10",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-6 lg:col-span-3",children:[e.jsx(Qi,{generation:Js}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(pe,{accent:!z,className:z?"text-[var(--public-second)]":void 0,"data-testid":"sdp-eyebrow",children:s(z?"skillSdp.skillBadge":"drive.count.prompt")}),T?e.jsxs("div",{className:"flex w-full flex-col gap-2",children:[e.jsx(tt,{ref:wt,type:"text",value:Ie,onChange:a=>_e(a.target.value),onKeyDown:a=>{a.key==="Enter"&&_a(),a.key==="Escape"&&X(!1)},placeholder:"Enter title...","data-testid":"input-edit-title"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{size:"sm",onClick:_a,className:"flex-1","data-testid":"button-save-title",children:[e.jsx(Fe,{"aria-hidden":"true"}),e.jsx("span",{children:"Save"})]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>X(!1),className:"flex-1","data-testid":"button-cancel-title",children:[e.jsx(ht,{"aria-hidden":"true"}),e.jsx("span",{children:"Cancel"})]})]})]}):e.jsxs("h1",{className:x(p.display,"text-[28px] sm:text-[32px] lg:text-[34px] lg:leading-[1.1]",q&&"group cursor-pointer"),onClick:()=>{q&&(_e(t.title),X(!0))},"data-testid":"prompt-title",children:[et(t.title),q&&e.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),_e(t.title),X(!0)},"aria-label":`${s("privatePdp.edit")}: ${et(t.title)}`,"data-testid":"button-edit-title",className:x("-my-2 ml-1 inline-flex h-9 w-9 items-center justify-center rounded-[var(--public-radius-control)] align-middle text-[var(--public-ink-3)] opacity-60 transition-opacity duration-color ease-public hover:text-[var(--public-ink)] focus-visible:opacity-100 motion-reduce:transition-none sm:opacity-0 sm:group-hover:opacity-100",p.focus),children:e.jsx(Xe,{className:"h-4 w-4","aria-hidden":"true"})})]}),e.jsx(de,{status:M,anchor:"title","data-testid":"inline-status-title"}),e.jsxs(ws,{variant:"rows","data-testid":"pdp-head-ledger",children:[e.jsx(Te,{label:s("promptCard.ledger.updated","Updated"),children:Xa(t.updatedAt||(z?t.createdAt:null))}
26),!z&&e.jsx(Te,{label:s("promptCard.ledger.created","Created"),children:Xa(t.createdAt)}),e.jsx(Te,{label:s("promptCard.ledger.uses","Uses"),children:ki(t.usageCount)}),z&&e.jsx(Te,{label:s("promptCard.ledger.scan","Scan"),tone:fi,children:Ua?`${Ua}${$e?.score!=null?` · ${Math.round($e.score)}`:""}`:null}),e.jsx(Te,{label:s("promptCard.ledger.folder","Folder"),children:Ys}),z?e.jsxs(e.Fragment,{children:[e.jsx(Te,{label:s("promptCard.ledger.format","Format"),children:"SKILL.md"}),e.jsx(Te,{label:s("promptCard.ledger.downloads","Downloads"),valueProps:{title:kn(s),"data-testid":"pdp-ledger-downloads"},children:$a!=null?us($a,Dt):null}),Bt!=null?e.jsx(Te,{label:s("promptCard.ledger.npmWeek","npm/week"),suffix:Oa?` · ${Oa}`:void 0,valueProps:{title:Nn(s,Je.figures,Dt),"data-testid":"pdp-ledger-npm-week"},children:us(Bt,Dt)}):null]}):e.jsx(Te,{label:s("promptCard.ledger.length","Length"),children:gi})]}),Ra&&e.jsxs(H,{job:"status",className:"w-fit","data-testid":"pdp-optimized-for",children:[e.jsx(ls,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsxs("span",{children:["Optimized for ",Ra]})]}),z&&t.description&&e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(pe,{children:s("privatePdp.skillDescriptionTitle",{defaultValue:"Description"})}),e.jsx("p",{className:p.body,children:(()=>{const r=(t.content||t.promptText||"").match(/^description:\s*>-?\s*\n([\s\S]*?)(?=\n\w|\n---)/m);if(r){const w=r[1].replace(/\n\s*/g," ").trim();if(w.length>t.description.length)return w}return t.description})()})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"flex w-full sm:hidden",children:at?e.jsxs("div",{className:"flex w-full flex-col items-stretch gap-2",children:[Ya,e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{size:"sm",onClick:za,className:"flex-1","data-testid":"button-save-category-mobile",children:[e.jsx(Fe,{"aria-hidden":"true"}),e.jsx("span",{children:"Save"})]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>ie(!1),className:"flex-1","data-testid":"button-cancel-category-mobile",children:[e.jsx(ht,{"aria-hidden":"true"}),e.jsx("span",{children:"Cancel"})]})]})]}):e.jsx("button",{type:"button",onClick:Ga,disabled:!q,className:Va,"data-testid":"category-badge-mobile",children:Ba})}),e.jsx("div",{className:"hidden sm:flex sm:min-w-0",children:at?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Ya,e.jsx(h,{size:"sm",onClick:za,"aria-label":"Save","data-testid":"button-save-category",children:e.jsx(Fe,{"aria-hidden":"true"})}),e.jsx(h,{variant:"outline",size:"sm",onClick:()=>ie(!1),"aria-label":"Cancel","data-testid":"button-cancel-category",children:e.jsx(ht,{"aria-hidden":"true"})})]}):e.jsx("button",{type:"button",onClick:Ga,disabled:!q,className:Va,"data-testid":"category-badge",children:Ba})}),z&&e.jsx(H,{job:"category","data-testid":"sdp-type-badge",children:s("skillSdp.skillBadge")}),z&&t.securityStatus&&e.jsx(ln,{status:t.securityStatus,size:"md"}),z&&(t.sourceLabel||t.skillSource)&&e.jsxs(ra,{children:[e.jsx(na,{asChild:!0,children:t.githubUrl?e.jsxs("a",{href:t.githubUrl,target:"_blank",rel:"noopener noreferrer",className:x(Zt({variant:ea("count"),size:"md"}),"gap-1.5",p.focus),children:[e.jsx(os,{className:"h-3 w-3 text-[var(--public-second)]","aria-hidden":"true"}),t.sourceLabel||t.skillSource]}):e.jsxs(H,{job:"count",size:"md",children:[e.jsx(os,{className:"h-3 w-3 text-[var(--public-second)]","aria-hidden":"true"}),t.sourceLabel||t.skillSource]})}),e.jsx(la,{side:"bottom",className:"max-w-xs text-xs",children:e.jsx("span",{className:"font-mono",children:t.skillSource})})]})]}),e.jsx(de,{status:M,anchor:"category","data-testid":"inline-status-category"})]}),z&&!(Ae&&!$e)&&e.jsx(dn,{report:as(t.metadata),securityStatus:t.securityStatus})]}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-6 lg:col-span-6",children:[e.jsxs(Xi,{className:"overflow-hidden p-0 sm:p-0","data-testid":"sdp-workbench",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-[var(--public-hairline)] px-5 py-4 sm:px-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(pe,{className:"text-[var(--public-ink-2)]",children:z?Ta?s("bundles.breadcrumbSkillsHub","Skills Hub"):s("privatePdp.yourCuratedSkill"):t.metadata?.source==="user_import"?s("privatePdp.yourImportedPrompt"):s("privatePdp.yourPrompeteerPrompt")}),t.metadata?.compliance&&e.jsxs(H,{variant:Qa,title:`${s("privatePdp.regulatoryContext")}: ${t.metadata.compliance.domains?.join(", ")||s("privatePdp.compliance")}`,"data-testid":"badge-regulatory-context",children:[e.jsx(Is,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),t.metadata.compliance.domains?.length>1?s("privatePdp.regulatoryDomains",{count:t.metadata.compliance.domains.length}):t.metadata.compliance.domains?.[0]?.replace(/-/g," ").replace(/\b\w/g,a=>a.toUpperCase())||s("privatePdp.compliance")]}),t.metadata?.compliance?.jurisdictions&&t.metadata.compliance.jurisdictions.length>0&&e.jsx(ds,{delayDuration:200,children:e.jsxs("span",{className:"inline-flex items-center gap-1","data-testid":"badge-jurisdiction-flags-header",children:[t.metadata.compliance.jurisdictions.slice(0,4).map(a=>e.jsxs(ra,{children:[e.jsx(na,{asChild:!0,children:e.jsx("span",{className:"cursor-help",children:e.jsx(is,{jurisdiction:a,size:"sm"})})}),e.jsx(la,{side:"top",className:"text-xs",children:Za[a]||a})]},a)),t.metadata.compliance.jurisdictions.length>4&&e.jsxs("span",{className:p.meta,children:["+",t.metadata.compliance.jurisdictions.length-4]})]})})]}),!Ae&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ir,{promptId:t.id,promptText:he,platformId:t.platformId,variant:"minimal"}),e.jsx(rr,{size:"sm",tooltip:s("privatePdp.howWasThisPrompt"),className:"rounded-[var(--public-radius-control)] p-2 transition-colors duration-color ease-public hover:bg-[var(--public-surface-2)]"}),e.jsxs(h,{ref:ka,variant:"outline",size:"sm",onClick:a=>{a.stopPropagation(),q&&Ee(!0)},disabled:!q,className:"hidden sm:inline-flex","aria-label":s("privatePdp.edit"),"data-testid":"button-edit-prompt-desktop",children:[e.jsx(Xe,{"aria-hidden":"true"}),e.jsx("span",{children:s("privatePdp.edit")})]}),e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:()=>{Ha("pdp_header_copy").then(a=>{a&&k({title:s("privatePdp.promptCopiedToClipboard"),duration:2e3})})},"aria-label":s("privatePdp.copy"),"data-testid":"button-copy-prompt",children:e.jsx(Ke,{"aria-hidden":"true"})})]})]}),e.jsxs("div",{className:x(p.meta,"flex flex-wrap gap-x-3 gap-y-1"),
26children:[Ka&&e.jsx("span",{children:s("privatePdp.originalVersionCreated",{date:Lt.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})}),!Ae&&e.jsx("span",{children:Vt(he)})]}),e.jsx("h2",{className:p.h3,"data-testid":"title-display",children:t.title}),e.jsx(de,{status:M,anchor:"copy-workbench","data-testid":"inline-status-copy-workbench"})]}),e.jsxs("div",{className:"px-5 py-5 sm:px-6",children:[Ae?e.jsx(pn,{kind:"skill",children:e.jsxs("div",{className:"flex flex-col items-start gap-3 rounded-[var(--public-radius-control)] border border-[var(--public-hairline)] bg-[var(--public-paper)] p-5 sm:p-6","data-testid":"sdp-instructions-sign-in",children:[e.jsx("span",{className:p.tile,children:e.jsx(Dr,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx("h3",{className:p.h3,children:s("skillSdp.signInToRead","Sign in to read the instructions")}),e.jsx("p",{className:x(p.small,"max-w-[52ch] font-normal"),children:s("skillSdp.signInToReadDesc","The full SKILL.md and its scan report are free with an account. Browsing the Skills Hub needs none.")}),e.jsx(h,{onClick:xi,"data-testid":"button-sign-in-to-read",children:s("skillSdp.signInToReadButton","Sign in to read")})]})}):je?e.jsx(yl,{original:je.original,translationLanguage:je.translation,originalText:he,translation:Be,onCopyOriginal:()=>{dt(he,"copy-workbench").then(a=>{a&&k({title:s("drive.toasts.languageContentCopied",{language:je.original.label})})})},onCopyTranslation:()=>{Be.state==="ready"&&dt(Be.text,"copy-workbench").then(a=>{a&&k({title:s("drive.toasts.languageContentCopied",{language:je.translation.label})})})},onRetry:()=>Ks(a=>a+1)}):e.jsx("div",{ref:wa,className:x("btn-no-grey relative max-h-[500px] overflow-y-auto rounded-[var(--public-radius-control)] border border-[var(--public-hairline)] bg-[var(--public-paper)] p-4",q&&"cursor-pointer sm:cursor-text",p.focus),style:{touchAction:"pan-y",WebkitTapHighlightColor:"transparent",WebkitUserSelect:"text",userSelect:"text",WebkitOverflowScrolling:"touch"},role:q?"button":void 0,tabIndex:q?0:void 0,"aria-label":q?"Tap to edit prompt":void 0,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&q&&(a.preventDefault(),Ee(!0))},"data-testid":"prompt-content-box",children:e.jsx("pre",{className:x(pa,"pointer-events-none"),children:he})}),!Ye&&!Ae&&e.jsxs("div",{className:"mt-3 flex items-center justify-end gap-2 border-t border-[var(--public-hairline)] pt-3 sm:hidden",children:[e.jsx(h,{variant:"outline",size:"icon-sm",onClick:ce,disabled:V,"aria-label":s("agent.refine.forkCopy"),title:s("agent.refine.forkCopy"),"data-testid":"button-action-refine-mobile",children:V?e.jsx(ye,{className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}):e.jsx(sa,{"aria-hidden":"true"})}),q&&e.jsxs(h,{size:"sm",onClick:a=>{a.preventDefault(),a.stopPropagation(),Ee(!0)},onTouchEnd:a=>{a.preventDefault(),a.stopPropagation(),Ee(!0)},style:{touchAction:"manipulation",WebkitUserSelect:"none",WebkitTouchCallout:"none"},"aria-label":s("privatePdp.edit"),"data-testid":"button-edit-prompt-mobile",children:[e.jsx(Xe,{"aria-hidden":"true"}),e.jsx("span",{children:s("privatePdp.edit")})]})]}),e.jsx(de,{status:M,anchor:"refine",className:"mt-2 sm:hidden","data-testid":"inline-status-refine-mobile"})]})]}),!z&&vl(t.platformId,t.category,he)&&e.jsx(xl,{userInput:t.originalInput||t.userInput||"",enhancedPrompt:he,promptId:t.id,category:t.category,platformId:t.platformId,cachedComparison:t.metadata?.responseComparison?.inputKey===ma(JSON.stringify([t.originalInput||t.userInput||"",he]))?t.metadata.responseComparison:null},t.id),t.originalInput&&t.originalInput.trim()!==(t.userInput||"").trim()&&e.jsxs("section",{className:x(p.card,"flex flex-col gap-3 p-5 sm:p-6"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(pe,{children:s("privatePdp.yourOriginalInput")}),(t.refinementCount??0)>0&&e.jsx("span",{className:p.meta,children:s("privatePdp.enhancedCount",{count:t.refinementCount})})]}),e.jsx("p",{className:p.meta,children:Vt(t.originalInput||"")})]}),e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:()=>{dt(t.originalInput||"","copy-original").then(a=>{a&&k({title:s("privatePdp.inputCopiedToClipboard")})})},"aria-label":s("privatePdp.copyOriginalInput"),title:s("privatePdp.copyOriginalInput"),"data-testid":"button-copy-original-input",children:e.jsx(Ke,{"aria-hidden":"true"})})]}),e.jsx(de,{status:M,anchor:"copy-original","data-testid":"inline-status-copy-original"}),e.jsx("div",{className:"max-h-[300px] overflow-y-auto rounded-[var(--public-radius-control)] bg-[var(--public-surface-2)] p-4",children:e.jsx("pre",{className:pa,children:t.originalInput})})]}),t.userInput&&e.jsxs("section",{className:x(p.card,"flex flex-col gap-3 p-5 sm:p-6"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[e.jsx(pe,{children:t.originalInput&&t.originalInput.trim()!==(t.userIn
26put||"").trim()?s("privatePdp.yourEnhancedInput"):s("privatePdp.yourInput")}),e.jsx("p",{className:p.meta,children:Vt(t.userInput||"")})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:()=>{dt(t.userInput||"","copy-input").then(a=>{a&&k({title:s("privatePdp.inputCopiedToClipboard")})})},"aria-label":s("privatePdp.copyInput"),title:s("privatePdp.copyInput"),"data-testid":"button-copy-enhanced-input",children:e.jsx(Ke,{"aria-hidden":"true"})}),e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:()=>{sessionStorage.setItem("prefilled_user_input",t.userInput||""),$("/create")},"aria-label":s("privatePdp.redoEnhancement"),title:s("privatePdp.redoEnhancement"),"data-testid":"button-redo-enhanced-input",children:e.jsx(Ds,{"aria-hidden":"true"})})]})]}),e.jsx(de,{status:M,anchor:"copy-input","data-testid":"inline-status-copy-input"}),e.jsx("div",{className:"max-h-[300px] overflow-y-auto rounded-[var(--public-radius-control)] bg-[var(--public-surface-2)] p-4",children:e.jsx("pre",{className:pa,children:t.userInput})})]}),!z&&e.jsxs("section",{className:x(p.card,"flex flex-col gap-3 p-5 sm:p-6"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ia,{className:"h-4 w-4 text-[var(--public-ink-3)]","aria-hidden":"true"}),e.jsx(pe,{children:s("privatePdp.exportFormats","Export Formats")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:oi,"data-testid":"button-export-json",children:[e.jsx(Lr,{"aria-hidden":"true"}),e.jsx("span",{children:"JSON"})]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:ci,"data-testid":"button-export-md",children:[e.jsx(ta,{"aria-hidden":"true"}),e.jsx("span",{children:"MD"})]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:di,"data-testid":"button-export-txt",children:[e.jsx(ta,{"aria-hidden":"true"}),e.jsx("span",{children:"TXT"})]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:pi,"data-testid":"button-export-yaml",children:[e.jsx(Rr,{"aria-hidden":"true"}),e.jsx("span",{children:"YAML"})]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:ui,"data-testid":"button-export-agentkit",children:[e.jsx(ia,{"aria-hidden":"true"}),e.jsx("span",{children:"AgentKit"})]})]})]}),!Ae&&e.jsx("section",{className:x(p.card,"overflow-hidden"),children:e.jsx(cl,{prompt:t?.content||t?.promptText||"",platform:t?.platformId||"prompeteer",context:t?.userInput||"",metadata:{promptId:t?.id,title:t?.title,category:t?.category}})}),e.jsxs("section",{className:x(p.card,"overflow-hidden"),children:[e.jsxs("button",{type:"button",onClick:()=>jt(!Me),"aria-expanded":Me,"aria-controls":"sdp-metadata-panel",className:x("flex min-h-[56px] w-full items-center justify-between gap-3 px-5 py-4 text-left transition-colors duration-color ease-public hover:bg-[var(--public-surface-2)] sm:px-6",p.focus),"data-testid":"button-toggle-metadata",children:[e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:p.h3,children:s("privatePdp.metadata")}),q&&e.jsx(H,{job:"status",className:"sm:hidden",children:s("privatePdp.editable")})]}),e.jsx(ga,{className:x("h-5 w-5 shrink-0 text-[var(--public-ink-3)] transition-transform duration-transform ease-public motion-reduce:transition-none",Me&&"rotate-180"),"aria-hidden":"true"})]}),Me&&e.jsx("div",{id:"sdp-metadata-panel",className:"border-t border-[var(--public-hairline)] px-5 pb-6 pt-5 sm:px-6",children:e.jsxs("div",{className:"grid grid-cols-1 gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-6",children:[z&&(()=>{const a=t?.metadata?.skillClassification,r=a?.domain||t.category||null,w=a?.taskType||null,N=a?.goals||[],Y=a?.complexity||t.difficulty||null,G=a?.expertise||null;return e.jsxs(e.Fragment,{children:[r&&e.jsx(le,{label:s("privatePdp.skillDomain",{defaultValue:"Domain"}),children:e.jsx("span",{className:x(p.small,"capitalize text-[var(--public-ink)]"),children:r})}),G&&e.jsx(le,{label:s("privatePdp.skillExpertise",{defaultValue:"Expertise"}),children:e.jsx("span",{className:x(p.small,"capitalize text-[var(--public-ink)]"),children:G})}),w&&e.jsx(le,{label:s("privatePdp.skillTaskType",{defaultValue:"Task Type"}),children:e.jsx("span",{className:x(p.small,"capitalize text-[var(--public-ink)]"),children:w.replace(/_/g," ")})}),N.length>0&&e.jsx(le,{label:s("privatePdp.skillGoals",{defaultValue:"Goals"}),children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:N.map(re=>e.jsx(H,{job:"category",children:re},re))})}),Y&&e.jsx(le,{label:s("privatePdp.skillComplexity",{defaultValue:"Complexity"}),children:e.jsx(H,{job:"category",size:"md",className:"capitalize",children:Y})})]})})(),!z&&e.jsxs(e.Fragment,{children:[e.jsx(le,{label:s("privatePdp.platform"),children:e.jsx("span",{className:x(p.small,"capitalize text-[var(--public-ink)]"),children:t.platformId==="x-model"?"X Model":(t.platformId||"Universal").replace("-"," ")})}),e.jsx(le,{label:s("privatePdp.model"),children:e.jsx("span",{className:x(p.small,"capitalize text-[var(--public-ink)]"),children:t.modelId==="agnostic"||t.modelId==="universal"?"Universal":(t.modelId||"
26Universal").replace(/-/g," ")})})]}),e.jsx(le,{label:s("privatePdp.generationMode"),children:e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:z?e.jsxs(H,{job:"category",children:[e.jsx(sa,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),s("privatePdp.skillMode",{defaultValue:"Skill"})]}):t.metadata?.generationMode==="agent"?e.jsxs(e.Fragment,{children:[e.jsxs(H,{job:"status",children:[e.jsx(cs,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),s("privatePdp.agent")]}),t.metadata?.agentPattern&&e.jsx("span",{className:p.meta,children:t.metadata.agentPattern==="react"?s("privatePdp.reactPattern"):s("privatePdp.rewooPattern")})]}):t.metadata?.generationMode==="system-prompt"?e.jsxs(H,{job:"status",children:[e.jsx(Er,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),s("privatePdp.systemPrompt")]}):t.deepReasoning||t.extendedThinkingEnabled?e.jsxs(e.Fragment,{children:[e.jsxs(H,{job:"status",children:[e.jsx(cs,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),s("privatePdp.extendedThinking")]}),(t.deepReasoningPlatform||t.extendedThinkingTargetPlatform)&&e.jsxs("span",{className:p.meta,children:[s("privatePdp.via")," ",(()=>{const a=(t.deepReasoningPlatform||t.extendedThinkingTargetPlatform||"").toLowerCase();return a.includes("claude")?"Claude":a.includes("openai")||a.includes("o1")||a.includes("gpt")?"OpenAI":a.includes("gemini")?"Gemini":(t.deepReasoningPlatform||t.extendedThinkingTargetPlatform)?.replace(/-/g," ")||"Unknown"})()]})]}):e.jsxs(H,{job:"status",children:[e.jsx(ls,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),s("privatePdp.standard")]})})}),t.contextFiles&&Array.isArray(t.contextFiles)&&t.contextFiles.length>0&&e.jsx(le,{label:s("privatePdp.contextFiles"),children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.contextFiles.map((a,r)=>e.jsxs(H,{job:"count",className:"max-w-[180px]",title:a.name||a.filename||a.originalName||`File ${r+1}`,children:[e.jsx(Ar,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:a.name||a.filename||a.originalName||`File ${r+1}`})]},r))})}),t.metadata?.compliance&&e.jsx(le,{label:s("privatePdp.regulatoryContext"),children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{children:e.jsxs(H,{variant:Qa,children:[(t.metadata.compliance.riskLevel||"low").toUpperCase()," ",s("privatePdp.risk")]})}),t.metadata.compliance.jurisdictions&&t.metadata.compliance.jurisdictions.length>0&&e.jsx(ds,{delayDuration:200,children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"metadata-jurisdiction-flags",children:[e.jsxs("span",{className:p.meta,children:[s("privatePdp.jurisdictions"),":"]}),t.metadata.compliance.jurisdictions.map(a=>e.jsxs(ra,{children:[e.jsx(na,{asChild:!0,children:e.jsxs("span",{className:x(Zt({variant:ea("count"),size:"md"}),"cursor-help gap-1.5"),children:[e.jsx(is,{jurisdiction:a,size:"md"}),e.jsx("span",{children:a})]})}),e.jsx(la,{side:"top",className:"text-xs",children:Za[a]||a})]},a))]})}),t.metadata.compliance.domains&&t.metadata.compliance.domains.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.metadata.compliance.domains.map((a,r)=>e.jsx(H,{job:"category",className:"capitalize",children:a.replace(/-/g," ")},r))}),t.metadata.compliance.regulations&&t.metadata.compliance.regulations.length>0&&e.jsxs("div",{className:p.small,children:[e.jsxs("span",{className:"text-[var(--public-ink)]",children:[s("privatePdp.regulations"),":"]})," ",t.metadata.compliance.regulations.slice(0,5).join(", "),t.metadata.compliance.regulations.length>5&&` +${t.metadata.compliance.regulations.length-5} ${s("privatePdp.more")}`]})]})}),e.jsx(le,{label:s("privatePdp.created"),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:x(p.small,"text-[var(--public-ink)]"),children:Ka?Lt.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}):Ni}),t.generationSource==="mcp"&&t.mcpClientType&&e.jsxs(H,{job:"status",children:[s("privatePdp.createdIn")," ",Es(t.mcpClientType)]})]})}),e.jsxs(le,{label:s("privatePdp.description"),aside:q&&!te&&e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>{gt(t.description||""),se(!0)},"aria-label":s("privatePdp.edit"),"data-testid":"button-edit-description",children:[e.jsx(Xe,{"aria-hidden":"true"}),e.jsx("span",{className:"sm:hidden",children:s("privatePdp.edit")})]}),children:[te?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ls,{ref:kt,value:We,onChange:a=>gt(a.target.value),onKeyDown:a=>{a.key==="Escape"&&se(!1)},placeholder:s("privatePdp.enterDescription"),"data-testid":"input-edit-description"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs(h,{size:"sm",onClick:ai,"data-testid":"button-save-description",children:[e.jsx(Fe,{"aria-hidden":"true"}),e.jsx("span",{children:s("privatePdp.saveDescription")})]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>se(!1),"data-testid":"button-cancel-description",children:[e.jsx(ht,{"aria-hidden":"true"}
26),e.jsx("span",{children:s("privatePdp.cancel")})]})]})]}):e.jsx("p",{className:x(p.body,"min-h-[60px] rounded-[var(--public-radius-control)] bg-[var(--public-surface-2)] p-3 text-[14px]"),children:t.description||s("privatePdp.noDescriptionDefault")}),e.jsx(de,{status:M,anchor:"description",className:"mt-2","data-testid":"inline-status-description"})]})]}),e.jsxs("div",{className:"flex flex-col gap-6",children:[!z&&e.jsxs(e.Fragment,{children:[e.jsx(le,{label:s("privatePdp.advancedOptions"),children:e.jsxs("dl",{className:"flex flex-col divide-y divide-[var(--public-hairline)]",children:[t.temperature&&Number(t.temperature)>0&&(()=>{const a=Number(t.temperature),r=a<=.3?s("privatePdp.precise"):a<=.5?s("privatePdp.balanced"):a<=.7?s("privatePdp.creative"):a<=.9?s("privatePdp.veryCreative"):s("privatePdp.experimental");return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2",children:[e.jsx("dt",{className:p.small,children:s("privatePdp.creativity")}),e.jsxs("dd",{className:x(p.meta,"text-[var(--public-ink)]"),children:[r," (",a.toFixed(1),")"]})]})})(),t.maxTokens&&t.maxTokens>0&&(()=>{const a=t.maxTokens,r=Math.round(a*.75),w=Math.round(a*4);return e.jsxs("div",{className:"flex flex-col gap-1 py-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[e.jsx("dt",{className:p.small,children:s("privatePdp.length")}),e.jsx("dd",{className:x(p.meta,"text-[var(--public-ink)]"),children:s("privatePdp.wordsChars",{words:r.toLocaleString(),chars:w.toLocaleString()})})]})})(),t.outputType&&t.outputType!=="text"&&e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2",children:[e.jsx("dt",{className:p.small,children:s("privatePdp.outputFormat")}),e.jsx("dd",{className:x(p.meta,"capitalize text-[var(--public-ink)]"),children:t.outputType})]}),(!t.temperature||Number(t.temperature)===0)&&(!t.maxTokens||t.maxTokens===0)&&(!t.outputType||t.outputType==="text")&&e.jsx("div",{className:"py-2",children:e.jsx("dd",{className:x(p.small,"italic"),children:s("privatePdp.auto")})})]})}),e.jsx(le,{label:s("privatePdp.complexity"),children:e.jsx(H,{job:"count",size:"md",children:t.difficulty||"Professional"})}),(()=>{const a=xs(t),r=a.kind==="mcp";return a.kind==="unknown"?null:e.jsx(le,{label:"Source","data-testid":"metadata-source-section",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:x(p.tile,"h-6 w-6 rounded-[calc(var(--public-radius-control)/2)]"),"data-testid":r?"badge-mcp-metadata":"badge-imported-metadata",title:r?"MCP generated prompt":"Imported prompt",children:e.jsx(Fr,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx("span",{className:x(p.small,"text-[var(--public-ink)]"),children:a.label}),t.metadata?.importedAt&&e.jsx("span",{className:p.meta,children:new Date(t.metadata.importedAt).toLocaleDateString()})]})})})()]}),e.jsxs(le,{label:"Tags",aside:q&&!ee&&e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>{st(t.tags||[]),ke(!0)},"aria-label":"Edit","data-testid":"button-edit-tags",children:[e.jsx(Xe,{"aria-hidden":"true"}),e.jsx("span",{className:"sm:hidden",children:"Edit"})]}),children:[ee?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("div",{className:"flex min-h-[36px] flex-wrap gap-2",children:Re.map((a,r)=>e.jsx(nn,{mono:!0,size:"sm",onRemove:()=>ii(a),removeLabel:`Remove ${a}`,children:a},r))}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(tt,{ref:ya,type:"text",value:He,onChange:a=>rt(a.target.value),onKeyDown:a=>{a.key==="Enter"&&He.trim()&&Ma(),a.key==="Escape"&&ke(!1)},placeholder:"Type tag and press Enter...",className:"flex-1","data-testid":"input-new-tag"}),e.jsx(h,{variant:"outline",onClick:Ma,disabled:!He.trim(),"data-testid":"button-add-tag",children:"Add Tag"})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsxs(h,{size:"sm",onClick:si,"data-testid":"button-save-tags",children:[e.jsx(Fe,{"aria-hidden":"true"}),e.jsx("span",{children:"Save Tags"})]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>ke(!1),"data-testid":"button-cancel-tags",children:[e.jsx(ht,{"aria-hidden":"true"}),e.jsx("span",{children:"Cancel"})]})]})]}):e.jsx("div",{className:"flex min-h-[36px] flex-wrap items-center gap-2",children:t.tags&&t.tags.length>0?t.tags.map((a,r)=>
26e.jsx(H,{job:"count",size:"md",children:a},r)):e.jsx("span",{className:x(p.small,"italic"),children:"No tags yet"})}),e.jsx(de,{status:M,anchor:"tags",className:"mt-2","data-testid":"inline-status-tags"})]})]})]})})]})]}),e.jsxs("aside",{className:"flex min-w-0 flex-col gap-4 lg:col-span-3",children:[!z&&e.jsx(An,{record:t,isLoading:Kt.isPending}),Gt&&e.jsxs("section",{className:x(p.card,"flex flex-col gap-3 p-5"),"data-testid":"pdp-rubric-section",children:[e.jsx(ar,{rubric:Gt}),e.jsx(sr,{rubric:Gt,reasoning:ji})]}),z&&e.jsxs("section",{className:x(p.card,"flex flex-col gap-3 p-5"),"data-testid":"sdp-rail-download",children:[e.jsx(pe,{children:s("skillSdp.downloadSkill")}),e.jsx("p",{className:p.small,children:s("skillSdp.downloadDesc")}),e.jsxs(h,{size:"lg",fullWidth:!0,onClick:()=>{bi()},"data-testid":"button-download-skill-sdp",children:[e.jsx(ia,{"aria-hidden":"true"}),e.jsx("span",{children:s("skillSdp.downloadButton")})]}),e.jsx(de,{status:M,anchor:"download","data-testid":"inline-status-download"}),Wa]}),!z&&e.jsxs("section",{className:x(p.card,"flex flex-col gap-3 p-5"),"data-testid":"sdp-rail-run-in",children:[e.jsx(pe,{children:s("privatePdp.runIn")}),e.jsx("p",{className:p.small,children:s("privatePdp.pasteInstruction",{shortcut:typeof navigator<"u"&&navigator.platform?.toLowerCase().includes("mac")?"â+V":"Ctrl+V"})}),(()=>{const a=new Set(["chatgpt","claude","gemini","perplexity","grok","xai-grok","metaai","meta","openai","x-model","sarvam","general","universal"]),r=t?.platformId;if(!r)return null;const w=r.toLowerCase().replace(/[-_\s]/g,"");if(!Array.from(a).some(G=>G.replace(/[-_\s]/g,"")===w)){const G=hn(r),re=Gi(r),ne={suno:"https://suno.com/create",claudecode:"https://claude.com/claude-code",codex:"https://openai.com/codex/",openaicodex:"https://openai.com/codex/",replit:"https://replit.com",replitai:"https://replit.com",replitagent:"https://replit.com",cursor:"https://cursor.com",emergent:"https://emergent.sh",coco:"https://www.snowflake.com/en/product/snowflake-coco/",cortexcode:"https://www.snowflake.com/en/product/snowflake-coco/",snowflakecoco:"https://www.snowflake.com/en/product/snowflake-coco/",base44:"https://base44.com",codingagent:"https://claude.com/claude-code"}[w]||re?.website||`https://${r.replace(/[-_]/g,"")}.com`;return e.jsxs("div",{className:"flex flex-col gap-2 border-b border-[var(--public-hairline)] pb-3","data-testid":"run-in-selected-platform",children:[e.jsx(pe,{children:s("privatePdp.optimizedFor")}),e.jsx(h,{fullWidth:!0,onClick:()=>Qt(G,ne),"data-testid":"button-run-in-selected-platform",children:e.jsx("span",{className:"truncate",children:G})})]})}return null})(),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",className:"justify-start",onClick:()=>Ue("chatgpt"),"data-testid":"button-llm-chatgpt",children:[e.jsx(Wr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:"ChatGPT"})]}),e.jsxs(h,{variant:"outline",size:"sm",className:"justify-start",onClick:()=>Ue("gemini"),"data-testid":"button-llm-gemini",children:[e.jsx(Qr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:"Gemini"})]}),e.jsxs(h,{variant:"outline",size:"sm",className:"justify-start",onClick:()=>Ue("perplexity"),"data-testid":"button-llm-perplexity",children:[e.jsx(Hr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:"Perplexity"})]}),e.jsxs(h,{variant:"outline",size:"sm",className:"justify-start",onClick:()=>Ue("claude"),"data-testid":"button-llm-claude",children:[e.jsx(Br,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:"Claude"})]}),e.jsxs(h,{variant:"outline",size:"sm",className:"justify-start",onClick:()=>Ue("grok"),"data-testid":"button-llm-grok",children:[e.jsx(Vr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:"Grok"})]}),e.jsxs(h,{variant:"outline",size:"sm",className:"justify-start",onClick:()=>Ue("metaai"),"data-testid":"button-llm-metaai",children:[e.jsx(Gr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:"Meta"})]}),e.jsxs(h,{variant:"outline",size:"sm",className:"justify-start",onClick:()=>Ue("sarvam"),"data-testid":"button-llm-sarvam",children:[e.jsx(Yr,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:"Sarvam"})]}),J?.name&&J?.url&&e.jsxs(h,{variant:"outline",size:"sm",className:"justify-start",onClick:()=>Qt(J.name,J.url),"data-testid":"button-llm-custom1",children:[e.jsx("span",{className:x(p.tile,"h-4 w-4 roun
26ded-[calc(var(--public-radius-control)/2)] font-mono text-[10px] font-semibold"),"aria-hidden":"true",children:J.name.charAt(0).toUpperCase()}),e.jsx("span",{className:"truncate",children:J.name})]}),_?.name&&_?.url&&e.jsxs(h,{variant:"outline",size:"sm",className:"justify-start",onClick:()=>Qt(_.name,_.url),"data-testid":"button-llm-custom2",children:[e.jsx("span",{className:x(p.tile,"h-4 w-4 rounded-[calc(var(--public-radius-control)/2)] font-mono text-[10px] font-semibold"),"aria-hidden":"true",children:_.name.charAt(0).toUpperCase()}),e.jsx("span",{className:"truncate",children:_.name})]})]}),e.jsx(de,{status:M,anchor:"run-in","data-testid":"inline-status-run-in"})]}),vi&&e.jsxs("section",{className:x(p.card,"flex flex-col gap-3 p-5"),"data-testid":"sdp-rail-actions",children:[e.jsx(pe,{children:s("privatePdp.quickActions")}),e.jsxs("div",{className:"flex flex-col gap-2",children:[Wa,q&&!K&&e.jsxs(h,{variant:"outline",fullWidth:!0,onClick:()=>g(!0),"data-testid":"button-action-collaborate",title:s("privatePdp.collaborate"),children:[e.jsx(ft,{"aria-hidden":"true"}),e.jsx("span",{children:s("privatePdp.collaborate")})]}),!Ye&&!K&&La&&e.jsxs(h,{variant:"outline",fullWidth:!0,onClick:()=>O(!0),"data-testid":"button-action-team",title:s("privatePdp.shareToTeam"),children:[e.jsx(ft,{"aria-hidden":"true"}),e.jsx("span",{children:s("privatePdp.teamLabel")})]}),q&&(Ms?e.jsxs("div",{className:"flex flex-col gap-2 border-t border-[var(--public-hairline)] pt-3",children:[e.jsx("span",{className:p.small,children:s("privatePdp.deleteThisPrompt")}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(h,{variant:"destructive",onClick:ni,disabled:Le,"data-testid":"button-confirm-delete",children:s(Le?"privatePdp.deleting":"privatePdp.yes")}),e.jsx(h,{variant:"outline",onClick:li,disabled:Le,autoFocus:!0,"data-testid":"button-cancel-delete",children:s("privatePdp.no")})]})]}):e.jsxs(h,{ref:Na,variant:"outline",fullWidth:!0,onClick:ri,disabled:Le,"data-testid":"button-action-delete",title:s("privatePdp.delete"),children:[e.jsx(fa,{"aria-hidden":"true"}),e.jsx("span",{children:s("privatePdp.delete")})]})),e.jsx(de,{status:M,anchor:"delete","data-testid":"inline-status-delete"})]})]}),j&&u&&e.jsx(il,{sourceSkillId:u,skills:Ca.data,loading:Ca.isLoading})]})]})}),t&&e.jsx(lr,{isOpen:At,onClose:()=>vt(!1),prompt:{id:t.id,title:t.title}}),t&&qa&&e.jsx(_r,{open:ae,onOpenChange:De,target:{kind:"skill",id:String(t.id)},title:et(t.title),description:t.description||void 0}),t&&e.jsx(Ln,{isOpen:bt,onClose:()=>g(!1),prompt:{id:t.id,title:t.title}}),t&&e.jsx(Mi,{isOpen:b,onClose:()=>O(!1),vaultItemId:t.id,promptTitle:t.title,promptContent:t.promptText||t.content,promptDescription:t.description,promptCategory:t.category,hasTeamsSubscription:Ia?.accessState?.hasTeamsAccess||!1}),t&&e.jsx(En,{isOpen:$s,onClose:()=>Ee(!1),onSave:ei,promptText:Xs,promptId:t.id,versionsApiPath:C?`/api/squads/vault-item/${t.id}/versions`:void 0,isSaving:Fa.isPending,saveError:M?.anchor==="editor"?M.message:null}),A&&e.jsx(Zi,{mode:Z,onClose:fe,onModeChange:ge}),e.jsx(er,{})]})}export{tc as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.