// אירוע פרוע - מתקין (3.0.0). מדביקים את כל הקוד הזה ב-Worker חדש, לוחצים Deploy ופותחים את כתובת ה-Worker. // Eirua Parua installer. (c) Ohad Shpindel (ShpatzAppZ). Free license, not open source: https://get.shpatzappz.link/license var N={k1:"g04vKKBOed34K-d8EUQrk4zqg8qauid9yLW5dLjZkSA",k2:"3soNL1IJDjW-ZE0fhuykcwbeDjzsBTGSY0An86_67ZI",k3:"TTna6LfJZlJbmTXwonWR60OeGFmJk9LXkazprkIZT4c"};var D=new TextEncoder;function z(e){let n=atob(e.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((e.length+3)%4)),t=new Uint8Array(n.length);for(let r=0;rr.toString(16).padStart(2,"0")).join("")}var M=new Map;function fe(e){let n=M.get(e);return n||(n=crypto.subtle.importKey("raw",z(e),{name:"Ed25519"},!1,["verify"]),M.set(e,n)),n}var u=class extends Error{constructor(t,r){super(r||t);this.code=t}code};async function I(e,n=N){let t;try{t=JSON.parse(e)}catch{throw new u("bad_format")}if(!t||typeof t.payload!="string"||!Array.isArray(t.sigs))throw new u("bad_format");let r=D.encode(t.payload),s=!1;for(let a of t.sigs.slice(0,4)){let i=a&&typeof a.key=="string"?n[a.key]:void 0;if(!(!i||typeof a.sig!="string"))try{if(await crypto.subtle.verify({name:"Ed25519"},await fe(i),z(a.sig),r)){s=!0;break}}catch{}}if(!s)throw new u("bad_signature");try{return JSON.parse(t.payload)}catch{throw new u("bad_format")}}var ge=/^\d{1,6}\.\d{1,6}\.\d{1,6}$/,K=/^[0-9a-f]{64}$/,he=/^[0-9a-f]{32}$/,$=/^[a-z]\/[A-Za-z0-9._-]{1,120}$/;function H(e){if(!e||e.schema!==2||!e.latest||!ge.test(e.latest.version)||!$.test(e.latest.manifest)||!K.test(e.latest.sha256))throw new u("bad_format","feed");return e}function G(e,n){let t=s=>new u("bad_format",`manifest: ${s}`);if(!e||e.schema!==1)throw new u("unsupported","manifest schema");if(e.version!==n)throw t("version");let r=e.worker;if(!r||!Array.isArray(r.modules)||!r.modules.length||!r.modules.some(s=>s.name===r.main))throw t("worker");for(let s of r.modules)if(!/^[A-Za-z0-9._-]{1,80}\.m?js$/.test(s.name)||!K.test(s.sha256)||!$.test(s.url))throw t("module");if(!e.assets||typeof e.assets.files!="object")throw t("assets");for(let[s,a]of Object.entries(e.assets.files)){if(!s.startsWith("/")||s.includes("..")||!he.test(a.hash))throw t(`asset ${s}`);let i=a.at;if(i.f!==void 0?!$.test(i.f):!(i.p&&$.test(i.p)&&Number.isInteger(i.o)&&Number.isInteger(i.l)))throw t(`asset location ${s}`)}if(!Array.isArray(e.crons)||!Array.isArray(e.bindings))throw t("settings");return e}var J="https://api.cloudflare.com/client/v4",y=class extends Error{constructor(t,r,s){super(s);this.status=t;this.cfCode=r}status;cfCode;get refused(){return this.status===401||this.status===403||this.cfCode===1e4||this.cfCode===9109}};async function m(e,n,t,r){let s={Authorization:`Bearer ${e}`},a;r instanceof FormData?a=r:r!==void 0&&(s["Content-Type"]="application/json",a=JSON.stringify(r));let i=await fetch(`${J}${t}`,{method:n,headers:s,body:a,signal:AbortSignal.timeout(6e4)}),d=await i.json().catch(()=>null);if(!i.ok||!d||d.success===!1){let c=d?.errors?.[0];throw new y(i.status,c?.code??null,`${n} ${t.replace(/\/accounts\/[^/]+/,"/accounts/\u2026")}: ${i.status} ${c?.message||""}`.trim())}return d.result}var C=e=>`/accounts/${encodeURIComponent(e.accountId)}`,b=e=>`${C(e)}/workers/scripts/${encodeURIComponent(e.script)}`;async function W(e){return(await m(e,"GET","/accounts?per_page=50")).map(t=>({id:t.id,name:t.name}))}async function V(e){return(await m(e.token,"GET",`${C(e)}/workers/subdomain`)).subdomain}async function S(e){return((await m(e.token,"GET",`${b(e)}/settings`)).bindings||[]).map(t=>({name:t.name,type:t.type}))}async function Z(e,n){let r=(await m(e.token,"GET",`${C(e)}/d1/database?name=${encodeURIComponent(n)}`)).find(a=>a.name===n);return r?r.uuid:(await m(e.token,"POST",`${C(e)}/d1/database`,{name:n})).uuid}async function q(e,n){await m(e.token,"PUT",`${b(e)}/schedules`,n.map(t=>({cron:t})))}async function Y(e){await m(e.token,"POST",`${b(e)}/subdomain`,{enabled:!0,previews_enabled:!1})}async function X(e,n){await m(e.token,"PATCH",`${b(e)}/script-settings`,{observability:{enabled:n}})}async function Q(e,n,t){await m(e.token,"POST",`${b(e)}/deployments?force=true`,{strategy:"percentage",versions:[{version_id:n,percentage:100}],annotations:{"workers/message":t.slice(0,100)}})}async function P(e){let n=await fetch(e,{signal:AbortSignal.timeout(2e4),headers:{"User-Agent":"eirua-parua-site"}});if(!n.ok)throw new Error(`HTTP ${n.status} ${new URL(e).pathname}`);return n.text()}async function ee(e,n){return H(await I(await P(`${e}${n}.json`)))}async function T(e,n){if(!/^\d{1,6}\.\d{1,6}\.\d{1,6}$/.test(n))throw new u("bad_format","version");return G(await I(await P(`${e}m/${n}.json`)),n)}function j(e){let n=/^([a-z0-9-]+)\.([a-z0-9-]+)\.workers\.dev$/.exec(e.toLowerCase());return n?{script:n[1],subdomain:n[2]}:null}async function te(e,n){let t=[];for(let r of n.worker.modules){let s=await P(`${e}${r.url}`);if(await F(s)!==r.sha256)throw new u("bad_hash",r.name);t.push({name:r.name,text:s})}return t}async function ne(e,n){let t={};for(let[s,a]of Object.entries(n.assets.files))t[s]={hash:a.hash,size:a.size};let r=await m(e.token,"POST",`${b(e)}/assets-upload-session`,{manifest:t});return{jwt:r.jwt,buckets:r.buckets||[]}}async function se(e,n,t,r,s){let a=new Map;for(let l of Object.values(t.assets.files))a.has(l.hash)||a.set(l.hash,{at:l.at,ct:l.ct});let i=new Map,d=0,c=r.jwt,o=[...r.buckets];for(;o.length;){let l=o[0],f=new Set,B=0;for(let w of l){let g=a.get(w);if(!g)throw new u("bad_format",`unknown asset ${w}`);"p"in g.at?i.has(g.at.p)||f.add(g.at.p):B++}let O=f.size+B+1;if(d>0&&d+O>s)break;d+=O;let L=new FormData;for(let w of l){let g=a.get(w),R;if("p"in g.at){let h=g.at,_=i.get(h.p);_||(_=fetch(`${n}${h.p}`,{signal:AbortSignal.timeout(6e4)}).then(A=>{if(!A.ok)throw new Error(`HTTP ${A.status} ${h.p}`);return A.arrayBuffer()}),i.set(h.p,_)),R=new Blob([(await _).slice(h.o,h.o+h.l)],{type:g.ct})}else{let h=await fetch(`${n}${g.at.f}`,{signal:AbortSignal.timeout(6e4)});if(!h.ok)throw new Error(`HTTP ${h.status} ${g.at.f}`);R=new Blob([await h.arrayBuffer()],{type:g.ct})}L.append(w,new File([R],w,{type:g.ct}))}let x=await fetch(`${J}/accounts/${encodeURIComponent(e.accountId)}/workers/assets/upload?base64=true`,{method:"POST",headers:{Authorization:`Bearer ${r.jwt}`},body:L,signal:AbortSignal.timeout(12e4)}),v=await x.json().catch(()=>null);if(!x.ok||!v?.success)throw new y(x.status,null,`assets upload: ${x.status} ${v?.errors?.[0]?.message||""}`.trim());o.shift(),v.result?.jwt&&(c=v.result.jwt)}return{jwt:c,buckets:o}}var me=e=>btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function be(e){return me(crypto.getRandomValues(new Uint8Array(e==="key32"?32:18)))}function re(e,n,t={}){let r=new Set(n.map(o=>o.name)),s=[],a={},i=[],d=new Set,c=o=>{d.has(o.name)||(d.add(o.name),s.push(o))};for(let[o,l]of Object.entries(t.secrets||{}))c({type:"secret_text",name:o,text:l});for(let[o,l]of Object.entries(t.plain||{}))c({type:"plain_text",name:o,text:l});for(let o of e)if(o.type==="assets")c({type:"assets",name:o.name});else if(r.has(o.name))c({type:"inherit",name:o.name});else if(o.type==="d1")t.d1Id?c({type:"d1",name:o.name,id:t.d1Id}):i.push(o.name);else if(o.type==="secret_text"){let l=be(o.generate);a[o.name]=l,c({type:"secret_text",name:o.name,text:l})}for(let o of n)o.type!=="assets"&&c({type:"inherit",name:o.name});return{bindings:s,created:a,missingDb:i}}async function ae(e,n,t,r,s){let a={main_module:n.worker.main,compatibility_date:n.worker.compatibility_date,compatibility_flags:n.worker.compatibility_flags,bindings:r,assets:{jwt:s,config:n.assets.config},annotations:{"workers/message":`\u05D0\u05D9\u05E8\u05D5\u05E2 \u05E4\u05E8\u05D5\u05E2 ${n.version}`,"workers/tag":`v${n.version}`}},i=new FormData;i.append("metadata",new Blob([JSON.stringify(a)],{type:"application/json"}));for(let c of t)i.append(c.name,new File([c.text],c.name,{type:"application/javascript+module"}));return(await m(e.token,"POST",`${b(e)}/versions?bindings_inherit=strict`,i)).id}var k="https://get.shpatzappz.link",we="https://ohad-shpindel.shpatzappz.link",Ie=`${we}/#contact`,oe=`${k}/`,ie=`${k}/license`,ce=`${k}/support`,ye=[{key:"workers_scripts",type:"edit"},{key:"d1",type:"edit"}];function de(e="eirua-parua-updates"){return`https://dash.cloudflare.com/?to=/:account/api-tokens&permissionGroupKeys=${encodeURIComponent(JSON.stringify(ye))}&name=${encodeURIComponent(e)}`}var ke=` :root{--fg:#09090b;--muted:#52525b;--bg:#fafafa;--card:#fff;--border:#e4e4e7;--primary:#18181b;--ok:#15803d;--warn:#b45309;--err:#b91c1c;--brand:#3b1d5e} *{box-sizing:border-box} body{margin:0;background:radial-gradient(90% 60% at 100% 0%,#ede9fe,transparent 60%),linear-gradient(180deg,#fafafa,#f4f4f5);color:var(--fg);font:16px/1.6 system-ui,-apple-system,"Segoe UI",Heebo,Arial,sans-serif;min-height:100vh} main{max-width:640px;margin:0 auto;padding:32px 20px 64px} h1{font-size:1.75rem;line-height:1.25;margin:0 0 4px} h2{font-size:1.15rem;margin:0 0 8px;display:flex;gap:10px;align-items:center} .brand{display:inline-block;font-weight:900;font-size:2rem;color:var(--brand);transform:rotate(-2deg);text-shadow:.03em 0 0 #fff,-.03em 0 0 #fff,0 .03em 0 #fff,0 -.03em 0 #fff,.06em .07em 0 #d8c0d8;margin-bottom:8px} .lead{color:var(--muted);margin:0 0 24px} .card{background:var(--card);border:1px solid var(--border);border-radius:16px;padding:20px;margin:16px 0;box-shadow:0 1px 2px rgba(0,0,0,.05)} .num{flex:none;width:28px;height:28px;border-radius:50%;background:var(--primary);color:#fff;display:inline-grid;place-items:center;font-size:.9rem} ul,ol{margin:8px 0;padding-inline-start:22px} li{margin:4px 0} a{color:#4c1d95} .muted{color:var(--muted);font-size:.95rem} label.check{display:flex;gap:10px;align-items:flex-start;min-height:44px;padding:8px 0;cursor:pointer;font-weight:600} input[type=checkbox]{width:22px;height:22px;margin-top:2px;flex:none;accent-color:var(--primary)} .field{display:block;font-weight:600;margin:12px 0 6px} input[type=password],input[type=text],select{width:100%;min-height:48px;padding:10px 14px;border:1px solid #d4d4d8;border-radius:10px;font:inherit;background:#fff;direction:ltr;text-align:left} input:focus-visible,select:focus-visible,button:focus-visible,a:focus-visible{outline:3px solid #8b5cf6;outline-offset:2px} .btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:48px;padding:10px 20px;border-radius:12px;border:1px solid var(--primary);background:var(--primary);color:#fff;font:inherit;font-weight:700;cursor:pointer;text-decoration:none} .btn.secondary{background:#fff;color:var(--primary)} .btn[disabled]{opacity:.45;cursor:not-allowed} .row{display:flex;gap:10px;flex-wrap:wrap;align-items:center} .wide{width:100%} .err{color:var(--err);font-weight:600;margin:10px 0 0} .note{background:#fffbeb;border:1px solid #fde68a;border-radius:12px;padding:12px 14px;margin:12px 0;color:#78350f} .steps{list-style:none;padding:0;margin:0} .steps li{display:flex;gap:10px;align-items:center;min-height:36px;color:var(--muted)} .steps li .ic{width:22px;height:22px;flex:none;border-radius:50%;border:2px solid #d4d4d8} .steps li.run{color:var(--fg);font-weight:600} .steps li.run .ic{border-color:var(--primary);border-top-color:transparent;animation:spin 1s linear infinite} .steps li.ok{color:var(--fg)} .steps li.ok .ic{border-color:var(--ok);background:var(--ok);box-shadow:inset 0 0 0 3px #fff} .steps li.bad{color:var(--err);font-weight:600} .steps li.bad .ic{border-color:var(--err);background:var(--err);box-shadow:inset 0 0 0 3px #fff} @keyframes spin{to{transform:rotate(360deg)}} @media (prefers-reduced-motion:reduce){.steps li.run .ic{animation:none;border-top-color:var(--primary)}} .secret{display:flex;gap:8px;align-items:stretch;margin:6px 0 14px} .secret code{flex:1;min-width:0;direction:ltr;text-align:left;background:#f4f4f5;border:1px solid var(--border);border-radius:10px;padding:12px;font:15px/1.4 ui-monospace,Menlo,Consolas,monospace;overflow-wrap:anywhere} .done h2{color:var(--ok)} [hidden]{display:none!important} .sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)} footer{color:var(--muted);font-size:.85rem;margin-top:32px;text-align:center} `,xe=` (function(){ var $=function(id){return document.getElementById(id)}; var state={}; var ERR={ bad_token:"\u05D4\u05D8\u05D5\u05E7\u05DF \u05DC\u05D0 \u05E0\u05E8\u05D0\u05D4 \u05EA\u05E7\u05D9\u05DF. \u05D4\u05E2\u05EA\u05D9\u05E7\u05D5 \u05D0\u05D5\u05EA\u05D5 \u05E9\u05D5\u05D1 \u05DE-Cloudflare (\u05DB\u05E4\u05EA\u05D5\u05E8 Copy) \u05D5\u05D4\u05D3\u05D1\u05D9\u05E7\u05D5 \u05DB\u05D0\u05DF.", token_refused:"Cloudflare \u05DC\u05D0 \u05D0\u05D9\u05E9\u05E8\u05D4 \u05D0\u05EA \u05D4\u05D8\u05D5\u05E7\u05DF. \u05E6\u05E8\u05D5 \u05D8\u05D5\u05E7\u05DF \u05D7\u05D3\u05E9 \u05DE\u05D4\u05DB\u05E4\u05EA\u05D5\u05E8 \\"\u05D9\u05E6\u05D9\u05E8\u05EA \u05D8\u05D5\u05E7\u05DF \u05D1-Cloudflare\\" (\u05E2\u05DD \u05E9\u05EA\u05D9 \u05D4\u05D4\u05E8\u05E9\u05D0\u05D5\u05EA \u05E9\u05DB\u05D1\u05E8 \u05DE\u05E1\u05D5\u05DE\u05E0\u05D5\u05EA \u05E9\u05DD).", no_d1:"\u05DC\u05D8\u05D5\u05E7\u05DF \u05D7\u05E1\u05E8\u05D4 \u05D4\u05D4\u05E8\u05E9\u05D0\u05D4 \u05DC\u05D9\u05E6\u05D5\u05E8 \u05DE\u05E1\u05D3 \u05E0\u05EA\u05D5\u05E0\u05D9\u05DD (D1: Edit). \u05E6\u05E8\u05D5 \u05D8\u05D5\u05E7\u05DF \u05D7\u05D3\u05E9 \u05DE\u05D4\u05DB\u05E4\u05EA\u05D5\u05E8 \u05DC\u05DE\u05E2\u05DC\u05D4.", other_account:"\u05D4\u05D8\u05D5\u05E7\u05DF \u05E9\u05D9\u05D9\u05DA \u05DC\u05D7\u05E9\u05D1\u05D5\u05DF Cloudflare \u05D0\u05D7\u05E8 \u05DE\u05D6\u05D4 \u05E9\u05D4-Worker \u05D4\u05D6\u05D4 \u05E0\u05DE\u05E6\u05D0 \u05D1\u05D5. \u05E6\u05E8\u05D5 \u05D8\u05D5\u05E7\u05DF \u05DE\u05EA\u05D5\u05DA \u05D0\u05D5\u05EA\u05D5 \u05D7\u05E9\u05D1\u05D5\u05DF.", wrong_host:"\u05E4\u05EA\u05D7\u05D5 \u05D0\u05EA \u05D4\u05D3\u05E3 \u05D4\u05D6\u05D4 \u05D1\u05DB\u05EA\u05D5\u05D1\u05EA workers.dev \u05E9\u05DC \u05D4-Worker (\u05DC\u05DE\u05E9\u05DC albums.\u05D4\u05E9\u05DD-\u05E9\u05DC\u05DB\u05DD.workers.dev), \u05D5\u05DC\u05D0 \u05D1\u05D3\u05D5\u05DE\u05D9\u05D9\u05DF \u05D0\u05D7\u05E8.", bad_account:"\u05D1\u05D7\u05E8\u05D5 \u05D0\u05EA \u05D4\u05D7\u05E9\u05D1\u05D5\u05DF \u05E9\u05D1\u05D5 \u05E0\u05DE\u05E6\u05D0 \u05D4-Worker.", release:"\u05DC\u05D0 \u05D4\u05E6\u05DC\u05D7\u05E0\u05D5 \u05DC\u05D4\u05D5\u05E8\u05D9\u05D3 \u05D0\u05EA \u05D4\u05D2\u05E8\u05E1\u05D4. \u05E0\u05E1\u05D5 \u05E9\u05D5\u05D1 \u05D1\u05E2\u05D5\u05D3 \u05DB\u05DE\u05D4 \u05D3\u05E7\u05D5\u05EA.", bad_signature:"\u05D4\u05D2\u05E8\u05E1\u05D4 \u05E9\u05D4\u05D5\u05E8\u05D3\u05D4 \u05DC\u05D0 \u05D7\u05EA\u05D5\u05DE\u05D4 \u05E2\u05DC \u05D9\u05D3\u05D9 \u05DE\u05E4\u05EA\u05D7 \u05D4\u05EA\u05D5\u05DB\u05E0\u05D4, \u05D5\u05DC\u05DB\u05DF \u05DC\u05D0 \u05D4\u05D5\u05EA\u05E7\u05E0\u05D4. \u05E0\u05E1\u05D5 \u05E9\u05D5\u05D1 \u05DE\u05D0\u05D5\u05D7\u05E8 \u05D9\u05D5\u05EA\u05E8.", no_database:"\u05DC\u05D0 \u05E0\u05DE\u05E6\u05D0 \u05DE\u05E1\u05D3 \u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD \u05E9\u05DC \u05D4\u05D0\u05EA\u05E8. \u05E0\u05E1\u05D5 \u05DC\u05D4\u05EA\u05E7\u05D9\u05DF \u05E9\u05D5\u05D1.", lost_db:"\u05D6\u05D4 \u05D0\u05EA\u05E8 \u05E7\u05D9\u05D9\u05DD, \u05D0\u05D1\u05DC \u05D4\u05D5\u05D0 \u05DB\u05D1\u05E8 \u05DC\u05D0 \u05DE\u05D7\u05D5\u05D1\u05E8 \u05DC\u05DE\u05E1\u05D3 \u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD \u05E9\u05DC\u05D5. \u05D1-Cloudflare, \u05D1\u05D3\u05E3 \u05D4-Worker: Settings \u05D5\u05D0\u05D6 Bindings, \u05DE\u05D7\u05D1\u05E8\u05D9\u05DD \u05E9\u05D5\u05D1 \u05D0\u05EA \u05DE\u05E1\u05D3 \u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD (D1) \u05D1\u05E9\u05DD DB, \u05D5\u05D0\u05D6 \u05DE\u05E0\u05E1\u05D9\u05DD \u05E9\u05D5\u05D1. \u05DB\u05DA \u05D4\u05DE\u05D9\u05D3\u05E2 \u05E9\u05DC \u05D4\u05D0\u05EA\u05E8 \u05E0\u05E9\u05DE\u05E8.", cloudflare:"Cloudflare \u05D4\u05D7\u05D6\u05D9\u05E8\u05D4 \u05E9\u05D2\u05D9\u05D0\u05D4. \u05E0\u05E1\u05D5 \u05E9\u05D5\u05D1 \u05D1\u05E2\u05D5\u05D3 \u05D3\u05E7\u05D4.", network:"\u05D4\u05D7\u05D9\u05D1\u05D5\u05E8 \u05E0\u05E7\u05D8\u05E2. \u05E0\u05E1\u05D5 \u05E9\u05D5\u05D1.", bad_request:"\u05DE\u05E9\u05D4\u05D5 \u05D4\u05E9\u05EA\u05D1\u05E9. \u05E8\u05E2\u05E0\u05E0\u05D5 \u05D0\u05EA \u05D4\u05D3\u05E3 \u05D5\u05E0\u05E1\u05D5 \u05E9\u05D5\u05D1." }; function msg(code){return ERR[code]||ERR.network} async function call(body){ var r=await fetch("/__install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(body)}); var j=await r.json().catch(function(){return {error:"network"}}); if(!r.ok||j.error){var e=new Error(j.error||"network");e.code=j.error||"network";throw e} return j; } function setStep(id,cls,text){var li=$(id);li.className=cls;if(text!==undefined)li.querySelector(".t").textContent=text} function ready(){ $("install").disabled=!($("agree").checked&&$("token").value.trim().length>=30) } $("agree").addEventListener("change",ready); $("token").addEventListener("input",ready); $("show").addEventListener("change",function(){$("token").type=this.checked?"text":"password"}); document.querySelectorAll("[data-copy]").forEach(function(b){ b.addEventListener("click",async function(){ var v=$(b.getAttribute("data-copy")).textContent; try{await navigator.clipboard.writeText(v);b.textContent="\u05D4\u05D5\u05E2\u05EA\u05E7";$("live").textContent="\u05D4\u05D5\u05E2\u05EA\u05E7";setTimeout(function(){b.textContent="\u05D4\u05E2\u05EA\u05E7\u05D4"},2000)}catch(e){} }); }); function fail(stepId,code){ if(stepId)setStep(stepId,"bad"); $("error").textContent=msg(code);$("error").hidden=false; $("install").disabled=false;$("install").textContent="\u05E0\u05D9\u05E1\u05D9\u05D5\u05DF \u05E0\u05D5\u05E1\u05E3"; $("form").removeAttribute("aria-busy"); } async function waitSite(){ for(var i=0;i<60;i++){ await new Promise(function(r){setTimeout(r,i?2000:1500)}); try{var r=await fetch("/api/health",{cache:"no-store"});if(r.ok){var j=await r.json();if(j&&j.ok)return true}}catch(e){} } return false; } $("form").addEventListener("submit",async function(ev){ ev.preventDefault(); $("error").hidden=true;$("install").disabled=true;$("progress").hidden=false; $("form").setAttribute("aria-busy","true"); ["s1","s2","s3","s4","s5"].forEach(function(id){setStep(id,"")}); var token=$("token").value.trim(); var cur="s1"; try{ setStep("s1","run"); var chk=await call({step:"check",token:token,accountId:$("account").value||undefined}); if(chk.pick){ var sel=$("account");sel.innerHTML=""; chk.pick.forEach(function(a){var o=document.createElement("option");o.value=a.id;o.textContent=a.name;sel.appendChild(o)}); $("accountBox").hidden=false;setStep("s1","");$("progress").hidden=true; $("error").textContent=msg("bad_account");$("error").hidden=false;$("install").disabled=false;$("form").removeAttribute("aria-busy");sel.focus();return; } state={token:token,accountId:chk.accountId,version:chk.version,repair:chk.repair}; $("repairNote").hidden=!chk.repair; setStep("s1","ok","\u05D4\u05D8\u05D5\u05E7\u05DF \u05EA\u05E7\u05D9\u05DF (\u05D2\u05E8\u05E1\u05D4 "+chk.version+")"); cur="s2";setStep("s2","run"); var prep=await call({step:"prepare",token:token,accountId:state.accountId,version:state.version}); setStep("s2","ok"); cur="s3";var total=prep.total||0;var session=prep.session; setStep("s3","run","\u05DE\u05E2\u05DC\u05D9\u05DD \u05D0\u05EA \u05E7\u05D1\u05E6\u05D9 \u05D4\u05D0\u05EA\u05E8"+(total?" (0 \u05DE\u05EA\u05D5\u05DA "+total+")":"")); while(session.buckets.length){ var r=await call({step:"assets",token:token,accountId:state.accountId,version:state.version,session:session}); session=r.session; setStep("s3","run","\u05DE\u05E2\u05DC\u05D9\u05DD \u05D0\u05EA \u05E7\u05D1\u05E6\u05D9 \u05D4\u05D0\u05EA\u05E8 ("+(total-session.buckets.length)+" \u05DE\u05EA\u05D5\u05DA "+total+")"); } setStep("s3","ok","\u05E7\u05D1\u05E6\u05D9 \u05D4\u05D0\u05EA\u05E8 \u05D4\u05D5\u05E2\u05DC\u05D5"); cur="s4";setStep("s4","run"); var dep=await call({step:"deploy",token:token,accountId:state.accountId,version:state.version,dbId:prep.dbId,jwt:session.jwt}); setStep("s4","ok"); cur="s5";setStep("s5","run"); var up=await waitSite(); if(!up){fail("s5","network");$("error").textContent="\u05D4\u05D0\u05EA\u05E8 \u05D4\u05D5\u05EA\u05E7\u05DF, \u05D0\u05D1\u05DC \u05E2\u05D5\u05D3 \u05DC\u05D0 \u05E2\u05D5\u05E0\u05D4. \u05D7\u05DB\u05D5 \u05D3\u05E7\u05D4 \u05D5\u05E8\u05E2\u05E0\u05E0\u05D5 \u05D0\u05EA \u05D4\u05D3\u05E3.";return} setStep("s5","ok"); $("form").hidden=true;$("intro").hidden=true;$("done").hidden=false; if(dep.setupToken){ var link=location.origin+"/setup?token="+encodeURIComponent(dep.setupToken); $("link").textContent=link;$("code").textContent=dep.setupToken;$("go").href=link; }else{$("secrets").hidden=true;$("go").href=location.origin+"/setup"} $("done").focus(); }catch(e){fail(cur,e.code||"network")} }); })(); `,E=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/ \u05D4\u05EA\u05E7\u05E0\u05EA \u05D0\u05D9\u05E8\u05D5\u05E2 \u05E4\u05E8\u05D5\u05E2

