import{d as z,i as P,a as S,V as W,X as D,r as h,o as s,f as _,g as r,t as I,x as V,z as y,y as F,A as N,W as O,$ as M,ax as R,_ as E,ap as j,c as w,w as $,b as p,aw as q,a1 as K,S as g,bB as A,D as C,E as T,a3 as Q}from"./index-dyx4v2bZ.js";import{u as U}from"./BuilderApp-DQFSeMDQ.js";import"./WdsCheckbox-CjK48piR.js";import"./marked.esm-273vDTCT.js";const X={class:"BuilderBlueprintLibraryItem"},G={class:"BuilderBlueprintLibraryItem__header"},H={class:"BuilderBlueprintLibraryItem__title"},J={class:"BuilderBlueprintLibraryItem__description"},Y={class:"BuilderBlueprintLibraryItem__actions"},Z=z({__name:"BuilderBlueprintLibraryItem",props:{block:{}},emits:["installed"],setup(L,{emit:B}){const o=L,b=B,v=P(S.core),m=P(S.builderManager),{pushToast:i}=W(),{writerApi:u}=D(),{installSharedBlueprint:c}=R(v,m),d=h(!1);async function f(){const n=v.writerOrgId.value;if(!n){i({type:"error",message:"Organization ID is required. Please set up your environment variable."});return}d.value=!0;try{const l=await u.getSharedBlueprint(n,o.block.id),k=l.components,a=c({id:l.id,title:l.title,description:l.description||void 0,components:k}),e=v.writerAppId.value;e&&u.trackBlueprintInstallation(n,o.block.id,e).catch(M().error),i({type:"success",message:`Blueprint "${o.block.title}" installed successfully`}),b("installed")}catch(l){i({type:"error",message:`Failed to install blueprint: ${l instanceof Error?l.message:String(l)}`})}finally{d.value=!1}}return(n,l)=>(s(),_("div",X,[r("div",G,[r("h3",H,I(n.block.title),1)]),r("p",J,I(n.block.description),1),r("div",Y,[V(O,{variant:"primary",size:"small",disabled:d.value,onClick:f},{default:y(()=>[V(F,{name:"download"}),N(" "+I(d.value?"Installing...":"Install"),1)]),_:1},8,["disabled"])])]))}}),x=E(Z,[["__scopeId","data-v-6bf01558"]]),ee={class:"BuilderBlueprintLibraryPanel"},te={class:"BuilderBlueprintLibraryPanel__header"},re={class:"BuilderBlueprintLibraryPanel__search"},se={class:"BuilderBlueprintLibraryPanel__content"},le={key:1,class:"BuilderBlueprintLibraryPanel__empty"},ae={key:0,class:"BuilderBlueprintLibraryPanel__empty__hint"},ie={key:2,class:"BuilderBlueprintLibraryPanel__sections"},ne={class:"BuilderBlueprintLibraryPanel__grid"},oe={class:"BuilderBlueprintLibraryPanel__grid"},ue=z({__name:"BuilderBlueprintLibraryPanel",props:{modelValue:{type:Boolean},modelModifiers:{}},emits:["update:modelValue"],setup(L){const B=j(L,"modelValue"),o=P(S.core),{pushToast:b}=W(),{writerApi:v}=D(),m=w(()=>Array.isArray(o.featureFlags.value)&&o.featureFlags.value.includes("blueprint_library")),i=h(""),u=h([]),c=h(!1),d=w(()=>u.value.filter(a=>a.isReadonly===!0)),f=w(()=>u.value.filter(a=>a.isReadonly!==!0));async function n(){if(!m.value)return;const a=o.writerOrgId.value;if(!a){b({type:"error",message:"Organization ID is required. Please set up your environment variable."}),c.value=!1;return}c.value=!0;try{const e=await v.listSharedBlueprints(a,i.value||void 0);u.value=e.map(t=>({id:t.id,title:t.title,description:t.description,category:t.category||"Shared Blueprints",isReadonly:!!t.isReadonly,createdBy:t.createdBy}))}catch(e){b({type:"error",message:`Failed to load blueprints: ${e instanceof Error?e.message:String(e)}`})}finally{c.value=!1}}const l=U(n,300);$(i,l);function k(){B.value=!1}return $(B,a=>{a&&m.value&&n()}),(a,e)=>B.value&&m.value?(s(),p(Q,{key:0,title:"Blueprint Library",size:"wide","display-close-button":"",onClose:k},{default:y(()=>[r("div",ee,[r("div",te,[r("div",re,[V(q,{modelValue:i.value,"onUpdate:modelValue":e[0]||(e[0]=t=>i.value=t),placeholder:"Search blueprints...","left-icon":"search"},null,8,["modelValue"])])]),r("div",se,[c.value?(s(),p(K,{key:0,class:"BuilderBlueprintLibraryPanel__loading"})):u.value.length===0?(s(),_("div",le,[e[1]||(e[1]=r("p",null,"No blueprints found",-1)),i.value?(s(),_("p",ae," Try adjusting your search ")):g("",!0)])):(s(),_("div",ie,[d.value.length>0?(s(),p(A,{key:0,class:"BuilderBlueprintLibraryPanel__section",open:!0,icons:{open:"chevron-down",close:"chevron-right"}},{title:y(()=>e[2]||(e[2]=[r("span",{class:"BuilderBlueprintLibraryPanel__sectionTitle"}," Agents for everyone ",-1)])),content:y(()=>[r("div",ne,[(s(!0),_(C,null,T(d.value,t=>(s(),p(x,{key:t.id,block:t},null,8,["block"]))),128))])]),_:1})):g("",!0),f.value.length>0?(s(),p(A,{key:1,class:"BuilderBlueprintLibraryPanel__section",open:!0,icons:{open:"chevron-down",close:"chevron-right"}},{title:y(()=>e[3]||(e[3]=[r("span",{class:"BuilderBlueprintLibraryPanel__sectionTitle"}," Agents for your organization ",-1)])),content:y(()=>[r("div",oe,[(s(!0),_(C,null,T(f.value,t=>(s(),p(x,{key:t.id,block:t},null,8,["block"]))),128))])]),_:1})):g("",!0)]))])])]),_:1})):g("",!0)}}),ye=E(ue,[["__scopeId","data-v-04347713"]]);export{ye as default};
