Files
dockerStuff/config/tandoor/staticfiles/vue3/assets/RecipeViewPage-CDj_dH5L.a6056ace9b7c.js
2025-11-16 21:46:46 +00:00

3 lines
32 KiB
JavaScript

import{d as P,r as C,c as E,h as f,w as t,g as e,i as p,j as V,t as s,b,e as _,k as L,V as T,b1 as me,l as k,L as U,z as R,F as D,p as N,f as n,M as A,o as z,A as H,O as F,ae as Ce,af as Re,aY as Ue,aP as ve,N as M,x as Y,Q as x,R as B,y as q,C as De,E as Ee,_ as X,W as Ie,D as I,av as Pe,I as Le,b8 as fe,a7 as Fe,b9 as ce,n as j,P as Me,aX as Ne,bw as Oe,u as qe,b7 as xe,ab as Be,bx as ze,ba as ge,aa as He,aL as _e,aH as Z,a9 as je,G as ye,aj as We,aN as Ve,aO as $e,ai as J,by as ee,aT as Je,aM as be,bz as Ge,bA as Ke,b6 as te,br as le,K as ke,ag as Qe,S as Xe,a as Ye,bB as Ze}from"./main-BhFWIRV_.js";import{_ as ae}from"./NumberScalerDialog.vue_vue_type_script_setup_true_lang-BKqLc88N.js";import{_ as G}from"./IngredientsTable.vue_vue_type_script_setup_true_lang-ClY6kQB1.js";import{V as we,a as he,c as Te,b as Se,d as et,r as ne}from"./number_utils-1sJWKMUK.js";import{V as tt}from"./VTextarea-Dyu7dPGe.js";import{V as K}from"./VRating-BGFrV4il.js";import{V as lt}from"./VListItemAction-BR9wagZD.js";import{V as at}from"./VTooltip-CP00KBBq.js";import{_ as re,a as se}from"./PrivateRecipeBadge.vue_vue_type_script_setup_true_lang-CuYHMwhT.js";import{_ as oe}from"./KeywordsBar.vue_vue_type_script_setup_true_lang-9vWdzSaj.js";import{u as nt}from"./useFileApi-4KcBp6Fj.js";import{V as O}from"./AddToShoppingDialog.vue_vue_type_script_setup_true_lang-ByrmCw9F.js";import{_ as rt}from"./logo_color-BwefLr6I.js";import{a as st,V as ue,b as ot,c as ie}from"./VTabs-BQFRhgOd.js";import"./model_utils-CVQgSPL_.js";import"./BtnCopy.vue_vue_type_script_setup_true_lang-B_1A58TG.js";const ut={key:0},it=P({__name:"StepsOverview",props:{steps:{type:Array,default:[]},ingredientFactor:{type:Number,required:!0}},setup(w){const i=w;C(!1);const c=E(()=>{const $=(()=>{const u=[];return i.steps.forEach(o=>{o.ingredients.forEach(d=>{d.food&&!d.isHeader&&u.push(d)}),o.stepRecipeData&&o.stepRecipeData.steps?.forEach(d=>{d.ingredients.forEach(m=>{m.food&&!m.isHeader&&u.push(m)})})}),u})(),v=new Map;return $.forEach(u=>{if(!u.food)return;const o=`${u.food.id}-${u.unit?u.unit.id:"no_unit"}`;if(v.has(o)){const d=v.get(o);d.amount+=u.amount}else{const d={...u};v.set(o,d)}}),Array.from(v.values()).sort((u,o)=>{const d=u.food?.name.toLowerCase()||"",m=o.food?.name.toLowerCase()||"";return d.localeCompare(m)})});return(y,$)=>(n(),f(we,null,{default:t(()=>[e(he,null,{default:t(()=>[e(Te,null,{default:t(()=>[$[2]||($[2]=p("i",{class:"far fa-list-alt fa-fw me-2"},null,-1)),V(" "+s(y.$t("StepsOverview")),1)]),_:1,__:[2]}),e(Se,null,{default:t(()=>[e(L,null,{default:t(()=>[e(T,null,{default:t(()=>[e(me,{density:"compact",modelValue:k(U)().deviceSettings.recipe_mergeStepOverview,"onUpdate:modelValue":$[0]||($[0]=v=>k(U)().deviceSettings.recipe_mergeStepOverview=v),border:"",divided:""},{default:t(()=>[e(R,{value:!1,"prepend-icon":"fa-solid fa-folder-tree"},{default:t(()=>[V(s(y.$t("Structured")),1)]),_:1}),e(R,{value:!0,"prepend-icon":"fa-solid fa-arrows-to-circle"},{default:t(()=>[V(s(y.$t("Summary")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1}),k(U)().deviceSettings.recipe_mergeStepOverview?_("",!0):(n(!0),b(D,{key:0},N(i.steps,(v,l)=>(n(),f(L,null,{default:t(()=>[e(T,{class:"pa-1",cols:"12",md:"6"},{default:t(()=>[v.showAsHeader?(n(),b("b",ut,s(l+1)+". "+s(v.name),1)):_("",!0),e(G,{modelValue:v.ingredients,"onUpdate:modelValue":u=>v.ingredients=u,"ingredient-factor":i.ingredientFactor},null,8,["modelValue","onUpdate:modelValue","ingredient-factor"]),v.stepRecipe?(n(),f(A,{key:1,class:"ma-2 border-md","prepend-icon":"$recipes",title:v.stepRecipeData.name,to:{name:"RecipeViewPage",params:{id:v.stepRecipeData.id}},target:"_blank"},{default:t(()=>[(n(!0),b(D,null,N(v.stepRecipeData.steps,u=>(n(),f(L,null,{default:t(()=>[e(T,null,{default:t(()=>[e(G,{modelValue:u.ingredients,"onUpdate:modelValue":o=>u.ingredients=o,"ingredient-factor":i.ingredientFactor},null,8,["modelValue","onUpdate:modelValue","ingredient-factor"])]),_:2},1024)]),_:2},1024))),256))]),_:2},1032,["title","to"])):_("",!0)]),_:2},1024)]),_:2},1024))),256)),k(U)().deviceSettings.recipe_mergeStepOverview?(n(),f(L,{key:1},{default:t(()=>[e(T,{class:"pa-1",cols:"12",md:"6"},{default:t(()=>[e(G,{modelValue:c.value,"onUpdate:modelValue":$[1]||($[1]=v=>c.value=v),"ingredient-factor":i.ingredientFactor,"show-checkbox":!1},null,8,["modelValue","ingredient-factor"])]),_:1})]),_:1})):_("",!0)]),_:1})]),_:1})]),_:1}))}}),dt={key:0},pt={key:1},mt={key:2},vt=P({__name:"RecipeActivity",props:{recipe:{type:Object,required:!0}},setup(w){const i=w,c=C({}),y=C([]),$=C(!1);z(()=>{v(i.recipe.id),l()});function v(o,d=1){const m=new H;$.value=!0,d==1&&(y.value=[]),m.apiCookLogList({recipe:i.recipe.id,page:d}).then(S=>{S.results&&(y.value=y.value.concat(S.results),S.next?v(o,d+1):(y.value=y.value.sort((g,r)=>g.createdAt>r.createdAt?1:-1),$.value=!1))})}function l(){c.value={},c.value.servings=i.recipe.servings,c.value.createdAt=new Date,c.value.recipe=i.recipe.id}function u(){new H().apiCookLogCreate({cookLog:c.value}).then(d=>{y.value.push(d),l()}).catch(d=>{x().addError(B.CREATE_ERROR,d)})}return(o,d)=>(n(),b(D,null,[k(U)().isAuthenticated?(n(),f(A,{key:0,class:"mt-1 d-print-none",loading:$.value},{default:t(()=>[e(F,null,{default:t(()=>[e(tt,{label:o.$t("Comment"),rows:"2",modelValue:c.value.comment,"onUpdate:modelValue":d[0]||(d[0]=m=>c.value.comment=m),"auto-grow":""},null,8,["label","modelValue"]),e(L,{dense:""},{default:t(()=>[e(T,{cols:"12",md:"4"},{default:t(()=>[e(Ce,null,{default:t(()=>[V(s(o.$t("Rating")),1)]),_:1}),d[7]||(d[7]=p("br",null,null,-1)),e(K,{modelValue:c.value.rating,"onUpdate:modelValue":d[1]||(d[1]=m=>c.value.rating=m),clearable:"",hover:"",density:"compact"},null,8,["modelValue"])]),_:1,__:[7]}),e(T,{cols:"12",md:"4"},{default:t(()=>[e(Re,{label:o.$t("Servings"),modelValue:c.value.servings,"onUpdate:modelValue":d[2]||(d[2]=m=>c.value.servings=m),precision:2},null,8,["label","modelValue"])]),_:1}),e(T,{cols:"12",md:"4"},{default:t(()=>[e(k(Ue),{label:o.$t("Date"),modelValue:c.value.createdAt,"onUpdate:modelValue":d[3]||(d[3]=m=>c.value.createdAt=m)},null,8,["label","modelValue"])]),_:1})]),_:1})]),_:1}),e(ve,null,{default:t(()=>[e(R,{color:"create","prepend-icon":"$create",onClick:d[4]||(d[4]=m=>u())},{default:t(()=>[V(s(o.$t("Create")),1)]),_:1})]),_:1})]),_:1},8,["loading"])):_("",!0),y.value.length>0?(n(),f(A,{key:1,class:"mt-1",loading:$.value},{default:t(()=>[e(M,null,{default:t(()=>[V(s(o.$t("Activity")),1)]),_:1}),e(F,null,{default:t(()=>[e(Y,null,{default:t(()=>[(n(!0),b(D,null,N(y.value,m=>(n(),f(q,{class:"border-t-sm",key:m.id,link:m.createdBy.id==k(U)().userSettings?.user.id},{prepend:t(()=>[e(Le,{color:"primary"},{default:t(()=>[V(s(m.createdBy.displayName.charAt(0)),1)]),_:2},1024)]),append:t(()=>[e(lt,{class:"flex-column align-end"},{default:t(()=>[m.rating!=null?(n(),f(K,{key:0,density:"comfortable",size:"x-small",color:"tandoor",modelValue:m.rating,"onUpdate:modelValue":S=>m.rating=S,"half-increments":"",readonly:"",style:{overflow:"hidden"}},null,8,["modelValue","onUpdate:modelValue"])):_("",!0),e(Ie),m.createdAt!=null?(n(),f(at,{key:1,location:"top",text:k(I).fromJSDate(m.createdAt).toLocaleString(k(I).DATETIME_MED)},{activator:t(({props:S})=>[p("span",Pe({ref_for:!0},S),s(k(I).fromJSDate(m.createdAt).toRelative({style:"narrow"})),17)]),_:2},1032,["text"])):_("",!0)]),_:2},1024)]),default:t(()=>[e(De,{class:"font-weight-bold"},{default:t(()=>[V(s(m.createdBy.displayName),1)]),_:2},1024),p("span",null,s(m.comment),1),m.servings!=null&&m.servings>0?(n(),f(Ee,{key:0,class:"font-italic mt-1"},{default:t(()=>[V(s(m.servings)+" ",1),w.recipe.servingsText!=""?(n(),b("span",dt,s(w.recipe.servingsText),1)):m.servings==1?(n(),b("span",pt,s(o.$t("Serving")),1)):(n(),b("span",mt,s(o.$t("Servings")),1))]),_:2},1024)):_("",!0),m.createdBy.id==k(U)().userSettings?.user.id?(n(),f(X,{key:1,model:"CookLog",item:m,onSave:d[5]||(d[5]=S=>v(i.recipe.id)),onDelete:d[6]||(d[6]=S=>v(i.recipe.id))},null,8,["item"])):_("",!0)]),_:2},1032,["link"]))),128))]),_:1})]),_:1})]),_:1},8,["loading"])):_("",!0)],64))}}),ft=["src"],ct=P({__name:"ExternalRecipeViewer",props:{recipe:{type:{},required:!0}},setup(w){const i=w,c=fe("history"),{getDjangoUrl:y}=Fe(),$=C("");z(()=>{(!i.recipe.internal||i.recipe.steps.length==0)&&($.value="show")});const v=E(()=>{let o=i.recipe.filePath;return o?o.includes(".pdf"):!1}),l=E(()=>{let o=i.recipe.filePath;return o?o.includes(".png")||o.includes(".jpg")||o.includes(".jpeg")||o.includes(".gif"):!1}),u=E(()=>{let o="";return l.value?o=`${y("/api/get_recipe_file/")}${i.recipe.id}/`:v.value&&(o=`${y("/view-recipe-pdf/")}${i.recipe.id}/`),c.share&&typeof c.share=="string"&&(o+=`?share=${c.share}`),o});return(o,d)=>(n(),f(we,{modelValue:$.value,"onUpdate:modelValue":d[0]||(d[0]=m=>$.value=m)},{default:t(()=>[e(he,{value:"show"},{default:t(()=>[e(Te,null,{default:t(()=>[V(s(o.$t("ExternalRecipe")),1)]),_:1}),e(Se,null,{default:t(()=>[e(A,{class:"mt-1 h-100"},{default:t(()=>[v.value?(n(),b("iframe",{key:0,width:"100%",height:"700px",src:u.value},null,8,ft)):_("",!0),l.value?(n(),f(ce,{key:1,src:u.value},null,8,["src"])):_("",!0)]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]))}}),gt=["innerHTML"],de=P({__name:"ScalableNumber",props:{number:Number,factor:{type:Number,default:4}},setup(w){const i=w;function c(y){return et(y,i.factor,U().userSettings.useFractions)}return(y,$)=>(n(),b("span",{class:j(["step__scalable-num",[i.factor===1?"step__scalable-num_scaled_false":i.factor>1?"step__scalable-num_scaled_up":"step__scalable-num_scaled_down"]]),innerHTML:c(w.number)},null,10,gt))}}),_t=P({name:"Instructions",computed:{},components:{ScalableNumber:de},props:{instructions_html:{type:String,required:!0},ingredient_factor:{type:Number,required:!0}},data(){return{compiled_instructions:Oe(P({name:"compiled-instructions-component",props:{instructions_html:{type:String,required:!0},ingredient_factor:{type:Number,required:!0}},components:{ScalableNumber:de},template:`
<div>${this.instructions_html}</div>`}))}},mounted(){}});function yt(w,i,c,y,$,v){return n(),f(Ne(w.compiled_instructions),{ingredient_factor:w.ingredient_factor,instructions_html:w.instructions_html},null,8,["ingredient_factor","instructions_html"])}const pe=Me(_t,[["render",yt]]),Vt=P({__name:"Timer",props:{seconds:{type:Number,required:!0}},emits:["stop"],setup(w,{emit:i}){const c=i,y=w,{t:$}=qe(),v=C(y.seconds),l=C(v.value),u=C(!0);let o=E(()=>l.value>0?"primary":"warning");const d=E(()=>v.value==0?100:(1-l.value/v.value)*100);z(()=>{setInterval(()=>{u.value&&l.value>0&&(l.value=l.value-1)},1e3)});function m(r){l.value=Math.max(0,l.value+r),v.value=Math.max(0,v.value+r)}function S(){l.value=y.seconds,v.value=y.seconds,c("stop")}function g(r){const a=I.now(),h=a.plus({seconds:r});let W=h.toLocaleString(I.TIME_SIMPLE);const Q=Math.floor(h.startOf("day").diff(a.startOf("day"),"days").days);if(Q>=1){const Ae=$(Q===1?"Day":"Days");W+=` +${Q} ${Ae}`}return W}return(r,a)=>(n(),b(D,null,[e(xe,{"model-value":d.value,color:"primary",height:"5"},null,8,["model-value"]),e(He,{color:k(o),class:"rounded-0",variant:"tonal"},{close:t(()=>[e(ge,{divided:""},{default:t(()=>[e(R,{width:"40",onClick:a[0]||(a[0]=h=>m(-60))},{default:t(()=>a[5]||(a[5]=[p("i",{class:"fas fa-minus"},null,-1),V("1")])),_:1,__:[5]}),e(R,{width:"40",onClick:a[1]||(a[1]=h=>m(60))},{default:t(()=>a[6]||(a[6]=[p("i",{class:"fas fa-plus"},null,-1),V("1")])),_:1,__:[6]}),e(R,{width:"40",onClick:a[2]||(a[2]=h=>u.value=!u.value)},{default:t(()=>[p("i",{class:j(["fas fa-fw",{"fa-pause":u.value,"fa-play":!u.value}])},null,2)]),_:1}),e(R,{width:"40",onClick:a[3]||(a[3]=h=>S())},{default:t(()=>a[7]||(a[7]=[p("i",{class:"fas fa-stop"},null,-1)])),_:1,__:[7]})]),_:1})]),default:t(()=>[e(Be,null,{default:t(()=>[a[4]||(a[4]=p("i",{class:"fas fa-stopwatch mr-1"},null,-1)),V(" "+s(k(ze).fromMillis(l.value*1e3).toFormat("hh:mm:ss")),1)]),_:1,__:[4]}),V(" "+s(r.$t("FinishedAt"))+" "+s(g(l.value))+" ",1)]),_:1},8,["color"])],64))}}),$t={key:0},bt={key:1},kt=["href"],wt=P({__name:"StepView",props:_e({stepNumber:{type:Number,required:!1,default:1},ingredientFactor:{type:Number,required:!0}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(w){const i=Z(w,"modelValue"),c=w,y=C(!1),$=C(!1),v=E(()=>i.value.ingredients.length>0||i.value.instruction!=null&&i.value.instruction.length>0||i.value.stepRecipeData!=null||i.value.file!=null);return(l,u)=>{const o=je("step-view",!0);return n(),f(A,null,{default:t(()=>[e(M,null,{default:t(()=>[e(L,null,{default:t(()=>[e(T,null,{default:t(()=>[i.value.name?(n(),b("span",$t,s(i.value.name),1)):(n(),b("span",bt,s(l.$t("Step"))+" "+s(c.stepNumber),1))]),_:1}),e(T,{class:"text-right"},{default:t(()=>[e(ge,{density:"compact",variant:"tonal",class:"d-print-none"},{default:t(()=>[i.value.time!=null&&i.value.time>0?(n(),f(R,{key:0,size:"small",color:"info",onClick:u[0]||(u[0]=d=>y.value=!0)},{default:t(()=>[u[4]||(u[4]=p("i",{class:"fas fa-stopwatch mr-1 fa-fw"},null,-1)),V(" "+s(i.value.time),1)]),_:1,__:[4]})):_("",!0),v.value?(n(),f(R,{key:1,size:"small",color:"success",onClick:u[1]||(u[1]=d=>$.value=!$.value)},{default:t(()=>[p("i",{class:j(["fas fa-fw",{"fa-check":!$.value,"fa-times":$.value}])},null,2)]),_:1})):_("",!0)]),_:1})]),_:1})]),_:1})]),_:1}),$.value?_("",!0):(n(),b(D,{key:0},[y.value?(n(),f(Vt,{key:0,seconds:i.value.time!=null?i.value.time*60:0,onStop:u[2]||(u[2]=d=>y.value=!1)},null,8,["seconds"])):_("",!0),i.value.ingredients.length>0||i.value.instruction!=""?(n(),f(F,{key:1},{default:t(()=>[e(L,null,{default:t(()=>[i.value.ingredients.length>0&&(i.value.showIngredientsTable||i.value.show_ingredients_table)?(n(),f(T,{key:0,cols:"12",md:"6"},{default:t(()=>[e(G,{modelValue:i.value.ingredients,"onUpdate:modelValue":u[3]||(u[3]=d=>i.value.ingredients=d),"ingredient-factor":w.ingredientFactor},null,8,["modelValue","ingredient-factor"])]),_:1})):_("",!0),e(T,{cols:"12",md:"6",class:"markdown-body"},{default:t(()=>[i.value.instructionsMarkdown!=null?(n(),f(pe,{key:0,instructions_html:i.value.instructionsMarkdown,ingredient_factor:w.ingredientFactor},null,8,["instructions_html","ingredient_factor"])):(n(),f(pe,{key:1,instructions_html:i.value.instructions_markdown,ingredient_factor:w.ingredientFactor},null,8,["instructions_html","ingredient_factor"]))]),_:1})]),_:1})]),_:1})):_("",!0),i.value.stepRecipe?(n(),f(A,{key:2,class:"ma-2 border-md"},{default:t(()=>[e(M,null,{default:t(()=>[e(ye,{icon:"$recipes"}),V(" "+s(i.value.stepRecipeData.name)+" ",1),e(R,{icon:"fa-solid fa-up-right-from-square",size:"x-small",to:{name:"RecipeViewPage",params:{id:i.value.stepRecipeData.id}},target:"_blank",variant:"plain"},null,8,["to"])]),_:1}),(n(!0),b(D,null,N(i.value.stepRecipeData.steps,(d,m)=>(n(),f(F,{class:"mt-1",key:d.id},{default:t(()=>[e(o,{modelValue:i.value.stepRecipeData.steps[m],"onUpdate:modelValue":S=>i.value.stepRecipeData.steps[m]=S,"step-number":m+1,ingredientFactor:w.ingredientFactor},null,8,["modelValue","onUpdate:modelValue","step-number","ingredientFactor"])]),_:2},1024))),128))]),_:1})):_("",!0),i.value.file?(n(),b(D,{key:3},[i.value.file.preview?(n(),f(ce,{key:0,src:i.value.file.preview},null,8,["src"])):(n(),b("a",{key:1,href:i.value.file.fileDownload},s(l.$t("Download")),9,kt))],64)):_("",!0)],64))]),_:1})}}}),ht={key:0},Tt={key:0},St={class:"ms-2"},At=P({__name:"PropertyView",props:_e({servings:{type:Number,required:!0}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(w){const i=w,c=Z(w,"modelValue"),y=E(()=>c.value.properties!=null&&c.value.properties.length>0),$=E(()=>{let g=!1;for(const[r,a]of Object.entries(c.value.foodProperties))a.total_value!==0&&(console.log(a,a.total_value),g=!0);return g}),v=E(()=>{let g=[];if(l.value=="recipe")y.value&&c.value.properties.forEach(a=>{g.push({id:a.propertyType.id,name:a.propertyType.name,description:a.propertyType.description,foodValues:[],propertyAmountPerServing:a.propertyAmount,propertyAmountTotal:a.propertyAmount*c.value.servings*(i.servings/c.value.servings),missingValue:!1,unit:a.propertyType.unit,type:a.propertyType})});else for(const[a,h]of Object.entries(c.value.foodProperties))g.push({id:h.id,name:h.name,description:h.description,icon:h.icon,foodValues:h.food_values,propertyAmountPerServing:h.total_value/c.value.servings,propertyAmountTotal:h.total_value*(i.servings/c.value.servings),missingValue:h.missing_value,unit:h.unit,type:h});function r(a,h){return a.type.order>h.type.order?1:a.type.order<h.type.order?-1:0}return g.sort(r)}),l=C("food"),u=C(!1),o=C(void 0),d=C(!1);z(()=>{$.value||(l.value="recipe")});function m(){let g=new H;d.value=!0,g.apiRecipeRetrieve({id:c.value.id}).then(r=>{c.value=r,Je(()=>{o.value!=null&&u.value&&v.value.forEach(a=>{o.value.id==a.id&&(o.value=a)}),d.value=!1})}).catch(r=>{x().addError(B.FETCH_ERROR,r)})}function S(g){return g>80?"error":g>50?"warning":g>30?"info":"success"}return(g,r)=>(n(),b(D,null,[$.value||y.value?(n(),f(A,{key:0,class:"mt-2"},{default:t(()=>[e(M,null,{default:t(()=>[e(ye,{icon:"$properties"}),V(" "+s(g.$t("Properties"))+" ",1),y.value&&y.value?(n(),f(me,{key:0,border:"",divided:"",density:"compact",class:"float-right d-print-none",modelValue:l.value,"onUpdate:modelValue":r[0]||(r[0]=a=>l.value=a)},{default:t(()=>[e(R,{size:"small",value:"food"},{default:t(()=>[V(s(g.$t("Food")),1)]),_:1}),e(R,{size:"small",value:"recipe"},{default:t(()=>[V(s(g.$t("Recipe")),1)]),_:1})]),_:1},8,["modelValue"])):_("",!0)]),_:1}),e(F,null,{default:t(()=>[e(We,{density:"compact",style:{"max-width":"800px"}},{default:t(()=>[p("thead",null,[p("tr",null,[r[5]||(r[5]=p("th",null,null,-1)),p("th",null,s(g.$t("per_serving")),1),p("th",null,s(g.$t("total")),1),l.value=="food"?(n(),b("th",ht)):_("",!0)])]),p("tbody",null,[(n(!0),b(D,null,N(v.value,a=>(n(),b("tr",{key:a.id},[p("td",null,s(a.name),1),p("td",null,s(g.$n(k(ne)(a.propertyAmountPerServing)))+" "+s(a.unit),1),p("td",null,s(g.$n(k(ne)(a.propertyAmountTotal)))+" "+s(a.unit),1),l.value=="food"?(n(),b("td",Tt,[a.missingValue?(n(),f(R,{key:0,onClick:h=>{o.value=a,u.value=!0},variant:"plain",color:"warning",icon:"fa-solid fa-triangle-exclamation",size:"small",class:"d-print-none"},null,8,["onClick"])):_("",!0),a.missingValue?_("",!0):(n(),f(R,{key:1,onClick:h=>{o.value=a,u.value=!0},variant:"plain",icon:"fa-solid fa-circle-info",size:"small",class:"d-print-none"},null,8,["onClick"]))])):_("",!0)]))),128))])]),_:1})]),_:1})]),_:1})):_("",!0),e(Ve,{"max-width":"900px",modelValue:u.value,"onUpdate:modelValue":r[4]||(r[4]=a=>u.value=a)},{default:t(()=>[o.value?(n(),f(A,{key:0,loading:d.value},{default:t(()=>[e($e,{title:`${o.value.propertyAmountTotal} ${o.value.unit} ${o.value.name}`,"sub-title":g.$t("total"),icon:"$properties",modelValue:u.value,"onUpdate:modelValue":r[1]||(r[1]=a=>u.value=a)},null,8,["title","sub-title","modelValue"]),e(F,null,{default:t(()=>[e(Y,null,{default:t(()=>[(n(!0),b(D,null,N(o.value.foodValues,a=>(n(),f(q,{border:"",key:`${o.value.id}_${a.id}`},{prepend:t(()=>[a.value!=null&&o.value.propertyAmountTotal>0?(n(),f(ee,{key:0,size:"55",width:"5","model-value":a.value/o.value.propertyAmountTotal*100,color:S(a.value/o.value.propertyAmountTotal*100)},{default:t(()=>[V(s(Math.round(a.value/o.value.propertyAmountTotal*100))+"% ",1)]),_:2},1032,["model-value","color"])):_("",!0),a.value==null?(n(),f(ee,{key:1,size:"55",width:"5"},{default:t(()=>r[6]||(r[6]=[V("?")])),_:1,__:[6]})):_("",!0)]),append:t(()=>[a.missing_conversion?(n(),f(J,{key:0,color:"create",class:"cursor-pointer","prepend-icon":"$create"},{default:t(()=>[V(s(g.$t("Conversion"))+": "+s(a.missing_conversion.base_unit.name)+" ",1),r[7]||(r[7]=p("i",{class:"fa-solid fa-arrow-right me-1 ms-1"},null,-1)),V(" "+s(a.missing_conversion.converted_unit.name)+" ",1),e(X,{model:"UnitConversion",onCreate:r[2]||(r[2]=h=>m()),"item-defaults":{baseAmount:1,baseUnit:a.missing_conversion.base_unit,convertedUnit:a.missing_conversion.converted_unit,food:a.food}},null,8,["item-defaults"])]),_:2,__:[7]},1024)):a.value!=null?(n(),f(J,{key:1},{default:t(()=>[V(s(g.$n(a.value))+" "+s(o.value.unit),1)]),_:2},1024)):a.missing_unit?(n(),f(J,{key:2,color:"warning","prepend-icon":"$edit",class:"cursor-pointer",to:{name:"ModelEditPage",params:{model:"Recipe",id:c.value.id}}},{default:t(()=>[V(s(g.$t("NoUnit")),1)]),_:1},8,["to"])):(n(),f(J,{key:3,color:"error","prepend-icon":"$edit",class:"cursor-pointer"},{default:t(()=>[V(s(g.$t("MissingProperties"))+" ",1),e(X,{model:"Food","item-id":a.food.id,"onUpdate:modelValue":r[3]||(r[3]=h=>m())},null,8,["item-id"])]),_:2},1024))]),default:t(()=>[p("span",St,s(a.food.name),1)]),_:2},1024))),128))]),_:1})]),_:1}),e(ve,null,{default:t(()=>[e(R,{to:{name:"PropertyEditorPage",query:{recipe:c.value.id}}},{default:t(()=>[V(s(g.$t("Property_Editor")),1)]),_:1},8,["to"])]),_:1})]),_:1},8,["loading"])):_("",!0)]),_:1},8,["modelValue"])],64))}}),Ct={class:"d-block d-lg-none"},Rt={class:"text-grey"},Ut={class:"text-grey"},Dt={class:"cursor-pointer"},Et={class:"text-grey"},It={key:0},Pt={key:1},Lt={class:"d-none d-lg-block"},Ft={class:"d-flex"},Mt={class:"flex-column flex-grow-1"},Nt={class:"text-grey"},Ot={class:"text-grey"},qt={class:"cursor-pointer"},xt={class:"text-grey"},Bt={key:0},zt={key:1},Ht=["href"],jt=P({__name:"RecipeView",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(w){const{request:i,release:c}=Ge(),{doAiImport:y,fileApiLoading:$}=nt(),v=C(!1),l=Z(w,"modelValue"),u=C(1),o=C(!1),d=C(U().activeSpace.aiDefaultProvider),m=E(()=>u.value/(l.value.servings!=null?Math.max(l.value.servings,1):1));be(()=>l.value.servings,()=>{l.value.servings&&(u.value=l.value.servings)}),z(()=>{i("screen")}),Ke(()=>{c()});function S(){let g=new H;y(d.value.id,null,"",l.value.id).then(r=>{r.recipe?(l.value.internal=!0,l.value.steps=r.recipe.steps,l.value.keywords=r.recipe.keywords,l.value.servings=r.recipe.servings,l.value.servingsText=r.recipe.servingsText,l.value.workingTime=r.recipe.workingTime,l.value.waitingTime=r.recipe.waitingTime,u.value=r.recipe.servings,v.value=!0,g.apiRecipeUpdate({id:l.value.id,recipe:l.value}).then(a=>{l.value=a}).catch(a=>{x().addError(B.UPDATE_ERROR,a)}).finally(()=>{v.value=!1})):x().addError(B.UPDATE_ERROR,[r.error,r.msg])}).catch(r=>{x().addError(B.FETCH_ERROR,r)})}return(g,r)=>(n(),b(D,null,[l.value.name==null?(n(),b(D,{key:0},[e(O,{type:"card",class:"mt-md-4 rounded-0"}),e(O,{type:"article",class:"mt-2"}),e(O,{type:"article",class:"mt-2"}),e(O,{type:"list-item-avatar-three-line",class:"mt-2"}),e(O,{type:"list-item-avatar-two-line"}),e(O,{type:"list-item-avatar-three-line"})],64)):_("",!0),l.value.name!=null?(n(),b(D,{key:1},[p("template",Ct,[e(A,{class:"rounded-0"},{default:t(()=>[l.value.image!=null?(n(),f(te,{key:0,"max-height":"25vh",recipe:l.value},null,8,["recipe"])):_("",!0),e(A,null,{default:t(()=>[e(le,{class:"d-flex align-center"},{default:t(()=>[p("span",{class:j(["ps-2 text-h5 flex-grow-1 pa-1",{"text-truncate":!o.value}]),onClick:r[0]||(r[0]=a=>o.value=!o.value)},s(l.value.name),3),k(U)().isAuthenticated?(n(),f(re,{key:0,recipe:l.value},null,8,["recipe"])):_("",!0)]),_:1}),e(oe,{variant:"flat",class:"ms-1",keywords:l.value.keywords},null,8,["keywords"]),l.value._private?(n(),f(se,{key:0,users:l.value.shared},null,8,["users"])):_("",!0),l.value.rating?(n(),f(K,{key:1,modelValue:l.value.rating,"onUpdate:modelValue":r[1]||(r[1]=a=>l.value.rating=a),size:"x-small","half-increments":"",readonly:""},null,8,["modelValue"])):_("",!0),e(le,{class:"ps-2 text-disabled"},{default:t(()=>[V(s(l.value.description),1)]),_:1})]),_:1})]),_:1}),e(A,{class:"mt-1"},{default:t(()=>[e(ke,null,{default:t(()=>[e(L,{class:"text-center text-body-2"},{default:t(()=>[e(T,{class:"pt-1 pb-1"},{default:t(()=>[r[8]||(r[8]=p("i",{class:"fas fa-cogs fa-fw mr-1"},null,-1)),V(" "+s(l.value.workingTime)+" min",1),r[9]||(r[9]=p("br",null,null,-1)),p("div",Rt,s(g.$t("WorkingTime")),1)]),_:1,__:[8,9]}),e(T,{class:"pt-1 pb-1"},{default:t(()=>[p("div",null,[r[10]||(r[10]=p("i",{class:"fas fa-hourglass-half fa-fw mr-1"},null,-1)),V(" "+s(l.value.waitingTime)+" min",1)]),p("div",Ut,s(g.$t("WaitingTime")),1)]),_:1}),e(T,{class:"pt-1 pb-1"},{default:t(()=>[p("div",Dt,[r[11]||(r[11]=p("i",{class:"fas fa-sort-numeric-up fa-fw mr-1"},null,-1)),V(" "+s(u.value)+" ",1),r[12]||(r[12]=p("br",null,null,-1)),p("div",Et,[l.value.servingsText?(n(),b("span",It,s(l.value.servingsText),1)):(n(),b("span",Pt,s(g.$t("Servings")),1))]),e(ae,{number:u.value,onConfirm:r[2]||(r[2]=a=>{u.value=a}),title:"Servings"},null,8,["number"])])]),_:1})]),_:1})]),_:1})]),_:1})]),p("template",Lt,[e(L,{dense:""},{default:t(()=>[e(T,{cols:"8"},{default:t(()=>[e(te,{rounded:!0,"max-height":"40vh",recipe:l.value},null,8,["recipe"])]),_:1}),e(T,{cols:"4"},{default:t(()=>[e(A,{class:"h-100 d-flex flex-column"},{default:t(()=>[e(F,{class:"flex-grow-1"},{default:t(()=>[p("div",Ft,[p("h1",Mt,s(l.value.name),1),k(U)().isAuthenticated?(n(),f(re,{key:0,recipe:l.value,class:"flex-column mb-auto mt-2 float-right"},null,8,["recipe"])):_("",!0)]),p("p",null,s(g.$t("created_by"))+" "+s(l.value.createdBy.displayName)+" ("+s(k(I).fromJSDate(l.value.createdAt).toLocaleString(k(I).DATE_SHORT))+") ",1),p("p",null,[p("i",null,s(l.value.description),1)]),l.value._private?(n(),f(se,{key:0,users:l.value.shared},null,8,["users"])):_("",!0),l.value.rating?(n(),f(K,{key:1,modelValue:l.value.rating,"onUpdate:modelValue":r[3]||(r[3]=a=>l.value.rating=a),size:"x-small",readonly:""},null,8,["modelValue"])):_("",!0),e(oe,{variant:"flat",class:"mt-4",keywords:l.value.keywords},null,8,["keywords"])]),_:1}),e(L,{class:"text-center text-body-2 mb-1 flex-grow-0"},{default:t(()=>[e(T,null,{default:t(()=>[r[13]||(r[13]=p("i",{class:"fas fa-cogs fa-fw mr-1"},null,-1)),V(" "+s(l.value.workingTime)+" "+s(g.$t("min")),1),r[14]||(r[14]=p("br",null,null,-1)),p("div",Nt,s(g.$t("WorkingTime")),1)]),_:1,__:[13,14]}),e(T,null,{default:t(()=>[p("div",null,[r[15]||(r[15]=p("i",{class:"fas fa-hourglass-half fa-fw mr-1"},null,-1)),V(" "+s(l.value.waitingTime)+" "+s(g.$t("min")),1)]),p("div",Ot,s(g.$t("WaitingTime")),1)]),_:1}),e(T,null,{default:t(()=>[p("div",qt,[r[16]||(r[16]=p("i",{class:"fas fa-sort-numeric-up fa-fw mr-1"},null,-1)),V(" "+s(u.value)+" ",1),r[17]||(r[17]=p("br",null,null,-1)),p("div",xt,[l.value.servingsText?(n(),b("span",Bt,s(l.value.servingsText),1)):(n(),b("span",zt,s(g.$t("Servings")),1))]),e(ae,{number:u.value,onConfirm:r[4]||(r[4]=a=>{u.value=a}),title:"Servings"},null,8,["number"])])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),l.value.filePath?(n(),b(D,{key:0},[e(ct,{class:"mt-2",recipe:l.value},null,8,["recipe"]),l.value.internal?_("",!0):(n(),f(A,{key:0,title:g.$t("AI"),"prepend-icon":"$ai",loading:k($)||v.value,disabled:k($)||v.value||!k(U)().activeSpace.aiEnabled},{default:t(()=>[e(F,null,{default:t(()=>[V(s(g.$t("ConvertUsingAI"))+" ",1),e(Qe,{model:"AiProvider",modelValue:d.value,"onUpdate:modelValue":r[6]||(r[6]=a=>d.value=a)},{append:t(()=>[e(R,{onClick:r[5]||(r[5]=a=>S()),icon:"fa-solid fa-person-running",color:"success"})]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["title","loading","disabled"]))],64)):_("",!0),(l.value.steps.length>1||l.value.steps.length==1&&!l.value.steps[0].showIngredientsTable)&&l.value.showIngredientOverview?(n(),f(A,{key:1,class:"mt-1"},{default:t(()=>[e(it,{steps:l.value.steps,"ingredient-factor":m.value},null,8,["steps","ingredient-factor"])]),_:1})):_("",!0),(n(!0),b(D,null,N(l.value.steps,(a,h)=>(n(),f(A,{class:"mt-1",key:a.id},{default:t(()=>[e(wt,{modelValue:l.value.steps[h],"onUpdate:modelValue":W=>l.value.steps[h]=W,"step-number":h+1,ingredientFactor:m.value},null,8,["modelValue","onUpdate:modelValue","step-number","ingredientFactor"])]),_:2},1024))),128)),e(At,{modelValue:l.value,"onUpdate:modelValue":r[7]||(r[7]=a=>l.value=a),servings:u.value},null,8,["modelValue","servings"]),e(A,{class:"mt-2"},{default:t(()=>[e(F,null,{default:t(()=>[e(L,null,{default:t(()=>[e(T,{cols:"12",md:"3"},{default:t(()=>[e(A,{variant:"outlined",title:g.$t("CreatedBy"),subtitle:l.value.createdBy.displayName,"prepend-icon":"fa-solid fa-user",to:k(U)().isAuthenticated?{name:"SearchPage",query:{createdby:l.value.createdBy.id}}:void 0},null,8,["title","subtitle","to"])]),_:1}),e(T,{cols:"12",md:"3"},{default:t(()=>[e(A,{variant:"outlined",title:g.$t("Created"),subtitle:k(I).fromJSDate(l.value.createdAt).toLocaleString(k(I).DATETIME_MED),"prepend-icon":"$create",to:k(U)().isAuthenticated?{name:"SearchPage",query:{createdon:k(I).fromJSDate(l.value.createdAt).toISODate()}}:void 0},null,8,["title","subtitle","to"])]),_:1}),e(T,{cols:"12",md:"3"},{default:t(()=>[e(A,{variant:"outlined",title:g.$t("Updated"),subtitle:k(I).fromJSDate(l.value.updatedAt).toLocaleString(k(I).DATETIME_MED),"prepend-icon":"$edit",to:k(U)().isAuthenticated?{name:"SearchPage",query:{updatedon:k(I).fromJSDate(l.value.updatedAt).toISODate()}}:void 0},null,8,["title","subtitle","to"])]),_:1}),l.value.sourceUrl?(n(),f(T,{key:0,cols:"12",md:"3"},{default:t(()=>[e(A,{variant:"outlined",title:g.$t("Imported_From"),"prepend-icon":"$import"},{subtitle:t(()=>[p("a",{href:l.value.sourceUrl,target:"_blank"},s(l.value.sourceUrl),9,Ht)]),_:1},8,["title"])]),_:1})):_("",!0)]),_:1})]),_:1})]),_:1}),k(U)().userSettings.comments?(n(),f(vt,{key:2,recipe:l.value},null,8,["recipe"])):_("",!0)],64)):_("",!0)],64))}}),Wt={href:"https://tandoor.dev",target:"_blank"},Jt={href:"https://tandoor.dev",target:"_blank"},Gt=P({__name:"ImportTandoorDialog",setup(w){const i=E(()=>"https://app.tandoor.dev/recipe/import/?url="+location.href),c=E(()=>{let l=v.value;return l.endsWith("/")||(l+="/"),l+"recipe/import/?url="+location.href}),y=C(!1),$=C("hosted"),v=C("");return(l,u)=>(n(),b(D,null,[e(A,{class:"ml-auto mr-auto","max-width":"300px","prepend-avatar":rt,title:l.$t("ImportIntoTandoor"),onClick:u[0]||(u[0]=o=>y.value=!0)},null,8,["title"]),e(Ve,{"max-width":"800px",modelValue:y.value,"onUpdate:modelValue":u[5]||(u[5]=o=>y.value=o)},{default:t(()=>[e(A,null,{default:t(()=>[e($e,{title:l.$t("ImportIntoTandoor"),modelValue:y.value,"onUpdate:modelValue":u[1]||(u[1]=o=>y.value=o)},null,8,["title","modelValue"]),e(st,{grow:"",modelValue:$.value,"onUpdate:modelValue":u[2]||(u[2]=o=>$.value=o)},{default:t(()=>[e(ue,{value:"hosted"},{default:t(()=>u[6]||(u[6]=[V("tandoor.dev")])),_:1,__:[6]}),e(ue,{value:"selfhosted"},{default:t(()=>[V(s(l.$t("SelfHosted")),1)]),_:1})]),_:1},8,["modelValue"]),e(F,null,{default:t(()=>[e(ot,{modelValue:$.value,"onUpdate:modelValue":u[4]||(u[4]=o=>$.value=o)},{default:t(()=>[e(ie,{value:"hosted"},{default:t(()=>[p("p",null,[V(s(l.$t("AboutTandoor"))+" ",1),p("a",Wt,s(l.$t("Learn_More"))+".",1)]),p("p",null,s(l.$t("ImportIntoTandoorHelp")),1),e(Y,null,{default:t(()=>[e(q,{border:""},{append:t(()=>[e(R,{icon:"fa-solid fa-arrow-up-right-from-square",href:"https://app.tandoor.dev",target:"_blank"})]),default:t(()=>[e(M,null,{default:t(()=>[V("1. "+s(l.$t("CreateAccount")),1)]),_:1})]),_:1}),e(q,{border:""},{append:t(()=>[e(R,{icon:"fa-solid fa-paper-plane",href:i.value,target:"_blank"},null,8,["href"])]),default:t(()=>[e(M,null,{default:t(()=>[V("2. "+s(l.$t("Import")),1)]),_:1})]),_:1})]),_:1})]),_:1}),e(ie,{value:"selfhosted"},{default:t(()=>[p("p",null,[V(s(l.$t("AboutTandoor"))+" ",1),p("a",Jt,s(l.$t("Learn_More"))+".",1)]),p("p",null,s(l.$t("ImportIntoTandoorHelp")),1),e(q,{border:""},{default:t(()=>[e(M,null,{default:t(()=>[V("1. "+s(l.$t("URL")),1)]),_:1}),e(Xe,{modelValue:v.value,"onUpdate:modelValue":u[3]||(u[3]=o=>v.value=o),label:l.$t("Url")},null,8,["modelValue","label"])]),_:1}),e(q,{border:""},{append:t(()=>[e(R,{icon:"fa-solid fa-paper-plane",href:c.value,disabled:v.value=="",target:"_blank"},null,8,["href","disabled"])]),default:t(()=>[e(M,null,{default:t(()=>[V("2. "+s(l.$t("Import")),1)]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["modelValue"])],64))}}),Kt={key:0,class:"mt-2"},ml=P({__name:"RecipeViewPage",props:{id:{type:String,required:!0}},setup(w){const i=w,c=fe("history"),{mobile:y}=Ye(),$=Ze(),v=E(()=>c.share&&typeof c.share=="string"),l=C({});be(()=>i.id,()=>{u(i.id)}),z(()=>{u(i.id)});function u(o){const d=new H;l.value={};let m={id:i.id};v.value&&(m.share=c.share),d.apiRecipeRetrieve(m).then(S=>{l.value=S,$.value=l.value.name,U().isAuthenticated&&d.apiViewLogCreate({viewLog:{recipe:Number(o)}})}).catch(S=>{S.response.status==403||x().addError(B.FETCH_ERROR,S)})}return(o,d)=>(n(),f(ke,{class:j({"ps-0 pe-0 pt-0":k(y)})},{default:t(()=>[e(jt,{modelValue:l.value,"onUpdate:modelValue":d[0]||(d[0]=m=>l.value=m)},null,8,["modelValue"]),v.value&&Object.keys(l.value).length>0?(n(),b("div",Kt,[e(Gt)])):_("",!0)]),_:1},8,["class"]))}});export{ml as default};