\u05D4\u05EA\u05E7\u05E0\u05EA \u05D4\u05D0\u05EA\u05E8 \u05E9\u05DC\u05DB\u05DD

\u05D4\u05D3\u05E3 \u05D4\u05D6\u05D4 \u05E8\u05E5 \u05D1\u05D7\u05E9\u05D1\u05D5\u05DF Cloudflare \u05E9\u05DC\u05DB\u05DD \u05D5\u05DE\u05EA\u05E7\u05D9\u05DF \u05D1\u05D5 \u05D0\u05EA \u05D4\u05D0\u05EA\u05E8. \u05D4\u05D8\u05D5\u05E7\u05DF \u05E9\u05EA\u05D3\u05D1\u05D9\u05E7\u05D5 \u05E0\u05E9\u05D0\u05E8 \u05E8\u05E7 \u05D1\u05D7\u05E9\u05D1\u05D5\u05DF \u05E9\u05DC\u05DB\u05DD, \u05D5\u05D0\u05E3 \u05D0\u05D7\u05D3 \u05D0\u05D7\u05E8 (\u05D2\u05DD \u05DC\u05D0 \u05DE\u05E4\u05EA\u05D7 \u05D4\u05EA\u05D5\u05DB\u05E0\u05D4) \u05DC\u05D0 \u05E8\u05D5\u05D0\u05D4 \u05D0\u05D5\u05EA\u05D5.

