import{I as E}from"./IdnodeGrid-U6EqXqja.js";import{I as V}from"./IdnodeConfigForm-BL6DOswR.js";import{d as R,u as T,c as B,a as M,o as v,e as b,f as n,g as C,P as z,t as L,h as c,I as F,r as u,k as _,L as G,_ as U}from"./index-D92x6h1h.js";import{M as $}from"./MasterDetailLayout-oilsSeUU.js";import{I as j}from"./IdnodePickClassDialog-CA1mKQhx.js";import{A as q}from"./ActionMenu-B3aKIJFu.js";import{b as H}from"./useMasterDetailActions-7f-vDWd7.js";import"./DataGrid-CbtTsx8d.js";import"./index-BG9mM10J.js";import"./index-7HNOjfAo.js";import"./localDay-CoEbUe3O.js";import"./SearchInput-DBHWpJgW.js";import"./useGridLayout-DCIiMD42.js";import"./CollapsibleSection.vue_vue_type_style_index_0_lang-Cq2AVc9p.js";import"./sliders-horizontal-Am8f4Xsv.js";import"./useStaleDataRecovery-BuNK-94T.js";const J={class:"codec-profiles"},K={key:1,class:"codec-profiles__empty"},O=R({__name:"CodecProfilesView",setup(Q){const{t:o}=T(),p=B(),g=M(),a=u(null),f=H({selected:a,confirmText:o("Do you really want to delete this codec profile?")}),r=u(!1),s=u(!1),l=u(null);function k(){r.value=!0}async function h(){if(!(!a.value||s.value)){s.value=!0;try{const i=(await G("idnode/load",{uuid:a.value})).entries?.[0]?.params??[],e={};for(const y of i)e[y.id]=y.value;const d=typeof e.codec_name=="string"?e.codec_name:"";if(!d){p.error(o("Source codec profile has no codec_name."),{summary:o("Clone failed")});return}delete e.uuid;const m=e.name;e.name=(typeof m=="string"&&m?m:"unnamed")+" (copy)",l.value={codecName:d,preselect:e}}catch(t){p.error(t instanceof Error?t.message:String(t),{summary:o("Clone failed")})}finally{s.value=!1}}}function w(t){r.value=!1,l.value={codecName:t,preselect:null}}function I(){l.value=null}function A(){l.value=null,p.success(o("Codec profile saved."))}const S=_(()=>[{id:"add",label:o("Add"),onClick:k},{id:"clone",label:s.value?o("Cloning…"):o("Clone"),disabled:!a.value||s.value,onClick:h},{id:"delete",label:f.inflight.value?o("Deleting…"):o("Delete"),disabled:!a.value||f.inflight.value,onClick:f.run}]),P=[{field:"title",label:o("Name"),sortable:!0,filterType:"string",width:280,minVisible:"phone",phoneRole:"primary"}];function D(t,i){const e=t.uuid;i(typeof e=="string"?e:null)}const N=_(()=>l.value?{classEndpoint:"codec_profile/class",createEndpoint:"codec_profile/create",params:{class:l.value.codecName}}:null),x=_(()=>{if(l.value)return l.value.preselect?o("Clone Codec Profile"):o("Add Codec Profile")});return(t,i)=>(v(),b("div",J,[n($,{"selected-uuid":a.value,"onUpdate:selectedUuid":i[0]||(i[0]=e=>a.value=e),"storage-key":"config-codec-profiles","default-detail-fraction":35},{master:C(({select:e})=>[n(E,{endpoint:"codec_profile/list","help-page":"class/codec_profile","entity-class":"codec_profile",columns:P,"store-key":"config-stream-codec-profiles","default-sort":{key:"title",dir:"ASC"},"virtual-scroller-options":{itemSize:36,lazy:!1},"count-label":c(o)("codec profiles"),"client-side-filter":"",selectable:"single",class:"codec-profiles__grid",onRowClick:d=>D(d,e)},{toolbarActions:C(()=>[n(q,{actions:S.value},null,8,["actions"])]),_:1},8,["count-label","onRowClick"])]),detail:C(({selectedUuid:e})=>[e?(v(),z(V,{key:0,uuid:e},null,8,["uuid"])):(v(),b("p",K,L(c(o)("Select a codec profile on the left to view and edit its configuration.")),1))]),_:1},8,["selected-uuid"]),n(j,{visible:r.value,"builders-endpoint":"codec/list",title:c(o)("Add Codec Profile"),label:c(o)("Codec"),onPick:w,onClose:i[1]||(i[1]=e=>r.value=!1)},null,8,["visible","title","label"]),n(F,{uuid:null,level:c(g).uilevel,"create-base":l.value?"codec_profile":null,"parent-scoped":N.value,preselect:l.value?.preselect??null,title:x.value,onClose:I,onSaved:A},null,8,["level","create-base","parent-scoped","preselect","title"])]))}}),pe=U(O,[["__scopeId","data-v-b61d142b"]]);export{pe as default};
