1import{M as u,r as x,aG as Y,j as e,aH as w,z as N,B,X as P}from"./index-BWtN1VwT.js";import{I as R}from"./input-pi7YzH4v.js";import{T as S,a as W,b as k,c as M}from"./tabs-5MVoItlh.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const D=u("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const K=u("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const m=u("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/** 17 * @license lucide-react v0.462.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const O=u("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]),V=t=>{const s=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const r of s){const i=t.match(r);if(i)return i[1]}return null},T=t=>{const s=[/vimeo\.com\/(\d+)/,/player\.vimeo\.com\/video\/(\d+)/];for(const r of s){const i=t.match(r);if(i)return i[1]}return null},H=t=>t?V(t)?"youtube":T(t)?"vimeo":(t.match(/\.(mp4|webm|mov)(\?|$)/i)||t.includes("supabase"),"direct"):null,Z=t=>{const s=V(t);if(s)return`https://www.youtube.com/embed/${s}`;const r=T(t);return r?`https://player.vimeo.com/video/${r}`:null},J=({value:t,onChange:s,folder:r="creator-tips",uploadOnly:i=!1})=>{const[n,p]=x.useState(!1),[L,U]=x.useState("link"),l=x.useRef(null),{toast:d}=Y(),c=H(t),C=Z(t),v=async a=>{var j,y,g;const o=(j=a.target.files)==null?void 0:j[0];if(!o)return;const A=["mp4","webm","mov","avi","mkv","m4v","qt"],h=((y=o.name.split(".").pop())==null?void 0:y.toLowerCase())||"",E=o.type.startsWith("video/"),F=A.includes(h);if(!E&&!F){d({variant:"destructive",title:"Fel",description:`Filformatet stöds inte (${o.type||"okänd typ"}, .${h}). Tillåtna: MP4, WebM, MOV, AVI, MKV, M4V`});return}if(o.size>500*1024*1024){d({variant:"destructive",title:"Fel",description:"Videon får max vara 500MB"});return}p(!0);const q=((g=o.name.split(".").pop())==null?void 0:g.toLowerCase())||"mp4",f=`${r}/${Date.now()}-${Math.random().toString(36).substring(7)}.${q}`,{error:b}=await N.storage.from("videos").upload(f,o,{cacheControl:"3600",upsert:!1});if(b){d({variant:"destructive",title:"Uppladdning misslyckades",description:b.message}),p(!1);return}const{data:{publicUrl:z}}=N.storage.from("videos").getPublicUrl(f);s(z),p(!1),d({title:"Video uppladdad!"})},$=()=>{s(""),l.current&&(l.current.value="")},I=()=>t?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"relative rounded-lg overflow-hidden bg-black aspect-video w-full max-w-md",children:c==="youtube"||c==="vimeo"?e.jsx("iframe",{src:C||void 0,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Video preview"}):e.jsx("video",{src:t,controls:!0,className:"w-full h-full object-contain",preload:"metadata",children:"Din webbläsare stödjer inte video-taggen."})}),c&&e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[c==="youtube"&&e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"h-3 w-3"})," YouTube"]}),c==="vimeo"&&e.jsxs(e.Fragment,{children:[e.jsx(m,{className:"h-3 w-3"})," Vimeo"]}),c==="direct"&&e.jsxs(e.Fragment,{children:[e.jsx(m,{className:"h-3 w-3"})," Direktvideo"]})]}),e.jsxs(B,{type:"button",variant:"destructive",size:"sm",className:"w-full sm:w-auto min-h-[44px]",onClick:$,children:[e.jsx(P,{className:"h-4 w-4 mr-2"}),"Ta bort video"]})]}):null;return t?e.jsx("div",{className:"space-y-2",children:I()}):i?e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{type:"file",ref:l,onChange:v,accept:"video/mp4,video/webm,video/quicktime,.mov,.avi,.mkv,.m4v",className:"hidden"}),e.jsx("div",{className:"border-2 border-dashed border-muted-foreground
21/25 rounded-lg p-8 text-center hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>{var a;return!n&&((a=l.current)==null?void 0:a.click())},children:n?e.jsxs("div",{className:"space-y-3",children:[e.jsx(w,{className:"h-10 w-10 mx-auto animate-spin text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Laddar upp video..."})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(m,{className:"h-10 w-10 mx-auto text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Klicka för att välja video"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, WebM eller MOV (max 100MB)"})]})]})})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{type:"file",ref:l,onChange:v,accept:"video/mp4,video/webm,video/quicktime,.mov,.avi,.mkv,.m4v",className:"hidden"}),e.jsxs(S,{value:L,onValueChange:U,className:"w-full",children:[e.jsxs(W,{className:"grid w-full grid-cols-2",children:[e.jsxs(k,{value:"link",className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-4 w-4"}),"YouTube / Vimeo / URL"]}),e.jsxs(k,{value:"upload",className:"flex items-center gap-2",children:[e.jsx(K,{className:"h-4 w-4"}),"Ladda upp"]})]}),e.jsxs(M,{value:"link",className:"space-y-2 mt-3",children:[e.jsx(R,{type:"url",value:t,onChange:a=>s(a.target.value),placeholder:"https://youtube.com/watch?v=... eller https://vimeo.com/..."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Stöder YouTube, Vimeo och direktlänkar till videofiler"})]}),e.jsx(M,{value:"upload",className:"mt-3",children:e.jsx("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>{var a;return!n&&((a=l.current)==null?void 0:a.click())},children:n?e.jsxs("div",{className:"space-y-3",children:[e.jsx(w,{className:"h-10 w-10 mx-auto animate-spin text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Laddar upp video..."})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(m,{className:"h-10 w-10 mx-auto text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Klicka för att välja video"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, WebM eller MOV (max 100MB)"})]})]})})})]})]})};export{D as L,K as U,J as V,Z as a,H as g};
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.