\u05E8\u05D9\u05E9\u05D9\u05D5\u05DF \u05E9\u05D9\u05DE\u05D5\u05E9

  • \u05D4\u05EA\u05D5\u05DB\u05E0\u05D4 \u05E0\u05D9\u05EA\u05E0\u05EA \u05D1\u05D7\u05D9\u05E0\u05DD, \u05DB\u05DE\u05D5\u05EA \u05E9\u05D4\u05D9\u05D0 (AS IS), \u05D1\u05DC\u05D9 \u05D4\u05EA\u05D7\u05D9\u05D9\u05D1\u05D5\u05EA \u05D5\u05D1\u05DC\u05D9 \u05D0\u05D7\u05E8\u05D9\u05D5\u05EA \u05DE\u05E6\u05D3 \u05D4\u05DE\u05E4\u05EA\u05D7.
  • \u05D0\u05EA\u05DD \u05D4\u05D1\u05E2\u05DC\u05D9\u05DD \u05D5\u05D4\u05DE\u05E4\u05E2\u05D9\u05DC\u05D9\u05DD \u05E9\u05DC \u05D4\u05D0\u05EA\u05E8: \u05D4\u05D7\u05E9\u05D1\u05D5\u05E0\u05D5\u05EA, \u05D4\u05DE\u05D9\u05D3\u05E2 \u05E9\u05D1\u05D0\u05EA\u05E8 \u05D5\u05D4\u05D0\u05D7\u05E8\u05D9\u05D5\u05EA \u05DB\u05DC\u05E4\u05D9 \u05D4\u05DE\u05E9\u05EA\u05DE\u05E9\u05D9\u05DD \u05D5\u05D4\u05D0\u05D5\u05E8\u05D7\u05D9\u05DD \u05E9\u05DC\u05DB\u05DD \u05D4\u05DD \u05E9\u05DC\u05DB\u05DD \u05D1\u05DC\u05D1\u05D3.
  • \u05DE\u05E4\u05EA\u05D7 \u05D4\u05EA\u05D5\u05DB\u05E0\u05D4 \u05DC\u05D0 \u05DE\u05E4\u05E2\u05D9\u05DC \u05D0\u05EA \u05D4\u05D0\u05EA\u05E8 \u05E9\u05DC\u05DB\u05DD \u05D5\u05D0\u05D9\u05DF \u05DC\u05D5 \u05D2\u05D9\u05E9\u05D4 \u05DC\u05DE\u05D9\u05D3\u05E2 \u05E9\u05D1\u05D5.
  • \u05D4\u05D0\u05EA\u05E8 \u05D9\u05EA\u05E7\u05D9\u05DF \u05DC\u05D1\u05D3 \u05D2\u05E8\u05E1\u05D0\u05D5\u05EA \u05D7\u05D3\u05E9\u05D5\u05EA, \u05D1\u05DC\u05D9\u05DC\u05D4 \u05D5\u05DC\u05D0 \u05D1\u05D0\u05DE\u05E6\u05E2 \u05D0\u05D9\u05E8\u05D5\u05E2. \u05D0\u05E4\u05E9\u05E8 \u05DC\u05DB\u05D1\u05D5\u05EA \u05D0\u05EA \u05D6\u05D4 \u05D1\u05E0\u05D9\u05D4\u05D5\u05DC \u05D4\u05D0\u05EA\u05E8.
  • \u05DE\u05D5\u05EA\u05E8 \u05DC\u05D2\u05D1\u05D5\u05EA \u05DB\u05E1\u05E3 \u05DE\u05D4\u05DC\u05E7\u05D5\u05D7\u05D5\u05EA \u05E9\u05DC\u05DB\u05DD \u05E2\u05DC \u05D4\u05E9\u05D9\u05E8\u05D5\u05EA. \u05D0\u05E1\u05D5\u05E8 \u05DC\u05DE\u05DB\u05D5\u05E8, \u05DC\u05D4\u05E4\u05D9\u05E5 \u05D0\u05D5 \u05DC\u05E9\u05E0\u05D5\u05EA \u05D0\u05EA \u05D4\u05EA\u05D5\u05DB\u05E0\u05D4 \u05E2\u05E6\u05DE\u05D4.

