var de=Object.defineProperty,_e=Object.defineProperties;var pe=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var Z=(a,e,t)=>e in a?de(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,v=(a,e)=>{for(var t in e||(e={}))ee.call(e,t)&&Z(a,t,e[t]);if(B)for(var t of B(e))te.call(e,t)&&Z(a,t,e[t]);return a},W=(a,e)=>_e(a,pe(e));var se=(a,e)=>{var t={};for(var r in a)ee.call(a,r)&&e.indexOf(r)<0&&(t[r]=a[r]);if(a!=null&&B)for(var r of B(a))e.indexOf(r)<0&&te.call(a,r)&&(t[r]=a[r]);return t};import{S as ge,i as me,s as we,e as be,c as ve,a as ye,d as R,b as G,f as I,g as S,t as ke,h as Ee,j as $e,k as Re,l as y,m as Le,n as x,o as k,p as U,q as E,r as Oe,u as Se,v as F,w as A,x as C,y as P,z as j,A as q,B as T,C as z,D as Y,E as re}from"./chunks/vendor-hf-doc-builder.js";import{s as Ae,b as Pe}from"./chunks/paths-hf-doc-builder.js";function Te(a){let e,t,r;const o=[a[1]||{}];var i=a[0][0];function l(s){let n={};for(let c=0;c<o.length;c+=1)n=z(n,o[c]);return{props:n}}return i&&(e=new i(l())),{c(){e&&A(e.$$.fragment),t=y()},l(s){e&&C(e.$$.fragment,s),t=y()},m(s,n){e&&P(e,s,n),S(s,t,n),r=!0},p(s,n){const c=n&2?j(o,[q(s[1]||{})]):{};if(i!==(i=s[0][0])){if(e){x();const u=e;k(u.$$.fragment,1,0,()=>{T(u,1)}),U()}i?(e=new i(l()),A(e.$$.fragment),E(e.$$.fragment,1),P(e,t.parentNode,t)):e=null}else i&&e.$set(c)},i(s){r||(e&&E(e.$$.fragment,s),r=!0)},o(s){e&&k(e.$$.fragment,s),r=!1},d(s){s&&R(t),e&&T(e,s)}}}function Ve(a){let e,t,r;const o=[a[1]||{}];var i=a[0][0];function l(s){let n={$$slots:{default:[Ue]},$$scope:{ctx:s}};for(let c=0;c<o.length;c+=1)n=z(n,o[c]);return{props:n}}return i&&(e=new i(l(a))),{c(){e&&A(e.$$.fragment),t=y()},l(s){e&&C(e.$$.fragment,s),t=y()},m(s,n){e&&P(e,s,n),S(s,t,n),r=!0},p(s,n){const c=n&2?j(o,[q(s[1]||{})]):{};if(n&525&&(c.$$scope={dirty:n,ctx:s}),i!==(i=s[0][0])){if(e){x();const u=e;k(u.$$.fragment,1,0,()=>{T(u,1)}),U()}i?(e=new i(l(s)),A(e.$$.fragment),E(e.$$.fragment,1),P(e,t.parentNode,t)):e=null}else i&&e.$set(c)},i(s){r||(e&&E(e.$$.fragment,s),r=!0)},o(s){e&&k(e.$$.fragment,s),r=!1},d(s){s&&R(t),e&&T(e,s)}}}function Ie(a){let e,t,r;const o=[a[2]||{}];var i=a[0][1];function l(s){let n={};for(let c=0;c<o.length;c+=1)n=z(n,o[c]);return{props:n}}return i&&(e=new i(l())),{c(){e&&A(e.$$.fragment),t=y()},l(s){e&&C(e.$$.fragment,s),t=y()},m(s,n){e&&P(e,s,n),S(s,t,n),r=!0},p(s,n){const c=n&4?j(o,[q(s[2]||{})]):{};if(i!==(i=s[0][1])){if(e){x();const u=e;k(u.$$.fragment,1,0,()=>{T(u,1)}),U()}i?(e=new i(l()),A(e.$$.fragment),E(e.$$.fragment,1),P(e,t.parentNode,t)):e=null}else i&&e.$set(c)},i(s){r||(e&&E(e.$$.fragment,s),r=!0)},o(s){e&&k(e.$$.fragment,s),r=!1},d(s){s&&R(t),e&&T(e,s)}}}function De(a){let e,t,r;const o=[a[2]||{}];var i=a[0][1];function l(s){let n={$$slots:{default:[xe]},$$scope:{ctx:s}};for(let c=0;c<o.length;c+=1)n=z(n,o[c]);return{props:n}}return i&&(e=new i(l(a))),{c(){e&&A(e.$$.fragment),t=y()},l(s){e&&C(e.$$.fragment,s),t=y()},m(s,n){e&&P(e,s,n),S(s,t,n),r=!0},p(s,n){const c=n&4?j(o,[q(s[2]||{})]):{};if(n&521&&(c.$$scope={dirty:n,ctx:s}),i!==(i=s[0][1])){if(e){x();const u=e;k(u.$$.fragment,1,0,()=>{T(u,1)}),U()}i?(e=new i(l(s)),A(e.$$.fragment),E(e.$$.fragment,1),P(e,t.parentNode,t)):e=null}else i&&e.$set(c)},i(s){r||(e&&E(e.$$.fragment,s),r=!0)},o(s){e&&k(e.$$.fragment,s),r=!1},d(s){s&&R(t),e&&T(e,s)}}}function xe(a){let e,t,r;const o=[a[3]||{}];var i=a[0][2];function l(s){let n={};for(let c=0;c<o.length;c+=1)n=z(n,o[c]);return{props:n}}return i&&(e=new i(l())),{c(){e&&A(e.$$.fragment),t=y()},l(s){e&&C(e.$$.fragment,s),t=y()},m(s,n){e&&P(e,s,n),S(s,t,n),r=!0},p(s,n){const c=n&8?j(o,[q(s[3]||{})]):{};if(i!==(i=s[0][2])){if(e){x();const u=e;k(u.$$.fragment,1,0,()=>{T(u,1)}),U()}i?(e=new i(l()),A(e.$$.fragment),E(e.$$.fragment,1),P(e,t.parentNode,t)):e=null}else i&&e.$set(c)},i(s){r||(e&&E(e.$$.fragment,s),r=!0)},o(s){e&&k(e.$$.fragment,s),r=!1},d(s){s&&R(t),e&&T(e,s)}}}function Ue(a){let e,t,r,o;const i=[De,Ie],l=[];function s(n,c){return n[0][2]?0:1}return e=s(a),t=l[e]=i[e](a),{c(){t.c(),r=y()},l(n){t.l(n),r=y()},m(n,c){l[e].m(n,c),S(n,r,c),o=!0},p(n,c){let u=e;e=s(n),e===u?l[e].p(n,c):(x(),k(l[u],1,1,()=>{l[u]=null}),U(),t=l[e],t?t.p(n,c):(t=l[e]=i[e](n),t.c()),E(t,1),t.m(r.parentNode,r))},i(n){o||(E(t),o=!0)},o(n){k(t),o=!1},d(n){l[e].d(n),n&&R(r)}}}function ie(a){let e,t=a[5]&&ne(a);return{c(){e=be("div"),t&&t.c(),this.h()},l(r){e=ve(r,"DIV",{id:!0,"aria-live":!0,"aria-atomic":!0,style:!0});var o=ye(e);t&&t.l(o),o.forEach(R),this.h()},h(){G(e,"id","svelte-announcer"),G(e,"aria-live","assertive"),G(e,"aria-atomic","true"),I(e,"position","absolute"),I(e,"left","0"),I(e,"top","0"),I(e,"clip","rect(0 0 0 0)"),I(e,"clip-path","inset(50%)"),I(e,"overflow","hidden"),I(e,"white-space","nowrap"),I(e,"width","1px"),I(e,"height","1px")},m(r,o){S(r,e,o),t&&t.m(e,null)},p(r,o){r[5]?t?t.p(r,o):(t=ne(r),t.c(),t.m(e,null)):t&&(t.d(1),t=null)},d(r){r&&R(e),t&&t.d()}}}function ne(a){let e;return{c(){e=ke(a[6])},l(t){e=Ee(t,a[6])},m(t,r){S(t,e,r)},p(t,r){r&64&&$e(e,t[6])},d(t){t&&R(e)}}}function Ne(a){let e,t,r,o,i;const l=[Ve,Te],s=[];function n(u,d){return u[0][1]?0:1}e=n(a),t=s[e]=l[e](a);let c=a[4]&&ie(a);return{c(){t.c(),r=Re(),c&&c.c(),o=y()},l(u){t.l(u),r=Le(u),c&&c.l(u),o=y()},m(u,d){s[e].m(u,d),S(u,r,d),c&&c.m(u,d),S(u,o,d),i=!0},p(u,[d]){let h=e;e=n(u),e===h?s[e].p(u,d):(x(),k(s[h],1,1,()=>{s[h]=null}),U(),t=s[e],t?t.p(u,d):(t=s[e]=l[e](u),t.c()),E(t,1),t.m(r.parentNode,r)),u[4]?c?c.p(u,d):(c=ie(u),c.c(),c.m(o.parentNode,o)):c&&(c.d(1),c=null)},i(u){i||(E(t),i=!0)},o(u){k(t),i=!1},d(u){s[e].d(u),u&&R(r),c&&c.d(u),u&&R(o)}}}function Ce(a,e,t){let{stores:r}=e,{page:o}=e,{components:i}=e,{props_0:l=null}=e,{props_1:s=null}=e,{props_2:n=null}=e;Oe("__svelte__",r),Se(r.page.notify);let c=!1,u=!1,d=null;return F(()=>{const h=r.page.subscribe(()=>{c&&(t(5,u=!0),t(6,d=document.title||"untitled page"))});return t(4,c=!0),h}),a.$$set=h=>{"stores"in h&&t(7,r=h.stores),"page"in h&&t(8,o=h.page),"components"in h&&t(0,i=h.components),"props_0"in h&&t(1,l=h.props_0),"props_1"in h&&t(2,s=h.props_1),"props_2"in h&&t(3,n=h.props_2)},a.$$.update=()=>{a.$$.dirty&384&&r.page.set(o)},[i,l,s,n,c,u,d,r,o]}class je extends ge{constructor(e){super();me(this,e,Ce,Ne,we,{stores:7,page:8,components:0,props_0:1,props_1:2,props_2:3})}}const qe="modulepreload",ae={},ze="/docs/transformers/pr_19907/it/_app/",g=function(e,t){return!t||t.length===0?e():Promise.all(t.map(r=>{if(r=`${ze}${r}`,r in ae)return;ae[r]=!0;const o=r.endsWith(".css"),i=o?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${r}"]${i}`))return;const l=document.createElement("link");if(l.rel=o?"stylesheet":qe,o||(l.as="script",l.crossOrigin=""),l.href=r,document.head.appendChild(l),o)return new Promise((s,n)=>{l.addEventListener("load",s),l.addEventListener("error",n)})})).then(()=>e())},f=[()=>g(()=>import("./pages/__layout.svelte-hf-doc-builder.js"),["pages/__layout.svelte-hf-doc-builder.js","assets/pages/__layout.svelte-hf-doc-builder.css","chunks/vendor-hf-doc-builder.js","chunks/paths-hf-doc-builder.js"]),()=>g(()=>import("./error.svelte-hf-doc-builder.js"),["error.svelte-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js"]),()=>g(()=>import("./pages/index.mdx-hf-doc-builder.js"),["pages/index.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js"]),()=>g(()=>import("./pages/converting_tensorflow_models.mdx-hf-doc-builder.js"),["pages/converting_tensorflow_models.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/Tip-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js"]),()=>g(()=>import("./pages/autoclass_tutorial.mdx-hf-doc-builder.js"),["pages/autoclass_tutorial.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/Tip-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js","chunks/Markdown-hf-doc-builder.js","chunks/IconTensorflow-hf-doc-builder.js"]),()=>g(()=>import("./pages/pipeline_tutorial.mdx-hf-doc-builder.js"),["pages/pipeline_tutorial.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/Tip-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js"]),()=>g(()=>import("./pages/add_new_pipeline.mdx-hf-doc-builder.js"),["pages/add_new_pipeline.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js"]),()=>g(()=>import("./pages/create_a_model.mdx-hf-doc-builder.js"),["pages/create_a_model.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/Tip-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js","chunks/Markdown-hf-doc-builder.js","chunks/IconTensorflow-hf-doc-builder.js"]),()=>g(()=>import("./pages/add_new_model.mdx-hf-doc-builder.js"),["pages/add_new_model.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/Tip-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js"]),()=>g(()=>import("./pages/custom_models.mdx-hf-doc-builder.js"),["pages/custom_models.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/Tip-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js"]),()=>g(()=>import("./pages/model_sharing.mdx-hf-doc-builder.js"),["pages/model_sharing.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/Tip-hf-doc-builder.js","chunks/Youtube-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js","chunks/Markdown-hf-doc-builder.js","chunks/IconTensorflow-hf-doc-builder.js"]),()=>g(()=>import("./pages/preprocessing.mdx-hf-doc-builder.js"),["pages/preprocessing.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/Tip-hf-doc-builder.js","chunks/Youtube-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js","chunks/IconTensorflow-hf-doc-builder.js","chunks/DocNotebookDropdown-hf-doc-builder.js"]),()=>g(()=>import("./pages/serialization.mdx-hf-doc-builder.js"),["pages/serialization.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/Tip-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js","chunks/Markdown-hf-doc-builder.js","chunks/IconTensorflow-hf-doc-builder.js"]),()=>g(()=>import("./pages/installation.mdx-hf-doc-builder.js"),["pages/installation.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/Tip-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js"]),()=>g(()=>import("./pages/multilingual.mdx-hf-doc-builder.js"),["pages/multilingual.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js","chunks/DocNotebookDropdown-hf-doc-builder.js"]),()=>g(()=>import("./pages/run_scripts.mdx-hf-doc-builder.js"),["pages/run_scripts.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js","chunks/Markdown-hf-doc-builder.js","chunks/IconTensorflow-hf-doc-builder.js"]),()=>g(()=>import("./pages/accelerate.mdx-hf-doc-builder.js"),["pages/accelerate.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js"]),()=>g(()=>import("./pages/debugging.mdx-hf-doc-builder.js"),["pages/debugging.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/Tip-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js"]),()=>g(()=>import("./pages/quicktour.mdx-hf-doc-builder.js"),["pages/quicktour.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/Tip-hf-doc-builder.js","chunks/Youtube-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js","chunks/DocNotebookDropdown-hf-doc-builder.js","chunks/Markdown-hf-doc-builder.js","chunks/IconTensorflow-hf-doc-builder.js"]),()=>g(()=>import("./pages/training.mdx-hf-doc-builder.js"),["pages/training.mdx-hf-doc-builder.js","chunks/vendor-hf-doc-builder.js","chunks/Tip-hf-doc-builder.js","chunks/Youtube-hf-doc-builder.js","chunks/IconCopyLink-hf-doc-builder.js","chunks/CodeBlock-hf-doc-builder.js","chunks/DocNotebookDropdown-hf-doc-builder.js","chunks/Markdown-hf-doc-builder.js","chunks/IconTensorflow-hf-doc-builder.js"])],Je=[[/^\/$/,[f[0],f[2]],[f[1]]],[/^\/converting_tensorflow_models\/?$/,[f[0],f[3]],[f[1]]],[/^\/autoclass_tutorial\/?$/,[f[0],f[4]],[f[1]]],[/^\/pipeline_tutorial\/?$/,[f[0],f[5]],[f[1]]],[/^\/add_new_pipeline\/?$/,[f[0],f[6]],[f[1]]],[/^\/create_a_model\/?$/,[f[0],f[7]],[f[1]]],[/^\/add_new_model\/?$/,[f[0],f[8]],[f[1]]],[/^\/custom_models\/?$/,[f[0],f[9]],[f[1]]],[/^\/model_sharing\/?$/,[f[0],f[10]],[f[1]]],[/^\/preprocessing\/?$/,[f[0],f[11]],[f[1]]],[/^\/serialization\/?$/,[f[0],f[12]],[f[1]]],[/^\/installation\/?$/,[f[0],f[13]],[f[1]]],[/^\/multilingual\/?$/,[f[0],f[14]],[f[1]]],[/^\/run_scripts\/?$/,[f[0],f[15]],[f[1]]],[/^\/accelerate\/?$/,[f[0],f[16]],[f[1]]],[/^\/debugging\/?$/,[f[0],f[17]],[f[1]]],[/^\/quicktour\/?$/,[f[0],f[18]],[f[1]]],[/^\/training\/?$/,[f[0],f[19]],[f[1]]]],Ke=[f[0](),f[1]()];function Be(a){let e=a.baseURI;if(!e){const t=a.getElementsByTagName("base");e=t.length?t[0].href:a.URL}return e}function We(a,e){return a==="/"||e==="ignore"?a:e==="never"?a.endsWith("/")?a.slice(0,-1):a:e==="always"&&/\/[^./]+$/.test(a)?a+"/":a}const he="sveltekit:scroll";let N={};try{N=JSON.parse(sessionStorage[he])}catch{}function M(a){N[a]=X()}function X(){return{x:pageXOffset,y:pageYOffset}}function oe(a){return a.composedPath().find(t=>t instanceof Node&&t.nodeName.toUpperCase()==="A")}function le(a){return a instanceof SVGAElement?new URL(a.href.baseVal,document.baseURI):new URL(a.href)}class Ye{constructor({base:e,routes:t,trailing_slash:r,renderer:o}){var l,s;this.base=e,this.routes=t,this.trailing_slash=r,this.navigating=0,this.renderer=o,o.router=this,this.enabled=!0,this.initialized=!1,document.body.setAttribute("tabindex","-1"),this.current_history_index=(s=(l=history.state)==null?void 0:l["sveltekit:index"])!=null?s:0,this.current_history_index===0&&history.replaceState(W(v({},history.state),{"sveltekit:index":0}),"",location.href);const i=N[this.current_history_index];i&&scrollTo(i.x,i.y),this.hash_navigating=!1,this.callbacks={before_navigate:[],after_navigate:[]}}init_listeners(){history.scrollRestoration="manual",addEventListener("beforeunload",o=>{let i=!1;const l={from:this.renderer.current.url,to:null,cancel:()=>i=!0};this.callbacks.before_navigate.forEach(s=>s(l)),i?(o.preventDefault(),o.returnValue=""):history.scrollRestoration="auto"}),addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden"){M(this.current_history_index);try{sessionStorage[he]=JSON.stringify(N)}catch{}}});const e=o=>{const i=oe(o);i&&i.href&&i.hasAttribute("sveltekit:prefetch")&&this.prefetch(le(i))};let t;const r=o=>{clearTimeout(t),t=setTimeout(()=>{var i;(i=o.target)==null||i.dispatchEvent(new CustomEvent("sveltekit:trigger_prefetch",{bubbles:!0}))},20)};addEventListener("touchstart",e),addEventListener("mousemove",r),addEventListener("sveltekit:trigger_prefetch",e),addEventListener("click",o=>{if(!this.enabled||o.button||o.which!==1||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||o.defaultPrevented)return;const i=oe(o);if(!i||!i.href)return;const l=i instanceof SVGAElement,s=le(i);if(s.toString()===location.href){location.hash||o.preventDefault();return}if(!l&&s.origin==="null")return;const c=(i.getAttribute("rel")||"").split(/\s+/);if(i.hasAttribute("download")||c&&c.includes("external")||(l?i.target.baseVal:i.target))return;const[u,d]=s.href.split("#");if(d!==void 0&&u===location.href.split("#")[0]){this.hash_navigating=!0,M(this.current_history_index),this.renderer.update_page_store(new URL(s.href));return}this._navigate({url:s,scroll:i.hasAttribute("sveltekit:noscroll")?X():null,keepfocus:!1,chain:[],details:{state:{},replaceState:!1},accepted:()=>o.preventDefault(),blocked:()=>o.preventDefault()})}),addEventListener("popstate",o=>{if(o.state&&this.enabled){if(o.state["sveltekit:index"]===this.current_history_index)return;this._navigate({url:new URL(location.href),scroll:N[o.state["sveltekit:index"]],keepfocus:!1,chain:[],details:null,accepted:()=>{this.current_history_index=o.state["sveltekit:index"]},blocked:()=>{const i=this.current_history_index-o.state["sveltekit:index"];history.go(i)}})}}),addEventListener("hashchange",()=>{this.hash_navigating&&(this.hash_navigating=!1,history.replaceState(W(v({},history.state),{"sveltekit:index":++this.current_history_index}),"",location.href))}),this.initialized=!0}owns(e){return e.origin===location.origin&&e.pathname.startsWith(this.base)}parse(e){if(this.owns(e)){const t=decodeURI(e.pathname.slice(this.base.length)||"/");return{id:e.pathname+e.search,routes:this.routes.filter(([r])=>r.test(t)),url:e,path:t,initial:!this.initialized}}}async goto(e,{noscroll:t=!1,replaceState:r=!1,keepfocus:o=!1,state:i={}}={},l){const s=new URL(e,Be(document));return this.enabled?this._navigate({url:s,scroll:t?X():null,keepfocus:o,chain:l,details:{state:i,replaceState:r},accepted:()=>{},blocked:()=>{}}):(location.href=s.href,new Promise(()=>{}))}enable(){this.enabled=!0}disable(){this.enabled=!1}async prefetch(e){const t=this.parse(e);if(!t)throw new Error("Attempted to prefetch a URL that does not belong to this app");return this.renderer.load(t)}after_navigate(e){F(()=>(this.callbacks.after_navigate.push(e),()=>{const t=this.callbacks.after_navigate.indexOf(e);this.callbacks.after_navigate.splice(t,1)}))}before_navigate(e){F(()=>(this.callbacks.before_navigate.push(e),()=>{const t=this.callbacks.before_navigate.indexOf(e);this.callbacks.before_navigate.splice(t,1)}))}async _navigate({url:e,scroll:t,keepfocus:r,chain:o,details:i,accepted:l,blocked:s}){const n=this.renderer.current.url;let c=!1;const u={from:n,to:e,cancel:()=>c=!0};if(this.callbacks.before_navigate.forEach(p=>p(u)),c){s();return}const d=this.parse(e);if(!d)return location.href=e.href,new Promise(()=>{});M(this.current_history_index),l(),this.navigating++;const h=We(e.pathname,this.trailing_slash);d.url=new URL(e.origin+h+e.search+e.hash);const _=this.navigating_token={};if(await this.renderer.handle_navigation(d,o,!1,{scroll:t,keepfocus:r}),this.navigating--,this.navigating_token===_){if(!this.navigating){const p={from:n,to:e};this.callbacks.after_navigate.forEach(V=>V(p))}if(i){const p=i.replaceState?0:1;i.state["sveltekit:index"]=this.current_history_index+=p,history[i.replaceState?"replaceState":"pushState"](i.state,"",d.url)}}}}function ce(a){return a instanceof Error||a&&a.name&&a.message?a:new Error(JSON.stringify(a))}function Ge(a){let e=5381,t=a.length;if(typeof a=="string")for(;t;)e=e*33^a.charCodeAt(--t);else for(;t;)e=e*33^a[--t];return(e>>>0).toString(36)}function ue(a){const e=a.status&&a.status>=400&&a.status<=599&&!a.redirect;if(a.error||e){const t=a.status;if(!a.error&&e)return{status:t||500,error:new Error};const r=typeof a.error=="string"?new Error(a.error):a.error;return r instanceof Error?!t||t<400||t>599?(console.warn('"error" returned from load() without a valid status code \u2014 defaulting to 500'),{status:500,error:r}):{status:t,error:r}:{status:500,error:new Error(`"error" property returned from load() must be a string or instance of Error, received type "${typeof r}"`)}}if(a.redirect){if(!a.status||Math.floor(a.status/100)!==3)return{status:500,error:new Error('"redirect" property returned from load() must be accompanied by a 3xx status code')};if(typeof a.redirect!="string")return{status:500,error:new Error('"redirect" property returned from load() must be a string')}}if(a.context)throw new Error('You are returning "context" from a load function. "context" was renamed to "stuff", please adjust your code accordingly.');return a}function fe(a){const e=Y(a);let t=!0;function r(){t=!0,e.update(l=>l)}function o(l){t=!1,e.set(l)}function i(l){let s;return e.subscribe(n=>{(s===void 0||t&&n!==s)&&l(s=n)})}return{notify:r,set:o,subscribe:i}}function Me(){const{set:a,subscribe:e}=Y(!1),t="1666829721122";let r;async function o(){clearTimeout(r);const l=await fetch(`${Pe}/_app/version.json`,{headers:{pragma:"no-cache","cache-control":"no-cache"}});if(l.ok){const{version:s}=await l.json(),n=s!==t;return n&&(a(!0),clearTimeout(r)),n}else throw new Error(`Version check failed: ${l.status}`)}return{subscribe:e,check:o}}function Fe(a,e){const t=typeof a=="string"?a:a.url;let r=`script[data-type="svelte-data"][data-url=${JSON.stringify(t)}]`;e&&typeof e.body=="string"&&(r+=`[data-body="${Ge(e.body)}"]`);const o=document.querySelector(r);if(o&&o.textContent){const i=JSON.parse(o.textContent),{body:l}=i,s=se(i,["body"]);return Promise.resolve(new Response(l,s))}return fetch(a,e)}class Xe{constructor({Root:e,fallback:t,target:r,session:o}){this.Root=e,this.fallback=t,this.router,this.target=r,this.started=!1,this.session_id=1,this.invalid=new Set,this.invalidating=null,this.autoscroll=!0,this.updating=!1,this.current={url:null,session_id:0,branch:[]},this.cache=new Map,this.loading={id:null,promise:null},this.stores={url:fe({}),page:fe({}),navigating:Y(null),session:Y(o),updated:Me()},this.$session=null,this.root=null;let i=!1;this.stores.session.subscribe(async l=>{if(this.$session=l,!i||!this.router)return;this.session_id+=1;const s=this.router.parse(new URL(location.href));s&&this.update(s,[],!0)}),i=!0}disable_scroll_handling(){(this.updating||!this.started)&&(this.autoscroll=!1)}async start({status:e,error:t,nodes:r,params:o}){const i=new URL(location.href),l=[];let s={},n,c;try{for(let u=0;u<r.length;u+=1){const d=u===r.length-1;let h;if(d){const p=document.querySelector('[data-type="svelte-props"]');p&&(h=JSON.parse(p.textContent))}const _=await this._load_node({module:await r[u],url:i,params:o,stuff:s,status:d?e:void 0,error:d?t:void 0,props:h});if(h&&(_.uses.dependencies.add(i.href),_.uses.url=!0),l.push(_),_&&_.loaded)if(_.loaded.error){if(t)throw _.loaded.error;c={status:_.loaded.status,error:_.loaded.error,url:i}}else _.loaded.stuff&&(s=v(v({},s),_.loaded.stuff))}n=c?await this._load_error(c):await this._get_navigation_result_from_branch({url:i,params:o,stuff:s,branch:l,status:e,error:t})}catch(u){if(t)throw u;n=await this._load_error({status:500,error:ce(u),url:i})}if(n.redirect){location.href=new URL(n.redirect,location.href).href;return}this._init(n)}async handle_navigation(e,t,r,o){this.started&&this.stores.navigating.set({from:this.current.url,to:e.url}),await this.update(e,t,r,o)}async update(e,t,r,o){var n,c,u;const i=this.token={};let l=await this._get_navigation_result(e,r);if(!l){location.href=e.url.href;return}if(i!==this.token)return;if(this.invalid.clear(),l.redirect)if(t.length>10||t.includes(e.url.pathname))l=await this._load_error({status:500,error:new Error("Redirect loop"),url:e.url});else{this.router?this.router.goto(new URL(l.redirect,e.url).href,{},[...t,e.url.pathname]):location.href=new URL(l.redirect,location.href).href;return}else if(((c=(n=l.props)==null?void 0:n.page)==null?void 0:c.status)>=400&&await this.stores.updated.check()){location.href=e.url.href;return}if(this.updating=!0,this.started?(this.current=l.state,this.root.$set(l.props),this.stores.navigating.set(null)):this._init(l),o){const{scroll:d,keepfocus:h}=o;if(h||((u=getSelection())==null||u.removeAllRanges(),document.body.focus()),await re(),this.autoscroll){const _=e.url.hash&&document.getElementById(e.url.hash.slice(1));d?scrollTo(d.x,d.y):_?_.scrollIntoView():scrollTo(0,0)}}else await re();if(this.loading.promise=null,this.loading.id=null,this.autoscroll=!0,this.updating=!1,l.props.page&&(this.page=l.props.page),!this.router)return;const s=l.state.branch[l.state.branch.length-1];s&&s.module.router===!1?this.router.disable():this.router.enable()}load(e){return this.loading.promise=this._get_navigation_result(e,!1),this.loading.id=e.id,this.loading.promise}invalidate(e){return this.invalid.add(e),this.invalidating||(this.invalidating=Promise.resolve().then(async()=>{const t=this.router&&this.router.parse(new URL(location.href));t&&await this.update(t,[],!0),this.invalidating=null})),this.invalidating}update_page_store(e){this.stores.page.set(W(v({},this.page),{url:e})),this.stores.page.notify()}_init(e){this.current=e.state;const t=document.querySelector("style[data-svelte]");if(t&&t.remove(),this.page=e.props.page,this.root=new this.Root({target:this.target,props:v({stores:this.stores},e.props),hydrate:!0}),this.started=!0,this.router){const r={from:null,to:new URL(location.href)};this.router.callbacks.after_navigate.forEach(o=>o(r))}}async _get_navigation_result(e,t){if(this.loading.id===e.id&&this.loading.promise)return this.loading.promise;for(let r=0;r<e.routes.length;r+=1){const o=e.routes[r];let i=r+1;for(;i<e.routes.length;){const s=e.routes[i];if(s[0].toString()===o[0].toString())s[1].forEach(n=>n()),i+=1;else break}const l=await this._load({route:o,info:e},t);if(l)return l}if(e.initial)return await this._load_error({status:404,error:new Error(`Not found: ${e.url.pathname}`),url:e.url})}async _get_navigation_result_from_branch({url:e,params:t,stuff:r,branch:o,status:i,error:l}){const s=o.filter(Boolean),n=s.find(h=>h.loaded&&h.loaded.redirect),c={redirect:n&&n.loaded?n.loaded.redirect:void 0,state:{url:e,params:t,branch:o,session_id:this.session_id},props:{components:s.map(h=>h.module.default)}};for(let h=0;h<s.length;h+=1){const _=s[h].loaded;c.props[`props_${h}`]=_?await _.props:null}if(!this.current.url||e.href!==this.current.url.href){c.props.page={url:e,params:t,status:i,error:l,stuff:r};const h=(_,p)=>{Object.defineProperty(c.props.page,_,{get:()=>{throw new Error(`$page.${_} has been replaced by $page.url.${p}`)}})};h("origin","origin"),h("path","pathname"),h("query","searchParams")}const u=s[s.length-1],d=u.loaded&&u.loaded.maxage;if(d){const h=e.pathname+e.search;let _=!1;const p=()=>{this.cache.get(h)===c&&this.cache.delete(h),L(),clearTimeout(V)},V=setTimeout(p,d*1e3),L=this.stores.session.subscribe(()=>{_&&p()});_=!0,this.cache.set(h,c)}return c}async _load_node({status:e,error:t,module:r,url:o,params:i,stuff:l,props:s}){const n={module:r,uses:{params:new Set,url:!1,session:!1,stuff:!1,dependencies:new Set},loaded:null,stuff:l};s&&n.uses.dependencies.add(o.href);const c={};for(const d in i)Object.defineProperty(c,d,{get(){return n.uses.params.add(d),i[d]},enumerable:!0});const u=this.$session;if(r.load){const{started:d}=this,h={params:c,props:s||{},get url(){return n.uses.url=!0,o},get session(){return n.uses.session=!0,u},get stuff(){return n.uses.stuff=!0,v({},l)},fetch(p,V){const L=typeof p=="string"?p:p.url,{href:O}=new URL(L,o);return n.uses.dependencies.add(O),d?fetch(p,V):Fe(p,V)}};t&&(h.status=e,h.error=t);const _=await r.load.call(null,h);if(!_)throw new Error("load function must return a value");n.loaded=ue(_),n.loaded.stuff&&(n.stuff=n.loaded.stuff)}else s&&(n.loaded=ue({props:s}));return n}async _load({route:e,info:{url:t,path:r}},o){const i=t.pathname+t.search;if(!o){const m=this.cache.get(i);if(m)return m}const[l,s,n,c,u]=e,d=c?c(l.exec(r)):{},h=this.current.url&&{url:i!==this.current.url.pathname+this.current.url.search,params:Object.keys(d).filter(m=>this.current.params[m]!==d[m]),session:this.session_id!==this.current.session_id};let _=[],p={},V=!1,L=200,O;s.forEach(m=>m());e:for(let m=0;m<s.length;m+=1){let w;try{if(!s[m])continue;const b=await s[m](),$=this.current.branch[m];if(!$||b!==$.module||h.url&&$.uses.url||h.params.some(D=>$.uses.params.has(D))||h.session&&$.uses.session||Array.from($.uses.dependencies).some(D=>this.invalid.has(D))||V&&$.uses.stuff){let D={};const H=u&&m===s.length-1;if(H){const K=await fetch(`${t.pathname}${t.pathname.endsWith("/")?"":"/"}__data.json${t.search}`,{headers:{"x-sveltekit-load":"true"}});if(K.ok){const Q=K.headers.get("x-sveltekit-location");if(Q)return{redirect:Q,props:{},state:this.current};D=await K.json()}else L=K.status,O=new Error("Failed to load data")}if(O||(w=await this._load_node({module:b,url:t,params:d,props:D,stuff:p})),w&&(H&&(w.uses.url=!0),w.loaded)){if(w.loaded.fallthrough)return;if(w.loaded.error&&(L=w.loaded.status,O=w.loaded.error),w.loaded.redirect)return{redirect:w.loaded.redirect,props:{},state:this.current};w.loaded.stuff&&(V=!0)}}else w=$}catch(b){L=500,O=ce(b)}if(O){for(;m--;)if(n[m]){let b,$,J=m;for(;!($=_[J]);)J-=1;try{if(b=await this._load_node({status:L,error:O,module:await n[m](),url:t,params:d,stuff:$.stuff}),b&&b.loaded&&b.loaded.error)continue;b&&b.loaded&&b.loaded.stuff&&(p=v(v({},p),b.loaded.stuff)),_=_.slice(0,J+1).concat(b);break e}catch{continue}}return await this._load_error({status:L,error:O,url:t})}else w&&w.loaded&&w.loaded.stuff&&(p=v(v({},p),w.loaded.stuff)),_.push(w)}return await this._get_navigation_result_from_branch({url:t,params:d,stuff:p,branch:_,status:L,error:O})}async _load_error({status:e,error:t,url:r}){var c,u;const o={},i=await this._load_node({module:await this.fallback[0],url:r,params:o,stuff:{}}),l=await this._load_node({status:e,error:t,module:await this.fallback[1],url:r,params:o,stuff:i&&i.loaded&&i.loaded.stuff||{}}),s=[i,l],n=v(v({},(c=i==null?void 0:i.loaded)==null?void 0:c.stuff),(u=l==null?void 0:l.loaded)==null?void 0:u.stuff);return await this._get_navigation_result_from_branch({url:r,params:o,stuff:n,branch:s,status:e,error:t})}}async function et({paths:a,target:e,session:t,route:r,spa:o,trailing_slash:i,hydrate:l}){const s=new Xe({Root:je,fallback:Ke,target:e,session:t}),n=r?new Ye({base:a.base,routes:Je,trailing_slash:i,renderer:s}):null;Ae(a),l&&await s.start(l),n&&(o&&n.goto(location.href,{replaceState:!0},[]),n.init_listeners()),dispatchEvent(new CustomEvent("sveltekit:start"))}export{et as start};
