huggingfab / build /bundle.js
julien-c's picture
julien-c HF staff
Fix relative paths
d9624d5 verified
raw
history blame
12 kB
var app=function(){"use strict";function t(){}const e=t=>t;function n(t){return t()}function o(){return Object.create(null)}function r(t){t.forEach(n)}function s(t){return"function"==typeof t}function c(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}let i;function l(t,e){return i||(i=document.createElement("a")),i.href=e,t===i.href}const u="undefined"!=typeof window;let a=u?()=>window.performance.now():()=>Date.now(),f=u?t=>requestAnimationFrame(t):t;const d=new Set;function p(t){d.forEach((e=>{e.c(t)||(d.delete(e),e.f())})),0!==d.size&&f(p)}function m(t,e){t.appendChild(e)}function g(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function h(t){const e=b("style");return function(t,e){m(t.head||t,e)}(g(t),e),e}function $(t,e,n){t.insertBefore(e,n||null)}function v(t){t.parentNode.removeChild(t)}function b(t){return document.createElement(t)}function _(t){return document.createTextNode(t)}function y(){return _(" ")}function w(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function x(t){return function(e){return e.preventDefault(),t.call(this,e)}}function k(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function E(t,e){t.value=null==e?"":e}function A(t,e,n,o){t.style.setProperty(e,n,o?"important":"")}function C(t,e,n){t.classList[n?"add":"remove"](e)}const L=new Set;let D,z=0;function S(t,e,n,o,r,s,c,i=0){const l=16.666/o;let u="{\n";for(let t=0;t<=1;t+=l){const o=e+(n-e)*s(t);u+=100*t+`%{${c(o,1-o)}}\n`}const a=u+`100% {${c(n,1-n)}}\n}`,f=`__svelte_${function(t){let e=5381,n=t.length;for(;n--;)e=(e<<5)-e^t.charCodeAt(n);return e>>>0}(a)}_${i}`,d=g(t);L.add(d);const p=d.__svelte_stylesheet||(d.__svelte_stylesheet=h(t).sheet),m=d.__svelte_rules||(d.__svelte_rules={});m[f]||(m[f]=!0,p.insertRule(`@keyframes ${f} ${a}`,p.cssRules.length));const $=t.style.animation||"";return t.style.animation=`${$?`${$}, `:""}${f} ${o}ms linear ${r}ms 1 both`,z+=1,f}function R(t,e){const n=(t.style.animation||"").split(", "),o=n.filter(e?t=>t.indexOf(e)<0:t=>-1===t.indexOf("__svelte")),r=n.length-o.length;r&&(t.style.animation=o.join(", "),z-=r,z||f((()=>{z||(L.forEach((t=>{const e=t.__svelte_stylesheet;let n=e.cssRules.length;for(;n--;)e.deleteRule(n);t.__svelte_rules={}})),L.clear())})))}function N(t){D=t}function O(t){(function(){if(!D)throw new Error("Function called outside component initialization");return D})().$$.on_mount.push(t)}const P=[],T=[],j=[],F=[],M=Promise.resolve();let U=!1;function q(t){j.push(t)}let H=!1;const I=new Set;function B(){if(!H){H=!0;do{for(let t=0;t<P.length;t+=1){const e=P[t];N(e),G(e.$$)}for(N(null),P.length=0;T.length;)T.pop()();for(let t=0;t<j.length;t+=1){const e=j[t];I.has(e)||(I.add(e),e())}j.length=0}while(P.length);for(;F.length;)F.pop()();U=!1,H=!1,I.clear()}}function G(t){if(null!==t.fragment){t.update(),r(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(q)}}let J;function W(t,e,n){t.dispatchEvent(function(t,e,n=!1){const o=document.createEvent("CustomEvent");return o.initCustomEvent(t,n,!1,e),o}(`${e?"intro":"outro"}${n}`))}const K=new Set;let Q;function V(){Q={r:0,c:[],p:Q}}function X(){Q.r||r(Q.c),Q=Q.p}function Y(t,e){t&&t.i&&(K.delete(t),t.i(e))}function Z(t,e,n,o){if(t&&t.o){if(K.has(t))return;K.add(t),Q.c.push((()=>{K.delete(t),o&&(n&&t.d(1),o())})),t.o(e)}}const tt={duration:0};function et(n,o,c,i){let l=o(n,c),u=i?0:1,m=null,g=null,h=null;function $(){h&&R(n,h)}function v(t,e){const n=t.b-u;return e*=Math.abs(n),{a:u,b:t.b,d:n,duration:e,start:t.start,end:t.start+e,group:t.group}}function b(o){const{delay:s=0,duration:c=300,easing:i=e,tick:b=t,css:_}=l||tt,y={start:a()+s,b:o};o||(y.group=Q,Q.r+=1),m||g?g=y:(_&&($(),h=S(n,u,o,c,s,i,_)),o&&b(0,1),m=v(y,c),q((()=>W(n,o,"start"))),function(t){let e;0===d.size&&f(p),new Promise((n=>{d.add(e={c:t,f:n})}))}((t=>{if(g&&t>g.start&&(m=v(g,c),g=null,W(n,m.b,"start"),_&&($(),h=S(n,u,m.b,m.duration,0,i,l.css))),m)if(t>=m.end)b(u=m.b,1-u),W(n,m.b,"end"),g||(m.b?$():--m.group.r||r(m.group.c)),m=null;else if(t>=m.start){const e=t-m.start;u=m.a+m.d*i(e/m.duration),b(u,1-u)}return!(!m&&!g)})))}return{run(t){s(l)?(J||(J=Promise.resolve(),J.then((()=>{J=null}))),J).then((()=>{l=l(),b(t)})):b(t)},end(){$(),m=g=null}}}function nt(t){t&&t.c()}function ot(t,e,o,c){const{fragment:i,on_mount:l,on_destroy:u,after_update:a}=t.$$;i&&i.m(e,o),c||q((()=>{const e=l.map(n).filter(s);u?u.push(...e):r(e),t.$$.on_mount=[]})),a.forEach(q)}function rt(t,e){const n=t.$$;null!==n.fragment&&(r(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function st(t,e){-1===t.$$.dirty[0]&&(P.push(t),U||(U=!0,M.then(B)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function ct(e,n,s,c,i,l,u,a=[-1]){const f=D;N(e);const d=e.$$={fragment:null,ctx:null,props:l,update:t,not_equal:i,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(n.context||(f?f.$$.context:[])),callbacks:o(),dirty:a,skip_bound:!1,root:n.target||f.$$.root};u&&u(d.root);let p=!1;if(d.ctx=s?s(e,n.props||{},((t,n,...o)=>{const r=o.length?o[0]:n;return d.ctx&&i(d.ctx[t],d.ctx[t]=r)&&(!d.skip_bound&&d.bound[t]&&d.bound[t](r),p&&st(e,t)),n})):[],d.update(),p=!0,r(d.before_update),d.fragment=!!c&&c(d.ctx),n.target){if(n.hydrate){const t=function(t){return Array.from(t.childNodes)}(n.target);d.fragment&&d.fragment.l(t),t.forEach(v)}else d.fragment&&d.fragment.c();n.intro&&Y(e.$$.fragment),ot(e,n.target,n.anchor,n.customElement),B()}N(f)}class it{$destroy(){rt(this,1),this.$destroy=t}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function lt(t,{delay:n=0,duration:o=400,easing:r=e}={}){const s=+getComputedStyle(t).opacity;return{delay:n,duration:o,easing:r,css:t=>"opacity: "+t*s}}function ut(e){let n,o,r,s,c,i,u,a,f,d,p,g,h,_,E,A,C;return{c(){n=b("div"),o=b("div"),r=b("img"),c=y(),i=b("span"),i.textContent="+",u=y(),a=b("img"),d=y(),p=b("p"),p.innerHTML='A <span class="sketchfab svelte-19le2fc">Sketchfab</span> + <span class="huggingface">Huggingface</span> experiment',g=y(),h=b("p"),h.textContent="This demo uses the Huggingface inference API to trigger animations on a Sketchfab model.",_=y(),E=b("button"),E.textContent="Let's Go !",k(r,"class","hf svelte-19le2fc"),l(r.src,s="./huggingface.svg")||k(r,"src","./huggingface.svg"),k(i,"class","plus svelte-19le2fc"),k(a,"class","sketchfab svelte-19le2fc"),l(a.src,f="./sketchfab-logo.svg")||k(a,"src","./sketchfab-logo.svg"),k(p,"class","subtitle svelte-19le2fc"),k(h,"class","desc svelte-19le2fc"),k(E,"class","button svelte-19le2fc"),k(o,"class","popup svelte-19le2fc"),k(n,"class","container svelte-19le2fc")},m(t,s){$(t,n,s),m(n,o),m(o,r),m(o,c),m(o,i),m(o,u),m(o,a),m(o,d),m(o,p),m(o,g),m(o,h),m(o,_),m(o,E),A||(C=w(E,"click",x(e[0])),A=!0)},p:t,i:t,o:t,d(t){t&&v(n),A=!1,C()}}}function at(t,e,n){let{introDone:o=!1}=e;return t.$$set=t=>{"introDone"in t&&n(1,o=t.introDone)},[function(){n(1,o=!0)},o]}class ft extends it{constructor(t){super(),ct(this,t,at,ut,c,{introDone:1})}}function dt(t){let e,n,o,r,s,c,i,l,u,a,f,d=Math.floor(100*t[0])+"";return{c(){e=b("div"),n=b("div"),o=y(),r=b("div"),s=y(),c=b("div"),i=_("Loading "),l=_(d),u=_("%"),k(n,"class","loading-logo-grayscale svelte-1nu4cza"),k(r,"class","loading-logo svelte-1nu4cza"),A(r,"height",100*t[0]+"px"),k(e,"class","loader svelte-1nu4cza"),C(e,"loading",!t[3])},m(t,a){$(t,e,a),m(e,n),m(e,o),m(e,r),m(e,s),m(e,c),m(c,i),m(c,l),m(c,u),f=!0},p(t,n){(!f||1&n)&&A(r,"height",100*t[0]+"px"),(!f||1&n)&&d!==(d=Math.floor(100*t[0])+"")&&function(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}(l,d),8&n&&C(e,"loading",!t[3])},i(t){f||(q((()=>{a||(a=et(e,lt,{},!0)),a.run(1)})),f=!0)},o(t){a||(a=et(e,lt,{},!1)),a.run(0),f=!1},d(t){t&&v(e),t&&a&&a.end()}}}function pt(t){let e,n,o,s,c,i;return{c(){e=b("form"),n=b("input"),k(n,"class","query svelte-1nu4cza"),k(n,"placeholder","Tell me what to do and press enter !"),k(n,"autocomplete",""),n.autofocus=!0,k(e,"class","form svelte-1nu4cza")},m(o,r){$(o,e,r),m(e,n),E(n,t[2]),s=!0,n.focus(),c||(i=[w(n,"input",t[7]),w(e,"submit",x(t[4]))],c=!0)},p(t,e){4&e&&n.value!==t[2]&&E(n,t[2])},i(t){s||(q((()=>{o||(o=et(e,lt,{duration:300},!0)),o.run(1)})),s=!0)},o(t){o||(o=et(e,lt,{duration:300},!1)),o.run(0),s=!1},d(t){t&&v(e),t&&o&&o.end(),c=!1,r(i)}}}function mt(t){let e,n,o,r,s,c,i=!t[3]&&dt(t),u=t[3]&&pt(t);return{c(){e=b("div"),i&&i.c(),n=y(),o=b("iframe"),s=y(),u&&u.c(),k(o,"title","Forest Animal: Fox"),k(o,"frameborder","0"),o.allowFullscreen="true",k(o,"mozallowfullscreen","true"),k(o,"webkitallowfullscreen","true"),k(o,"allow","autoplay; fullscreen; xr-spatial-tracking"),k(o,"xr-spatial-tracking","true"),k(o,"execution-while-out-of-viewport","true"),k(o,"execution-while-not-rendered","true"),k(o,"web-share","true"),l(o.src,r="")||k(o,"src",""),k(o,"class","svelte-1nu4cza"),C(o,"viewer",t[1]),C(o,"started",t[3]),k(e,"class","container svelte-1nu4cza")},m(r,l){$(r,e,l),i&&i.m(e,null),m(e,n),m(e,o),t[6](o),m(e,s),u&&u.m(e,null),c=!0},p(t,[r]){t[3]?i&&(V(),Z(i,1,1,(()=>{i=null})),X()):i?(i.p(t,r),8&r&&Y(i,1)):(i=dt(t),i.c(),Y(i,1),i.m(e,n)),2&r&&C(o,"viewer",t[1]),8&r&&C(o,"started",t[3]),t[3]?u?(u.p(t,r),8&r&&Y(u,1)):(u=pt(t),u.c(),Y(u,1),u.m(e,null)):u&&(V(),Z(u,1,1,(()=>{u=null})),X())},i(t){c||(Y(i),Y(u),c=!0)},o(t){Z(i),Z(u),c=!1},d(n){n&&v(e),i&&i.d(),t[6](null),u&&u.d()}}}function gt(t,e,n){let o,r,s,{modelUid:c="abf5788c354f4d4b9ff5ea1fd10c6496"}=e,i=0,l=!1;l=!0;let u,a="";return O((()=>{s=new Sketchfab(r),s.init(c,{success:t=>{s=t,s.start(),s.addEventListener("modelLoadProgress",(function(t){n(0,i=t.progress)})),s.addEventListener("viewerready",(function(){s.getAnimations((function(t,e){u=e.filter((t=>{const e=t[1];return"Walk"!==e&&"Roll"!==e&&"Run"!==e&&"Land"!==e&&"Idle_2"!==e}))}))}))}})})),t.$$set=t=>{"modelUid"in t&&n(5,c=t.modelUid)},t.$$.update=()=>{1&t.$$.dirty&&n(3,o=i>=1)},[i,r,a,o,async function(){const t=await fetch("https://api-inference.huggingface.co/models/facebook/bart-large-mnli",{method:"POST",body:JSON.stringify({inputs:(e=a,e.trim().toLowerCase()),parameters:{candidate_labels:u.map((t=>t[1].replaceAll("_"," ")))}})});var e;let o=(await t.json()).labels[0];for(const t of u)if(t[1].replaceAll("_"," ").toLowerCase()===o.trim().toLowerCase()){const e=t[0];s.setCurrentAnimationByUID(e)}n(2,a="")},c,function(t){T[t?"unshift":"push"]((()=>{r=t,n(1,r)}))},function(){a=this.value,n(2,a)}]}class ht extends it{constructor(t){super(),ct(this,t,gt,mt,c,{modelUid:5})}}function $t(t){let e,n,o;function r(e){t[1](e)}let s={};return void 0!==t[0]&&(s.introDone=t[0]),e=new ft({props:s}),T.push((()=>function(t,e,n){const o=t.$$.props[e];void 0!==o&&(t.$$.bound[o]=n,n(t.$$.ctx[o]))}(e,"introDone",r))),{c(){nt(e.$$.fragment)},m(t,n){ot(e,t,n),o=!0},p(t,o){const r={};var s;!n&&1&o&&(n=!0,r.introDone=t[0],s=()=>n=!1,F.push(s)),e.$set(r)},i(t){o||(Y(e.$$.fragment,t),o=!0)},o(t){Z(e.$$.fragment,t),o=!1},d(t){rt(e,t)}}}function vt(e){let n,o;return n=new ht({}),{c(){nt(n.$$.fragment)},m(t,e){ot(n,t,e),o=!0},p:t,i(t){o||(Y(n.$$.fragment,t),o=!0)},o(t){Z(n.$$.fragment,t),o=!1},d(t){rt(n,t)}}}function bt(t){let e,n,o,r;const s=[vt,$t],c=[];function i(t,e){return t[0]?0:1}return e=i(t),n=c[e]=s[e](t),{c(){n.c(),o=_("")},m(t,n){c[e].m(t,n),$(t,o,n),r=!0},p(t,[r]){let l=e;e=i(t),e===l?c[e].p(t,r):(V(),Z(c[l],1,1,(()=>{c[l]=null})),X(),n=c[e],n?n.p(t,r):(n=c[e]=s[e](t),n.c()),Y(n,1),n.m(o.parentNode,o))},i(t){r||(Y(n),r=!0)},o(t){Z(n),r=!1},d(t){c[e].d(t),t&&v(o)}}}function _t(t,e,n){let o=!1;return[o,function(t){o=t,n(0,o)}]}return new class extends it{constructor(t){super(),ct(this,t,_t,bt,c,{})}}({target:document.body,props:{}})}();
//# sourceMappingURL=bundle.js.map