PageSourceSearch

https://tastly.ai/assets/_app.recipes.new-BOBdxeFV.js

js tastly.ai collected 2026-10-05 14:07:55 UTC 6,075 bytes, 1 lines download raw bytes

1import{u as C,r as f,e as R,H as D,j as e,T as o,S as P,Z as O,a as E,d as L,aP as T,aQ as _,aR as F,t as S,aS as M,aT as H}from"./index-Dkwi1Om3.js";import{R as U}from"./recipe-form-CLXM1Xma.js";import{O as $,a as z}from"./overlay-page-BKhPAsee.js";import{A as G,a as J,b as V,c as Z,d as B}from"./alert-dialog-BL1v76Z-.js";import{C as K}from"./crown-Cuuarg_v.js";import{u as Q}from"./workspace-B-SPAe3z.js";import{s as q}from"./albums-CD2UG41v.js";import{s as W}from"./tags-BlHBTDQd.js";import{P as X}from"./pen-line-B4tUlEmF.js";import"./gradient-trash-D_AjzDZg.js";import"./photo-source-sheet-N4a0D5XU.js";import"./bottom-sheet-BVYajbS_.js";import"./camera-BL0MLE8f.js";import"./image-plus-D5y7qeYW.js";import"./photo-crop-CrERFuu7.js";import"./loader-circle-CUpjekET.js";import"./album-cover-Y4X9EHK5.js";import"./image-to-file-C3_NgsZ_.js";import"./ai-credit-error-CjTK0qhD.js";import"./http-DxpoFMdq.js";import"./pencil-U2jJ9VzO.js";import"./account-members.functions-BVq3vlx7.js";const k="tastly:recipe-limit-reached";function Y(s){return s==="free"?"/pricing?plan=starter":s==="starter"?"/pricing?plan=pro":"/pricing"}function ee({open:s,onClose:w}={}){const{t:u}=C("common"),[y,n]=f.useState(!1),[p,I]=f.useState("free"),v=R(D),d=typeof s=="boolean",j=d?s:y;function b(){d?w?.():n(!1)}function N(){v().then(t=>{t?.plan&&I(t.plan)}).catch(()=>{})}f.useEffect(()=>{if(d)return;function t(){n(!0),N()}return window.addEventListener(k,t),()=>window.removeEventListener(k,t)},[d]),f.useEffect(()=>{d&&j&&N()},[d,j]);function l(t){b(),typeof window<"u"&&window.location.assign(t)}const g=p!=="pro"&&p!=="family"&&p!=="forever_free";return e.jsx(G,{open:j,onOpenChange:t=>{t||b()},children:e.jsxs(J,{className:"rounded-3xl border-0 items-center text-center duration-500 max-w-sm",style:{background:o.bg,color:o.ink,boxShadow:o.shadowLg},children:[e.jsxs(V,{className:"items-center text-center space-y-4",children:[e.jsx("div",{className:"w-20 h-20 rounded-full grid place-items-center",style:{background:o.brandGradient},children:e.jsx(K,{className:"size-10 text-white"})}),e.jsx(Z,{style:{color:o.ink},className:"text-xl font-bold",children:u("recipeLimitDialog.title")}),e.jsx(B,{style:{color:o.subInk},className:"text-sm leading-relaxed",children:u("recipeLimitDialog.body")})]}),e.jsxs("div",{className:"w-full flex flex-col gap-3 mt-2",children:[g&&e.jsxs("button",{type:"button",onClick:()=>l(Y(p)),className:"w-full inline-flex items-center justify-center gap-2 px-6 py-3 rounded-full text-sm font-semibold text-white",style:{background:o.brandGradient,boxShadow:o.shadowBrand},children:[e.jsx(P,{className:"size-4"}),u("recipeLimitDialog.upgradeCta")]}),e.jsxs("button",{type:"button",onClick:()=>l("/pricing?topup=credits_standaard#topups"),className:"w-full inline-flex flex-col items-center justify-center gap-0.5 px-6 py-3 rounded-full text-sm font-semibold",style:{background:o.surface,color:o.ink,border:`1px solid ${o.border}`},children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(O,{className:"size-4"}),u("recipeLimitDialog.topupCta")]}),e.jsx("span",{className:"text-[11px] font-normal",style:{color:o.subInk},children:u("recipeLimitDialog.topupHint")})]}),e.jsx("button",{type:"button",onClick:b,className:"text-xs underline pt-1",style:{color:o.subInk},children:u("recipeLimitDialog.dismiss")})]})]})})}function Ne(){const{t:s}=C("recipes"),{user:w}=E(),u=Q(),y=L(),{addToAlbum:n,sourceUrl:p}=T.useSearch(),[I,v]=f.useState(!1),d=f.useMemo(()=>{if(!(typeof window>"u"))try{const l=sessionStorage.getItem("tastly:prefill-recipe");return l?(sessionStorage.removeItem("tastly:prefill-recipe"),JSON.parse(l)):void 0}catch{return}},[]),j=f.useMemo(()=>{if(typeof window>"u")return null;try{const l=sessionStorage.getItem("tastly:prefill-photo");if(!l)return null;sessionStorage.removeItem("tastly:prefill-photo");const{dataUrl:g,name:t,type:A}=JSON.parse(l),[x,h]=g.split(","),r=A||(x.match(/data:(.*?);base64/)?.[1]??"image/jpeg"),a=atob(h),c=new Uint8Array(a.length);for(let m=0;m<a.length;m++)c[m]=a.charCodeAt(m);return new File([c],t||"photo.jpg",{type:r})}catch{return null}},[]);f.useMemo(()=>
1{if(typeof window>"u")return null;try{sessionStorage.removeItem("tastly:prefill-nutrition")}catch{}return null},[]);const b=null,N=d?{...d,...p?{source_url:p}:{}}:p?{source_url:p}:void 0;return e.jsxs($,{children:[e.jsx(z,{kicker:"Nieuw recept",icon:X,title:s("new.title")}),e.jsx(ee,{open:I,onClose:()=>v(!1)}),n&&e.jsx("p",{className:"text-sm font-medium",style:{color:"#E8178C"},children:s("new.albumNote")}),e.jsx(U,{variant:"v2",initial:N,initialPhotoFile:j,initialAlbumIds:n?[n]:[],submitLabel:s("new.submit"),onCancel:()=>y(n?{to:"/albums/$albumId",params:{albumId:n}}:{to:"/"}),onSubmit:async(l,g,t,A,x)=>{if(w)try{const h=u??w.id,r=await _(h,l),a={};if(g)try{const i=await F(w.id,r,g);a.photo_url=i}catch(i){console.error("[recipes/new] photo upload failed",i),S.warning(s("new.photoUploadFailed"))}if(x.originalFile)try{const i=await M(w.id,r,x.originalFile);a.photo_original_url=i}catch(i){console.error("[recipes/new] original upload failed",i)}x.cropTransform&&(a.photo_crop=x.cropTransform);const c={...a};if(Object.keys(c).length>0)try{await H(r,c)}catch(i){console.error("[recipes/new] updateRecipe patch failed",{patch:c,error:i})}if(t.length>0)try{await W(r,t)}catch(i){console.error("[recipes/new] setRecipeTags failed",i)}const m=Array.from(new Set([...A??[],...n?[n]:[]]));if(m.length>0)try{await q(r,m)}catch(i){console.error("[recipes/new] setRecipeAlbums failed",i)}console.info("[recipes/new] saved",{recipeId:r,hasPhoto:!!g,hadNutritionPrefill:!!b,addedAlbums:m.length,patchKeys:Object.keys(c)}),S.success(s("new.saved")),y(n?{to:"/albums/$albumId",params:{albumId:n}}:{to:"/recipes/$recipeId",params:{recipeId:r}})}catch(h){if(h?.code==="RECIPE_LIMIT_REACHED")v(!0);else{console.error("[recipes/new] save failed",h);const r=h,a=[r?.message,r?.details,r?.hint,r?.code].filter(c=>typeof c=="string"&&c.length>0);S.error(a.length>0?a.join(" — "):s("new.saveFailed"))}}}})]})}export{Ne as component};

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.