\u05DC\u05E8\u05D9\u05E9\u05D9\u05D5\u05DF \u05D4\u05DE\u05DC\u05D0 (\u05E0\u05E4\u05EA\u05D7 \u05D1\u05D7\u05DC\u05D5\u05DF \u05D7\u05D3\u05E9)

\u05D8\u05D5\u05E7\u05DF \u05E9\u05DC Cloudflare

\u05D4\u05D0\u05EA\u05E8 \u05DE\u05E9\u05EA\u05DE\u05E9 \u05D1\u05D8\u05D5\u05E7\u05DF \u05DB\u05D3\u05D9 \u05DC\u05D9\u05E6\u05D5\u05E8 \u05D0\u05EA \u05DE\u05E1\u05D3 \u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD \u05E9\u05DC\u05D5, \u05D5\u05D0\u05D7\u05E8 \u05DB\u05DA \u05DB\u05D3\u05D9 \u05DC\u05D4\u05EA\u05E7\u05D9\u05DF \u05DC\u05E2\u05E6\u05DE\u05D5 \u05D2\u05E8\u05E1\u05D0\u05D5\u05EA \u05D7\u05D3\u05E9\u05D5\u05EA.

  1. \u05DC\u05D5\u05D7\u05E6\u05D9\u05DD \u05E2\u05DC \u05D4\u05DB\u05E4\u05EA\u05D5\u05E8. \u05E0\u05E4\u05EA\u05D7 \u05D3\u05E3 \u05D1-Cloudflare \u05E9\u05D1\u05D5 \u05D4\u05D4\u05E8\u05E9\u05D0\u05D5\u05EA \u05DB\u05D1\u05E8 \u05DE\u05E1\u05D5\u05DE\u05E0\u05D5\u05EA.
  2. \u05D2\u05D5\u05DC\u05DC\u05D9\u05DD \u05DC\u05DE\u05D8\u05D4 \u05D5\u05DC\u05D5\u05D7\u05E6\u05D9\u05DD Continue to summary, \u05D5\u05D0\u05D6 Create Token.
  3. \u05DC\u05D5\u05D7\u05E6\u05D9\u05DD Copy, \u05D7\u05D5\u05D6\u05E8\u05D9\u05DD \u05DC\u05DB\u05D0\u05DF \u05D5\u05DE\u05D3\u05D1\u05D9\u05E7\u05D9\u05DD.

