utils-D0ctH_jZ.js 8.8 KB

1
  1. import{a as e}from"./client-BdOyoZJz.js";import{Y as t}from"./index-BoVbGTav.js";var n=[`PLA`,`PETG`,`ABS`,`TPU`,`ASA`,`PC`,`PA`,`PVA`,`HIPS`,`PA-CF`,`PETG-CF`,`PLA-CF`],r=[`Bambu`,`PolyLite`,`PolyTerra`,`eSUN`,`Overture`,`Fiberon`,`SUNLU`,`Inland`,`Hatchbox`,`Generic`],i=`Basic.Matte.Silk.Silk+.Tough.Tough+.HF.High Flow.Engineering.CF.GF.Galaxy.Glow.Marble.Metal.Rainbow.Sparkle.Wood.Translucent.Transparent.Clear.Lite.Pro.Plus.Max.Super.Ultra.Flex.Soft.Hard.Strong.Impact.Heat Resistant.UV Resistant.ESD.Conductive.Magnetic.Gradient.Dual Color.Tri Color.Multicolor`.split(`.`),a=[{name:`Black`,hex:`000000`},{name:`White`,hex:`FFFFFF`},{name:`Gray`,hex:`808080`},{name:`Red`,hex:`FF0000`},{name:`Orange`,hex:`FFA500`},{name:`Yellow`,hex:`FFFF00`},{name:`Green`,hex:`00AE42`},{name:`Blue`,hex:`0066FF`},{name:`Purple`,hex:`8B00FF`},{name:`Pink`,hex:`FF69B4`},{name:`Brown`,hex:`8B4513`},{name:`Silver`,hex:`C0C0C0`},{name:`Clear`,hex:`00000000`}],o=[{name:`Dark Red`,hex:`8B0000`},{name:`Crimson`,hex:`DC143C`},{name:`Coral`,hex:`FF7F50`},{name:`Salmon`,hex:`FA8072`},{name:`Dark Orange`,hex:`FF8C00`},{name:`Peach`,hex:`FFDAB9`},{name:`Gold`,hex:`FFD700`},{name:`Khaki`,hex:`F0E68C`},{name:`Lemon`,hex:`FFF44F`},{name:`Lime`,hex:`32CD32`},{name:`Forest Green`,hex:`228B22`},{name:`Olive`,hex:`808000`},{name:`Mint`,hex:`98FF98`},{name:`Teal`,hex:`008080`},{name:`Navy`,hex:`000080`},{name:`Sky Blue`,hex:`87CEEB`},{name:`Royal Blue`,hex:`4169E1`},{name:`Cyan`,hex:`00FFFF`},{name:`Turquoise`,hex:`40E0D0`},{name:`Violet`,hex:`EE82EE`},{name:`Magenta`,hex:`FF00FF`},{name:`Indigo`,hex:`4B0082`},{name:`Lavender`,hex:`E6E6FA`},{name:`Plum`,hex:`DDA0DD`},{name:`Hot Pink`,hex:`FF69B4`},{name:`Rose`,hex:`FF007F`},{name:`Blush`,hex:`FFB6C1`},{name:`Chocolate`,hex:`D2691E`},{name:`Tan`,hex:`D2B48C`},{name:`Beige`,hex:`F5F5DC`},{name:`Maroon`,hex:`800000`},{name:`Dark Gray`,hex:`404040`},{name:`Light Gray`,hex:`D3D3D3`},{name:`Charcoal`,hex:`36454F`},{name:`Ivory`,hex:`FFFFF0`},{name:`Bambu Green`,hex:`00AE42`},{name:`Jade White`,hex:`E8E8E8`},{name:`Titan Gray`,hex:`5A5A5A`}],s=[...a,...o],c=`bambuddy-recent-colors`,l=[`0.2`,`0.4`,`0.6`,`0.8`];async function u(n,r){let i=t(r),a=Array.from(new Set([...l,...i])),o=[];for(let t of a)o.push(await e.getKProfiles(n,t).catch(()=>null));let s=[];for(let e of o)if(e)for(let t of e.profiles)s.push({cali_idx:t.slot_id,filament_id:t.filament_id,setting_id:t.setting_id||``,name:t.name,k_value:parseFloat(t.k_value)||0,n_coef:parseFloat(t.n_coef)||0,extruder_id:t.extruder_id,nozzle_diameter:t.nozzle_diameter,nozzle_id:t.nozzle_id});return s}var d=[{code:`GFL00`,name:`Bambu PLA Basic`,displayName:`Bambu PLA Basic`,isCustom:!1,allCodes:[`GFL00`],source:`builtin`},{code:`GFL01`,name:`Bambu PLA Matte`,displayName:`Bambu PLA Matte`,isCustom:!1,allCodes:[`GFL01`],source:`builtin`},{code:`GFL05`,name:`Generic PLA`,displayName:`Generic PLA`,isCustom:!1,allCodes:[`GFL05`],source:`builtin`},{code:`GFG00`,name:`Bambu PETG Basic`,displayName:`Bambu PETG Basic`,isCustom:!1,allCodes:[`GFG00`],source:`builtin`},{code:`GFG05`,name:`Generic PETG`,displayName:`Generic PETG`,isCustom:!1,allCodes:[`GFG05`],source:`builtin`},{code:`GFB00`,name:`Bambu ABS Basic`,displayName:`Bambu ABS Basic`,isCustom:!1,allCodes:[`GFB00`],source:`builtin`},{code:`GFB05`,name:`Generic ABS`,displayName:`Generic ABS`,isCustom:!1,allCodes:[`GFB05`],source:`builtin`},{code:`GFA00`,name:`Bambu ASA Basic`,displayName:`Bambu ASA Basic`,isCustom:!1,allCodes:[`GFA00`],source:`builtin`},{code:`GFU00`,name:`Bambu TPU 95A`,displayName:`Bambu TPU 95A`,isCustom:!1,allCodes:[`GFU00`],source:`builtin`},{code:`GFU05`,name:`Generic TPU`,displayName:`Generic TPU`,isCustom:!1,allCodes:[`GFU05`],source:`builtin`},{code:`GFC00`,name:`Bambu PC Basic`,displayName:`Bambu PC Basic`,isCustom:!1,allCodes:[`GFC00`],source:`builtin`},{code:`GFN00`,name:`Bambu PA Basic`,displayName:`Bambu PA Basic`,isCustom:!1,allCodes:[`GFN00`],source:`builtin`},{code:`GFN05`,name:`Generic PA`,displayName:`Generic PA`,isCustom:!1,allCodes:[`GFN05`],source:`builtin`},{code:`GFS00`,name:`Bambu PLA-CF`,displayName:`Bambu PLA-CF`,isCustom:!1,allCodes:[`GFS00`],source:`builtin`},{code:`GFT00`,name:`Bambu PETG-CF`,displayName:`Bambu PETG-CF`,isCustom:!1,allCodes:[`GFT00`],source:`builtin`},{code:`GFNC0`,name:`Bambu PA-CF`,displayName:`Bambu PA-CF`,isCustom:!1,allCodes:[`GFNC0`],source:`builtin`},{code:`GFV00`,name:`Bambu PVA`,displayName:`Bambu PVA`,isCustom:!1,allCodes:[`GFV00`],source:`builtin`}];function f(e){let t=e.replace(/@.*$/,``).trim();t=t.replace(/\(Custom\)/i,``).trim(),t=t.replace(/^[#*]+\s*/,``).trim();let n=`PLA-CF.PETG-CF.ABS-GF.ASA-CF.PA-CF.PAHT-CF.PA6-CF.PA6-GF.PPA-CF.PPA-GF.PET-CF.PPS-CF.PC-CF.PC-ABS.ABS-GF.PCTG.PETG.PLA.ABS.ASA.PC.PA.TPU.PVA.HIPS.BVOH.PPS.PEEK.PEI`.split(`.`),r=``,a=-1;for(let e of n){let n=t.toUpperCase().indexOf(e.toUpperCase());if(n!==-1){r=e,a=n;break}}let o=``;a>0&&(o=t.substring(0,a).trim(),o=o.replace(/[-_\s]+$/,``));let s=``;a!==-1&&r&&(s=t.substring(a+r.length).trim(),s=s.replace(/^[-_\s]+/,``));let c=``;for(let e of i)if(s.toLowerCase().includes(e.toLowerCase())){c=e;break}if(!c&&o)for(let e of i){let t=RegExp(`\\s+${e}$`,`i`);if(t.test(o)){c=e,o=o.replace(t,``).trim();break}}return{brand:o,material:r,variant:c}}function p(e,t){let n=new Set(r);for(let t of e){let{brand:e}=f(t.name);e&&e.length>1&&n.add(e)}if(t)for(let e of t)if(e.filament_vendor&&e.filament_vendor.length>1)n.add(e.filament_vendor);else{let{brand:t}=f(e.name);t&&t.length>1&&n.add(t)}return Array.from(n).sort((e,t)=>e.localeCompare(t))}function m(e){let t=e.filter(e=>e.preset_type===`filament`);return t.length===0?[]:t.map(e=>{let t=String(e.id),n=e.filament_type||t,r=Array.from(new Set([t,n]));return{code:t,name:e.name,displayName:e.name,isCustom:!1,allCodes:r,source:`local`}}).sort((e,t)=>e.displayName.localeCompare(t.displayName))}function h(e,t,n,r,i){let a=[],o=[],s=new Set;for(let n of e)if(n.is_custom){let e=n.name.toUpperCase();(t.size===0||Array.from(t).some(t=>e.includes(t))||!e.includes(`@`))&&(a.push({code:n.setting_id,name:n.name,displayName:`${n.name} (Custom)`,isCustom:!0,allCodes:[n.setting_id],source:i?.has(n.setting_id)?`orca_cloud`:`cloud`}),s.add(n.setting_id))}else o.push({code:n.setting_id,name:n.name,displayName:n.name,isCustom:!1,allCodes:[n.setting_id],source:i?.has(n.setting_id)?`orca_cloud`:`cloud`}),s.add(n.setting_id);let c=n&&n.length>0?m(n):[],l=[];if(r&&r.length>0)for(let e of r){let t=e.filament_id.startsWith(`GF`)?`GFS`+e.filament_id.slice(2):e.filament_id;s.has(e.filament_id)||s.has(t)||l.push({code:e.filament_id,name:e.name,displayName:e.name,isCustom:!1,allCodes:[e.filament_id,t],source:`builtin`})}let u=[...a,...o,...c,...l];return u.length===0?d:u.sort((e,t)=>e.displayName.localeCompare(t.displayName))}function g(e,t){if(!e)return;let n=t.find(t=>t.code===e);if(n||=t.find(t=>t.allCodes.includes(e)),!n){let r=e.toLowerCase();n=t.find(e=>e.code.toLowerCase()===r||e.allCodes.some(e=>e.toLowerCase()===r))}return n}function _(e,t){let n=t.trim();return!n||e.some(e=>e.toLowerCase()===n.toLowerCase())?e:[...e,n].sort((e,t)=>e.localeCompare(t))}function v(e,t,n){if(!t)return[];let r=n.get(t.toLowerCase());return!r||r.size===0?[]:e.filter(e=>r.has(e.toLowerCase()))}function y(){try{let e=localStorage.getItem(c);if(e)return JSON.parse(e)}catch{}return[]}function b(e,t){let n=[e,...t.filter(t=>t.hex.toUpperCase()!==e.hex.toUpperCase())].slice(0,8);try{localStorage.setItem(c,JSON.stringify(n))}catch{}return n}function x(e){if(!e)return``;let t=e.split(`_`)[0];return/^GFS/i.test(t)&&(t=t.slice(0,2)+t.slice(3)),t.toUpperCase()}function S(e){return!!e&&/^GF[A-Z]99$/i.test(e)}var C={GFB99:`ABS`,GFC99:`PC`,GFG99:`PETG`,GFL99:`PLA`,GFN99:`PA`,GFP99:`PE`,GFR99:`EVA`,GFS99:`PVA`,GFU99:`TPU`};function w(e){return e&&C[e.toUpperCase()]||``}function T(e){let t=e.trim().toUpperCase();return t===`NYLON`?`PA`:t}function E(e,t){let n=w(e);return!!n&&!!t&&T(n)===T(t)}function D(e,t,n){return`${e}:${t}:${n}`}function O(e,t){return`${e}\u0000${t}`}function k(e){let[t=``,n=``]=e.split(`\0`);return{model:t,diameter:n}}function A(e,t){if(!t.material)return!1;let n=x(t.slicer_filament),r=x(e.filament_id);if(n&&r&&n===r){if(!S(r))return!0;let e=t.brand.trim();if((!e||e.toUpperCase()===`GENERIC`)&&E(r,t.material))return!0}let i=(e.name||``).replace(/^High Flow[_\s]+/i,``).replace(/^Standard[_\s]+/i,``).replace(/^HF[_\s]+/i,``).replace(/^S[_\s]+/i,``).trim(),a=f(i);return!(a.material.toUpperCase()!==t.material.toUpperCase()||t.brand&&!(a.brand.toLowerCase().includes(t.brand.toLowerCase())||t.brand.toLowerCase().includes(a.brand.toLowerCase()))||t.subtype&&!(a.variant.toLowerCase().includes(t.subtype.toLowerCase())||t.subtype.toLowerCase().includes(a.variant.toLowerCase())||i.toLowerCase().includes(t.subtype.toLowerCase())))}export{i as _,D as a,l as b,v as c,O as d,b as f,r as g,s as h,g as i,k as l,_ as m,p as n,A as o,x as p,u as r,y as s,h as t,f as u,n as v,a as y};