\u05D9\u05E6\u05D9\u05E8\u05EA \u05D8\u05D5\u05E7\u05DF \u05D1-Cloudflare

\u05E8\u05E6\u05E3 \u05D0\u05E8\u05D5\u05DA \u05E9\u05DC \u05D0\u05D5\u05EA\u05D9\u05D5\u05EA \u05D5\u05DE\u05E1\u05E4\u05E8\u05D9\u05DD. \u05D4\u05D5\u05D0 \u05E0\u05E9\u05DE\u05E8 \u05DB\u05E1\u05D5\u05D3 \u05D1\u05D0\u05EA\u05E8 \u05E9\u05DC\u05DB\u05DD.

`}var pe=/^[0-9a-f]{32}$/,ue=/^[A-Za-z0-9_-]{30,200}$/,p=class extends Error{},ve=e=>`${(e.UPDATE_FEED_URL?.trim()||k).replace(/\/+$/,"")}/v1/`;function U(e,n){let t=j(new URL(e.url).hostname);if(!t)throw new p("wrong_host");let r=(n.token||"").trim();if(!ue.test(r))throw new p("bad_token");if(!n.accountId||!pe.test(n.accountId))throw new p("bad_account");return{token:r,accountId:n.accountId,script:t.script}}async function _e(e,n,t){let r=ve(n);switch(t.step){case"check":{let s=j(new URL(e.url).hostname);if(!s)throw new p("wrong_host");let a=(t.token||"").trim();if(!ue.test(a))throw new p("bad_token");let i=t.accountId&&pe.test(t.accountId)?t.accountId:"";if(!i){let f=await W(a);if(!f.length)throw new p("token_refused");if(f.length>1)return{pick:f};i=f[0].id}let d={token:a,accountId:i,script:s.script};if(await V(d)!==s.subdomain)throw new p("other_account");let c=await S(d),o=c.some(f=>f.name==="DB");if(!o&&c.some(f=>f.name==="TOKEN_ENC_KEY"||f.name==="SETUP_TOKEN"))throw new p("lost_db");o||await $e(d);let l=await ee(r,"stable");return{accountId:i,script:s.script,repair:o,version:l.latest.version}}case"prepare":{let s=U(e,t),a=await T(r,t.version||""),d=(await S(s)).some(o=>o.name==="DB")?null:await Z(s,`${s.script}-db`),c=await ne(s,a);return{dbId:d,session:c,total:c.buckets.length}}case"assets":{let s=U(e,t);if(!t.session||typeof t.session.jwt!="string"||!Array.isArray(t.session.buckets))throw new p("bad_request");let a=await T(r,t.version||"");return{session:await se(s,r,a,t.session,40)}}case"deploy":{let s=U(e,t);if(typeof t.jwt!="string"||!t.jwt)throw new p("bad_request");let a=await T(r,t.version||""),i=await te(r,a),d=re(a.bindings,await S(s),{d1Id:t.dbId||void 0,secrets:{CF_API_TOKEN:s.token},plain:{CF_ACCOUNT_ID:s.accountId,CF_SCRIPT_NAME:s.script}});if(d.missingDb.length)throw new p("no_database");let c=await ae(s,a,i,d.bindings,t.jwt);return await Q(s,c,`\u05D4\u05EA\u05E7\u05E0\u05D4: \u05D0\u05D9\u05E8\u05D5\u05E2 \u05E4\u05E8\u05D5\u05E2 ${a.version}`),await q(s,a.crons).catch(()=>{}),await Y(s).catch(()=>{}),await X(s,a.observability).catch(()=>{}),{setupToken:d.created.SETUP_TOKEN||n.SETUP_TOKEN||null,version:a.version}}}throw new p("bad_request")}async function $e(e){let n=await fetch(`https://api.cloudflare.com/client/v4/accounts/${e.accountId}/d1/database?per_page=1`,{headers:{Authorization:`Bearer ${e.token}`}});if(n.status===401||n.status===403)throw new p("no_d1")}function Ce(e){return e instanceof p?e.message:e instanceof u?e.code==="bad_signature"||e.code==="bad_hash"?"bad_signature":"release":e instanceof y?e.status===404?"other_account":e.refused?"token_refused":"cloudflare":"network"}var Me={async fetch(e,n){let t=new URL(e.url);if(e.method==="POST"&&t.pathname==="/__install"){let r;try{r=await e.json()}catch{return Response.json({error:"bad_request"},{status:400})}try{return Response.json(await _e(e,n,r))}catch(s){let a=Ce(s);return console.log(`install step ${r.step}: ${a} ${String(s?.message||s).slice(0,200)}`),Response.json({error:a,detail:String(s?.message||"").slice(0,200)},{status:400})}}return t.pathname.startsWith("/api/")?Response.json({installing:!0},{status:503}):e.method!=="GET"||t.pathname!=="/"?Response.redirect(`${t.origin}/`,302):new Response(le(),{headers:{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store","Content-Security-Policy":"default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; base-uri 'none'; form-action 'none'; frame-ancestors 'none'","Referrer-Policy":"no-referrer"}})}};export{Me as default};